Commit 7ed594d0 authored by hybrid's avatar hybrid

Changed parent handling in GUI loader.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2091 dfc29bdd-3216-0410-991c-e03cc46cb475
parent ebb18402
...@@ -75,7 +75,7 @@ public: ...@@ -75,7 +75,7 @@ public:
virtual bool setFocus(IGUIElement* element) = 0; virtual bool setFocus(IGUIElement* element) = 0;
//! Returns the element which holds the focus. //! Returns the element which holds the focus.
//! \return Pointer to the element with focus. /** \return Pointer to the element with focus. */
virtual IGUIElement* getFocus() const = 0; virtual IGUIElement* getFocus() const = 0;
//! Removes the focus from an element. //! Removes the focus from an element.
...@@ -91,15 +91,15 @@ public: ...@@ -91,15 +91,15 @@ public:
virtual bool hasFocus(IGUIElement* element) const = 0; virtual bool hasFocus(IGUIElement* element) const = 0;
//! Returns the current video driver. //! Returns the current video driver.
//! \return Pointer to the video driver. /** \return Pointer to the video driver. */
virtual video::IVideoDriver* getVideoDriver() const = 0; virtual video::IVideoDriver* getVideoDriver() const = 0;
//! Returns the file system. //! Returns the file system.
//! \return Pointer to the file system. /** \return Pointer to the file system. */
virtual io::IFileSystem* getFileSystem() const = 0; virtual io::IFileSystem* getFileSystem() const = 0;
//! returns a pointer to the OS operator //! returns a pointer to the OS operator
//! \return Pointer to the OS operator. /** \return Pointer to the OS operator. */
virtual IOSOperator* getOSOperator() const = 0; virtual IOSOperator* getOSOperator() const = 0;
//! Removes all elements from the environment. //! Removes all elements from the environment.
...@@ -119,7 +119,7 @@ public: ...@@ -119,7 +119,7 @@ public:
virtual void setUserEventReceiver(IEventReceiver* evr) = 0; virtual void setUserEventReceiver(IEventReceiver* evr) = 0;
//! Returns pointer to the current gui skin. //! Returns pointer to the current gui skin.
//! \return Pointer to the GUI skin. /** \return Pointer to the GUI skin. */
virtual IGUISkin* getSkin() const = 0; virtual IGUISkin* getSkin() const = 0;
//! Sets a new GUI Skin //! Sets a new GUI Skin
...@@ -208,10 +208,10 @@ public: ...@@ -208,10 +208,10 @@ public:
virtual IGUIWindow* addWindow(const core::rect<s32>& rectangle, bool modal = false, virtual IGUIWindow* addWindow(const core::rect<s32>& rectangle, bool modal = false,
const wchar_t* text=0, IGUIElement* parent=0, s32 id=-1) = 0; const wchar_t* text=0, IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds a modal screen. This control stops its parent's members from //! Adds a modal screen.
//! being able to recieve input until its last child is removed, it /** This control stops its parent's members from being able to recieve
//! then deletes itself. input until its last child is removed, it then deletes itself.
/** \param parent Parent gui element of the modal. \param parent Parent gui element of the modal.
\return Pointer to the created modal. Returns 0 if an error occured. \return Pointer to the created modal. Returns 0 if an error occured.
This pointer should not be dropped. See IReferenceCounted::drop() for This pointer should not be dropped. See IReferenceCounted::drop() for
more information. */ more information. */
...@@ -434,7 +434,7 @@ public: ...@@ -434,7 +434,7 @@ public:
IGUIElement* parent=0, s32 id=-1) = 0; IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds a menu to the environment. //! Adds a menu to the environment.
/* This is like the menu you can find on top of most windows in modern /** This is like the menu you can find on top of most windows in modern
graphical user interfaces. graphical user interfaces.
\param parent Parent item of the element, e.g. a window. \param parent Parent item of the element, e.g. a window.
Set it to 0 to place the menu directly in the environment. Set it to 0 to place the menu directly in the environment.
...@@ -467,6 +467,14 @@ public: ...@@ -467,6 +467,14 @@ public:
IGUIElement* parent=0, s32 id=-1) = 0; IGUIElement* parent=0, s32 id=-1) = 0;
//! Adds a table to the environment //! Adds a table to the environment
/** \param rectangle Position and dimension of the table.
\param parent Parent item of the element, e.g. a window. Set it to 0
to place the element directly in the environment.
\param id An identifier for the table.
\param drawBackground Flag whether the background should be drawn.
\return Pointer to the created table. Returns 0 if an error occured.
This pointer should not be dropped. See IReferenceCounted::drop() for
more information. */
virtual IGUITable* addTable(const core::rect<s32>& rectangle, virtual IGUITable* addTable(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1, bool drawBackground = false) = 0; IGUIElement* parent=0, s32 id=-1, bool drawBackground = false) = 0;
...@@ -484,7 +492,7 @@ public: ...@@ -484,7 +492,7 @@ public:
virtual void registerGUIElementFactory(IGUIElementFactory* factoryToAdd) = 0; virtual void registerGUIElementFactory(IGUIElementFactory* factoryToAdd) = 0;
//! Returns amount of registered gui element factories. //! Returns amount of registered gui element factories.
//! \return Amount of registered gui element factories. /** \return Amount of registered gui element factories. */
virtual u32 getRegisteredGUIElementFactoryCount() const = 0; virtual u32 getRegisteredGUIElementFactoryCount() const = 0;
//! Returns a gui element factory by index //! Returns a gui element factory by index
...@@ -494,23 +502,23 @@ public: ...@@ -494,23 +502,23 @@ public:
virtual IGUIElement* addGUIElement(const c8* elementName, IGUIElement* parent=0) = 0; virtual IGUIElement* addGUIElement(const c8* elementName, IGUIElement* parent=0) = 0;
//! Saves the current gui into a file. //! Saves the current gui into a file.
//! \param filename Name of the file. /** \param filename Name of the file.
//! \param start The GUIElement to start with. Root if 0. \param start The GUIElement to start with. Root if 0. */
virtual bool saveGUI(const c8* filename, IGUIElement* start=0) = 0; virtual bool saveGUI(const c8* filename, IGUIElement* start=0) = 0;
//! Saves the current gui into a file. //! Saves the current gui into a file.
//! \param file The file to write to. /** \param file The file to write to.
//! \param start The GUIElement to start with. Root if 0. \param start The GUIElement to start with. Root if 0. */
virtual bool saveGUI(io::IWriteFile* file, IGUIElement* start=0) = 0; virtual bool saveGUI(io::IWriteFile* file, IGUIElement* start=0) = 0;
//! Loads the gui. Note that the current gui is not cleared before. //! Loads the gui. Note that the current gui is not cleared before.
//! \param filename Name of the file . /** \param filename Name of the file.
//! \param parent Parent for the loaded GUI, root if 0. \param parent Parent for the loaded GUI, root if 0. */
virtual bool loadGUI(const c8* filename, IGUIElement* parent=0) = 0; virtual bool loadGUI(const c8* filename, IGUIElement* parent=0) = 0;
//! Loads the gui. Note that the current gui is not cleared before. //! Loads the gui. Note that the current gui is not cleared before.
//! \param file The file to load from. /** \param file The file to load from.
//! \param parent Parent for the loaded GUI, root if 0. \param parent Parent for the loaded GUI, root if 0. */
virtual bool loadGUI(io::IReadFile* file, IGUIElement* parent=0) = 0; virtual bool loadGUI(io::IReadFile* file, IGUIElement* parent=0) = 0;
//! Writes attributes of the gui environment //! Writes attributes of the gui environment
...@@ -523,7 +531,7 @@ public: ...@@ -523,7 +531,7 @@ public:
virtual void writeGUIElement(io::IXMLWriter* writer, IGUIElement* node) =0; virtual void writeGUIElement(io::IXMLWriter* writer, IGUIElement* node) =0;
//! reads an element //! reads an element
virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* parent) =0; virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* node) =0;
}; };
......
...@@ -747,28 +747,27 @@ bool CGUIEnvironment::loadGUI(io::IReadFile* file, IGUIElement* parent) ...@@ -747,28 +747,27 @@ bool CGUIEnvironment::loadGUI(io::IReadFile* file, IGUIElement* parent)
//! reads an element //! reads an element
void CGUIEnvironment::readGUIElement(io::IXMLReader* reader, IGUIElement* parent) void CGUIEnvironment::readGUIElement(io::IXMLReader* reader, IGUIElement* node)
{ {
if (!reader) if (!reader)
return; return;
gui::IGUIElement* node = 0;
io::EXML_NODE nodeType = reader->getNodeType(); io::EXML_NODE nodeType = reader->getNodeType();
if (nodeType == io::EXN_NONE || nodeType == io::EXN_UNKNOWN || nodeType == io::EXN_ELEMENT_END) if (nodeType == io::EXN_NONE || nodeType == io::EXN_UNKNOWN || nodeType == io::EXN_ELEMENT_END)
return; return;
if (!parent && !wcscmp(IRR_XML_FORMAT_GUI_ENV, reader->getNodeName())) if (!wcscmp(IRR_XML_FORMAT_GUI_ENV, reader->getNodeName()))
{ {
if (!node)
node = this; // root node = this; // root
} }
else if (!wcscmp(IRR_XML_FORMAT_GUI_ELEMENT, reader->getNodeName())) else if (!wcscmp(IRR_XML_FORMAT_GUI_ELEMENT, reader->getNodeName()))
{ {
// find node type and create it // find node type and create it
core::stringc attrName = reader->getAttributeValue(IRR_XML_FORMAT_GUI_ELEMENT_ATTR_TYPE); const core::stringc attrName = reader->getAttributeValue(IRR_XML_FORMAT_GUI_ELEMENT_ATTR_TYPE);
node = addGUIElement(attrName.c_str(), parent); node = addGUIElement(attrName.c_str(), node);
if (!node) if (!node)
os::Printer::log("Could not create GUI element of unknown type", attrName.c_str()); os::Printer::log("Could not create GUI element of unknown type", attrName.c_str());
......
...@@ -233,7 +233,7 @@ public: ...@@ -233,7 +233,7 @@ public:
virtual void writeGUIElement(io::IXMLWriter* writer, IGUIElement* node); virtual void writeGUIElement(io::IXMLWriter* writer, IGUIElement* node);
//! reads an element //! reads an element
virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* parent); virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* node);
private: private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment