Knopf.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. #ifndef Knopf_H
  2. #define Knopf_H
  3. #include "TextFeld.h"
  4. namespace Framework
  5. {
  6. class TextFeld; //! TextFeld.h
  7. class AlphaFeld; //! AlphaFeld.h
  8. class Text; //! Text.h
  9. class Schrift; //! Schrift.h
  10. class Rahmen; //! Rahmen.h
  11. class LTDBDatei; //! Dateisystem.h
  12. class Knopf; //! from this file
  13. class KontrollKnopf; //! from this file
  14. class TextRenderer;
  15. //! A 2D GUI Framework drawing that renders a button that the user can press
  16. class Knopf : public TextFeld
  17. {
  18. public:
  19. class Style : public ZeichnungHintergrund::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 KlickFarbe = 0x0020000;
  27. //! Specifies whether the button has a background image
  28. //! while being pressed
  29. static const __int64 KlickBild = 0x0040000;
  30. //! Specifies whether the button uses alpha blending
  31. //! for the background while being pressed
  32. static const __int64 KlickAlpha = 0x0080000;
  33. //! Specifies whether the button has a color gradient
  34. //! while being pressed
  35. static const __int64 KlickBuffer = 0x0100000;
  36. //! Combines flags Sichtbar, Erlaubt, Rahmen,
  37. //! Buffered, MehrfarbigText, KlickBuffer
  38. static const __int64 Normal = Sichtbar | Erlaubt | Rahmen | Buffered
  39. | MehrfarbigText | KlickBuffer;
  40. };
  41. private:
  42. int klickFarbe;
  43. Bild* klickBild;
  44. AlphaFeld* klickBuffer;
  45. int klickIndex;
  46. //! Processes mouse messages
  47. //! \param me The event triggered by the mouse input
  48. DLLEXPORT void doMausEreignis(MausEreignis& me, bool userRet) override;
  49. public:
  50. //! Constructor
  51. DLLEXPORT Knopf();
  52. //! Destructor
  53. DLLEXPORT virtual ~Knopf();
  54. //! Sets the color used as background when the button is pressed
  55. //! \param fc The color in A8R8G8B8 format
  56. DLLEXPORT void setKlickFarbe(int fc);
  57. //! Sets the background image by copying, used when the button is pressed
  58. //! \param bild The image to copy
  59. DLLEXPORT void setKlickBild(Bild* bild);
  60. //! Sets a pointer to the background image used when the button is pressed
  61. //! \param bild The new image
  62. DLLEXPORT void setKlickBildZ(Bild* bild);
  63. //! Sets a pointer to the color gradient used when the button is pressed
  64. //! \param af The new color gradient
  65. DLLEXPORT void setKBZ(AlphaFeld* af);
  66. //! Sets the strength of the color gradient used when the button is pressed
  67. //! \param st The strength
  68. DLLEXPORT void setKBStrength(int st);
  69. //! Sets the color of the color gradient used when the button is pressed
  70. //! \param fc The color in A8R8G8B8 format
  71. DLLEXPORT void setKBFarbe(int fc);
  72. //! Verarbeitet Maus Nachrichten
  73. //! \param te Das Ereignis, was durch die Tastatur Eingabe ausgelößt
  74. //! wurde
  75. DLLEXPORT void doTastaturEreignis(TastaturEreignis& te) override;
  76. //! Draws the object to zRObj if it is visible
  77. //! \param zRObj The image to draw into
  78. DLLEXPORT void render(Bild& zRObj) override;
  79. //! Returns the background color in A8R8G8B8 format used when
  80. //! the button is pressed
  81. DLLEXPORT int getKlickFarbe() const;
  82. //! Returns the background image used when the button is pressed
  83. DLLEXPORT Bild* getKlickBild() const;
  84. //! Returns the background image without increased reference counter
  85. //! used when the button is pressed
  86. DLLEXPORT Bild* zKlickBild() const;
  87. //! Returns the color gradient used when the button is pressed
  88. DLLEXPORT AlphaFeld* getKB() const;
  89. //! Returns the color gradient without increased reference counter
  90. //! used when the button is pressed
  91. DLLEXPORT AlphaFeld* zKB() const;
  92. //! Returns the color of the color gradient in A8R8G8B8 format
  93. //! used when the button is pressed
  94. DLLEXPORT int getKBFarbe() const;
  95. //! Returns the strength of the color gradient used when the button
  96. //! is pressed
  97. DLLEXPORT int getKBStrength() const;
  98. //! Copies the button so it can be modified without affecting the original
  99. DLLEXPORT Zeichnung* dublizieren() const override;
  100. };
  101. //! A 2D GUI Framework drawing that renders a selectable checkbox
  102. //! with label
  103. class KontrollKnopf : public ZeichnungHintergrund
  104. {
  105. public:
  106. class Style : public ZeichnungHintergrund::Style
  107. {
  108. public:
  109. //! Specifies whether the checkbox is selected
  110. static const __int64 Selected = 0x1000000;
  111. //! Specifies whether the label text can be multicolored
  112. static const __int64 MehrfarbigText = 0x001000;
  113. //! Specifies whether the checkbox has a background color
  114. //! while being pressed
  115. static const __int64 KlickFarbe = 0x002000;
  116. //! Specifies whether the checkbox has a background image
  117. //! when clicked
  118. static const __int64 KlickBild = 0x004000;
  119. //! Specifies whether alpha blending is used for the
  120. //! checkbox background when clicked
  121. static const __int64 KlickAlpha = 0x008000;
  122. //! Specifies whether the checkbox has a color gradient
  123. //! when clicked
  124. static const __int64 KlickBuffer = 0x010000;
  125. //! Specifies whether the checkbox has a background color
  126. //! while selected
  127. static const __int64 SelectFarbe = 0x020000;
  128. //! Specifies whether the checkbox has a background image
  129. //! while selected
  130. static const __int64 SelectBild = 0x040000;
  131. //! Specifies whether alpha blending is used for the
  132. //! checkbox background while selected
  133. static const __int64 SelectAlpha = 0x080000;
  134. //! Specifies whether the checkbox has a color gradient
  135. //! while selected
  136. static const __int64 SelectBuffer = 0x100000;
  137. //! Specifies whether the checkbox has a different label
  138. //! while selected
  139. static const __int64 SelectText = 0x200000;
  140. //! Specifies whether the checkbox can have a multi-line label
  141. static const __int64 MehrzeiligText = 0x400000;
  142. //! Specifies whether the checkbox is currently being clicked
  143. //! with the mouse. (Managed by the checkbox itself)
  144. static const __int64 MausKlick = 0x800000;
  145. //! Combines the flags Sichtbar, Erlaubt, Rahmen,
  146. //! KlickBuffer
  147. static const __int64 Normal
  148. = Sichtbar | Erlaubt | Rahmen | KlickBuffer;
  149. };
  150. private:
  151. Text* txt;
  152. Text* sTxt;
  153. int sBgF;
  154. int kBgF;
  155. Bild* sBgB;
  156. Bild* kBgB;
  157. AlphaFeld* sAf;
  158. AlphaFeld* kAf;
  159. Bild* kasten;
  160. Bild* sKasten;
  161. TextRenderer* textRd;
  162. int sF;
  163. int sGr;
  164. //! Verarbeitet Maus Nachrichten
  165. //! \param me Das Ereignis, was durch die Mauseingabe ausgelößt wurde
  166. DLLEXPORT void doMausEreignis(MausEreignis& me, bool userRet) override;
  167. public:
  168. //! Konstruktor
  169. DLLEXPORT KontrollKnopf();
  170. //! Destruktor
  171. DLLEXPORT virtual ~KontrollKnopf();
  172. //! Setzt den Zeiger auf den Beschriftungs Text
  173. //! \param txt Der Text
  174. DLLEXPORT void setTextZ(Text* txt);
  175. //! Setzt den Beschriftungs Text
  176. //! \param txt Der Text
  177. DLLEXPORT void setText(Text* txt);
  178. //! Setzt den Beschriftungs Text
  179. //! \param txt Der Text
  180. DLLEXPORT void setText(const char* txt);
  181. //! Setzt den Zeiger auf den Beschriftungs Text, der angezeigt wird,
  182. //! während das Kästchen ausgewählt ist \param txt Der Text
  183. DLLEXPORT void setSTextZ(Text* txt);
  184. //! Setzt den Beschriftungs Text, der angezeigt wird, während das
  185. //! Kästchen ausgewählt ist \param txt Der Text
  186. DLLEXPORT void setSText(Text* txt);
  187. //! Setzt den Beschriftungs Text, der angezeigt wird, während das
  188. //! Kästchen ausgewählt ist \param txt Der Text
  189. DLLEXPORT void setSText(const char* txt);
  190. //! Setzt den verwendeten TextRenderer
  191. //! \param textRd Der Textrenderer
  192. DLLEXPORT void setTextRendererZ(TextRenderer* textRd);
  193. //! Setzt die Schrift, die für die Beschriftung verwendet werden soll
  194. //! \param schrift Die Schrift
  195. DLLEXPORT void setSchriftZ(Schrift* schrift);
  196. //! Setzt die Farbe der Schrift, die für die Beschriftung verwendet
  197. //! werden soll \param f Die Farbe im A8R8G8B8 Format
  198. DLLEXPORT void setSFarbe(int f);
  199. //! Setzt die Größe der Schrift, die für die Beschriftung verwendet
  200. //! werden soll \param f Die Höhe einer Zeile in Pixeln
  201. DLLEXPORT void setSSize(int gr);
  202. //! Setzt die Hintergrund Farbe, die verwendet wird, während das
  203. //! Kästchen ausgewählt ist \param f Die Farbe im A8R8G8B8 Format
  204. DLLEXPORT void setSBgFarbe(int f);
  205. //! Setzt die Hintergrund Farbe, die verwendet wird, während auf das
  206. //! Kästchen geklickt wird \param f Die Farbe im A8R8G8B8 Format
  207. DLLEXPORT void setKBgFarbe(int f);
  208. //! Setzt einen Zeiger auf das Hintergrund Bild, das verwendet wird,
  209. //! während das Kästchen ausgewählt ist \param b Das Bild
  210. DLLEXPORT void setSBgBildZ(Bild* b);
  211. //! Setzt das Hintergrund Bild durch kopieren, das verwendet wird,
  212. //! während das Kästchen ausgewählt ist \param b Das Bild, das kopiert
  213. //! werden soll
  214. DLLEXPORT void setSBgBild(Bild* b);
  215. //! Setzt einen Zeiger auf das Hintergrund Bild, das verwendet wird,
  216. //! während auf das Kästchen geklickt wird \param b Das Bild
  217. DLLEXPORT void setKBgBildZ(Bild* b);
  218. //! Setzt das Hintergrund Bild durch kopieren, das verwendet wird,
  219. //! während auf das Kästchen geklickt wird \param b Das Bild, das
  220. //! kopiert werden soll
  221. DLLEXPORT void setKBgBild(Bild* b);
  222. //! Setzt einen Zeiger auf den Farbübergang, der verwendet wird, während
  223. //! das Kästchen ausgewählt ist \param af Der Farbübergang
  224. DLLEXPORT void setSAlphaFeldZ(AlphaFeld* af);
  225. //! Setzt die Farbe des Farbübergangs, der verwendet wird, während das
  226. //! Kästchen ausgewählt ist \param f Die Farbe im A8R8G8B8 Format
  227. DLLEXPORT void setSAFFarbe(int f);
  228. //! Setzt die Stärke des Farbübergangs, der verwendet wird, während das
  229. //! Kästchen ausgewählt ist \param st Die Stärke
  230. DLLEXPORT void setSAFStrength(int st);
  231. //! Setzt einen Zeiger auf den Farbübergang, der verwendet wird, während
  232. //! auf das Kästchen geklickt wird \param af Der Farbübergang
  233. DLLEXPORT void setKAlphaFeldZ(AlphaFeld* af);
  234. //! Setzt die Farbe des Farbübergangs, der verwendet wird, während auf
  235. //! das Kästchen geklickt wird \param f Die Farbe im A8R8G8B8 Format
  236. DLLEXPORT void setKAFFarbe(int f);
  237. //! Setzt die Stärke des Farbübergangs, der verwendet wird, während auf
  238. //! das Kästchen geklickt wird \param st Die Stärke
  239. DLLEXPORT void setKAFStrength(int st);
  240. //! Lädt die Bilder "kasten.gif" und "skasten.gif" aus einer LTDB Datei
  241. //! Das Bild kasten.gif wird gezeichnet, wenn das Kästchen nicht
  242. //! ausgewählt ist. Das Bild skasten.gif wird gezeichnet, wenn das
  243. //! Kästchen ausgewählt wird \param zDat Die LTDB Datei
  244. DLLEXPORT void loadData(LTDBDatei* zDat);
  245. //! Lädt die Bilder "kasten.gif" und "skasten.gif" aus einer LTDB Datei
  246. //! Das Bild kasten.gif wird gezeichnet, wenn das Kästchen nicht
  247. //! ausgewählt ist. Das Bild skasten.gif wird gezeichnet, wenn das
  248. //! Kästchen ausgewählt wird \param ltdb Der Pfad zur LTDB Datei
  249. DLLEXPORT void loadData(const char* ltdb);
  250. //! Zeichnet das Objekt nach zRObj, falls es sichtbar ist
  251. //! \param zRObj Das Bild, in welches gezeichnet werden soll
  252. DLLEXPORT void render(Bild& zRObj) override;
  253. //! Gibt die beschriftung zurück
  254. DLLEXPORT Text* getText() const;
  255. //! Gibt die beschriftung ohne erhöhten Reference Counter zurück
  256. DLLEXPORT Text* zText() const;
  257. //! Gibt die beschriftung zurück, die verwendet wird, während das
  258. //! Kästchen ausgewählt ist
  259. DLLEXPORT Text* getSText() const;
  260. //! Gibt die beschriftung ohne erhöhten Reference Counter zurück, die
  261. //! verwendet wird, während das Kästchen ausgewählt ist
  262. DLLEXPORT Text* zSText() const;
  263. //! Gibt die verwendete Schrift zurück
  264. DLLEXPORT Schrift* getSchrift() const;
  265. //! Gibt die verwendete Schrift ohne Reference Counter zurück
  266. DLLEXPORT Schrift* zSchrift() const;
  267. //! Gibt die Schrift Farbe im A8R8G8B8 Format zurück
  268. DLLEXPORT int getSFarbe() const;
  269. //! Gibt die Schrift Größe zurück
  270. DLLEXPORT int getSSize() const;
  271. //! Gibt die Hintergrund Farbe im A8R8G8B8 Format zurück, die verwendet
  272. //! wird, während das Kästchen ausgewählt ist
  273. DLLEXPORT int getSBgFarbe() const;
  274. //! Gibt die Hintergrund Farbe im A8R8G8B8 Format zurück, die verwendet
  275. //! wird, während auf das Kästchen geklickt wird
  276. DLLEXPORT int getKBgFarbe() const;
  277. //! Gibt das Hintergrund Bild zurück, das verwendet wird, während das
  278. //! Kästchen ausgewählt ist
  279. DLLEXPORT Bild* getSBgBild() const;
  280. //! Gibt das Hintergrund Bild ohne erhöhten Reference Counter zurück,
  281. //! das verwendet wird, während das Kästchen ausgewählt ist
  282. DLLEXPORT Bild* zSBgBild() const;
  283. //! Gibt das Hintergrund Bild zurück, das verwendet wird, während auf
  284. //! das Kästchen geklickt wird
  285. DLLEXPORT Bild* getKBgBild() const;
  286. //! Gibt das Hintergrund Bild ohne erhöhten Reference Counter zurück,
  287. //! das verwendet wird, während auf das Kästchen geklickt wird
  288. DLLEXPORT Bild* zKBgBild() const;
  289. //! Gibt den Farbübergang zurück, der verwendet wird, während das
  290. //! Kästchen ausgewählt ist
  291. DLLEXPORT AlphaFeld* getSAlphaFeld() const;
  292. //! Gibt den Farbübergang ohne erhöhten Reference COunter zurück, der
  293. //! verwendet wird, während das Kästchen ausgewählt ist
  294. DLLEXPORT AlphaFeld* zSAlphaFeld() const;
  295. //! Gibt den Farbübergang zurück, der verwendet wird, während auf das
  296. //! Kästchen geklickt wird
  297. DLLEXPORT AlphaFeld* getKAlphaFeld() const;
  298. //! Gibt den Farbübergang ohne erhöhten Reference COunter zurück, der
  299. //! verwendet wird, während auf das Kästchen geklickt wird
  300. DLLEXPORT AlphaFeld* zKAlphaFeld() const;
  301. };
  302. } // namespace Framework
  303. #endif