#include <app.h>
Inheritance diagram for TProgram::
Public Methods | |
TProgram () | |
virtual | ~TProgram () |
virtual Boolean | canMoveFocus () |
virtual ushort | executeDialog (TDialog *pD, void *data=0) |
virtual void | getEvent (TEvent &event) |
virtual TPalette& | getPalette () const |
virtual void | handleEvent (TEvent &event) |
virtual void | idle () |
virtual void | initScreen () |
virtual void | outOfMemory () |
virtual void | putEvent (TEvent &event) |
virtual void | run () |
virtual TWindow* | insertWindow (TWindow *) |
void | setScreenMode (ushort mode) |
TView* | validView (TView *p) |
virtual void | shutDown () |
virtual void | suspend () |
virtual void | resume () |
Static Public Methods | |
TStatusLine* | initStatusLine (TRect) |
TMenuBar* | initMenuBar (TRect) |
TDeskTop* | initDeskTop (TRect) |
Static Public Attributes | |
TProgram* | application |
TStatusLine* | statusLine |
TMenuBar* | menuBar |
TDeskTop* | deskTop |
int | appPalette |
Static Protected Attributes | |
TEvent | pending |
TProgram provides the basic template for all standard TVision applications. All programs must be derived from TProgram or its immediate derived class, TApplication. TApplication differs from TProgram only for its constructor and destructor. However most applications will be derived from TApplication.
Definition at line 524 of file app.h.
|
Constructor. The TProgram constructor calls the TProgInit constructor, passing to it the addresses of three init functions. The TProgInit constructor creates a status line, menu bar, and desk top. If these calls are successful, the three objects are inserted into the TProgram group. Variables statusLine, menuBar and deskTop are set to point at these new objects. The TGroup constructor is also invoked to create a full screen view; the video buffer and default palettes are initialized; and the following state flags are set:
state = sfVisible | sfSelected | sfFocused | sfModal | sfExposed; |
|
Destructor. Deletes the associated deskTop, menuBar, statusLine objects, and sets application to 0. |
|
Returns True if the focus can be moved from one desktop view to another one. It just returns `deskTop->valid(cmReleasedFocus)'.
|
|
Executes a dialog. `pD' points to the dialog. The dialog is executed only if it is valid.
|
|
Gets an event. This method collects events from the system like key events, mouse events and timer events and returns them in the `event' structure. getEvent() first checks if TProgram::putEvent() has generated a pending event. If so, getEvent() returns that event. If there is no pending event, getEvent() calls TScreen::getEvent(). If both calls return evNothing, indicating that no user input is available, getEvent() calls TProgram::idle() to allow "background" tasks to be performed while the application is waiting for user input.
Reimplemented from TView. Reimplemented in TApplication. |
|
Returns a reference to the standard TProgram palette. Returns the palette string given by the palette index in appPalette. TProgram supports three palettes. appPalette is initialized by TProgram::initScreen(). Reimplemented from TView. |
|
Standard TProgram event handler. This method first checks for keyboard events. When it catches keys from Alt-1 to Alt-9 it generates an evBroadcast event with the `command' field equal to cmSelectWindowNum and the `infoPtr' field in the range 1 to 9. Then it calls TGroup::handleEvent(). Last it checks for a cmQuit command in a evCommand event. On success it calls TGroup::endModal(cmQuit) to end the modal state. This causes TProgram::run() method to return. In most applications this will result in program termination.
Reimplemented from TGroup. |
|
Called when in idle state. This method is called whenever the library is in idle state, i.e. there is not any event to serve. It allows the application to perform background tasks while waiting for user input. The default idle() calls statusLine->update() to allow the status line to update itself according to the current help context. Then, if the command set has changed since the last call to idle(), an evBroadcast with a command value of cmCommandSetChanged is generated to allow views that depend on the command set to enable or disable themselves.
The user may redefine this method, for example, to update a clock in the upper right corner of the screen, like the `demo' program does. |
|
Creates a new desktop. This method creates a standard TDeskTop view and returns its address. The address of this function is passed to the TProgInit constructor, which creates a TDeskTop object for the application and stores a pointer to it in the deskTop static member. initDeskTop() should never be called directly. Few applications need to redefine it to have a custom desktop, instead of the default empty TDeskTop. |
|
Creates a new menu bar. This method creates a standard TMenuBar view and returns its address. The address of this function is passed to the TProgInit constructor, which creates a TMenuBar object for the application and stores a pointer to it in the menuBar static member. initMenuBar() should never be called directly. initMenuBar() is almost always overridden to instantiate a user defined TMenuBar instead of the default empty TMenuBar. |
|
Initializes the screen. This method is called by the TProgram constructor and setScreenMode() every time the screen mode is initialized or changed.
|
|
Creates a new status line. This method creates a standard TStatusLine view and returns its address. The address of this function is passed to the TProgInit constructor, which creates a TStatusLine object for the application and stores a pointer to it in the statusLine static member. initStatusLine() should never be called directly. initStatusLine() is almost always overridden to instantiate a user defined TStatusLine instead of the default empty TStatusLine. |
|
Inserts a window in the TProgram. |
|
Called on out of memory condition. It is called from validView() whenever lowMemory() returns True. This happens when there is few free memory. Of course this should rarely happen. This method may be redefined to tell the user (by calling messageBox() for example) that there is not free memory to end the current task. |
|
Sets a pending event. Puts an event in the pending state, by storing a copy of the `event' structure in the pending variable, a static member of TProgram. Only one event is allowed to be pending. The next call to getEvent() will return this pending event even if there are other events in the system queue to be handled. Reimplemented from TView. |
|
Restores the execution of the application. This method is empty. Will be redefined in TApplication which is a child of TProgram.
Reimplemented in TApplication. |
|
Runs TProgram. Executes TProgram by calling its method execute(), which TProgram inherits from TGroup. |
|
Sets a new screen mode. The `mode' parameter can by one of the constants smCO80, smBW80 or smMono, defined in `system.h' as follows. Optionally the value may be or-ed with smFont8x8.
Constant Value Meaning smBW80 0x0002 Requires black & white screen, 80 columns smCO80 0x0003 Requires color screen, 80 columns smMono 0x0007 Requires monochrome screen smFont8x8 0x0100 Requires small size font Note: in my port this method only redraws the screen. |
|
Releases TProgram resources. Used internally by TObject::destroy() to ensure correct destruction of derived and related objects.
Reimplemented from TGroup. |
|
Stops the execution of the application. This method is empty. Will be redefined in TApplication which is a child of TProgram.
Reimplemented in TApplication. |
|
Checks if a view is valid. Returns `p' if the view pointed by `p' is valid. Otherwise returns a null pointer. First, if `p' is 0 the call returns 0. Next, if lowMemory() returns True the view pointed by `p' is released by calling TObject::destroy() followed by outOfMemory() and the function returns 0. Last if a call to `p->valid(cmValid)' returns False the view pointed by `p' is released and the function returns 0.
|
|
The current application palette. Indexes the default palette for this application. The TPalette object corresponding to appPalette is returned by getPalette(). This value is set automatically at startup by initScreen(). The following application palette constants are defined:
Constant Value Meaning apColor 0 Use palette for color screen apBlackWhite 1 Use palette for LCD screen apMonochrome 2 Use palette for monochrome screen |
|
A pointer to the current application, direct istance of TProgram or istance of another class derived from TProgram, usually TApplication. Set to this by the TProgInit constructor. Only one TProgram object can exist at any time. In this way every object can call TProgram methods even if it does't know its name. |
|
A pointer to the current desk top object, set by a call to TProgInit::createDeskTop in the TProgram constructor. The resulting desk top is inserted into the TProgram group. May be 0 if no desk top exist. |
|
A pointer to the current menu bar object, set by a call to TProgInit::createMenuBar in the TProgram constructor. The resulting menu bar is inserted into the TProgram group. May be 0 if no menu bar exist. |
|
The current pending event. This structure contains the current pending event, if any exists. A maximum of one pending event may be set by calling putEvent(). |
|
A pointer to the current status line object, set by a call to TProgInit::createStatusLine in the TProgram constructor. The resulting status line is inserted into the TProgram group. May be 0 if no status line exist. |