#include <guisurface.h>
Inheritance diagram for GuiSurface:
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 SdlSurface * | getDestSurface () |
virtual DECLSPEC void | onInit () |
virtual DECLSPEC Uint32 | onFrame (SdlSurface *dest) |
virtual void | incRequireOnFrame () |
virtual void | decRequireOnFrame () |
Does the opposite of incRequireOnFrame(). |
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.
GuiSurface::GuiSurface | ( | const SDL_Rect & | r, | |
GuiElement * | p, | |||
const char * | name | |||
) |
Constructor.
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.
el | the XML data | |
p | the parent element, or NULL to take GuiManager::the as parent |
virtual const char* GuiSurface::getClassName | ( | ) | [inline, virtual] |
This function should be overriden in every sub-class of BasicObject!
Reimplemented from GuiElement.
virtual bool GuiSurface::hasSurface | ( | ) | const [inline, virtual] |
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.
Reimplemented from GuiElement.
virtual SdlSurface* GuiSurface::getDestSurface | ( | ) | [inline, protected, virtual] |
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.
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.
Reimplemented from GuiElement.