TProgram Class Reference

[tvision Index] [tvision Hierarchy] [Headers]


The mother of TApplication More...

#include <app.h>

Inherits: TGroup, TProgInit

Public Members

Protected Members


Detailed Description

The mother of TApplication.

Every program must be inherited from TProgram or from its child TApplication. TApplication differs from TProgram only for its constructor and destructor. However most applications will be derived from TApplication.

See Also: TApplication


TProgram() [public]

Constructor.

~TProgram() [public virtual]

Destructor.

Boolean canMoveFocus() [public virtual]

Returns True if the focus can be moved from one desktop view to another one.

It just returns deskTop->valid(cmReleasedFocus).

See Also:
TGroup::valid

ushort executeDialog(TDialog* pD, void*data = 0) [public virtual]

Executes a dialog.

`pD' points to the dialog. The dialog is executed only if it is valid. `data' is a pointer to the memory area where the dialog data will be read before executing the dialog and where the dialog data will be written after executing the dialog. If `data' is 0 no data area is used. This method calls TGroup::execView() to execute the dialog. The dialog is destroyed before returning from the function, so a call to delete is not necessary. executeDialog() returns cmCancel if the view is not valid, otherwise it returns the return value of TGroup::execView().

See Also:
TDialog::valid, TGroup::execView, TGroup::getData, TGroup::setData

void getEvent(TEvent& event) [public virtual]

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.

See Also:
TScreen

TPalette& getPalette() const [public virtual]

Returns a reference to the standard TProgram palette.

void handleEvent(TEvent& event) [public virtual]

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

See Also:
TGroup::handleEvent, TGroup::endModal, TProgram::run

void idle() [public virtual]

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. The main task it does is to update the status line (if one exists). In the original DOS version this method was called continously. In my port this method is called about 10 times for second. This result in less CPU load. 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.

void initScreen() [public virtual]

Initializes the screen.

This method is called by the TProgram constructor. Its goal is to select the application palette (color, monochrome or black & white) and to set the shadow size. The shadows are usually painted in the right and bottom sides of menus and windows.

void outOfMemory() [public virtual]

Called on out of memory condition.

It is called from TProgram::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.

See Also:
TProgram::validView, lowMemory, messageBox

void putEvent( TEvent& event ) [public virtual]

Sets a pending event.

Puts an event in the pending state. 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.

See Also:
TProgram::pending, TProgram::getEvent

void run() [public virtual]

Runs TProgram.

Executes TProgram by calling its method execute(), which TProgram inherits from TGroup.

See Also:
TGroup::execute

TWindow* insertWindow(TWindow*) [public virtual]

Inserts a window in the TProgram.

void setScreenMode( ushort mode ) [public]

Sets a new screen mode.

The `mode' parameter can by one of the constants smCO80, smBW80 or smMono. Optionally the value may be or-ed with smFont8x8. In my port this method only redraws the screen.

TView* validView( TView *p ) [public]

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.

Otherwise the method returns the pointer `p' and the view is valid.

See Also:
lowMemory, TObject::destroy, TView::valid

void shutDown() [public virtual]

Releases TProgram resources.

This method releases all the resources allocated by TProgram. It sets pointers `statusLine', `menuBar' and `deskTop' to 0 and then calls TGroup::shutDown() and TVMemMgr::clearSafetyPool().

See Also:
TGroup::shutDown, TVMemMgr::clearSafetyPool

void suspend() [public virtual]

Stops the execution of the application.

This method is empty. Will be redefined in TApplication which is a child of TProgram.

See Also:
TApplication

void resume() [public virtual]

Restores the execution of the application.

This method is empty. Will be redefined in TApplication which is a child of TProgram.

See Also:
TApplication

TStatusLine* initStatusLine( TRect ) [public static]

Creates a new status line.

This method creates a standard TStatusLine view and returns its address. Most applications redefine it to have a custom status line.

See Also:
TStatusLine

TMenuBar* initMenuBar( TRect ) [public static]

Creates a new menu bar.

This method creates a standard TMenuBar view and returns its address. Every application should redefine it to have custom menus.

See Also:
TMenuBar

TDeskTop* initDeskTop( TRect ) [public static]

Creates a new desktop.

This method creates a standard TDeskTop view and returns its address. Few applications need to redefine it to have a custom desktop.

See Also:
TDeskTop

static TProgram * application[public]

A pointer to the current TProgram object.

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.

static TStatusLine * statusLine[public]

A pointer to the current status line view.

May be 0 if none exists.

static TMenuBar * menuBar[public]

A pointer to the current menu bar view.

May be 0 if none exists.

static TDeskTop * deskTop[public]

A pointer to the current desktop view.

May be 0 if none exists.

static int appPalette[public]

The current application palette.

This value may be apBlackWhite, apColor or apMonoChrome. Its value is chosen automatically at startup by initScreen().

See Also:
TProgram::initScreen

static TEvent pending[protected]

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

See Also:
TProgram::putEvent

Documentation generated by sergio@athena.milk.it on Wed Feb 10 22:11:47 CET 1999
Kdoc