[Home] [Prev] [Next] [Up]


XGAppCore class

Base application core for the YAAF application framework.

Usage:

#include <XApplication.h>

class XGAppCore;

Description

This provides the encapsulation of the application framework. While you would normally not build an application by deriving directly from this class, it does provide the methods and virtual callbacks which you need to derive from or use to provide basic application functionality.

Construction/Destruction

XGAppCore::XGAppCore()

This initializes the host OS.

XGAppCore::~XGAppCore()

This shuts down the host OS.

Initialization callback methods

When your application is started up, your application can receive a message specifying the files to open (on the Macintosh) or optional command-line arguments (on Windows). Instead of trying to provide some standard interface, I simply provide a different method interface depending on which OS the application is running under.

On the Macintosh, this provides the basic interface to the Core AppleEvent classes required for opening a file from Finder. And on Windows, this simply returns the parsed command-line arguments.

long XGAppCore::Open(FSSpec *f)

(MacOS) This requests the specified file needs to be opened. If there was an error, return the appropriate MacOS error code.

long XGAppCore::Print(FSSpec *f)

(MacOS) This requests the specified file be printed.

long XGAppCore::New(void)

(MacOS) If the application is started up without any files specified, this method gets called. This can be used to open a new file if one is not specified.

long XGAppCore::Quit(void)

(MacOS) This method is called when the AppleEvent for quitting this application is requested. By default this closes all the windows (attempting to save them first). If you override this method and wish to provide the default functionality of closing the different windows, you need to call the XGAppCore::Quit method first.

(WinOS) This method is called when the application's close box is clicked, and otherwise works just like the MacOS counterpart.

void XGAppCore::CommandLine(short argc, char **argv)

(WinOS) This method is called when the Windows application is started up; this specifies the command-line arguments.

Event Filtering

bool XGAppCore::FilterEvent(EventRecord *event)
bool XGAppCore::FilterEvent(MSG *event)

This method is called just before an event is dispatched. The first version is MacOS specific; the second is a WinOS specific version.

This gives the application the chance to trap the event and not dispatch the event; return true if the event is not to be processed.

By default, the method returns false.

Event Loop

void XGAppCore::Run(void)

This starts the event loop. This doesn't quit until the quit flag is set by the XGAppCore::Exit method. Normally you don't need to deal with this method.

void XGAppCore::Exit(void)

This ends the event loop by setting an internal flag. If you wish to prematurely end the application through an orderly shutdown, you should call this method. If you want to orderly close all the windows first, you should call the Quit method instead. (see above)

Support Routines

void XGAppCore::ShowCopyright(void)

This shows a copyright notice. You would override this method if you want to provide your own copyright notice.


[Home] [Prev] [Next] [Up]