CGUISkin.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. // Copyright (C) 2002-2012 Nikolaus Gebhardt
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #ifndef __C_GUI_SKIN_H_INCLUDED__
  5. #define __C_GUI_SKIN_H_INCLUDED__
  6. #include "IrrCompileConfig.h"
  7. #ifdef _IRR_COMPILE_WITH_GUI_
  8. #include "IGUISkin.h"
  9. #include "irrString.h"
  10. namespace irr
  11. {
  12. namespace video
  13. {
  14. class IVideoDriver;
  15. }
  16. namespace gui
  17. {
  18. class CGUISkin : public IGUISkin
  19. {
  20. public:
  21. CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver);
  22. //! destructor
  23. virtual ~CGUISkin();
  24. //! returns default color
  25. virtual video::SColor getColor(EGUI_DEFAULT_COLOR color) const;
  26. //! sets a default color
  27. virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor);
  28. //! returns size for the given size type
  29. virtual s32 getSize(EGUI_DEFAULT_SIZE size) const;
  30. //! sets a default size
  31. virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size);
  32. //! returns the default font
  33. virtual IGUIFont* getFont(EGUI_DEFAULT_FONT which=EGDF_DEFAULT) const;
  34. //! sets a default font
  35. virtual void setFont(IGUIFont* font, EGUI_DEFAULT_FONT which=EGDF_DEFAULT);
  36. //! sets the sprite bank used for drawing icons
  37. virtual void setSpriteBank(IGUISpriteBank* bank);
  38. //! gets the sprite bank used for drawing icons
  39. virtual IGUISpriteBank* getSpriteBank() const;
  40. //! Returns a default icon
  41. /** Returns the sprite index within the sprite bank */
  42. virtual u32 getIcon(EGUI_DEFAULT_ICON icon) const;
  43. //! Sets a default icon
  44. /** Sets the sprite index used for drawing icons like arrows,
  45. close buttons and ticks in checkboxes
  46. \param icon: Enum specifying which icon to change
  47. \param index: The sprite index used to draw this icon */
  48. virtual void setIcon(EGUI_DEFAULT_ICON icon, u32 index);
  49. //! Returns a default text.
  50. /** For example for Message box button captions:
  51. "OK", "Cancel", "Yes", "No" and so on. */
  52. virtual const wchar_t* getDefaultText(EGUI_DEFAULT_TEXT text) const;
  53. //! Sets a default text.
  54. /** For example for Message box button captions:
  55. "OK", "Cancel", "Yes", "No" and so on. */
  56. virtual void setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText);
  57. //! draws a standard 3d button pane
  58. /** Used for drawing for example buttons in normal state.
  59. It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
  60. EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
  61. \param rect: Defining area where to draw.
  62. \param clip: Clip area.
  63. \param element: Pointer to the element which wishes to draw this. This parameter
  64. is usually not used by ISkin, but can be used for example by more complex
  65. implementations to find out how to draw the part exactly. */
  66. virtual void draw3DButtonPaneStandard(IGUIElement* element,
  67. const core::rect<s32>& rect,
  68. const core::rect<s32>* clip=0);
  69. //! draws a pressed 3d button pane
  70. /** Used for drawing for example buttons in pressed state.
  71. It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
  72. EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
  73. \param rect: Defining area where to draw.
  74. \param clip: Clip area.
  75. \param element: Pointer to the element which wishes to draw this. This parameter
  76. is usually not used by ISkin, but can be used for example by more complex
  77. implementations to find out how to draw the part exactly. */
  78. virtual void draw3DButtonPanePressed(IGUIElement* element,
  79. const core::rect<s32>& rect,
  80. const core::rect<s32>* clip=0);
  81. //! draws a sunken 3d pane
  82. /** Used for drawing the background of edit, combo or check boxes.
  83. \param element: Pointer to the element which wishes to draw this. This parameter
  84. is usually not used by ISkin, but can be used for example by more complex
  85. implementations to find out how to draw the part exactly.
  86. \param bgcolor: Background color.
  87. \param flat: Specifies if the sunken pane should be flat or displayed as sunken
  88. deep into the ground.
  89. \param rect: Defining area where to draw.
  90. \param clip: Clip area. */
  91. virtual void draw3DSunkenPane(IGUIElement* element,
  92. video::SColor bgcolor, bool flat,
  93. bool fillBackGround,
  94. const core::rect<s32>& rect,
  95. const core::rect<s32>* clip=0);
  96. //! draws a window background
  97. /** Used for drawing the background of dialogs and windows.
  98. \param element: Pointer to the element which wishes to draw this. This parameter
  99. is usually not used by ISkin, but can be used for example by more complex
  100. implementations to find out how to draw the part exactly.
  101. \param titleBarColor: Title color.
  102. \param drawTitleBar: True to enable title drawing.
  103. \param rect: Defining area where to draw.
  104. \param clip: Clip area.
  105. \param checkClientArea: When set to non-null the function will not draw anything,
  106. but will instead return the clientArea which can be used for drawing by the calling window.
  107. That is the area without borders and without titlebar.
  108. \return Returns rect where it would be good to draw title bar text. This will
  109. work even when checkClientArea is set to a non-null value.*/
  110. virtual core::rect<s32> draw3DWindowBackground(IGUIElement* element,
  111. bool drawTitleBar, video::SColor titleBarColor,
  112. const core::rect<s32>& rect,
  113. const core::rect<s32>* clip,
  114. core::rect<s32>* checkClientArea);
  115. //! draws a standard 3d menu pane
  116. /** Used for drawing for menus and context menus.
  117. It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
  118. EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
  119. \param element: Pointer to the element which wishes to draw this. This parameter
  120. is usually not used by ISkin, but can be used for example by more complex
  121. implementations to find out how to draw the part exactly.
  122. \param rect: Defining area where to draw.
  123. \param clip: Clip area. */
  124. virtual void draw3DMenuPane(IGUIElement* element,
  125. const core::rect<s32>& rect,
  126. const core::rect<s32>* clip=0);
  127. //! draws a standard 3d tool bar
  128. /** Used for drawing for toolbars and menus.
  129. \param element: Pointer to the element which wishes to draw this. This parameter
  130. is usually not used by ISkin, but can be used for example by more complex
  131. implementations to find out how to draw the part exactly.
  132. \param rect: Defining area where to draw.
  133. \param clip: Clip area. */
  134. virtual void draw3DToolBar(IGUIElement* element,
  135. const core::rect<s32>& rect,
  136. const core::rect<s32>* clip=0);
  137. //! draws a tab button
  138. /** Used for drawing for tab buttons on top of tabs.
  139. \param element: Pointer to the element which wishes to draw this. This parameter
  140. is usually not used by ISkin, but can be used for example by more complex
  141. implementations to find out how to draw the part exactly.
  142. \param active: Specifies if the tab is currently active.
  143. \param rect: Defining area where to draw.
  144. \param clip: Clip area. */
  145. virtual void draw3DTabButton(IGUIElement* element, bool active,
  146. const core::rect<s32>& rect, const core::rect<s32>* clip=0, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT);
  147. //! draws a tab control body
  148. /** \param element: Pointer to the element which wishes to draw this. This parameter
  149. is usually not used by ISkin, but can be used for example by more complex
  150. implementations to find out how to draw the part exactly.
  151. \param border: Specifies if the border should be drawn.
  152. \param background: Specifies if the background should be drawn.
  153. \param rect: Defining area where to draw.
  154. \param clip: Clip area. */
  155. virtual void draw3DTabBody(IGUIElement* element, bool border, bool background,
  156. const core::rect<s32>& rect, const core::rect<s32>* clip=0, s32 tabHeight=-1, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT);
  157. //! draws an icon, usually from the skin's sprite bank
  158. /** \param element: Pointer to the element which wishes to draw this icon.
  159. This parameter is usually not used by IGUISkin, but can be used for example
  160. by more complex implementations to find out how to draw the part exactly.
  161. \param icon: Specifies the icon to be drawn.
  162. \param position: The position to draw the icon
  163. \param starttime: The time at the start of the animation
  164. \param currenttime: The present time, used to calculate the frame number
  165. \param loop: Whether the animation should loop or not
  166. \param clip: Clip area. */
  167. virtual void drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon,
  168. const core::position2di position,
  169. u32 starttime=0, u32 currenttime=0,
  170. bool loop=false, const core::rect<s32>* clip=0);
  171. //! draws a 2d rectangle.
  172. /** \param element: Pointer to the element which wishes to draw this icon.
  173. This parameter is usually not used by IGUISkin, but can be used for example
  174. by more complex implementations to find out how to draw the part exactly.
  175. \param color: Color of the rectangle to draw. The alpha component specifies how
  176. transparent the rectangle will be.
  177. \param pos: Position of the rectangle.
  178. \param clip: Pointer to rectangle against which the rectangle will be clipped.
  179. If the pointer is null, no clipping will be performed. */
  180. virtual void draw2DRectangle(IGUIElement* element, const video::SColor &color,
  181. const core::rect<s32>& pos, const core::rect<s32>* clip = 0);
  182. //! get the type of this skin
  183. virtual EGUI_SKIN_TYPE getType() const;
  184. //! Writes attributes of the object.
  185. //! Implement this to expose the attributes of your scene node animator for
  186. //! scripting languages, editors, debuggers or xml serialization purposes.
  187. virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const;
  188. //! Reads attributes of the object.
  189. //! Implement this to set the attributes of your scene node animator for
  190. //! scripting languages, editors, debuggers or xml deserialization purposes.
  191. virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0);
  192. virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
  193. const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect,
  194. const video::SColor* const colors, bool useAlphaChannelOfTexture);
  195. private:
  196. video::SColor Colors[EGDC_COUNT];
  197. s32 Sizes[EGDS_COUNT];
  198. u32 Icons[EGDI_COUNT];
  199. IGUIFont* Fonts[EGDF_COUNT];
  200. IGUISpriteBank* SpriteBank;
  201. core::stringw Texts[EGDT_COUNT];
  202. video::IVideoDriver* Driver;
  203. bool UseGradient;
  204. EGUI_SKIN_TYPE Type;
  205. };
  206. } // end namespace gui
  207. } // end namespace irr
  208. #endif // _IRR_COMPILE_WITH_GUI_
  209. #endif