ElementFormControlTextArea.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * This source file is part of RmlUi, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://github.com/mikke89/RmlUi
  5. *
  6. * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
  7. * Copyright (c) 2019 The RmlUi Team, and contributors
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10. * of this software and associated documentation files (the "Software"), to deal
  11. * in the Software without restriction, including without limitation the rights
  12. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. * copies of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included in
  17. * all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. * THE SOFTWARE.
  26. *
  27. */
  28. #include "precompiled.h"
  29. #include "ElementFormControlTextArea.h"
  30. #include <RmlUi/Controls/ElementFormControl.h>
  31. #include "ElementFormControl.h"
  32. #include <RmlUi/Core/Lua/Utilities.h>
  33. namespace Rml {
  34. namespace Controls {
  35. namespace Lua {
  36. //getters
  37. int ElementFormControlTextAreaGetAttrcols(lua_State* L)
  38. {
  39. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  40. LUACHECKOBJ(obj);
  41. lua_pushinteger(L,obj->GetNumColumns());
  42. return 1;
  43. }
  44. int ElementFormControlTextAreaGetAttrmaxlength(lua_State* L)
  45. {
  46. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  47. LUACHECKOBJ(obj);
  48. lua_pushinteger(L,obj->GetMaxLength());
  49. return 1;
  50. }
  51. int ElementFormControlTextAreaGetAttrrows(lua_State* L)
  52. {
  53. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  54. LUACHECKOBJ(obj);
  55. lua_pushinteger(L,obj->GetNumRows());
  56. return 1;
  57. }
  58. int ElementFormControlTextAreaGetAttrwordwrap(lua_State* L)
  59. {
  60. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  61. LUACHECKOBJ(obj);
  62. lua_pushboolean(L,obj->GetWordWrap());
  63. return 1;
  64. }
  65. //setters
  66. int ElementFormControlTextAreaSetAttrcols(lua_State* L)
  67. {
  68. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  69. LUACHECKOBJ(obj);
  70. int cols = luaL_checkinteger(L,2);
  71. obj->SetNumColumns(cols);
  72. return 0;
  73. }
  74. int ElementFormControlTextAreaSetAttrmaxlength(lua_State* L)
  75. {
  76. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  77. LUACHECKOBJ(obj);
  78. int ml = luaL_checkinteger(L,2);
  79. obj->SetMaxLength(ml);
  80. return 0;
  81. }
  82. int ElementFormControlTextAreaSetAttrrows(lua_State* L)
  83. {
  84. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  85. LUACHECKOBJ(obj);
  86. int rows = luaL_checkinteger(L,2);
  87. obj->SetNumRows(rows);
  88. return 0;
  89. }
  90. int ElementFormControlTextAreaSetAttrwordwrap(lua_State* L)
  91. {
  92. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  93. LUACHECKOBJ(obj);
  94. bool ww = CHECK_BOOL(L,2);
  95. obj->SetWordWrap(ww);
  96. return 0;
  97. }
  98. Rml::Core::Lua::RegType<ElementFormControlTextArea> ElementFormControlTextAreaMethods[] =
  99. {
  100. { nullptr, nullptr },
  101. };
  102. luaL_Reg ElementFormControlTextAreaGetters[] =
  103. {
  104. LUAGETTER(ElementFormControlTextArea,cols)
  105. LUAGETTER(ElementFormControlTextArea,maxlength)
  106. LUAGETTER(ElementFormControlTextArea,rows)
  107. LUAGETTER(ElementFormControlTextArea,wordwrap)
  108. { nullptr, nullptr },
  109. };
  110. luaL_Reg ElementFormControlTextAreaSetters[] =
  111. {
  112. LUASETTER(ElementFormControlTextArea,cols)
  113. LUASETTER(ElementFormControlTextArea,maxlength)
  114. LUASETTER(ElementFormControlTextArea,rows)
  115. LUASETTER(ElementFormControlTextArea,wordwrap)
  116. { nullptr, nullptr },
  117. };
  118. }
  119. }
  120. }
  121. namespace Rml {
  122. namespace Core {
  123. namespace Lua {
  124. template<> void ExtraInit<Rml::Controls::ElementFormControlTextArea>(lua_State* L, int metatable_index)
  125. {
  126. ExtraInit<Rml::Controls::ElementFormControl>(L,metatable_index);
  127. LuaType<Rml::Controls::ElementFormControl>::_regfunctions(L,metatable_index,metatable_index-1);
  128. AddTypeToElementAsTable<Rml::Controls::ElementFormControlTextArea>(L);
  129. }
  130. using Rml::Controls::ElementFormControlTextArea;
  131. LUACONTROLSTYPEDEFINE(ElementFormControlTextArea)
  132. }
  133. }
  134. }