UI.pkg 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. $#include "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 Update(float timeStep);
  9. void RenderUpdate();
  10. void Render();
  11. void DebugDraw(UIElement* element);
  12. tolua_outside UIElement* UILoadLayout @ LoadLayout(File* source, XMLFile* styleFile = 0);
  13. tolua_outside UIElement* UILoadLayout @ LoadLayout(const String fileName, XMLFile* styleFile = 0);
  14. tolua_outside UIElement* UILoadLayout @ LoadLayout(XMLFile* file, XMLFile* styleFile = 0);
  15. bool SaveLayout(Serializer& dest, UIElement* element);
  16. void SetClipboardText(const String text);
  17. void SetDoubleClickInterval(float interval);
  18. void SetDragBeginInterval(float interval);
  19. void SetDragBeginDistance(int pixels);
  20. void SetDefaultToolTipDelay(float delay);
  21. void SetMaxFontTextureSize(int size);
  22. void SetNonFocusedMouseWheel(bool nonFocusedMouseWheel);
  23. void SetUseSystemClipboard(bool enable);
  24. void SetUseScreenKeyboard(bool enable);
  25. void SetUseMutableGlyphs(bool enable);
  26. void SetForceAutoHint(bool enable);
  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. tolua_readonly tolua_property__get_set UIElement* root;
  50. tolua_readonly tolua_property__get_set UIElement* rootModalElement;
  51. tolua_property__get_set Cursor* cursor;
  52. tolua_readonly tolua_property__get_set IntVector2 cursorPosition;
  53. tolua_readonly tolua_property__get_set UIElement* focusElement;
  54. tolua_readonly tolua_property__get_set UIElement* frontElement;
  55. tolua_property__get_set String clipboardText;
  56. tolua_property__get_set float doubleClickInterval;
  57. tolua_property__get_set float dragBeginInterval;
  58. tolua_property__get_set int dragBeginDistance;
  59. tolua_property__get_set float defaultToolTipDelay;
  60. tolua_property__get_set int maxFontTextureSize;
  61. tolua_property__is_set bool nonFocusedMouseWheel;
  62. tolua_property__get_set bool useSystemClipboard;
  63. tolua_property__get_set bool useScreenKeyboard;
  64. tolua_property__get_set bool useMutableGlyphs;
  65. tolua_property__get_set bool forceAutoHint;
  66. tolua_readonly tolua_property__has_set bool modalElement;
  67. };
  68. UI* GetUI();
  69. tolua_readonly tolua_property__get_set UI* ui;
  70. ${
  71. static UIElement* UILoadLayout(UI* ui, File* source, XMLFile* styleFile)
  72. {
  73. if (!source)
  74. return 0;
  75. SharedPtr<UIElement> elementPtr = ui->LoadLayout(*source, styleFile);
  76. if (!elementPtr)
  77. return 0;
  78. UIElement* element = elementPtr.Get();
  79. elementPtr.Detach();
  80. return element;
  81. }
  82. static UIElement* UILoadLayout(UI* ui, const String& fileName, XMLFile* styleFile)
  83. {
  84. File file(ui->GetContext(), fileName, FILE_READ);
  85. if (!file.IsOpen())
  86. return 0;
  87. SharedPtr<UIElement> elementPtr = ui->LoadLayout(file, styleFile);
  88. if (!elementPtr)
  89. return 0;
  90. UIElement* element = elementPtr.Get();
  91. elementPtr.Detach();
  92. return element;
  93. }
  94. static UIElement* UILoadLayout(UI* ui, XMLFile* source, XMLFile* styleFile)
  95. {
  96. if (!source)
  97. return 0;
  98. SharedPtr<UIElement> elementPtr = ui->LoadLayout(source, styleFile);
  99. if (!elementPtr)
  100. return 0;
  101. UIElement* element = elementPtr.Get();
  102. elementPtr.Detach();
  103. return element;
  104. }
  105. #define TOLUA_DISABLE_tolua_UILuaAPI_GetUI00
  106. static int tolua_UILuaAPI_GetUI00(lua_State* tolua_S)
  107. {
  108. return ToluaGetSubsystem<UI>(tolua_S);
  109. }
  110. #define TOLUA_DISABLE_tolua_get_ui_ptr
  111. #define tolua_get_ui_ptr tolua_UILuaAPI_GetUI00
  112. $}