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 #ifndef __I_GUI_SKIN_H_INCLUDED__
\r
6 #define __I_GUI_SKIN_H_INCLUDED__
\r
8 #include "IReferenceCounted.h"
\r
9 #include "EGUIAlignment.h"
\r
18 class IGUISpriteBank;
\r
21 //! Enumeration of available default skins.
\r
22 /** To set one of the skins, use the following code, for example to set
\r
23 the Windows classic skin:
\r
25 gui::IGUISkin* newskin = environment->createSkin(gui::EGST_WINDOWS_CLASSIC);
\r
26 environment->setSkin(newskin);
\r
32 //! Default windows look and feel
\r
33 EGST_WINDOWS_CLASSIC=0,
\r
35 //! Like EGST_WINDOWS_CLASSIC, but with metallic shaded windows and buttons
\r
36 EGST_WINDOWS_METALLIC,
\r
41 //! An unknown skin, not serializable at present
\r
44 //! this value is not used, it only specifies the number of skin types
\r
48 //! Names for gui element types
\r
49 const c8* const GUISkinTypeNames[EGST_COUNT+1] =
\r
59 //! Enumeration for skin colors
\r
60 enum EGUI_DEFAULT_COLOR
\r
62 //! Dark shadow for three-dimensional display elements.
\r
63 EGDC_3D_DARK_SHADOW = 0,
\r
64 //! Shadow color for three-dimensional display elements (for edges facing away from the light source).
\r
66 //! Face color for three-dimensional display elements and for dialog box backgrounds.
\r
68 //! Highlight color for three-dimensional display elements (for edges facing the light source.)
\r
70 //! Light color for three-dimensional display elements (for edges facing the light source.)
\r
72 //! Active window border.
\r
74 //! Active window title bar text.
\r
75 EGDC_ACTIVE_CAPTION,
\r
76 //! Background color of multiple document interface (MDI) applications.
\r
78 //! Text on a button
\r
80 //! Grayed (disabled) text.
\r
82 //! Item(s) selected in a control.
\r
84 //! Text of item(s) selected in a control.
\r
85 EGDC_HIGH_LIGHT_TEXT,
\r
86 //! Inactive window border.
\r
87 EGDC_INACTIVE_BORDER,
\r
88 //! Inactive window caption.
\r
89 EGDC_INACTIVE_CAPTION,
\r
90 //! Tool tip text color
\r
92 //! Tool tip background color
\r
93 EGDC_TOOLTIP_BACKGROUND,
\r
94 //! Scrollbar gray area
\r
96 //! Window background
\r
98 //! Window symbols like on close buttons, scroll bars and check boxes
\r
100 //! Icons in a list or tree
\r
102 //! Selected icons in a list or tree
\r
103 EGDC_ICON_HIGH_LIGHT,
\r
104 //! Grayed (disabled) window symbols like on close buttons, scroll bars and check boxes
\r
105 EGDC_GRAY_WINDOW_SYMBOL,
\r
106 //! Window background for editable field (editbox, checkbox-field)
\r
108 //! Grayed (disabled) window background for editable field (editbox, checkbox-field)
\r
109 EGDC_GRAY_EDITABLE,
\r
110 //! Show focus of window background for editable field (editbox or when checkbox-field is pressed)
\r
111 EGDC_FOCUSED_EDITABLE,
\r
113 //! this value is not used, it only specifies the amount of default colors
\r
118 //! Names for default skin colors
\r
119 const c8* const GUISkinColorNames[EGDC_COUNT+1] =
\r
136 "ToolTipBackground",
\r
142 "GrayWindowSymbol",
\r
149 //! Enumeration for default sizes.
\r
150 enum EGUI_DEFAULT_SIZE
\r
152 //! default with / height of scrollbar. Also width of drop-down button in comboboxes.
\r
153 EGDS_SCROLLBAR_SIZE = 0,
\r
156 //! width and height of a window titlebar button (like minimize/maximize/close buttons). The titlebar height is also calculated from that.
\r
157 EGDS_WINDOW_BUTTON_WIDTH,
\r
158 //! width of a checkbox check
\r
159 EGDS_CHECK_BOX_WIDTH,
\r
160 //! \deprecated This may be removed by Irrlicht 1.9
\r
161 EGDS_MESSAGE_BOX_WIDTH,
\r
162 //! \deprecated This may be removed by Irrlicht 1.9
\r
163 EGDS_MESSAGE_BOX_HEIGHT,
\r
164 //! width of a default button
\r
166 //! height of a default button (OK and cancel buttons)
\r
167 EGDS_BUTTON_HEIGHT,
\r
168 //! distance for text from background
\r
169 EGDS_TEXT_DISTANCE_X,
\r
170 //! distance for text from background
\r
171 EGDS_TEXT_DISTANCE_Y,
\r
172 //! distance for text in the title bar, from the left of the window rect
\r
173 EGDS_TITLEBARTEXT_DISTANCE_X,
\r
174 //! distance for text in the title bar, from the top of the window rect
\r
175 EGDS_TITLEBARTEXT_DISTANCE_Y,
\r
176 //! free space in a messagebox between borders and contents on all sides
\r
177 EGDS_MESSAGE_BOX_GAP_SPACE,
\r
178 //! minimal space to reserve for messagebox text-width
\r
179 EGDS_MESSAGE_BOX_MIN_TEXT_WIDTH,
\r
180 //! maximal space to reserve for messagebox text-width
\r
181 EGDS_MESSAGE_BOX_MAX_TEXT_WIDTH,
\r
182 //! minimal space to reserve for messagebox text-height
\r
183 EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT,
\r
184 //! maximal space to reserve for messagebox text-height
\r
185 EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT,
\r
186 //! pixels to move an unscaled button image to the right when a button is pressed and the unpressed image looks identical
\r
187 EGDS_BUTTON_PRESSED_IMAGE_OFFSET_X,
\r
188 //! pixels to move an unscaled button image down when a button is pressed and the unpressed image looks identical
\r
189 EGDS_BUTTON_PRESSED_IMAGE_OFFSET_Y,
\r
190 //! pixels to move the button text to the right when a button is pressed
\r
191 EGDS_BUTTON_PRESSED_TEXT_OFFSET_X,
\r
192 //! pixels to move the button text down when a button is pressed
\r
193 EGDS_BUTTON_PRESSED_TEXT_OFFSET_Y,
\r
194 //! pixels to move an unscaled button sprite to the right when a button is pressed
\r
195 EGDS_BUTTON_PRESSED_SPRITE_OFFSET_X,
\r
196 //! pixels to move an unscaled button sprite down when a button is pressed
\r
197 EGDS_BUTTON_PRESSED_SPRITE_OFFSET_Y,
\r
199 //! this value is not used, it only specifies the amount of default sizes
\r
205 //! Names for default skin sizes
\r
206 const c8* const GUISkinSizeNames[EGDS_COUNT+1] =
\r
210 "WindowButtonWidth",
\r
213 "MessageBoxHeight",
\r
220 "MessageBoxGapSpace",
\r
221 "MessageBoxMinTextWidth",
\r
222 "MessageBoxMaxTextWidth",
\r
223 "MessageBoxMinTextHeight",
\r
224 "MessageBoxMaxTextHeight",
\r
225 "ButtonPressedImageOffsetX",
\r
226 "ButtonPressedImageOffsetY",
\r
227 "ButtonPressedTextOffsetX",
\r
228 "ButtonPressedTextOffsetY",
\r
229 "ButtonPressedSpriteOffsetX",
\r
230 "ButtonPressedSpriteOffsetY",
\r
235 enum EGUI_DEFAULT_TEXT
\r
237 //! Text for the OK button on a message box
\r
238 EGDT_MSG_BOX_OK = 0,
\r
239 //! Text for the Cancel button on a message box
\r
240 EGDT_MSG_BOX_CANCEL,
\r
241 //! Text for the Yes button on a message box
\r
243 //! Text for the No button on a message box
\r
245 //! Tooltip text for window close button
\r
247 //! Tooltip text for window maximize button
\r
248 EGDT_WINDOW_MAXIMIZE,
\r
249 //! Tooltip text for window minimize button
\r
250 EGDT_WINDOW_MINIMIZE,
\r
251 //! Tooltip text for window restore button
\r
252 EGDT_WINDOW_RESTORE,
\r
254 //! this value is not used, it only specifies the number of default texts
\r
258 //! Names for default skin sizes
\r
259 const c8* const GUISkinTextNames[EGDT_COUNT+1] =
\r
262 "MessageBoxCancel",
\r
265 "WindowButtonClose",
\r
266 "WindowButtonMaximize",
\r
267 "WindowButtonMinimize",
\r
268 "WindowButtonRestore",
\r
272 //! Customizable symbols for GUI
\r
273 enum EGUI_DEFAULT_ICON
\r
275 //! maximize window button
\r
276 EGDI_WINDOW_MAXIMIZE = 0,
\r
277 //! restore window button
\r
278 EGDI_WINDOW_RESTORE,
\r
279 //! close window button
\r
281 //! minimize window button
\r
282 EGDI_WINDOW_MINIMIZE,
\r
283 //! resize icon for bottom right corner of a window
\r
284 EGDI_WINDOW_RESIZE,
\r
285 //! scroll bar up button
\r
287 //! scroll bar down button
\r
289 //! scroll bar left button
\r
291 //! scroll bar right button
\r
293 //! icon for menu children
\r
295 //! tick for checkbox
\r
296 EGDI_CHECK_BOX_CHECKED,
\r
297 //! down arrow for dropdown menus
\r
299 //! smaller up arrow
\r
300 EGDI_SMALL_CURSOR_UP,
\r
301 //! smaller down arrow
\r
302 EGDI_SMALL_CURSOR_DOWN,
\r
303 //! selection dot in a radio button
\r
304 EGDI_RADIO_BUTTON_CHECKED,
\r
305 //! << icon indicating there is more content to the left
\r
307 //! >> icon indicating that there is more content to the right
\r
309 //! icon indicating that there is more content above
\r
311 //! icon indicating that there is more content below
\r
313 //! plus icon for trees
\r
316 //! minus icon for trees
\r
318 //! file icon for file selection
\r
320 //! folder icon for file selection
\r
323 //! value not used, it only specifies the number of icons
\r
327 const c8* const GUISkinIconNames[EGDI_COUNT+1] =
\r
343 "radioButtonChecked",
\r
355 // Customizable fonts
\r
356 enum EGUI_DEFAULT_FONT
\r
358 //! For static text, edit boxes, lists and most other places
\r
360 //! Font for buttons
\r
362 //! Font for window title bars
\r
364 //! Font for menu items
\r
366 //! Font for tooltips
\r
368 //! this value is not used, it only specifies the amount of default fonts
\r
373 const c8* const GUISkinFontNames[EGDF_COUNT+1] =
\r
383 //! A skin modifies the look of the GUI elements.
\r
384 class IGUISkin : virtual public IReferenceCounted
\r
388 //! returns default color
\r
389 virtual video::SColor getColor(EGUI_DEFAULT_COLOR color) const = 0;
\r
391 //! sets a default color
\r
392 virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor) = 0;
\r
394 //! returns size for the given size type
\r
395 virtual s32 getSize(EGUI_DEFAULT_SIZE size) const = 0;
\r
397 //! Returns a default text.
\r
398 /** For example for Message box button captions:
\r
399 "OK", "Cancel", "Yes", "No" and so on. */
\r
400 virtual const wchar_t* getDefaultText(EGUI_DEFAULT_TEXT text) const = 0;
\r
402 //! Sets a default text.
\r
403 /** For example for Message box button captions:
\r
404 "OK", "Cancel", "Yes", "No" and so on. */
\r
405 virtual void setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText) = 0;
\r
407 //! sets a default size
\r
408 virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size) = 0;
\r
410 //! returns the default font
\r
411 virtual IGUIFont* getFont(EGUI_DEFAULT_FONT which=EGDF_DEFAULT) const = 0;
\r
413 //! sets a default font
\r
414 virtual void setFont(IGUIFont* font, EGUI_DEFAULT_FONT which=EGDF_DEFAULT) = 0;
\r
416 //! returns the sprite bank
\r
417 virtual IGUISpriteBank* getSpriteBank() const = 0;
\r
419 //! sets the sprite bank
\r
420 virtual void setSpriteBank(IGUISpriteBank* bank) = 0;
\r
422 //! Returns a default icon
\r
423 /** Returns the sprite index within the sprite bank */
\r
424 virtual u32 getIcon(EGUI_DEFAULT_ICON icon) const = 0;
\r
426 //! Sets a default icon
\r
427 /** Sets the sprite index used for drawing icons like arrows,
\r
428 close buttons and ticks in checkboxes
\r
429 \param icon: Enum specifying which icon to change
\r
430 \param index: The sprite index used to draw this icon */
\r
431 virtual void setIcon(EGUI_DEFAULT_ICON icon, u32 index) = 0;
\r
433 //! draws a standard 3d button pane
\r
434 /** Used for drawing for example buttons in normal state.
\r
435 It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
\r
436 EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
\r
437 \param element: Pointer to the element which wishes to draw this. This parameter
\r
438 is usually not used by IGUISkin, but can be used for example by more complex
\r
439 implementations to find out how to draw the part exactly.
\r
440 \param rect: Defining area where to draw.
\r
441 \param clip: Clip area. */
\r
442 virtual void draw3DButtonPaneStandard(IGUIElement* element,
\r
443 const core::rect<s32>& rect,
\r
444 const core::rect<s32>* clip=0) = 0;
\r
446 //! draws a pressed 3d button pane
\r
447 /** Used for drawing for example buttons in pressed state.
\r
448 It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
\r
449 EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
\r
450 \param element: Pointer to the element which wishes to draw this. This parameter
\r
451 is usually not used by IGUISkin, but can be used for example by more complex
\r
452 implementations to find out how to draw the part exactly.
\r
453 \param rect: Defining area where to draw.
\r
454 \param clip: Clip area. */
\r
455 virtual void draw3DButtonPanePressed(IGUIElement* element,
\r
456 const core::rect<s32>& rect,
\r
457 const core::rect<s32>* clip=0) = 0;
\r
459 //! draws a sunken 3d pane
\r
460 /** Used for drawing the background of edit, combo or check boxes.
\r
461 \param element: Pointer to the element which wishes to draw this. This parameter
\r
462 is usually not used by IGUISkin, but can be used for example by more complex
\r
463 implementations to find out how to draw the part exactly.
\r
464 \param bgcolor: Background color.
\r
465 \param flat: Specifies if the sunken pane should be flat or displayed as sunken
\r
466 deep into the ground.
\r
467 \param fillBackGround: Specifies if the background should be filled with the background
\r
468 color or not be drawn at all.
\r
469 \param rect: Defining area where to draw.
\r
470 \param clip: Clip area. */
\r
471 virtual void draw3DSunkenPane(IGUIElement* element,
\r
472 video::SColor bgcolor, bool flat, bool fillBackGround,
\r
473 const core::rect<s32>& rect,
\r
474 const core::rect<s32>* clip=0) = 0;
\r
476 //! draws a window background
\r
477 /** Used for drawing the background of dialogs and windows.
\r
478 \param element: Pointer to the element which wishes to draw this. This parameter
\r
479 is usually not used by IGUISkin, but can be used for example by more complex
\r
480 implementations to find out how to draw the part exactly.
\r
481 \param titleBarColor: Title color.
\r
482 \param drawTitleBar: True to enable title drawing.
\r
483 \param rect: Defining area where to draw.
\r
484 \param clip: Clip area.
\r
485 \param checkClientArea: When set to non-null the function will not draw anything,
\r
486 but will instead return the clientArea which can be used for drawing by the calling window.
\r
487 That is the area without borders and without titlebar.
\r
488 \return Returns rect where it would be good to draw title bar text. This will
\r
489 work even when checkClientArea is set to a non-null value.*/
\r
490 virtual core::rect<s32> draw3DWindowBackground(IGUIElement* element,
\r
491 bool drawTitleBar, video::SColor titleBarColor,
\r
492 const core::rect<s32>& rect,
\r
493 const core::rect<s32>* clip=0,
\r
494 core::rect<s32>* checkClientArea=0) = 0;
\r
496 //! draws a standard 3d menu pane
\r
497 /** Used for drawing for menus and context menus.
\r
498 It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
\r
499 EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
\r
500 \param element: Pointer to the element which wishes to draw this. This parameter
\r
501 is usually not used by IGUISkin, but can be used for example by more complex
\r
502 implementations to find out how to draw the part exactly.
\r
503 \param rect: Defining area where to draw.
\r
504 \param clip: Clip area. */
\r
505 virtual void draw3DMenuPane(IGUIElement* element,
\r
506 const core::rect<s32>& rect,
\r
507 const core::rect<s32>* clip=0) = 0;
\r
509 //! draws a standard 3d tool bar
\r
510 /** Used for drawing for toolbars and menus.
\r
511 \param element: Pointer to the element which wishes to draw this. This parameter
\r
512 is usually not used by IGUISkin, but can be used for example by more complex
\r
513 implementations to find out how to draw the part exactly.
\r
514 \param rect: Defining area where to draw.
\r
515 \param clip: Clip area. */
\r
516 virtual void draw3DToolBar(IGUIElement* element,
\r
517 const core::rect<s32>& rect,
\r
518 const core::rect<s32>* clip=0) = 0;
\r
520 //! draws a tab button
\r
521 /** Used for drawing for tab buttons on top of tabs.
\r
522 \param element: Pointer to the element which wishes to draw this. This parameter
\r
523 is usually not used by IGUISkin, but can be used for example by more complex
\r
524 implementations to find out how to draw the part exactly.
\r
525 \param active: Specifies if the tab is currently active.
\r
526 \param rect: Defining area where to draw.
\r
527 \param clip: Clip area.
\r
528 \param alignment Alignment of GUI element. */
\r
529 virtual void draw3DTabButton(IGUIElement* element, bool active,
\r
530 const core::rect<s32>& rect, const core::rect<s32>* clip=0, gui::EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT) = 0;
\r
532 //! draws a tab control body
\r
533 /** \param element: Pointer to the element which wishes to draw this. This parameter
\r
534 is usually not used by IGUISkin, but can be used for example by more complex
\r
535 implementations to find out how to draw the part exactly.
\r
536 \param border: Specifies if the border should be drawn.
\r
537 \param background: Specifies if the background should be drawn.
\r
538 \param rect: Defining area where to draw.
\r
539 \param clip: Clip area.
\r
540 \param tabHeight Height of tab.
\r
541 \param alignment Alignment of GUI element. */
\r
542 virtual void draw3DTabBody(IGUIElement* element, bool border, bool background,
\r
543 const core::rect<s32>& rect, const core::rect<s32>* clip=0, s32 tabHeight=-1, gui::EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT ) = 0;
\r
545 //! draws an icon, usually from the skin's sprite bank
\r
546 /** \param element: Pointer to the element which wishes to draw this icon.
\r
547 This parameter is usually not used by IGUISkin, but can be used for example
\r
548 by more complex implementations to find out how to draw the part exactly.
\r
549 \param icon: Specifies the icon to be drawn.
\r
550 \param position: The position to draw the icon
\r
551 \param starttime: The time at the start of the animation
\r
552 \param currenttime: The present time, used to calculate the frame number
\r
553 \param loop: Whether the animation should loop or not
\r
554 \param clip: Clip area. */
\r
555 virtual void drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon,
\r
556 const core::position2di position, u32 starttime=0, u32 currenttime=0,
\r
557 bool loop=false, const core::rect<s32>* clip=0) = 0;
\r
559 //! draws a 2d rectangle.
\r
560 /** \param element: Pointer to the element which wishes to draw this icon.
\r
561 This parameter is usually not used by IGUISkin, but can be used for example
\r
562 by more complex implementations to find out how to draw the part exactly.
\r
563 \param color: Color of the rectangle to draw. The alpha component specifies how
\r
564 transparent the rectangle will be.
\r
565 \param pos: Position of the rectangle.
\r
566 \param clip: Pointer to rectangle against which the rectangle will be clipped.
\r
567 If the pointer is null, no clipping will be performed. */
\r
568 virtual void draw2DRectangle(IGUIElement* element, const video::SColor &color,
\r
569 const core::rect<s32>& pos, const core::rect<s32>* clip = 0) = 0;
\r
571 //! get the type of this skin
\r
572 virtual EGUI_SKIN_TYPE getType() const { return EGST_UNKNOWN; }
\r
576 } // end namespace gui
\r
577 } // end namespace irr
\r