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

Gewi::GewiEngine Class Reference

#include <GewiEngine.h>

List of all members.


Detailed Description

GewiEngine Singleton Class, accessible from anywhere in a program via GetInstance. Contains widgets in global context (those drawn in relation to screen, with a NULL parent) also handles resource management of fonts and images.


Public Member Functions

void Display ()
 Draw all widgets in the Gewi system.

ResourceID AddResource (ZE::ZImage *image)
 Adds an image resource to the private vector.

ResourceID AddResource (ZE::ZFont *font)
 Adds a font resource to the private vector.

ZE::ZImage * Image (ResourceID id)
 Access an image in the resource vector.

ZE::ZFont * Font (ResourceID id)
 Access a font in the resource vector.

void FreeResources ()
 Free all resources.

void Register (GWidget *widget)
 Register a widget, adding it to the list of widgets.

void SendMessage (SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch)
 Send a message to the widgets, this function will decide which widgets the message is relevant to.

void DeleteWidget (GWidget *widget)
 Delete a widget.


Static Public Member Functions

GewiEngine * GetInstance ()
 Get the static instance of GewiEngine.

void ReleaseInstance ()
 Release static instance.

int EventFilter (SDL_Event *event)
 Static event filter, defined to SDL specifications.

char TranslateKey (SDL_keysym key)
 Translate an SDL structure into a character, used by EventFilter.


Static Public Attributes

VersionInfo Version
 Static version information.

VersionInfo MinZEVersion
 Required ZEngine version.

const ResourceID InvalidID = UINT_MAX
 Static variable used to represent invalid IDs (before an ID has been assigned all resourceIDs should == InvalidID).


Private Member Functions

 GewiEngine ()
 GewiEngine constructor, private due to singleton design.

void InsertWidget (WidgetNode *node)
 Inserts a child to the child list.


Private Attributes

std::vector< ZE::ZImage * > mImageVec
 Vector of pointers to ZImages, used by resource management system.

std::vector< ZE::ZFont * > mFontVec
 Vector of pointers to ZFonts, used by resource management system.

WidgetList mWidgetList
 List of widgets in global context.


Static Private Attributes

GewiEngine * sInstance = NULL
 Singleton static instance of GewiEngine.


Constructor & Destructor Documentation

Gewi::GewiEngine::GewiEngine  )  [private]
 

Initializes GewiEngine instance variables, can only be called once per run of program due to design.


Member Function Documentation

GewiEngine * Gewi::GewiEngine::GetInstance  )  [static]
 

Important key to the singleton's design, gets the static instance stored within. Creates static instance on first call.

Returns:
Pointer to static instance of GewiEngine.

void Gewi::GewiEngine::ReleaseInstance  )  [static]
 

Releases the instance of GewiEngine, basically only called at very end of program.

int Gewi::GewiEngine::EventFilter SDL_Event *  event  )  [static]
 

Replaces SDL default event filter, and filters events into static GewiEngine instance.

Parameters:
event SDL_Event to handle.
Returns:
Return values specified by SDL.

char Gewi::GewiEngine::TranslateKey SDL_keysym  key  )  [static]
 

Converts SDL_keysym into a standard char, only works for certain meaningful keys.

Parameters:
key SDL_keysm structure to convert.
Returns:
Converted character.

void Gewi::GewiEngine::Display  ) 
 

Draws all top level widgets and containers, container widgets are expected to draw their own children.

ResourceID Gewi::GewiEngine::AddResource ZE::ZImage *  image  ) 
 

Add a ZImage to the private vector of images and assign it a ResourceID.

Parameters:
image Image to add to resources.
Returns:
ID number of new resource.

ResourceID Gewi::GewiEngine::AddResource ZE::ZFont *  font  ) 
 

Add a ZFont to the private vector of fonts and assign it a ResourceID.

Parameters:
font Font to add to resources.
Returns:
ID number of new resource.

ZE::ZImage * Gewi::GewiEngine::Image ResourceID  id  ) 
 

Given the images ID get a pointer to an image stored in the image vector.

Parameters:
id ID of image to retrieve.
Returns:
Pointer to image or NULL if invalid ID for images.

ZE::ZFont * Gewi::GewiEngine::Font ResourceID  id  ) 
 

Given the fonts ID get a pointer to a font stored in the font vector.

Parameters:
id ID of font to retrieve.
Returns:
Pointer to font or NULL if invalid ID for fonts.

void Gewi::GewiEngine::FreeResources  ) 
 

Frees memory for all resources.

void Gewi::GewiEngine::InsertWidget WidgetNode node  )  [private]
 

Calls needed function of WidgetList class to put widget into the linked list.

Parameters:
node WidgetNode to insert into mWidgetList.

void Gewi::GewiEngine::Register GWidget widget  ) 
 

Add a widget to the list of widgets, all widgets register themselves.

Parameters:
widget Widget to register.

void Gewi::GewiEngine::SendMessage SDL_Event *  rawEvent,
GewiEvent  event,
Uint16  mouseX,
Uint16  mouseY,
char  ch
 

Send a message to the widgets, this function will decide which widgets the message is relevant to. This generally isn't called by the client of GewiEngine, instead the EventFilter hook on events will filter and process. This can be used to fake an event however.

Parameters:
rawEvent SDL_Event of original message, may be needed if more information is available on event. (May be NULL).
event GewiEvent enum, description of event recieved.
mouseX Mouse x position in event, if not mouse event may be incorrect.
mouseY Mouse y position in event, if not mouse event may be incorrect.
ch Character pressed in event, may be 0 if not a keypress event.

void Gewi::GewiEngine::DeleteWidget GWidget widget  ) 
 

This deletes a widget and memory associated with that widget, like register, widgets do this for themselves.

Parameters:
widget to delete


The documentation for this class was generated from the following files:
Generated on Fri Aug 1 17:17:30 2003 for Gewi by doxygen1.3