home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2001 Mobile
/
Chip_Mobile_2001.iso
/
palm
/
business
/
printcar
/
printcar.exe
/
src
/
UI
/
Form.h
< prev
next >
Wrap
C/C++ Source or Header
|
2000-06-09
|
3KB
|
108 lines
//
// $Id: Form.h,v 1.4 2000/06/08 21:14:55 sergey Exp $
//
#ifndef _Form_h_
#define _Form_h_
namespace UI
{
//==============================================================================
// Form class
//==============================================================================
class Form
{
public:
Form(Word formID);
virtual ~Form();
private:
Form(const Form&);
Form& operator =(const Form&);
// operations
public:
// Creates a form in memory.
// Form could be activated later either by FrmGoToForm or by FrmPopupForm.
virtual void create();
virtual void destroy();
void display();
void activate() { FrmSetActiveForm(formPtr()); }
void showObject(Word objectID);
void hideObject(Word objectID);
// attributes
Word formID() const { return _formID; }
FormPtr formPtr() const { return _formPtr; }
void* getGenericObjectPtr(FormObjectKind objectKind, Word objectID) const;
// Returns the correct object pointer correct type by objectKind and objectId.
template <typename T>
T getObjectPtr(FormObjectKind objectKind, Word objectID) const
{
return reinterpret_cast<T>(getGenericObjectPtr(objectKind, objectID));
}
// event handling
// This routine will be called by the FormEventHandler thunk object.
virtual bool eventHandler(EventType* event);
// handlers to override
protected:
virtual bool handleLoadFormEvent(Word formID);
virtual bool handleOpenFormEvent(Word formID);
virtual bool handleUpdateFormEvent(Word formID);
virtual bool handleCtlSelectEvent(Word controlID, bool on);
virtual bool handleMenuEvent(Word menuID);
virtual bool handleKeyDownEvent(char asciiChar, Word keyCode, Word modifiers);
virtual bool handleNilEvent();
// data items
private:
Word _formID;
FormPtr _formPtr;
};
//==============================================================================
// FormEventHandler template class
//==============================================================================
//
// This is utility class aimed to simulate the kind of object-oriented
// callback routine for the Form.
//
template <class T>
class FormEventHandler
{
public:
void init(T* form)
{
_form = form;
FrmSetEventHandler(_form->formPtr(), eventHandlerCallback);
}
private:
static Boolean eventHandlerCallback(EventType* event)
{
return _form->eventHandler(event);
}
static T* _form;
};
template <class T>
T* FormEventHandler<T>::_form;
}
// namespace UI
#endif // _Form_h_