Commit 18184540 authored by cutealien's avatar cutealien

MessageBox supports now automatic resizing and images.

Deprecated EGDS_MESSAGE_BOX_WIDTH and EGDS_MESSAGE_BOX_HEIGHT.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2710 dfc29bdd-3216-0410-991c-e03cc46cb475
parent a8972015
...@@ -240,11 +240,12 @@ public: ...@@ -240,11 +240,12 @@ public:
to (EMBF_OK | EMBF_CANCEL). to (EMBF_OK | EMBF_CANCEL).
\param parent Parent gui element of the message box. \param parent Parent gui element of the message box.
\param id Id with which the gui element can be identified. \param id Id with which the gui element can be identified.
\param image Optional texture which will be displayed beside the text as an image
\return Pointer to the created message box. Returns 0 if an error \return Pointer to the created message box. Returns 0 if an error
occured. This pointer should not be dropped. See occured. This pointer should not be dropped. See
IReferenceCounted::drop() for more information. */ IReferenceCounted::drop() for more information. */
virtual IGUIWindow* addMessageBox(const wchar_t* caption, const wchar_t* text=0, virtual IGUIWindow* addMessageBox(const wchar_t* caption, const wchar_t* text=0,
bool modal = true, s32 flags = EMBF_OK, IGUIElement* parent=0, s32 id=-1) = 0; bool modal = true, s32 flags = EMBF_OK, IGUIElement* parent=0, s32 id=-1, video::ITexture* image=0) = 0;
//! Adds a scrollbar. //! Adds a scrollbar.
/** \param horizontal Specifies if the scroll bar is drawn horizontal /** \param horizontal Specifies if the scroll bar is drawn horizontal
......
...@@ -139,9 +139,9 @@ namespace gui ...@@ -139,9 +139,9 @@ namespace gui
EGDS_WINDOW_BUTTON_WIDTH, EGDS_WINDOW_BUTTON_WIDTH,
//! width of a checkbox check //! width of a checkbox check
EGDS_CHECK_BOX_WIDTH, EGDS_CHECK_BOX_WIDTH,
//! width of a messagebox //! deprecated
EGDS_MESSAGE_BOX_WIDTH, EGDS_MESSAGE_BOX_WIDTH,
//! height of a messagebox //! deprecated
EGDS_MESSAGE_BOX_HEIGHT, EGDS_MESSAGE_BOX_HEIGHT,
//! width of a default button //! width of a default button
EGDS_BUTTON_WIDTH, EGDS_BUTTON_WIDTH,
...@@ -155,6 +155,17 @@ namespace gui ...@@ -155,6 +155,17 @@ namespace gui
EGDS_TITLEBARTEXT_DISTANCE_X, EGDS_TITLEBARTEXT_DISTANCE_X,
//! distance for text in the title bar, from the top of the window rect //! distance for text in the title bar, from the top of the window rect
EGDS_TITLEBARTEXT_DISTANCE_Y, EGDS_TITLEBARTEXT_DISTANCE_Y,
//! free space in a messagebox between borders and contents on all sides
EGDS_MESSAGE_BOX_GAP_SPACE,
//! minimal space to reserve for messagebox text-width
EGDS_MESSAGE_BOX_MIN_TEXT_WIDTH,
//! maximal space to reserve for messagebox text-width
EGDS_MESSAGE_BOX_MAX_TEST_WIDTH,
//! minimal space to reserve for messagebox text-height
EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT,
//! maximal space to reserve for messagebox text-height
EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT,
//! this value is not used, it only specifies the amount of default sizes //! this value is not used, it only specifies the amount of default sizes
//! available. //! available.
EGDS_COUNT EGDS_COUNT
...@@ -174,6 +185,13 @@ namespace gui ...@@ -174,6 +185,13 @@ namespace gui
"ButtonHeight", "ButtonHeight",
"TextDistanceX", "TextDistanceX",
"TextDistanceY", "TextDistanceY",
"TitleBarTextX",
"TitleBarTextY",
"MessageBoxGapSpace",
"MessageBoxMinTextWidth",
"MessageBoxMaxTextWidth",
"MessageBoxMinTextHeight",
"MessageBoxMaxTextHeight",
0, 0,
}; };
......
...@@ -978,7 +978,7 @@ IGUIElement* CGUIEnvironment::addModalScreen(IGUIElement* parent) ...@@ -978,7 +978,7 @@ IGUIElement* CGUIEnvironment::addModalScreen(IGUIElement* parent)
//! Adds a message box. //! Adds a message box.
IGUIWindow* CGUIEnvironment::addMessageBox(const wchar_t* caption, const wchar_t* text, IGUIWindow* CGUIEnvironment::addMessageBox(const wchar_t* caption, const wchar_t* text,
bool modal, s32 flag, IGUIElement* parent, s32 id) bool modal, s32 flag, IGUIElement* parent, s32 id, video::ITexture* image)
{ {
if (!CurrentSkin) if (!CurrentSkin)
return 0; return 0;
...@@ -990,8 +990,8 @@ IGUIWindow* CGUIEnvironment::addMessageBox(const wchar_t* caption, const wchar_t ...@@ -990,8 +990,8 @@ IGUIWindow* CGUIEnvironment::addMessageBox(const wchar_t* caption, const wchar_t
screenDim.Width = parent->getAbsolutePosition().getWidth(); screenDim.Width = parent->getAbsolutePosition().getWidth();
screenDim.Height = parent->getAbsolutePosition().getHeight(); screenDim.Height = parent->getAbsolutePosition().getHeight();
msgBoxDim.Width = CurrentSkin->getSize(gui::EGDS_MESSAGE_BOX_WIDTH); msgBoxDim.Width = 2;
msgBoxDim.Height = CurrentSkin->getSize(gui::EGDS_MESSAGE_BOX_HEIGHT); msgBoxDim.Height = 2;
rect.UpperLeftCorner.X = (screenDim.Width - msgBoxDim.Width) / 2; rect.UpperLeftCorner.X = (screenDim.Width - msgBoxDim.Width) / 2;
rect.UpperLeftCorner.Y = (screenDim.Height - msgBoxDim.Height) / 2; rect.UpperLeftCorner.Y = (screenDim.Height - msgBoxDim.Height) / 2;
...@@ -1005,7 +1005,7 @@ IGUIWindow* CGUIEnvironment::addMessageBox(const wchar_t* caption, const wchar_t ...@@ -1005,7 +1005,7 @@ IGUIWindow* CGUIEnvironment::addMessageBox(const wchar_t* caption, const wchar_t
} }
IGUIWindow* win = new CGUIMessageBox(this, caption, text, flag, IGUIWindow* win = new CGUIMessageBox(this, caption, text, flag,
parent, id, rect); parent, id, rect, image);
win->drop(); win->drop();
return win; return win;
......
...@@ -96,7 +96,7 @@ public: ...@@ -96,7 +96,7 @@ public:
//! Adds a message box. //! Adds a message box.
virtual IGUIWindow* addMessageBox(const wchar_t* caption, const wchar_t* text=0, virtual IGUIWindow* addMessageBox(const wchar_t* caption, const wchar_t* text=0,
bool modal = true, s32 flag = EMBF_OK, IGUIElement* parent=0, s32 id=-1); bool modal = true, s32 flag = EMBF_OK, IGUIElement* parent=0, s32 id=-1, video::ITexture* image=0);
//! adds a scrollbar. The returned pointer must not be dropped. //! adds a scrollbar. The returned pointer must not be dropped.
virtual IGUIScrollBar* addScrollBar(bool horizontal, const core::rect<s32>& rectangle, virtual IGUIScrollBar* addScrollBar(bool horizontal, const core::rect<s32>& rectangle,
......
This diff is collapsed.
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "CGUIWindow.h" #include "CGUIWindow.h"
#include "IGUIStaticText.h" #include "IGUIStaticText.h"
#include "IGUIImage.h"
#include "irrArray.h" #include "irrArray.h"
namespace irr namespace irr
...@@ -23,7 +24,7 @@ namespace gui ...@@ -23,7 +24,7 @@ namespace gui
//! constructor //! constructor
CGUIMessageBox(IGUIEnvironment* environment, const wchar_t* caption, CGUIMessageBox(IGUIEnvironment* environment, const wchar_t* caption,
const wchar_t* text, s32 flag, const wchar_t* text, s32 flag,
IGUIElement* parent, s32 id, core::rect<s32> rectangle); IGUIElement* parent, s32 id, core::rect<s32> rectangle, video::ITexture* image=0);
//! destructor //! destructor
virtual ~CGUIMessageBox(); virtual ~CGUIMessageBox();
...@@ -40,12 +41,15 @@ namespace gui ...@@ -40,12 +41,15 @@ namespace gui
private: private:
void refreshControls(); void refreshControls();
void setButton(IGUIButton*& button, bool isAvailable, const core::rect<s32> & btnRect, const wchar_t * text, IGUIElement*& focusMe);
IGUIButton* OkButton; IGUIButton* OkButton;
IGUIButton* CancelButton; IGUIButton* CancelButton;
IGUIButton* YesButton; IGUIButton* YesButton;
IGUIButton* NoButton; IGUIButton* NoButton;
IGUIStaticText* StaticText; IGUIStaticText* StaticText;
IGUIImage * Icon;
video::ITexture * IconTexture;
s32 Flags; s32 Flags;
core::stringw MessageText; core::stringw MessageText;
......
...@@ -104,6 +104,12 @@ CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver) ...@@ -104,6 +104,12 @@ CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver)
Sizes[EGDS_TITLEBARTEXT_DISTANCE_Y] = 2; Sizes[EGDS_TITLEBARTEXT_DISTANCE_Y] = 2;
} }
Sizes[EGDS_MESSAGE_BOX_GAP_SPACE] = 15;
Sizes[EGDS_MESSAGE_BOX_MIN_TEXT_WIDTH] = 0;
Sizes[EGDS_MESSAGE_BOX_MAX_TEST_WIDTH] = 500;
Sizes[EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT] = 0;
Sizes[EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT] = 99999;
Texts[EGDT_MSG_BOX_OK] = L"OK"; Texts[EGDT_MSG_BOX_OK] = L"OK";
Texts[EGDT_MSG_BOX_CANCEL] = L"Cancel"; Texts[EGDT_MSG_BOX_CANCEL] = L"Cancel";
Texts[EGDT_MSG_BOX_YES] = L"Yes"; Texts[EGDT_MSG_BOX_YES] = L"Yes";
......
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