Class GTKApplication

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 superclass GTKMain, so look there for additional methods to control the event loop.


Class-Hierarchy:

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

Class GTKApplication inherits from GTKMain


Last modified: 18.1.99 (./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 *mainWindow
application's main window
protected 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 generate an error message if the application object has not yet been created.

See also: -initWithArgc:argv:

- 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.

- (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.

- (void) setDelegate:_delegate

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

- delegate

Return the application object's delegate.

- (void) run

Start the application's main event loop.

- (BOOL) isRunning

Check whether the main event loop is running.

- (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) 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) stop: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 even loop is running, it will be stopped instead of the main event loop. The sender parameter is ignored.

- (void) terminate:sender

Tell the application's main event loop to finish. This will cause the -run method to return, which will normally end the program. 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.

- (void) reportException:(NSException *) exception

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

- (BOOL) isActive

Check whether the application is active.

- (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

- (NSArray *) windows

Return the application's window list.


generated Tue Jan 19 16:35:31 1999 by Objcdoc