1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
\r
2 // This file is part of the "Irrlicht Engine".
\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
\r
5 #include "CGUISkin.h"
\r
6 #ifdef _IRR_COMPILE_WITH_GUI_
\r
8 #include "IGUIFont.h"
\r
9 #include "IGUISpriteBank.h"
\r
10 #include "IGUIElement.h"
\r
11 #include "IVideoDriver.h"
\r
12 #include "IAttributes.h"
\r
19 CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver)
\r
20 : SpriteBank(0), Driver(driver), Type(type)
\r
23 setDebugName("CGUISkin");
\r
26 if ((Type == EGST_WINDOWS_CLASSIC) || (Type == EGST_WINDOWS_METALLIC))
\r
28 Colors[EGDC_3D_DARK_SHADOW] = video::SColor(101,50,50,50);
\r
29 Colors[EGDC_3D_SHADOW] = video::SColor(101,130,130,130);
\r
30 Colors[EGDC_3D_FACE] = video::SColor(101,210,210,210);
\r
31 Colors[EGDC_3D_HIGH_LIGHT] = video::SColor(101,255,255,255);
\r
32 Colors[EGDC_3D_LIGHT] = video::SColor(101,210,210,210);
\r
33 Colors[EGDC_ACTIVE_BORDER] = video::SColor(101,16,14,115);
\r
34 Colors[EGDC_ACTIVE_CAPTION] = video::SColor(255,255,255,255);
\r
35 Colors[EGDC_APP_WORKSPACE] = video::SColor(101,100,100,100);
\r
36 Colors[EGDC_BUTTON_TEXT] = video::SColor(240,10,10,10);
\r
37 Colors[EGDC_GRAY_TEXT] = video::SColor(240,130,130,130);
\r
38 Colors[EGDC_HIGH_LIGHT] = video::SColor(101,8,36,107);
\r
39 Colors[EGDC_HIGH_LIGHT_TEXT] = video::SColor(240,255,255,255);
\r
40 Colors[EGDC_INACTIVE_BORDER] = video::SColor(101,165,165,165);
\r
41 Colors[EGDC_INACTIVE_CAPTION] = video::SColor(255,30,30,30);
\r
42 Colors[EGDC_TOOLTIP] = video::SColor(200,0,0,0);
\r
43 Colors[EGDC_TOOLTIP_BACKGROUND] = video::SColor(200,255,255,225);
\r
44 Colors[EGDC_SCROLLBAR] = video::SColor(101,230,230,230);
\r
45 Colors[EGDC_WINDOW] = video::SColor(101,255,255,255);
\r
46 Colors[EGDC_WINDOW_SYMBOL] = video::SColor(200,10,10,10);
\r
47 Colors[EGDC_ICON] = video::SColor(200,255,255,255);
\r
48 Colors[EGDC_ICON_HIGH_LIGHT] = video::SColor(200,8,36,107);
\r
49 Colors[EGDC_GRAY_WINDOW_SYMBOL] = video::SColor(240,100,100,100);
\r
50 Colors[EGDC_EDITABLE] = video::SColor(255,255,255,255);
\r
51 Colors[EGDC_GRAY_EDITABLE] = video::SColor(255,120,120,120);
\r
52 Colors[EGDC_FOCUSED_EDITABLE] = video::SColor(255,240,240,255);
\r
55 Sizes[EGDS_SCROLLBAR_SIZE] = 14;
\r
56 Sizes[EGDS_MENU_HEIGHT] = 30;
\r
57 Sizes[EGDS_WINDOW_BUTTON_WIDTH] = 15;
\r
58 Sizes[EGDS_CHECK_BOX_WIDTH] = 18;
\r
59 Sizes[EGDS_MESSAGE_BOX_WIDTH] = 500;
\r
60 Sizes[EGDS_MESSAGE_BOX_HEIGHT] = 200;
\r
61 Sizes[EGDS_BUTTON_WIDTH] = 80;
\r
62 Sizes[EGDS_BUTTON_HEIGHT] = 30;
\r
64 Sizes[EGDS_TEXT_DISTANCE_X] = 2;
\r
65 Sizes[EGDS_TEXT_DISTANCE_Y] = 0;
\r
67 Sizes[EGDS_TITLEBARTEXT_DISTANCE_X] = 2;
\r
68 Sizes[EGDS_TITLEBARTEXT_DISTANCE_Y] = 0;
\r
73 Colors[EGDC_3D_DARK_SHADOW] = 0x60767982;
\r
74 //Colors[EGDC_3D_FACE] = 0xc0c9ccd4; // tab background
\r
75 Colors[EGDC_3D_FACE] = 0xc0cbd2d9; // tab background
\r
76 Colors[EGDC_3D_SHADOW] = 0x50e4e8f1; // tab background, and left-top highlight
\r
77 Colors[EGDC_3D_HIGH_LIGHT] = 0x40c7ccdc;
\r
78 Colors[EGDC_3D_LIGHT] = 0x802e313a;
\r
79 Colors[EGDC_ACTIVE_BORDER] = 0x80404040; // window title
\r
80 Colors[EGDC_ACTIVE_CAPTION] = 0xffd0d0d0;
\r
81 Colors[EGDC_APP_WORKSPACE] = 0xc0646464; // unused
\r
82 Colors[EGDC_BUTTON_TEXT] = 0xd0161616;
\r
83 Colors[EGDC_GRAY_TEXT] = 0x3c141414;
\r
84 Colors[EGDC_HIGH_LIGHT] = 0x6c606060;
\r
85 Colors[EGDC_HIGH_LIGHT_TEXT] = 0xd0e0e0e0;
\r
86 Colors[EGDC_INACTIVE_BORDER] = 0xf0a5a5a5;
\r
87 Colors[EGDC_INACTIVE_CAPTION] = 0xffd2d2d2;
\r
88 Colors[EGDC_TOOLTIP] = 0xf00f2033;
\r
89 Colors[EGDC_TOOLTIP_BACKGROUND] = 0xc0cbd2d9;
\r
90 Colors[EGDC_SCROLLBAR] = 0xf0e0e0e0;
\r
91 Colors[EGDC_WINDOW] = 0xf0f0f0f0;
\r
92 Colors[EGDC_WINDOW_SYMBOL] = 0xd0161616;
\r
93 Colors[EGDC_ICON] = 0xd0161616;
\r
94 Colors[EGDC_ICON_HIGH_LIGHT] = 0xd0606060;
\r
95 Colors[EGDC_GRAY_WINDOW_SYMBOL] = 0x3c101010;
\r
96 Colors[EGDC_EDITABLE] = 0xf0ffffff;
\r
97 Colors[EGDC_GRAY_EDITABLE] = 0xf0cccccc;
\r
98 Colors[EGDC_FOCUSED_EDITABLE] = 0xf0fffff0;
\r
100 Sizes[EGDS_SCROLLBAR_SIZE] = 14;
\r
101 Sizes[EGDS_MENU_HEIGHT] = 48;
\r
102 Sizes[EGDS_WINDOW_BUTTON_WIDTH] = 15;
\r
103 Sizes[EGDS_CHECK_BOX_WIDTH] = 18;
\r
104 Sizes[EGDS_MESSAGE_BOX_WIDTH] = 500;
\r
105 Sizes[EGDS_MESSAGE_BOX_HEIGHT] = 200;
\r
106 Sizes[EGDS_BUTTON_WIDTH] = 80;
\r
107 Sizes[EGDS_BUTTON_HEIGHT] = 30;
\r
109 Sizes[EGDS_TEXT_DISTANCE_X] = 3;
\r
110 Sizes[EGDS_TEXT_DISTANCE_Y] = 2;
\r
112 Sizes[EGDS_TITLEBARTEXT_DISTANCE_X] = 3;
\r
113 Sizes[EGDS_TITLEBARTEXT_DISTANCE_Y] = 2;
\r
116 Sizes[EGDS_MESSAGE_BOX_GAP_SPACE] = 15;
\r
117 Sizes[EGDS_MESSAGE_BOX_MIN_TEXT_WIDTH] = 0;
\r
118 Sizes[EGDS_MESSAGE_BOX_MAX_TEXT_WIDTH] = 500;
\r
119 Sizes[EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT] = 0;
\r
120 Sizes[EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT] = 99999;
\r
122 Sizes[EGDS_BUTTON_PRESSED_IMAGE_OFFSET_X] = 1;
\r
123 Sizes[EGDS_BUTTON_PRESSED_IMAGE_OFFSET_Y] = 1;
\r
124 Sizes[EGDS_BUTTON_PRESSED_TEXT_OFFSET_X] = 0;
\r
125 Sizes[EGDS_BUTTON_PRESSED_TEXT_OFFSET_Y] = 2;
\r
126 Sizes[EGDS_BUTTON_PRESSED_SPRITE_OFFSET_X] = 0;
\r
127 Sizes[EGDS_BUTTON_PRESSED_SPRITE_OFFSET_Y] = 0;
\r
129 Texts[EGDT_MSG_BOX_OK] = L"OK";
\r
130 Texts[EGDT_MSG_BOX_CANCEL] = L"Cancel";
\r
131 Texts[EGDT_MSG_BOX_YES] = L"Yes";
\r
132 Texts[EGDT_MSG_BOX_NO] = L"No";
\r
133 Texts[EGDT_WINDOW_CLOSE] = L"Close";
\r
134 Texts[EGDT_WINDOW_RESTORE] = L"Restore";
\r
135 Texts[EGDT_WINDOW_MINIMIZE] = L"Minimize";
\r
136 Texts[EGDT_WINDOW_MAXIMIZE] = L"Maximize";
\r
138 Icons[EGDI_WINDOW_MAXIMIZE] = 225;
\r
139 Icons[EGDI_WINDOW_RESTORE] = 226;
\r
140 Icons[EGDI_WINDOW_CLOSE] = 227;
\r
141 Icons[EGDI_WINDOW_MINIMIZE] = 228;
\r
142 Icons[EGDI_CURSOR_UP] = 229;
\r
143 Icons[EGDI_CURSOR_DOWN] = 230;
\r
144 Icons[EGDI_CURSOR_LEFT] = 231;
\r
145 Icons[EGDI_CURSOR_RIGHT] = 232;
\r
146 Icons[EGDI_MENU_MORE] = 232;
\r
147 Icons[EGDI_CHECK_BOX_CHECKED] = 233;
\r
148 Icons[EGDI_DROP_DOWN] = 234;
\r
149 Icons[EGDI_SMALL_CURSOR_UP] = 235;
\r
150 Icons[EGDI_SMALL_CURSOR_DOWN] = 236;
\r
151 Icons[EGDI_RADIO_BUTTON_CHECKED] = 237;
\r
152 Icons[EGDI_MORE_LEFT] = 238;
\r
153 Icons[EGDI_MORE_RIGHT] = 239;
\r
154 Icons[EGDI_MORE_UP] = 240;
\r
155 Icons[EGDI_MORE_DOWN] = 241;
\r
156 Icons[EGDI_WINDOW_RESIZE] = 242;
\r
157 Icons[EGDI_EXPAND] = 243;
\r
158 Icons[EGDI_COLLAPSE] = 244;
\r
160 Icons[EGDI_FILE] = 245;
\r
161 Icons[EGDI_DIRECTORY] = 246;
\r
163 for (u32 i=0; i<EGDF_COUNT; ++i)
\r
166 UseGradient = (Type == EGST_WINDOWS_METALLIC) || (Type == EGST_BURNING_SKIN) ;
\r
171 CGUISkin::~CGUISkin()
\r
173 for (u32 i=0; i<EGDF_COUNT; ++i)
\r
180 SpriteBank->drop();
\r
184 //! returns default color
\r
185 video::SColor CGUISkin::getColor(EGUI_DEFAULT_COLOR color) const
\r
187 if ((u32)color < EGDC_COUNT)
\r
188 return Colors[color];
\r
190 return video::SColor();
\r
194 //! sets a default color
\r
195 void CGUISkin::setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor)
\r
197 if ((u32)which < EGDC_COUNT)
\r
198 Colors[which] = newColor;
\r
202 //! returns size for the given size type
\r
203 s32 CGUISkin::getSize(EGUI_DEFAULT_SIZE size) const
\r
205 if ((u32)size < EGDS_COUNT)
\r
206 return Sizes[size];
\r
212 //! sets a default size
\r
213 void CGUISkin::setSize(EGUI_DEFAULT_SIZE which, s32 size)
\r
215 if ((u32)which < EGDS_COUNT)
\r
216 Sizes[which] = size;
\r
220 //! returns the default font
\r
221 IGUIFont* CGUISkin::getFont(EGUI_DEFAULT_FONT which) const
\r
223 if (((u32)which < EGDF_COUNT) && Fonts[which])
\r
224 return Fonts[which];
\r
226 return Fonts[EGDF_DEFAULT];
\r
230 //! sets a default font
\r
231 void CGUISkin::setFont(IGUIFont* font, EGUI_DEFAULT_FONT which)
\r
233 if ((u32)which >= EGDF_COUNT)
\r
240 Fonts[which]->drop();
\r
242 Fonts[which] = font;
\r
247 //! gets the sprite bank stored
\r
248 IGUISpriteBank* CGUISkin::getSpriteBank() const
\r
254 //! set a new sprite bank or remove one by passing 0
\r
255 void CGUISkin::setSpriteBank(IGUISpriteBank* bank)
\r
261 SpriteBank->drop();
\r
267 //! Returns a default icon
\r
268 u32 CGUISkin::getIcon(EGUI_DEFAULT_ICON icon) const
\r
270 if ((u32)icon < EGDI_COUNT)
\r
271 return Icons[icon];
\r
277 //! Sets a default icon
\r
278 void CGUISkin::setIcon(EGUI_DEFAULT_ICON icon, u32 index)
\r
280 if ((u32)icon < EGDI_COUNT)
\r
281 Icons[icon] = index;
\r
285 //! Returns a default text. For example for Message box button captions:
\r
286 //! "OK", "Cancel", "Yes", "No" and so on.
\r
287 const wchar_t* CGUISkin::getDefaultText(EGUI_DEFAULT_TEXT text) const
\r
289 if ((u32)text < EGDT_COUNT)
\r
290 return Texts[text].c_str();
\r
292 return Texts[0].c_str();
\r
296 //! Sets a default text. For example for Message box button captions:
\r
297 //! "OK", "Cancel", "Yes", "No" and so on.
\r
298 void CGUISkin::setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText)
\r
300 if ((u32)which < EGDT_COUNT)
\r
301 Texts[which] = newText;
\r
305 //! draws a standard 3d button pane
\r
306 /** Used for drawing for example buttons in normal state.
\r
307 It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
\r
308 EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
\r
309 \param rect: Defining area where to draw.
\r
310 \param clip: Clip area.
\r
311 \param element: Pointer to the element which wishes to draw this. This parameter
\r
312 is usually not used by ISkin, but can be used for example by more complex
\r
313 implementations to find out how to draw the part exactly. */
\r
314 void CGUISkin::draw3DButtonPaneStandard(IGUIElement* element,
\r
315 const core::rect<s32>& r,
\r
316 const core::rect<s32>* clip)
\r
321 core::rect<s32> rect = r;
\r
323 if ( Type == EGST_BURNING_SKIN )
\r
325 rect.UpperLeftCorner.X -= 1;
\r
326 rect.UpperLeftCorner.Y -= 1;
\r
327 rect.LowerRightCorner.X += 1;
\r
328 rect.LowerRightCorner.Y += 1;
\r
329 draw3DSunkenPane(element,
\r
330 getColor( EGDC_WINDOW ).getInterpolated( 0xFFFFFFFF, 0.9f )
\r
331 ,false, true, rect, clip);
\r
335 Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip);
\r
337 rect.LowerRightCorner.X -= 1;
\r
338 rect.LowerRightCorner.Y -= 1;
\r
339 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip);
\r
341 rect.UpperLeftCorner.X += 1;
\r
342 rect.UpperLeftCorner.Y += 1;
\r
343 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip);
\r
345 rect.LowerRightCorner.X -= 1;
\r
346 rect.LowerRightCorner.Y -= 1;
\r
350 Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip);
\r
354 const video::SColor c1 = getColor(EGDC_3D_FACE);
\r
355 const video::SColor c2 = c1.getInterpolated(getColor(EGDC_3D_DARK_SHADOW), 0.4f);
\r
356 Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip);
\r
361 //! draws a pressed 3d button pane
\r
362 /** Used for drawing for example buttons in pressed state.
\r
363 It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
\r
364 EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
\r
365 \param rect: Defining area where to draw.
\r
366 \param clip: Clip area.
\r
367 \param element: Pointer to the element which wishes to draw this. This parameter
\r
368 is usually not used by ISkin, but can be used for example by more complex
\r
369 implementations to find out how to draw the part exactly. */
\r
370 void CGUISkin::draw3DButtonPanePressed(IGUIElement* element,
\r
371 const core::rect<s32>& r,
\r
372 const core::rect<s32>* clip)
\r
377 core::rect<s32> rect = r;
\r
378 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip);
\r
380 rect.LowerRightCorner.X -= 1;
\r
381 rect.LowerRightCorner.Y -= 1;
\r
382 Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip);
\r
384 rect.UpperLeftCorner.X += 1;
\r
385 rect.UpperLeftCorner.Y += 1;
\r
386 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip);
\r
388 rect.UpperLeftCorner.X += 1;
\r
389 rect.UpperLeftCorner.Y += 1;
\r
393 Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip);
\r
397 const video::SColor c1 = getColor(EGDC_3D_FACE);
\r
398 const video::SColor c2 = c1.getInterpolated(getColor(EGDC_3D_DARK_SHADOW), 0.4f);
\r
399 Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip);
\r
404 //! draws a sunken 3d pane
\r
405 /** Used for drawing the background of edit, combo or check boxes.
\r
406 \param element: Pointer to the element which wishes to draw this. This parameter
\r
407 is usually not used by ISkin, but can be used for example by more complex
\r
408 implementations to find out how to draw the part exactly.
\r
409 \param bgcolor: Background color.
\r
410 \param flat: Specifies if the sunken pane should be flat or displayed as sunken
\r
411 deep into the ground.
\r
412 \param rect: Defining area where to draw.
\r
413 \param clip: Clip area. */
\r
414 void CGUISkin::draw3DSunkenPane(IGUIElement* element, video::SColor bgcolor,
\r
415 bool flat, bool fillBackGround,
\r
416 const core::rect<s32>& r,
\r
417 const core::rect<s32>* clip)
\r
422 core::rect<s32> rect = r;
\r
424 if (fillBackGround)
\r
425 Driver->draw2DRectangle(bgcolor, rect, clip);
\r
429 // draw flat sunken pane
\r
431 rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1;
\r
432 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); // top
\r
434 ++rect.UpperLeftCorner.Y;
\r
435 rect.LowerRightCorner.Y = r.LowerRightCorner.Y;
\r
436 rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1;
\r
437 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); // left
\r
440 ++rect.UpperLeftCorner.Y;
\r
441 rect.UpperLeftCorner.X = rect.LowerRightCorner.X - 1;
\r
442 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); // right
\r
445 ++rect.UpperLeftCorner.X;
\r
446 rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1;
\r
447 --rect.LowerRightCorner.X;
\r
448 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); // bottom
\r
452 // draw deep sunken pane
\r
453 rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1;
\r
454 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); // top
\r
455 ++rect.UpperLeftCorner.X;
\r
456 ++rect.UpperLeftCorner.Y;
\r
457 --rect.LowerRightCorner.X;
\r
458 ++rect.LowerRightCorner.Y;
\r
459 Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip);
\r
461 rect.UpperLeftCorner.X = r.UpperLeftCorner.X;
\r
462 rect.UpperLeftCorner.Y = r.UpperLeftCorner.Y+1;
\r
463 rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1;
\r
464 rect.LowerRightCorner.Y = r.LowerRightCorner.Y;
\r
465 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); // left
\r
466 ++rect.UpperLeftCorner.X;
\r
467 ++rect.UpperLeftCorner.Y;
\r
468 ++rect.LowerRightCorner.X;
\r
469 --rect.LowerRightCorner.Y;
\r
470 Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip);
\r
473 rect.UpperLeftCorner.X = rect.LowerRightCorner.X - 1;
\r
474 ++rect.UpperLeftCorner.Y;
\r
475 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); // right
\r
476 --rect.UpperLeftCorner.X;
\r
477 ++rect.UpperLeftCorner.Y;
\r
478 --rect.LowerRightCorner.X;
\r
479 --rect.LowerRightCorner.Y;
\r
480 Driver->draw2DRectangle(getColor(EGDC_3D_LIGHT), rect, clip);
\r
483 ++rect.UpperLeftCorner.X;
\r
484 rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1;
\r
485 --rect.LowerRightCorner.X;
\r
486 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); // bottom
\r
487 ++rect.UpperLeftCorner.X;
\r
488 --rect.UpperLeftCorner.Y;
\r
489 --rect.LowerRightCorner.X;
\r
490 --rect.LowerRightCorner.Y;
\r
491 Driver->draw2DRectangle(getColor(EGDC_3D_LIGHT), rect, clip);
\r
496 //! draws a window background
\r
497 // return where to draw title bar text.
\r
498 core::rect<s32> CGUISkin::draw3DWindowBackground(IGUIElement* element,
\r
499 bool drawTitleBar, video::SColor titleBarColor,
\r
500 const core::rect<s32>& r,
\r
501 const core::rect<s32>* clip,
\r
502 core::rect<s32>* checkClientArea)
\r
506 if ( checkClientArea )
\r
508 *checkClientArea = r;
\r
513 core::rect<s32> rect = r;
\r
516 rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1;
\r
517 if ( !checkClientArea )
\r
519 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip);
\r
523 rect.LowerRightCorner.Y = r.LowerRightCorner.Y;
\r
524 rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1;
\r
525 if ( !checkClientArea )
\r
527 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip);
\r
530 // right border dark outer line
\r
531 rect.UpperLeftCorner.X = r.LowerRightCorner.X - 1;
\r
532 rect.LowerRightCorner.X = r.LowerRightCorner.X;
\r
533 rect.UpperLeftCorner.Y = r.UpperLeftCorner.Y;
\r
534 rect.LowerRightCorner.Y = r.LowerRightCorner.Y;
\r
535 if ( !checkClientArea )
\r
537 Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip);
\r
540 // right border bright innner line
\r
541 rect.UpperLeftCorner.X -= 1;
\r
542 rect.LowerRightCorner.X -= 1;
\r
543 rect.UpperLeftCorner.Y += 1;
\r
544 rect.LowerRightCorner.Y -= 1;
\r
545 if ( !checkClientArea )
\r
547 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip);
\r
550 // bottom border dark outer line
\r
551 rect.UpperLeftCorner.X = r.UpperLeftCorner.X;
\r
552 rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1;
\r
553 rect.LowerRightCorner.Y = r.LowerRightCorner.Y;
\r
554 rect.LowerRightCorner.X = r.LowerRightCorner.X;
\r
555 if ( !checkClientArea )
\r
557 Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip);
\r
560 // bottom border bright inner line
\r
561 rect.UpperLeftCorner.X += 1;
\r
562 rect.LowerRightCorner.X -= 1;
\r
563 rect.UpperLeftCorner.Y -= 1;
\r
564 rect.LowerRightCorner.Y -= 1;
\r
565 if ( !checkClientArea )
\r
567 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip);
\r
570 // client area for background
\r
572 rect.UpperLeftCorner.X +=1;
\r
573 rect.UpperLeftCorner.Y +=1;
\r
574 rect.LowerRightCorner.X -= 2;
\r
575 rect.LowerRightCorner.Y -= 2;
\r
576 if (checkClientArea)
\r
578 *checkClientArea = rect;
\r
581 if ( !checkClientArea )
\r
585 Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip);
\r
587 else if ( Type == EGST_BURNING_SKIN )
\r
589 const video::SColor c1 = getColor(EGDC_WINDOW).getInterpolated ( 0xFFFFFFFF, 0.9f );
\r
590 const video::SColor c2 = getColor(EGDC_WINDOW).getInterpolated ( 0xFFFFFFFF, 0.8f );
\r
592 Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip);
\r
596 const video::SColor c2 = getColor(EGDC_3D_SHADOW);
\r
597 const video::SColor c1 = getColor(EGDC_3D_FACE);
\r
598 Driver->draw2DRectangle(rect, c1, c1, c1, c2, clip);
\r
604 rect.UpperLeftCorner.X += 2;
\r
605 rect.UpperLeftCorner.Y += 2;
\r
606 rect.LowerRightCorner.X -= 2;
\r
607 rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + getSize(EGDS_WINDOW_BUTTON_WIDTH) + 2;
\r
611 if (checkClientArea)
\r
613 (*checkClientArea).UpperLeftCorner.Y = rect.LowerRightCorner.Y;
\r
618 //if (!UseGradient)
\r
619 // Driver->draw2DRectangle(titleBarColor, rect, clip);
\r
621 if ( Type == EGST_BURNING_SKIN )
\r
623 const video::SColor c = titleBarColor.getInterpolated( video::SColor(titleBarColor.getAlpha(),255,255,255), 0.8f);
\r
624 Driver->draw2DRectangle(rect, titleBarColor, titleBarColor, c, c, clip);
\r
628 const video::SColor c = titleBarColor.getInterpolated(video::SColor(titleBarColor.getAlpha(),0,0,0), 0.2f);
\r
629 Driver->draw2DRectangle(rect, titleBarColor, c, titleBarColor, c, clip);
\r
638 //! draws a standard 3d menu pane
\r
639 /** Used for drawing for menus and context menus.
\r
640 It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
\r
641 EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
\r
642 \param element: Pointer to the element which wishes to draw this. This parameter
\r
643 is usually not used by ISkin, but can be used for example by more complex
\r
644 implementations to find out how to draw the part exactly.
\r
645 \param rect: Defining area where to draw.
\r
646 \param clip: Clip area. */
\r
647 void CGUISkin::draw3DMenuPane(IGUIElement* element,
\r
648 const core::rect<s32>& r, const core::rect<s32>* clip)
\r
653 core::rect<s32> rect = r;
\r
655 if ( Type == EGST_BURNING_SKIN )
\r
657 rect.UpperLeftCorner.Y -= 3;
\r
658 draw3DButtonPaneStandard(element, rect, clip);
\r
662 // in this skin, this is exactly what non pressed buttons look like,
\r
663 // so we could simply call
\r
664 // draw3DButtonPaneStandard(element, rect, clip);
\r
666 // but if the skin is transparent, this doesn't look that nice. So
\r
667 // We draw it a little bit better, with some more draw2DRectangle calls,
\r
668 // but there aren't that much menus visible anyway.
\r
670 rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1;
\r
671 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip);
\r
673 rect.LowerRightCorner.Y = r.LowerRightCorner.Y;
\r
674 rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1;
\r
675 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip);
\r
677 rect.UpperLeftCorner.X = r.LowerRightCorner.X - 1;
\r
678 rect.LowerRightCorner.X = r.LowerRightCorner.X;
\r
679 rect.UpperLeftCorner.Y = r.UpperLeftCorner.Y;
\r
680 rect.LowerRightCorner.Y = r.LowerRightCorner.Y;
\r
681 Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip);
\r
683 rect.UpperLeftCorner.X -= 1;
\r
684 rect.LowerRightCorner.X -= 1;
\r
685 rect.UpperLeftCorner.Y += 1;
\r
686 rect.LowerRightCorner.Y -= 1;
\r
687 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip);
\r
689 rect.UpperLeftCorner.X = r.UpperLeftCorner.X;
\r
690 rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1;
\r
691 rect.LowerRightCorner.Y = r.LowerRightCorner.Y;
\r
692 rect.LowerRightCorner.X = r.LowerRightCorner.X;
\r
693 Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip);
\r
695 rect.UpperLeftCorner.X += 1;
\r
696 rect.LowerRightCorner.X -= 1;
\r
697 rect.UpperLeftCorner.Y -= 1;
\r
698 rect.LowerRightCorner.Y -= 1;
\r
699 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip);
\r
702 rect.UpperLeftCorner.X +=1;
\r
703 rect.UpperLeftCorner.Y +=1;
\r
704 rect.LowerRightCorner.X -= 2;
\r
705 rect.LowerRightCorner.Y -= 2;
\r
708 Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip);
\r
711 const video::SColor c1 = getColor(EGDC_3D_FACE);
\r
712 const video::SColor c2 = getColor(EGDC_3D_SHADOW);
\r
713 Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip);
\r
718 //! draws a standard 3d tool bar
\r
719 /** Used for drawing for toolbars and menus.
\r
720 \param element: Pointer to the element which wishes to draw this. This parameter
\r
721 is usually not used by ISkin, but can be used for example by more complex
\r
722 implementations to find out how to draw the part exactly.
\r
723 \param rect: Defining area where to draw.
\r
724 \param clip: Clip area. */
\r
725 void CGUISkin::draw3DToolBar(IGUIElement* element,
\r
726 const core::rect<s32>& r,
\r
727 const core::rect<s32>* clip)
\r
732 core::rect<s32> rect = r;
\r
734 rect.UpperLeftCorner.X = r.UpperLeftCorner.X;
\r
735 rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1;
\r
736 rect.LowerRightCorner.Y = r.LowerRightCorner.Y;
\r
737 rect.LowerRightCorner.X = r.LowerRightCorner.X;
\r
738 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip);
\r
741 rect.LowerRightCorner.Y -= 1;
\r
745 Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip);
\r
748 if ( Type == EGST_BURNING_SKIN )
\r
750 const video::SColor c1 = 0xF0000000 | getColor(EGDC_3D_FACE).color;
\r
751 const video::SColor c2 = 0xF0000000 | getColor(EGDC_3D_SHADOW).color;
\r
753 rect.LowerRightCorner.Y += 1;
\r
754 Driver->draw2DRectangle(rect, c1, c2, c1, c2, clip);
\r
758 const video::SColor c1 = getColor(EGDC_3D_FACE);
\r
759 const video::SColor c2 = getColor(EGDC_3D_SHADOW);
\r
760 Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip);
\r
765 //! draws a tab button
\r
766 /** Used for drawing for tab buttons on top of tabs.
\r
767 \param element: Pointer to the element which wishes to draw this. This parameter
\r
768 is usually not used by ISkin, but can be used for example by more complex
\r
769 implementations to find out how to draw the part exactly.
\r
770 \param active: Specifies if the tab is currently active.
\r
771 \param rect: Defining area where to draw.
\r
772 \param clip: Clip area. */
\r
773 void CGUISkin::draw3DTabButton(IGUIElement* element, bool active,
\r
774 const core::rect<s32>& frameRect, const core::rect<s32>* clip, EGUI_ALIGNMENT alignment)
\r
779 core::rect<s32> tr = frameRect;
\r
781 if ( alignment == EGUIA_UPPERLEFT )
\r
783 tr.LowerRightCorner.X -= 2;
\r
784 tr.LowerRightCorner.Y = tr.UpperLeftCorner.Y + 1;
\r
785 tr.UpperLeftCorner.X += 1;
\r
786 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
\r
788 // draw left highlight
\r
790 tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
\r
791 tr.UpperLeftCorner.Y += 1;
\r
792 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
\r
794 // draw grey background
\r
796 tr.UpperLeftCorner.X += 1;
\r
797 tr.UpperLeftCorner.Y += 1;
\r
798 tr.LowerRightCorner.X -= 2;
\r
799 Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip);
\r
801 // draw right middle gray shadow
\r
802 tr.LowerRightCorner.X += 1;
\r
803 tr.UpperLeftCorner.X = tr.LowerRightCorner.X - 1;
\r
804 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip);
\r
806 tr.LowerRightCorner.X += 1;
\r
807 tr.UpperLeftCorner.X += 1;
\r
808 tr.UpperLeftCorner.Y += 1;
\r
809 Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), tr, clip);
\r
813 tr.LowerRightCorner.X -= 2;
\r
814 tr.UpperLeftCorner.Y = tr.LowerRightCorner.Y - 1;
\r
815 tr.UpperLeftCorner.X += 1;
\r
816 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
\r
818 // draw left highlight
\r
820 tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
\r
821 tr.LowerRightCorner.Y -= 1;
\r
822 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
\r
824 // draw grey background
\r
826 tr.UpperLeftCorner.X += 1;
\r
827 tr.UpperLeftCorner.Y -= 1;
\r
828 tr.LowerRightCorner.X -= 2;
\r
829 tr.LowerRightCorner.Y -= 1;
\r
830 Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip);
\r
832 // draw right middle gray shadow
\r
833 tr.LowerRightCorner.X += 1;
\r
834 tr.UpperLeftCorner.X = tr.LowerRightCorner.X - 1;
\r
835 //tr.LowerRightCorner.Y -= 1;
\r
836 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip);
\r
838 tr.LowerRightCorner.X += 1;
\r
839 tr.UpperLeftCorner.X += 1;
\r
840 tr.LowerRightCorner.Y -= 1;
\r
841 Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), tr, clip);
\r
846 //! draws a tab control body
\r
847 /** \param element: Pointer to the element which wishes to draw this. This parameter
\r
848 is usually not used by ISkin, but can be used for example by more complex
\r
849 implementations to find out how to draw the part exactly.
\r
850 \param border: Specifies if the border should be drawn.
\r
851 \param background: Specifies if the background should be drawn.
\r
852 \param rect: Defining area where to draw.
\r
853 \param clip: Clip area. */
\r
854 void CGUISkin::draw3DTabBody(IGUIElement* element, bool border, bool background,
\r
855 const core::rect<s32>& rect, const core::rect<s32>* clip, s32 tabHeight, EGUI_ALIGNMENT alignment)
\r
860 core::rect<s32> tr = rect;
\r
862 if ( tabHeight == -1 )
\r
863 tabHeight = getSize(gui::EGDS_BUTTON_HEIGHT);
\r
868 if ( alignment == EGUIA_UPPERLEFT )
\r
870 // draw left hightlight
\r
871 tr.UpperLeftCorner.Y += tabHeight + 2;
\r
872 tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
\r
873 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
\r
875 // draw right shadow
\r
876 tr.UpperLeftCorner.X = rect.LowerRightCorner.X - 1;
\r
877 tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
\r
878 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip);
\r
880 // draw lower shadow
\r
882 tr.UpperLeftCorner.Y = tr.LowerRightCorner.Y - 1;
\r
883 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip);
\r
887 // draw left hightlight
\r
888 tr.LowerRightCorner.Y -= tabHeight + 2;
\r
889 tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
\r
890 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
\r
892 // draw right shadow
\r
893 tr.UpperLeftCorner.X = rect.LowerRightCorner.X - 1;
\r
894 tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
\r
895 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip);
\r
897 // draw lower shadow
\r
899 tr.LowerRightCorner.Y = tr.UpperLeftCorner.Y + 1;
\r
900 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
\r
906 if ( alignment == EGUIA_UPPERLEFT )
\r
909 tr.UpperLeftCorner.Y += tabHeight + 2;
\r
910 tr.LowerRightCorner.X -= 1;
\r
911 tr.UpperLeftCorner.X += 1;
\r
912 tr.LowerRightCorner.Y -= 1;
\r
917 tr.UpperLeftCorner.X += 1;
\r
918 tr.UpperLeftCorner.Y -= 1;
\r
919 tr.LowerRightCorner.X -= 1;
\r
920 tr.LowerRightCorner.Y -= tabHeight + 2;
\r
921 //tr.UpperLeftCorner.X += 1;
\r
925 Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip);
\r
928 video::SColor c1 = getColor(EGDC_3D_FACE);
\r
929 video::SColor c2 = getColor(EGDC_3D_SHADOW);
\r
930 Driver->draw2DRectangle(tr, c1, c1, c2, c2, clip);
\r
936 //! draws an icon, usually from the skin's sprite bank
\r
937 /** \param parent: Pointer to the element which wishes to draw this icon.
\r
938 This parameter is usually not used by IGUISkin, but can be used for example
\r
939 by more complex implementations to find out how to draw the part exactly.
\r
940 \param icon: Specifies the icon to be drawn.
\r
941 \param position: The position to draw the icon
\r
942 \param starttime: The time at the start of the animation
\r
943 \param currenttime: The present time, used to calculate the frame number
\r
944 \param loop: Whether the animation should loop or not
\r
945 \param clip: Clip area. */
\r
946 void CGUISkin::drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon,
\r
947 const core::position2di position,
\r
948 u32 starttime, u32 currenttime,
\r
949 bool loop, const core::rect<s32>* clip)
\r
954 bool gray = element && !element->isEnabled();
\r
955 SpriteBank->draw2DSprite(Icons[icon], position, clip,
\r
956 Colors[gray? EGDC_GRAY_WINDOW_SYMBOL : EGDC_WINDOW_SYMBOL], starttime, currenttime, loop, true);
\r
960 EGUI_SKIN_TYPE CGUISkin::getType() const
\r
966 //! draws a 2d rectangle.
\r
967 void CGUISkin::draw2DRectangle(IGUIElement* element,
\r
968 const video::SColor &color, const core::rect<s32>& pos,
\r
969 const core::rect<s32>* clip)
\r
971 Driver->draw2DRectangle(color, pos, clip);
\r
974 } // end namespace gui
\r
975 } // end namespace irr
\r
977 #endif // _IRR_COMPILE_WITH_GUI_
\r