| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- $#include "File.h"
- $#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 Animatable
- {
- UIElement();
- virtual ~UIElement();
- virtual const IntVector2& GetScreenPosition() const;
- bool LoadXML(Deserializer& source);
- bool SaveXML(Serializer& dest) const;
- tolua_outside bool UIElementLoadXML @ LoadXML(const String fileName);
- tolua_outside bool UIElementSaveXML @ SaveXML(const String fileName) const;
- bool FilterAttributes(XMLElement& dest) const;
- void SetName(const String 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 SetDeepEnabled(bool enable);
- void ResetDeepEnabled();
- void SetEnabledRecursive(bool enable);
- void SetEditable(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 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 SetLayoutFlexScale(const Vector2& scale);
- void SetIndent(int indent);
- void SetIndentSpacing(int indentSpacing);
- void UpdateLayout();
- void DisableLayoutUpdate();
- void EnableLayoutUpdate();
- void BringToFront();
- UIElement* CreateChild(const String type, const String name = String::EMPTY, unsigned index = M_MAX_UNSIGNED);
- void AddChild(UIElement* element);
- void InsertChild(unsigned index, UIElement* element);
- void RemoveChild(UIElement* element, unsigned index = 0);
- void RemoveChildAtIndex(unsigned index);
- void RemoveAllChildren();
- void Remove();
- unsigned FindChild(UIElement* element) const;
- void SetParent(UIElement* parent, unsigned index = M_MAX_UNSIGNED);
- void SetVar(StringHash key, const Variant& value);
- void SetInternal(bool enable);
- void SetTraversalMode(TraversalMode traversalMode);
- void SetElementEventSender(bool flag);
- 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 IsEnabledSelf() const;
- bool IsEditable() 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;
- const Vector2& GetLayoutFlexScale() const;
- unsigned GetNumChildren(bool recursive = false) const;
- int GetDragButtonCombo() const;
- unsigned GetDragButtonCount() const;
- UIElement* GetChild(const String name, bool recursive = false) const;
- UIElement* GetChild(unsigned index) const;
- UIElement* GetParent() const;
- UIElement* GetRoot() const;
- const Color& GetDerivedColor() const;
- const Variant& GetVar(StringHash key) const;
- const VariantMap& GetVars() 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 GetIndent() const;
- int GetIndentSpacing() const;
- int GetIndentWidth() const;
- void SetChildOffset(const IntVector2& offset);
- void SetHovering(bool enable);
- const Color& GetColorAttr @ GetColor() 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& colorAttr @ color;
- 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_readonly tolua_property__is_set bool enabledSelf;
- tolua_property__is_set bool editable;
- 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_property__get_set Vector2& layoutFlexScale;
- 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_property__get_set int indent;
- tolua_property__get_set int indentSpacing;
- tolua_readonly tolua_property__get_set int indentWidth;
- tolua_property__get_set TraversalMode traversalMode;
- tolua_property__is_set bool elementEventSender;
- };
- ${
- #define TOLUA_DISABLE_tolua_UILuaAPI_UIElement_new00
- static int tolua_UILuaAPI_UIElement_new00(lua_State* tolua_S)
- {
- return ToluaNewObject<UIElement>(tolua_S);
- }
- #define TOLUA_DISABLE_tolua_UILuaAPI_UIElement_new00_local
- static int tolua_UILuaAPI_UIElement_new00_local(lua_State* tolua_S)
- {
- return ToluaNewObjectGC<UIElement>(tolua_S);
- }
- static bool UIElementLoadXML(UIElement* element, const String& fileName)
- {
- if (!element)
- return false;
- File file(element->GetContext());
- if (!file.Open(fileName, FILE_READ))
- return false;
- return element->LoadXML(file);
- }
- static bool UIElementSaveXML(const UIElement* element, const String& fileName)
- {
- if (!element)
- return false;
- File file(element->GetContext());
- if (!file.Open(fileName, FILE_WRITE))
- return false;
- return element->SaveXML(file);
- }
- #define GetStyle GetAppliedStyle
- #define SetColorAttr SetColor
- $}
|