juce_FileSearchPathListComponent.h 4.4 KB

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