UIElement.pkg 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. $#include "UIElement.h"
  2. enum HorizontalAlignment
  3. {
  4. HA_LEFT = 0,
  5. HA_CENTER,
  6. HA_RIGHT
  7. };
  8. enum VerticalAlignment
  9. {
  10. VA_TOP = 0,
  11. VA_CENTER,
  12. VA_BOTTOM
  13. };
  14. enum Corner
  15. {
  16. C_TOPLEFT = 0,
  17. C_TOPRIGHT,
  18. C_BOTTOMLEFT,
  19. C_BOTTOMRIGHT,
  20. MAX_UIELEMENT_CORNERS
  21. };
  22. enum Orientation
  23. {
  24. O_HORIZONTAL = 0,
  25. O_VERTICAL
  26. };
  27. enum FocusMode
  28. {
  29. FM_NOTFOCUSABLE = 0,
  30. FM_RESETFOCUS,
  31. FM_FOCUSABLE,
  32. FM_FOCUSABLE_DEFOCUSABLE
  33. };
  34. enum LayoutMode
  35. {
  36. LM_FREE = 0,
  37. LM_HORIZONTAL,
  38. LM_VERTICAL
  39. };
  40. enum TraversalMode
  41. {
  42. TM_BREADTH_FIRST = 0,
  43. TM_DEPTH_FIRST
  44. };
  45. static const unsigned DD_DISABLED;
  46. static const unsigned DD_SOURCE;
  47. static const unsigned DD_TARGET;
  48. static const unsigned DD_SOURCE_AND_TARGET;
  49. class UIElement : public Serializable
  50. {
  51. public:
  52. // Methods:
  53. UIElement(Context* context);
  54. virtual ~UIElement();
  55. virtual const IntVector2& GetScreenPosition() const;
  56. void SetName(const String& name);
  57. void SetPosition(const IntVector2& position);
  58. void SetPosition(int x, int y);
  59. void SetSize(const IntVector2& size);
  60. void SetSize(int width, int height);
  61. void SetWidth(int width);
  62. void SetHeight(int height);
  63. void SetMinSize(const IntVector2& minSize);
  64. void SetMinSize(int width, int height);
  65. void SetMinWidth(int width);
  66. void SetMinHeight(int height);
  67. void SetMaxSize(const IntVector2& maxSize);
  68. void SetMaxSize(int width, int height);
  69. void SetMaxWidth(int width);
  70. void SetMaxHeight(int height);
  71. void SetFixedSize(const IntVector2& size);
  72. void SetFixedSize(int width, int height);
  73. void SetFixedWidth(int width);
  74. void SetFixedHeight(int height);
  75. void SetAlignment(HorizontalAlignment hAlign, VerticalAlignment vAlign);
  76. void SetHorizontalAlignment(HorizontalAlignment align);
  77. void SetVerticalAlignment(VerticalAlignment align);
  78. void SetClipBorder(const IntRect& rect);
  79. void SetColor(const Color& color);
  80. void SetColor(Corner corner, const Color& color);
  81. void SetPriority(int priority);
  82. void SetOpacity(float opacity);
  83. void SetBringToFront(bool enable);
  84. void SetBringToBack(bool enable);
  85. void SetClipChildren(bool enable);
  86. void SetSortChildren(bool enable);
  87. void SetUseDerivedOpacity(bool enable);
  88. void SetEnabled(bool enable);
  89. void SetFocus(bool enable);
  90. void SetSelected(bool enable);
  91. void SetVisible(bool enable);
  92. void SetFocusMode(FocusMode mode);
  93. void SetDragDropMode(unsigned mode);
  94. bool SetStyle(const String& styleName, XMLFile* file = 0);
  95. bool SetStyle(const String& styleName);
  96. bool SetStyle(const XMLElement& element);
  97. bool SetStyleAuto(XMLFile* file = 0);
  98. bool SetStyleAuto();
  99. void SetDefaultStyle(XMLFile* style);
  100. void SetLayout(LayoutMode mode, int spacing = 0, const IntRect& border = IntRect::ZERO);
  101. void SetLayout(LayoutMode mode, int spacing = 0);
  102. void SetLayout(LayoutMode mode);
  103. void SetLayoutMode(LayoutMode mode);
  104. void SetLayoutSpacing(int spacing);
  105. void SetLayoutBorder(const IntRect& border);
  106. void SetIndent(int indent);
  107. void SetIndentSpacing(int indentSpacing);
  108. void UpdateLayout();
  109. void DisableLayoutUpdate();
  110. void EnableLayoutUpdate();
  111. void BringToFront();
  112. UIElement* CreateChild(ShortStringHash type, const String& name = String::EMPTY, unsigned index = M_MAX_UNSIGNED);
  113. UIElement* CreateChild(ShortStringHash type, const String& name = String::EMPTY);
  114. UIElement* CreateChild(ShortStringHash type);
  115. void AddChild(UIElement* element);
  116. void InsertChild(unsigned index, UIElement* element);
  117. void RemoveChild(UIElement* element, unsigned index = 0);
  118. void RemoveChild(UIElement* element);
  119. void RemoveChildAtIndex @ RemoveChild(unsigned index);
  120. void RemoveAllChildren();
  121. void Remove();
  122. unsigned FindChild(UIElement* element) const;
  123. void SetParent(UIElement* parent, unsigned index = M_MAX_UNSIGNED);
  124. void SetParent(UIElement* parent);
  125. void SetInternal(bool enable);
  126. void SetTraversalMode(TraversalMode traversalMode);
  127. void SetElementEventSender(bool flag);
  128. const String& GetName() const;
  129. const IntVector2& GetPosition() const;
  130. const IntVector2& GetSize() const;
  131. int GetWidth() const;
  132. int GetHeight() const;
  133. const IntVector2& GetMinSize() const;
  134. int GetMinWidth() const;
  135. int GetMinHeight() const;
  136. const IntVector2& GetMaxSize() const;
  137. int GetMaxWidth() const;
  138. int GetMaxHeight() const;
  139. bool IsFixedSize() const;
  140. bool IsFixedWidth() const;
  141. bool IsFixedHeight() const;
  142. const IntVector2& GetChildOffset() const;
  143. HorizontalAlignment GetHorizontalAlignment() const;
  144. VerticalAlignment GetVerticalAlignment() const;
  145. const IntRect& GetClipBorder() const;
  146. const Color& GetColor(Corner corner) const;
  147. int GetPriority() const;
  148. float GetOpacity() const;
  149. float GetDerivedOpacity() const;
  150. bool GetBringToFront() const;
  151. bool GetBringToBack() const;
  152. bool GetClipChildren() const;
  153. bool GetSortChildren() const;
  154. bool GetUseDerivedOpacity() const;
  155. bool HasFocus() const;
  156. bool IsEnabled() const;
  157. bool IsSelected() const;
  158. bool IsVisible() const;
  159. bool IsHovering() const;
  160. bool IsInternal() const;
  161. bool HasColorGradient() const;
  162. FocusMode GetFocusMode() const;
  163. unsigned GetDragDropMode() const;
  164. const String& GetAppliedStyle() const;
  165. XMLFile* GetDefaultStyle(bool recursiveUp = true) const;
  166. XMLFile* GetDefaultStyle() const;
  167. LayoutMode GetLayoutMode() const;
  168. int GetLayoutSpacing() const;
  169. const IntRect& GetLayoutBorder() const;
  170. unsigned GetNumChildren(bool recursive = false) const;
  171. unsigned GetNumChildren() const;
  172. UIElement* GetChild(unsigned index) const;
  173. UIElement* GetChild(const String& name, bool recursive = false) const;
  174. UIElement* GetChild(const String& name) const;
  175. tolua_outside UIElement* UIElementGetChild @ GetChild(const char* name, bool recursive = false) const;
  176. tolua_outside UIElement* UIElementGetChild @ GetChild(const char* name) const;
  177. UIElement* GetChild(const ShortStringHash& key, const Variant& value = Variant::EMPTY, bool recursive = false) const;
  178. UIElement* GetChild(const ShortStringHash& key, const Variant& value = Variant::EMPTY) const;
  179. UIElement* GetChild(const ShortStringHash& key) const;
  180. UIElement* GetParent() const;
  181. UIElement* GetRoot() const;
  182. const Color& GetDerivedColor() const;
  183. IntVector2 ScreenToElement(const IntVector2& screenPosition);
  184. IntVector2 ElementToScreen(const IntVector2& position);
  185. bool IsInside(IntVector2 position, bool isScreen);
  186. bool IsInsideCombined(IntVector2 position, bool isScreen);
  187. IntRect GetCombinedScreenRect();
  188. void SortChildren();
  189. int GetLayoutMinSize() const;
  190. int GetIndent() const;
  191. int GetIndentSpacing() const;
  192. int GetIndentWidth() const;
  193. void SetChildOffset(const IntVector2& offset);
  194. void SetHovering(bool enable);
  195. TraversalMode GetTraversalMode() const;
  196. bool IsElementEventSender() const;
  197. UIElement* GetElementEventSender() const;
  198. // Properties:
  199. tolua_property__get_set const String& style;
  200. tolua_property__get_set const String& name;
  201. tolua_property__get_set const IntVector2& position;
  202. tolua_property__get_set const IntVector2 size;
  203. tolua_property__get_set int width;
  204. tolua_property__get_set const int height;
  205. tolua_property__get_set const IntVector2 minSize;
  206. tolua_property__get_set const int minWidth;
  207. tolua_property__get_set const int minHeight;
  208. tolua_property__get_set IntVector2 maxSize;
  209. tolua_property__get_set int maxWidth;
  210. tolua_property__get_set int maxHeight;
  211. tolua_readonly tolua_property__is_set bool fixedSize;
  212. tolua_readonly tolua_property__is_set bool fixedWidth;
  213. tolua_readonly tolua_property__is_set bool fixedHeight;
  214. tolua_property__get_set HorizontalAlignment horizontalAlignment;
  215. tolua_property__get_set VerticalAlignment verticalAlignment;
  216. tolua_property__get_set IntRect clipBorder;
  217. tolua_property__get_set int priority;
  218. tolua_property__get_set float opacity;
  219. tolua_property__get_set bool bringToFront;
  220. tolua_property__get_set bool bringToBack;
  221. tolua_property__get_set bool clipChildren;
  222. tolua_property__get_set bool sortChildren;
  223. tolua_property__get_set bool useDerivedOpacity;
  224. tolua_property__is_set bool enabled;
  225. tolua_property__has_set bool focus;
  226. tolua_property__is_set bool selected;
  227. tolua_property__is_set bool visible;
  228. tolua_property__is_set bool hovering;
  229. tolua_property__is_set bool internal;
  230. tolua_readonly tolua_property__has_set bool colorGradient;
  231. tolua_property__get_set FocusMode focusMode;
  232. tolua_property__get_set unsigned dragDropMode;
  233. tolua_property__get_set TraversalMode traversalMode;
  234. tolua_property__get_set XMLFile* defaultStyle;
  235. tolua_property__get_set LayoutMode layoutMode;
  236. tolua_property__get_set int layoutSpacing;
  237. tolua_property__get_set const IntRect& layoutBorder;
  238. tolua_property__get_set int indent;
  239. tolua_property__get_set int indentSpacing;
  240. tolua_readonly tolua_property__get_set int indentWidth;
  241. tolua_property__get_set const IntVector2& childOffset;
  242. tolua_property__is_set bool elementEventSender;
  243. tolua_readonly tolua_property__get_set unsigned numChildren;
  244. tolua_property__get_set UIElement* parent;
  245. tolua_readonly tolua_property__get_set UIElement* root;
  246. tolua_readonly tolua_property__get_set const IntVector2& screenPosition;
  247. tolua_readonly tolua_property__get_set const IntRect& combinedScreenRect;
  248. tolua_readonly tolua_property__get_set float derivedOpacity;
  249. };
  250. ${
  251. UIElement* UIElementGetChild(const UIElement* uiElement, const char* name, bool recursive = false)
  252. {
  253. return uiElement->GetChild(String(name), recursive);
  254. }
  255. #define GetStyle GetAppliedStyle
  256. // Fixed combinedScreenRect property.
  257. #define TOLUA_DISABLE_tolua_get_UIElement_combinedScreenRect_ref
  258. #define tolua_get_UIElement_combinedScreenRect_ref tolua_UILuaAPI_UIElement_GetCombinedScreenRect00
  259. $}