Button.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. #ifndef Button_H
  2. #define Button_H
  3. #include "TextField.h"
  4. namespace Framework
  5. {
  6. class TextField; //! TextField.h
  7. class AlphaField; //! AlphaField.h
  8. class Text; //! Text.h
  9. class Font; //! Font.h
  10. class Border; //! Border.h
  11. class LTDBFile; //! FileSystem.h
  12. class Button; //! from this file
  13. class CheckBox; //! from this file
  14. class TextRenderer;
  15. //! A 2D GUI Framework drawing that renders a button that the user can press
  16. class Button : public TextField
  17. {
  18. public:
  19. class Style : public DrawableBackground::Style
  20. {
  21. public:
  22. //! Specifies whether the button text may have multiple colors
  23. static const __int64 MehrfarbigText = 0x0010000;
  24. //! Specifies whether the button has a background color
  25. //! while being pressed
  26. static const __int64 ClickColor = 0x0020000;
  27. //! Specifies whether the button has a background image
  28. //! while being pressed
  29. static const __int64 ClickImage = 0x0040000;
  30. //! Specifies whether the button uses alpha blending
  31. //! for the background while being pressed
  32. static const __int64 ClickAlpha = 0x0080000;
  33. //! Specifies whether the button has a color gradient
  34. //! while being pressed
  35. static const __int64 ClickBuffer = 0x0100000;
  36. //! Combines flags Visible, Allowed, Border,
  37. //! Buffered, MehrfarbigText, ClickBuffer
  38. static const __int64 Normal = Visible | Allowed | Border | Buffered
  39. | MehrfarbigText | ClickBuffer;
  40. };
  41. private:
  42. int klickColor;
  43. Image* clickImage;
  44. AlphaField* klickBuffer;
  45. int klickIndex;
  46. //! Processes mouse messages
  47. //! \param me The event triggered by the mouse input
  48. DLLEXPORT void doMouseEvent(MouseEvent& me, bool userRet) override;
  49. public:
  50. //! Constructor
  51. DLLEXPORT Button();
  52. //! Destructor
  53. DLLEXPORT virtual ~Button();
  54. //! Sets the color used as background when the button is pressed
  55. //! \param fc The color in A8R8G8B8 format
  56. DLLEXPORT void setClickColor(int fc);
  57. //! Sets the background image by copying, used when the button is
  58. //! pressed
  59. //! \param bild The image to copy
  60. DLLEXPORT void setClickImage(Image* bild);
  61. //! Sets a pointer to the background image used when the button is
  62. //! pressed
  63. //! \param bild The new image
  64. DLLEXPORT void setClickImageZ(Image* bild);
  65. //! Sets a pointer to the color gradient used when the button is pressed
  66. //! \param af The new color gradient
  67. DLLEXPORT void setKBZ(AlphaField* af);
  68. //! Sets the strength of the color gradient used when the button is
  69. //! pressed
  70. //! \param st The strength
  71. DLLEXPORT void setKBStrength(int st);
  72. //! Sets the color of the color gradient used when the button is pressed
  73. //! \param fc The color in A8R8G8B8 format
  74. DLLEXPORT void setKBColor(int fc);
  75. //! Processes mouse messages
  76. //! \param me The event triggered by the keyboard input
  77. DLLEXPORT void doKeyboardEvent(KeyboardEvent& te) override;
  78. //! Draws the object to zRObj if it is visible
  79. //! \param zRObj The image to draw into
  80. DLLEXPORT void render(Image& zRObj) override;
  81. //! Returns the background color in A8R8G8B8 format used when
  82. //! the button is pressed
  83. DLLEXPORT int getClickColor() const;
  84. //! Returns the background image used when the button is pressed
  85. DLLEXPORT Image* getClickImage() const;
  86. //! Returns the background image without increased reference counter
  87. //! used when the button is pressed
  88. DLLEXPORT Image* zClickImage() const;
  89. //! Returns the color gradient used when the button is pressed
  90. DLLEXPORT AlphaField* getKB() const;
  91. //! Returns the color gradient without increased reference counter
  92. //! used when the button is pressed
  93. DLLEXPORT AlphaField* zKB() const;
  94. //! Returns the color of the color gradient in A8R8G8B8 format
  95. //! used when the button is pressed
  96. DLLEXPORT int getKBColor() const;
  97. //! Returns the strength of the color gradient used when the button
  98. //! is pressed
  99. DLLEXPORT int getKBStrength() const;
  100. //! Copies the button so it can be modified without affecting the
  101. //! original
  102. DLLEXPORT Drawable* duplicate() const override;
  103. };
  104. //! A 2D GUI Framework drawing that renders a selectable checkbox
  105. //! with label
  106. class CheckBox : public DrawableBackground
  107. {
  108. public:
  109. class Style : public DrawableBackground::Style
  110. {
  111. public:
  112. //! Specifies whether the checkbox is selected
  113. static const __int64 Selected = 0x1000000;
  114. //! Specifies whether the label text can be multicolored
  115. static const __int64 MehrfarbigText = 0x001000;
  116. //! Specifies whether the checkbox has a background color
  117. //! while being pressed
  118. static const __int64 ClickColor = 0x002000;
  119. //! Specifies whether the checkbox has a background image
  120. //! when clicked
  121. static const __int64 ClickImage = 0x004000;
  122. //! Specifies whether alpha blending is used for the
  123. //! checkbox background when clicked
  124. static const __int64 ClickAlpha = 0x008000;
  125. //! Specifies whether the checkbox has a color gradient
  126. //! when clicked
  127. static const __int64 ClickBuffer = 0x010000;
  128. //! Specifies whether the checkbox has a background color
  129. //! while selected
  130. static const __int64 SelectColor = 0x020000;
  131. //! Specifies whether the checkbox has a background image
  132. //! while selected
  133. static const __int64 SelectImage = 0x040000;
  134. //! Specifies whether alpha blending is used for the
  135. //! checkbox background while selected
  136. static const __int64 SelectAlpha = 0x080000;
  137. //! Specifies whether the checkbox has a color gradient
  138. //! while selected
  139. static const __int64 SelectBuffer = 0x100000;
  140. //! Specifies whether the checkbox has a different label
  141. //! while selected
  142. static const __int64 SelectText = 0x200000;
  143. //! Specifies whether the checkbox can have a multi-line label
  144. static const __int64 MehrzeiligText = 0x400000;
  145. //! Specifies whether the checkbox is currently being clicked
  146. //! with the mouse. (Managed by the checkbox itself)
  147. static const __int64 MouseClick = 0x800000;
  148. //! Combines the flags Visible, Allowed, Border,
  149. //! ClickBuffer
  150. static const __int64 Normal
  151. = Visible | Allowed | Border | ClickBuffer;
  152. };
  153. private:
  154. Text* txt;
  155. Text* sTxt;
  156. int sBgF;
  157. int kBgF;
  158. Image* sBgB;
  159. Image* kBgB;
  160. AlphaField* sAf;
  161. AlphaField* kAf;
  162. Image* kasten;
  163. Image* sKasten;
  164. TextRenderer* textRd;
  165. int sF;
  166. int sGr;
  167. //! Processes mouse messages
  168. //! \param me The event triggered by the mouse input
  169. DLLEXPORT void doMouseEvent(MouseEvent& me, bool userRet) override;
  170. public:
  171. //! Constructor
  172. DLLEXPORT CheckBox();
  173. //! Destructor
  174. DLLEXPORT virtual ~CheckBox();
  175. //! Sets a pointer to the label text
  176. //! \param txt The text
  177. DLLEXPORT void setTextZ(Text* txt);
  178. //! Sets the label text
  179. //! \param txt The text
  180. DLLEXPORT void setText(Text* txt);
  181. //! Sets the label text
  182. //! \param txt The text
  183. DLLEXPORT void setText(const char* txt);
  184. //! Sets a pointer to the label text displayed while the
  185. //! checkbox is selected \param txt The text
  186. DLLEXPORT void setSTextZ(Text* txt);
  187. //! Sets the label text displayed while the checkbox is selected
  188. //! \param txt The text
  189. DLLEXPORT void setSText(Text* txt);
  190. //! Sets the label text displayed while the checkbox is selected
  191. //! \param txt The text
  192. DLLEXPORT void setSText(const char* txt);
  193. //! Sets the TextRenderer to use
  194. //! \param textRd The text renderer
  195. DLLEXPORT void setTextRendererZ(TextRenderer* textRd);
  196. //! Sets the font to use for the label
  197. //! \param font The font
  198. DLLEXPORT void setFontZ(Font* font);
  199. //! Sets the color of the font used for the label
  200. //! \param f The color in A8R8G8B8 format
  201. DLLEXPORT void setSColor(int f);
  202. //! Sets the size of the font used for the label
  203. //! \param f The height of a line in pixels
  204. DLLEXPORT void setSSize(int gr);
  205. //! Sets the background color used while the checkbox is selected
  206. //! \param f The color in A8R8G8B8 format
  207. DLLEXPORT void setSBgColor(int f);
  208. //! Sets the background color used while the checkbox is being clicked
  209. //! \param f The color in A8R8G8B8 format
  210. DLLEXPORT void setKBgColor(int f);
  211. //! Sets a pointer to the background image used while the checkbox
  212. //! is selected \param b The image
  213. DLLEXPORT void setSBgImageZ(Image* b);
  214. //! Sets the background image by copying, used while the checkbox
  215. //! is selected \param b The image to copy
  216. DLLEXPORT void setSBgImage(Image* b);
  217. //! Sets a pointer to the background image used while the checkbox
  218. //! is being clicked \param b The image
  219. DLLEXPORT void setKBgImageZ(Image* b);
  220. //! Sets the background image by copying, used while the checkbox
  221. //! is being clicked \param b The image to copy
  222. DLLEXPORT void setKBgImage(Image* b);
  223. //! Sets a pointer to the color gradient used while the checkbox
  224. //! is selected \param af The color gradient
  225. DLLEXPORT void setSAlphaFieldZ(AlphaField* af);
  226. //! Sets the color of the color gradient used while the checkbox
  227. //! is selected \param f The color in A8R8G8B8 format
  228. DLLEXPORT void setSAFColor(int f);
  229. //! Sets the strength of the color gradient used while the checkbox
  230. //! is selected \param st The strength
  231. DLLEXPORT void setSAFStrength(int st);
  232. //! Sets a pointer to the color gradient used while the checkbox
  233. //! is being clicked \param af The color gradient
  234. DLLEXPORT void setKAlphaFieldZ(AlphaField* af);
  235. //! Sets the color of the color gradient used while the checkbox
  236. //! is being clicked \param f The color in A8R8G8B8 format
  237. DLLEXPORT void setKAFColor(int f);
  238. //! Sets the strength of the color gradient used while the checkbox
  239. //! is being clicked \param st The strength
  240. DLLEXPORT void setKAFStrength(int st);
  241. //! Loads images "kasten.gif" and "skasten.gif" from an LTDB file.
  242. //! kasten.gif is drawn when the checkbox is not selected.
  243. //! skasten.gif is drawn when the checkbox is selected.
  244. //! \param zDat The LTDB file
  245. DLLEXPORT void loadData(LTDBFile* zDat);
  246. //! Loads images "kasten.gif" and "skasten.gif" from an LTDB file.
  247. //! kasten.gif is drawn when the checkbox is not selected.
  248. //! skasten.gif is drawn when the checkbox is selected.
  249. //! \param ltdb The path to the LTDB file
  250. DLLEXPORT void loadData(const char* ltdb);
  251. //! Draws the object to zRObj if it is visible
  252. //! \param zRObj The image to draw into
  253. DLLEXPORT void render(Image& zRObj) override;
  254. //! Returns the label
  255. DLLEXPORT Text* getText() const;
  256. //! Returns the label without increased reference counter
  257. DLLEXPORT Text* zText() const;
  258. //! Returns the label used while the checkbox is selected
  259. DLLEXPORT Text* getSText() const;
  260. //! Returns the label without increased reference counter used
  261. //! while the checkbox is selected
  262. DLLEXPORT Text* zSText() const;
  263. //! Returns the font used
  264. DLLEXPORT Font* getFont() const;
  265. //! Returns the font used without increased reference counter
  266. DLLEXPORT Font* zFont() const;
  267. //! Returns the font color in A8R8G8B8 format
  268. DLLEXPORT int getSColor() const;
  269. //! Returns the font size
  270. DLLEXPORT int getSSize() const;
  271. //! Returns the background color in A8R8G8B8 format used while
  272. //! the checkbox is selected
  273. DLLEXPORT int getSBgColor() const;
  274. //! Returns the background color in A8R8G8B8 format used while
  275. //! the checkbox is being clicked
  276. DLLEXPORT int getKBgColor() const;
  277. //! Returns the background image used while the checkbox is selected
  278. DLLEXPORT Image* getSBgImage() const;
  279. //! Returns the background image without increased reference counter
  280. //! used while the checkbox is selected
  281. DLLEXPORT Image* zSBgImage() const;
  282. //! Returns the background image used while the checkbox is being clicked
  283. DLLEXPORT Image* getKBgImage() const;
  284. //! Returns the background image without increased reference counter
  285. //! used while the checkbox is being clicked
  286. DLLEXPORT Image* zKBgImage() const;
  287. //! Returns the color gradient used while the checkbox is selected
  288. DLLEXPORT AlphaField* getSAlphaField() const;
  289. //! Returns the color gradient without increased reference counter
  290. //! used while the checkbox is selected
  291. DLLEXPORT AlphaField* zSAlphaField() const;
  292. //! Returns the color gradient used while the checkbox is being clicked
  293. DLLEXPORT AlphaField* getKAlphaField() const;
  294. //! Returns the color gradient without increased reference counter
  295. //! used while the checkbox is being clicked
  296. DLLEXPORT AlphaField* zKAlphaField() const;
  297. };
  298. } // namespace Framework
  299. #endif