guiTreeViewCtrl.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. #ifndef _GUI_TREEVIEWCTRL_H
  23. #define _GUI_TREEVIEWCTRL_H
  24. #include "gui/guiListBoxCtrl.h"
  25. #include <vector>
  26. //------------------------------------------------------------------------------
  27. class GuiTreeViewCtrl : public GuiListBoxCtrl
  28. {
  29. private:
  30. typedef GuiListBoxCtrl Parent;
  31. protected:
  32. SimObjectPtr<SimObject> mRootObject;
  33. S32 mIndentSize;
  34. public:
  35. GuiTreeViewCtrl();
  36. virtual ~GuiTreeViewCtrl();
  37. static void initPersistFields();
  38. class TreeItem : public GuiListBoxCtrl::LBItem
  39. {
  40. public:
  41. TreeItem() : isOpen(1), level(0), triangleArea(RectI()), isVisible(1) { }
  42. virtual ~TreeItem() { }
  43. bool isOpen;
  44. U16 level;
  45. RectI triangleArea;
  46. bool isVisible;
  47. vector<TreeItem*> branchList;
  48. TreeItem* trunk;
  49. };
  50. private:
  51. TreeItem* grabItemPtr(S32 index);
  52. public:
  53. // GuiControl
  54. //bool onWake();
  55. //void onSleep();
  56. //void onPreRender();
  57. //bool onKeyDown(const GuiEvent& event);
  58. //void onTouchDown(const GuiEvent& event);
  59. //void onMiddleMouseDown(const GuiEvent& event);
  60. //void onTouchMove(const GuiEvent& event);
  61. //void onTouchEnter(const GuiEvent& event);
  62. //void onTouchLeave(const GuiEvent& event);
  63. //void onRightMouseDown(const GuiEvent& event);
  64. //void onTouchDragged(const GuiEvent& event);
  65. //void onTouchUp(const GuiEvent& event);
  66. //bool onAdd();
  67. void onPreRender();
  68. void onRender(Point2I offset, const RectI& updateRect);
  69. //void setControlProfile(GuiControlProfile* prof);
  70. //void resize(const Point2I& newPosition, const Point2I& newExtent);
  71. virtual void onRenderItem(RectI& itemRect, LBItem* item);
  72. S32 getHitIndex(const GuiEvent& event);
  73. virtual void handleItemClick(LBItem* hitItem, S32 hitIndex, const GuiEvent& event);
  74. virtual void handleItemClick_ClickCallbacks(LBItem* hitItem, S32 hitIndex, const GuiEvent& event);
  75. void inspectObject(SimObject* obj);
  76. void addBranches(TreeItem* treeItem, SimObject* obj, U16 level);
  77. void refreshTree();
  78. StringTableEntry getObjectText(SimObject* obj);
  79. void calculateHeaderExtent();
  80. virtual GuiListBoxCtrl::LBItem* createItem();
  81. void setBranchesVisible(TreeItem* treeItem, bool isVisible);
  82. DECLARE_CONOBJECT(GuiTreeViewCtrl);
  83. };
  84. #endif