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.

108 lines
4.0KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI 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. #pragma once
  18. //==============================================================================
  19. /**
  20. A base class for components that display a list of the files in a directory.
  21. @see DirectoryContentsList
  22. */
  23. class JUCE_API DirectoryContentsDisplayComponent
  24. {
  25. public:
  26. //==============================================================================
  27. /** Creates a DirectoryContentsDisplayComponent for a given list of files. */
  28. DirectoryContentsDisplayComponent (DirectoryContentsList& listToShow);
  29. /** Destructor. */
  30. virtual ~DirectoryContentsDisplayComponent();
  31. //==============================================================================
  32. /** Returns the number of files the user has got selected.
  33. @see getSelectedFile
  34. */
  35. virtual int getNumSelectedFiles() const = 0;
  36. /** Returns one of the files that the user has currently selected.
  37. The index should be in the range 0 to (getNumSelectedFiles() - 1).
  38. @see getNumSelectedFiles
  39. */
  40. virtual File getSelectedFile (int index) const = 0;
  41. /** Deselects any selected files. */
  42. virtual void deselectAllFiles() = 0;
  43. /** Scrolls this view to the top. */
  44. virtual void scrollToTop() = 0;
  45. /** If the specified file is in the list, it will become the only selected item
  46. (and if the file isn't in the list, all other items will be deselected). */
  47. virtual void setSelectedFile (const File&) = 0;
  48. //==============================================================================
  49. /** Adds a listener to be told when files are selected or clicked.
  50. @see removeListener
  51. */
  52. void addListener (FileBrowserListener* listener);
  53. /** Removes a listener.
  54. @see addListener
  55. */
  56. void removeListener (FileBrowserListener* listener);
  57. //==============================================================================
  58. /** A set of colour IDs to use to change the colour of various aspects of the list.
  59. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  60. methods.
  61. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  62. */
  63. enum ColourIds
  64. {
  65. highlightColourId = 0x1000540, /**< The colour to use to fill a highlighted row of the list. */
  66. textColourId = 0x1000541, /**< The colour for the text. */
  67. };
  68. //==============================================================================
  69. /** @internal */
  70. void sendSelectionChangeMessage();
  71. /** @internal */
  72. void sendDoubleClickMessage (const File& file);
  73. /** @internal */
  74. void sendMouseClickMessage (const File& file, const MouseEvent& e);
  75. protected:
  76. //==============================================================================
  77. DirectoryContentsList& fileList;
  78. ListenerList <FileBrowserListener> listeners;
  79. private:
  80. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DirectoryContentsDisplayComponent)
  81. };