GuiManager Class Reference
[2D graphical user interface]

Manages 2D graphics functions and user actions. More...

#include <guimanager.h>

Inheritance diagram for GuiManager:

Inheritance graph
[legend]
Collaboration diagram for GuiManager:

Collaboration graph
[legend]
List of all members.

Public Member Functions

DECLSPEC GuiManager (UiManager *parent, const char *name="GuiManager")
virtual const char * getClassName ()
DECLSPEC bool init (TiXmlElement *el=NULL)
DECLSPEC void setBaseElements (GuiElement *front, GuiElement *main)
GuiElementgetFront ()
 
Returns:
a pointer to the top front element (that contains cursor, hint...)

GuiElementgetMain ()
 
Returns:
a pointer to the top main element (that contains windows...)

DECLSPEC void focus (GuiElement *el)
DECLSPEC bool release (GuiElement *el)
GuiElementgetFocus ()
 
Returns:
the element, currently having the mouse focus

DECLSPEC void setCursor (GuiElement *cur)
GuiElementgetCursor ()
 
Returns:
the currently used mouse cursor

DECLSPEC void cleanupElement (GuiElement *ge)

Static Public Member Functions

static DECLSPEC GuiManagergetThe ()

Static Public Attributes

static GuiManagerthe

Protected Member Functions

virtual Uint32 onKeyDown (SDL_KeyboardEvent *ev)
virtual Uint32 onKeyUp (SDL_KeyboardEvent *ev)
virtual DECLSPEC Uint32 onMouseDown (SDL_MouseButtonEvent *ev)
virtual DECLSPEC Uint32 onMouseUp (SDL_MouseButtonEvent *ev)
virtual DECLSPEC Uint32 onMouseMotion (SDL_MouseMotionEvent *ev)
virtual DECLSPEC Uint32 onFocus (FocusTypes gained)
virtual DECLSPEC Uint32 onRelease (FocusTypes lost)
virtual DECLSPEC Uint32 onFrame ()
virtual Uint32 onThemeChanged (UiTheme *t)
virtual DECLSPEC void onDestroy ()

Detailed Description

Manages 2D graphics functions and user actions.

See also:
UiManager, GuiElement


Constructor & Destructor Documentation

GuiManager::GuiManager ( UiManager parent,
const char *  name = "GuiManager" 
)

Constructor. Registers itself at the UiManager. There must be UiManager initialized before creating a GuiElement!

Parameters:
parent pointer to the UiManager
name the object's name ("GuiManager" by default)


Member Function Documentation

virtual const char* GuiManager::getClassName (  )  [inline, virtual]

This function should be overriden in every sub-class of BasicObject!

Returns:
the name of the class.

Reimplemented from UiObject.

bool GuiManager::init ( TiXmlElement el = NULL  ) 

Initializes this class and, if el is specified creates elements. The XML data can be structured as follows (for a screen with the size 1024x768):

 <GuiManager>
    <Front>
        <GuiElement rect="0;0;1024;768" name="front">
            [front elements like cursor, hint...]
        </GuiElement>
    </Front>
    <Main>
        <GuiElement rect="0;0;1024;768" name="main">
            [window elements...]
        </GuiElement>
    </Main>
    <GuiFader name="fader" normal="0xFFFF"/>
 </GuiManager>
Parameters:
el XML data for the elements to create
Note:
onInit() is not called in this method, this is not necessary.

void GuiManager::setBaseElements ( GuiElement front,
GuiElement main 
)

Sets the elements that recieve onFrame-events from the GuiManager.

Parameters:
front the front element (for cursor, hints...)
main the main element (for windows...)

void GuiManager::focus ( GuiElement el  ) 

Sets the mouse focus to the specified element. If an element has the focus, its onMouseMove() function is called, when the mouse is moved, but the other element's onMouseMove() function is not called. (If no element has the focus, onMouseMove() of the element is called, over which the cursor is - after the move)

Parameters:
el the element to focus

bool GuiManager::release ( GuiElement el  ) 

Sets the mouse focus to NULL, if the specified element had the focus.

Parameters:
el the element
Returns:
true if the element had the focus

void GuiManager::setCursor ( GuiElement cur  ) 

Sets the mouse cursor. The cursor recieves all mouse actions.

Parameters:
cur the cursor

void GuiManager::cleanupElement ( GuiElement ge  ) 

Cleans up all associations to the specified element. This is done, when an element is deleted. This method shall not be called from somewhere else but ~GuiElement().

Parameters:
ge the element to clean up

GuiManager * GuiManager::getThe (  )  [static]

Returns:
a pointer to the GuiManager-variable, or NULL if not initialized. (There is only one GuiManager-variable allowed in an application)
Every netrinjo-class that can only exist once at a time, has this static function.
See also:
Single inited classes

virtual Uint32 GuiManager::onKeyDown ( SDL_KeyboardEvent *  ev  )  [inline, protected, virtual]

This event is called, when the object has the keyboard focus and a key is pressed down.

Parameters:
ev the key-down event, that occured
Returns:
currently the result is not used; may be zero, if no error...

Reimplemented from UiObject.

virtual Uint32 GuiManager::onKeyUp ( SDL_KeyboardEvent *  ev  )  [inline, protected, virtual]

This event is called, when the object has the keyboard focus and a key is released.

Parameters:
ev the key-up event, that occured
Returns:
currently the result is not used; may be zero, if no error...

Reimplemented from UiObject.

Uint32 GuiManager::onMouseDown ( SDL_MouseButtonEvent *  ev  )  [protected, virtual]

This event is called, when the object has the mouse focus and a mouse button is pressed down.

Parameters:
ev the button-down event, that occured
Returns:
currently the result is not used; may be zero, if no error...

Reimplemented from UiObject.

Uint32 GuiManager::onMouseUp ( SDL_MouseButtonEvent *  ev  )  [protected, virtual]

This event is called, when the object has the mouse focus and a mouse button is released.

Parameters:
ev the button-up event, that occured
Returns:
currently the result is not used; may be zero, if no error...

Reimplemented from UiObject.

Uint32 GuiManager::onMouseMotion ( SDL_MouseMotionEvent *  ev  )  [protected, virtual]

This event is called, when the mouse cursor is moved over the object.

Parameters:
x the absolute x coordinate of the cursor (distance from left)
y the absolute y coordinate of the cursor (distance from top)
Returns:
currently the result is not used; may be zero, if no error...

Reimplemented from UiObject.

Uint32 GuiManager::onFrame (  )  [protected, virtual]

This event is called when graphics should be updated. It does not call the children's onFrame() function!

Returns:
currently the result is not used; may be zero, if no error...
Note:
in classes derived from GuiElement, it is probably more useful to implement onFrame(SdlSurface*)

Reimplemented from UiObject.

virtual Uint32 GuiManager::onThemeChanged ( UiTheme t  )  [inline, protected, virtual]

This event is called, when the theme changes. Perform here the changes of the object's look and feel.

Parameters:
t pointer to the new used theme
Returns:
currently the result is not used; may be zero, if no error...

Reimplemented from UiObject.

void GuiManager::onDestroy (  )  [protected, virtual]

May be called to reinitialise this object or stop an initialised module. Calls all children's onDestroy(). Most classes do not use this method. But sometimes it is useful to reset the functionality of an object.

Reimplemented from UiObject.


Member Data Documentation

GuiManager * GuiManager::the [static]

Not accessible in Windows (dynamic linking), equals the result of getThe()


The documentation for this class was generated from the following files:
Generated on Wed May 9 17:36:21 2007 for netrinjo by  doxygen 1.5.1