juce_DirectoryContentsDisplayComponent.h 4.1 KB

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