LApplication is a PowerPlant class that is used for encapsulating the common behaviors of a typical Mac OS application.
Methods :
The methods in this class are:
Data Members:
The data members in this class are:
Operation:
You create a single object of this class in your application. This object manages the execution of the application program. It handles initialization, destruction, the main event loop, application-level events using LEventDispatcher , Apple Events, updating of the menu bar, cursor adjustment, and printing of documents.
Source files:
See also:
LMenuBar
Purpose:
The constructor initializes parameters such as the default event loop sleep time, Color QuickDraw, and some PowerPlant-specific parameters.
Access:
Prototype:
LApplication();Parameters:
Purpose:
The destructor destroys the application object.
Access:
Prototype:
virtual ~LApplication();Parameters:
Purpose:
This method counts the number of windows or documents open in the application.
Access:
Prototype:
virtual SInt32 CountSubModels( DescType inModelID ) const;Parameters:
The parameter for this method is:
Return:
SInt32 indicating the number of open windows (if inModelID == cWindow) or open documents.
Purpose:
Quit the Application, if the conditions specified by AttemptQuit() in LCommander() are met.
Access:
Prototype:
virtual void DoQuit( SInt32 inSaveOption );Parameters:
The parameter for this method is:
|
Return:
Purpose:
Pass back status information on whether a Command is enabled and/or marked in a Menu.
Access:
Prototype:
virtual void FindCommandStatus( CommandT inCommand,Parameters:
Boolean &outEnabled,
Boolean &outUsesMark,
USInt16 &outMark,
Str255 outName);
The parameters for this method are:
Return:
Purpose:
Return the position (1 means the first) of an Apple Event SubModel within an Application.
Access:
Prototype:
virtual SInt32 GetPositionOfSubModel(Parameters:
DescType inModelID,
const LModelObject *inSubModel) const;
The parameters for this method are:
Return:
SInt32 containing the position of the Apple Event SubModel.
Purpose:
This method returns the value of the mState data member.
Access:
Prototype:
EProgramState GetState() const;Parameters:
Return:
EProgramState containing the value of mState.
Purpose:
Pass back a token to an Apple Event SubModel specified by name.
Access:
Prototype:
virtual void GetSubModelByName( DescType inModelID,Parameters:
Str255 inName,
AEDesc &outToken) const;
The parameters for this method are:
Return:
Purpose:
Get the token of an Apple Event SubModel specified by its position.
Access:
Prototype:
virtual void GetSubModelByPosition(Parameters:
DescType inModelID,
SInt32 inPosition,
AEDesc &outToken) const;
The parameters for this method are:
Return:
Purpose:
This method handles the Apple Events that are sent to the application.
Access:
Prototype:
virtual void HandleAppleEvent(Parameters:
const AppleEvent &inAppleEvent,
AppleEvent &outAEReply,
AEDesc &outResult,
long inAENumber);
The parameters for this method are:
Purpose:
Calling this method provides a last chance to initialize the application before event processing begins.
Access:
Prototype:
virtual void Initialize();Parameters:
Return:
Purpose:
Create the MenuBar object for the application. You should override this to use a class other than LMenuBar.
Access:
Prototype:
virtual void MakeMenuBar();Parameters:
Return:
Purpose:
Create ModelDirector (an AppleEvent handle) object for the application. You should override this if you want to use a class other than LModelDirector.
Access:
Prototype:
virtual void MakeModelDirector();Parameters:
Return:
Purpose:
Make an Object Specifier for the application.
Access:
Prototype:
virtual void MakeSelfSpecifier(Parameters:
AEDesc& inSuperSpecifier,
AEDesc& outSelfSpecifier) const;
The parameters for this method are:
Return:
Purpose:
Process commands that are generated when running the application.
Access:
Prototype:
virtual Boolean ObeyCommand( CommandT inCommand,Parameters:
void *ioParam);
The parameters for this method are:
Return:
A Boolean containing true if the command was handled by this call, and false otherwise.
Purpose:
Retrieve and handle the next event in the application event queue. This includes letting Attachments process the event, updating menu item status, and calling Repeaters.
Access:
Prototype:
virtual void ProcessNextEvent();Parameters:
Return:
Purpose:
Run the Application by processing events until quitting. This includes doing some menu management, cursor updating, and other housekeeping.
Access:
Prototype:
virtual void Run();Parameters:
Return:
Remarks:
You should catch all exceptions in your code. If an exception occurs when calling ProcessNextEvent(), a signal will occur and the application will continue running.
Purpose:
Sends a Quit AppleEvent to this application.
Access:
Prototype:
virtual void SendAEQuit();Parameters:
Return:
Purpose:
This method sets the value of the mSleepTime data member.
Access:
Prototype:
void SetSleepTime( SInt32 inSleepTime);Parameters:
The parameter for this method is:
|
Return:
Purpose:
Display the About Box for the application. This basic implementation just puts up an Alert Box. You should override this if you wish to display a more elaborate About Box.
Access:
Prototype:
virtual void ShowAboutBox();Parameters:
Return:
Purpose:
This method is meant to provide a place to perform actions at application start up when launched without any documents. You should override this if you wish to instead perform some default action, such as creating a new, untitled document.
Access:
Prototype:
virtual void StartUp();Parameters:
Return:
Purpose:
This data member contains a value signifying the state of the
program, such as programState_StartingUp.
Access:
Prototype:
EProgramState mState;
Purpose:
This data member contains the overridable value of the sleep time parameter for the main event loop. This member is set to a default value by the constructor.
Access:
Prototype:
long mSleepTime;