The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
3.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef __JUCE_FILETREECOMPONENT_JUCEHEADER__
  18. #define __JUCE_FILETREECOMPONENT_JUCEHEADER__
  19. #include "juce_DirectoryContentsDisplayComponent.h"
  20. #include "../widgets/juce_TreeView.h"
  21. //==============================================================================
  22. /**
  23. A component that displays the files in a directory as a treeview.
  24. This implements the DirectoryContentsDisplayComponent base class so that
  25. it can be used in a FileBrowserComponent.
  26. To attach a listener to it, use its DirectoryContentsDisplayComponent base
  27. class and the FileBrowserListener class.
  28. @see DirectoryContentsList, FileListComponent
  29. */
  30. class JUCE_API FileTreeComponent : public TreeView,
  31. public DirectoryContentsDisplayComponent
  32. {
  33. public:
  34. //==============================================================================
  35. /** Creates a listbox to show the contents of a specified directory.
  36. */
  37. FileTreeComponent (DirectoryContentsList& listToShow);
  38. /** Destructor. */
  39. ~FileTreeComponent();
  40. //==============================================================================
  41. /** Returns the number of files the user has got selected.
  42. @see getSelectedFile
  43. */
  44. int getNumSelectedFiles() const { return TreeView::getNumSelectedItems(); }
  45. /** Returns one of the files that the user has currently selected.
  46. The index should be in the range 0 to (getNumSelectedFiles() - 1).
  47. @see getNumSelectedFiles
  48. */
  49. File getSelectedFile (int index = 0) const;
  50. /** Deselects any files that are currently selected. */
  51. void deselectAllFiles();
  52. /** Scrolls the list to the top. */
  53. void scrollToTop();
  54. /** If the specified file is in the list, it will become the only selected item
  55. (and if the file isn't in the list, all other items will be deselected). */
  56. void setSelectedFile (const File&);
  57. /** Updates the files in the list. */
  58. void refresh();
  59. /** Setting a name for this allows tree items to be dragged.
  60. The string that you pass in here will be returned by the getDragSourceDescription()
  61. of the items in the tree. For more info, see TreeViewItem::getDragSourceDescription().
  62. */
  63. void setDragAndDropDescription (const String& description);
  64. /** Returns the last value that was set by setDragAndDropDescription().
  65. */
  66. const String& getDragAndDropDescription() const noexcept { return dragAndDropDescription; }
  67. private:
  68. //==============================================================================
  69. String dragAndDropDescription;
  70. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileTreeComponent)
  71. };
  72. #endif // __JUCE_FILETREECOMPONENT_JUCEHEADER__