List.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. #ifndef Liste_H
  2. #define Liste_H
  3. #include "Array.h"
  4. #include "Drawing.h"
  5. namespace Framework
  6. {
  7. class Rahmen; //! Border.h
  8. class AlphaFeld; //! AlphaField.h
  9. class Bild; //! Image.h
  10. class Text; //! Text.h
  11. class TextFeld; //! TextField.h
  12. class VScrollBar; //! Scroll.h
  13. struct TastaturEreignis; //! KeyboardEvent.h
  14. struct MausEreignis; //! MouseEvent.h
  15. class Schrift; //! Font.h
  16. class AuswahlListe; //! from this file
  17. //! A drawing of the 2D GUI Framework that displays a list from which
  18. //! the user can select and deselect elements
  19. class AuswahlListe : public DrawableBackground
  20. {
  21. public:
  22. class Style : public DrawableBackground::Style
  23. {
  24. public:
  25. //! Specifies whether the list entries have a border
  26. static const __int64 FeldRahmen = 0x0001000;
  27. //! Specifies whether the entries have a background
  28. static const __int64 FeldHintergrund = 0x0002000;
  29. //! Specifies whether the entries have a background image
  30. static const __int64 FeldHBild = 0x0004000;
  31. //! Specifies whether alpha blending is used when drawing
  32. //! entry backgrounds
  33. static const __int64 FeldHAlpha = 0x0008000;
  34. //! Specifies whether the entries have a color gradient
  35. static const __int64 FeldBuffer = 0x0010000;
  36. //! Specifies whether selected entries have a background
  37. static const __int64 AuswahlHintergrund = 0x0020000;
  38. //! Specifies whether selected entries have a background image
  39. static const __int64 AuswahlHBild = 0x0040000;
  40. //! Specifies whether alpha blending is used for drawing
  41. //! backgrounds of selected entries
  42. static const __int64 AuswahlHAlpha = 0x0080000;
  43. //! Specifies whether selected entries have a color gradient
  44. static const __int64 AuswahlBuffer = 0x0100000;
  45. //! Specifies whether selected entries have a border
  46. static const __int64 AuswahlRahmen = 0x0200000;
  47. //! Specifies whether each entry has its own background,
  48. //! color gradient, and border when selected
  49. static const __int64 MultiStyled = 0x0400000;
  50. //! Specifies that multiple entries can be selected simultaneously
  51. static const __int64 MultiSelect = 0x0800000;
  52. //! Specifies whether a specific entry is selected, if
  53. //! MultiSelect was set.
  54. static const __int64 Selected = 0x1000000;
  55. //! Combines the flags Sichtbar, Erlaubt, Rahmen, FeldHAlpha,
  56. //! FeldHintergrund, FeldRahmen, AuswahlBuffer, AuswahlRahmen
  57. static const __int64 Normal
  58. = Sichtbar | Erlaubt | Rahmen | FeldHAlpha | FeldHintergrund
  59. | FeldRahmen | AuswahlBuffer | AuswahlRahmen;
  60. };
  61. private:
  62. RCArray<TextFeld>* tfListe;
  63. int auswahl;
  64. int ahFarbe;
  65. Bild* ahBild;
  66. AlphaFeld* aBuffer;
  67. Rahmen* aRahmen;
  68. Array<__int64>* styles;
  69. Array<int>* ahFarbeListe;
  70. RCArray<Bild>* ahBildListe;
  71. RCArray<AlphaFeld>* aBufferListe;
  72. RCArray<Rahmen>* aRahmenListe;
  73. Schrift* schrift;
  74. //! Processes mouse messages
  75. //! \param me The event triggered by the mouse input
  76. DLLEXPORT void doMausEreignis(MausEreignis& me, bool userRet) override;
  77. DLLEXPORT bool hatStyle(int styleSet, int styleCheck) const;
  78. public:
  79. //! Constructor
  80. DLLEXPORT AuswahlListe();
  81. //! Destructor
  82. DLLEXPORT virtual ~AuswahlListe();
  83. //! Updates the styles, size and position of the entries
  84. DLLEXPORT void update();
  85. //! Adds an entry
  86. //! \param txt The text of the entry
  87. DLLEXPORT void addEintrag(Text* txt);
  88. //! Adds an entry
  89. //! \param txt The text of the entry
  90. DLLEXPORT void addEintrag(const char* txt);
  91. //! Adds a pointer to an entry
  92. //! \param tf The TextFeld used to draw the entry
  93. DLLEXPORT void addEintragZ(TextFeld* tf);
  94. //! Adds an entry at a specific position
  95. //! \param pos The index of the new entry
  96. //! \param txt The text of the entry
  97. DLLEXPORT void addEintrag(int pos, Text* txt);
  98. //! Adds an entry at a specific position
  99. //! \param pos The index of the new entry
  100. //! \param txt The text of the entry
  101. DLLEXPORT void addEintrag(int pos, const char* txt);
  102. //! Adds a pointer to an entry at a specific position
  103. //! \param pos The index of the new entry \param tf The TextFeld
  104. //! used to draw the entry
  105. DLLEXPORT void addEintragZ(int pos, TextFeld* tf);
  106. //! Changes an entry
  107. //! \param pos The index of the entry
  108. //! \param txt The new text of the entry
  109. DLLEXPORT void setEintrag(int pos, Text* txt);
  110. //! Changes an entry
  111. //! \param pos The index of the entry
  112. //! \param txt The new text of the entry
  113. DLLEXPORT void setEintrag(int pos, const char* txt);
  114. //! Changes the pointer of an entry
  115. //! \param pos The index of the entry
  116. //! \param tf The new entry
  117. DLLEXPORT void setEintragZ(int pos, TextFeld* tf);
  118. //! Swaps the positions of two entries
  119. //! \param vpos The index of the first entry
  120. //! \param npos The index of the second entry
  121. DLLEXPORT void tauschEintragPos(int vpos, int npos);
  122. //! Sets the position of an entry
  123. //! \param vpos The index of the entry
  124. //! \param npos The index the entry should have
  125. DLLEXPORT void setEintragPos(int vpos, int npos);
  126. //! Deletes an entry
  127. //! pos: The index of the entry
  128. DLLEXPORT void removeEintrag(int pos);
  129. //! Sets the font to use
  130. //! \param schrift The font
  131. DLLEXPORT void setSchriftZ(Schrift* schrift);
  132. //! Scrolls to a specific entry
  133. //! \param eintrag The index of the entry
  134. DLLEXPORT void setVScrollZuEintrag(int eintrag);
  135. //! Updates the maximum scroll height by adding the heights of all entries
  136. DLLEXPORT void updateVScroll();
  137. //! Sets a pointer to the border used for selected entries
  138. //! if MultiStyled is not set \param rahmen The border
  139. DLLEXPORT void setALRZ(Rahmen* rahmen);
  140. //! Sets the width of the border used for selected entries
  141. //! if MultiStyled is not set \param br The width in pixels
  142. DLLEXPORT void setALRBreite(int br);
  143. //! Sets the color of the border used for selected entries
  144. //! if MultiStyled is not set \param fc The color in A8R8G8B8 format
  145. DLLEXPORT void setALRFarbe(int fc);
  146. //! Sets a pointer to the color gradient used for selected entries
  147. //! if MultiStyled is not set \param buffer The color gradient
  148. DLLEXPORT void setAAFZ(AlphaFeld* buffer);
  149. //! Sets the strength of the color gradient used for selected entries
  150. //! if MultiStyled is not set \param st The strength
  151. DLLEXPORT void setAAFStrength(int st);
  152. //! Sets the color of the color gradient used for selected entries
  153. //! if MultiStyled is not set \param fc The color in A8R8G8B8 format
  154. DLLEXPORT void setAAFFarbe(int fc);
  155. //! Sets the background image by copying, used for selected entries
  156. //! if MultiStyled is not set \param bild The image to copy
  157. DLLEXPORT void setAHBild(Bild* bild);
  158. //! Sets a pointer to the background image used for selected entries
  159. //! if MultiStyled is not set \param bild The image
  160. DLLEXPORT void setAHBildZ(Bild* bild);
  161. //! Sets the background color used for selected entries
  162. //! if MultiStyled is not set \param fc The color in A8R8G8B8 format
  163. DLLEXPORT void setAHFarbe(int fc);
  164. //! Sets a pointer to the border used for a selected entry
  165. //! if MultiStyled is set \param pos The index of the entry
  166. //! \param rahmen The border
  167. DLLEXPORT void setALRZ(int pos, Rahmen* rahmen);
  168. //! Sets the width of the border used for a selected entry
  169. //! if MultiStyled is set \param pos The index of the entry
  170. //! \param br The width in pixels
  171. DLLEXPORT void setALRBreite(int pos, int br);
  172. //! Sets the color of the border used for a selected entry
  173. //! if MultiStyled is set \param pos The index of the entry
  174. //! \param fc The color in A8R8G8B8 format
  175. DLLEXPORT void setALRFarbe(int pos, int fc);
  176. //! Sets a pointer to the color gradient used for a selected entry
  177. //! if MultiStyled is set \param pos The index of the entry
  178. //! \param buffer The color gradient
  179. DLLEXPORT void setAAFZ(int pos, AlphaFeld* buffer);
  180. //! Sets the strength of the color gradient used for a selected entry
  181. //! if MultiStyled is set \param pos The index of the entry
  182. //! \param st The strength
  183. DLLEXPORT void setAAFStrength(int pos, int st);
  184. //! Sets the color of the color gradient used for a selected entry
  185. //! if MultiStyled is set \param pos The index of the entry
  186. //! \param fc The color in A8R8G8B8 format
  187. DLLEXPORT void setAAFFarbe(int pos, int fc);
  188. //! Sets the background image by copying, used for a selected entry
  189. //! if MultiStyled is set
  190. //! \param pos The index of the entry
  191. //! \param bild The image to copy
  192. DLLEXPORT void setAHBild(int pos, Bild* bild);
  193. //! Sets a pointer to the background image used for a selected entry
  194. //! if MultiStyled is set
  195. //! \param pos The index of the entry
  196. //! \param bild The image
  197. DLLEXPORT void setAHBildZ(int pos, Bild* bild);
  198. //! Sets the background color used for a selected entry
  199. //! if MultiStyled is set \param pos The index of the entry
  200. //! \param fc The color in A8R8G8B8 format
  201. DLLEXPORT void setAHFarbe(int pos, int fc);
  202. //! Sets the style of an entry if MultiStyled is set, and specifies
  203. //! whether an entry is selected if MultiSelect is set
  204. //! \param pos The index of the entry \param style The new style
  205. DLLEXPORT void setMsStyle(int pos, __int64 style);
  206. //! Changes the style of an entry if MultiStyled is set, and specifies
  207. //! whether an entry is selected if MultiSelect is set
  208. //! \param pos The index of the entry \param style The style
  209. //! add_remove: 1 if the style should be added. 0 if the style
  210. //! should be removed
  211. DLLEXPORT void setMsStyle(int pos, __int64 style, bool add_remove);
  212. //! Adds styles to an entry if MultiStyled is set, and specifies
  213. //! whether an entry is selected if MultiSelect is set
  214. //! \param pos The index of the entry \param style The style to add
  215. DLLEXPORT void addMsStyle(int pos, __int64 style);
  216. //! Removes styles from an entry if MultiStyled is set, and specifies
  217. //! whether an entry is selected if MultiSelect is set
  218. //! \param pos The index of the entry \param style The style to remove
  219. DLLEXPORT void removeMsStyle(int pos, __int64 style);
  220. //! Processes a keyboard event. Called automatically by the framework
  221. //! \param te The event
  222. DLLEXPORT void doTastaturEreignis(TastaturEreignis& te) override;
  223. //! Draws the object to zRObj if it is visible
  224. //! \param zRObj The image to draw into
  225. DLLEXPORT void render(Bild& zRObj) override;
  226. //! Returns the index of an entry the mouse points to
  227. //! \param my The position of the mouse on the Y axis relative to
  228. //! the top edge of the list
  229. DLLEXPORT int getKlickEintrag(int my);
  230. //! Selects an entry
  231. //! \param ausw The index of the entry
  232. DLLEXPORT void setAuswahl(int ausw);
  233. //! Deselects all selected entries
  234. DLLEXPORT void deSelect();
  235. //! Returns the number of entries
  236. DLLEXPORT int getEintragAnzahl() const;
  237. //! Returns the index of the selected entry if MultiSelect is not
  238. //! set. If MultiSelect is set, the selection of an entry can be
  239. //! checked with hatMsStyle( entry index,
  240. //! AuswahlListe::Style::Ausgewaehlt )
  241. DLLEXPORT int getAuswahl() const;
  242. //! Returns the index of an entry
  243. //! \param eintragText The text of the entry
  244. DLLEXPORT int getEintragPos(Text* eintragText);
  245. //! Returns an entry
  246. //! \param pos The index of the entry
  247. DLLEXPORT TextFeld* getEintrag(int pos) const;
  248. //! Returns an entry without increased reference counter
  249. //! \param pos The index of the entry
  250. DLLEXPORT TextFeld* zEintrag(int pos) const;
  251. //! Returns the border used for selected entries
  252. //! if MultiStyled is not set
  253. DLLEXPORT Rahmen* getARahmen() const;
  254. //! Returns the border without increased reference counter used for
  255. //! selected entries if MultiStyled is not set
  256. DLLEXPORT Rahmen* zARahmen() const;
  257. //! Returns the background color in A8R8G8B8 format used for
  258. //! selected entries if MultiStyled is not set
  259. DLLEXPORT int getAHFarbe() const;
  260. //! Returns the background image used for selected entries
  261. //! if MultiStyled is not set
  262. DLLEXPORT Bild* getAHBild() const;
  263. //! Returns the background image without increased reference counter
  264. //! used for selected entries if MultiStyled is not set
  265. DLLEXPORT Bild* zAHBild() const;
  266. //! Returns the color gradient used for selected entries
  267. //! if MultiStyled is not set
  268. DLLEXPORT AlphaFeld* getABuffer() const;
  269. //! Returns the color gradient without increased reference counter
  270. //! used for selected entries if MultiStyled is not set
  271. DLLEXPORT AlphaFeld* zABuffer() const;
  272. //! Returns the border used for a selected entry
  273. //! if MultiStyled is set
  274. DLLEXPORT Rahmen* getARahmen(int pos) const;
  275. //! Returns the border without increased reference counter used for
  276. //! a selected entry if MultiStyled is set
  277. DLLEXPORT Rahmen* zARahmen(int pos) const;
  278. //! Returns the background color in A8R8G8B8 format used for a
  279. //! selected entry if MultiStyled is set
  280. DLLEXPORT int getAHFarbe(int pos) const;
  281. //! Returns the background image used for a selected entry
  282. //! if MultiStyled is set
  283. DLLEXPORT Bild* getAHBild(int pos) const;
  284. //! Returns the background image without increased reference counter
  285. //! used for a selected entry if MultiStyled is set
  286. DLLEXPORT Bild* zAHBild(int pos) const;
  287. //! Returns the color gradient used for a selected entry
  288. //! if MultiStyled is set
  289. DLLEXPORT AlphaFeld* getABuffer(int pos) const;
  290. //! Returns the color gradient without increased reference counter
  291. //! used for a selected entry if MultiStyled is set
  292. DLLEXPORT AlphaFeld* zABuffer(int pos) const;
  293. //! Checks whether specific styles are set for a specific entry
  294. //! if MultiStyled is set. Also checks whether an entry is selected
  295. //! if MultiSelect is set \param pos The index of the entry
  296. //! \param style The styles to check
  297. DLLEXPORT inline bool hatMsStyle(int pos, __int64 style) const;
  298. //! Checks whether specific styles are not set for a specific entry
  299. //! if MultiStyled is set. Also checks whether an entry is not selected
  300. //! if MultiSelect is set
  301. //! \param pos The index of the entry
  302. //! \param style The styles to check
  303. DLLEXPORT inline bool hatMsStyleNicht(int pos, __int64 style) const;
  304. };
  305. class ZListe : public DrawableBackground
  306. {
  307. public:
  308. class Style : public DrawableBackground::Style
  309. {
  310. public:
  311. //! draws a seperation line between the entries
  312. static const __int64 EntrySeperator = 0x0001000;
  313. //! Combines the flags Sichtbar, Erlaubt,
  314. //! Rahmen, Hintergrund
  315. static const __int64 Normal
  316. = Sichtbar | Erlaubt | Rahmen | Hintergrund | EntrySeperator;
  317. };
  318. private:
  319. int entrySeperatorSize;
  320. int entrySeperatorColor;
  321. RCArray<Drawable> list;
  322. protected:
  323. //! Processes mouse messages
  324. //! \param me The event triggered by the mouse input
  325. DLLEXPORT void doMausEreignis(MausEreignis& me, bool userRet) override;
  326. public:
  327. //! Constructor
  328. DLLEXPORT ZListe();
  329. //! Destructor
  330. DLLEXPORT virtual ~ZListe();
  331. //! Adds an entry
  332. //! \param entry The drawing to add
  333. DLLEXPORT void addEintrag(Drawable* entry);
  334. //! Changes an entry
  335. //! \param pos The index of the entry
  336. //! \param entry The new drawing
  337. DLLEXPORT void setEintrag(int pos, Drawable* entry);
  338. //! Swaps the positions of two entries
  339. //! \param vpos The index of the first entry
  340. //! \param npos The index of the second entry
  341. DLLEXPORT void tauschEintragPos(int vpos, int npos);
  342. //! Sets the position of an entry
  343. //! \param vpos The index of the entry
  344. //! \param npos The index the entry should have
  345. DLLEXPORT void setEintragPos(int vpos, int npos);
  346. //! Deletes an entry
  347. //! pos: The index of the entry
  348. DLLEXPORT void removeEintrag(int pos);
  349. //! Scrolls to a specific entry
  350. //! \param eintrag The index of the entry
  351. DLLEXPORT void setVScrollZuEintrag(int eintrag);
  352. //! Updates the maximum scroll height by adding the heights of all entries
  353. DLLEXPORT void updateVScroll();
  354. //! sets the size of the entry seperator
  355. DLLEXPORT void setEntrySeperatorSize(int size);
  356. //! sets the color of the entry seperator
  357. DLLEXPORT void setEntrySeperatorColor(int color);
  358. //! Processes a keyboard event. Called automatically by the framework
  359. //! \param te The event
  360. DLLEXPORT void doTastaturEreignis(TastaturEreignis& te) override;
  361. //! Updates the drawing
  362. //! \param tickVal The elapsed time in seconds since the last
  363. //! call of this function \return 1 if the drawing has changed
  364. //! since the last call
  365. DLLEXPORT bool tick(double tickVal) override;
  366. //! Draws the object to zRObj if it is visible
  367. //! \param zRObj The image to draw into
  368. DLLEXPORT void render(Bild& rObj) override;
  369. //! Returns the index of an entry the mouse points to
  370. //! \param my The position of the mouse on the Y axis relative to
  371. //! the top edge of the list
  372. DLLEXPORT int getKlickEintrag(int my);
  373. //! Returns the number of entries
  374. DLLEXPORT int getEintragAnzahl() const;
  375. //! Returns the index of an entry
  376. //! \param zEntry The drawing
  377. DLLEXPORT int getEintragPos(Drawable* zEntry);
  378. //! Returns an entry
  379. //! \param pos The index of the entry
  380. DLLEXPORT Drawable* getEintrag(int pos) const;
  381. //! Returns an entry without increased reference counter
  382. //! \param pos The index of the entry
  383. DLLEXPORT Drawable* zEintrag(int pos) const;
  384. //! Returns the needed height
  385. DLLEXPORT int getNeededHeight() const;
  386. //! returns the size of the entry seperator
  387. DLLEXPORT int getEntrySeperatorSize() const;
  388. //! returns the color of the entry seperator
  389. DLLEXPORT int getEntrySeperatorColor() const;
  390. };
  391. } // namespace Framework
  392. #endif