| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- $#include "UIElement.h"
- enum HorizontalAlignment
- {
- HA_LEFT = 0,
- HA_CENTER,
- HA_RIGHT
- };
- enum VerticalAlignment
- {
- VA_TOP = 0,
- VA_CENTER,
- VA_BOTTOM
- };
- enum Corner
- {
- C_TOPLEFT = 0,
- C_TOPRIGHT,
- C_BOTTOMLEFT,
- C_BOTTOMRIGHT,
- MAX_UIELEMENT_CORNERS
- };
- enum Orientation
- {
- O_HORIZONTAL = 0,
- O_VERTICAL
- };
- enum FocusMode
- {
- FM_NOTFOCUSABLE = 0,
- FM_RESETFOCUS,
- FM_FOCUSABLE,
- FM_FOCUSABLE_DEFOCUSABLE
- };
- enum LayoutMode
- {
- LM_FREE = 0,
- LM_HORIZONTAL,
- LM_VERTICAL
- };
- enum TraversalMode
- {
- TM_BREADTH_FIRST = 0,
- TM_DEPTH_FIRST
- };
- static const unsigned DD_DISABLED;
- static const unsigned DD_SOURCE;
- static const unsigned DD_TARGET;
- static const unsigned DD_SOURCE_AND_TARGET;
- class UIElement : public Serializable
- {
- UIElement(Context* context);
- virtual ~UIElement();
- virtual const IntVector2& GetScreenPosition() const;
- bool LoadXML(Deserializer& source);
- bool SaveXML(Serializer& dest) const;
- bool FilterAttributes(XMLElement& dest) const;
- void SetName(const String& name);
- void SetName(const char* name);
-
- void SetPosition(const IntVector2& position);
- void SetPosition(int x, int y);
- void SetSize(const IntVector2& size);
- void SetSize(int width, int height);
- void SetWidth(int width);
- void SetHeight(int height);
- void SetMinSize(const IntVector2& minSize);
- void SetMinSize(int width, int height);
- void SetMinWidth(int width);
- void SetMinHeight(int height);
- void SetMaxSize(const IntVector2& maxSize);
- void SetMaxSize(int width, int height);
- void SetMaxWidth(int width);
- void SetMaxHeight(int height);
- void SetFixedSize(const IntVector2& size);
- void SetFixedSize(int width, int height);
- void SetFixedWidth(int width);
- void SetFixedHeight(int height);
- void SetAlignment(HorizontalAlignment hAlign, VerticalAlignment vAlign);
- void SetHorizontalAlignment(HorizontalAlignment align);
- void SetVerticalAlignment(VerticalAlignment align);
- void SetClipBorder(const IntRect& rect);
- void SetColor(const Color& color);
- void SetColor(Corner corner, const Color& color);
- void SetPriority(int priority);
- void SetOpacity(float opacity);
- void SetBringToFront(bool enable);
- void SetBringToBack(bool enable);
- void SetClipChildren(bool enable);
- void SetSortChildren(bool enable);
- void SetUseDerivedOpacity(bool enable);
- void SetEnabled(bool enable);
- void SetFocus(bool enable);
- void SetSelected(bool enable);
- void SetVisible(bool enable);
- void SetFocusMode(FocusMode mode);
- void SetDragDropMode(unsigned mode);
- bool SetStyle(const String& styleName, XMLFile* file = 0);
- bool SetStyle(const char* styleName, XMLFile* file = 0);
-
- bool SetStyle(const XMLElement& element);
- bool SetStyleAuto(XMLFile* file = 0);
- void SetDefaultStyle(XMLFile* style);
-
- void SetLayout(LayoutMode mode, int spacing = 0, const IntRect& border = IntRect::ZERO);
-
- void SetLayoutMode(LayoutMode mode);
- void SetLayoutSpacing(int spacing);
- void SetLayoutBorder(const IntRect& border);
- void SetIndent(int indent);
- void SetIndentSpacing(int indentSpacing);
- void UpdateLayout();
- void DisableLayoutUpdate();
- void EnableLayoutUpdate();
- void BringToFront();
-
- // UIElement* CreateChild(ShortStringHash type, const String& name = String::EMPTY, unsigned index = M_MAX_UNSIGNED);
- // UIElement* CreateChild(const char* type, const char* name = 0, unsigned index = M_MAX_UNSIGNED);
-
- void AddChild(UIElement* element);
- void InsertChild(unsigned index, UIElement* element);
- void RemoveChild(UIElement* element, unsigned index = 0);
- void RemoveChildAtIndex @ RemoveChild(unsigned index);
- void RemoveAllChildren();
- void Remove();
- unsigned FindChild(UIElement* element) const;
- void SetParent(UIElement* parent, unsigned index = M_MAX_UNSIGNED);
- void SetInternal(bool enable);
- void SetTraversalMode(TraversalMode traversalMode);
- void SetElementEventSender(bool flag);
- // template <class T> T* CreateChild(const String& name = String::EMPTY, unsigned index = M_MAX_UNSIGNED);
- BorderImage* CreateChild<BorderImage> @ CreateBorderImage(const char* name = 0, unsigned index = M_MAX_UNSIGNED);
- Button* CreateChild<Button> @ CreateButton(const char* name = 0, unsigned index = M_MAX_UNSIGNED);
- CheckBox* CreateChild<CheckBox> @ CreateCheckBox(const char* name = 0, unsigned index = M_MAX_UNSIGNED);
- Cursor* CreateChild<Cursor> @ CreateCursor(const char* name = 0, unsigned index = M_MAX_UNSIGNED);
- DropDownList* CreateChild<DropDownList> @ CreateDropDownList(const char* name = 0, unsigned index = M_MAX_UNSIGNED);
- LineEdit* CreateChild<LineEdit> @ CreateLineEdit(const char* name = 0, unsigned index = M_MAX_UNSIGNED);
- ListView* CreateChild<ListView> @ CreateListView(const char* name = 0, unsigned index = M_MAX_UNSIGNED);
- Menu* CreateChild<Menu> @ CreateMenu(const char* name = 0, unsigned index = M_MAX_UNSIGNED);
- ScrollBar* CreateChild<ScrollBar> @ CreateScrollBar(const char* name = 0, unsigned index = M_MAX_UNSIGNED);
- ScrollView* CreateChild<ScrollView> @ CreateScrollView(const char* name = 0, unsigned index = M_MAX_UNSIGNED);
- Slider* CreateChild<Slider> @ CreateSlider(const char* name = 0, unsigned index = M_MAX_UNSIGNED);
- Sprite* CreateChild<Sprite> @ CreateSprite(const char* name = 0, unsigned index = M_MAX_UNSIGNED);
- Text* CreateChild<Text> @ CreateText(const char* name = 0, unsigned index = M_MAX_UNSIGNED);
- UIElement* CreateChild<UIElement> @ CreateUIElement(const char* name = 0, unsigned index = M_MAX_UNSIGNED);
- Window* CreateChild<Window> @ CreateWindow(const char* name = 0, unsigned index = M_MAX_UNSIGNED);
- const String& GetName() const;
- const IntVector2& GetPosition() const;
- const IntVector2& GetSize() const;
- int GetWidth() const;
- int GetHeight() const;
- const IntVector2& GetMinSize() const;
- int GetMinWidth() const;
- int GetMinHeight() const;
- const IntVector2& GetMaxSize() const;
- int GetMaxWidth() const;
- int GetMaxHeight() const;
- bool IsFixedSize() const;
- bool IsFixedWidth() const;
- bool IsFixedHeight() const;
- const IntVector2& GetChildOffset() const;
- HorizontalAlignment GetHorizontalAlignment() const;
- VerticalAlignment GetVerticalAlignment() const;
- const IntRect& GetClipBorder() const;
- const Color& GetColor(Corner corner) const;
- int GetPriority() const;
- float GetOpacity() const;
- float GetDerivedOpacity() const;
- bool GetBringToFront() const;
- bool GetBringToBack() const;
- bool GetClipChildren() const;
- bool GetSortChildren() const;
- bool GetUseDerivedOpacity() const;
- bool HasFocus() const;
- bool IsEnabled() const;
- bool IsSelected() const;
- bool IsVisible() const;
- bool IsHovering() const;
- bool IsInternal() const;
- bool HasColorGradient() const;
- FocusMode GetFocusMode() const;
- unsigned GetDragDropMode() const;
- const String& GetAppliedStyle() const;
- XMLFile* GetDefaultStyle(bool recursiveUp = true) const;
- LayoutMode GetLayoutMode() const;
- int GetLayoutSpacing() const;
- const IntRect& GetLayoutBorder() const;
- unsigned GetNumChildren(bool recursive = false) const;
- UIElement* GetChild(unsigned index) const;
-
- UIElement* GetChild(const String& name, bool recursive = false) const;
- tolua_outside UIElement* UIElementGetChild @ GetChild(const char* name, bool recursive = false) const;
-
- UIElement* GetChild(const ShortStringHash& key, const Variant& value = Variant::EMPTY, bool recursive = false) const;
- tolua_outside UIElement* UIElementGetChild2 @ GetChild(const char* key, const Variant& value = Variant::EMPTY, bool recursive = false) const;
-
- UIElement* GetParent() const;
- UIElement* GetRoot() const;
- const Color& GetDerivedColor() const;
- IntVector2 ScreenToElement(const IntVector2& screenPosition);
- IntVector2 ElementToScreen(const IntVector2& position);
- bool IsInside(IntVector2 position, bool isScreen);
- bool IsInsideCombined(IntVector2 position, bool isScreen);
- IntRect GetCombinedScreenRect();
- void SortChildren();
- int GetLayoutMinSize() const;
- int GetIndent() const;
- int GetIndentSpacing() const;
- int GetIndentWidth() const;
- void SetChildOffset(const IntVector2& offset);
- void SetHovering(bool enable);
- const Color& GetColorAttr() const;
- TraversalMode GetTraversalMode() const;
- bool IsElementEventSender() const;
- UIElement* GetElementEventSender() const;
-
- tolua_readonly tolua_property__get_set IntVector2& screenPosition;
- tolua_property__get_set String& name;
- tolua_property__get_set IntVector2& position;
- tolua_property__get_set IntVector2 size;
- tolua_property__get_set int width;
- tolua_property__get_set int height;
- tolua_property__get_set IntVector2 minSize;
- tolua_property__get_set int minWidth;
- tolua_property__get_set int minHeight;
- tolua_property__get_set IntVector2 maxSize;
- tolua_property__get_set int maxWidth;
- tolua_property__get_set int maxHeight;
- tolua_readonly tolua_property__is_set bool fixedSize;
- tolua_readonly tolua_property__is_set bool fixedWidth;
- tolua_readonly tolua_property__is_set bool fixedHeight;
- tolua_property__get_set IntVector2& childOffset;
- tolua_property__get_set HorizontalAlignment horizontalAlignment;
- tolua_property__get_set VerticalAlignment verticalAlignment;
- tolua_property__get_set IntRect clipBorder;
- tolua_property__get_set Color& color; // Write only property.
- tolua_property__get_set int priority;
- tolua_property__get_set float opacity;
- tolua_readonly tolua_property__get_set float derivedOpacity;
- tolua_property__get_set bool bringToFront;
- tolua_property__get_set bool bringToBack;
- tolua_property__get_set bool clipChildren;
- tolua_property__get_set bool sortChildren;
- tolua_property__get_set bool useDerivedOpacity;
- tolua_property__has_set bool focus;
- tolua_property__is_set bool enabled;
- tolua_property__is_set bool selected;
- tolua_property__is_set bool visible;
- tolua_property__is_set bool hovering;
- tolua_property__is_set bool internal;
- tolua_readonly tolua_property__has_set bool colorGradient;
- tolua_property__get_set FocusMode focusMode;
- tolua_property__get_set unsigned dragDropMode;
- tolua_property__get_set String& style;
- tolua_property__get_set XMLFile* defaultStyle;
- tolua_property__get_set LayoutMode layoutMode;
- tolua_property__get_set int layoutSpacing;
- tolua_property__get_set IntRect& layoutBorder;
- tolua_readonly tolua_property__get_set unsigned numChildren;
- tolua_property__get_set UIElement* parent;
- tolua_readonly tolua_property__get_set UIElement* root;
- tolua_readonly tolua_property__get_set Color& derivedColor;
- tolua_readonly tolua_property__get_set IntRect combinedScreenRect;
- tolua_readonly tolua_property__get_set int layoutMinSize;
- tolua_property__get_set int indent;
- tolua_property__get_set int indentSpacing;
- tolua_readonly tolua_property__get_set int indentWidth;
- tolua_property__get_set Color& colorAttr;
- tolua_property__get_set TraversalMode traversalMode;
- tolua_property__is_set bool elementEventSender;
- };
- ${
- static UIElement* UIElementGetChild(const UIElement* element, const char* name, bool recursive = false)
- {
- return element->GetChild(String(name), recursive);
- }
- static UIElement* UIElementGetChild2(const UIElement* element, const char* key, const Variant& value = Variant::EMPTY, bool recursive = false)
- {
- return element->GetChild(ShortStringHash(key), value, recursive);
- }
- #define GetStyle GetAppliedStyle
- #define TOLUA_DISABLE_tolua_get_UIElement_color_ref
- #define tolua_get_UIElement_color_ref NULL
- $}
|