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.

122 lines
4.6KB

  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_FILESEARCHPATHLISTCOMPONENT_JUCEHEADER__
  18. #define __JUCE_FILESEARCHPATHLISTCOMPONENT_JUCEHEADER__
  19. #include "../widgets/juce_ListBox.h"
  20. #include "../buttons/juce_DrawableButton.h"
  21. #include "../buttons/juce_TextButton.h"
  22. #include "../mouse/juce_FileDragAndDropTarget.h"
  23. //==============================================================================
  24. /**
  25. Shows a set of file paths in a list, allowing them to be added, removed or
  26. re-ordered.
  27. @see FileSearchPath
  28. */
  29. class JUCE_API FileSearchPathListComponent : public Component,
  30. public SettableTooltipClient,
  31. public FileDragAndDropTarget,
  32. private ButtonListener, // (can't use Button::Listener due to idiotic VC2005 bug)
  33. private ListBoxModel
  34. {
  35. public:
  36. //==============================================================================
  37. /** Creates an empty FileSearchPathListComponent. */
  38. FileSearchPathListComponent();
  39. /** Destructor. */
  40. ~FileSearchPathListComponent();
  41. //==============================================================================
  42. /** Returns the path as it is currently shown. */
  43. const FileSearchPath& getPath() const noexcept { return path; }
  44. /** Changes the current path. */
  45. void setPath (const FileSearchPath& newPath);
  46. /** Sets a file or directory to be the default starting point for the browser to show.
  47. This is only used if the current file hasn't been set.
  48. */
  49. void setDefaultBrowseTarget (const File& newDefaultDirectory);
  50. /** A set of colour IDs to use to change the colour of various aspects of the label.
  51. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  52. methods.
  53. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  54. */
  55. enum ColourIds
  56. {
  57. backgroundColourId = 0x1004100, /**< The background colour to fill the component with.
  58. Make this transparent if you don't want the background to be filled. */
  59. };
  60. //==============================================================================
  61. /** @internal */
  62. int getNumRows() override;
  63. /** @internal */
  64. void paintListBoxItem (int rowNumber, Graphics& g, int width, int height, bool rowIsSelected) override;
  65. /** @internal */
  66. void deleteKeyPressed (int lastRowSelected) override;
  67. /** @internal */
  68. void returnKeyPressed (int lastRowSelected) override;
  69. /** @internal */
  70. void listBoxItemDoubleClicked (int row, const MouseEvent&) override;
  71. /** @internal */
  72. void selectedRowsChanged (int lastRowSelected) override;
  73. /** @internal */
  74. void resized() override;
  75. /** @internal */
  76. void paint (Graphics&) override;
  77. /** @internal */
  78. bool isInterestedInFileDrag (const StringArray&) override;
  79. /** @internal */
  80. void filesDropped (const StringArray& files, int, int) override;
  81. /** @internal */
  82. void buttonClicked (Button*) override;
  83. private:
  84. //==============================================================================
  85. FileSearchPath path;
  86. File defaultBrowseTarget;
  87. ListBox listBox;
  88. TextButton addButton, removeButton, changeButton;
  89. DrawableButton upButton, downButton;
  90. void changed();
  91. void updateButtons();
  92. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileSearchPathListComponent)
  93. };
  94. #endif // __JUCE_FILESEARCHPATHLISTCOMPONENT_JUCEHEADER__