UIMLView.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. #pragma once
  2. #include "Array.h"
  3. #include "Trie.h"
  4. #include "UIInitialization.h"
  5. #include "Zeichnung.h"
  6. namespace Framework
  7. {
  8. class Text;
  9. class ObjTabelle;
  10. class Schrift;
  11. class Bildschirm;
  12. class UIMLContainer;
  13. namespace XML
  14. {
  15. class Element;
  16. }
  17. class UIMLElement : public virtual ReferenceCounter
  18. {
  19. public:
  20. DLLEXPORT UIMLElement();
  21. DLLEXPORT virtual ~UIMLElement();
  22. //! prüft, ob dieses UIML Element für ein bestimmtes xml Element
  23. //! zuständig ist
  24. virtual bool isApplicableFor(XML::Element& element) = 0;
  25. //! erstellt eine neue Zeichnung zu einem gegebenen xml Element
  26. virtual Zeichnung* parseElement(
  27. XML::Element& element, UIMLContainer& generalFactory)
  28. = 0;
  29. //! wendet die layout parameter zu einer Zeichnung an
  30. DLLEXPORT virtual void layout(XML::Element& element,
  31. Zeichnung& z,
  32. int pWidth,
  33. int pHeight,
  34. UIMLContainer& generalLayouter);
  35. };
  36. class UIMLContainer : public UIMLElement
  37. {
  38. public:
  39. DLLEXPORT UIMLContainer();
  40. DLLEXPORT virtual ~UIMLContainer();
  41. virtual Zeichnung* zZeichnungById(const char* id) = 0;
  42. virtual Zeichnung* getZeichnungById(const char* id) = 0;
  43. virtual bool registerZeichnung(const char* id, Zeichnung* z) = 0;
  44. virtual const UIInit& getFactory() = 0;
  45. };
  46. class UIMLTextField : public UIMLElement
  47. {
  48. public:
  49. DLLEXPORT UIMLTextField();
  50. DLLEXPORT bool isApplicableFor(XML::Element& element) override;
  51. DLLEXPORT Zeichnung* parseElement(
  52. XML::Element& element, UIMLContainer& generalFactory) override;
  53. DLLEXPORT void layout(XML::Element& element,
  54. Zeichnung& z,
  55. int pWidth,
  56. int pHeight,
  57. UIMLContainer& generalLayouter) override;
  58. };
  59. class UIMLButton : public UIMLElement
  60. {
  61. public:
  62. DLLEXPORT UIMLButton();
  63. DLLEXPORT bool isApplicableFor(XML::Element& element) override;
  64. DLLEXPORT Zeichnung* parseElement(
  65. XML::Element& element, UIMLContainer& generalFactory) override;
  66. DLLEXPORT void layout(XML::Element& element,
  67. Zeichnung& z,
  68. int pWidth,
  69. int pHeight,
  70. UIMLContainer& generalLayouter) override;
  71. };
  72. class UIMLCheck : public UIMLElement
  73. {
  74. public:
  75. DLLEXPORT UIMLCheck();
  76. DLLEXPORT bool isApplicableFor(XML::Element& element) override;
  77. DLLEXPORT Zeichnung* parseElement(
  78. XML::Element& element, UIMLContainer& generalFactory) override;
  79. DLLEXPORT void layout(XML::Element& element,
  80. Zeichnung& z,
  81. int pWidth,
  82. int pHeight,
  83. UIMLContainer& generalLayouter) override;
  84. };
  85. class UIMLText : public UIMLElement
  86. {
  87. public:
  88. DLLEXPORT UIMLText();
  89. DLLEXPORT bool isApplicableFor(XML::Element& element) override;
  90. DLLEXPORT Zeichnung* parseElement(
  91. XML::Element& element, UIMLContainer& generalFactory) override;
  92. DLLEXPORT void layout(XML::Element& element,
  93. Zeichnung& z,
  94. int pWidth,
  95. int pHeight,
  96. UIMLContainer& generalLayouter) override;
  97. };
  98. class UIMLTextArea : public UIMLElement
  99. {
  100. public:
  101. DLLEXPORT UIMLTextArea();
  102. DLLEXPORT bool isApplicableFor(XML::Element& element) override;
  103. DLLEXPORT Zeichnung* parseElement(
  104. XML::Element& element, UIMLContainer& generalFactory) override;
  105. DLLEXPORT void layout(XML::Element& element,
  106. Zeichnung& z,
  107. int pWidth,
  108. int pHeight,
  109. UIMLContainer& generalLayouter) override;
  110. };
  111. class UIMLTable : public UIMLElement
  112. {
  113. public:
  114. DLLEXPORT UIMLTable();
  115. DLLEXPORT bool isApplicableFor(XML::Element& element) override;
  116. DLLEXPORT Zeichnung* parseElement(
  117. XML::Element& element, UIMLContainer& generalFactory) override;
  118. DLLEXPORT void layout(XML::Element& element,
  119. Zeichnung& z,
  120. int pWidth,
  121. int pHeight,
  122. UIMLContainer& generalLayouter) override;
  123. };
  124. class UIMLFrame : public UIMLElement
  125. {
  126. public:
  127. DLLEXPORT UIMLFrame();
  128. DLLEXPORT bool isApplicableFor(XML::Element& element) override;
  129. DLLEXPORT Zeichnung* parseElement(
  130. XML::Element& element, UIMLContainer& generalFactory) override;
  131. DLLEXPORT void layout(XML::Element& element,
  132. Zeichnung& z,
  133. int pWidth,
  134. int pHeight,
  135. UIMLContainer& generalLayouter) override;
  136. };
  137. /**
  138. KSG UIML Standart
  139. possible XML elements:
  140. - uimlview (the root element of uiml),
  141. - class (only as direct child of uimlview),
  142. - textfield,
  143. - button,
  144. - check, (KontrollKnopf)
  145. - text,
  146. - textarea,
  147. - table (allowed child elements: tr),
  148. - tr (allowed child elements: textfield, button, table, text, textarea,
  149. frame),
  150. - frame (allowed child elements: textfield, button, table, text,
  151. textarea, frame).
  152. possible global XML attributes:
  153. - id (string should be unique),
  154. - x (integer, optional % char at end),
  155. - y (integer, optional % char at end),
  156. - width (integer, optional % char at end) or auto keyword,
  157. - height (integer, optional % char at end) or auto keyword,
  158. - margin (integer, optional % char at end),
  159. - margin-left (integer, optional % char at end),
  160. - margin-top (integer, optional % char at end),
  161. - margin-right (integer, optional % char at end),
  162. - margin-bottom (integer, optional % char at end),
  163. - align-left (string (id values of other elements or keywords: start,
  164. end, center)),
  165. - align-top (string (id values of other elements or keywords: start,
  166. end, center)),
  167. - align-bottom ((string (id values of other elements or keywords: start,
  168. end, center)),
  169. - align-right (string (id values of other elements or keywords: start,
  170. end, center)),
  171. - tooltip (string),
  172. - style (hex __int64),
  173. - class (string (id of class element))
  174. attribute die sich gegenseitig ausschließen:
  175. - align-left / align-right
  176. - align-top / align-bottom
  177. spezific attributes:
  178. - font-size (textfield, text, textarea, button)
  179. - text-align (textfield, text, textarea)
  180. - text-align-horizontal (textfield, text, textarea)
  181. - text-align-vertical (textfield, text, textarea)
  182. example:
  183. \code
  184. <view>
  185. <textfield id="element_at_top_left" align-left="start",
  186. align-top="start", margin-left="5", margin-top="5" width="90%"
  187. height="30"/> <table id="element_below_textfield" align-left="start",
  188. aliign-top="element_at_top_left", margin-left="5", margin-top="5"
  189. width="90%" height="300"> <tr> <button id="a_button_in_a_table"/>
  190. <textfield id="a_textfield_in_a_table"/>
  191. </tr>
  192. </table>
  193. </view>
  194. \endcode
  195. */
  196. class UIMLView : public ZeichnungHintergrund,
  197. public UIMLContainer
  198. {
  199. private:
  200. RCArray<UIMLElement> knownElements;
  201. UIInit init;
  202. RCTrie<Zeichnung>* members;
  203. XML::Element* dom;
  204. int nextId;
  205. //! Verarbeitet ein Maus Ereignis. Wird vom Framework automatisch
  206. //! aufgerufen. \param me Das Ereignis
  207. DLLEXPORT virtual void doMausEreignis(
  208. MausEreignis& me, bool userRet) override;
  209. public:
  210. //! Erstellt eine UIML View
  211. DLLEXPORT UIMLView();
  212. //! Erstellt eine UIML View zu einem UIML Text
  213. //! \param uiml Ein xml element gemät des KSG UIML standarts
  214. //! \param screen Ein zeiger für den Belschirm auf dem die tooltips
  215. //! angezeigt werden sollen \param schrift Die schrift mit der der Text
  216. //! gezeichnet werden soll
  217. DLLEXPORT UIMLView(XML::Element* uiml, UIInit& init);
  218. //! Erstellt eine UIML View zu einem UIML Text
  219. //! \param uiml Ein xml text gemät des KSG UIML standarts
  220. //! \param screen Ein zeiger für den Belschirm auf dem die tooltips
  221. //! angezeigt werden sollen \param schrift Die schrift mit der der Text
  222. //! gezeichnet werden soll
  223. DLLEXPORT UIMLView(Text uiml, UIInit& init);
  224. DLLEXPORT ~UIMLView();
  225. //! entfernt alle bekannten elemente, die im uiml verwendet werden
  226. //! können
  227. DLLEXPORT void removeAllKnownElements();
  228. //! fügt ein neues bekanntes element hinzu, dass danach im uiml
  229. //! verwendet werden kann.
  230. DLLEXPORT void addKnownElement(UIMLElement* element);
  231. //! prüft, ob ein xml Element ein bekanntes uiml Element ist;
  232. DLLEXPORT bool isKnownElement(XML::Element* zElement);
  233. //! setzt den inhalt der view
  234. //! \param uiml Ein xml element gemät des KSG UIML standarts
  235. DLLEXPORT void setUIML(XML::Element* uiml);
  236. //! setzt den inhalt der view
  237. //! \param uiml Ein xml text gemät des KSG UIML standarts
  238. DLLEXPORT void setUIML(Text uiml);
  239. //! aktualisiert größe und position aller Zeichnungen gemäß den
  240. //! spezifikationen in UIML
  241. DLLEXPORT void layout();
  242. //! fügt ein element hinzu
  243. //! \param uiml Ein xml text gemät des KSG UIML standarts, welcher das
  244. //! neue Objekt darstellt \return id des neuen Elements
  245. DLLEXPORT Text addMember(Text uiml);
  246. //! fügt ein element zu einem Elternelement hinzu (funktioniert momentan
  247. //! nur mit frame Objekten) \param uiml Ein xml text gemät des KSG UIML
  248. //! standarts, welcher das neue Objekt darstellt \return id des neuen
  249. //! Elements
  250. DLLEXPORT Text addMember(Text uiml, Text parentId);
  251. //! entfernt ein element
  252. //! \param id id des Elements
  253. DLLEXPORT void removeMember(Text id);
  254. //! Gibt eine zeichnung zurück, welche in uiml eine bestimmte id hat
  255. //! \param id die id der Zeichnung
  256. DLLEXPORT Zeichnung* zZeichnungById(const char* id) override;
  257. //! Gibt eine zeichnung zurück, welche in uiml eine bestimmte id hat
  258. //! \param id die id der Zeichnung
  259. DLLEXPORT Zeichnung* getZeichnungById(const char* id) override;
  260. //! Verarbeitet ein Tastatur Ereignis. Wird vom Framework automatisch
  261. //! aufgerufen \param te Das Ereignis
  262. DLLEXPORT virtual void doTastaturEreignis(TastaturEreignis& te);
  263. //! Updated den Zeichenhintergrund
  264. //! \param tickVal Die vergangene Zeit in Sekunden, die seit dem Letzten
  265. //! Aufruf dieser Funktion verstrichen ist \return 1, wenn das Bild neu
  266. //! gezeichnet werden muss. 0 sonnst
  267. DLLEXPORT bool tick(double tickVal) override;
  268. //! Zeichnet den Hintergrund eines Zeichnunges nach rObj
  269. DLLEXPORT void render(Bild& rObj) override;
  270. //! Gibt den Dom Tree ohne erhöhten reference counter zurück
  271. //! Änderungen am Dom Tree sollten vermieden werden (nur änderungen von
  272. //! attributen einzelner elemente sind erlaubt)
  273. DLLEXPORT XML::Element* zDom() const;
  274. //! Gibt den Dom Tree zurück
  275. //! Änderungen am Dom Tree sollten vermieden werden (nur änderungen von
  276. //! attributen einzelner elemente sind erlaubt)
  277. DLLEXPORT XML::Element* getDom() const;
  278. DLLEXPORT bool isApplicableFor(XML::Element& element) override;
  279. DLLEXPORT Zeichnung* parseElement(
  280. XML::Element& element, UIMLContainer& generalFactory) override;
  281. DLLEXPORT void layout(XML::Element& element,
  282. Zeichnung& z,
  283. int pWidth,
  284. int pHeight,
  285. UIMLContainer& generalLayouter) override;
  286. DLLEXPORT bool registerZeichnung(const char* id, Zeichnung* z) override;
  287. DLLEXPORT const UIInit& getFactory() override;
  288. //! calculates the needed size for all content elements to be visible
  289. DLLEXPORT Punkt calculateContentSize();
  290. };
  291. } // namespace Framework