UI.pkg 5.0 KB

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