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.

110 lines
3.9KB

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