wxWidgets / wxWidgets

Cross-Platform C++ GUI Library
https://www.wxwidgets.org/
5.78k stars 1.7k forks source link

Refactoring of Document Open/Save Procedures #6733

Closed wxtrac closed 2 years ago

wxtrac commented 19 years ago

Issue migrated from trac ticket # 6733

priority: normal

2004-07-01 19:54:16: rick_brice created the issue


The purpose of this patch is to refactor the overall procedure of opening and saving a document from the actual details of opening a file stream and reading/writing data.

wxDocument::OnOpenDocument and wxDocument::OnSaveDocument provide the overall procedure for opening and saving a document. This procedure includes managing the “modified” state of the document and notifying views. If LoadObject/SaveObject are not adequate for the application being developed you must replace, in its entirety, the functionality of OnOpenDocument and OnSaveDocument.

With this patch, I propose the addition of two virtual methods, DoOpenDocument and DoSaveDocument. The purpose of these methods is to provide a developer functions to override to replace only the portion of the open/save procedure that deals with the actual opening of a file stream and reading/writing data.

OnOpenDocument and OnSaveDocument will be modified to call DoOpenDocument and DoSaveDocument as a step in the overall load/save procedure. DoOpenDocument and DoSaveDocument will create the appropriate stream object and call LoadObject/SaveObject. Therefore, the default behavior of the framework remains unchanged.

To replace only the functionality of creating a file stream and reading/writing data, a developer can override DoOpenDocument and DoSaveDocument without having to copy and paste the code in OnOpen/SaveDocument to deal with managing the “modified” flag and notifying views.

This change will make wxWidgets Doc/View model more flexible while maintain its current default behavior.

wxtrac commented 19 years ago

2004-07-01 19:54:16: rick_brice uploaded file wxDocument.patch (5.5 KiB)

Patch to wxDocument that implements proposed change

wxtrac commented 19 years ago

2004-07-25 17:41:37: @vadz commented


your patch was applied to the cvs trunk, thanks!