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.

116 lines
4.3KB

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