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
7 #include "IGUIFont.h"
\r
8 #include "IGUISpriteBank.h"
\r
9 #include "IGUIElement.h"
\r
10 #include "IVideoDriver.h"
\r
11 #include "IAttributes.h"
\r
18 CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver)
\r
19 : SpriteBank(0), Driver(driver), Type(type)
\r
22 setDebugName("CGUISkin");
\r
25 if ((Type == EGST_WINDOWS_CLASSIC) || (Type == EGST_WINDOWS_METALLIC))
\r
27 Colors[EGDC_3D_DARK_SHADOW] = video::SColor(101,50,50,50);
\r
28 Colors[EGDC_3D_SHADOW] = video::SColor(101,130,130,130);
\r
29 Colors[EGDC_3D_FACE] = video::SColor(101,210,210,210);
\r
30 Colors[EGDC_3D_HIGH_LIGHT] = video::SColor(101,255,255,255);
\r
31 Colors[EGDC_3D_LIGHT] = video::SColor(101,210,210,210);
\r
32 Colors[EGDC_ACTIVE_BORDER] = video::SColor(101,16,14,115);
\r
33 Colors[EGDC_ACTIVE_CAPTION] = video::SColor(255,255,255,255);
\r
34 Colors[EGDC_APP_WORKSPACE] = video::SColor(101,100,100,100);
\r
35 Colors[EGDC_BUTTON_TEXT] = video::SColor(240,10,10,10);
\r
36 Colors[EGDC_GRAY_TEXT] = video::SColor(240,130,130,130);
\r
37 Colors[EGDC_HIGH_LIGHT] = video::SColor(101,8,36,107);
\r
38 Colors[EGDC_HIGH_LIGHT_TEXT] = video::SColor(240,255,255,255);
\r
39 Colors[EGDC_INACTIVE_BORDER] = video::SColor(101,165,165,165);
\r
40 Colors[EGDC_INACTIVE_CAPTION] = video::SColor(255,30,30,30);
\r
41 Colors[EGDC_TOOLTIP] = video::SColor(200,0,0,0);
\r
42 Colors[EGDC_TOOLTIP_BACKGROUND] = video::SColor(200,255,255,225);
\r
43 Colors[EGDC_SCROLLBAR] = video::SColor(101,230,230,230);
\r
44 Colors[EGDC_WINDOW] = video::SColor(101,255,255,255);
\r
45 Colors[EGDC_WINDOW_SYMBOL] = video::SColor(200,10,10,10);
\r
46 Colors[EGDC_ICON] = video::SColor(200,255,255,255);
\r
47 Colors[EGDC_ICON_HIGH_LIGHT] = video::SColor(200,8,36,107);
\r
48 Colors[EGDC_GRAY_WINDOW_SYMBOL] = video::SColor(240,100,100,100);
\r
49 Colors[EGDC_EDITABLE] = video::SColor(255,255,255,255);
\r
50 Colors[EGDC_GRAY_EDITABLE] = video::SColor(255,120,120,120);
\r
51 Colors[EGDC_FOCUSED_EDITABLE] = video::SColor(255,240,240,255);
\r
54 Sizes[EGDS_SCROLLBAR_SIZE] = 14;
\r
55 Sizes[EGDS_MENU_HEIGHT] = 30;
\r
56 Sizes[EGDS_WINDOW_BUTTON_WIDTH] = 15;
\r
57 Sizes[EGDS_CHECK_BOX_WIDTH] = 18;
\r
58 Sizes[EGDS_MESSAGE_BOX_WIDTH] = 500;
\r
59 Sizes[EGDS_MESSAGE_BOX_HEIGHT] = 200;
\r
60 Sizes[EGDS_BUTTON_WIDTH] = 80;
\r
61 Sizes[EGDS_BUTTON_HEIGHT] = 30;
\r
63 Sizes[EGDS_TEXT_DISTANCE_X] = 2;
\r
64 Sizes[EGDS_TEXT_DISTANCE_Y] = 0;
\r
66 Sizes[EGDS_TITLEBARTEXT_DISTANCE_X] = 2;
\r
67 Sizes[EGDS_TITLEBARTEXT_DISTANCE_Y] = 0;
\r
72 Colors[EGDC_3D_DARK_SHADOW] = 0x60767982;
\r
73 //Colors[EGDC_3D_FACE] = 0xc0c9ccd4; // tab background
\r
74 Colors[EGDC_3D_FACE] = 0xc0cbd2d9; // tab background
\r
75 Colors[EGDC_3D_SHADOW] = 0x50e4e8f1; // tab background, and left-top highlight
\r
76 Colors[EGDC_3D_HIGH_LIGHT] = 0x40c7ccdc;
\r
77 Colors[EGDC_3D_LIGHT] = 0x802e313a;
\r
78 Colors[EGDC_ACTIVE_BORDER] = 0x80404040; // window title
\r
79 Colors[EGDC_ACTIVE_CAPTION] = 0xffd0d0d0;
\r
80 Colors[EGDC_APP_WORKSPACE] = 0xc0646464; // unused
\r
81 Colors[EGDC_BUTTON_TEXT] = 0xd0161616;
\r
82 Colors[EGDC_GRAY_TEXT] = 0x3c141414;
\r
83 Colors[EGDC_HIGH_LIGHT] = 0x6c606060;
\r
84 Colors[EGDC_HIGH_LIGHT_TEXT] = 0xd0e0e0e0;
\r
85 Colors[EGDC_INACTIVE_BORDER] = 0xf0a5a5a5;
\r
86 Colors[EGDC_INACTIVE_CAPTION] = 0xffd2d2d2;
\r
87 Colors[EGDC_TOOLTIP] = 0xf00f2033;
\r
88 Colors[EGDC_TOOLTIP_BACKGROUND] = 0xc0cbd2d9;
\r
89 Colors[EGDC_SCROLLBAR] = 0xf0e0e0e0;
\r
90 Colors[EGDC_WINDOW] = 0xf0f0f0f0;
\r
91 Colors[EGDC_WINDOW_SYMBOL] = 0xd0161616;
\r
92 Colors[EGDC_ICON] = 0xd0161616;
\r
93 Colors[EGDC_ICON_HIGH_LIGHT] = 0xd0606060;
\r
94 Colors[EGDC_GRAY_WINDOW_SYMBOL] = 0x3c101010;
\r
95 Colors[EGDC_EDITABLE] = 0xf0ffffff;
\r
96 Colors[EGDC_GRAY_EDITABLE] = 0xf0cccccc;
\r
97 Colors[EGDC_FOCUSED_EDITABLE] = 0xf0fffff0;
\r
99 Sizes[EGDS_SCROLLBAR_SIZE] = 14;
\r
100 Sizes[EGDS_MENU_HEIGHT] = 48;
\r
101 Sizes[EGDS_WINDOW_BUTTON_WIDTH] = 15;
\r
102 Sizes[EGDS_CHECK_BOX_WIDTH] = 18;
\r
103 Sizes[EGDS_MESSAGE_BOX_WIDTH] = 500;
\r
104 Sizes[EGDS_MESSAGE_BOX_HEIGHT] = 200;
\r
105 Sizes[EGDS_BUTTON_WIDTH] = 80;
\r
106 Sizes[EGDS_BUTTON_HEIGHT] = 30;
\r
108 Sizes[EGDS_TEXT_DISTANCE_X] = 3;
\r
109 Sizes[EGDS_TEXT_DISTANCE_Y] = 2;
\r
111 Sizes[EGDS_TITLEBARTEXT_DISTANCE_X] = 3;
\r
112 Sizes[EGDS_TITLEBARTEXT_DISTANCE_Y] = 2;
\r
115 Sizes[EGDS_MESSAGE_BOX_GAP_SPACE] = 15;
\r
116 Sizes[EGDS_MESSAGE_BOX_MIN_TEXT_WIDTH] = 0;
\r
117 Sizes[EGDS_MESSAGE_BOX_MAX_TEXT_WIDTH] = 500;
\r
118 Sizes[EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT] = 0;
\r
119 Sizes[EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT] = 99999;
\r
121 Sizes[EGDS_BUTTON_PRESSED_IMAGE_OFFSET_X] = 1;
\r
122 Sizes[EGDS_BUTTON_PRESSED_IMAGE_OFFSET_Y] = 1;
\r
123 Sizes[EGDS_BUTTON_PRESSED_TEXT_OFFSET_X] = 0;
\r
124 Sizes[EGDS_BUTTON_PRESSED_TEXT_OFFSET_Y] = 2;
\r
125 Sizes[EGDS_BUTTON_PRESSED_SPRITE_OFFSET_X] = 0;
\r
126 Sizes[EGDS_BUTTON_PRESSED_SPRITE_OFFSET_Y] = 0;
\r
128 Texts[EGDT_MSG_BOX_OK] = L"OK";
\r
129 Texts[EGDT_MSG_BOX_CANCEL] = L"Cancel";
\r
130 Texts[EGDT_MSG_BOX_YES] = L"Yes";
\r
131 Texts[EGDT_MSG_BOX_NO] = L"No";
\r
132 Texts[EGDT_WINDOW_CLOSE] = L"Close";
\r
133 Texts[EGDT_WINDOW_RESTORE] = L"Restore";
\r
134 Texts[EGDT_WINDOW_MINIMIZE] = L"Minimize";
\r
135 Texts[EGDT_WINDOW_MAXIMIZE] = L"Maximize";
\r
137 Icons[EGDI_WINDOW_MAXIMIZE] = 225;
\r
138 Icons[EGDI_WINDOW_RESTORE] = 226;
\r
139 Icons[EGDI_WINDOW_CLOSE] = 227;
\r
140 Icons[EGDI_WINDOW_MINIMIZE] = 228;
\r
141 Icons[EGDI_CURSOR_UP] = 229;
\r
142 Icons[EGDI_CURSOR_DOWN] = 230;
\r
143 Icons[EGDI_CURSOR_LEFT] = 231;
\r
144 Icons[EGDI_CURSOR_RIGHT] = 232;
\r
145 Icons[EGDI_MENU_MORE] = 232;
\r
146 Icons[EGDI_CHECK_BOX_CHECKED] = 233;
\r
147 Icons[EGDI_DROP_DOWN] = 234;
\r
148 Icons[EGDI_SMALL_CURSOR_UP] = 235;
\r
149 Icons[EGDI_SMALL_CURSOR_DOWN] = 236;
\r
150 Icons[EGDI_RADIO_BUTTON_CHECKED] = 237;
\r
151 Icons[EGDI_MORE_LEFT] = 238;
\r
152 Icons[EGDI_MORE_RIGHT] = 239;
\r
153 Icons[EGDI_MORE_UP] = 240;
\r
154 Icons[EGDI_MORE_DOWN] = 241;
\r
155 Icons[EGDI_WINDOW_RESIZE] = 242;
\r
156 Icons[EGDI_EXPAND] = 243;
\r
157 Icons[EGDI_COLLAPSE] = 244;
\r
159 Icons[EGDI_FILE] = 245;
\r
160 Icons[EGDI_DIRECTORY] = 246;
\r
162 for (u32 i=0; i<EGDF_COUNT; ++i)
\r
165 UseGradient = (Type == EGST_WINDOWS_METALLIC) || (Type == EGST_BURNING_SKIN) ;
\r
170 CGUISkin::~CGUISkin()
\r
172 for (u32 i=0; i<EGDF_COUNT; ++i)
\r
179 SpriteBank->drop();
\r
183 //! returns default color
\r
184 video::SColor CGUISkin::getColor(EGUI_DEFAULT_COLOR color) const
\r
186 if ((u32)color < EGDC_COUNT)
\r
187 return Colors[color];
\r
189 return video::SColor();
\r
193 //! sets a default color
\r
194 void CGUISkin::setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor)
\r
196 if ((u32)which < EGDC_COUNT)
\r
197 Colors[which] = newColor;
\r
201 //! returns size for the given size type
\r
202 s32 CGUISkin::getSize(EGUI_DEFAULT_SIZE size) const
\r
204 if ((u32)size < EGDS_COUNT)
\r
205 return Sizes[size];
\r
211 //! sets a default size
\r
212 void CGUISkin::setSize(EGUI_DEFAULT_SIZE which, s32 size)
\r
214 if ((u32)which < EGDS_COUNT)
\r
215 Sizes[which] = size;
\r
219 //! returns the default font
\r
220 IGUIFont* CGUISkin::getFont(EGUI_DEFAULT_FONT which) const
\r
222 if (((u32)which < EGDF_COUNT) && Fonts[which])
\r
223 return Fonts[which];
\r
225 return Fonts[EGDF_DEFAULT];
\r
229 //! sets a default font
\r
230 void CGUISkin::setFont(IGUIFont* font, EGUI_DEFAULT_FONT which)
\r
232 if ((u32)which >= EGDF_COUNT)
\r
239 Fonts[which]->drop();
\r
241 Fonts[which] = font;
\r
246 //! gets the sprite bank stored
\r
247 IGUISpriteBank* CGUISkin::getSpriteBank() const
\r
253 //! set a new sprite bank or remove one by passing 0
\r
254 void CGUISkin::setSpriteBank(IGUISpriteBank* bank)
\r
260 SpriteBank->drop();
\r
266 //! Returns a default icon
\r
267 u32 CGUISkin::getIcon(EGUI_DEFAULT_ICON icon) const
\r
269 if ((u32)icon < EGDI_COUNT)
\r
270 return Icons[icon];
\r
276 //! Sets a default icon
\r
277 void CGUISkin::setIcon(EGUI_DEFAULT_ICON icon, u32 index)
\r
279 if ((u32)icon < EGDI_COUNT)
\r
280 Icons[icon] = index;
\r
284 //! Returns a default text. For example for Message box button captions:
\r
285 //! "OK", "Cancel", "Yes", "No" and so on.
\r
286 const wchar_t* CGUISkin::getDefaultText(EGUI_DEFAULT_TEXT text) const
\r
288 if ((u32)text < EGDT_COUNT)
\r
289 return Texts[text].c_str();
\r
291 return Texts[0].c_str();
\r
295 //! Sets a default text. For example for Message box button captions:
\r
296 //! "OK", "Cancel", "Yes", "No" and so on.
\r
297 void CGUISkin::setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText)
\r
299 if ((u32)which < EGDT_COUNT)
\r
300 Texts[which] = newText;
\r
304 //! draws a standard 3d button pane
\r
305 /** Used for drawing for example buttons in normal state.
\r
306 It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
\r
307 EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
\r
308 \param rect: Defining area where to draw.
\r
309 \param clip: Clip area.
\r
310 \param element: Pointer to the element which wishes to draw this. This parameter
\r
311 is usually not used by ISkin, but can be used for example by more complex
\r
312 implementations to find out how to draw the part exactly. */
\r
313 void CGUISkin::draw3DButtonPaneStandard(IGUIElement* element,
\r
314 const core::rect<s32>& r,
\r
315 const core::rect<s32>* clip)
\r
320 core::rect<s32> rect = r;
\r
322 if ( Type == EGST_BURNING_SKIN )
\r
324 rect.UpperLeftCorner.X -= 1;
\r
325 rect.UpperLeftCorner.Y -= 1;
\r
326 rect.LowerRightCorner.X += 1;
\r
327 rect.LowerRightCorner.Y += 1;
\r
328 draw3DSunkenPane(element,
\r
329 getColor( EGDC_WINDOW ).getInterpolated( 0xFFFFFFFF, 0.9f )
\r
330 ,false, true, rect, clip);
\r
334 Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip);
\r
336 rect.LowerRightCorner.X -= 1;
\r
337 rect.LowerRightCorner.Y -= 1;
\r
338 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip);
\r
340 rect.UpperLeftCorner.X += 1;
\r
341 rect.UpperLeftCorner.Y += 1;
\r
342 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip);
\r
344 rect.LowerRightCorner.X -= 1;
\r
345 rect.LowerRightCorner.Y -= 1;
\r
349 Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip);
\r
353 const video::SColor c1 = getColor(EGDC_3D_FACE);
\r
354 const video::SColor c2 = c1.getInterpolated(getColor(EGDC_3D_DARK_SHADOW), 0.4f);
\r
355 Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip);
\r
360 //! draws a pressed 3d button pane
\r
361 /** Used for drawing for example buttons in pressed state.
\r
362 It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
\r
363 EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
\r
364 \param rect: Defining area where to draw.
\r
365 \param clip: Clip area.
\r
366 \param element: Pointer to the element which wishes to draw this. This parameter
\r
367 is usually not used by ISkin, but can be used for example by more complex
\r
368 implementations to find out how to draw the part exactly. */
\r
369 void CGUISkin::draw3DButtonPanePressed(IGUIElement* element,
\r
370 const core::rect<s32>& r,
\r
371 const core::rect<s32>* clip)
\r
376 core::rect<s32> rect = r;
\r
377 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip);
\r
379 rect.LowerRightCorner.X -= 1;
\r
380 rect.LowerRightCorner.Y -= 1;
\r
381 Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip);
\r
383 rect.UpperLeftCorner.X += 1;
\r
384 rect.UpperLeftCorner.Y += 1;
\r
385 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip);
\r
387 rect.UpperLeftCorner.X += 1;
\r
388 rect.UpperLeftCorner.Y += 1;
\r
392 Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip);
\r
396 const video::SColor c1 = getColor(EGDC_3D_FACE);
\r
397 const video::SColor c2 = c1.getInterpolated(getColor(EGDC_3D_DARK_SHADOW), 0.4f);
\r
398 Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip);
\r
403 //! draws a sunken 3d pane
\r
404 /** Used for drawing the background of edit, combo or check boxes.
\r
405 \param element: Pointer to the element which wishes to draw this. This parameter
\r
406 is usually not used by ISkin, but can be used for example by more complex
\r
407 implementations to find out how to draw the part exactly.
\r
408 \param bgcolor: Background color.
\r
409 \param flat: Specifies if the sunken pane should be flat or displayed as sunken
\r
410 deep into the ground.
\r
411 \param rect: Defining area where to draw.
\r
412 \param clip: Clip area. */
\r
413 void CGUISkin::draw3DSunkenPane(IGUIElement* element, video::SColor bgcolor,
\r
414 bool flat, bool fillBackGround,
\r
415 const core::rect<s32>& r,
\r
416 const core::rect<s32>* clip)
\r
421 core::rect<s32> rect = r;
\r
423 if (fillBackGround)
\r
424 Driver->draw2DRectangle(bgcolor, rect, clip);
\r
428 // draw flat sunken pane
\r
430 rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1;
\r
431 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); // top
\r
433 ++rect.UpperLeftCorner.Y;
\r
434 rect.LowerRightCorner.Y = r.LowerRightCorner.Y;
\r
435 rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1;
\r
436 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); // left
\r
439 ++rect.UpperLeftCorner.Y;
\r
440 rect.UpperLeftCorner.X = rect.LowerRightCorner.X - 1;
\r
441 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); // right
\r
444 ++rect.UpperLeftCorner.X;
\r
445 rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1;
\r
446 --rect.LowerRightCorner.X;
\r
447 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); // bottom
\r
451 // draw deep sunken pane
\r
452 rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1;
\r
453 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); // top
\r
454 ++rect.UpperLeftCorner.X;
\r
455 ++rect.UpperLeftCorner.Y;
\r
456 --rect.LowerRightCorner.X;
\r
457 ++rect.LowerRightCorner.Y;
\r
458 Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip);
\r
460 rect.UpperLeftCorner.X = r.UpperLeftCorner.X;
\r
461 rect.UpperLeftCorner.Y = r.UpperLeftCorner.Y+1;
\r
462 rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1;
\r
463 rect.LowerRightCorner.Y = r.LowerRightCorner.Y;
\r
464 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip); // left
\r
465 ++rect.UpperLeftCorner.X;
\r
466 ++rect.UpperLeftCorner.Y;
\r
467 ++rect.LowerRightCorner.X;
\r
468 --rect.LowerRightCorner.Y;
\r
469 Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip);
\r
472 rect.UpperLeftCorner.X = rect.LowerRightCorner.X - 1;
\r
473 ++rect.UpperLeftCorner.Y;
\r
474 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); // right
\r
475 --rect.UpperLeftCorner.X;
\r
476 ++rect.UpperLeftCorner.Y;
\r
477 --rect.LowerRightCorner.X;
\r
478 --rect.LowerRightCorner.Y;
\r
479 Driver->draw2DRectangle(getColor(EGDC_3D_LIGHT), rect, clip);
\r
482 ++rect.UpperLeftCorner.X;
\r
483 rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1;
\r
484 --rect.LowerRightCorner.X;
\r
485 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); // bottom
\r
486 ++rect.UpperLeftCorner.X;
\r
487 --rect.UpperLeftCorner.Y;
\r
488 --rect.LowerRightCorner.X;
\r
489 --rect.LowerRightCorner.Y;
\r
490 Driver->draw2DRectangle(getColor(EGDC_3D_LIGHT), rect, clip);
\r
495 //! draws a window background
\r
496 // return where to draw title bar text.
\r
497 core::rect<s32> CGUISkin::draw3DWindowBackground(IGUIElement* element,
\r
498 bool drawTitleBar, video::SColor titleBarColor,
\r
499 const core::rect<s32>& r,
\r
500 const core::rect<s32>* clip,
\r
501 core::rect<s32>* checkClientArea)
\r
505 if ( checkClientArea )
\r
507 *checkClientArea = r;
\r
512 core::rect<s32> rect = r;
\r
515 rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1;
\r
516 if ( !checkClientArea )
\r
518 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip);
\r
522 rect.LowerRightCorner.Y = r.LowerRightCorner.Y;
\r
523 rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1;
\r
524 if ( !checkClientArea )
\r
526 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip);
\r
529 // right border dark outer line
\r
530 rect.UpperLeftCorner.X = r.LowerRightCorner.X - 1;
\r
531 rect.LowerRightCorner.X = r.LowerRightCorner.X;
\r
532 rect.UpperLeftCorner.Y = r.UpperLeftCorner.Y;
\r
533 rect.LowerRightCorner.Y = r.LowerRightCorner.Y;
\r
534 if ( !checkClientArea )
\r
536 Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip);
\r
539 // right border bright innner line
\r
540 rect.UpperLeftCorner.X -= 1;
\r
541 rect.LowerRightCorner.X -= 1;
\r
542 rect.UpperLeftCorner.Y += 1;
\r
543 rect.LowerRightCorner.Y -= 1;
\r
544 if ( !checkClientArea )
\r
546 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip);
\r
549 // bottom border dark outer line
\r
550 rect.UpperLeftCorner.X = r.UpperLeftCorner.X;
\r
551 rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1;
\r
552 rect.LowerRightCorner.Y = r.LowerRightCorner.Y;
\r
553 rect.LowerRightCorner.X = r.LowerRightCorner.X;
\r
554 if ( !checkClientArea )
\r
556 Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip);
\r
559 // bottom border bright inner line
\r
560 rect.UpperLeftCorner.X += 1;
\r
561 rect.LowerRightCorner.X -= 1;
\r
562 rect.UpperLeftCorner.Y -= 1;
\r
563 rect.LowerRightCorner.Y -= 1;
\r
564 if ( !checkClientArea )
\r
566 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip);
\r
569 // client area for background
\r
571 rect.UpperLeftCorner.X +=1;
\r
572 rect.UpperLeftCorner.Y +=1;
\r
573 rect.LowerRightCorner.X -= 2;
\r
574 rect.LowerRightCorner.Y -= 2;
\r
575 if (checkClientArea)
\r
577 *checkClientArea = rect;
\r
580 if ( !checkClientArea )
\r
584 Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip);
\r
586 else if ( Type == EGST_BURNING_SKIN )
\r
588 const video::SColor c1 = getColor(EGDC_WINDOW).getInterpolated ( 0xFFFFFFFF, 0.9f );
\r
589 const video::SColor c2 = getColor(EGDC_WINDOW).getInterpolated ( 0xFFFFFFFF, 0.8f );
\r
591 Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip);
\r
595 const video::SColor c2 = getColor(EGDC_3D_SHADOW);
\r
596 const video::SColor c1 = getColor(EGDC_3D_FACE);
\r
597 Driver->draw2DRectangle(rect, c1, c1, c1, c2, clip);
\r
603 rect.UpperLeftCorner.X += 2;
\r
604 rect.UpperLeftCorner.Y += 2;
\r
605 rect.LowerRightCorner.X -= 2;
\r
606 rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + getSize(EGDS_WINDOW_BUTTON_WIDTH) + 2;
\r
610 if (checkClientArea)
\r
612 (*checkClientArea).UpperLeftCorner.Y = rect.LowerRightCorner.Y;
\r
617 //if (!UseGradient)
\r
618 // Driver->draw2DRectangle(titleBarColor, rect, clip);
\r
620 if ( Type == EGST_BURNING_SKIN )
\r
622 const video::SColor c = titleBarColor.getInterpolated( video::SColor(titleBarColor.getAlpha(),255,255,255), 0.8f);
\r
623 Driver->draw2DRectangle(rect, titleBarColor, titleBarColor, c, c, clip);
\r
627 const video::SColor c = titleBarColor.getInterpolated(video::SColor(titleBarColor.getAlpha(),0,0,0), 0.2f);
\r
628 Driver->draw2DRectangle(rect, titleBarColor, c, titleBarColor, c, clip);
\r
637 //! draws a standard 3d menu pane
\r
638 /** Used for drawing for menus and context menus.
\r
639 It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
\r
640 EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
\r
641 \param element: Pointer to the element which wishes to draw this. This parameter
\r
642 is usually not used by ISkin, but can be used for example by more complex
\r
643 implementations to find out how to draw the part exactly.
\r
644 \param rect: Defining area where to draw.
\r
645 \param clip: Clip area. */
\r
646 void CGUISkin::draw3DMenuPane(IGUIElement* element,
\r
647 const core::rect<s32>& r, const core::rect<s32>* clip)
\r
652 core::rect<s32> rect = r;
\r
654 if ( Type == EGST_BURNING_SKIN )
\r
656 rect.UpperLeftCorner.Y -= 3;
\r
657 draw3DButtonPaneStandard(element, rect, clip);
\r
661 // in this skin, this is exactly what non pressed buttons look like,
\r
662 // so we could simply call
\r
663 // draw3DButtonPaneStandard(element, rect, clip);
\r
665 // but if the skin is transparent, this doesn't look that nice. So
\r
666 // We draw it a little bit better, with some more draw2DRectangle calls,
\r
667 // but there aren't that much menus visible anyway.
\r
669 rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1;
\r
670 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip);
\r
672 rect.LowerRightCorner.Y = r.LowerRightCorner.Y;
\r
673 rect.LowerRightCorner.X = rect.UpperLeftCorner.X + 1;
\r
674 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip);
\r
676 rect.UpperLeftCorner.X = r.LowerRightCorner.X - 1;
\r
677 rect.LowerRightCorner.X = r.LowerRightCorner.X;
\r
678 rect.UpperLeftCorner.Y = r.UpperLeftCorner.Y;
\r
679 rect.LowerRightCorner.Y = r.LowerRightCorner.Y;
\r
680 Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip);
\r
682 rect.UpperLeftCorner.X -= 1;
\r
683 rect.LowerRightCorner.X -= 1;
\r
684 rect.UpperLeftCorner.Y += 1;
\r
685 rect.LowerRightCorner.Y -= 1;
\r
686 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip);
\r
688 rect.UpperLeftCorner.X = r.UpperLeftCorner.X;
\r
689 rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1;
\r
690 rect.LowerRightCorner.Y = r.LowerRightCorner.Y;
\r
691 rect.LowerRightCorner.X = r.LowerRightCorner.X;
\r
692 Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), rect, clip);
\r
694 rect.UpperLeftCorner.X += 1;
\r
695 rect.LowerRightCorner.X -= 1;
\r
696 rect.UpperLeftCorner.Y -= 1;
\r
697 rect.LowerRightCorner.Y -= 1;
\r
698 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip);
\r
701 rect.UpperLeftCorner.X +=1;
\r
702 rect.UpperLeftCorner.Y +=1;
\r
703 rect.LowerRightCorner.X -= 2;
\r
704 rect.LowerRightCorner.Y -= 2;
\r
707 Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip);
\r
710 const video::SColor c1 = getColor(EGDC_3D_FACE);
\r
711 const video::SColor c2 = getColor(EGDC_3D_SHADOW);
\r
712 Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip);
\r
717 //! draws a standard 3d tool bar
\r
718 /** Used for drawing for toolbars and menus.
\r
719 \param element: Pointer to the element which wishes to draw this. This parameter
\r
720 is usually not used by ISkin, but can be used for example by more complex
\r
721 implementations to find out how to draw the part exactly.
\r
722 \param rect: Defining area where to draw.
\r
723 \param clip: Clip area. */
\r
724 void CGUISkin::draw3DToolBar(IGUIElement* element,
\r
725 const core::rect<s32>& r,
\r
726 const core::rect<s32>* clip)
\r
731 core::rect<s32> rect = r;
\r
733 rect.UpperLeftCorner.X = r.UpperLeftCorner.X;
\r
734 rect.UpperLeftCorner.Y = r.LowerRightCorner.Y - 1;
\r
735 rect.LowerRightCorner.Y = r.LowerRightCorner.Y;
\r
736 rect.LowerRightCorner.X = r.LowerRightCorner.X;
\r
737 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), rect, clip);
\r
740 rect.LowerRightCorner.Y -= 1;
\r
744 Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip);
\r
747 if ( Type == EGST_BURNING_SKIN )
\r
749 const video::SColor c1 = 0xF0000000 | getColor(EGDC_3D_FACE).color;
\r
750 const video::SColor c2 = 0xF0000000 | getColor(EGDC_3D_SHADOW).color;
\r
752 rect.LowerRightCorner.Y += 1;
\r
753 Driver->draw2DRectangle(rect, c1, c2, c1, c2, clip);
\r
757 const video::SColor c1 = getColor(EGDC_3D_FACE);
\r
758 const video::SColor c2 = getColor(EGDC_3D_SHADOW);
\r
759 Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip);
\r
764 //! draws a tab button
\r
765 /** Used for drawing for tab buttons on top of tabs.
\r
766 \param element: Pointer to the element which wishes to draw this. This parameter
\r
767 is usually not used by ISkin, but can be used for example by more complex
\r
768 implementations to find out how to draw the part exactly.
\r
769 \param active: Specifies if the tab is currently active.
\r
770 \param rect: Defining area where to draw.
\r
771 \param clip: Clip area. */
\r
772 void CGUISkin::draw3DTabButton(IGUIElement* element, bool active,
\r
773 const core::rect<s32>& frameRect, const core::rect<s32>* clip, EGUI_ALIGNMENT alignment)
\r
778 core::rect<s32> tr = frameRect;
\r
780 if ( alignment == EGUIA_UPPERLEFT )
\r
782 tr.LowerRightCorner.X -= 2;
\r
783 tr.LowerRightCorner.Y = tr.UpperLeftCorner.Y + 1;
\r
784 tr.UpperLeftCorner.X += 1;
\r
785 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
\r
787 // draw left highlight
\r
789 tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
\r
790 tr.UpperLeftCorner.Y += 1;
\r
791 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
\r
793 // draw grey background
\r
795 tr.UpperLeftCorner.X += 1;
\r
796 tr.UpperLeftCorner.Y += 1;
\r
797 tr.LowerRightCorner.X -= 2;
\r
798 Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip);
\r
800 // draw right middle gray shadow
\r
801 tr.LowerRightCorner.X += 1;
\r
802 tr.UpperLeftCorner.X = tr.LowerRightCorner.X - 1;
\r
803 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip);
\r
805 tr.LowerRightCorner.X += 1;
\r
806 tr.UpperLeftCorner.X += 1;
\r
807 tr.UpperLeftCorner.Y += 1;
\r
808 Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), tr, clip);
\r
812 tr.LowerRightCorner.X -= 2;
\r
813 tr.UpperLeftCorner.Y = tr.LowerRightCorner.Y - 1;
\r
814 tr.UpperLeftCorner.X += 1;
\r
815 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
\r
817 // draw left highlight
\r
819 tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
\r
820 tr.LowerRightCorner.Y -= 1;
\r
821 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
\r
823 // draw grey background
\r
825 tr.UpperLeftCorner.X += 1;
\r
826 tr.UpperLeftCorner.Y -= 1;
\r
827 tr.LowerRightCorner.X -= 2;
\r
828 tr.LowerRightCorner.Y -= 1;
\r
829 Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip);
\r
831 // draw right middle gray shadow
\r
832 tr.LowerRightCorner.X += 1;
\r
833 tr.UpperLeftCorner.X = tr.LowerRightCorner.X - 1;
\r
834 //tr.LowerRightCorner.Y -= 1;
\r
835 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip);
\r
837 tr.LowerRightCorner.X += 1;
\r
838 tr.UpperLeftCorner.X += 1;
\r
839 tr.LowerRightCorner.Y -= 1;
\r
840 Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), tr, clip);
\r
845 //! draws a tab control body
\r
846 /** \param element: Pointer to the element which wishes to draw this. This parameter
\r
847 is usually not used by ISkin, but can be used for example by more complex
\r
848 implementations to find out how to draw the part exactly.
\r
849 \param border: Specifies if the border should be drawn.
\r
850 \param background: Specifies if the background should be drawn.
\r
851 \param rect: Defining area where to draw.
\r
852 \param clip: Clip area. */
\r
853 void CGUISkin::draw3DTabBody(IGUIElement* element, bool border, bool background,
\r
854 const core::rect<s32>& rect, const core::rect<s32>* clip, s32 tabHeight, EGUI_ALIGNMENT alignment)
\r
859 core::rect<s32> tr = rect;
\r
861 if ( tabHeight == -1 )
\r
862 tabHeight = getSize(gui::EGDS_BUTTON_HEIGHT);
\r
867 if ( alignment == EGUIA_UPPERLEFT )
\r
869 // draw left hightlight
\r
870 tr.UpperLeftCorner.Y += tabHeight + 2;
\r
871 tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
\r
872 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
\r
874 // draw right shadow
\r
875 tr.UpperLeftCorner.X = rect.LowerRightCorner.X - 1;
\r
876 tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
\r
877 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip);
\r
879 // draw lower shadow
\r
881 tr.UpperLeftCorner.Y = tr.LowerRightCorner.Y - 1;
\r
882 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip);
\r
886 // draw left hightlight
\r
887 tr.LowerRightCorner.Y -= tabHeight + 2;
\r
888 tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
\r
889 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
\r
891 // draw right shadow
\r
892 tr.UpperLeftCorner.X = rect.LowerRightCorner.X - 1;
\r
893 tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1;
\r
894 Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip);
\r
896 // draw lower shadow
\r
898 tr.LowerRightCorner.Y = tr.UpperLeftCorner.Y + 1;
\r
899 Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip);
\r
905 if ( alignment == EGUIA_UPPERLEFT )
\r
908 tr.UpperLeftCorner.Y += tabHeight + 2;
\r
909 tr.LowerRightCorner.X -= 1;
\r
910 tr.UpperLeftCorner.X += 1;
\r
911 tr.LowerRightCorner.Y -= 1;
\r
916 tr.UpperLeftCorner.X += 1;
\r
917 tr.UpperLeftCorner.Y -= 1;
\r
918 tr.LowerRightCorner.X -= 1;
\r
919 tr.LowerRightCorner.Y -= tabHeight + 2;
\r
920 //tr.UpperLeftCorner.X += 1;
\r
924 Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip);
\r
927 video::SColor c1 = getColor(EGDC_3D_FACE);
\r
928 video::SColor c2 = getColor(EGDC_3D_SHADOW);
\r
929 Driver->draw2DRectangle(tr, c1, c1, c2, c2, clip);
\r
935 //! draws an icon, usually from the skin's sprite bank
\r
936 /** \param parent: Pointer to the element which wishes to draw this icon.
\r
937 This parameter is usually not used by IGUISkin, but can be used for example
\r
938 by more complex implementations to find out how to draw the part exactly.
\r
939 \param icon: Specifies the icon to be drawn.
\r
940 \param position: The position to draw the icon
\r
941 \param starttime: The time at the start of the animation
\r
942 \param currenttime: The present time, used to calculate the frame number
\r
943 \param loop: Whether the animation should loop or not
\r
944 \param clip: Clip area. */
\r
945 void CGUISkin::drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon,
\r
946 const core::position2di position,
\r
947 u32 starttime, u32 currenttime,
\r
948 bool loop, const core::rect<s32>* clip)
\r
953 bool gray = element && !element->isEnabled();
\r
954 SpriteBank->draw2DSprite(Icons[icon], position, clip,
\r
955 Colors[gray? EGDC_GRAY_WINDOW_SYMBOL : EGDC_WINDOW_SYMBOL], starttime, currenttime, loop, true);
\r
959 EGUI_SKIN_TYPE CGUISkin::getType() const
\r
965 //! draws a 2d rectangle.
\r
966 void CGUISkin::draw2DRectangle(IGUIElement* element,
\r
967 const video::SColor &color, const core::rect<s32>& pos,
\r
968 const core::rect<s32>* clip)
\r
970 Driver->draw2DRectangle(color, pos, clip);
\r
973 } // end namespace gui
\r
974 } // end namespace irr
\r