#ifndef Liste_H #define Liste_H #include "Array.h" #include "Drawing.h" namespace Framework { class Border; //! Border.h class AlphaField; //! AlphaField.h class Image; //! Image.h class Text; //! Text.h class TextField; //! TextField.h class VScrollBar; //! Scroll.h struct KeyboardEvent; //! KeyboardEvent.h struct MouseEvent; //! MouseEvent.h class Font; //! Font.h class SelectionList; //! from this file //! A drawing of the 2D GUI Framework that displays a list from which //! the user can select and deselect elements class SelectionList : public DrawableBackground { public: class Style : public DrawableBackground::Style { public: //! Specifies whether the list entries have a border static const __int64 FieldBorder = 0x0001000; //! Specifies whether the entries have a background static const __int64 FeldHintergrund = 0x0002000; //! Specifies whether the entries have a background image static const __int64 FeldHImage = 0x0004000; //! Specifies whether alpha blending is used when drawing //! entry backgrounds static const __int64 FeldHAlpha = 0x0008000; //! Specifies whether the entries have a color gradient static const __int64 FeldBuffer = 0x0010000; //! Specifies whether selected entries have a background static const __int64 AuswahlHintergrund = 0x0020000; //! Specifies whether selected entries have a background image static const __int64 AuswahlHImage = 0x0040000; //! Specifies whether alpha blending is used for drawing //! backgrounds of selected entries static const __int64 AuswahlHAlpha = 0x0080000; //! Specifies whether selected entries have a color gradient static const __int64 AuswahlBuffer = 0x0100000; //! Specifies whether selected entries have a border static const __int64 SelectionBorder = 0x0200000; //! Specifies whether each entry has its own background, //! color gradient, and border when selected static const __int64 MultiStyled = 0x0400000; //! Specifies that multiple entries can be selected simultaneously static const __int64 MultiSelect = 0x0800000; //! Specifies whether a specific entry is selected, if //! MultiSelect was set. static const __int64 Selected = 0x1000000; //! Combines the flags Sichtbar, Erlaubt, Border, FeldHAlpha, //! FeldHintergrund, FieldBorder, AuswahlBuffer, SelectionBorder static const __int64 Normal = Sichtbar | Erlaubt | Border | FeldHAlpha | FeldHintergrund | FieldBorder | AuswahlBuffer | SelectionBorder; }; private: RCArray* tfListe; int auswahl; int ahFarbe; Image* ahImage; AlphaField* aBuffer; Border* aBorder; Array<__int64>* styles; Array* ahFarbeListe; RCArray* ahImageListe; RCArray* aBufferListe; RCArray* aBorderList; Font* schrift; //! Processes mouse messages //! \param me The event triggered by the mouse input DLLEXPORT void doMouseEvent(MouseEvent& me, bool userRet) override; DLLEXPORT bool hatStyle(int styleSet, int styleCheck) const; public: //! Constructor DLLEXPORT SelectionList(); //! Destructor DLLEXPORT virtual ~SelectionList(); //! Updates the styles, size and position of the entries DLLEXPORT void update(); //! Adds an entry //! \param txt The text of the entry DLLEXPORT void addEintrag(Text* txt); //! Adds an entry //! \param txt The text of the entry DLLEXPORT void addEintrag(const char* txt); //! Adds a pointer to an entry //! \param tf The TextField used to draw the entry DLLEXPORT void addEintragZ(TextField* tf); //! Adds an entry at a specific position //! \param pos The index of the new entry //! \param txt The text of the entry DLLEXPORT void addEintrag(int pos, Text* txt); //! Adds an entry at a specific position //! \param pos The index of the new entry //! \param txt The text of the entry DLLEXPORT void addEintrag(int pos, const char* txt); //! Adds a pointer to an entry at a specific position //! \param pos The index of the new entry \param tf The TextField //! used to draw the entry DLLEXPORT void addEintragZ(int pos, TextField* tf); //! Changes an entry //! \param pos The index of the entry //! \param txt The new text of the entry DLLEXPORT void setEintrag(int pos, Text* txt); //! Changes an entry //! \param pos The index of the entry //! \param txt The new text of the entry DLLEXPORT void setEintrag(int pos, const char* txt); //! Changes the pointer of an entry //! \param pos The index of the entry //! \param tf The new entry DLLEXPORT void setEintragZ(int pos, TextField* tf); //! Swaps the positions of two entries //! \param vpos The index of the first entry //! \param npos The index of the second entry DLLEXPORT void tauschEintragPos(int vpos, int npos); //! Sets the position of an entry //! \param vpos The index of the entry //! \param npos The index the entry should have DLLEXPORT void setEintragPos(int vpos, int npos); //! Deletes an entry //! pos: The index of the entry DLLEXPORT void removeEintrag(int pos); //! Sets the font to use //! \param schrift The font DLLEXPORT void setFontZ(Font* schrift); //! Scrolls to a specific entry //! \param eintrag The index of the entry DLLEXPORT void setVScrollZuEintrag(int eintrag); //! Updates the maximum scroll height by adding the heights of all entries DLLEXPORT void updateVScroll(); //! Sets a pointer to the border used for selected entries //! if MultiStyled is not set \param rahmen The border DLLEXPORT void setALRZ(Border* rahmen); //! Sets the width of the border used for selected entries //! if MultiStyled is not set \param br The width in pixels DLLEXPORT void setALRBreite(int br); //! Sets the color of the border used for selected entries //! if MultiStyled is not set \param fc The color in A8R8G8B8 format DLLEXPORT void setALRFarbe(int fc); //! Sets a pointer to the color gradient used for selected entries //! if MultiStyled is not set \param buffer The color gradient DLLEXPORT void setAAFZ(AlphaField* buffer); //! Sets the strength of the color gradient used for selected entries //! if MultiStyled is not set \param st The strength DLLEXPORT void setAAFStrength(int st); //! Sets the color of the color gradient used for selected entries //! if MultiStyled is not set \param fc The color in A8R8G8B8 format DLLEXPORT void setAAFFarbe(int fc); //! Sets the background image by copying, used for selected entries //! if MultiStyled is not set \param bild The image to copy DLLEXPORT void setAHImage(Image* bild); //! Sets a pointer to the background image used for selected entries //! if MultiStyled is not set \param bild The image DLLEXPORT void setAHImageZ(Image* bild); //! Sets the background color used for selected entries //! if MultiStyled is not set \param fc The color in A8R8G8B8 format DLLEXPORT void setAHFarbe(int fc); //! Sets a pointer to the border used for a selected entry //! if MultiStyled is set \param pos The index of the entry //! \param rahmen The border DLLEXPORT void setALRZ(int pos, Border* rahmen); //! Sets the width of the border used for a selected entry //! if MultiStyled is set \param pos The index of the entry //! \param br The width in pixels DLLEXPORT void setALRBreite(int pos, int br); //! Sets the color of the border used for a selected entry //! if MultiStyled is set \param pos The index of the entry //! \param fc The color in A8R8G8B8 format DLLEXPORT void setALRFarbe(int pos, int fc); //! Sets a pointer to the color gradient used for a selected entry //! if MultiStyled is set \param pos The index of the entry //! \param buffer The color gradient DLLEXPORT void setAAFZ(int pos, AlphaField* buffer); //! Sets the strength of the color gradient used for a selected entry //! if MultiStyled is set \param pos The index of the entry //! \param st The strength DLLEXPORT void setAAFStrength(int pos, int st); //! Sets the color of the color gradient used for a selected entry //! if MultiStyled is set \param pos The index of the entry //! \param fc The color in A8R8G8B8 format DLLEXPORT void setAAFFarbe(int pos, int fc); //! Sets the background image by copying, used for a selected entry //! if MultiStyled is set //! \param pos The index of the entry //! \param bild The image to copy DLLEXPORT void setAHImage(int pos, Image* bild); //! Sets a pointer to the background image used for a selected entry //! if MultiStyled is set //! \param pos The index of the entry //! \param bild The image DLLEXPORT void setAHImageZ(int pos, Image* bild); //! Sets the background color used for a selected entry //! if MultiStyled is set \param pos The index of the entry //! \param fc The color in A8R8G8B8 format DLLEXPORT void setAHFarbe(int pos, int fc); //! Sets the style of an entry if MultiStyled is set, and specifies //! whether an entry is selected if MultiSelect is set //! \param pos The index of the entry \param style The new style DLLEXPORT void setMsStyle(int pos, __int64 style); //! Changes the style of an entry if MultiStyled is set, and specifies //! whether an entry is selected if MultiSelect is set //! \param pos The index of the entry \param style The style //! add_remove: 1 if the style should be added. 0 if the style //! should be removed DLLEXPORT void setMsStyle(int pos, __int64 style, bool add_remove); //! Adds styles to an entry if MultiStyled is set, and specifies //! whether an entry is selected if MultiSelect is set //! \param pos The index of the entry \param style The style to add DLLEXPORT void addMsStyle(int pos, __int64 style); //! Removes styles from an entry if MultiStyled is set, and specifies //! whether an entry is selected if MultiSelect is set //! \param pos The index of the entry \param style The style to remove DLLEXPORT void removeMsStyle(int pos, __int64 style); //! Processes a keyboard event. Called automatically by the framework //! \param te The event DLLEXPORT void doKeyboardEvent(KeyboardEvent& te) override; //! Draws the object to zRObj if it is visible //! \param zRObj The image to draw into DLLEXPORT void render(Image& zRObj) override; //! Returns the index of an entry the mouse points to //! \param my The position of the mouse on the Y axis relative to //! the top edge of the list DLLEXPORT int getKlickEintrag(int my); //! Selects an entry //! \param ausw The index of the entry DLLEXPORT void setAuswahl(int ausw); //! Deselects all selected entries DLLEXPORT void deSelect(); //! Returns the number of entries DLLEXPORT int getEntryCount() const; //! Returns the index of the selected entry if MultiSelect is not //! set. If MultiSelect is set, the selection of an entry can be //! checked with hatMsStyle( entry index, //! SelectionList::Style::Ausgewaehlt ) DLLEXPORT int getAuswahl() const; //! Returns the index of an entry //! \param eintragText The text of the entry DLLEXPORT int getEintragPos(Text* eintragText); //! Returns an entry //! \param pos The index of the entry DLLEXPORT TextField* getEintrag(int pos) const; //! Returns an entry without increased reference counter //! \param pos The index of the entry DLLEXPORT TextField* zEintrag(int pos) const; //! Returns the border used for selected entries //! if MultiStyled is not set DLLEXPORT Border* getABorder() const; //! Returns the border without increased reference counter used for //! selected entries if MultiStyled is not set DLLEXPORT Border* zABorder() const; //! Returns the background color in A8R8G8B8 format used for //! selected entries if MultiStyled is not set DLLEXPORT int getAHFarbe() const; //! Returns the background image used for selected entries //! if MultiStyled is not set DLLEXPORT Image* getAHImage() const; //! Returns the background image without increased reference counter //! used for selected entries if MultiStyled is not set DLLEXPORT Image* zAHImage() const; //! Returns the color gradient used for selected entries //! if MultiStyled is not set DLLEXPORT AlphaField* getABuffer() const; //! Returns the color gradient without increased reference counter //! used for selected entries if MultiStyled is not set DLLEXPORT AlphaField* zABuffer() const; //! Returns the border used for a selected entry //! if MultiStyled is set DLLEXPORT Border* getABorder(int pos) const; //! Returns the border without increased reference counter used for //! a selected entry if MultiStyled is set DLLEXPORT Border* zABorder(int pos) const; //! Returns the background color in A8R8G8B8 format used for a //! selected entry if MultiStyled is set DLLEXPORT int getAHFarbe(int pos) const; //! Returns the background image used for a selected entry //! if MultiStyled is set DLLEXPORT Image* getAHImage(int pos) const; //! Returns the background image without increased reference counter //! used for a selected entry if MultiStyled is set DLLEXPORT Image* zAHImage(int pos) const; //! Returns the color gradient used for a selected entry //! if MultiStyled is set DLLEXPORT AlphaField* getABuffer(int pos) const; //! Returns the color gradient without increased reference counter //! used for a selected entry if MultiStyled is set DLLEXPORT AlphaField* zABuffer(int pos) const; //! Checks whether specific styles are set for a specific entry //! if MultiStyled is set. Also checks whether an entry is selected //! if MultiSelect is set \param pos The index of the entry //! \param style The styles to check DLLEXPORT inline bool hatMsStyle(int pos, __int64 style) const; //! Checks whether specific styles are not set for a specific entry //! if MultiStyled is set. Also checks whether an entry is not selected //! if MultiSelect is set //! \param pos The index of the entry //! \param style The styles to check DLLEXPORT inline bool hatMsStyleNicht(int pos, __int64 style) const; }; class DrawableList : public DrawableBackground { public: class Style : public DrawableBackground::Style { public: //! draws a seperation line between the entries static const __int64 EntrySeperator = 0x0001000; //! Combines the flags Sichtbar, Erlaubt, //! Border, Hintergrund static const __int64 Normal = Sichtbar | Erlaubt | Border | Hintergrund | EntrySeperator; }; private: int entrySeperatorSize; int entrySeperatorColor; RCArray list; protected: //! Processes mouse messages //! \param me The event triggered by the mouse input DLLEXPORT void doMouseEvent(MouseEvent& me, bool userRet) override; public: //! Constructor DLLEXPORT DrawableList(); //! Destructor DLLEXPORT virtual ~DrawableList(); //! Adds an entry //! \param entry The drawing to add DLLEXPORT void addEintrag(Drawable* entry); //! Changes an entry //! \param pos The index of the entry //! \param entry The new drawing DLLEXPORT void setEintrag(int pos, Drawable* entry); //! Swaps the positions of two entries //! \param vpos The index of the first entry //! \param npos The index of the second entry DLLEXPORT void tauschEintragPos(int vpos, int npos); //! Sets the position of an entry //! \param vpos The index of the entry //! \param npos The index the entry should have DLLEXPORT void setEintragPos(int vpos, int npos); //! Deletes an entry //! pos: The index of the entry DLLEXPORT void removeEintrag(int pos); //! Scrolls to a specific entry //! \param eintrag The index of the entry DLLEXPORT void setVScrollZuEintrag(int eintrag); //! Updates the maximum scroll height by adding the heights of all entries DLLEXPORT void updateVScroll(); //! sets the size of the entry seperator DLLEXPORT void setEntrySeperatorSize(int size); //! sets the color of the entry seperator DLLEXPORT void setEntrySeperatorColor(int color); //! Processes a keyboard event. Called automatically by the framework //! \param te The event DLLEXPORT void doKeyboardEvent(KeyboardEvent& te) override; //! Updates the drawing //! \param tickVal The elapsed time in seconds since the last //! call of this function \return 1 if the drawing has changed //! since the last call DLLEXPORT bool tick(double tickVal) override; //! Draws the object to zRObj if it is visible //! \param zRObj The image to draw into DLLEXPORT void render(Image& rObj) override; //! Returns the index of an entry the mouse points to //! \param my The position of the mouse on the Y axis relative to //! the top edge of the list DLLEXPORT int getKlickEintrag(int my); //! Returns the number of entries DLLEXPORT int getEntryCount() const; //! Returns the index of an entry //! \param zEntry The drawing DLLEXPORT int getEintragPos(Drawable* zEntry); //! Returns an entry //! \param pos The index of the entry DLLEXPORT Drawable* getEintrag(int pos) const; //! Returns an entry without increased reference counter //! \param pos The index of the entry DLLEXPORT Drawable* zEintrag(int pos) const; //! Returns the needed height DLLEXPORT int getNeededHeight() const; //! returns the size of the entry seperator DLLEXPORT int getEntrySeperatorSize() const; //! returns the color of the entry seperator DLLEXPORT int getEntrySeperatorColor() const; }; } // namespace Framework #endif