UI.pkg 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. $#include "UI/UI.h"
  2. class UI : public Object
  3. {
  4. void SetCursor(Cursor* cursor);
  5. void SetFocusElement(UIElement* element, bool byKey = false);
  6. bool SetModalElement(UIElement* modalElement, bool enable);
  7. void Clear();
  8. void DebugDraw(UIElement* element);
  9. tolua_outside UIElement* UILoadLayout @ LoadLayout(File* source, XMLFile* styleFile = 0);
  10. tolua_outside UIElement* UILoadLayout @ LoadLayout(const String fileName, XMLFile* styleFile = 0);
  11. tolua_outside UIElement* UILoadLayout @ LoadLayout(XMLFile* file, XMLFile* styleFile = 0);
  12. bool SaveLayout(Serializer& dest, UIElement* element);
  13. void SetClipboardText(const String text);
  14. void SetDoubleClickInterval(float interval);
  15. void SetDragBeginInterval(float interval);
  16. void SetDragBeginDistance(int pixels);
  17. void SetDefaultToolTipDelay(float delay);
  18. void SetMaxFontTextureSize(int size);
  19. void SetNonFocusedMouseWheel(bool nonFocusedMouseWheel);
  20. void SetUseSystemClipboard(bool enable);
  21. void SetUseScreenKeyboard(bool enable);
  22. void SetUseMutableGlyphs(bool enable);
  23. void SetForceAutoHint(bool enable);
  24. void SetScale(float scale);
  25. void SetWidth(float size);
  26. void SetHeight(float size);
  27. UIElement* GetRoot() const;
  28. UIElement* GetRootModalElement() const;
  29. Cursor* GetCursor() const;
  30. IntVector2 GetCursorPosition() const;
  31. UIElement* GetElementAt(const IntVector2& position, bool enabledOnly = true);
  32. UIElement* GetElementAt(int x, int y, bool enabledOnly = true);
  33. UIElement* GetFocusElement() const;
  34. UIElement* GetFrontElement() const;
  35. UIElement* GetDragElement(unsigned index);
  36. const String GetClipboardText() const;
  37. float GetDoubleClickInterval() const;
  38. float GetDragBeginInterval() const;
  39. int GetDragBeginDistance() const;
  40. float GetDefaultToolTipDelay() const;
  41. int GetMaxFontTextureSize() const;
  42. bool IsNonFocusedMouseWheel() const;
  43. bool GetUseSystemClipboard() const;
  44. bool GetUseScreenKeyboard() const;
  45. bool GetUseMutableGlyphs() const;
  46. bool GetForceAutoHint() const;
  47. bool HasModalElement() const;
  48. bool IsDragging() const;
  49. float GetScale() const;
  50. tolua_readonly tolua_property__get_set UIElement* root;
  51. tolua_readonly tolua_property__get_set UIElement* rootModalElement;
  52. tolua_property__get_set Cursor* cursor;
  53. tolua_readonly tolua_property__get_set IntVector2 cursorPosition;
  54. tolua_readonly tolua_property__get_set UIElement* focusElement;
  55. tolua_readonly tolua_property__get_set UIElement* frontElement;
  56. tolua_property__get_set String clipboardText;
  57. tolua_property__get_set float doubleClickInterval;
  58. tolua_property__get_set float dragBeginInterval;
  59. tolua_property__get_set int dragBeginDistance;
  60. tolua_property__get_set float defaultToolTipDelay;
  61. tolua_property__get_set int maxFontTextureSize;
  62. tolua_property__is_set bool nonFocusedMouseWheel;
  63. tolua_property__get_set bool useSystemClipboard;
  64. tolua_property__get_set bool useScreenKeyboard;
  65. tolua_property__get_set bool useMutableGlyphs;
  66. tolua_property__get_set bool forceAutoHint;
  67. tolua_readonly tolua_property__has_set bool modalElement;
  68. tolua_property__get_set float scale;
  69. };
  70. UI* GetUI();
  71. tolua_readonly tolua_property__get_set UI* ui;
  72. ${
  73. static UIElement* UILoadLayout(UI* ui, File* source, XMLFile* styleFile)
  74. {
  75. if (!source)
  76. return 0;
  77. SharedPtr<UIElement> elementPtr = ui->LoadLayout(*source, styleFile);
  78. if (!elementPtr)
  79. return 0;
  80. UIElement* element = elementPtr.Get();
  81. elementPtr.Detach();
  82. return element;
  83. }
  84. static UIElement* UILoadLayout(UI* ui, const String& fileName, XMLFile* styleFile)
  85. {
  86. File file(ui->GetContext(), fileName, FILE_READ);
  87. if (!file.IsOpen())
  88. return 0;
  89. SharedPtr<UIElement> elementPtr = ui->LoadLayout(file, styleFile);
  90. if (!elementPtr)
  91. return 0;
  92. UIElement* element = elementPtr.Get();
  93. elementPtr.Detach();
  94. return element;
  95. }
  96. static UIElement* UILoadLayout(UI* ui, XMLFile* source, XMLFile* styleFile)
  97. {
  98. if (!source)
  99. return 0;
  100. SharedPtr<UIElement> elementPtr = ui->LoadLayout(source, styleFile);
  101. if (!elementPtr)
  102. return 0;
  103. UIElement* element = elementPtr.Get();
  104. elementPtr.Detach();
  105. return element;
  106. }
  107. #define TOLUA_DISABLE_tolua_UILuaAPI_GetUI00
  108. static int tolua_UILuaAPI_GetUI00(lua_State* tolua_S)
  109. {
  110. return ToluaGetSubsystem<UI>(tolua_S);
  111. }
  112. #define TOLUA_DISABLE_tolua_get_ui_ptr
  113. #define tolua_get_ui_ptr tolua_UILuaAPI_GetUI00
  114. $}