GuiSurface Class Reference
[2D graphical user interface]

A simple class for reducing the number of blits per frame. More...

#include <guisurface.h>

Inheritance diagram for GuiSurface:

Inheritance graph
[legend]
Collaboration diagram for GuiSurface:

Collaboration graph
[legend]
List of all members.

Public Member Functions

DECLSPEC GuiSurface (const SDL_Rect &r, GuiElement *p, const char *name)
DECLSPEC GuiSurface (TiXmlElement *el, GuiElement *p)
virtual const char * getClassName ()
virtual bool hasSurface () const
DECLSPEC void incUnuseRef ()
DECLSPEC void decUnuseRef ()
 Does the opposite of incUnuseRef().

Static Public Member Functions

static void newguiobject (void *presult, BasicObject *o, void *xmldata)

Protected Member Functions

virtual DECLSPEC Uint32 onResize ()
virtual SdlSurfacegetDestSurface ()
virtual DECLSPEC void onInit ()
virtual DECLSPEC Uint32 onFrame (SdlSurface *dest)
virtual void incRequireOnFrame ()
virtual void decRequireOnFrame ()
 Does the opposite of incRequireOnFrame().

Detailed Description

A simple class for reducing the number of blits per frame.

By creating an element of this class, the children elements draw onto an off-screen surface and so, only need to draw, if this off-screen surface changes. If you have some elements that do not change their look very often, it is efficient to put them onto a GuiSurface.

The usage of the off-screen surface can also be temporarily disabled.

Deriving a class from this does probably not make much sense.


Constructor & Destructor Documentation

GuiSurface::GuiSurface ( const SDL_Rect &  r,
GuiElement p,
const char *  name 
)

Constructor.

Parameters:
r the rect of the element's appearance, relative to the parent's top-left position
p the parent element (a GuiElement cannot have a child derived from UiObject or BasicObject and not from GuiElement), if NULL, GuiManager::the is its parent.
name the element's name

GuiSurface::GuiSurface ( TiXmlElement el,
GuiElement p 
)

Constructor, used to create an element from XML data.

Parameters:
el the XML data
p the parent element, or NULL to take GuiManager::the as parent


Member Function Documentation

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

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

Returns:
the name of the class.

Reimplemented from GuiElement.

virtual bool GuiSurface::hasSurface (  )  const [inline, virtual]

Returns:
true, if the off-screen surface is used

Reimplemented from GuiElement.

DECLSPEC void GuiSurface::incUnuseRef (  )  [inline]

Increments the reference counter, indicating how many children currently require the onFrame() method (this disables the functionality of this object). If the reference counter is zero, the off-screen surface is used.

Uint32 GuiSurface::onResize (  )  [protected, virtual]

This event is called, when the element changed its place or size.

Returns:
currently the result is not used; may be zero, if no error...

Reimplemented from GuiElement.

virtual SdlSurface* GuiSurface::getDestSurface (  )  [inline, protected, virtual]

Returns:
the surface, where this element draws onto

void GuiSurface::onInit (  )  [protected, virtual]

Initializes the object's variables by reading data from the XML element. If there were no XML data used for creation, nothing is done. This function calls onInit() of its children recursively (after it has inited itself). It is highly recommended to call BasicObject::onInit(), usually at the end of the onInit() method, when overwriting it in a derived class.

Reimplemented from GuiElement.

Uint32 GuiSurface::onFrame ( SdlSurface dest  )  [protected, virtual]

This event is called, when a frame is drawn. If the object should be visible, is has to draw it's look to a valid surface. This method calls the children's function, if visible.

Returns:
zero, if no error occured; if not zero, drawing is stopped
Note:
if you derive the function, then call GuiElement::onFrame(SdlSurface*) after your class's drawing was done in the onFrame-event, otherwise you paint over the children elements

Reimplemented from GuiElement.

virtual void GuiSurface::incRequireOnFrame (  )  [inline, protected, virtual]

Increments the reference counters of parent GuiSurfaces, to disable their off-screen surface blitting. So the onFrame-Method will always be called when drawing a frame.

See also:
GuiSurface::incUnuseRef()

Reimplemented from GuiElement.


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