xapplication
is a base class which implements the main
thread of control in an application: initialization, event loop and
termination.
Each application must derive a subclass from xapplication
and
define exactly one static object of this class.
An application does not need a main()
function.
AXE has its own main
which calls the member functions of the
xapplication
object.
The baseclass constructor registers its this
pointer in a
global area: xapplication *XApp
.
The main thread of control for an application is implemented in virtual
functions of xapplication
.
The class derived from xapplication
may override these
functions to implement application-specific behavior.
The functionality performed in xapplication
is :
xapplication
object maintains a list of all
window
objects that are used
by the application.
The list of windows is maintained by the contructor and destructor
of the window class.
A window object handles events through virtual functions.
Classes derived from window
, like buttons, menu items,
slider and scrollbars implement their specific behavior by overriding
these event-handling functions.
The event dispatcher in the xapplication
object passes
an appropriate XEvent structure as a parameter to the event-handling
function of the window.
The event-handling function returns TRUE if the application can
continue, or FALSE if the application should terminate.
Some windows may send commands back to the xapplication object.
A menu item, for instance sends a command to the application when it is
clicked.
To send a command to the application, an object (usually a window)
calls the function XApp->DoCommand(code)
.
This function dispatches the command to a handler function.
Member functions | |
---|---|
add_window | Add a window to the application's list of windows |
remove_window | Remove a window from the application's list of windows |
Pgrab | Set the window that grabs the pointer |
DispatchEvent | Find the window object and call its event-handling function |
Overridable member functions | |
Initialize | Initialize the application |
ParseArguments | Parse the command-line arguments |
SetupResources | Create all visible objects |
UserInit | Perform user-specific initialization |
DoCommand | Handle a command form another object |
Cleanup | Cleanup the application when it exits |