Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

FormManager Class Reference

This class manages dispatching Form events, by using Form classes instead of the normal C mechanism provided by PalmOS. More...

#include <FormManager.h>

Collaboration diagram for FormManager:

Collaboration graph
[legend]
List of all members.

Public Methods

void suicide () FORM_SECTION2
 instructs the FormManger to destroy its instance immidiately if possible or when all forms have been de-registred. More...

void registerForm (UInt16 form_id, Form *form) FORM_SECTION2
 this function adds the details given by the paramaters to the forms array. More...

void deregisterForm (UInt16 form_id) FORM_SECTION2
 removes a form from the forms array containing registred forms. More...

void bringToFront (UInt16 form_id, Form *form) FORM_SECTION2
 rearanges the forms array in such a way that the given form always receives the events first. More...

Boolean dispatchEvent (EventPtr event) FORM_SECTION2
 dispatches event to the right form (if registred). More...

Boolean dispatchLoadEvent (UInt16 form_id) FORM_SECTION2
 dispatches a load event to a given form. More...

Boolean dispatchCloseEvent (UInt16 form_id) FORM_SECTION2
 dispatches a close event to a given form. More...


Static Public Methods

FormManager * instance ()
 returns a reference to FormManager. More...

void destroyInstance () FORM_SECTION2
 destroys the instance (if no forms are still registred). More...


Private Methods

 FormManager () FORM_SECTION2
 constructor; initialises the forms array (private to prevent accidental duplication). More...


Private Attributes

form_info forms [max_forms]
 information on all forms. More...


Static Private Attributes

const UInt8 max_forms = 25
 maximum number of forms that can be handled (active at the same time). More...

FormManager * _instance
 singleton reference to this class. More...

Boolean _destroy_requested
 flag indicating whether the FormManager is required to kill itself. this cannot be accomplished while forms are still registred. More...

UInt8 _form_count
 number of forms currently registred with the FormManager. More...


Detailed Description

This class manages dispatching Form events, by using Form classes instead of the normal C mechanism provided by PalmOS.

The current implementation is jusr a hack, but it seems to work rather well.

The idea behind this is to keep a dictionary of form_id's and the associated form pointers. This way any kind of events can be dispatched to the right form, provided the form registered with the manager (i.e. the manager know what form handles the form_id which is targeted by the incoming event.

Please note that this class is a Singleton. Ummm sort of that is. more like a singleton hack. Point is that you are only meant to access it via the frm_mngr pointer, which in turn is automatically initialised at the first call to registerForm (so *DO NOT* calll any other method before register form)

Todo:
class should be reimplemented. May be convenient to use a linked list instead of a fixed size array

Definition at line 41 of file FormManager.h.


Constructor & Destructor Documentation

FormManager::FormManager   [private]
 

constructor; initialises the forms array (private to prevent accidental duplication).


Member Function Documentation

void FormManager::bringToFront UInt16    form_id,
Form   form
 

rearanges the forms array in such a way that the given form always receives the events first.

This is useful when a given form has more than one instance, all active at the same time and they are all sharing the same form_id

Parameters:
form_id  id of the form resource
form  pointer to form to handle events for this resource first.

void FormManager::deregisterForm UInt16    form_id
 

removes a form from the forms array containing registred forms.

void FormManager::destroyInstance   [static]
 

destroys the instance (if no forms are still registred).

Boolean FormManager::dispatchCloseEvent UInt16    form_id
 

dispatches a close event to a given form.

Parameters:
form_id  form to dispatch load event to

Boolean FormManager::dispatchEvent EventPtr    event
 

dispatches event to the right form (if registred).

Parameters:
event  event to be dispatched

Boolean FormManager::dispatchLoadEvent UInt16    form_id
 

dispatches a load event to a given form.

Parameters:
form_id  form to dispatch load event to

FormManager* FormManager::instance   [static]
 

returns a reference to FormManager.

This is the only allowed way to access this class

void FormManager::registerForm UInt16    form_id,
Form   form
 

this function adds the details given by the paramaters to the forms array.

Parameters:
form_id  id of the form to be added
form  pointer to the form to be added. All events will be re-routed via this pointer

void FormManager::suicide  
 

instructs the FormManger to destroy its instance immidiately if possible or when all forms have been de-registred.


Member Data Documentation

Boolean FormManager::_destroy_requested [static, private]
 

flag indicating whether the FormManager is required to kill itself. this cannot be accomplished while forms are still registred.

Definition at line 92 of file FormManager.h.

UInt8 FormManager::_form_count [static, private]
 

number of forms currently registred with the FormManager.

Definition at line 94 of file FormManager.h.

FormManager* FormManager::_instance [static, private]
 

singleton reference to this class.

Definition at line 90 of file FormManager.h.

form_info FormManager::forms[max_forms] [private]
 

information on all forms.

Definition at line 87 of file FormManager.h.

const UInt8 FormManager::max_forms = 25 [static, private]
 

maximum number of forms that can be handled (active at the same time).

Definition at line 84 of file FormManager.h.


The documentation for this class was generated from the following file:
Generated on Thu Jan 16 23:11:15 2003 for FreeCoins by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002