JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
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) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29//==============================================================================
51class JUCE_API FileBasedDocument : public ChangeBroadcaster
52{
53public:
61 FileBasedDocument (const String& fileExtension,
62 const String& fileWildCard,
63 const String& openFileDialogTitle,
64 const String& saveFileDialogTitle);
65
68
69 //==============================================================================
75 bool hasChangedSinceSaved() const;
76
87 virtual void changed();
88
96 void setChangedFlag (bool hasChanged);
97
98 //==============================================================================
109 Result loadFrom (const File& fileToLoadFrom,
110 bool showMessageOnFailure,
111 bool showWaitCursor = true);
112
124 void loadFromAsync (const File& fileToLoadFrom,
125 bool showMessageOnFailure,
126 std::function<void (Result)> callback);
127
128 #if JUCE_MODAL_LOOPS_PERMITTED
140 Result loadFromUserSpecifiedFile (bool showMessageOnFailure);
141 #endif
142
153 void loadFromUserSpecifiedFileAsync (bool showMessageOnFailure, std::function<void (Result)> callback);
154
155 //==============================================================================
159 {
160 savedOk = 0,
162 failedToWriteToFile
163 };
164
165 #if JUCE_MODAL_LOOPS_PERMITTED
178 SaveResult save (bool askUserForFileIfNotSpecified,
179 bool showMessageOnFailure);
180 #endif
181
195 void saveAsync (bool askUserForFileIfNotSpecified,
196 bool showMessageOnFailure,
197 std::function<void (SaveResult)> callback);
198
199 #if JUCE_MODAL_LOOPS_PERMITTED
220 SaveResult saveIfNeededAndUserAgrees();
221 #endif
222
243 void saveIfNeededAndUserAgreesAsync (std::function<void (SaveResult)> callback);
244
245 #if JUCE_MODAL_LOOPS_PERMITTED
263 SaveResult saveAs (const File& newFile,
264 bool warnAboutOverwritingExistingFiles,
265 bool askUserForFileIfNotSpecified,
266 bool showMessageOnFailure,
267 bool showWaitCursor = true);
268 #endif
269
287 void saveAsAsync (const File& newFile,
288 bool warnAboutOverwritingExistingFiles,
289 bool askUserForFileIfNotSpecified,
290 bool showMessageOnFailure,
291 std::function<void (SaveResult)> callback);
292
293 #if JUCE_MODAL_LOOPS_PERMITTED
305 SaveResult saveAsInteractive (bool warnAboutOverwritingExistingFiles);
306 #endif
307
320 void saveAsInteractiveAsync (bool warnAboutOverwritingExistingFiles,
321 std::function<void (SaveResult)> callback);
322
323 //==============================================================================
331 const File& getFile() const;
332
339 void setFile (const File& newFile);
340
341protected:
342 //==============================================================================
349
353 virtual Result loadDocument (const File& file) = 0;
354
364 virtual void loadDocumentAsync (const File& file, std::function<void (Result)> callback);
365
369 virtual Result saveDocument (const File& file) = 0;
370
380 virtual void saveDocumentAsync (const File& file, std::function<void (Result)> callback);
381
399
413 virtual void setLastDocumentOpened (const File& file) = 0;
414
421 virtual File getSuggestedSaveAsFile (const File& defaultFile);
422
423private:
424 //==============================================================================
425 class Pimpl;
427
429};
430
431} // namespace juce
Holds a list of ChangeListeners, and sends messages to them when instructed.
A class to take care of the logic involved with the loading/saving of some kind of document.
virtual Result loadDocument(const File &file)=0
This method should try to load your document from the given file.
~FileBasedDocument() override
Destructor.
virtual String getDocumentTitle()=0
Overload this to return the title of the document.
SaveResult
A set of possible outcomes of one of the save() methods.
@ userCancelledSave
indicates that the user aborted the save operation.
virtual Result saveDocument(const File &file)=0
This method should try to write your document to the given file.
virtual void setLastDocumentOpened(const File &file)=0
This is used for dialog boxes to make them open at the last folder you were using.
virtual File getLastDocumentOpened()=0
This is used for dialog boxes to make them open at the last folder you were using.
Represents a local file or directory.
Definition juce_File.h:45
Represents the 'success' or 'failure' of an operation, and holds an associated error message to descr...
Definition juce_Result.h:57
The JUCE String class!
Definition juce_String.h:53
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
JUCE Namespace.