UI.pkg 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. UIElement* GetRoot() const;
  25. UIElement* GetRootModalElement() const;
  26. Cursor* GetCursor() const;
  27. IntVector2 GetCursorPosition() const;
  28. UIElement* GetElementAt(const IntVector2& position, bool enabledOnly = true);
  29. UIElement* GetElementAt(int x, int y, bool enabledOnly = true);
  30. UIElement* GetFocusElement() const;
  31. UIElement* GetFrontElement() const;
  32. UIElement* GetDragElement(unsigned index);
  33. const String GetClipboardText() const;
  34. float GetDoubleClickInterval() const;
  35. float GetDragBeginInterval() const;
  36. int GetDragBeginDistance() const;
  37. float GetDefaultToolTipDelay() const;
  38. int GetMaxFontTextureSize() const;
  39. bool IsNonFocusedMouseWheel() const;
  40. bool GetUseSystemClipboard() const;
  41. bool GetUseScreenKeyboard() const;
  42. bool GetUseMutableGlyphs() const;
  43. bool GetForceAutoHint() const;
  44. bool HasModalElement() const;
  45. bool IsDragging() const;
  46. tolua_readonly tolua_property__get_set UIElement* root;
  47. tolua_readonly tolua_property__get_set UIElement* rootModalElement;
  48. tolua_property__get_set Cursor* cursor;
  49. tolua_readonly tolua_property__get_set IntVector2 cursorPosition;
  50. tolua_readonly tolua_property__get_set UIElement* focusElement;
  51. tolua_readonly tolua_property__get_set UIElement* frontElement;
  52. tolua_property__get_set String clipboardText;
  53. tolua_property__get_set float doubleClickInterval;
  54. tolua_property__get_set float dragBeginInterval;
  55. tolua_property__get_set int dragBeginDistance;
  56. tolua_property__get_set float defaultToolTipDelay;
  57. tolua_property__get_set int maxFontTextureSize;
  58. tolua_property__is_set bool nonFocusedMouseWheel;
  59. tolua_property__get_set bool useSystemClipboard;
  60. tolua_property__get_set bool useScreenKeyboard;
  61. tolua_property__get_set bool useMutableGlyphs;
  62. tolua_property__get_set bool forceAutoHint;
  63. tolua_readonly tolua_property__has_set bool modalElement;
  64. };
  65. UI* GetUI();
  66. tolua_readonly tolua_property__get_set UI* ui;
  67. ${
  68. static UIElement* UILoadLayout(UI* ui, File* source, XMLFile* styleFile)
  69. {
  70. if (!source)
  71. return 0;
  72. SharedPtr<UIElement> elementPtr = ui->LoadLayout(*source, styleFile);
  73. if (!elementPtr)
  74. return 0;
  75. UIElement* element = elementPtr.Get();
  76. elementPtr.Detach();
  77. return element;
  78. }
  79. static UIElement* UILoadLayout(UI* ui, const String& fileName, XMLFile* styleFile)
  80. {
  81. File file(ui->GetContext(), fileName, FILE_READ);
  82. if (!file.IsOpen())
  83. return 0;
  84. SharedPtr<UIElement> elementPtr = ui->LoadLayout(file, styleFile);
  85. if (!elementPtr)
  86. return 0;
  87. UIElement* element = elementPtr.Get();
  88. elementPtr.Detach();
  89. return element;
  90. }
  91. static UIElement* UILoadLayout(UI* ui, XMLFile* source, XMLFile* styleFile)
  92. {
  93. if (!source)
  94. return 0;
  95. SharedPtr<UIElement> elementPtr = ui->LoadLayout(source, styleFile);
  96. if (!elementPtr)
  97. return 0;
  98. UIElement* element = elementPtr.Get();
  99. elementPtr.Detach();
  100. return element;
  101. }
  102. #define TOLUA_DISABLE_tolua_UILuaAPI_GetUI00
  103. static int tolua_UILuaAPI_GetUI00(lua_State* tolua_S)
  104. {
  105. return ToluaGetSubsystem<UI>(tolua_S);
  106. }
  107. #define TOLUA_DISABLE_tolua_get_ui_ptr
  108. #define tolua_get_ui_ptr tolua_UILuaAPI_GetUI00
  109. $}