Class GTKApplication

Inherits from:
GTKMain
Declared in:
GToolKit/GTKApplication.h

Class Hierarchy

    NSObject
      |
      +---GTKMain
	    |
	    +---GTKApplication

Class Description

The GTKApplication class controls the running application, and exactly one instance of this class must be created when the program starts. This GTKApplication object is globally accessible through the variable GTKApp, so there is no need to pass it as an argument to method calls.

Most of the methods of GTKApplication are implemented in its base class GTKMain, so look there for additional methods to control the event loop.

Last modified:
21-Feb-2002 (GToolKit/GTKApplication.m)

Instance Variables

protected id delegate
delegate of the application object
protected NSNotificationCenter *center
default notification center of this task
protected NSMutableArray *windows
application's window list
protected GTKWindow *volatile mainWindow
application's main window
private volatile int modalCode
return code of the current event loop

Method Index

Methods

+ (GTKApplication *) sharedApplication

Return the shared application object (as stored in the variable GTKApp). This method will raise an NSGenericException if the application object has not yet been created.

See also:
-initWithArgc:argv:

- (id) delegate

Return the application object's delegate.

- (void) finishLaunching

This method is invoked automatically by the -run method (see below) just before the application's main event loop will be started. It currently does nothing except for posting (in this order) the GTKApplicationWillFinishLaunchingNotification and GTKApplicationDidFinishLaunchingNotification to the default notification center.

- (id) initWithArgc:(int *) argc argv:(char ***) argv

Initialize a new GTKApplication object and store it in the global variable GTKApp. Note that you cannot create more than one application object in your program. This method will modify the program's command line arguments as given by argc and argv and remove any options related to GTK (such as --display or --class) from the argument list.

If the environment variable GTOOLKIT_DEBUG has been set, the GTKApplication class will activate special debug code to trace object allocation and deallocation calls.

- (BOOL) isActive

Check whether the application is active.

- (BOOL) isRunning

Check whether the main event loop is running.

- (GTKWindow *) mainWindow

Return the application's current main window (the active window) or nil if the application is not active (or has no windows).

See also:
-isActive

- (void) reportException:(NSException *) exception

Report an exception to stderr. This method simply calls NSLog() to print the exception's name and reason.

- (void) run

Start the application's main event loop.

- (int) runModalForWindow:(GTKWindow *) window

Start a modal event loop for the given window, i.e. restrict all events for this application to the specified window. This input mechanism should only be used for panels or windows that require immediate user interaction. Generally, it is best to avoid modal windows if possible.

-runModalForWindow: does not return until the modal event loop is terminated by a -stopModalWithCode: message, and it returns the status code passed as an argument to this method.

See also:
-stopModal, -stopModalWithCode:

- (void) setDelegate:(id) object

Set the application object's delegate or unset it (if delegate is nil). If the delegate implements any of the methods described in the protocol protocol GTKApplicationDelegate, it will be notified by the application object on the corresponding events.

- (void) stop:(id) sender

Stop the application's main event loop (if it is running). This will cause the -run method to return (similar to -terminate:), but will not send any notifications. If a modal event loop is running, it will be stopped instead of the main event loop. The sender parameter is ignored.

- (void) stopModal

Stop a running modal event loop with the code GTKRunStoppedResponse.

- (void) stopModalWithCode:(int) code

Stop a running modal event loop with the given code.

See also:
-runModalForWindow:

- (void) terminate:(id) sender

Tell the application's main event loop to finish (if it is running). This will cause the -run method to return, which will normally end the program. If a modal event loop is running, the program will be terminated anyway. The sender parameter is ignored.

If the delegate implements the method:

- (BOOL) applicationShouldTerminate:(GTKApplication *) sender
this message is sent to the delegate to determine whether the application should actually terminate. If it returns YES, this method will post the GTKApplicationWillTerminateNotification to the default notification center and terminate the event loop.

- (NSArray *) windows

Return the application's window list.


generated on 06-Mar-2002 by ObjcDoc 3.0.1