ElementFormControlTextArea.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 "ElementFormControlTextArea.h"
  29. #include <RmlUi/Core/Elements/ElementFormControl.h>
  30. #include "ElementFormControl.h"
  31. #include <RmlUi/Lua/Utilities.h>
  32. namespace Rml {
  33. namespace Lua {
  34. //getters
  35. int ElementFormControlTextAreaGetAttrcols(lua_State* L)
  36. {
  37. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  38. RMLUI_CHECK_OBJ(obj);
  39. lua_pushinteger(L,obj->GetNumColumns());
  40. return 1;
  41. }
  42. int ElementFormControlTextAreaGetAttrmaxlength(lua_State* L)
  43. {
  44. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  45. RMLUI_CHECK_OBJ(obj);
  46. lua_pushinteger(L,obj->GetMaxLength());
  47. return 1;
  48. }
  49. int ElementFormControlTextAreaGetAttrrows(lua_State* L)
  50. {
  51. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  52. RMLUI_CHECK_OBJ(obj);
  53. lua_pushinteger(L,obj->GetNumRows());
  54. return 1;
  55. }
  56. int ElementFormControlTextAreaGetAttrwordwrap(lua_State* L)
  57. {
  58. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  59. RMLUI_CHECK_OBJ(obj);
  60. lua_pushboolean(L,obj->GetWordWrap());
  61. return 1;
  62. }
  63. //setters
  64. int ElementFormControlTextAreaSetAttrcols(lua_State* L)
  65. {
  66. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  67. RMLUI_CHECK_OBJ(obj);
  68. int cols = (int)luaL_checkinteger(L,2);
  69. obj->SetNumColumns(cols);
  70. return 0;
  71. }
  72. int ElementFormControlTextAreaSetAttrmaxlength(lua_State* L)
  73. {
  74. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  75. RMLUI_CHECK_OBJ(obj);
  76. int ml = (int)luaL_checkinteger(L,2);
  77. obj->SetMaxLength(ml);
  78. return 0;
  79. }
  80. int ElementFormControlTextAreaSetAttrrows(lua_State* L)
  81. {
  82. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  83. RMLUI_CHECK_OBJ(obj);
  84. int rows = (int)luaL_checkinteger(L,2);
  85. obj->SetNumRows(rows);
  86. return 0;
  87. }
  88. int ElementFormControlTextAreaSetAttrwordwrap(lua_State* L)
  89. {
  90. ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
  91. RMLUI_CHECK_OBJ(obj);
  92. bool ww = RMLUI_CHECK_BOOL(L,2);
  93. obj->SetWordWrap(ww);
  94. return 0;
  95. }
  96. RegType<ElementFormControlTextArea> ElementFormControlTextAreaMethods[] =
  97. {
  98. { nullptr, nullptr },
  99. };
  100. luaL_Reg ElementFormControlTextAreaGetters[] =
  101. {
  102. RMLUI_LUAGETTER(ElementFormControlTextArea,cols)
  103. RMLUI_LUAGETTER(ElementFormControlTextArea,maxlength)
  104. RMLUI_LUAGETTER(ElementFormControlTextArea,rows)
  105. RMLUI_LUAGETTER(ElementFormControlTextArea,wordwrap)
  106. { nullptr, nullptr },
  107. };
  108. luaL_Reg ElementFormControlTextAreaSetters[] =
  109. {
  110. RMLUI_LUASETTER(ElementFormControlTextArea,cols)
  111. RMLUI_LUASETTER(ElementFormControlTextArea,maxlength)
  112. RMLUI_LUASETTER(ElementFormControlTextArea,rows)
  113. RMLUI_LUASETTER(ElementFormControlTextArea,wordwrap)
  114. { nullptr, nullptr },
  115. };
  116. template<> void ExtraInit<ElementFormControlTextArea>(lua_State* L, int metatable_index)
  117. {
  118. ExtraInit<ElementFormControl>(L,metatable_index);
  119. LuaType<ElementFormControl>::_regfunctions(L,metatable_index,metatable_index-1);
  120. AddTypeToElementAsTable<ElementFormControlTextArea>(L);
  121. }
  122. RMLUI_LUATYPE_DEFINE(ElementFormControlTextArea)
  123. } // namespace Lua
  124. } // namespace Rml