guiGridCtrl_ScriptBinding.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. ConsoleMethodGroupBeginWithDocs(GuiGridCtrl, GuiControl)
  23. /*! Sets the size assigned to each child control.
  24. @param width The width of the child.
  25. @param height The height of the child.
  26. @return No return value.
  27. */
  28. ConsoleMethodWithDocs(GuiGridCtrl, setCellSize, ConsoleVoid, 3, 4, (float width, float height))
  29. {
  30. F32 width, height;
  31. const U32 elementCount = Utility::mGetStringElementCount(argv[2]);
  32. // ("width height")
  33. if ((elementCount == 2) && (argc == 3))
  34. {
  35. width = dAtof(Utility::mGetStringElement(argv[2], 0));
  36. height = dAtof(Utility::mGetStringElement(argv[2], 1));
  37. }
  38. // (width, [height])
  39. else if (elementCount == 1)
  40. {
  41. width = dAtof(argv[2]);
  42. if (argc > 3)
  43. height = dAtof(argv[3]);
  44. else
  45. height = width;
  46. }
  47. // Invalid
  48. else
  49. {
  50. Con::warnf("GuiGridCtrl::setCellSize() - Invalid number of parameters!");
  51. return;
  52. }
  53. // Set Position.
  54. object->setCellSize(width, height);
  55. }
  56. /*! Gets the size assigned to child controls. Results should be interpreted based on CellMode.
  57. @return (float width/float height) The width and height of the cells.
  58. */
  59. ConsoleMethodWithDocs(GuiGridCtrl, getCellSize, ConsoleString, 2, 2, ())
  60. {
  61. return object->getCellSize().stringThis();
  62. }
  63. /*! Sets the spacing used between each child control. Note that if child controls use margin, there will appear to be additional spacing.
  64. @param x The horizontal spacing.
  65. @param y The vertical spacing.
  66. @return No return value.
  67. */
  68. ConsoleMethodWithDocs(GuiGridCtrl, setCellSpacing, ConsoleVoid, 3, 4, (float x, float y))
  69. {
  70. F32 width, height;
  71. const U32 elementCount = Utility::mGetStringElementCount(argv[2]);
  72. // ("width height")
  73. if ((elementCount == 2) && (argc == 3))
  74. {
  75. width = dAtof(Utility::mGetStringElement(argv[2], 0));
  76. height = dAtof(Utility::mGetStringElement(argv[2], 1));
  77. }
  78. // (width, [height])
  79. else if (elementCount == 1)
  80. {
  81. width = dAtof(argv[2]);
  82. if (argc > 3)
  83. height = dAtof(argv[3]);
  84. else
  85. height = width;
  86. }
  87. // Invalid
  88. else
  89. {
  90. Con::warnf("GuiGridCtrl::setCellSpacing() - Invalid number of parameters!");
  91. return;
  92. }
  93. // Set Position.
  94. object->setCellSpacing(width, height);
  95. }
  96. /*! Gets the spacing that will be between each child control. Results should be interpreted based on CellMode.
  97. @return (float x/float y) The horizontal and vertical spacing between the cells.
  98. */
  99. ConsoleMethodWithDocs(GuiGridCtrl, getCellSpacing, ConsoleString, 2, 2, ())
  100. {
  101. return object->getCellSpacing().stringThis();
  102. }
  103. /*! Sets the cell mode in the horizontal direction.
  104. @return No return value.
  105. */
  106. ConsoleMethodWithDocs(GuiGridCtrl, setCellModeX, ConsoleVoid, 3, 3, (cellMode mode))
  107. {
  108. // Fetch cell mode.
  109. const GuiGridCtrl::CellMode mode = GuiGridCtrl::getCellModeEnum(argv[2]);
  110. // Check for error.
  111. if (mode != GuiGridCtrl::Percent && mode != GuiGridCtrl::Variable && mode != GuiGridCtrl::Absolute)
  112. return;
  113. // Set body type.
  114. object->setCellModeX(mode);
  115. }
  116. /*! Sets the cell mode in the vertical direction.
  117. @return No return value.
  118. */
  119. ConsoleMethodWithDocs(GuiGridCtrl, setCellModeY, ConsoleVoid, 3, 3, (cellMode mode))
  120. {
  121. // Fetch cell mode.
  122. const GuiGridCtrl::CellMode mode = GuiGridCtrl::getCellModeEnum(argv[2]);
  123. // Check for error.
  124. if (mode != GuiGridCtrl::Percent && mode != GuiGridCtrl::Variable && mode != GuiGridCtrl::Absolute)
  125. return;
  126. // Set body type.
  127. object->setCellModeY(mode);
  128. }
  129. /*! Gets the horizontal cell mode.
  130. @return The horizontal cell mode.
  131. */
  132. ConsoleMethodWithDocs(GuiGridCtrl, getCellModeX, ConsoleString, 2, 2, ())
  133. {
  134. return GuiGridCtrl::getCellModeDescription(object->getCellModeX());
  135. }
  136. /*! Gets the vertical cell mode.
  137. @return The vertical cell mode.
  138. */
  139. ConsoleMethodWithDocs(GuiGridCtrl, getCellModeY, ConsoleString, 2, 2, ())
  140. {
  141. return GuiGridCtrl::getCellModeDescription(object->getCellModeY());
  142. }
  143. /*! Sets the max number of columns. This will be ignored by Order Modes that end in L or R.
  144. @param max The max number of columns. Use zero for auto.
  145. @return No return value.
  146. */
  147. ConsoleMethodWithDocs(GuiGridCtrl, setMaxColCount, ConsoleVoid, 3, 3, (int max))
  148. {
  149. object->setMaxColCount(dAtoi(argv[2]));
  150. }
  151. /*! Sets the max number of rows. This will be ignored by Order Modes that end in T or B.
  152. @param max The max number of rows. Use zero for auto.
  153. @return No return value.
  154. */
  155. ConsoleMethodWithDocs(GuiGridCtrl, setMaxRowCount, ConsoleVoid, 3, 3, (int max))
  156. {
  157. object->setMaxRowCount(dAtoi(argv[2]));
  158. }
  159. /*! Gets the max column count.
  160. @return The max column count.
  161. */
  162. ConsoleMethodWithDocs(GuiGridCtrl, getMaxColCount, ConsoleInt, 2, 2, ())
  163. {
  164. return object->getMaxColCount();
  165. }
  166. /*! Gets the max row count.
  167. @return The max row count.
  168. */
  169. ConsoleMethodWithDocs(GuiGridCtrl, getMaxRowCount, ConsoleInt, 2, 2, ())
  170. {
  171. return object->getMaxRowCount();
  172. }
  173. /*! Gets the order mode.
  174. @return The order mode.
  175. */
  176. ConsoleMethodWithDocs(GuiGridCtrl, getOrderMode, ConsoleString, 2, 2, ())
  177. {
  178. return GuiGridCtrl::getOrderModeDescription(object->getOrderMode());
  179. }
  180. /*! Gets if the extent will change based on the size of the contents. Expansion will happen in the direction of the final letter of the order mode.
  181. @return The dynamic extent.
  182. */
  183. ConsoleMethodWithDocs(GuiGridCtrl, getIsExtentDynamic, ConsoleBool, 2, 2, ())
  184. {
  185. return object->getIsExtentDynamic();
  186. }
  187. ConsoleMethodGroupEndWithDocs(GuiGridCtrl)