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.

118 lines
4.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. namespace juce
  20. {
  21. //==============================================================================
  22. /**
  23. A base class for components that display a list of the files in a directory.
  24. @see DirectoryContentsList
  25. @tags{GUI}
  26. */
  27. class JUCE_API DirectoryContentsDisplayComponent
  28. {
  29. public:
  30. //==============================================================================
  31. /** Creates a DirectoryContentsDisplayComponent for a given list of files. */
  32. DirectoryContentsDisplayComponent (DirectoryContentsList& listToShow);
  33. /** Destructor. */
  34. virtual ~DirectoryContentsDisplayComponent();
  35. //==============================================================================
  36. /** The list that this component is displaying */
  37. DirectoryContentsList& directoryContentsList;
  38. //==============================================================================
  39. /** Returns the number of files the user has got selected.
  40. @see getSelectedFile
  41. */
  42. virtual int getNumSelectedFiles() const = 0;
  43. /** Returns one of the files that the user has currently selected.
  44. The index should be in the range 0 to (getNumSelectedFiles() - 1).
  45. @see getNumSelectedFiles
  46. */
  47. virtual File getSelectedFile (int index) const = 0;
  48. /** Deselects any selected files. */
  49. virtual void deselectAllFiles() = 0;
  50. /** Scrolls this view to the top. */
  51. virtual void scrollToTop() = 0;
  52. /** If the specified file is in the list, it will become the only selected item
  53. (and if the file isn't in the list, all other items will be deselected). */
  54. virtual void setSelectedFile (const File&) = 0;
  55. //==============================================================================
  56. /** Adds a listener to be told when files are selected or clicked.
  57. @see removeListener
  58. */
  59. void addListener (FileBrowserListener* listener);
  60. /** Removes a listener.
  61. @see addListener
  62. */
  63. void removeListener (FileBrowserListener* listener);
  64. //==============================================================================
  65. /** A set of colour IDs to use to change the colour of various aspects of the list.
  66. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  67. methods.
  68. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  69. */
  70. enum ColourIds
  71. {
  72. highlightColourId = 0x1000540, /**< The colour to use to fill a highlighted row of the list. */
  73. textColourId = 0x1000541, /**< The colour for the text. */
  74. highlightedTextColourId = 0x1000542 /**< The colour with which to draw the text in highlighted sections. */
  75. };
  76. //==============================================================================
  77. /** @internal */
  78. void sendSelectionChangeMessage();
  79. /** @internal */
  80. void sendDoubleClickMessage (const File&);
  81. /** @internal */
  82. void sendMouseClickMessage (const File&, const MouseEvent&);
  83. protected:
  84. //==============================================================================
  85. ListenerList<FileBrowserListener> listeners;
  86. private:
  87. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DirectoryContentsDisplayComponent)
  88. };
  89. } // namespace juce