ElementDataGridRow.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 "precompiled.h"
  29. #include "ElementDataGridRow.h"
  30. #include <RmlUi/Controls/ElementDataGrid.h>
  31. #include <RmlUi/Core/Lua/Utilities.h>
  32. namespace Rml {
  33. namespace Controls {
  34. namespace Lua {
  35. //getters
  36. int ElementDataGridRowGetAttrrow_expanded(lua_State* L)
  37. {
  38. ElementDataGridRow* obj = LuaType<ElementDataGridRow>::check(L,1);
  39. LUACHECKOBJ(obj);
  40. lua_pushboolean(L,obj->IsRowExpanded());
  41. return 1;
  42. }
  43. int ElementDataGridRowGetAttrparent_relative_index(lua_State* L)
  44. {
  45. ElementDataGridRow* obj = LuaType<ElementDataGridRow>::check(L,1);
  46. LUACHECKOBJ(obj);
  47. lua_pushinteger(L,obj->GetParentRelativeIndex());
  48. return 1;
  49. }
  50. int ElementDataGridRowGetAttrtable_relative_index(lua_State* L)
  51. {
  52. ElementDataGridRow* obj = LuaType<ElementDataGridRow>::check(L,1);
  53. LUACHECKOBJ(obj);
  54. lua_pushinteger(L,obj->GetTableRelativeIndex());
  55. return 1;
  56. }
  57. int ElementDataGridRowGetAttrparent_row(lua_State* L)
  58. {
  59. ElementDataGridRow* obj = LuaType<ElementDataGridRow>::check(L,1);
  60. LUACHECKOBJ(obj);
  61. LuaType<ElementDataGridRow>::push(L,obj->GetParentRow(),false);
  62. return 1;
  63. }
  64. int ElementDataGridRowGetAttrparent_grid(lua_State* L)
  65. {
  66. ElementDataGridRow* obj = LuaType<ElementDataGridRow>::check(L,1);
  67. LUACHECKOBJ(obj);
  68. LuaType<ElementDataGrid>::push(L,obj->GetParentGrid(),false);
  69. return 1;
  70. }
  71. //setter
  72. int ElementDataGridRowSetAttrrow_expanded(lua_State* L)
  73. {
  74. ElementDataGridRow* obj = LuaType<ElementDataGridRow>::check(L,1);
  75. LUACHECKOBJ(obj);
  76. bool expanded = CHECK_BOOL(L,2);
  77. if(expanded)
  78. obj->ExpandRow();
  79. else
  80. obj->CollapseRow();
  81. return 0;
  82. }
  83. Rml::Core::Lua::RegType<ElementDataGridRow> ElementDataGridRowMethods[] =
  84. {
  85. { nullptr, nullptr },
  86. };
  87. luaL_Reg ElementDataGridRowGetters[] =
  88. {
  89. LUAGETTER(ElementDataGridRow,row_expanded)
  90. LUAGETTER(ElementDataGridRow,parent_relative_index)
  91. LUAGETTER(ElementDataGridRow,table_relative_index)
  92. LUAGETTER(ElementDataGridRow,parent_row)
  93. LUAGETTER(ElementDataGridRow,parent_grid)
  94. { nullptr, nullptr },
  95. };
  96. luaL_Reg ElementDataGridRowSetters[] =
  97. {
  98. LUASETTER(ElementDataGridRow,row_expanded)
  99. { nullptr, nullptr },
  100. };
  101. }
  102. }
  103. }
  104. namespace Rml {
  105. namespace Core {
  106. namespace Lua {
  107. template<> void ExtraInit<Rml::Controls::ElementDataGridRow>(lua_State* L, int metatable_index)
  108. {
  109. ExtraInit<Element>(L,metatable_index);
  110. LuaType<Element>::_regfunctions(L,metatable_index,metatable_index-1);
  111. AddTypeToElementAsTable<Rml::Controls::ElementDataGridRow>(L);
  112. }
  113. using Rml::Controls::ElementDataGridRow;
  114. LUACONTROLSTYPEDEFINE(ElementDataGridRow)
  115. }
  116. }
  117. }