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.

117 lines
4.5KB

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