ElementFormControlInput.cpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * This source file is part of libRocket, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://www.librocket.com
  5. *
  6. * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. *
  26. */
  27. #include "precompiled.h"
  28. #include "ElementFormControlInput.h"
  29. #include <Rocket/Controls/ElementFormControl.h>
  30. #include "ElementFormControl.h"
  31. template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementFormControlInput>(lua_State* L, int metatable_index)
  32. {
  33. Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementFormControl>(L,metatable_index);
  34. LuaType<Rocket::Controls::ElementFormControl>::_regfunctions(L,metatable_index,metatable_index-1);
  35. }
  36. namespace Rocket {
  37. namespace Controls {
  38. namespace Lua {
  39. //getters
  40. int ElementFormControlInputGetAttrchecked(lua_State* L)
  41. {
  42. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  43. LUACHECKOBJ(obj);
  44. lua_pushboolean(L,obj->HasAttribute("checked"));
  45. return 1;
  46. }
  47. int ElementFormControlInputGetAttrmaxlength(lua_State* L)
  48. {
  49. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  50. LUACHECKOBJ(obj);
  51. lua_pushinteger(L,obj->GetAttribute<int>("maxlength",-1));
  52. return 1;
  53. }
  54. int ElementFormControlInputGetAttrsize(lua_State* L)
  55. {
  56. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  57. LUACHECKOBJ(obj);
  58. lua_pushinteger(L,obj->GetAttribute<int>("size",20));
  59. return 1;
  60. }
  61. int ElementFormControlInputGetAttrmax(lua_State* L)
  62. {
  63. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  64. LUACHECKOBJ(obj);
  65. lua_pushinteger(L,obj->GetAttribute<int>("max",100));
  66. return 1;
  67. }
  68. int ElementFormControlInputGetAttrmin(lua_State* L)
  69. {
  70. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  71. LUACHECKOBJ(obj);
  72. lua_pushinteger(L,obj->GetAttribute<int>("min",0));
  73. return 1;
  74. }
  75. int ElementFormControlInputGetAttrstep(lua_State* L)
  76. {
  77. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  78. LUACHECKOBJ(obj);
  79. lua_pushinteger(L,obj->GetAttribute<int>("step",1));
  80. return 1;
  81. }
  82. //setters
  83. int ElementFormControlInputSetAttrchecked(lua_State* L)
  84. {
  85. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  86. LUACHECKOBJ(obj);
  87. bool checked = CHECK_BOOL(L,2);
  88. if(checked)
  89. obj->SetAttribute("checked",true);
  90. else
  91. obj->RemoveAttribute("checked");
  92. return 0;
  93. }
  94. int ElementFormControlInputSetAttrmaxlength(lua_State* L)
  95. {
  96. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  97. LUACHECKOBJ(obj);
  98. int maxlength = luaL_checkint(L,2);
  99. obj->SetAttribute("maxlength",maxlength);
  100. return 0;
  101. }
  102. int ElementFormControlInputSetAttrsize(lua_State* L)
  103. {
  104. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  105. LUACHECKOBJ(obj);
  106. int size = luaL_checkint(L,2);
  107. obj->SetAttribute("size",size);
  108. return 0;
  109. }
  110. int ElementFormControlInputSetAttrmax(lua_State* L)
  111. {
  112. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  113. LUACHECKOBJ(obj);
  114. int max = luaL_checkint(L,2);
  115. obj->SetAttribute("max",max);
  116. return 0;
  117. }
  118. int ElementFormControlInputSetAttrmin(lua_State* L)
  119. {
  120. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  121. LUACHECKOBJ(obj);
  122. int min = luaL_checkint(L,2);
  123. obj->SetAttribute("min",min);
  124. return 0;
  125. }
  126. int ElementFormControlInputSetAttrstep(lua_State* L)
  127. {
  128. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  129. LUACHECKOBJ(obj);
  130. int step = luaL_checkint(L,2);
  131. obj->SetAttribute("step",step);
  132. return 0;
  133. }
  134. Rocket::Core::Lua::RegType<ElementFormControlInput> ElementFormControlInputMethods[] =
  135. {
  136. {NULL,NULL},
  137. };
  138. luaL_reg ElementFormControlInputGetters[] =
  139. {
  140. LUAGETTER(ElementFormControlInput,checked)
  141. LUAGETTER(ElementFormControlInput,maxlength)
  142. LUAGETTER(ElementFormControlInput,size)
  143. LUAGETTER(ElementFormControlInput,max)
  144. LUAGETTER(ElementFormControlInput,min)
  145. LUAGETTER(ElementFormControlInput,step)
  146. {NULL,NULL},
  147. };
  148. luaL_reg ElementFormControlInputSetters[] =
  149. {
  150. LUASETTER(ElementFormControlInput,checked)
  151. LUASETTER(ElementFormControlInput,maxlength)
  152. LUASETTER(ElementFormControlInput,size)
  153. LUASETTER(ElementFormControlInput,max)
  154. LUASETTER(ElementFormControlInput,min)
  155. LUASETTER(ElementFormControlInput,step)
  156. {NULL,NULL},
  157. };
  158. }
  159. }
  160. }
  161. using Rocket::Controls::ElementFormControlInput;
  162. LUACONTROLSTYPEDEFINE(ElementFormControlInput,true)