doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GEInsertModifier.cpp
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 
29 #include "../../idlib/precompiled.h"
30 #pragma hdrstop
31 
32 #include "GEApp.h"
33 #include "GEInsertModifier.h"
34 
36  rvGEModifier ( name, window )
37 {
38  mParent = parent;
39  mBefore = before;
40 
41  assert ( mParent );
42 
43  mUndoParent = window->GetParent ( );
44  mUndoBefore = NULL;
47 
48  // Find the child window the window being inserted is before
49  if ( mUndoParent )
50  {
51  int index;
52  rvGEWindowWrapper* pwrapper;
53 
55 
56  index = mUndoParent->GetChildIndex ( mWindow );
57 
58  if ( index + 1 < pwrapper->GetChildCount ( ) )
59  {
60  mUndoBefore = pwrapper->GetChild ( index + 1 );
61  }
62  }
63 
64  // Since rectangles are relative to the parent rectangle we need to figure
65  // out the new x and y coordinate as if this window were a child
66  rvGEWindowWrapper* parentWrapper;
67  parentWrapper = rvGEWindowWrapper::GetWrapper ( mParent );
68  mRect.x = mWrapper->GetScreenRect( )[0] - parentWrapper->GetScreenRect()[0];
69  mRect.y = mWrapper->GetScreenRect( )[1] - parentWrapper->GetScreenRect()[1];
70 }
71 
72 /*
73 ================
74 rvGEInsertModifier::Apply
75 
76 Apply the insert modifier by removing the child from its original parent and
77 inserting it as a child of the new parent
78 ================
79 */
81 {
82  if ( mUndoParent )
83  {
85  }
86 
88  mWrapper->SetRect ( mRect );
89 
90  return true;
91 }
92 
93 /*
94 ================
95 rvGEInsertModifier::Undo
96 
97 Undo the insert modifier by removing the window from the parent it was
98 added to and re-inserting it back into its original parent
99 ================
100 */
102 {
104 
105  if ( mUndoParent )
106  {
109  }
110 
111  return true;
112 }
113 
rvGEInsertModifier(const char *name, idWindow *window, idWindow *parent, idWindow *before)
assert(prefInfo.fullscreenBtn)
idWindow * mWindow
Definition: GEModifier.h:55
rvGEWindowWrapper * mWrapper
Definition: GEModifier.h:56
idWindow * GetChild(int index)
GLuint index
Definition: glext.h:3476
idRectangle & GetClientRect(void)
float y
Definition: Rectangle.h:37
#define NULL
Definition: Lib.h:88
idRectangle & GetScreenRect(void)
void RemoveChild(idWindow *win)
Definition: Window.cpp:4066
float x
Definition: Rectangle.h:36
prefInfo window
virtual bool Undo(void)
static rvGEWindowWrapper * GetWrapper(idWindow *window)
const GLcharARB * name
Definition: glext.h:3629
bool InsertChild(idWindow *win, idWindow *before)
Definition: Window.cpp:4089
int GetChildIndex(idWindow *window)
Definition: Window.cpp:4048
void SetRect(idRectangle &rect)
idWindow * GetParent()
Definition: Window.h:224
virtual bool Apply(void)