//! Adds a message box. IGUIWindow* CGUIEnvironment::addMessageBox(const wchar_t* caption, const wchar_t* text, bool modal, s32 flag, IGUIElement* parent, s32 id) { if (!CurrentSkin) return 0; parent = parent ? parent : this; core::rect<s32> rect; core::dimension2d<s32> screenDim, msgBoxDim; screenDim.Width = parent->getAbsolutePosition().getWidth(); screenDim.Height = parent->getAbsolutePosition().getHeight(); msgBoxDim.Width = CurrentSkin->getSize(gui::EGDS_MESSAGE_BOX_WIDTH); msgBoxDim.Height = CurrentSkin->getSize(gui::EGDS_MESSAGE_BOX_HEIGHT); rect.UpperLeftCorner.X = (screenDim.Width - msgBoxDim.Width) / 2; rect.UpperLeftCorner.Y = (screenDim.Height - msgBoxDim.Height) / 2; rect.LowerRightCorner.X = rect.UpperLeftCorner.X + msgBoxDim.Width; rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + msgBoxDim.Height; if (modal) { parent = new CGUIModalScreen(this, parent, -1); parent->drop(); } IGUIWindow* win = new CGUIMessageBox(this, caption, text, flag, parent, id, rect); win->drop(); return win; }
//! adds a window. The returned pointer must not be dropped. IGUIWindow* CGUIEnvironment::addWindow(const core::rect<s32>& rectangle, bool modal, const wchar_t* text, IGUIElement* parent, s32 id) { parent = parent ? parent : this; if (modal) { parent = new CGUIModalScreen(this, parent, -1); parent->drop(); } IGUIWindow* win = new CGUIWindow(this, parent, id, rectangle); if (text) win->setText(text); win->drop(); return win; }