General

Wpy is a document/view model of a GUI.  The most important classes are:

CWinApp, the application.  You must write an application class derived from
this class and provide your own InitInstance method.  See below.  There can
be only one instance of the application class.  Generally, a wpy program
consists of class definitions plus a single line at the end "app=MyApp()"
to instantiate the application class instance.

CScrollView, a scroll view class.  You need to write a view class derived from
one of the CView classes.  CScrollView is a CView with built in scrolling
capabilities.  If the view does not require scrolling, the scroll bars disappear,
so this class is generally useful.

CDocument, a document class.  If your program reads and writes documents to
disk, you will need to derive a document class from this class.

There are many other useful classes such as CDialog, but the above three are
central to the document/view model.  Although a frame class is required, it
is not as important, and does not play a central role.

SDI and MDI Models

Wpy can create Single Document and Multi Document Interface GUI models.  The SDI
model means that the application has only one window with a menu on the screen.
In the MDI model, there are multiple child windows clipped to fit within
a single main window.  Each child window can have a menu, but that menu is displayed on
the main window when the child window is active.  The client area of the main window
is not used except as a background for the child windows.  Either model may also have
an unlimited number of dialog windows.

The choice between SDI and MDI is made in the InitInstance method of your application
class.  The code is mostly boiler plate.  To create a SDI application do the following:

1)  class MyApp(CWinApp):
2)    def InitInstance(self):
3)      templ = CSingleDocTemplate(CDocument, CFrameWnd, MyView, MyMenu)
4)      templ.wpyText = "Usual Hello World Demo"
5)      self.AddDocTemplate(templ)
6)      self.FileNew()

Line 1 derives a class from CWinApp, and line 2 overrides the InitInstance method.
This is required by every wpy app.  Line 3 instantiates a "template" instance from
an SDI template.  The template specifies how to create documents, frames, views and
menus for the application.  You specify the classes from which these objects will be
created.  The document and frame classes are wpy classes, and the view class is
a user-specified class derived (in this example) from CScrollView.  The frame class
for the SDI model must be CFrameWnd, or a user class derived from it.  Line 4 just
specifies a document title.  Note that this is an attribute of the
template.  Line 5 records the template in the application.  Line 6 creates a new
empty document plus its frame and view.  This is the same operation which would
occur if the user selected File/New from a main menu.  Line 6 is required, otherwise
there would be no window to display after InitInstance returns.  When "FileNew()"
is called, the template will be used to make an instance of the four classes
specified, namely CDocumnet, CFrameWnd, MyView and MyMenu.  These classes will be
linked together, and the window will appear on the screen.

Wpy has the concept of a "Main Window".  In SDI the main window is the only window.
In a MDI model things are a little more complicated.  You need different frame classes,
and you use a different template.  To create a MDI application do the following:

1)  class MyApp(CWinApp):
2)    def InitInstance(self):
3)      templ = CMultiDocTemplate(CDocument, CMDIChildWnd, MyView, ScribFrameMenu)
4)      templ.wpyText = "Scribble"
5)      self.AddDocTemplate(templ)
6)      main_frame = CMDIFrameWnd()
7)      main_frame.wpyMenu = ScribMainFrameMenu()
8)      main_frame.Create()
9)      self.FileNew()

Lines 1 and 2 drive an application class and override InitInstance as before.  Line 3
creates a template but this time it is an MDI template with a different frame type
CMDIChildWnd.  This template is responsible for creating child windows.  Line 5
records the doc template as before.  Line 6 makes a main frame window which will act
as a container for all the child windows.  Many wpy objects require two-step creation,
so line 8 actually creates the main window and makes it visible.  Line 9 is optional
in this case, since there is already a main window.  It just creates a single empty
child window.  The menu in Line 3 is an attribute of the template, and is created for
every child window.  The menu in line 7 is an attribute of the main window and will
only be visible if there are no child windows.  Otherwise, the menu shown on the main
window will be that of the active child.

After InitInstance returns, all further interaction with the system will be in response
to events.  So you need to be sure you have set up a main window in InitInstance, and
that all your derived classes have proper message handlers.

