ElementFormControl.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 "../Element.h"
  29. #include "ElementFormControl.h"
  30. #include <RmlUi/Core/Elements/ElementFormControl.h>
  31. #include <RmlUi/Core/Element.h>
  32. #include <RmlUi/Lua/Utilities.h>
  33. namespace Rml {
  34. namespace Lua {
  35. //getters
  36. int ElementFormControlGetAttrdisabled(lua_State* L)
  37. {
  38. ElementFormControl* efc = LuaType<ElementFormControl>::check(L,1);
  39. RMLUI_CHECK_OBJ(efc);
  40. lua_pushboolean(L,efc->IsDisabled());
  41. return 1;
  42. }
  43. int ElementFormControlGetAttrname(lua_State* L)
  44. {
  45. ElementFormControl* efc = LuaType<ElementFormControl>::check(L,1);
  46. RMLUI_CHECK_OBJ(efc);
  47. lua_pushstring(L,efc->GetName().c_str());
  48. return 1;
  49. }
  50. int ElementFormControlGetAttrvalue(lua_State* L)
  51. {
  52. ElementFormControl* efc = LuaType<ElementFormControl>::check(L,1);
  53. RMLUI_CHECK_OBJ(efc);
  54. lua_pushstring(L,efc->GetValue().c_str());
  55. return 1;
  56. }
  57. //setters
  58. int ElementFormControlSetAttrdisabled(lua_State* L)
  59. {
  60. ElementFormControl* efc = LuaType<ElementFormControl>::check(L,1);
  61. RMLUI_CHECK_OBJ(efc);
  62. efc->SetDisabled(RMLUI_CHECK_BOOL(L,2));
  63. return 0;
  64. }
  65. int ElementFormControlSetAttrname(lua_State* L)
  66. {
  67. ElementFormControl* efc = LuaType<ElementFormControl>::check(L,1);
  68. RMLUI_CHECK_OBJ(efc);
  69. const char* name = luaL_checkstring(L,2);
  70. efc->SetName(name);
  71. return 0;
  72. }
  73. int ElementFormControlSetAttrvalue(lua_State* L)
  74. {
  75. ElementFormControl* efc = LuaType<ElementFormControl>::check(L,1);
  76. RMLUI_CHECK_OBJ(efc);
  77. const char* value = luaL_checkstring(L,2);
  78. efc->SetValue(value);
  79. return 0;
  80. }
  81. RegType<ElementFormControl> ElementFormControlMethods[] =
  82. {
  83. { nullptr, nullptr },
  84. };
  85. luaL_Reg ElementFormControlGetters[] =
  86. {
  87. RMLUI_LUAGETTER(ElementFormControl,disabled)
  88. RMLUI_LUAGETTER(ElementFormControl,name)
  89. RMLUI_LUAGETTER(ElementFormControl,value)
  90. { nullptr, nullptr },
  91. };
  92. luaL_Reg ElementFormControlSetters[] =
  93. {
  94. RMLUI_LUASETTER(ElementFormControl,disabled)
  95. RMLUI_LUASETTER(ElementFormControl,name)
  96. RMLUI_LUASETTER(ElementFormControl,value)
  97. { nullptr, nullptr },
  98. };
  99. template<> void ExtraInit<ElementFormControl>(lua_State* L, int metatable_index)
  100. {
  101. ExtraInit<Element>(L,metatable_index);
  102. LuaType<Element>::_regfunctions(L,metatable_index,metatable_index-1);
  103. AddTypeToElementAsTable<ElementFormControl>(L);
  104. }
  105. RMLUI_LUATYPE_DEFINE(ElementFormControl)
  106. } // namespace Lua
  107. } // namespace Rml