ElementFormControl.cpp 3.8 KB

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