wxDocview vs. wxWidgets

If you are familiar with wxWidget you may have recognized that this portable GUI toolkit also delivers a document/ view framework in its standard distribution. So, why another document/ view framework?

Motivation

The reason to develop this framework was that the wxWidget doc/view architecture is heavily related to the interface you want to use for your application (i.e. MDI or SDI). Views are responsible for creating the windows and frames that they use for displaying document data. This makes views only useable for the one type of application.

If you develop a MDI application your views rely on the MDI classes and you will have to do a lot of work if you want switch to another interface, i.e. SDI, because the views are related to a wxDocMDIChildFrame, for example. Therefore you can not write general view classes that can be used in any type of application.

Imagine someone has written a nice viewing class to display the content of an HTML document. Of course one would like to make this viewing class part of a library that includes the HTML document class, plus its viewing classes. The trouble in that case is that the view class creates a window and frame for one type of application, this makes it impossible to use it in another type of application.

Alternative Approach

This framework has another approach: A view is independent from a frame, it is only interested in one window, which it will use for displaying data from a document. Where this window is situated in the application is not important for the view. A view knows nothing about the user interface, it may be MDI, SDI etc.. You can use a view with several user interfaces; the view is connected to a specific interface (window or frame) at runtime by a view connector. After creation of a new view, a view connector class is used to generate or use an existing window for the view, and if needed, it will also create the (child)frame to be used as parent for the new window. Now a view only needs to know its display window, which it uses for displaying document data, and for sending events up to that window, including parent windows or frames. The view connector is responsible for connecting of a view into the application, and this makes a view application independent.

Because of this a view can easily be used in all types of applications, and therefore be made part of a library. In the wxArt2D library, a view called a2dCanvasView is used to display the content of a a2dCanvasDocument, on a a2dCanvas window. a2dCanvasView is only aware of one window, which is a2dCanvas. It does not know, if the application is SDI or MDI, or any other. This way of connecting views works very well when reusing the same windows in one frame for displaying several document plus views. All that is needed is to disconnect the old views from the windows in a frame and connect the new ones.

Benefits

The wxDocview framework is an improvement over the wxWidgets Docview classes for the following reasons:

DocviewWxWidgets (last edited 2011-03-05 21:00:42 by MichaelStratmann)