ElementFormControl.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #include "ElementFormControl.h"
  2. #include "../Element.h"
  3. #include <RmlUi/Core/Element.h>
  4. #include <RmlUi/Core/Elements/ElementFormControl.h>
  5. #include <RmlUi/Lua/Utilities.h>
  6. namespace Rml {
  7. namespace Lua {
  8. // getters
  9. int ElementFormControlGetAttrdisabled(lua_State* L)
  10. {
  11. ElementFormControl* efc = LuaType<ElementFormControl>::check(L, 1);
  12. RMLUI_CHECK_OBJ(efc);
  13. lua_pushboolean(L, efc->IsDisabled());
  14. return 1;
  15. }
  16. int ElementFormControlGetAttrname(lua_State* L)
  17. {
  18. ElementFormControl* efc = LuaType<ElementFormControl>::check(L, 1);
  19. RMLUI_CHECK_OBJ(efc);
  20. lua_pushstring(L, efc->GetName().c_str());
  21. return 1;
  22. }
  23. int ElementFormControlGetAttrvalue(lua_State* L)
  24. {
  25. ElementFormControl* efc = LuaType<ElementFormControl>::check(L, 1);
  26. RMLUI_CHECK_OBJ(efc);
  27. lua_pushstring(L, efc->GetValue().c_str());
  28. return 1;
  29. }
  30. // setters
  31. int ElementFormControlSetAttrdisabled(lua_State* L)
  32. {
  33. ElementFormControl* efc = LuaType<ElementFormControl>::check(L, 1);
  34. RMLUI_CHECK_OBJ(efc);
  35. efc->SetDisabled(RMLUI_CHECK_BOOL(L, 2));
  36. return 0;
  37. }
  38. int ElementFormControlSetAttrname(lua_State* L)
  39. {
  40. ElementFormControl* efc = LuaType<ElementFormControl>::check(L, 1);
  41. RMLUI_CHECK_OBJ(efc);
  42. const char* name = luaL_checkstring(L, 2);
  43. efc->SetName(name);
  44. return 0;
  45. }
  46. int ElementFormControlSetAttrvalue(lua_State* L)
  47. {
  48. ElementFormControl* efc = LuaType<ElementFormControl>::check(L, 1);
  49. RMLUI_CHECK_OBJ(efc);
  50. const char* value = luaL_checkstring(L, 2);
  51. efc->SetValue(value);
  52. return 0;
  53. }
  54. RegType<ElementFormControl> ElementFormControlMethods[] = {
  55. {nullptr, nullptr},
  56. };
  57. luaL_Reg ElementFormControlGetters[] = {
  58. RMLUI_LUAGETTER(ElementFormControl, disabled),
  59. RMLUI_LUAGETTER(ElementFormControl, name),
  60. RMLUI_LUAGETTER(ElementFormControl, value),
  61. {nullptr, nullptr},
  62. };
  63. luaL_Reg ElementFormControlSetters[] = {
  64. RMLUI_LUASETTER(ElementFormControl, disabled),
  65. RMLUI_LUASETTER(ElementFormControl, name),
  66. RMLUI_LUASETTER(ElementFormControl, value),
  67. {nullptr, nullptr},
  68. };
  69. template <>
  70. void ExtraInit<ElementFormControl>(lua_State* L, int metatable_index)
  71. {
  72. ExtraInit<Element>(L, metatable_index);
  73. LuaType<Element>::_regfunctions(L, metatable_index, metatable_index - 1);
  74. AddTypeToElementAsTable<ElementFormControl>(L);
  75. }
  76. RMLUI_LUATYPE_DEFINE(ElementFormControl)
  77. } // namespace Lua
  78. } // namespace Rml