PolyUITreeContainer.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. Copyright (C) 2012 by Ivan Safrin
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. THE SOFTWARE.
  18. */
  19. #pragma once
  20. #include "PolyGlobals.h"
  21. #include "PolyUITree.h"
  22. #include "PolyUIBox.h"
  23. #include "PolyInputKeys.h"
  24. #include "PolyUIElement.h"
  25. #include "PolyUIScrollContainer.h"
  26. namespace Polycode {
  27. class _PolyExport UITreeContainer : public UIElement {
  28. public:
  29. UITreeContainer(String icon, String text, Number treeWidth, Number treeHeight);
  30. virtual ~UITreeContainer();
  31. void handleEvent(Event *event);
  32. void Resize(Number width, Number height);
  33. UITree *getRootNode();
  34. Entity *scrollChild;
  35. void onKeyDown(PolyKEY key, wchar_t charCode);
  36. void onGainFocus();
  37. /**
  38. * Scrolls the container to show a specified node.
  39. * @param node The tree node to scroll to or show.
  40. * @param showAtTop If true, show the node at the top of the container. If false, show it at the bottom.
  41. */
  42. void scrollToNode(UITree *node, bool showAtTop);
  43. UIScrollContainer *getScrollContainer();
  44. protected:
  45. bool keyNavigable;
  46. UITree *findLastOpenNode(UITree *tree);
  47. UITree *findNextParentSibling(UITree *parent);
  48. private:
  49. UIScrollContainer *mainContainer;
  50. UITree *rootNode;
  51. UIBox *bgBox;
  52. };
  53. }