openshot-audio  0.1.2
juce_FileBrowserComponent.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_FILEBROWSERCOMPONENT_H_INCLUDED
26 #define JUCE_FILEBROWSERCOMPONENT_H_INCLUDED
27 
28 
29 //==============================================================================
40  private FileBrowserListener,
41  private TextEditorListener,
42  private ButtonListener,
43  private ComboBoxListener, // (can't use ComboBox::Listener due to idiotic VC2005 bug)
44  private FileFilter
45 {
46 public:
47  //==============================================================================
53  {
54  openMode = 1,
56  saveMode = 2,
58  canSelectFiles = 4,
60  canSelectDirectories = 8,
62  canSelectMultipleItems = 16,
63  useTreeView = 32,
64  filenameBoxIsReadOnly = 64,
65  warnAboutOverwriting = 128,
66  doNotClearFileNameOnRootChange = 256
67  };
68 
69  //==============================================================================
85  const File& initialFileOrDirectory,
86  const FileFilter* fileFilter,
87  FilePreviewComponent* previewComp);
88 
91 
92  //==============================================================================
97  int getNumSelectedFiles() const noexcept;
98 
104  File getSelectedFile (int index) const noexcept;
105 
108  void deselectAllFiles();
109 
117  bool currentFileIsValid() const;
118 
125  File getHighlightedFile() const noexcept;
126 
127  //==============================================================================
129  const File& getRoot() const;
130 
132  void setRoot (const File& newRootDirectory);
133 
135  void setFileName (const String& newName);
136 
138  void goUp();
139 
141  void refresh();
142 
144  void setFileFilter (const FileFilter* newFileFilter);
145 
151  virtual String getActionVerb() const;
152 
155  bool isSaveMode() const noexcept;
156 
161  void setFilenameBoxLabel (const String& name);
162 
163  //==============================================================================
167  void addListener (FileBrowserListener* listener);
168 
172  void removeListener (FileBrowserListener* listener);
173 
179  static void getDefaultRoots (StringArray& rootNames, StringArray& rootPaths);
180 
181  //==============================================================================
186  {
187  virtual ~LookAndFeelMethods() {}
188 
189  // These return a pointer to an internally cached drawable - make sure you don't keep
190  // a copy of this pointer anywhere, as it may become invalid in the future.
191  virtual const Drawable* getDefaultFolderImage() = 0;
192  virtual const Drawable* getDefaultDocumentFileImage() = 0;
193 
194  virtual AttributedString createFileChooserHeaderText (const String& title,
195  const String& instructions) = 0;
196 
197  virtual void drawFileBrowserRow (Graphics&, int width, int height,
198  const String& filename,
199  Image* optionalIcon,
200  const String& fileSizeDescription,
201  const String& fileTimeDescription,
202  bool isDirectory,
203  bool isItemSelected,
204  int itemIndex,
206 
207  virtual Button* createFileBrowserGoUpButton() = 0;
208 
209  virtual void layoutFileBrowserComponent (FileBrowserComponent& browserComp,
210  DirectoryContentsDisplayComponent* fileListComponent,
211  FilePreviewComponent* previewComp,
212  ComboBox* currentPathBox,
213  TextEditor* filenameBox,
214  Button* goUpButton) = 0;
215  };
216 
217  //==============================================================================
219  void resized() override;
221  void buttonClicked (Button*) override;
223  void comboBoxChanged (ComboBox*) override;
225  void textEditorTextChanged (TextEditor&) override;
227  void textEditorReturnKeyPressed (TextEditor&) override;
229  void textEditorEscapeKeyPressed (TextEditor&) override;
231  void textEditorFocusLost (TextEditor&) override;
233  bool keyPressed (const KeyPress&) override;
235  void selectionChanged() override;
237  void fileClicked (const File&, const MouseEvent&) override;
239  void fileDoubleClicked (const File&) override;
241  void browserRootChanged (const File&) override;
243  bool isFileSuitable (const File&) const override;
245  bool isDirectorySuitable (const File&) const override;
246 
248  FilePreviewComponent* getPreviewComponent() const noexcept;
249 
251  DirectoryContentsDisplayComponent* getDisplayComponent() const noexcept;
252 
253 protected:
259  virtual void getRoots (StringArray& rootNames, StringArray& rootPaths);
260 
262  void resetRecentPaths();
263 
264 private:
265  //==============================================================================
267  const FileFilter* fileFilter;
268 
269  int flags;
270  File currentRoot;
271  Array<File> chosenFiles;
273 
275  FilePreviewComponent* previewComp;
276  ComboBox currentPathBox;
277  TextEditor filenameBox;
278  Label fileLabel;
279  ScopedPointer<Button> goUpButton;
280 
281  TimeSliceThread thread;
282 
283  void sendListenerChangeMessage();
284  bool isFileOrDirSuitable (const File& f) const;
285 
287 };
288 
289 
290 
291 #endif // JUCE_FILEBROWSERCOMPONENT_H_INCLUDED
Definition: juce_TextEditor.h:280
Definition: juce_DirectoryContentsDisplayComponent.h:35
Definition: juce_KeyPress.h:37
virtual ~LookAndFeelMethods()
Definition: juce_FileBrowserComponent.h:187
virtual void fileClicked(const File &file, const MouseEvent &e)=0
virtual bool isDirectorySuitable(const File &file) const =0
#define noexcept
Definition: juce_CompilerSupport.h:141
virtual void buttonClicked(Button *)=0
virtual bool isFileSuitable(const File &file) const =0
Definition: juce_Button.h:39
Definition: juce_FileFilter.h:42
Definition: juce_String.h:43
#define JUCE_API
Definition: juce_StandardHeader.h:139
virtual void selectionChanged()=0
Definition: juce_FileBrowserComponent.h:185
#define const
FileChooserFlags
Definition: juce_FileBrowserComponent.h:52
virtual void resized()
Definition: juce_Component.cpp:2272
there are legal restrictions on arithmetic coding Invalid progressive parameters caller expects u Cannot quantize more than d color components Adobe APP14 flags
Definition: juce_JPEGLoader.cpp:127
Definition: juce_Label.h:34
bool keyPressed(const KeyPress &) override
Definition: juce_Button.cpp:616
virtual void textEditorTextChanged(TextEditor &)
Definition: juce_TextEditor.h:287
ComponentFlags flags
Definition: juce_Component.h:2279
Definition: juce_FilePreviewComponent.h:41
Definition: juce_ComboBox.h:284
virtual void textEditorFocusLost(TextEditor &)
Definition: juce_TextEditor.h:296
Definition: juce_Component.h:33
Definition: juce_TextEditor.h:38
Definition: juce_AttributedString.h:39
Definition: juce_Button.h:162
png_const_structrp png_const_inforp int png_fixed_point * width
Definition: juce_PNGLoader.cpp:2339
Definition: juce_StringArray.h:39
Definition: juce_FileBrowserComponent.h:39
Definition: juce_Drawable.h:35
Definition: juce_FileBrowserListener.h:35
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
Definition: juce_TimeSliceThread.h:84
Definition: juce_GraphicsContext.h:42
virtual void textEditorReturnKeyPressed(TextEditor &)
Definition: juce_TextEditor.h:290
Definition: juce_Image.h:54
virtual void browserRootChanged(const File &newRoot)=0
virtual void comboBoxChanged(ComboBox *comboBoxThatHasChanged)=0
virtual void fileDoubleClicked(const File &file)=0
Definition: juce_ComboBox.h:44
virtual void textEditorEscapeKeyPressed(TextEditor &)
Definition: juce_TextEditor.h:293
Definition: juce_File.h:45
Definition: juce_MouseEvent.h:36