aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CGUIWindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CGUIWindow.cpp808
1 files changed, 404 insertions, 404 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CGUIWindow.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CGUIWindow.cpp
index 9769750..8776130 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CGUIWindow.cpp
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CGUIWindow.cpp
@@ -1,404 +1,404 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt 1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine". 2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h 3// For conditions of distribution and use, see copyright notice in irrlicht.h
4 4
5#include "CGUIWindow.h" 5#include "CGUIWindow.h"
6#ifdef _IRR_COMPILE_WITH_GUI_ 6#ifdef _IRR_COMPILE_WITH_GUI_
7 7
8#include "IGUISkin.h" 8#include "IGUISkin.h"
9#include "IGUIEnvironment.h" 9#include "IGUIEnvironment.h"
10#include "IVideoDriver.h" 10#include "IVideoDriver.h"
11#include "IGUIButton.h" 11#include "IGUIButton.h"
12#include "IGUIFont.h" 12#include "IGUIFont.h"
13#include "IGUIFontBitmap.h" 13#include "IGUIFontBitmap.h"
14 14
15namespace irr 15namespace irr
16{ 16{
17namespace gui 17namespace gui
18{ 18{
19 19
20//! constructor 20//! constructor
21CGUIWindow::CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) 21CGUIWindow::CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
22: IGUIWindow(environment, parent, id, rectangle), Dragging(false), IsDraggable(true), DrawBackground(true), DrawTitlebar(true), IsActive(false) 22: IGUIWindow(environment, parent, id, rectangle), Dragging(false), IsDraggable(true), DrawBackground(true), DrawTitlebar(true), IsActive(false)
23{ 23{
24 #ifdef _DEBUG 24 #ifdef _DEBUG
25 setDebugName("CGUIWindow"); 25 setDebugName("CGUIWindow");
26 #endif 26 #endif
27 27
28 IGUISkin* skin = 0; 28 IGUISkin* skin = 0;
29 if (environment) 29 if (environment)
30 skin = environment->getSkin(); 30 skin = environment->getSkin();
31 31
32 CurrentIconColor = video::SColor(255,255,255,255); 32 CurrentIconColor = video::SColor(255,255,255,255);
33 33
34 s32 buttonw = 15; 34 s32 buttonw = 15;
35 if (skin) 35 if (skin)
36 { 36 {
37 buttonw = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); 37 buttonw = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH);
38 } 38 }
39 s32 posx = RelativeRect.getWidth() - buttonw - 4; 39 s32 posx = RelativeRect.getWidth() - buttonw - 4;
40 40
41 CloseButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1, 41 CloseButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1,
42 L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close" ); 42 L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close" );
43 CloseButton->setSubElement(true); 43 CloseButton->setSubElement(true);
44 CloseButton->setTabStop(false); 44 CloseButton->setTabStop(false);
45 CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); 45 CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
46 posx -= buttonw + 2; 46 posx -= buttonw + 2;
47 47
48 RestoreButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1, 48 RestoreButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1,
49 L"", skin ? skin->getDefaultText(EGDT_WINDOW_RESTORE) : L"Restore" ); 49 L"", skin ? skin->getDefaultText(EGDT_WINDOW_RESTORE) : L"Restore" );
50 RestoreButton->setVisible(false); 50 RestoreButton->setVisible(false);
51 RestoreButton->setSubElement(true); 51 RestoreButton->setSubElement(true);
52 RestoreButton->setTabStop(false); 52 RestoreButton->setTabStop(false);
53 RestoreButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); 53 RestoreButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
54 posx -= buttonw + 2; 54 posx -= buttonw + 2;
55 55
56 MinButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1, 56 MinButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1,
57 L"", skin ? skin->getDefaultText(EGDT_WINDOW_MINIMIZE) : L"Minimize" ); 57 L"", skin ? skin->getDefaultText(EGDT_WINDOW_MINIMIZE) : L"Minimize" );
58 MinButton->setVisible(false); 58 MinButton->setVisible(false);
59 MinButton->setSubElement(true); 59 MinButton->setSubElement(true);
60 MinButton->setTabStop(false); 60 MinButton->setTabStop(false);
61 MinButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); 61 MinButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
62 62
63 MinButton->grab(); 63 MinButton->grab();
64 RestoreButton->grab(); 64 RestoreButton->grab();
65 CloseButton->grab(); 65 CloseButton->grab();
66 66
67 // this element is a tab group 67 // this element is a tab group
68 setTabGroup(true); 68 setTabGroup(true);
69 setTabStop(true); 69 setTabStop(true);
70 setTabOrder(-1); 70 setTabOrder(-1);
71 71
72 refreshSprites(); 72 refreshSprites();
73 updateClientRect(); 73 updateClientRect();
74} 74}
75 75
76 76
77//! destructor 77//! destructor
78CGUIWindow::~CGUIWindow() 78CGUIWindow::~CGUIWindow()
79{ 79{
80 if (MinButton) 80 if (MinButton)
81 MinButton->drop(); 81 MinButton->drop();
82 82
83 if (RestoreButton) 83 if (RestoreButton)
84 RestoreButton->drop(); 84 RestoreButton->drop();
85 85
86 if (CloseButton) 86 if (CloseButton)
87 CloseButton->drop(); 87 CloseButton->drop();
88} 88}
89 89
90void CGUIWindow::refreshSprites() 90void CGUIWindow::refreshSprites()
91{ 91{
92 if (!Environment) 92 if (!Environment)
93 return; 93 return;
94 IGUISkin* skin = Environment->getSkin(); 94 IGUISkin* skin = Environment->getSkin();
95 if ( !skin ) 95 if ( !skin )
96 return; 96 return;
97 97
98 IGUISpriteBank* sprites = skin->getSpriteBank(); 98 IGUISpriteBank* sprites = skin->getSpriteBank();
99 if ( !sprites ) 99 if ( !sprites )
100 return; 100 return;
101 101
102 CurrentIconColor = skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL); 102 CurrentIconColor = skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL);
103 103
104 if (sprites) 104 if (sprites)
105 { 105 {
106 CloseButton->setSpriteBank(sprites); 106 CloseButton->setSpriteBank(sprites);
107 CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), CurrentIconColor); 107 CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), CurrentIconColor);
108 CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), CurrentIconColor); 108 CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), CurrentIconColor);
109 109
110 RestoreButton->setSpriteBank(sprites); 110 RestoreButton->setSpriteBank(sprites);
111 RestoreButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_RESTORE), CurrentIconColor); 111 RestoreButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_RESTORE), CurrentIconColor);
112 RestoreButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_RESTORE), CurrentIconColor); 112 RestoreButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_RESTORE), CurrentIconColor);
113 113
114 MinButton->setSpriteBank(sprites); 114 MinButton->setSpriteBank(sprites);
115 MinButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_MINIMIZE), CurrentIconColor); 115 MinButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_MINIMIZE), CurrentIconColor);
116 MinButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_MINIMIZE), CurrentIconColor); 116 MinButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_MINIMIZE), CurrentIconColor);
117 } 117 }
118} 118}
119 119
120//! called if an event happened. 120//! called if an event happened.
121bool CGUIWindow::OnEvent(const SEvent& event) 121bool CGUIWindow::OnEvent(const SEvent& event)
122{ 122{
123 if (isEnabled()) 123 if (isEnabled())
124 { 124 {
125 125
126 switch(event.EventType) 126 switch(event.EventType)
127 { 127 {
128 case EET_GUI_EVENT: 128 case EET_GUI_EVENT:
129 if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) 129 if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST)
130 { 130 {
131 Dragging = false; 131 Dragging = false;
132 IsActive = false; 132 IsActive = false;
133 } 133 }
134 else 134 else
135 if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUSED) 135 if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUSED)
136 { 136 {
137 if (Parent && ((event.GUIEvent.Caller == this) || isMyChild(event.GUIEvent.Caller))) 137 if (Parent && ((event.GUIEvent.Caller == this) || isMyChild(event.GUIEvent.Caller)))
138 { 138 {
139 Parent->bringToFront(this); 139 Parent->bringToFront(this);
140 IsActive = true; 140 IsActive = true;
141 } 141 }
142 else 142 else
143 { 143 {
144 IsActive = false; 144 IsActive = false;
145 } 145 }
146 } 146 }
147 else 147 else
148 if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED) 148 if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED)
149 { 149 {
150 if (event.GUIEvent.Caller == CloseButton) 150 if (event.GUIEvent.Caller == CloseButton)
151 { 151 {
152 if (Parent) 152 if (Parent)
153 { 153 {
154 // send close event to parent 154 // send close event to parent
155 SEvent e; 155 SEvent e;
156 e.EventType = EET_GUI_EVENT; 156 e.EventType = EET_GUI_EVENT;
157 e.GUIEvent.Caller = this; 157 e.GUIEvent.Caller = this;
158 e.GUIEvent.Element = 0; 158 e.GUIEvent.Element = 0;
159 e.GUIEvent.EventType = EGET_ELEMENT_CLOSED; 159 e.GUIEvent.EventType = EGET_ELEMENT_CLOSED;
160 160
161 // if the event was not absorbed 161 // if the event was not absorbed
162 if (!Parent->OnEvent(e)) 162 if (!Parent->OnEvent(e))
163 remove(); 163 remove();
164 164
165 return true; 165 return true;
166 166
167 } 167 }
168 else 168 else
169 { 169 {
170 remove(); 170 remove();
171 return true; 171 return true;
172 } 172 }
173 } 173 }
174 } 174 }
175 break; 175 break;
176 case EET_MOUSE_INPUT_EVENT: 176 case EET_MOUSE_INPUT_EVENT:
177 switch(event.MouseInput.Event) 177 switch(event.MouseInput.Event)
178 { 178 {
179 case EMIE_LMOUSE_PRESSED_DOWN: 179 case EMIE_LMOUSE_PRESSED_DOWN:
180 DragStart.X = event.MouseInput.X; 180 DragStart.X = event.MouseInput.X;
181 DragStart.Y = event.MouseInput.Y; 181 DragStart.Y = event.MouseInput.Y;
182 Dragging = IsDraggable; 182 Dragging = IsDraggable;
183 if (Parent) 183 if (Parent)
184 Parent->bringToFront(this); 184 Parent->bringToFront(this);
185 return true; 185 return true;
186 case EMIE_LMOUSE_LEFT_UP: 186 case EMIE_LMOUSE_LEFT_UP:
187 Dragging = false; 187 Dragging = false;
188 return true; 188 return true;
189 case EMIE_MOUSE_MOVED: 189 case EMIE_MOUSE_MOVED:
190 if (!event.MouseInput.isLeftPressed()) 190 if (!event.MouseInput.isLeftPressed())
191 Dragging = false; 191 Dragging = false;
192 192
193 if (Dragging) 193 if (Dragging)
194 { 194 {
195 // gui window should not be dragged outside its parent 195 // gui window should not be dragged outside its parent
196 if (Parent && 196 if (Parent &&
197 (event.MouseInput.X < Parent->getAbsolutePosition().UpperLeftCorner.X +1 || 197 (event.MouseInput.X < Parent->getAbsolutePosition().UpperLeftCorner.X +1 ||
198 event.MouseInput.Y < Parent->getAbsolutePosition().UpperLeftCorner.Y +1 || 198 event.MouseInput.Y < Parent->getAbsolutePosition().UpperLeftCorner.Y +1 ||
199 event.MouseInput.X > Parent->getAbsolutePosition().LowerRightCorner.X -1 || 199 event.MouseInput.X > Parent->getAbsolutePosition().LowerRightCorner.X -1 ||
200 event.MouseInput.Y > Parent->getAbsolutePosition().LowerRightCorner.Y -1)) 200 event.MouseInput.Y > Parent->getAbsolutePosition().LowerRightCorner.Y -1))
201 return true; 201 return true;
202 202
203 move(core::position2d<s32>(event.MouseInput.X - DragStart.X, event.MouseInput.Y - DragStart.Y)); 203 move(core::position2d<s32>(event.MouseInput.X - DragStart.X, event.MouseInput.Y - DragStart.Y));
204 DragStart.X = event.MouseInput.X; 204 DragStart.X = event.MouseInput.X;
205 DragStart.Y = event.MouseInput.Y; 205 DragStart.Y = event.MouseInput.Y;
206 return true; 206 return true;
207 } 207 }
208 break; 208 break;
209 default: 209 default:
210 break; 210 break;
211 } 211 }
212 default: 212 default:
213 break; 213 break;
214 } 214 }
215 } 215 }
216 216
217 return IGUIElement::OnEvent(event); 217 return IGUIElement::OnEvent(event);
218} 218}
219 219
220 220
221//! Updates the absolute position. 221//! Updates the absolute position.
222void CGUIWindow::updateAbsolutePosition() 222void CGUIWindow::updateAbsolutePosition()
223{ 223{
224 IGUIElement::updateAbsolutePosition(); 224 IGUIElement::updateAbsolutePosition();
225} 225}
226 226
227 227
228//! draws the element and its children 228//! draws the element and its children
229void CGUIWindow::draw() 229void CGUIWindow::draw()
230{ 230{
231 if (IsVisible) 231 if (IsVisible)
232 { 232 {
233 IGUISkin* skin = Environment->getSkin(); 233 IGUISkin* skin = Environment->getSkin();
234 234
235 235
236 // update each time because the skin is allowed to change this always. 236 // update each time because the skin is allowed to change this always.
237 updateClientRect(); 237 updateClientRect();
238 238
239 if ( CurrentIconColor != skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL) ) 239 if ( CurrentIconColor != skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL) )
240 refreshSprites(); 240 refreshSprites();
241 241
242 core::rect<s32> rect = AbsoluteRect; 242 core::rect<s32> rect = AbsoluteRect;
243 243
244 // draw body fast 244 // draw body fast
245 if (DrawBackground) 245 if (DrawBackground)
246 { 246 {
247 rect = skin->draw3DWindowBackground(this, DrawTitlebar, 247 rect = skin->draw3DWindowBackground(this, DrawTitlebar,
248 skin->getColor(IsActive ? EGDC_ACTIVE_BORDER : EGDC_INACTIVE_BORDER), 248 skin->getColor(IsActive ? EGDC_ACTIVE_BORDER : EGDC_INACTIVE_BORDER),
249 AbsoluteRect, &AbsoluteClippingRect); 249 AbsoluteRect, &AbsoluteClippingRect);
250 250
251 if (DrawTitlebar && Text.size()) 251 if (DrawTitlebar && Text.size())
252 { 252 {
253 rect.UpperLeftCorner.X += skin->getSize(EGDS_TITLEBARTEXT_DISTANCE_X); 253 rect.UpperLeftCorner.X += skin->getSize(EGDS_TITLEBARTEXT_DISTANCE_X);
254 rect.UpperLeftCorner.Y += skin->getSize(EGDS_TITLEBARTEXT_DISTANCE_Y); 254 rect.UpperLeftCorner.Y += skin->getSize(EGDS_TITLEBARTEXT_DISTANCE_Y);
255 rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5; 255 rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5;
256 256
257 IGUIFont* font = skin->getFont(EGDF_WINDOW); 257 IGUIFont* font = skin->getFont(EGDF_WINDOW);
258 if (font) 258 if (font)
259 { 259 {
260 font->draw(Text.c_str(), rect, 260 font->draw(Text.c_str(), rect,
261 skin->getColor(IsActive ? EGDC_ACTIVE_CAPTION:EGDC_INACTIVE_CAPTION), 261 skin->getColor(IsActive ? EGDC_ACTIVE_CAPTION:EGDC_INACTIVE_CAPTION),
262 false, true, &AbsoluteClippingRect); 262 false, true, &AbsoluteClippingRect);
263 } 263 }
264 } 264 }
265 } 265 }
266 } 266 }
267 267
268 IGUIElement::draw(); 268 IGUIElement::draw();
269} 269}
270 270
271 271
272//! Returns pointer to the close button 272//! Returns pointer to the close button
273IGUIButton* CGUIWindow::getCloseButton() const 273IGUIButton* CGUIWindow::getCloseButton() const
274{ 274{
275 return CloseButton; 275 return CloseButton;
276} 276}
277 277
278 278
279//! Returns pointer to the minimize button 279//! Returns pointer to the minimize button
280IGUIButton* CGUIWindow::getMinimizeButton() const 280IGUIButton* CGUIWindow::getMinimizeButton() const
281{ 281{
282 return MinButton; 282 return MinButton;
283} 283}
284 284
285 285
286//! Returns pointer to the maximize button 286//! Returns pointer to the maximize button
287IGUIButton* CGUIWindow::getMaximizeButton() const 287IGUIButton* CGUIWindow::getMaximizeButton() const
288{ 288{
289 return RestoreButton; 289 return RestoreButton;
290} 290}
291 291
292 292
293//! Returns true if the window is draggable, false if not 293//! Returns true if the window is draggable, false if not
294bool CGUIWindow::isDraggable() const 294bool CGUIWindow::isDraggable() const
295{ 295{
296 return IsDraggable; 296 return IsDraggable;
297} 297}
298 298
299 299
300//! Sets whether the window is draggable 300//! Sets whether the window is draggable
301void CGUIWindow::setDraggable(bool draggable) 301void CGUIWindow::setDraggable(bool draggable)
302{ 302{
303 IsDraggable = draggable; 303 IsDraggable = draggable;
304 304
305 if (Dragging && !IsDraggable) 305 if (Dragging && !IsDraggable)
306 Dragging = false; 306 Dragging = false;
307} 307}
308 308
309 309
310//! Set if the window background will be drawn 310//! Set if the window background will be drawn
311void CGUIWindow::setDrawBackground(bool draw) 311void CGUIWindow::setDrawBackground(bool draw)
312{ 312{
313 DrawBackground = draw; 313 DrawBackground = draw;
314} 314}
315 315
316 316
317//! Get if the window background will be drawn 317//! Get if the window background will be drawn
318bool CGUIWindow::getDrawBackground() const 318bool CGUIWindow::getDrawBackground() const
319{ 319{
320 return DrawBackground; 320 return DrawBackground;
321} 321}
322 322
323 323
324//! Set if the window titlebar will be drawn 324//! Set if the window titlebar will be drawn
325void CGUIWindow::setDrawTitlebar(bool draw) 325void CGUIWindow::setDrawTitlebar(bool draw)
326{ 326{
327 DrawTitlebar = draw; 327 DrawTitlebar = draw;
328} 328}
329 329
330 330
331//! Get if the window titlebar will be drawn 331//! Get if the window titlebar will be drawn
332bool CGUIWindow::getDrawTitlebar() const 332bool CGUIWindow::getDrawTitlebar() const
333{ 333{
334 return DrawTitlebar; 334 return DrawTitlebar;
335} 335}
336 336
337 337
338void CGUIWindow::updateClientRect() 338void CGUIWindow::updateClientRect()
339{ 339{
340 if (! DrawBackground ) 340 if (! DrawBackground )
341 { 341 {
342 ClientRect = core::rect<s32>(0,0, AbsoluteRect.getWidth(), AbsoluteRect.getHeight()); 342 ClientRect = core::rect<s32>(0,0, AbsoluteRect.getWidth(), AbsoluteRect.getHeight());
343 return; 343 return;
344 } 344 }
345 IGUISkin* skin = Environment->getSkin(); 345 IGUISkin* skin = Environment->getSkin();
346 skin->draw3DWindowBackground(this, DrawTitlebar, 346 skin->draw3DWindowBackground(this, DrawTitlebar,
347 skin->getColor(IsActive ? EGDC_ACTIVE_BORDER : EGDC_INACTIVE_BORDER), 347 skin->getColor(IsActive ? EGDC_ACTIVE_BORDER : EGDC_INACTIVE_BORDER),
348 AbsoluteRect, &AbsoluteClippingRect, &ClientRect); 348 AbsoluteRect, &AbsoluteClippingRect, &ClientRect);
349 ClientRect -= AbsoluteRect.UpperLeftCorner; 349 ClientRect -= AbsoluteRect.UpperLeftCorner;
350} 350}
351 351
352 352
353//! Returns the rectangle of the drawable area (without border, without titlebar and without scrollbars) 353//! Returns the rectangle of the drawable area (without border, without titlebar and without scrollbars)
354core::rect<s32> CGUIWindow::getClientRect() const 354core::rect<s32> CGUIWindow::getClientRect() const
355{ 355{
356 return ClientRect; 356 return ClientRect;
357} 357}
358 358
359 359
360//! Writes attributes of the element. 360//! Writes attributes of the element.
361void CGUIWindow::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const 361void CGUIWindow::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
362{ 362{
363 IGUIWindow::serializeAttributes(out,options); 363 IGUIWindow::serializeAttributes(out,options);
364 364
365 out->addBool("IsDraggable", IsDraggable); 365 out->addBool("IsDraggable", IsDraggable);
366 out->addBool("DrawBackground", DrawBackground); 366 out->addBool("DrawBackground", DrawBackground);
367 out->addBool("DrawTitlebar", DrawTitlebar); 367 out->addBool("DrawTitlebar", DrawTitlebar);
368 368
369 // Currently we can't just serialize attributes of sub-elements. 369 // Currently we can't just serialize attributes of sub-elements.
370 // To do this we either 370 // To do this we either
371 // a) allow further serialization after attribute serialiation (second function, callback or event) 371 // a) allow further serialization after attribute serialiation (second function, callback or event)
372 // b) add an IGUIElement attribute 372 // b) add an IGUIElement attribute
373 // c) extend the attribute system to allow attributes to have sub-attributes 373 // c) extend the attribute system to allow attributes to have sub-attributes
374 // We just serialize the most important info for now until we can do one of the above solutions. 374 // We just serialize the most important info for now until we can do one of the above solutions.
375 out->addBool("IsCloseVisible", CloseButton->isVisible()); 375 out->addBool("IsCloseVisible", CloseButton->isVisible());
376 out->addBool("IsMinVisible", MinButton->isVisible()); 376 out->addBool("IsMinVisible", MinButton->isVisible());
377 out->addBool("IsRestoreVisible", RestoreButton->isVisible()); 377 out->addBool("IsRestoreVisible", RestoreButton->isVisible());
378} 378}
379 379
380 380
381//! Reads attributes of the element 381//! Reads attributes of the element
382void CGUIWindow::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) 382void CGUIWindow::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
383{ 383{
384IGUIWindow::deserializeAttributes(in,options); 384IGUIWindow::deserializeAttributes(in,options);
385 385
386 Dragging = false; 386 Dragging = false;
387 IsActive = false; 387 IsActive = false;
388 IsDraggable = in->getAttributeAsBool("IsDraggable"); 388 IsDraggable = in->getAttributeAsBool("IsDraggable");
389 DrawBackground = in->getAttributeAsBool("DrawBackground"); 389 DrawBackground = in->getAttributeAsBool("DrawBackground");
390 DrawTitlebar = in->getAttributeAsBool("DrawTitlebar"); 390 DrawTitlebar = in->getAttributeAsBool("DrawTitlebar");
391 391
392 CloseButton->setVisible(in->getAttributeAsBool("IsCloseVisible")); 392 CloseButton->setVisible(in->getAttributeAsBool("IsCloseVisible"));
393 MinButton->setVisible(in->getAttributeAsBool("IsMinVisible")); 393 MinButton->setVisible(in->getAttributeAsBool("IsMinVisible"));
394 RestoreButton->setVisible(in->getAttributeAsBool("IsRestoreVisible")); 394 RestoreButton->setVisible(in->getAttributeAsBool("IsRestoreVisible"));
395 395
396 updateClientRect(); 396 updateClientRect();
397} 397}
398 398
399 399
400} // end namespace gui 400} // end namespace gui
401} // end namespace irr 401} // end namespace irr
402 402
403#endif // _IRR_COMPILE_WITH_GUI_ 403#endif // _IRR_COMPILE_WITH_GUI_
404 404