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.

95 lines
3.6KB

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