#include <guifileelement.h>
Inheritance diagram for GuiFileElement:
Public Member Functions | |
DECLSPEC | GuiFileElement (SDL_Rect &r, GuiElement *el, const char *name, const char *filename=NULL) |
DECLSPEC | GuiFileElement (TiXmlElement *el, GuiElement *p) |
DECLSPEC bool | initByFile (const char *fn) |
virtual const char * | getClassName () |
Static Public Member Functions | |
static void | newguiobject (void *presult, BasicObject *o, void *xmldata) |
Protected Member Functions | |
virtual DECLSPEC void | onInit () |
This class can be used to distribute the xml-data to more files or to create elements during run-time using a xml-file.
XML-files that are specified to be parsed, should have a root element named as the classname (here "GuiFileElement"; if you derive a class from this, then the value from getClassname() should be used).
GuiFileElement::GuiFileElement | ( | SDL_Rect & | r, | |
GuiElement * | el, | |||
const char * | name, | |||
const char * | filename = NULL | |||
) |
filename | the XML-file to use for initialization, NULL if no child elements should be created here |
GuiFileElement::GuiFileElement | ( | TiXmlElement * | el, | |
GuiElement * | p | |||
) |
Constructor. Uses XML data.
el | the XML data for initialisation, the attribute Filename can be specified for initialization | |
p | parent element |
bool GuiFileElement::initByFile | ( | const char * | fn | ) |
Destroys all child elements and creates new child elements as defined in the specified XML-file. The onInit() method of the newly created elements is called after their creation.
fn | the XML-file's filename |
virtual const char* GuiFileElement::getClassName | ( | ) | [inline, virtual] |
This function should be overriden in every sub-class of BasicObject!
Reimplemented from GuiElement.
void GuiFileElement::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.