guiTreeViewCtrl_ScriptBinding.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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(GuiTreeViewCtrl, GuiListBoxCtrl)
  23. /*! Sets the root object to view.
  24. @param obj A SimGroup that will be viewed as a tree.
  25. @return No return value.
  26. */
  27. ConsoleMethodWithDocs( GuiTreeViewCtrl, open, ConsoleVoid, 3, 3, (SimGroup obj))
  28. {
  29. SimGroup* treeRoot = NULL;
  30. SimObject* target = Sim::findObject(argv[2]);
  31. if (target)
  32. treeRoot = dynamic_cast<SimGroup*>(target);
  33. object->inspectObject(treeRoot);
  34. }
  35. /*! Informs the tree that the contents of the tree have changed and should be refreshed but preserves selection if possible.
  36. @return No return value.
  37. */
  38. ConsoleMethodWithDocs(GuiTreeViewCtrl, refresh, ConsoleVoid, 2, 2, ())
  39. {
  40. object->refreshTree();
  41. }
  42. /*! Sets if an item is open by the index.
  43. @param index The zero-based index of the item.
  44. @param isOpen True if the item should be open and false otherwise.
  45. @return No return value.
  46. */
  47. ConsoleMethodWithDocs(GuiTreeViewCtrl, setItemOpen, ConsoleVoid, 4, 4, "(int index, bool isOpen)")
  48. {
  49. if (argc != 4)
  50. {
  51. Con::warnf("GuiTreeViewCtrl::setItemOpen() - Invalid number of parameters! Should be (index, isOpen).");
  52. }
  53. else
  54. {
  55. object->setItemOpen(dAtoi(argv[2]), dAtob(argv[3]));
  56. }
  57. }
  58. /*! Returns if an item is open or not using an index.
  59. @param index The zero-based index of the item.
  60. @return True if the item is open and false otherwise.
  61. */
  62. ConsoleMethodWithDocs(GuiTreeViewCtrl, getItemOpen, ConsoleBool, 3, 3, "(int index)")
  63. {
  64. if (argc != 3)
  65. {
  66. Con::warnf("GuiTreeViewCtrl::getItemOpen() - Invalid number of parameters! Should be (index).");
  67. return true;
  68. }
  69. return object->getItemOpen(dAtoi(argv[2]));
  70. }
  71. /*! Returns the index of the parent of the item.
  72. @param index The zero-based index of the child item.
  73. @return The index of the parent or -1 if the parent is the root.
  74. */
  75. ConsoleMethodWithDocs(GuiTreeViewCtrl, getItemParent, ConsoleInt, 3, 3, "(int index)")
  76. {
  77. if (argc != 3)
  78. {
  79. Con::warnf("GuiTreeViewCtrl::getItemOpen() - Invalid number of parameters! Should be (index).");
  80. return -1;
  81. }
  82. return object->getItemTrunk(dAtoi(argv[2]));
  83. }
  84. ConsoleMethodGroupEndWithDocs(GuiTreeViewCtrl)