API 0.9.5
CPApplication Class Reference

#import <CPApplication.h>

Inheritance diagram for CPApplication:

List of all members.

Instance Methods

(void) - abortModal
(void) - activateIgnoringOtherApps:
(CPImage- applicationIconImage
(CPArray- arguments
(CPModalSession) - beginModalSessionForWindow:
(void) - beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:
(CPEvent- currentEvent
(void) - deactivate
(id) - delegate
(void) - doCommandBySelector:
(void) - endSheet:
(void) - endSheet:returnCode:
(void) - finishLaunching
(void) - hide:
(void) - hideOtherApplications:
(id) - init
(void) - isActive
(CPWindow- keyWindow
(CPMenu- mainMenu
(CPWindow- mainWindow
(CPWindow- modalWindow
(CPDictionary- namedArguments
(CPArray- orderedWindows
(void) - orderFrontColorPanel:
(void) - orderFrontStandardAboutPanel:
(void) - orderFrontStandardAboutPanelWithOptions:
(void) - replyToApplicationShouldTerminate:
(void) - run
(void) - runModalForWindow:
(void) - runModalSession:
(BOOL) - sendAction:to:from:
(void) - sendEvent:
(void) - setApplicationIconImage:
(void) - setArguments:
(void) - setCallback:forNextEventMatchingMask:untilDate:inMode:dequeue:
(void) - setDelegate:
(void) - setMainMenu:
(void) - setMenu:
(void) - setTarget:selector:forNextEventMatchingMask:untilDate:inMode:dequeue:
(void) - setThemeBlend:
(void) - stopModal
(void) - stopModalWithCode:
(id) - targetForAction:
(id) - targetForAction:to:from:
(void) - terminate:
(CPThemeBlend- themeBlend
(BOOL) - tryToPerform:with:
(CPArray- windows
(CPWindow- windowWithWindowNumber:

Class Methods

(CPString+ defaultThemeName
(CPApplication+ sharedApplication

Detailed Description

CPApplication is THE way to start up the Cappuccino 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);
    }
    

-(void)applicationDidFinishLaunching:(CPNotification)aNotification; Sent from the notification center after the app initializes, but before receiving events.

Parameters:
aNotificationcontains information about the event

-(void)applicationWillFinishLaunching:(CPNotification)aNotification; Sent from the notification center before the app is initialized.

Parameters:
aNotificationcontains information about the event

Definition at line 2 of file CPApplication.h.


Method Documentation

- (void) abortModal

Aborts the event loop started by -runModalForWindow:

Definition at line 510 of file CPApplication.j.

- (void) activateIgnoringOtherApps: (BOOL)  shouldIgnoreOtherApps

Definition at line 416 of file CPApplication.j.

- (CPImage) applicationIconImage

Returns the application icon image. By default this is pulled from the CPApplicationIcon key of info.plist.

Returns:
CPImage - Your application icon image.

Definition at line 301 of file CPApplication.j.

- (CPArray) arguments

Returns and array of slash seperated arugments to your application. These values are pulled from your window location hash.

For exampled if your application loaded:

    index.html#280north/cappuccino/issues
    

The follow array would be returned:

    ["280north", "cappuccino", "issues"]
    
Returns:
CPArray - The array of arguments.

Definition at line 988 of file CPApplication.j.

- (CPModalSession) beginModalSessionForWindow: (CPWindow aWindow

Sets up a modal session with theWindow.

Parameters:
aWindowthe window to set up the modal session for

Definition at line 519 of file CPApplication.j.

- (void) beginSheet: (CPWindow aSheet
modalForWindow: (CPWindow aWindow
modalDelegate: (id)  aModalDelegate
didEndSelector: (SEL)  aDidEndSelector
contextInfo: (id)  aContextInfo 

Displays a window as a sheet.

Parameters:
aSheetthe window to display as a sheet
aWindowthe window that will hold the sheet as a child
aModalDelegate
aDidEndSelector
aContextInfo

Definition at line 918 of file CPApplication.j.

- (CPEvent) currentEvent

Returns the last event recieved by your application.

Definition at line 903 of file CPApplication.j.

- (void) deactivate

Definition at line 426 of file CPApplication.j.

+ (CPString) defaultThemeName

Definition at line 1150 of file CPApplication.j.

- (id) delegate

Returns the application's delegate. The app can only have one delegate at a time.

Definition at line 197 of file CPApplication.j.

- (void) doCommandBySelector: (SEL)  aSelector

If the delegate responds to the given selector it will call the method on the delegate, otherwise the method will be passed to CPResponder.

Reimplemented from CPResponder.

Definition at line 608 of file CPApplication.j.

- (void) endSheet: (CPWindow sheet

Ends a sheet and sends the return code "0".

Parameters:
sheet- The CPWindow object (sheet) that should be dismissed.

Definition at line 967 of file CPApplication.j.

- (void) endSheet: (CPWindow sheet
returnCode: (int)  returnCode 

Ends a sheet modal. The following are predefined return codes:

    CPRunStoppedResponse
    CPRunAbortedResponse
    CPRunContinuesResponse
    
Parameters:
sheet- The window object (sheet) to dismiss.
returnCode- The return code to send to the delegate. You can use one of the return codes above or a custom value that you define.

Definition at line 945 of file CPApplication.j.

- (void) finishLaunching

This method is called by -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.

Definition at line 208 of file CPApplication.j.

- (void) hide: (id)  aSender

Definition at line 660 of file CPApplication.j.

- (void) hideOtherApplications: (id)  aSender

Definition at line 441 of file CPApplication.j.

- (id) init

Initializes the Document based application with basic menu functions. Functions are New, Open, Undo, Redo, Save, Cut, Copy, Paste.

Returns:
the initialized application

Definition at line 122 of file CPApplication.j.

- (void) isActive

Definition at line 436 of file CPApplication.j.

- (CPWindow) keyWindow

Returns the key window.

Definition at line 619 of file CPApplication.j.

- (CPMenu) mainMenu

Returns the application's main menu

Definition at line 669 of file CPApplication.j.

- (CPWindow) mainWindow

Returns the main window.

Definition at line 627 of file CPApplication.j.

- (CPWindow) modalWindow

Returns the window for the current modal session. If there is no modal session, it returns nil.

Definition at line 548 of file CPApplication.j.

- (CPDictionary) namedArguments

Returns a dictionary of the window location named arguments. For example if your location was:

    index.html?owner=280north&repo=cappuccino&type=issues
    

a CPDictionary with the keys:

    owner, repo, type
    

and respective values:

    280north, cappuccino, issues
    

Will be returned.

Definition at line 1070 of file CPApplication.j.

- (CPArray) orderedWindows

Returns an array of visible CPWindow objects, ordered by their front to back order on the screen.

Definition at line 651 of file CPApplication.j.

- (void) orderFrontColorPanel: (id)  aSender

Opens the shared color panel.

Parameters:
aSender

Definition at line 703 of file CPApplication.j.

- (void) orderFrontStandardAboutPanel: (id)  sender

Opens the standard about panel with no options.

Definition at line 316 of file CPApplication.j.

- (void) orderFrontStandardAboutPanelWithOptions: (CPDictionary options

Opens the standard about panel. This method takes a single argument options. Options is a dictionary that can contain any of the following keys:

    ApplicationName - The name of your application.
    ApplicationIcon - Application icon image.
    Version - The full version of your application
    ApplicationVersion - The shorter version number of your application.
    Copyright - Human readable copyright information.
    

If you choose not the include any of the above keys, they will default to the following respective keys in your info.plist file.

    CPBundleName
    CPApplicationIcon (through a call to -applicationIconImage, see documentation for that method for more details)
    CPBundleVersion
    CPBundleShortVersionString
    CPHumanReadableCopyright
    
Parameters:
options- A dictionary with the aboe listed keys. You can pass nil to default to your plist values.

Definition at line 345 of file CPApplication.j.

- (void) replyToApplicationShouldTerminate: (BOOL)  terminate

Definition at line 407 of file CPApplication.j.

- (void) run

Calls -finishLaunching method which results in starting the main event loop.

Definition at line 450 of file CPApplication.j.

- (void) runModalForWindow: (CPWindow aWindow

Starts a modal event loop for aWindow

Parameters:
aWindowthe window to start the event loop for

Definition at line 460 of file CPApplication.j.

- (void) runModalSession: (CPModalSession)  aModalSession

Runs a modal session

Parameters:
CPModalSessionthe session to run

Definition at line 528 of file CPApplication.j.

- (BOOL) sendAction: (SEL)  anAction
to: (id)  aTarget
from: (id)  aSender 

Sends an action to a target.

Parameters:
anActionthe action to send
aTargetthe target for the action
aSenderthe action sender
Returns:
YES

Definition at line 743 of file CPApplication.j.

- (void) sendEvent: (CPEvent anEvent

Dispatches events to other objects.

Parameters:
anEventthe event to dispatch

Definition at line 567 of file CPApplication.j.

- (void) setApplicationIconImage: (CPImage anImage

Sets the applications icon image. This image is used in the default "About" window. By default this value is pulled from the CPApplicationIcon key in your info.plist file.

Parameters:
anImage- The image to set.

Definition at line 292 of file CPApplication.j.

- (void) setArguments: (CPArray args

Sets the arguments of your application. That is, set the slash seperated values of an array as the window location hash.

For example if you pass an array:

    ["280north", "cappuccino", "issues"]
    

The new window location would be

    index.html#280north/cappuccino/issues
    
Parameters:
args- An array of arguments.

Definition at line 1012 of file CPApplication.j.

- (void) setCallback: (Function)  aCallback
forNextEventMatchingMask: (unsigned int)  aMask
untilDate: (CPDate anExpiration
inMode: (CPString aMode
dequeue: (BOOL)  shouldDequeue 

Fires a callback function when an event matching a given mask occurs.

Parameters:
aCallback- A js function to be fired. aMask - An event mask for the next event.
anExpiration- The date for which this callback expires (not implemented).
inMode(not implemented).
shouldDequeue(not implemented).

Definition at line 879 of file CPApplication.j.

- (void) setDelegate: (id)  aDelegate

Sets the delegate for this application. The delegate will receive various notifications caused by user interactions during the application's run. The delegate can choose to react to these events.

Parameters:
aDelegatethe delegate object

Definition at line 148 of file CPApplication.j.

- (void) setMainMenu: (CPMenu aMenu

Sets the main menu for the application

Parameters:
aMenuthe menu to set for the application

Definition at line 678 of file CPApplication.j.

- (void) setMenu: (CPMenu aMenu

Reimplemented from CPResponder.

Definition at line 683 of file CPApplication.j.

- (void) setTarget: (id)  aTarget
selector: (SEL)  aSelector
forNextEventMatchingMask: (unsigned int)  aMask
untilDate: (CPDate anExpiration
inMode: (CPString aMode
dequeue: (BOOL)  shouldDequeue 

Assigns a target and action for the next event matching a given event mask. The callback method called will be passed the CPEvent when it fires.

Parameters:
aTarget- The target object for the callback.
aSelector- The selector which should be called on the target object.
aMask- The mask for a given event which should trigger the callback.
anExpiration- The date for which the callback expires (not implemented).
aMode(not implemented).
shouldDequeue(not implemented).

Definition at line 895 of file CPApplication.j.

- (void) setThemeBlend: (CPThemeBlend aValue

Synthesized accessor method.

Definition at line 1378 of file CPApplication.j.

+ (CPApplication) sharedApplication

Returns the singleton instance of the running application. If it doesn't exist, it will be created, and then returned.

Returns:
the application singleton

Definition at line 109 of file CPApplication.j.

- (void) stopModal

Stops the modal event loop

Definition at line 502 of file CPApplication.j.

- (void) stopModalWithCode: (int)  aCode

Stops the event loop started by -runModalForWindow: and sets the code that -runModalForWindow: will return.

Parameters:
aCodethe return code for the modal event

Definition at line 470 of file CPApplication.j.

- (id) targetForAction: (SEL)  anAction

Looks for a target that can handle the specified action. Checks for a target in the following order:

  1. a responder from the key window
  2. a responder from the main window
  3. the CPApplication instance
  4. the application delegate
  5. the document controller
Parameters:
anActionthe action to handle
Returns:
a target that can respond, or nil if no match could be found

Definition at line 844 of file CPApplication.j.

- (id) targetForAction: (SEL)  anAction
to: (id)  aTarget
from: (id)  aSender 

Finds a target for the specified action. If the action is nil, returns nil. If the target is not nil, aTarget is returned. Otherwise, it calls -targetForAction: to search for a target.

Parameters:
anActionthe action to find a target for
aTargetif not nil, this will be returned not used
Returns:
a target for the action

Definition at line 766 of file CPApplication.j.

- (void) terminate: (id)  aSender

Definition at line 268 of file CPApplication.j.

- (CPThemeBlend) themeBlend

Synthesized accessor method.

Definition at line 1370 of file CPApplication.j.

- (BOOL) tryToPerform: (SEL)  anAction
with: (id)  anObject 

Tries to perform the action with an argument. Performs the action on itself (if it responds to it), then tries to perform the action on the delegate.

Parameters:
anActionthe action to perform.
anObjectthe argument for the action method
Returns:
YES if the action was performed

Reimplemented from CPResponder.

Definition at line 718 of file CPApplication.j.

- (CPArray) windows

Returns an array of the application's CPWindows

Definition at line 643 of file CPApplication.j.

- (CPWindow) windowWithWindowNumber: (int)  aWindowNumber

Returns the CPWindow object corresponding to aWindowNumber.

Definition at line 635 of file CPApplication.j.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Defines