ElementFormControlTextArea.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 "ElementFormControlTextArea.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::ElementFormControlTextArea>(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::ElementFormControlTextArea>(L);
  37. }
  38. namespace Rocket {
  39. namespace Controls {
  40. namespace Lua {
  41. //getters
  42. int ElementFormControlTextAreaGetAttrcols(lua_State* L)
  43. {
  44. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  45. LUACHECKOBJ(obj);
  46. lua_pushinteger(L,obj->GetNumColumns());
  47. return 1;
  48. }
  49. int ElementFormControlTextAreaGetAttrmaxlength(lua_State* L)
  50. {
  51. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  52. LUACHECKOBJ(obj);
  53. lua_pushinteger(L,obj->GetMaxLength());
  54. return 1;
  55. }
  56. int ElementFormControlTextAreaGetAttrrows(lua_State* L)
  57. {
  58. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  59. LUACHECKOBJ(obj);
  60. lua_pushinteger(L,obj->GetNumRows());
  61. return 1;
  62. }
  63. int ElementFormControlTextAreaGetAttrwordwrap(lua_State* L)
  64. {
  65. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  66. LUACHECKOBJ(obj);
  67. lua_pushboolean(L,obj->GetWordWrap());
  68. return 1;
  69. }
  70. //setters
  71. int ElementFormControlTextAreaSetAttrcols(lua_State* L)
  72. {
  73. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  74. LUACHECKOBJ(obj);
  75. int cols = luaL_checkint(L,2);
  76. obj->SetNumColumns(cols);
  77. return 0;
  78. }
  79. int ElementFormControlTextAreaSetAttrmaxlength(lua_State* L)
  80. {
  81. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  82. LUACHECKOBJ(obj);
  83. int ml = luaL_checkint(L,2);
  84. obj->SetMaxLength(ml);
  85. return 0;
  86. }
  87. int ElementFormControlTextAreaSetAttrrows(lua_State* L)
  88. {
  89. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  90. LUACHECKOBJ(obj);
  91. int rows = luaL_checkint(L,2);
  92. obj->SetNumRows(rows);
  93. return 0;
  94. }
  95. int ElementFormControlTextAreaSetAttrwordwrap(lua_State* L)
  96. {
  97. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  98. LUACHECKOBJ(obj);
  99. bool ww = CHECK_BOOL(L,2);
  100. obj->SetWordWrap(ww);
  101. return 0;
  102. }
  103. Rocket::Core::Lua::RegType<ElementFormControlTextArea> ElementFormControlTextAreaMethods[] =
  104. {
  105. { NULL, NULL },
  106. };
  107. luaL_reg ElementFormControlTextAreaGetters[] =
  108. {
  109. LUAGETTER(ElementFormControlTextArea,cols)
  110. LUAGETTER(ElementFormControlTextArea,maxlength)
  111. LUAGETTER(ElementFormControlTextArea,rows)
  112. LUAGETTER(ElementFormControlTextArea,wordwrap)
  113. { NULL, NULL },
  114. };
  115. luaL_reg ElementFormControlTextAreaSetters[] =
  116. {
  117. LUASETTER(ElementFormControlTextArea,cols)
  118. LUASETTER(ElementFormControlTextArea,maxlength)
  119. LUASETTER(ElementFormControlTextArea,rows)
  120. LUASETTER(ElementFormControlTextArea,wordwrap)
  121. { NULL, NULL },
  122. };
  123. }
  124. }
  125. }
  126. using Rocket::Controls::ElementFormControlTextArea;
  127. LUACONTROLSTYPEDEFINE(ElementFormControlTextArea,true)