UIMLView.h 9.9 KB

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