ElementFormControlInput.cpp 5.6 KB

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