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.

124 lines
4.7KB

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