[Home] [Prev] [Next] [Up]
The XGAppCore class and it's derivitives provide the encapsulation for the application's event loop, some basic drag and drop functionality, command line argument parsing, and other very basic application behaviours.
There are two primary application classes you should construct your application from. The first is the XGAppSingleWindow class; this creates an application which has only one window. The XGAppSingleWindow class corrisponds to the MS Windows's SDI application.
The second is the XGAppMultiWindow class, which handles multiple window applications. On the Macintosh, this is provides the default behaviour for an application; on Windows, this builds an MDI application.
Creating an application
Normally you create a new application by first, selecting which type of application you want (single window or multiple window).
Second, you would create your own custom class which inherits from the appropriate application class (either XGAppSingleWindow or XGAppMultiWindow).
Third, you would override the RecieveDispatch method to provide the appropriate global menu functions (such as the menu's "Open" and "New" items), to provide the functionality you want.
Fourth, you would optionally override the other methods to provide custom functionality, such as drag and drop file opening.
And fifth, you would do the appropriate initialization in the StartApplication procedure.
Starting your YAAF application
When a YAAF application starts up, either the WinMain() [Win32 API] or the main() [MacOS] routines eventually calls your application-supplied routine StartApplication to get a pointer to the application object representing the application you are running.
How your StartApplication routine should work depends on the type of application you are writing.
In the case of a multiple window application, you simply need to create your application. At that point, all you need to write is:
/* StartApplication * * An example on how to create an XGAppMultiWindow * application. */ XGAppCore *StartApplication(void) { return new TMyApplication; }This example simply creates your application object. Your application object can then perform application-specific initialization in it's constructor.
In the case of a single-window application, things get harder. After your application is initialized, you need to create the XGWindow object which works with your application, and optionally create the document object.
In that case, you would write:
/* StartApplication * * An example on how to create an XGAppSingleWindow * application. */ XGAppCore *StartApplication(void) { TMyApplication *app; XGWindow *w; // XGDocument *doc; -- optional // First, create my application app = new TMyApplication; // Second, optionally create my document (this needs work) // doc = new TMyDocument; -- optional // Third, I must create my main single window here. w = XGWindow::Create(128); // Assume 'VRes'#128 resource // ANd fourth, associate the document (if there is one) // w->SetDocument(doc); -- optional // And return. return app; }
Classes
The core application engine. This provides the basic event loop and argument processing methods used by all applications.
This class overrides the needed fields in the XGAppCore to provide a single window application. Your application class would derive from either this class or the XGAppMultiWindow class (below) to provide your basic application processing.
This class provides multiple window application support, such as with the default Mac behaviour, or with Windows MDI applications.