CPObjectCPResponder
CPApplication
@implementation CPApplication : CPResponder
CPApplication is THE way to start up the Cappucino framework for your application to use.
Every GUI application has exactly one instance of CPApplication (or of a custom subclass of
CPApplication). Your program's main() function can create that instance by calling the
CPApplicationMain
function. A simple example looks like this:
function main(args, namedArgs) { CPApplicationMain(args, namedArgs); }
Method Summary | |
---|---|
+(CPApplication) | sharedApplication Returns the singleton instance of the running application. |
-(id) | init Initializes the Document based application with basic menu functions. |
-(void) | abortModal Aborts the event loop started by runModalForWindow: . |
-(CPArray) | arguments |
-(CPModalSession) | beginModalSessionForWindow:(CPWindow)aWindow Sets up a modal session with theWindow . |
-(void) | beginSheet:(CPWindow)aSheet modalForWindow:(CPWindow)aWindow modalDelegate:(id)aModalDelegate didEndSelector:(SEL)aDidEndSelector contextInfo:(id)aContextInfo Displays a window as a sheet. |
-(id) | delegate Returns the application's delegate. |
-(void) | doCommandBySelector:(SEL)aSelector The receiver will attempt to perform the command, if it responds to it. |
-(void) | finishLaunching This method is called by run before the event loop begins. |
-(CPWindow) | keyWindow Returns the key window. |
-(CPMenu) | mainMenu Returns the application's main menu. |
-(CPWindow) | mainWindow Returns the main window. |
-(CPWindow) | modalWindow Returns the window for the current modal session. |
-(CPDictionary) | namedArguments |
-(void) | run Calls finishLaunching method which results in starting
the main event loop. |
-(void) | runModalForWindow:(CPWindow)aWindow Starts a modal event loop for aWindow . |
-(void) | runModalSession:(CPModalSession)aModalSession Runs a modal session. |
-(BOOL) | sendAction:(SEL)anAction to:(id)aTarget from:(id)aSender Sends an action to a target. |
-(void) | sendEvent:(CPEvent)anEvent Dispatches events to other objects. |
-(void) | setCallback:(Function)aCallback forNextEventMatchingMask:(unsigned int)aMask untilDate:(CPDate)anExpiration inMode:(CPString)aMode dequeue:(BOOL)shouldDequeue |
-(void) | setDelegate:(id)aDelegate Sets the delegate for this application. |
-(void) | setMainMenu:(CPMenu)aMenu Sets the main menu for the application. |
-(CPEvent) | setTarget:(id)aTarget selector:(SEL)aSelector forNextEventMatchingMask:(unsigned int)aMask untilDate:(CPDate)anExpiration inMode:(CPString)aMode dequeue:(BOOL)shouldDequeue |
-(void) | stopModal Stops the modal event loop. |
-(void) | stopModalWithCode:(int)aCode Stops the event loop started by runModalForWindow: and
sets the code that runModalForWindow: will return. |
-(id) | targetForAction:(SEL)anAction Looks for a target that can handle the specified action. |
-(id) | targetForAction:(SEL)anAction to:(id)aTarget from:(id)aSender Finds a target for the specified action. |
-(BOOL) | tryToPerform:(SEL)anAction with:(id)anObject Tries to perform the action with an argument. |
-(CPWindow) | windowWithWindowNumber:(int)aWindowNumber Returns the CPWindow object corresponding to aWindowNumber . |
-(CPArray) | windows Returns an array of the application's CPWindow s. |
Delegate Method Summary | |
---|---|
-(void) | applicationDidFinishLaunching:(CPNotification)aNotification Sent from the notification center after the app initializes, but before receiving events. |
-(void) | applicationWillFinishLaunching:(CPNotification)aNotification Sent from the notification center before the app is initialized. |
Function Summary | |
---|---|
void | CPApplicationMain(args, namedArgs) Starts the GUI and Cappuccino frameworks. |
Method Detail |
---|
+(CPApplication)sharedApplication
-(id)init
New, Open, Undo, Redo, Save, Cut, Copy, Paste
.-(void)abortModal
runModalForWindow:
-(CPArray)arguments
-(CPModalSession)beginModalSessionForWindow:(CPWindow)aWindow
theWindow
.aWindow
- the window to set up the modal session for-(void)beginSheet:(CPWindow)aSheet modalForWindow:(CPWindow)aWindow modalDelegate:(id)aModalDelegate didEndSelector:(SEL)aDidEndSelector contextInfo:(id)aContextInfo
aSheet
- the window to display as a sheetaWindow
- the window that will hold the sheet as a childaModalDelegate
- aDidEndSelector
- aContextInfo
- -(id)delegate
-(void)doCommandBySelector:(SEL)aSelector
nextResponder
will be called to do it.aSelector
- the command to attempt-(void)finishLaunching
run
before the event loop begins.
When it successfully completes, it posts the notification
CPApplicationDidFinishLaunchingNotification
. If you override
finishLaunching
, the subclass method should invoke the superclass method.-(CPWindow)keyWindow
-(CPMenu)mainMenu
-(CPWindow)mainWindow
-(CPWindow)modalWindow
nil
.-(CPDictionary)namedArguments
-(void)run
finishLaunching
method which results in starting
the main event loop.-(void)runModalForWindow:(CPWindow)aWindow
aWindow
aWindow
- the window to start the event loop for-(void)runModalSession:(CPModalSession)aModalSession
aModalSession
-(BOOL)sendAction:(SEL)anAction to:(id)aTarget from:(id)aSender
anAction
- the action to sendaTarget
- the target for the actionaSender
- the action senderYES
-(void)sendEvent:(CPEvent)anEvent
anEvent
- the event to dispatch-(void)setCallback:(Function)aCallback forNextEventMatchingMask:(unsigned int)aMask untilDate:(CPDate)anExpiration inMode:(CPString)aMode dequeue:(BOOL)shouldDequeue
aCallback
aMask
anExpiration
aMode
shouldDequeue
-(void)setDelegate:(id)aDelegate
aDelegate
- the delegate object-(void)setMainMenu:(CPMenu)aMenu
aMenu
- the menu to set for the application-(CPEvent)setTarget:(id)aTarget selector:(SEL)aSelector forNextEventMatchingMask:(unsigned int)aMask untilDate:(CPDate)anExpiration inMode:(CPString)aMode dequeue:(BOOL)shouldDequeue
aTarget
aSelector
aMask
anExpiration
aMode
shouldDequeue
-(void)stopModal
-(void)stopModalWithCode:(int)aCode
runModalForWindow:
and
sets the code that runModalForWindow:
will return.aCode
- the return code for the modal event-(id)targetForAction:(SEL)anAction
CPApplication
instanceanAction
- the action to handlenil
if no match could be found
-(id)targetForAction:(SEL)anAction to:(id)aTarget from:(id)aSender
nil
, returns nil
.
If the target is not nil
, aTarget
is
returned. Otherwise, it calls targetForAction:
to search for a target.anAction
- the action to find a target foraTarget
- if not nil
, this will be returnedaSender
-(BOOL)tryToPerform:(SEL)anAction with:(id)anObject
anAction
- the action to perform.anObject
- the argument for the action
methodYES
if the action was performed
-(CPWindow)windowWithWindowNumber:(int)aWindowNumber
CPWindow
object corresponding to aWindowNumber
.aWindowNumber
-(CPArray)windows
CPWindow
sDelegate Method Detail |
---|
-(void)applicationDidFinishLaunching:(CPNotification)aNotification
aNotification
- contains information about the event-(void)applicationWillFinishLaunching:(CPNotification)aNotification
aNotification
- contains information about the eventFunction Detail |
---|
function CPApplicationMain(args, namedArgs)
main()
function of your program.args
namedArgs
Created on Sat Sep 13 14:15:43 PDT 2008