Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

TProgram Class Reference

The mother of TApplication. More...

#include <app.h>

Inheritance diagram for TProgram::

TGroup TProgInit TView TObject TStreamable TApplication List of all members.

Public Methods

 TProgram ()
virtual ~TProgram ()
virtual Boolean canMoveFocus ()
virtual ushort executeDialog (TDialog *pD, void *data=0)
virtual void getEvent (TEvent &event)
virtual TPalettegetPalette () const
virtual void handleEvent (TEvent &event)
virtual void idle ()
virtual void initScreen ()
virtual void outOfMemory ()
virtual void putEvent (TEvent &event)
virtual void run ()
virtual TWindowinsertWindow (TWindow *)
void setScreenMode (ushort mode)
TViewvalidView (TView *p)
virtual void shutDown ()
virtual void suspend ()
virtual void resume ()

Static Public Methods

TStatusLineinitStatusLine (TRect)
TMenuBarinitMenuBar (TRect)
TDeskTopinitDeskTop (TRect)

Static Public Attributes

TProgram* application
TStatusLinestatusLine
TMenuBarmenuBar
TDeskTopdeskTop
int appPalette

Static Protected Attributes

TEvent pending

Detailed Description

The mother of TApplication.

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 & Destructor Documentation

TProgram::TProgram ( )
 

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;
 

TProgram::~TProgram ( ) [virtual]
 

Destructor.

Deletes the associated deskTop, menuBar, statusLine objects, and sets application to 0.


Member Function Documentation

Boolean TProgram::canMoveFocus ( ) [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 TProgram::executeDialog ( TDialog * pD,
void * data = 0 ) [virtual]
 

Executes a dialog.

`pD' points to the dialog. The dialog is executed only if it is valid.

See also:
TDialog::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.
See also:
TGroup::getData , TGroup::setData

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

void TProgram::getEvent ( TEvent & event ) [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.

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.

See also:
TProgram::idle()

Before returning, getEvent() passes any evKeyDown and evMouseDown events to the statusLine for it to map into associated evCommand hot key events.

Reimplemented from TView.

Reimplemented in TApplication.

TPalette & TProgram::getPalette ( ) const [virtual]
 

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.

void TProgram::handleEvent ( TEvent & event ) [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 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.

See also:
TGroup::endModal

Method handleEvent() is almost always overridden to introduce handling of commands that are specific to your own application.

Reimplemented from TGroup.

void TProgram::idle ( ) [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. 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.

See also:
TStatusLine::update

Note: in the original DOS version this method was called continously. In my port this method is called about 10 times in a 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.

TDeskTop * TProgram::initDeskTop ( TRect ) [static]
 

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.

TMenuBar * TProgram::initMenuBar ( TRect ) [static]
 

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.

void TProgram::initScreen ( ) [virtual]
 

Initializes the screen.

This method is called by the TProgram constructor and setScreenMode() every time the screen mode is initialized or changed.

See also:
TProgram::TProgram

Performs the updating and adjustment of screen mode-dependent variables for shadow size, markers and application palette (color, monochrome or black & white). The shadows are usually painted in the right and bottom sides of menus and windows.

TStatusLine * TProgram::initStatusLine ( TRect ) [static]
 

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.

TWindow * TProgram::insertWindow ( TWindow * ) [virtual]
 

Inserts a window in the TProgram.

void TProgram::outOfMemory ( ) [virtual]
 

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.

void TProgram::putEvent ( TEvent & event ) [virtual]
 

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.

void TProgram::resume ( ) [inline, 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::resume

Reimplemented in TApplication.

Definition at line 767 of file app.h.

void TProgram::run ( ) [virtual]
 

Runs TProgram.

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

void TProgram::setScreenMode ( ushort mode )
 

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.

void TProgram::shutDown ( ) [virtual]
 

Releases TProgram resources.

Used internally by TObject::destroy() to ensure correct destruction of derived and related objects.

See also:
TObject::shutDown

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

Reimplemented from TGroup.

void TProgram::suspend ( ) [inline, 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::suspend

Reimplemented in TApplication.

Definition at line 759 of file app.h.

TView * TProgram::validView ( TView * p )
 

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.

See also:
TView::valid

Otherwise, the view is considered valid, and pointer `p' is returned.


Member Data Documentation

int TProgram::appPalette [static]
 

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
 

Definition at line 866 of file app.h.

TProgram * TProgram::application [static]
 

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.

Definition at line 825 of file app.h.

TDeskTop * TProgram::deskTop [static]
 

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.

Definition at line 849 of file app.h.

TMenuBar * TProgram::menuBar [static]
 

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.

Definition at line 841 of file app.h.

TEvent TProgram::pending [static, 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().

Definition at line 874 of file app.h.

TStatusLine * TProgram::statusLine [static]
 

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.

Definition at line 833 of file app.h.


The documentation for this class was generated from the following file:
Generated at Sat Sep 22 20:19:31 2001 for TVision by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001