> FROM: Marcus
> DATE: 10/18/2002=A016:16:18
> SUBJECT: [wxperl-users] Document/View framework
>
>
> What is the Document/View framework, and what can you do with it?
> I know it was in the last beta, but I didn't discover any info.
Hi Marcus,
I'll try and explain the purpose of Document/View, but you should also=20
look at the Document/View overview and the following classes in the=20
wxWindows docs:
wxDocManager, wxDocument, wxView, wxDocTemplate.
There is also wxDocParentFrame, wxDocChildFrame, wxDocMDIParentFrame,=20
wxDocMDIChildFrame and wxFileHistory. And there are a couple of docview=20
samples in wxwindows/samples: docview and docvwmdi.
BTW, I have a sample wxperl docview app, which I'll post on Jouke's=20
wxperl wiki, it's probably not suitable for the wxperl dist. If I have=20
some time, I'll put something together for the dist with Mattia's=20
approval/guidelines.
Basically the Document/View framework is a set of objects that facilitate=
=20
writing applications that behave like document editors. Something like an=
=20
HTML editor or a Perl IDE or even a graphics app, are ideal candidates.
Consider what you need (or ought) to impliment when writing such an=20
application: you need a way of tracking which files are open, what their=20
filenames are, have they been modified since the last save, etc. You need=
=20
to install event handlers for toolbars and menus, etc. You need to know=20
which document is the current document. You might write some code to=20
impliment a file history. The list goes on. These are common tasks for=20
all these applications. So why write them each time you write such a=20
piece of software? Well, you don't need to if you use document/view.
Here is a list again of the important classes (in Perl this time):
Wx::DocManager :
The "Master" class. maintains lists of documents, handles events
such as OnFileNew, OnFileOpen, OnFileSave, etc. It calls methods
in the other classes
Wx::DocTemplate
This expresses a relationship between a Wx::Document and a
Wx::View (You can have multiple views for a document)
Wx::Document
You subclass this for your particular document type. How you
load and save the file, is it modified, etc. Also has
OnSaveDoc.. and other events
Wx::View
This class defines how you want the document to be viewed/edited
on the screen, are you using a Wx::TextCtrl, Wx::Canvas or a
Wx::StyledTextControl?
If you're writing a document/view app, you'll need to use/subclass all of=
=20
them, and also use a wxDocParentFrame or wxDocMDIParentFrame if you are=20
allowing multiple documents.
Really it would be best to see an example. I will post my sample on=20
Monday. But in the meantime if it still sounds interesting, check out the=
=20
samples that come with wxWindows.
The wxwindows docview overview is also available here:
http://makeashorterlink.com/?X12921E22
Simon
|