ElementFormControlInput.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. #include "precompiled.h"
  2. #include "ElementFormControlInput.h"
  3. #include <Rocket/Controls/ElementFormControl.h>
  4. using Rocket::Controls::ElementFormControl;
  5. namespace Rocket {
  6. namespace Core {
  7. namespace Lua {
  8. //inherits from ElementFormControl which inherits from Element
  9. template<> void LuaType<ElementFormControlInput>::extra_init(lua_State* L, int metatable_index)
  10. {
  11. LuaType<ElementFormControl>::extra_init(L,metatable_index);
  12. LuaType<ElementFormControl>::_regfunctions(L,metatable_index,metatable_index-1);
  13. }
  14. //getters
  15. int ElementFormControlInputGetAttrchecked(lua_State* L)
  16. {
  17. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  18. LUACHECKOBJ(obj);
  19. lua_pushboolean(L,obj->HasAttribute("checked"));
  20. return 1;
  21. }
  22. int ElementFormControlInputGetAttrmaxlength(lua_State* L)
  23. {
  24. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  25. LUACHECKOBJ(obj);
  26. lua_pushinteger(L,obj->GetAttribute<int>("maxlength",-1));
  27. return 1;
  28. }
  29. int ElementFormControlInputGetAttrsize(lua_State* L)
  30. {
  31. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  32. LUACHECKOBJ(obj);
  33. lua_pushinteger(L,obj->GetAttribute<int>("size",20));
  34. return 1;
  35. }
  36. int ElementFormControlInputGetAttrmax(lua_State* L)
  37. {
  38. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  39. LUACHECKOBJ(obj);
  40. lua_pushinteger(L,obj->GetAttribute<int>("max",100));
  41. return 1;
  42. }
  43. int ElementFormControlInputGetAttrmin(lua_State* L)
  44. {
  45. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  46. LUACHECKOBJ(obj);
  47. lua_pushinteger(L,obj->GetAttribute<int>("min",0));
  48. return 1;
  49. }
  50. int ElementFormControlInputGetAttrstep(lua_State* L)
  51. {
  52. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  53. LUACHECKOBJ(obj);
  54. lua_pushinteger(L,obj->GetAttribute<int>("step",1));
  55. return 1;
  56. }
  57. //setters
  58. int ElementFormControlInputSetAttrchecked(lua_State* L)
  59. {
  60. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  61. LUACHECKOBJ(obj);
  62. bool checked = CHECK_BOOL(L,2);
  63. if(checked)
  64. obj->SetAttribute("checked",true);
  65. else
  66. obj->RemoveAttribute("checked");
  67. return 0;
  68. }
  69. int ElementFormControlInputSetAttrmaxlength(lua_State* L)
  70. {
  71. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  72. LUACHECKOBJ(obj);
  73. int maxlength = luaL_checkint(L,2);
  74. obj->SetAttribute("maxlength",maxlength);
  75. return 0;
  76. }
  77. int ElementFormControlInputSetAttrsize(lua_State* L)
  78. {
  79. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  80. LUACHECKOBJ(obj);
  81. int size = luaL_checkint(L,2);
  82. obj->SetAttribute("size",size);
  83. return 0;
  84. }
  85. int ElementFormControlInputSetAttrmax(lua_State* L)
  86. {
  87. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  88. LUACHECKOBJ(obj);
  89. int max = luaL_checkint(L,2);
  90. obj->SetAttribute("max",max);
  91. return 0;
  92. }
  93. int ElementFormControlInputSetAttrmin(lua_State* L)
  94. {
  95. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  96. LUACHECKOBJ(obj);
  97. int min = luaL_checkint(L,2);
  98. obj->SetAttribute("min",min);
  99. return 0;
  100. }
  101. int ElementFormControlInputSetAttrstep(lua_State* L)
  102. {
  103. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  104. LUACHECKOBJ(obj);
  105. int step = luaL_checkint(L,2);
  106. obj->SetAttribute("step",step);
  107. return 0;
  108. }
  109. RegType<ElementFormControlInput> ElementFormControlInputMethods[] =
  110. {
  111. {NULL,NULL},
  112. };
  113. luaL_reg ElementFormControlInputGetters[] =
  114. {
  115. LUAGETTER(ElementFormControlInput,checked)
  116. LUAGETTER(ElementFormControlInput,maxlength)
  117. LUAGETTER(ElementFormControlInput,size)
  118. LUAGETTER(ElementFormControlInput,max)
  119. LUAGETTER(ElementFormControlInput,min)
  120. LUAGETTER(ElementFormControlInput,step)
  121. {NULL,NULL},
  122. };
  123. luaL_reg ElementFormControlInputSetters[] =
  124. {
  125. LUASETTER(ElementFormControlInput,checked)
  126. LUASETTER(ElementFormControlInput,maxlength)
  127. LUASETTER(ElementFormControlInput,size)
  128. LUASETTER(ElementFormControlInput,max)
  129. LUASETTER(ElementFormControlInput,min)
  130. LUASETTER(ElementFormControlInput,step)
  131. {NULL,NULL},
  132. };
  133. template<> const char* GetTClassName<ElementFormControlInput>() { return "ElementFormControlInput"; }
  134. template<> RegType<ElementFormControlInput>* GetMethodTable<ElementFormControlInput>() { return ElementFormControlInputMethods; }
  135. template<> luaL_reg* GetAttrTable<ElementFormControlInput>() { return ElementFormControlInputGetters; }
  136. template<> luaL_reg* SetAttrTable<ElementFormControlInput>() { return ElementFormControlInputSetters; }
  137. }
  138. }
  139. }