diff -r c5c84a987b10 lib/irrlicht/include/EWindowFlags.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/irrlicht/include/EWindowFlags.h Tue Sep 09 01:20:19 2008 +0200 @@ -0,0 +1,30 @@ +// Copyright (C) 2007 StarSonata + +#ifndef __E_WINDOW_FLAGS_H_INCLUDED__ +#define __E_WINDOW_FLAGS_H_INCLUDED__ + +namespace irr +{ +namespace gui +{ + + //! enumeration for window construction flags which are used in construction + enum EWINDOW_CONSTRUCTION_FLAG + { + //! Flag for close button + EWCF_CLOSE = 0x1, + + //! Flag for title bar of windows + EWCF_TITLEBAR = 0x2, + + //! Flag for maximize button + EWCF_MAXIMIZE = 0x4, + + //! Flag for minimize button + EWCF_MINIMIZE = 0x8, + }; + +} // namespace gui +} // namespace irr + +#endif diff -r c5c84a987b10 lib/irrlicht/include/IGUIEnvironment.h --- a/lib/irrlicht/include/IGUIEnvironment.h Tue Sep 09 00:31:18 2008 +0200 +++ b/lib/irrlicht/include/IGUIEnvironment.h Tue Sep 09 01:20:19 2008 +0200 @@ -8,6 +8,7 @@ #include "IReferenceCounted.h" #include "IGUISkin.h" #include "rect.h" +#include "EWindowFlags.h" #include "EMessageBoxFlags.h" #include "IEventReceiver.h" #include "IXMLReader.h" @@ -204,11 +205,12 @@ \param text Text displayed as the window title. \param parent Parent gui element of the window. \param id Id with which the gui element can be identified. + \param constructionFlags window construction flags from EWINDOW_CONSTRUCTION_FLAG \return Pointer to the created window. Returns 0 if an error occured. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ virtual IGUIWindow* addWindow(const core::rect& 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, u32 constructionFlags=EWCF_CLOSE|EWCF_TITLEBAR|EWCF_MAXIMIZE|EWCF_MINIMIZE) = 0; //! Adds a modal screen. This control stops its parent's members from //! being able to recieve input until its last child is removed, it diff -r c5c84a987b10 lib/irrlicht/include/IGUIWindow.h --- a/lib/irrlicht/include/IGUIWindow.h Tue Sep 09 00:31:18 2008 +0200 +++ b/lib/irrlicht/include/IGUIWindow.h Tue Sep 09 01:20:19 2008 +0200 @@ -7,6 +7,7 @@ #include "IGUIElement.h" #include "EMessageBoxFlags.h" +#include "EWindowFlags.h" namespace irr { @@ -31,7 +32,10 @@ //! Returns pointer to the maximize button virtual IGUIButton* getMaximizeButton() const = 0; - }; + + //! return if given construction flag is set + virtual bool hasConstructionFlag( EWINDOW_CONSTRUCTION_FLAG flag ) const = 0; +}; } // end namespace gui diff -r c5c84a987b10 lib/irrlicht/source/Irrlicht/CGUIEnvironment.cpp --- a/lib/irrlicht/source/Irrlicht/CGUIEnvironment.cpp Tue Sep 09 00:31:18 2008 +0200 +++ b/lib/irrlicht/source/Irrlicht/CGUIEnvironment.cpp Tue Sep 09 01:20:19 2008 +0200 @@ -1218,7 +1218,7 @@ //! adds a window. The returned pointer must not be dropped. IGUIWindow* CGUIEnvironment::addWindow(const core::rect& rectangle, bool modal, - const wchar_t* text, IGUIElement* parent, s32 id) + const wchar_t* text, IGUIElement* parent, s32 id, u32 flags) { parent = parent ? parent : this; @@ -1228,7 +1228,7 @@ parent->drop(); } - IGUIWindow* win = new CGUIWindow(this, parent, id, rectangle); + IGUIWindow* win = new CGUIWindow(this, parent, id, rectangle, flags); if (text) win->setText(text); win->drop(); diff -r c5c84a987b10 lib/irrlicht/source/Irrlicht/CGUIEnvironment.h --- a/lib/irrlicht/source/Irrlicht/CGUIEnvironment.h Tue Sep 09 00:31:18 2008 +0200 +++ b/lib/irrlicht/source/Irrlicht/CGUIEnvironment.h Tue Sep 09 01:20:19 2008 +0200 @@ -84,7 +84,7 @@ //! adds a window. The returned pointer must not be dropped. virtual IGUIWindow* addWindow(const core::rect& rectangle, bool modal = false, - const wchar_t* text=0, IGUIElement* parent=0, s32 id=-1); + const wchar_t* text=0, IGUIElement* parent=0, s32 id=-1, u32 flags=EWCF_CLOSE|EWCF_TITLEBAR|EWCF_MAXIMIZE|EWCF_MINIMIZE); //! adds a modal screen. The returned pointer must not be dropped. virtual IGUIElement* addModalScreen(IGUIElement* parent); diff -r c5c84a987b10 lib/irrlicht/source/Irrlicht/CGUIMessageBox.cpp --- a/lib/irrlicht/source/Irrlicht/CGUIMessageBox.cpp Tue Sep 09 00:31:18 2008 +0200 +++ b/lib/irrlicht/source/Irrlicht/CGUIMessageBox.cpp Tue Sep 09 01:20:19 2008 +0200 @@ -19,7 +19,7 @@ CGUIMessageBox::CGUIMessageBox(IGUIEnvironment* environment, const wchar_t* caption, const wchar_t* text, s32 flags, IGUIElement* parent, s32 id, core::rect rectangle) -: CGUIWindow(environment, parent, id, rectangle), +: CGUIWindow(environment, parent, id, rectangle, EWCF_CLOSE|EWCF_TITLEBAR), OkButton(0), CancelButton(0), YesButton(0), NoButton(0), StaticText(0), Flags(flags), MessageText(text), Pressed(false) { @@ -32,11 +32,6 @@ // remove focus Environment->setFocus(0); - - // remove buttons - - getMaximizeButton()->remove(); - getMinimizeButton()->remove(); if (caption) setText(caption); diff -r c5c84a987b10 lib/irrlicht/source/Irrlicht/CGUIWindow.cpp --- a/lib/irrlicht/source/Irrlicht/CGUIWindow.cpp Tue Sep 09 00:31:18 2008 +0200 +++ b/lib/irrlicht/source/Irrlicht/CGUIWindow.cpp Tue Sep 09 01:20:19 2008 +0200 @@ -18,8 +18,11 @@ { //! constructor -CGUIWindow::CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) -: IGUIWindow(environment, parent, id, rectangle), Dragging(false) +CGUIWindow::CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle, u32 constructionFlags) +: IGUIWindow(environment, parent, id, rectangle) +, ConstructionFlags(constructionFlags) +, Dragging(false) +, CloseButton(NULL) , MinButton(NULL), RestoreButton(NULL) { #ifdef _DEBUG setDebugName("CGUIWindow"); @@ -85,12 +88,39 @@ RestoreButton->grab(); CloseButton->grab(); + refreshControls(); + // this element is a tab group setTabGroup(true); setTabStop(true); setTabOrder(-1); } + +void CGUIWindow::refreshControls() +{ + if ( ConstructionFlags & EWCF_CLOSE ) + CloseButton->setVisible(true); + else + CloseButton->setVisible(false); + + if ( ConstructionFlags & EWCF_MAXIMIZE ) + RestoreButton->setVisible(true); + else + RestoreButton->setVisible(false); + + if ( ConstructionFlags & EWCF_MINIMIZE ) + MinButton->setVisible(true); + else + MinButton->setVisible(false); +} + + +bool CGUIWindow::hasConstructionFlag( EWINDOW_CONSTRUCTION_FLAG flag ) const +{ + return (ConstructionFlags & flag) ? true : false; +} + //! destructor CGUIWindow::~CGUIWindow() @@ -256,6 +286,30 @@ } +//! Writes attributes of the element. +void CGUIWindow::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const +{ + IGUIWindow::serializeAttributes(out, options); + + //IGUIButton* CloseButton; // exists at whole lifetime of the object + //IGUIButton* MinButton; // exists at whole lifetime of the object + //IGUIButton* RestoreButton; // exists at whole lifetime of the object + + out->addInt ("ConstructionFlags", ConstructionFlags ); +} + + +//! Reads attributes of the element +void CGUIWindow::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + IGUIWindow::deserializeAttributes(in, options); + + ConstructionFlags = in->getAttributeAsInt("ConstructionFlags"); + + refreshControls(); +} + + } // end namespace gui } // end namespace irr diff -r c5c84a987b10 lib/irrlicht/source/Irrlicht/CGUIWindow.h --- a/lib/irrlicht/source/Irrlicht/CGUIWindow.h Tue Sep 09 00:31:18 2008 +0200 +++ b/lib/irrlicht/source/Irrlicht/CGUIWindow.h Tue Sep 09 01:20:19 2008 +0200 @@ -21,7 +21,7 @@ public: //! constructor - CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle); + CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle, u32 constructionFlags); //! destructor virtual ~CGUIWindow(); @@ -44,8 +44,20 @@ //! Returns pointer to the maximize button virtual IGUIButton* getMaximizeButton() const; + //! return if given flag is set + virtual bool hasConstructionFlag( EWINDOW_CONSTRUCTION_FLAG flag ) const; + + //! Writes attributes of the element. + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; + + //! Reads attributes of the element + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); + protected: + void refreshControls(); + + u32 ConstructionFlags; core::position2d DragStart; bool Dragging;