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 __GUI_SKIN_H_INCLUDED__
\r
6 #define __GUI_SKIN_H_INCLUDED__
\r
8 #include "IGUISkin.h"
\r
9 #include "irrString.h"
\r
11 #include "ITexture.h"
\r
21 class GUISkin : public IGUISkin
\r
25 GUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver);
\r
30 //! returns default color
\r
31 virtual video::SColor getColor(EGUI_DEFAULT_COLOR color) const;
\r
33 //! sets a default color
\r
34 virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor);
\r
36 //! returns size for the given size type
\r
37 virtual s32 getSize(EGUI_DEFAULT_SIZE size) const;
\r
39 //! sets a default size
\r
40 virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size);
\r
42 //! returns the default font
\r
43 virtual IGUIFont* getFont(EGUI_DEFAULT_FONT which=EGDF_DEFAULT) const;
\r
45 //! sets a default font
\r
46 virtual void setFont(IGUIFont* font, EGUI_DEFAULT_FONT which=EGDF_DEFAULT);
\r
48 //! sets the sprite bank used for drawing icons
\r
49 virtual void setSpriteBank(IGUISpriteBank* bank);
\r
51 //! gets the sprite bank used for drawing icons
\r
52 virtual IGUISpriteBank* getSpriteBank() const;
\r
54 //! Returns a default icon
\r
55 /** Returns the sprite index within the sprite bank */
\r
56 virtual u32 getIcon(EGUI_DEFAULT_ICON icon) const;
\r
58 //! Sets a default icon
\r
59 /** Sets the sprite index used for drawing icons like arrows,
\r
60 close buttons and ticks in checkboxes
\r
61 \param icon: Enum specifying which icon to change
\r
62 \param index: The sprite index used to draw this icon */
\r
63 virtual void setIcon(EGUI_DEFAULT_ICON icon, u32 index);
\r
65 //! Returns a default text.
\r
66 /** For example for Message box button captions:
\r
67 "OK", "Cancel", "Yes", "No" and so on. */
\r
68 virtual const wchar_t* getDefaultText(EGUI_DEFAULT_TEXT text) const;
\r
70 //! Sets a default text.
\r
71 /** For example for Message box button captions:
\r
72 "OK", "Cancel", "Yes", "No" and so on. */
\r
73 virtual void setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText);
\r
75 //! draws a standard 3d button pane
\r
76 /** Used for drawing for example buttons in normal state.
\r
77 It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
\r
78 EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
\r
79 \param rect: Defining area where to draw.
\r
80 \param clip: Clip area.
\r
81 \param element: Pointer to the element which wishes to draw this. This parameter
\r
82 is usually not used by ISkin, but can be used for example by more complex
\r
83 implementations to find out how to draw the part exactly. */
\r
84 virtual void draw3DButtonPaneStandard(IGUIElement* element,
\r
85 const core::rect<s32>& rect,
\r
86 const core::rect<s32>* clip=0)
\r
88 drawColored3DButtonPaneStandard(element, rect,clip);
\r
91 virtual void drawColored3DButtonPaneStandard(IGUIElement* element,
\r
92 const core::rect<s32>& rect,
\r
93 const core::rect<s32>* clip=0,
\r
94 const video::SColor* colors=0);
\r
96 //! draws a pressed 3d button pane
\r
97 /** Used for drawing for example buttons in pressed state.
\r
98 It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
\r
99 EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
\r
100 \param rect: Defining area where to draw.
\r
101 \param clip: Clip area.
\r
102 \param element: Pointer to the element which wishes to draw this. This parameter
\r
103 is usually not used by ISkin, but can be used for example by more complex
\r
104 implementations to find out how to draw the part exactly. */
\r
105 virtual void draw3DButtonPanePressed(IGUIElement* element,
\r
106 const core::rect<s32>& rect,
\r
107 const core::rect<s32>* clip=0)
\r
109 drawColored3DButtonPanePressed(element, rect, clip);
\r
112 virtual void drawColored3DButtonPanePressed(IGUIElement* element,
\r
113 const core::rect<s32>& rect,
\r
114 const core::rect<s32>* clip=0,
\r
115 const video::SColor* colors=0);
\r
117 //! draws a sunken 3d pane
\r
118 /** Used for drawing the background of edit, combo or check boxes.
\r
119 \param element: Pointer to the element which wishes to draw this. This parameter
\r
120 is usually not used by ISkin, but can be used for example by more complex
\r
121 implementations to find out how to draw the part exactly.
\r
122 \param bgcolor: Background color.
\r
123 \param flat: Specifies if the sunken pane should be flat or displayed as sunken
\r
124 deep into the ground.
\r
125 \param rect: Defining area where to draw.
\r
126 \param clip: Clip area. */
\r
127 virtual void draw3DSunkenPane(IGUIElement* element,
\r
128 video::SColor bgcolor, bool flat,
\r
129 bool fillBackGround,
\r
130 const core::rect<s32>& rect,
\r
131 const core::rect<s32>* clip=0)
\r
133 drawColored3DSunkenPane(element, bgcolor, flat, fillBackGround, rect, clip);
\r
136 virtual void drawColored3DSunkenPane(IGUIElement* element,
\r
137 video::SColor bgcolor, bool flat,
\r
138 bool fillBackGround,
\r
139 const core::rect<s32>& rect,
\r
140 const core::rect<s32>* clip=0,
\r
141 const video::SColor* colors=0);
\r
143 //! draws a window background
\r
144 /** Used for drawing the background of dialogs and windows.
\r
145 \param element: Pointer to the element which wishes to draw this. This parameter
\r
146 is usually not used by ISkin, but can be used for example by more complex
\r
147 implementations to find out how to draw the part exactly.
\r
148 \param titleBarColor: Title color.
\r
149 \param drawTitleBar: True to enable title drawing.
\r
150 \param rect: Defining area where to draw.
\r
151 \param clip: Clip area.
\r
152 \param checkClientArea: When set to non-null the function will not draw anything,
\r
153 but will instead return the clientArea which can be used for drawing by the calling window.
\r
154 That is the area without borders and without titlebar.
\r
155 \return Returns rect where it would be good to draw title bar text. This will
\r
156 work even when checkClientArea is set to a non-null value.*/
\r
157 virtual core::rect<s32> draw3DWindowBackground(IGUIElement* element,
\r
158 bool drawTitleBar, video::SColor titleBarColor,
\r
159 const core::rect<s32>& rect,
\r
160 const core::rect<s32>* clip,
\r
161 core::rect<s32>* checkClientArea)
\r
163 return drawColored3DWindowBackground(element, drawTitleBar, titleBarColor,
\r
164 rect, clip, checkClientArea);
\r
167 virtual core::rect<s32> drawColored3DWindowBackground(IGUIElement* element,
\r
168 bool drawTitleBar, video::SColor titleBarColor,
\r
169 const core::rect<s32>& rect,
\r
170 const core::rect<s32>* clip,
\r
171 core::rect<s32>* checkClientArea,
\r
172 const video::SColor* colors=0);
\r
174 //! draws a standard 3d menu pane
\r
175 /** Used for drawing for menus and context menus.
\r
176 It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
\r
177 EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
\r
178 \param element: Pointer to the element which wishes to draw this. This parameter
\r
179 is usually not used by ISkin, but can be used for example by more complex
\r
180 implementations to find out how to draw the part exactly.
\r
181 \param rect: Defining area where to draw.
\r
182 \param clip: Clip area. */
\r
183 virtual void draw3DMenuPane(IGUIElement* element,
\r
184 const core::rect<s32>& rect,
\r
185 const core::rect<s32>* clip=0)
\r
187 drawColored3DMenuPane(element, rect, clip);
\r
190 virtual void drawColored3DMenuPane(IGUIElement* element,
\r
191 const core::rect<s32>& rect,
\r
192 const core::rect<s32>* clip=0,
\r
193 const video::SColor* colors=0);
\r
195 //! draws a standard 3d tool bar
\r
196 /** Used for drawing for toolbars and menus.
\r
197 \param element: Pointer to the element which wishes to draw this. This parameter
\r
198 is usually not used by ISkin, but can be used for example by more complex
\r
199 implementations to find out how to draw the part exactly.
\r
200 \param rect: Defining area where to draw.
\r
201 \param clip: Clip area. */
\r
202 virtual void draw3DToolBar(IGUIElement* element,
\r
203 const core::rect<s32>& rect,
\r
204 const core::rect<s32>* clip=0)
\r
206 drawColored3DToolBar(element, rect, clip);
\r
209 virtual void drawColored3DToolBar(IGUIElement* element,
\r
210 const core::rect<s32>& rect,
\r
211 const core::rect<s32>* clip=0,
\r
212 const video::SColor* colors=0);
\r
214 //! draws a tab button
\r
215 /** Used for drawing for tab buttons on top of tabs.
\r
216 \param element: Pointer to the element which wishes to draw this. This parameter
\r
217 is usually not used by ISkin, but can be used for example by more complex
\r
218 implementations to find out how to draw the part exactly.
\r
219 \param active: Specifies if the tab is currently active.
\r
220 \param rect: Defining area where to draw.
\r
221 \param clip: Clip area. */
\r
222 virtual void draw3DTabButton(IGUIElement* element, bool active,
\r
223 const core::rect<s32>& rect, const core::rect<s32>* clip=0, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT)
\r
225 drawColored3DTabButton(element, active, rect, clip, alignment);
\r
228 virtual void drawColored3DTabButton(IGUIElement* element, bool active,
\r
229 const core::rect<s32>& rect, const core::rect<s32>* clip=0, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT,
\r
230 const video::SColor* colors=0);
\r
232 //! draws a tab control body
\r
233 /** \param element: Pointer to the element which wishes to draw this. This parameter
\r
234 is usually not used by ISkin, but can be used for example by more complex
\r
235 implementations to find out how to draw the part exactly.
\r
236 \param border: Specifies if the border should be drawn.
\r
237 \param background: Specifies if the background should be drawn.
\r
238 \param rect: Defining area where to draw.
\r
239 \param clip: Clip area. */
\r
240 virtual void draw3DTabBody(IGUIElement* element, bool border, bool background,
\r
241 const core::rect<s32>& rect, const core::rect<s32>* clip=0, s32 tabHeight=-1, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT)
\r
243 drawColored3DTabBody(element, border, background, rect, clip, tabHeight, alignment);
\r
246 virtual void drawColored3DTabBody(IGUIElement* element, bool border, bool background,
\r
247 const core::rect<s32>& rect, const core::rect<s32>* clip=0, s32 tabHeight=-1, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT,
\r
248 const video::SColor* colors=0);
\r
250 //! draws an icon, usually from the skin's sprite bank
\r
251 /** \param element: Pointer to the element which wishes to draw this icon.
\r
252 This parameter is usually not used by IGUISkin, but can be used for example
\r
253 by more complex implementations to find out how to draw the part exactly.
\r
254 \param icon: Specifies the icon to be drawn.
\r
255 \param position: The position to draw the icon
\r
256 \param starttime: The time at the start of the animation
\r
257 \param currenttime: The present time, used to calculate the frame number
\r
258 \param loop: Whether the animation should loop or not
\r
259 \param clip: Clip area. */
\r
260 virtual void drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon,
\r
261 const core::position2di position,
\r
262 u32 starttime=0, u32 currenttime=0,
\r
263 bool loop=false, const core::rect<s32>* clip=0)
\r
265 drawColoredIcon(element, icon, position, starttime, currenttime, loop, clip);
\r
268 virtual void drawColoredIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon,
\r
269 const core::position2di position,
\r
270 u32 starttime=0, u32 currenttime=0,
\r
271 bool loop=false, const core::rect<s32>* clip=0,
\r
272 const video::SColor* colors=0);
\r
274 //! draws a 2d rectangle.
\r
275 /** \param element: Pointer to the element which wishes to draw this icon.
\r
276 This parameter is usually not used by IGUISkin, but can be used for example
\r
277 by more complex implementations to find out how to draw the part exactly.
\r
278 \param color: Color of the rectangle to draw. The alpha component specifies how
\r
279 transparent the rectangle will be.
\r
280 \param pos: Position of the rectangle.
\r
281 \param clip: Pointer to rectangle against which the rectangle will be clipped.
\r
282 If the pointer is null, no clipping will be performed. */
\r
283 virtual void draw2DRectangle(IGUIElement* element, const video::SColor &color,
\r
284 const core::rect<s32>& pos, const core::rect<s32>* clip = 0);
\r
287 //! get the type of this skin
\r
288 virtual EGUI_SKIN_TYPE getType() const;
\r
290 //! gets the colors
\r
291 virtual void getColors(video::SColor* colors); // ::PATCH:
\r
295 video::SColor Colors[EGDC_COUNT];
\r
296 s32 Sizes[EGDS_COUNT];
\r
297 u32 Icons[EGDI_COUNT];
\r
298 IGUIFont* Fonts[EGDF_COUNT];
\r
299 IGUISpriteBank* SpriteBank;
\r
300 core::stringw Texts[EGDT_COUNT];
\r
301 video::IVideoDriver* Driver;
\r
304 EGUI_SKIN_TYPE Type;
\r
307 #define set3DSkinColors(skin, button_color) \
\r
309 skin->setColor(EGDC_3D_FACE, button_color); \
\r
310 skin->setColor(EGDC_3D_DARK_SHADOW, button_color, 0.25f); \
\r
311 skin->setColor(EGDC_3D_SHADOW, button_color, 0.5f); \
\r
312 skin->setColor(EGDC_3D_LIGHT, button_color); \
\r
313 skin->setColor(EGDC_3D_HIGH_LIGHT, button_color, 1.5f); \
\r
316 #define getElementSkinColor(color) \
\r
320 IGUISkin* skin = Environment->getSkin(); \
\r
322 return skin->getColor(color); \
\r
324 return Colors[color]; \
\r
327 #define setElementSkinColor(which, newColor, shading) \
\r
331 Colors = new video::SColor[EGDC_COUNT]; \
\r
332 GUISkin* skin = (GUISkin *)Environment->getSkin(); \
\r
334 skin->getColors(Colors); \
\r
336 Colors[which] = newColor; \
\r
337 setShading(Colors[which],shading); \
\r
339 } // end namespace gui
\r
340 //! Sets the shading
\r
341 inline void setShading(video::SColor &color,f32 s) // :PATCH:
\r
345 color.setRed(color.getRed() * s);
\r
346 color.setGreen(color.getGreen() * s);
\r
347 color.setBlue(color.getBlue() * s);
\r
353 color.setRed(color.getRed() + (255 - color.getRed()) * s);
\r
354 color.setGreen(color.getGreen() + (255 - color.getGreen()) * s);
\r
355 color.setBlue(color.getBlue() + (255 - color.getBlue()) * s);
\r
358 } // end namespace irr
\r