Important: The information in this document is obsolete and should not be used for new development.
Creating and Initializing the Application Object
Themain
routine's final task is to instantiate and initialize an application object. You define a subclass of one of MacApp's application classes to serve as the application object. The code for creating and initializing the application object looks something the following:
TYourApplication* aYourApplication; aYourApplication = new TYourApplication; aYourApplication->IYourApplication();In the IYourApplication method, you callIApplication
with a line like the following:
this->IApplication(kFileType, kSignature);The constantskSignature
andkFileType
specify an application signature and file type, used by the Macintosh Operating System to identify an application and the files that belong to it. Each application has just one signature but can have many file types, one for each type of file it supports.
The
- IMPORTANT
- Apple's Developer Technical Services (DTS) manages a registry of application signatures and file types. You should register your values with DTS so they won't conflict with those used in other applications. You can register types at the World Wide Web location http://dev.info.apple.com/cftype/main.html.
IApplication
method performs the following initialization tasks for the application:
After calling
- It creates regions to keep track of the cursor and to determine when to show help.
- It creates window and document lists.
- It creates a list to serve as the command queue.
- It creates a dependency space for tracking dependency relationships between application objects.
- It installs a default tab behavior (see "Tabbing Between Views," beginning on page 243).
- It creates an object to manage the application's menu bar.
- It creates a global view server object,
gViewServer
, to manage the creation of view objects for the application (see "The TViewServer Class," beginning on page 218).- If MacApp's UScripting unit hasn't been initialized, it calls
InitUScripting
to initialize it.- It sets the application object to be the default target for the Apple event dispatcher object, which dispatches Apple events to objects in the application.
IApplication
, the IYourApplication method takes care of any initialization specific to your application. That may include using theMA_REGISTER_CLASS
macro to register your view classes. (TheMA_REGISTER_CLASS
macro is described in Chapter 8, "Displaying, Manipulating, and Printing Data.")The next section describes the final steps for initializing MacApp.