ElementTabSet.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * This source file is part of RmlUi, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://github.com/mikke89/RmlUi
  5. *
  6. * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
  7. * Copyright (c) 2019 The RmlUi Team, and contributors
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10. * of this software and associated documentation files (the "Software"), to deal
  11. * in the Software without restriction, including without limitation the rights
  12. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. * copies of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included in
  17. * all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. * THE SOFTWARE.
  26. *
  27. */
  28. #include "ElementTabSet.h"
  29. #include <RmlUi/Core/Element.h>
  30. #include <RmlUi/Lua/Utilities.h>
  31. namespace Rml {
  32. namespace Lua {
  33. //methods
  34. int ElementTabSetSetPanel(lua_State* L, ElementTabSet* obj)
  35. {
  36. RMLUI_CHECK_OBJ(obj);
  37. int index = GetIndex(L,1);
  38. const char* rml = luaL_checkstring(L,2);
  39. obj->SetPanel(index,rml);
  40. return 0;
  41. }
  42. int ElementTabSetSetTab(lua_State* L, ElementTabSet* obj)
  43. {
  44. RMLUI_CHECK_OBJ(obj);
  45. int index = GetIndex(L,1);
  46. const char* rml = luaL_checkstring(L,2);
  47. obj->SetTab(index,rml);
  48. return 0;
  49. }
  50. //getters
  51. int ElementTabSetGetAttractive_tab(lua_State* L)
  52. {
  53. ElementTabSet* obj = LuaType<ElementTabSet>::check(L,1);
  54. RMLUI_CHECK_OBJ(obj);
  55. int tab = obj->GetActiveTab();
  56. PushIndex(L,tab);
  57. return 1;
  58. }
  59. int ElementTabSetGetAttrnum_tabs(lua_State* L)
  60. {
  61. ElementTabSet* obj = LuaType<ElementTabSet>::check(L,1);
  62. RMLUI_CHECK_OBJ(obj);
  63. int num = obj->GetNumTabs();
  64. lua_pushinteger(L,num);
  65. return 1;
  66. }
  67. //setter
  68. int ElementTabSetSetAttractive_tab(lua_State* L)
  69. {
  70. ElementTabSet* obj = LuaType<ElementTabSet>::check(L,1);
  71. RMLUI_CHECK_OBJ(obj);
  72. int tab = GetIndex(L,2);
  73. obj->SetActiveTab(tab);
  74. return 0;
  75. }
  76. RegType<ElementTabSet> ElementTabSetMethods[] =
  77. {
  78. RMLUI_LUAMETHOD(ElementTabSet,SetPanel)
  79. RMLUI_LUAMETHOD(ElementTabSet,SetTab)
  80. { nullptr, nullptr },
  81. };
  82. luaL_Reg ElementTabSetGetters[] =
  83. {
  84. RMLUI_LUAGETTER(ElementTabSet,active_tab)
  85. RMLUI_LUAGETTER(ElementTabSet,num_tabs)
  86. { nullptr, nullptr },
  87. };
  88. luaL_Reg ElementTabSetSetters[] =
  89. {
  90. RMLUI_LUASETTER(ElementTabSet,active_tab)
  91. { nullptr, nullptr },
  92. };
  93. //this will be used to "inherit" from Element
  94. template<> void ExtraInit<ElementTabSet>(lua_State* L, int metatable_index)
  95. {
  96. ExtraInit<Element>(L,metatable_index);
  97. LuaType<Element>::_regfunctions(L,metatable_index,metatable_index-1);
  98. AddTypeToElementAsTable<ElementTabSet>(L);
  99. }
  100. RMLUI_LUATYPE_DEFINE(ElementTabSet)
  101. } // namespace Lua
  102. } // namespace Rml