ElementTabSet.cpp 3.4 KB

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