ElementFormControlInput.cpp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. #include <Rocket/Core/Lua/Utilities.h>
  32. template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementFormControlInput>(lua_State* L, int metatable_index)
  33. {
  34. Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementFormControl>(L,metatable_index);
  35. LuaType<Rocket::Controls::ElementFormControl>::_regfunctions(L,metatable_index,metatable_index-1);
  36. Rocket::Core::Lua::AddTypeToElementAsTable<Rocket::Controls::ElementFormControlInput>(L);
  37. }
  38. namespace Rocket {
  39. namespace Controls {
  40. namespace Lua {
  41. //getters
  42. int ElementFormControlInputGetAttrchecked(lua_State* L)
  43. {
  44. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  45. LUACHECKOBJ(obj);
  46. lua_pushboolean(L,obj->HasAttribute("checked"));
  47. return 1;
  48. }
  49. int ElementFormControlInputGetAttrmaxlength(lua_State* L)
  50. {
  51. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  52. LUACHECKOBJ(obj);
  53. lua_pushinteger(L,obj->GetAttribute<int>("maxlength",-1));
  54. return 1;
  55. }
  56. int ElementFormControlInputGetAttrsize(lua_State* L)
  57. {
  58. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  59. LUACHECKOBJ(obj);
  60. lua_pushinteger(L,obj->GetAttribute<int>("size",20));
  61. return 1;
  62. }
  63. int ElementFormControlInputGetAttrmax(lua_State* L)
  64. {
  65. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  66. LUACHECKOBJ(obj);
  67. lua_pushinteger(L,obj->GetAttribute<int>("max",100));
  68. return 1;
  69. }
  70. int ElementFormControlInputGetAttrmin(lua_State* L)
  71. {
  72. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  73. LUACHECKOBJ(obj);
  74. lua_pushinteger(L,obj->GetAttribute<int>("min",0));
  75. return 1;
  76. }
  77. int ElementFormControlInputGetAttrstep(lua_State* L)
  78. {
  79. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  80. LUACHECKOBJ(obj);
  81. lua_pushinteger(L,obj->GetAttribute<int>("step",1));
  82. return 1;
  83. }
  84. //setters
  85. int ElementFormControlInputSetAttrchecked(lua_State* L)
  86. {
  87. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  88. LUACHECKOBJ(obj);
  89. bool checked = CHECK_BOOL(L,2);
  90. if(checked)
  91. obj->SetAttribute("checked",true);
  92. else
  93. obj->RemoveAttribute("checked");
  94. return 0;
  95. }
  96. int ElementFormControlInputSetAttrmaxlength(lua_State* L)
  97. {
  98. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  99. LUACHECKOBJ(obj);
  100. int maxlength = luaL_checkint(L,2);
  101. obj->SetAttribute("maxlength",maxlength);
  102. return 0;
  103. }
  104. int ElementFormControlInputSetAttrsize(lua_State* L)
  105. {
  106. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  107. LUACHECKOBJ(obj);
  108. int size = luaL_checkint(L,2);
  109. obj->SetAttribute("size",size);
  110. return 0;
  111. }
  112. int ElementFormControlInputSetAttrmax(lua_State* L)
  113. {
  114. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  115. LUACHECKOBJ(obj);
  116. int max = luaL_checkint(L,2);
  117. obj->SetAttribute("max",max);
  118. return 0;
  119. }
  120. int ElementFormControlInputSetAttrmin(lua_State* L)
  121. {
  122. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  123. LUACHECKOBJ(obj);
  124. int min = luaL_checkint(L,2);
  125. obj->SetAttribute("min",min);
  126. return 0;
  127. }
  128. int ElementFormControlInputSetAttrstep(lua_State* L)
  129. {
  130. ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
  131. LUACHECKOBJ(obj);
  132. int step = luaL_checkint(L,2);
  133. obj->SetAttribute("step",step);
  134. return 0;
  135. }
  136. Rocket::Core::Lua::RegType<ElementFormControlInput> ElementFormControlInputMethods[] =
  137. {
  138. {NULL,NULL},
  139. };
  140. luaL_reg ElementFormControlInputGetters[] =
  141. {
  142. LUAGETTER(ElementFormControlInput,checked)
  143. LUAGETTER(ElementFormControlInput,maxlength)
  144. LUAGETTER(ElementFormControlInput,size)
  145. LUAGETTER(ElementFormControlInput,max)
  146. LUAGETTER(ElementFormControlInput,min)
  147. LUAGETTER(ElementFormControlInput,step)
  148. {NULL,NULL},
  149. };
  150. luaL_reg ElementFormControlInputSetters[] =
  151. {
  152. LUASETTER(ElementFormControlInput,checked)
  153. LUASETTER(ElementFormControlInput,maxlength)
  154. LUASETTER(ElementFormControlInput,size)
  155. LUASETTER(ElementFormControlInput,max)
  156. LUASETTER(ElementFormControlInput,min)
  157. LUASETTER(ElementFormControlInput,step)
  158. {NULL,NULL},
  159. };
  160. }
  161. }
  162. }
  163. using Rocket::Controls::ElementFormControlInput;
  164. LUACONTROLSTYPEDEFINE(ElementFormControlInput,true)