openshot-audio  0.1.6
juce_FileBasedDocument.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_FILEBASEDDOCUMENT_H_INCLUDED
26 #define JUCE_FILEBASEDDOCUMENT_H_INCLUDED
27 
28 
29 //==============================================================================
50 {
51 public:
59  FileBasedDocument (const String& fileExtension,
60  const String& fileWildCard,
61  const String& openFileDialogTitle,
62  const String& saveFileDialogTitle);
63 
65  virtual ~FileBasedDocument();
66 
67  //==============================================================================
73  bool hasChangedSinceSaved() const { return changedSinceSave; }
74 
85  virtual void changed();
86 
94  void setChangedFlag (bool hasChanged);
95 
96  //==============================================================================
107  Result loadFrom (const File& fileToLoadFrom,
108  bool showMessageOnFailure);
109 
121  Result loadFromUserSpecifiedFile (bool showMessageOnFailure);
122 
123  //==============================================================================
127  {
128  savedOk = 0,
130  failedToWriteToFile
131  };
132 
145  SaveResult save (bool askUserForFileIfNotSpecified,
146  bool showMessageOnFailure);
147 
168  SaveResult saveIfNeededAndUserAgrees();
169 
185  SaveResult saveAs (const File& newFile,
186  bool warnAboutOverwritingExistingFiles,
187  bool askUserForFileIfNotSpecified,
188  bool showMessageOnFailure);
189 
201  SaveResult saveAsInteractive (bool warnAboutOverwritingExistingFiles);
202 
203  //==============================================================================
211  const File& getFile() const { return documentFile; }
212 
219  void setFile (const File& newFile);
220 
221 
222 protected:
223  //==============================================================================
229  virtual String getDocumentTitle() = 0;
230 
234  virtual Result loadDocument (const File& file) = 0;
235 
239  virtual Result saveDocument (const File& file) = 0;
240 
257  virtual File getLastDocumentOpened() = 0;
258 
272  virtual void setLastDocumentOpened (const File& file) = 0;
273 
274  #if JUCE_MODAL_LOOPS_PERMITTED
275 
281  virtual File getSuggestedSaveAsFile (const File& defaultFile);
282  #endif
283 
284 private:
285  //==============================================================================
286  File documentFile;
287  bool changedSinceSave;
288  String fileExtension, fileWildcard, openFileDialogTitle, saveFileDialogTitle;
289 
291 };
292 
293 
294 #endif // JUCE_FILEBASEDDOCUMENT_H_INCLUDED
const File & getFile() const
Definition: juce_FileBasedDocument.h:211
SaveResult
Definition: juce_FileBasedDocument.h:126
Definition: juce_FileBasedDocument.h:49
Definition: juce_String.h:43
Definition: juce_Result.h:61
bool hasChangedSinceSaved() const
Definition: juce_FileBasedDocument.h:73
Definition: juce_ChangeBroadcaster.h:35
#define JUCE_API
Definition: juce_StandardHeader.h:139
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
Definition: juce_FileBasedDocument.h:129
Definition: juce_File.h:45