#pragma once #include "Array.h" #include "Trie.h" #include "UIInitialization.h" #include "Zeichnung.h" namespace Framework { class Text; class ObjTabelle; class Schrift; class Bildschirm; class UIMLContainer; namespace XML { class Element; } /** creates a Zeichnung that views an element of the uiml tag: defined by subclasses; basic attributes: - (__int64) style: sets the style. Default: TextField::Style::TextField + 0x...: will be interpreted as hex # ...: will be interpreted as normal __int64 - (string) text-align-horizontal: + center: adds the style TextFeld::Style::HCenter - (string) text-align-vertical: + center: adds the style TextFeld::Style::VCenter - (int) font-size: sets the font size - (int) text-color: sets the text color format: 0xAARRGGBB - disabled: removes the style TextFeld::Style::Editierbar - (string) width: sets the with + (int)%: specifies the width in % of the parent element + (int): specifies the width in pixel + (expression): calculates the width from an expression that contains values concatenated by the operators +, -, / or * + auto: attribute will be ignored here and may be handled by the subclasses - (string) height: sets the with + (int)%: specifies the width in % of the parent element + (int): specifies the width in pixel + (expression): calculates the width from an expression that contains values concatenated by the operators +, -, / or * + auto: attribute will be ignored here and may be handled by the subclasses - (string) align-x: sets the x coordinate of the view. The value of margin-x will be added + start: 0 + end: parentWidth + center: parentWidth / 2 - width / 2 + id of other element: other element x - (string) margin-x: only available if align-x is specified. + (int)%: specifies the distance to its x aligned coordinate in percentage of parentWidth + (int): specifies the distance to its x aligned coordinate in pixel + (expression): calculates the distance from an expression that contains values concatenated by the operators +, -, / or * - (string) align-y: sets the y coordinate of the view. The value of margin-y will be added + start: 0 + end: parentWidth + center: parentHeight / 2 - height / 2 + id of other element: other element y - (string) margin-y: only available if align-y is specified. + (int)%: specifies the distance to its y aligned coordinate in percentage of parentHeight + (int): specifies the distance to its y aligned coordinate in pixel + (expression): calculates the distance from an expression that contains values concatenated by the operators +, -, / or * - (string) align-left: sets the x coordinate of the view. The value of margin-left will be added. Will be ignored when align-x is present. + start: 0 + end: parentWidth + center: parentWidth / 2 - width / 2 + id of other element: other element x + other element width - (string) margin-left: only available if align-left is specified. + (int)%: specifies the distance to its left aligned coordinate in percentage of parentWidth + (int): specifies the distance to its left aligned coordinate in pixel + (expression): calculates the distance from an expression that contains values concatenated by the operators +, -, / or * - (string) align-right: sets the x coordinate of the view. The value of margin-right will be subtracted. Will be ignored when align-x or align-left is present. + start: -width + end: parentWidth - width + center: parentWidth / 2 - width / 2 + id of other element: other element x - width - (string) margin-right: only available if align-right is specified. + (int)%: specifies the distance to its right aligned coordinate in percentage of parentWidth + (int): specifies the distance to its right aligned coordinate in pixel + (expression): calculates the distance from an expression that contains values concatenated by the operators +, -, / or * - (string) align-top: sets the y coordinate of the view. The value of margin-top will be added. Will be ignored when align-y is present. + start: 0 + end: parentHeight + center: parentHeight / 2 - height / 2 + id of other element: other element y + other element height - (string) margin-top: only available if align-top is specified. + (int)%: specifies the distance to its top aligned coordinate in percentage of parentHeight + (int): specifies the distance to its top aligned coordinate in pixel + (expression): calculates the distance from an expression that contains values concatenated by the operators +, -, / or * - (string) align-bottom: sets the y coordinate of the view. The value of margin-bottom will be subtracted. Will be ignored when align-y or align-top is present. + start: -height + end: parentHeight - height + center: parentHeight / 2 - height / 2 + id of other element: other element y - height - (string) margin-bottom: only available if align-bottom is specified. + (int)%: specifies the distance to its bottom aligned coordinate in percentage of parentHeight + (int): specifies the distance to its bottom aligned coordinate in pixel + (expression): calculates the distance from an expression that contains values concatenated by the operators +, -, / or * - (string) x: sets the x coordinate of the view. overwrites align-left and align-right and align-x + (int)%: specifies the x coordinate in percentage of parentWidth + (int): specifies the x coordinate in pixel + (expression): calculates the x coordinate from an expression that contains values concatenated by the operators +, -, / or * - (string) y: sets the y coordinate of the view. overwrites align-top and align-bottom and align-y + (int)%: specifies the y coordinate in percentage of parentHeight + (int): specifies the y coordinate in pixel + (expression): calculates the y from an expression that contains values concatenated by the operators +, -, / or * additional attributes if the created view is an instance of ZeichnungHintergrund: - (int) border: width of the border in pixel - (int) border-color: color of the border format: 0xAARRGGBB */ class UIMLElement : public virtual ReferenceCounter { public: DLLEXPORT UIMLElement(); DLLEXPORT virtual ~UIMLElement(); //! prüft, ob dieses UIML Element für ein bestimmtes xml Element //! zuständig ist virtual bool isApplicableFor(XML::Element& element) = 0; //! erstellt eine neue Zeichnung zu einem gegebenen xml Element virtual Zeichnung* parseElement( XML::Element& element, UIMLContainer& generalFactory) = 0; //! aktualisiert eine Zeichnung mit den Daten eines xml Elements. Gibt //! false zurück, wenn die Zeichnung nicht aktualisiert werden konnte //! und neu erstellt werden muss virtual bool updateElement( XML::Element& element, Zeichnung& z, UIMLContainer& generalFactory) = 0; //! wendet die layout parameter zu einer Zeichnung an DLLEXPORT virtual void layout(XML::Element& element, Zeichnung& z, int pWidth, int pHeight, UIMLContainer& generalLayouter); /// /// calculates the size based on a given attribute value. Allowed values /// are expression with +, -, * or / operators and percentages of /// parentSize. uses 0 for each invalid part of the expression /// /// the expression that should be /// evaluated the size of the parent in /// pixel the resulting size in pixel DLLEXPORT int calculateSize(Text attributeValue, int parentSize); }; class UIMLContainer : public UIMLElement { public: DLLEXPORT UIMLContainer(); DLLEXPORT virtual ~UIMLContainer(); virtual Zeichnung* zZeichnungById(const char* id) = 0; virtual Zeichnung* getZeichnungById(const char* id) = 0; virtual Text getZeichnungId(Zeichnung& z) = 0; virtual void removeZeichnung(Zeichnung& z) = 0; virtual bool registerZeichnung(const char* id, Zeichnung* z) = 0; virtual const UIInit& getFactory() = 0; }; /** creates a TextFeld instance with style TextField::Style::TextField tag: <textfield> additional attributes to UIMLElement: - (__int64) style: sets the style. Default: TextField::Style::TextField - (string) text-align-horizontal: + center: adds the style TextFeld::Style::HCenter - (string) text-align-vertical: + center: adds the style TextFeld::Style::VCenter - (int) font-size: sets the font size - (int) text-color: sets the text color. format: 0xAARRGGBB - disabled: removes the style TextFeld::Style::Editierbar - (string) width: sets the with + auto: setzt the width to the calculated needed width - (string) height: sets the height + auto: setzt the height to the calculated needed height - (string) vScroll: adds a vertical scroll bar + auto: the max vertical scroll size is set to the needed text height and the click scroll per pixel will be set to font size - (int) hScroll: adds a hotizontal scroll bar + auto: the max horizontal scroll size is set to the needed text width and the click scroll per pixel will be set to font size */ class UIMLTextField : public UIMLElement { public: DLLEXPORT UIMLTextField(); DLLEXPORT bool isApplicableFor(XML::Element& element) override; DLLEXPORT Zeichnung* parseElement( XML::Element& element, UIMLContainer& generalFactory) override; DLLEXPORT bool updateElement(XML::Element& element, Zeichnung& z, UIMLContainer& generalFactory) override; DLLEXPORT void layout(XML::Element& element, Zeichnung& z, int pWidth, int pHeight, UIMLContainer& generalLayouter) override; }; class UIMLButton : public UIMLElement { public: DLLEXPORT UIMLButton(); DLLEXPORT bool isApplicableFor(XML::Element& element) override; DLLEXPORT Zeichnung* parseElement( XML::Element& element, UIMLContainer& generalFactory) override; DLLEXPORT bool updateElement(XML::Element& element, Zeichnung& z, UIMLContainer& generalFactory) override; DLLEXPORT void layout(XML::Element& element, Zeichnung& z, int pWidth, int pHeight, UIMLContainer& generalLayouter) override; }; class UIMLCheck : public UIMLElement { public: DLLEXPORT UIMLCheck(); DLLEXPORT bool isApplicableFor(XML::Element& element) override; DLLEXPORT Zeichnung* parseElement( XML::Element& element, UIMLContainer& generalFactory) override; DLLEXPORT bool updateElement(XML::Element& element, Zeichnung& z, UIMLContainer& generalFactory) override; DLLEXPORT void layout(XML::Element& element, Zeichnung& z, int pWidth, int pHeight, UIMLContainer& generalLayouter) override; }; /** creates a TextFeld instance with style TextField::Style::Text tag: <text> additional attributes to UIMLElement: - (__int64) style: sets the style. Default: TextField::Style::Text - (string) text-align-horizontal: + center: adds the style TextFeld::Style::HCenter - (string) text-align-vertical: + center: adds the style TextFeld::Style::VCenter - (int) font-size: sets the font size - (int) text-color: sets the text color. format: 0xAARRGGBB - disabled: removes the style TextFeld::Style::Editierbar - (string) width: sets the with + auto: setzt the width to the calculated needed width - (string) height: sets the height + auto: setzt the height to the calculated needed height - (string) vScroll: adds a vertical scroll bar + auto: the max vertical scroll size is set to the needed text height and the click scroll per pixel will be set to font size - (int) hScroll: adds a hotizontal scroll bar + auto: the max horizontal scroll size is set to the needed text width and the click scroll per pixel will be set to font size */ class UIMLText : public UIMLElement { public: DLLEXPORT UIMLText(); DLLEXPORT bool isApplicableFor(XML::Element& element) override; DLLEXPORT Zeichnung* parseElement( XML::Element& element, UIMLContainer& generalFactory) override; DLLEXPORT bool updateElement(XML::Element& element, Zeichnung& z, UIMLContainer& generalFactory) override; DLLEXPORT void layout(XML::Element& element, Zeichnung& z, int pWidth, int pHeight, UIMLContainer& generalLayouter) override; }; /** creates a TextFeld instance with style TextField::Style::TextGebiet tag: <textarea> additional attributes to UIMLElement: - (__int64) style: sets the style. Default: TextField::Style::TextGebiet - (string) text-align-horizontal: + center: adds the style TextFeld::Style::HCenter - (string) text-align-vertical: + center: adds the style TextFeld::Style::VCenter - (int) font-size: sets the font size - (int) text-color: sets the text color. format: 0xAARRGGBB - disabled: removes the style TextFeld::Style::Editierbar - (string) width: sets the with + auto: setzt the width to the calculated needed width - (string) height: sets the height + auto: setzt the height to the calculated needed height - (string) vScroll: adds a vertical scroll bar + auto: the max vertical scroll size is set to the needed text height and the click scroll per pixel will be set to font size - (int) hScroll: adds a hotizontal scroll bar + auto: the max horizontal scroll size is set to the needed text width and the click scroll per pixel will be set to font size */ class UIMLTextArea : public UIMLElement { public: DLLEXPORT UIMLTextArea(); DLLEXPORT bool isApplicableFor(XML::Element& element) override; DLLEXPORT Zeichnung* parseElement( XML::Element& element, UIMLContainer& generalFactory) override; DLLEXPORT bool updateElement(XML::Element& element, Zeichnung& z, UIMLContainer& generalFactory) override; DLLEXPORT void layout(XML::Element& element, Zeichnung& z, int pWidth, int pHeight, UIMLContainer& generalLayouter) override; }; class UIMLTable : public UIMLElement { public: DLLEXPORT UIMLTable(); DLLEXPORT bool isApplicableFor(XML::Element& element) override; DLLEXPORT Zeichnung* parseElement( XML::Element& element, UIMLContainer& generalFactory) override; DLLEXPORT bool updateElement(XML::Element& element, Zeichnung& z, UIMLContainer& generalFactory) override; DLLEXPORT void layout(XML::Element& element, Zeichnung& z, int pWidth, int pHeight, UIMLContainer& generalLayouter) override; }; /** creates a Fenster instance tag: <frame> additional attributes to UIMLElement: - (string) title: the title of the window - (int) title-height: sets the height of the title - (int) title-font-size: sets the font size of the title - (int) title-text-color: sets the color of the title. format: 0xAARRGGBB - (string) display: specifies the position of child elements + column: sets the position of child elements vertically below each other. any align attribute will overwrite this behaviour. + row: sets the position of the child elements horizontally beneath each other. any align attribute will overwrite this behaviour. - (int) gap: the space between each child element. Only valid if display is specified. + (int)%: specifies the y coordinate in percentage of parentHeight + (int): specifies the y coordinate in pixel + (expression): calculates the width from an expression that contains values concatenated by the operators +, -, / or * - (string) vScroll: adds a vertical scroll bar + auto: the max vertical scroll size is set to the needed child elements height - (int) hScroll: adds a hotizontal scroll bar + auto: the max horizontal scroll size is set to the needed child elements width - (string) width: sets the with + auto: setzt the width to the calculated needed width - (string) height: sets the height + auto: setzt the height to the calculated needed height */ class UIMLFrame : public UIMLElement { public: DLLEXPORT UIMLFrame(); DLLEXPORT bool isApplicableFor(XML::Element& element) override; DLLEXPORT Zeichnung* parseElement( XML::Element& element, UIMLContainer& generalFactory) override; DLLEXPORT bool updateElement(XML::Element& element, Zeichnung& z, UIMLContainer& generalFactory) override; DLLEXPORT void layout(XML::Element& element, Zeichnung& z, int pWidth, int pHeight, UIMLContainer& generalLayouter) override; }; /** Converts uiml views to Zeichnung implementations and renders them. The attribute id of each element has to be unique or absent. All implementations of UIMLElement in the framework are supported by default. Custom elements can be added by calling addKnownElement with a custom UIMLElement implementation. Look at the documentation of specific UIMLElement implementations to view all supported attributes. example: \code
\endcode */ class UIMLView : public ZeichnungHintergrund, public UIMLContainer { public: class Style : public ZeichnungHintergrund::Style { public: /// /// if this style is set, then the mause event action will be /// overwritten for all member views. The onMemberMouseEvent /// function will be executed instead. The style needs to be set /// before the uiml is parsed /// static const int GlobalMouseEvent = 0x01000; /// /// if this style is set, then the keyvord event action will be /// overwritten for all member views. The onMemberKeybordEvent /// function will be executed instead. The style needs to be set /// before the uiml is parsed /// static const int GlobalTastaturEvent = 0x01000; }; private: RCArray knownElements; UIInit init; RCTrie* members; Array memberList; RCArray idList; XML::Element* dom; int nextId; std::function onMemberMouseEvent; std::function onMemberKeyboardEvent; //! Verarbeitet ein Maus Ereignis. Wird vom Framework automatisch //! aufgerufen. \param me Das Ereignis DLLEXPORT virtual void doMausEreignis( MausEreignis& me, bool userRet) override; public: //! Erstellt eine UIML View DLLEXPORT UIMLView(); //! Erstellt eine UIML View zu einem UIML Text //! \param uiml Ein xml element gemät des KSG UIML standarts //! \param screen Ein zeiger für den Belschirm auf dem die tooltips //! angezeigt werden sollen \param schrift Die schrift mit der der Text //! gezeichnet werden soll DLLEXPORT UIMLView(XML::Element* uiml, UIInit& init); //! Erstellt eine UIML View zu einem UIML Text //! \param uiml Ein xml text gemät des KSG UIML standarts //! \param screen Ein zeiger für den Belschirm auf dem die tooltips //! angezeigt werden sollen \param schrift Die schrift mit der der Text //! gezeichnet werden soll DLLEXPORT UIMLView(Text uiml, UIInit& init); DLLEXPORT ~UIMLView(); /// /// sets a function that is executed if a mouse event on a member view /// occures and the style Style::GlobalMouseEvent is set. /// The mouse event will be ignored by the view if false is returned. /// /// the function to execute if a mouse event /// occures DLLEXPORT void setOnMemberMouseEvent(std::function onEventAction); /// /// sets a function that is executed if a mouse event on a member view /// occures and the style Style::GlobalTastaturEvent is set. /// The mouse event will be ignored by the view if false is returned. /// /// the function to execute if a mouse event /// occures DLLEXPORT void setOnMemberKeyboardEvent(std::function onEventAction); //! entfernt alle bekannten elemente, die im uiml verwendet werden //! können DLLEXPORT void removeAllKnownElements(); //! fügt ein neues bekanntes element hinzu, dass danach im uiml //! verwendet werden kann. DLLEXPORT void addKnownElement(UIMLElement* element); //! prüft, ob ein xml Element ein bekanntes uiml Element ist; DLLEXPORT bool isKnownElement(XML::Element* zElement); //! setzt den inhalt der view //! \param uiml Ein xml element gemät des KSG UIML standarts DLLEXPORT void setUIML(XML::Element* uiml); //! setzt den inhalt der view //! \param uiml Ein xml text gemät des KSG UIML standarts DLLEXPORT void setUIML(Text uiml); //! aktualisiert alles zeichnungen gemäß den spezifikationen in UIML. //! Zeichnungen von entfernten elementen werden entfernt und neue //! Zeichnungen für neue Elemente werden erstellt DLLEXPORT void update(); //! aktualisiert größe und position aller Zeichnungen gemäß den //! spezifikationen in UIML DLLEXPORT void layout(); //! fügt ein element hinzu //! \param uiml Ein xml text gemät des KSG UIML standarts, welcher das //! neue Objekt darstellt \return id des neuen Elements DLLEXPORT Text addMember(Text uiml); //! fügt ein element zu einem Elternelement hinzu (funktioniert momentan //! nur mit frame Objekten) \param uiml Ein xml text gemät des KSG UIML //! standarts, welcher das neue Objekt darstellt \return id des neuen //! Elements DLLEXPORT Text addMember(Text uiml, Text parentId); //! entfernt ein element //! \param id id des Elements DLLEXPORT void removeMember(Text id); //! Gibt eine zeichnung zurück, welche in uiml eine bestimmte id hat //! \param id die id der Zeichnung DLLEXPORT Zeichnung* zZeichnungById(const char* id) override; //! Gibt eine zeichnung zurück, welche in uiml eine bestimmte id hat //! \param id die id der Zeichnung DLLEXPORT Zeichnung* getZeichnungById(const char* id) override; //! Verarbeitet ein Tastatur Ereignis. Wird vom Framework automatisch //! aufgerufen \param te Das Ereignis DLLEXPORT virtual void doTastaturEreignis(TastaturEreignis& te); //! Updated den Zeichenhintergrund //! \param tickVal Die vergangene Zeit in Sekunden, die seit dem Letzten //! Aufruf dieser Funktion verstrichen ist \return 1, wenn das Bild neu //! gezeichnet werden muss. 0 sonnst DLLEXPORT bool tick(double tickVal) override; //! Zeichnet den Hintergrund eines Zeichnunges nach rObj DLLEXPORT void render(Bild& rObj) override; //! Gibt den Dom Tree ohne erhöhten reference counter zurück //! Änderungen am Dom Tree sollten vermieden werden (nur änderungen von //! attributen einzelner elemente sind erlaubt) DLLEXPORT XML::Element* zDom() const; //! Gibt den Dom Tree zurück //! Änderungen am Dom Tree sollten vermieden werden (nur änderungen von //! attributen einzelner elemente sind erlaubt) DLLEXPORT XML::Element* getDom() const; DLLEXPORT bool isApplicableFor(XML::Element& element) override; DLLEXPORT Zeichnung* parseElement( XML::Element& element, UIMLContainer& generalFactory) override; DLLEXPORT bool updateElement(XML::Element& element, Zeichnung& z, UIMLContainer& generalFactory) override; DLLEXPORT void layout(XML::Element& element, Zeichnung& z, int pWidth, int pHeight, UIMLContainer& generalLayouter) override; DLLEXPORT Text getZeichnungId(Zeichnung& z) override; DLLEXPORT void removeZeichnung(Zeichnung& z) override; DLLEXPORT bool registerZeichnung(const char* id, Zeichnung* z) override; DLLEXPORT const UIInit& getFactory() override; //! calculates the needed size for all content elements to be visible DLLEXPORT Punkt calculateContentSize(); }; } // namespace Framework