LMMS
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//==============================================================================
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 //==============================================================================
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;
426 std::unique_ptr<Pimpl> pimpl;
427
429};
430
431} // namespace juce
ChangeBroadcaster() noexcept
Definition juce_ChangeBroadcaster.cpp:26
Definition juce_FileBasedDocument.cpp:31
void loadFromAsync(const File &fileToLoadFrom, bool showMessageOnFailure, std::function< void(Result)> callback)
Definition juce_FileBasedDocument.cpp:992
virtual Result loadDocument(const File &file)=0
~FileBasedDocument() override
virtual void changed()
Definition juce_FileBasedDocument.cpp:979
bool hasChangedSinceSaved() const
Definition juce_FileBasedDocument.cpp:969
virtual void loadDocumentAsync(const File &file, std::function< void(Result)> callback)
Definition juce_FileBasedDocument.cpp:1097
void loadFromUserSpecifiedFileAsync(bool showMessageOnFailure, std::function< void(Result)> callback)
Definition juce_FileBasedDocument.cpp:1007
virtual File getSuggestedSaveAsFile(const File &defaultFile)
Definition juce_FileBasedDocument.cpp:1113
virtual String getDocumentTitle()=0
Result loadFrom(const File &fileToLoadFrom, bool showMessageOnFailure, bool showWaitCursor=true)
Definition juce_FileBasedDocument.cpp:985
std::unique_ptr< Pimpl > pimpl
Definition juce_FileBasedDocument.h:426
virtual void saveDocumentAsync(const File &file, std::function< void(Result)> callback)
Definition juce_FileBasedDocument.cpp:1105
SaveResult
Definition juce_FileBasedDocument.h:159
@ userCancelledSave
Definition juce_FileBasedDocument.h:161
@ failedToWriteToFile
Definition juce_FileBasedDocument.h:162
@ savedOk
Definition juce_FileBasedDocument.h:160
void setChangedFlag(bool hasChanged)
Definition juce_FileBasedDocument.cpp:974
virtual Result saveDocument(const File &file)=0
virtual void setLastDocumentOpened(const File &file)=0
virtual File getLastDocumentOpened()=0
FileBasedDocument(const String &fileExtension, const String &fileWildCard, const String &openFileDialogTitle, const String &saveFileDialogTitle)
Definition juce_FileBasedDocument.cpp:954
Definition juce_File.h:45
Definition juce_Result.h:57
Definition juce_String.h:53
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
#define JUCE_API
Definition juce_StandardHeader.h:152
Definition carla_juce.cpp:31
RECT const char void(* callback)(const char *droppath))) SWELL_API_DEFINE(BOOL
Definition swell-functions.h:1004
static LV2_State_Status save(LV2_Handle instance, LV2_State_Store_Function store, void *callback_data, uint32_t flags, const LV2_Feature *const *features)
Definition test.c:161
struct zdirent * file
Definition win32.c:1500