Commit 8a0d790a authored by hybrid's avatar hybrid

Some constification.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@948 dfc29bdd-3216-0410-991c-e03cc46cb475
parent f583f7dc
...@@ -111,9 +111,9 @@ public: ...@@ -111,9 +111,9 @@ public:
virtual IGUISkin* getSkin() = 0; virtual IGUISkin* getSkin() = 0;
//! Sets a new GUI Skin //! Sets a new GUI Skin
/** You can used this to change the appearance of the whole GUI Environment. You /** You can use this to change the appearance of the whole GUI Environment. You
can set one ot the built-in skins or implement your own class derived from can set one of the built-in skins or implement your own class derived from
IGUISkin and set this useing this method. IGUISkin and enable it using this method.
To set for example the built-in Windows classic skin, use the following code: To set for example the built-in Windows classic skin, use the following code:
\code \code
gui::IGUISkin* newskin = environment->createSkin(gui::EGST_WINDOWS_CLASSIC); gui::IGUISkin* newskin = environment->createSkin(gui::EGST_WINDOWS_CLASSIC);
...@@ -126,7 +126,7 @@ public: ...@@ -126,7 +126,7 @@ public:
//! Creates a new GUI Skin based on a template. //! Creates a new GUI Skin based on a template.
/** Use setSkin() to set the created skin. /** Use setSkin() to set the created skin.
\return Returns a pointer to the created skin. \return Returns a pointer to the created skin.
If you no longer need the image, you should call IGUISkin::drop(). If you no longer need it, you should call IGUISkin::drop().
See IReferenceCounted::drop() for more information. */ See IReferenceCounted::drop() for more information. */
virtual IGUISkin* createSkin(EGUI_SKIN_TYPE type) = 0; virtual IGUISkin* createSkin(EGUI_SKIN_TYPE type) = 0;
......
...@@ -326,21 +326,21 @@ namespace gui ...@@ -326,21 +326,21 @@ namespace gui
public: public:
//! destructor //! destructor
~IGUISkin() {}; virtual ~IGUISkin() {};
//! returns default color //! returns default color
virtual video::SColor getColor(EGUI_DEFAULT_COLOR color) = 0; virtual video::SColor getColor(EGUI_DEFAULT_COLOR color) const = 0;
//! sets a default color //! sets a default color
virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor) = 0; virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor) = 0;
//! returns default color //! returns default color
virtual s32 getSize(EGUI_DEFAULT_SIZE size) = 0; virtual s32 getSize(EGUI_DEFAULT_SIZE size) const = 0;
//! Returns a default text. //! Returns a default text.
/** For example for Message box button captions: /** For example for Message box button captions:
"OK", "Cancel", "Yes", "No" and so on. */ "OK", "Cancel", "Yes", "No" and so on. */
virtual const wchar_t* getDefaultText(EGUI_DEFAULT_TEXT text) = 0; virtual const wchar_t* getDefaultText(EGUI_DEFAULT_TEXT text) const = 0;
//! Sets a default text. //! Sets a default text.
/** For example for Message box button captions: /** For example for Message box button captions:
...@@ -351,20 +351,20 @@ namespace gui ...@@ -351,20 +351,20 @@ namespace gui
virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size) = 0; virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size) = 0;
//! returns the default font //! returns the default font
virtual IGUIFont* getFont(EGUI_DEFAULT_FONT which=EGDF_DEFAULT) = 0; virtual IGUIFont* getFont(EGUI_DEFAULT_FONT which=EGDF_DEFAULT) const = 0;
//! sets a default font //! sets a default font
virtual void setFont(IGUIFont* font, EGUI_DEFAULT_FONT which=EGDF_DEFAULT) = 0; virtual void setFont(IGUIFont* font, EGUI_DEFAULT_FONT which=EGDF_DEFAULT) = 0;
//! returns the sprite bank //! returns the sprite bank
virtual IGUISpriteBank* getSpriteBank() = 0; virtual IGUISpriteBank* getSpriteBank() const = 0;
//! sets the sprite bank //! sets the sprite bank
virtual void setSpriteBank(IGUISpriteBank* bank) = 0; virtual void setSpriteBank(IGUISpriteBank* bank) = 0;
//! Returns a default icon //! Returns a default icon
/** Returns the sprite index within the sprite bank */ /** Returns the sprite index within the sprite bank */
virtual u32 getIcon(EGUI_DEFAULT_ICON icon) = 0; virtual u32 getIcon(EGUI_DEFAULT_ICON icon) const = 0;
//! Sets a default icon //! Sets a default icon
/** Sets the sprite index used for drawing icons like arrows, /** Sets the sprite index used for drawing icons like arrows,
......
...@@ -48,19 +48,19 @@ CGUIMessageBox::CGUIMessageBox(IGUIEnvironment* environment, const wchar_t* capt ...@@ -48,19 +48,19 @@ CGUIMessageBox::CGUIMessageBox(IGUIEnvironment* environment, const wchar_t* capt
void CGUIMessageBox::refreshControls() void CGUIMessageBox::refreshControls()
{ {
IGUISkin* skin = Environment->getSkin(); const IGUISkin* skin = Environment->getSkin();
IGUIElement* focusMe = 0; IGUIElement* focusMe = 0;
s32 buttonHeight = skin->getSize(EGDS_BUTTON_HEIGHT); const s32 buttonHeight = skin->getSize(EGDS_BUTTON_HEIGHT);
s32 buttonWidth = skin->getSize(EGDS_BUTTON_WIDTH); const s32 buttonWidth = skin->getSize(EGDS_BUTTON_WIDTH);
s32 titleHeight = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH)+2; const s32 titleHeight = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH)+2;
s32 buttonDistance = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); const s32 buttonDistance = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH);
// add static multiline text // add static multiline text
core::dimension2d<s32> dim(AbsoluteClippingRect.getWidth() - buttonWidth, core::dimension2d<s32> dim(AbsoluteClippingRect.getWidth() - buttonWidth,
AbsoluteClippingRect.getHeight() - (buttonHeight * 3)); AbsoluteClippingRect.getHeight() - (buttonHeight * 3));
core::position2d<s32> pos((AbsoluteClippingRect.getWidth() - dim.Width) / 2, const core::position2d<s32> pos((AbsoluteClippingRect.getWidth() - dim.Width) / 2,
buttonHeight / 2 + titleHeight); buttonHeight / 2 + titleHeight);
if (!StaticText) if (!StaticText)
...@@ -73,13 +73,13 @@ void CGUIMessageBox::refreshControls() ...@@ -73,13 +73,13 @@ void CGUIMessageBox::refreshControls()
} }
else else
{ {
StaticText->setRelativePosition( core::rect<s32>(pos, dim)); StaticText->setRelativePosition(core::rect<s32>(pos, dim));
StaticText->setText(MessageText.c_str()); StaticText->setText(MessageText.c_str());
} }
// adjust static text height // adjust static text height
s32 textHeight = StaticText->getTextHeight(); const s32 textHeight = StaticText->getTextHeight();
core::rect<s32> tmp = StaticText->getRelativePosition(); core::rect<s32> tmp = StaticText->getRelativePosition();
tmp.LowerRightCorner.Y = tmp.UpperLeftCorner.Y + textHeight; tmp.LowerRightCorner.Y = tmp.UpperLeftCorner.Y + textHeight;
StaticText->setRelativePosition(tmp); StaticText->setRelativePosition(tmp);
...@@ -88,7 +88,7 @@ void CGUIMessageBox::refreshControls() ...@@ -88,7 +88,7 @@ void CGUIMessageBox::refreshControls()
// adjust message box height // adjust message box height
tmp = getRelativePosition(); tmp = getRelativePosition();
s32 msgBoxHeight = textHeight + (s32)(2.5f * buttonHeight) + titleHeight; s32 msgBoxHeight = textHeight + core::floor32(2.5f * buttonHeight) + titleHeight;
// adjust message box position // adjust message box position
...@@ -99,10 +99,14 @@ void CGUIMessageBox::refreshControls() ...@@ -99,10 +99,14 @@ void CGUIMessageBox::refreshControls()
// add buttons // add buttons
s32 countButtons = 0; s32 countButtons = 0;
if (Flags & EMBF_OK) ++countButtons; if (Flags & EMBF_OK)
if (Flags & EMBF_CANCEL) ++countButtons; ++countButtons;
if (Flags & EMBF_YES) ++countButtons; if (Flags & EMBF_CANCEL)
if (Flags & EMBF_NO) ++countButtons; ++countButtons;
if (Flags & EMBF_YES)
++countButtons;
if (Flags & EMBF_NO)
++countButtons;
core::rect<s32> btnRect; core::rect<s32> btnRect;
btnRect.UpperLeftCorner.Y = pos.Y + dim.Height + buttonHeight / 2; btnRect.UpperLeftCorner.Y = pos.Y + dim.Height + buttonHeight / 2;
...@@ -134,7 +138,7 @@ void CGUIMessageBox::refreshControls() ...@@ -134,7 +138,7 @@ void CGUIMessageBox::refreshControls()
{ {
OkButton->drop(); OkButton->drop();
OkButton->remove(); OkButton->remove();
OkButton =0; OkButton = 0;
} }
// add cancel button // add cancel button
...@@ -150,7 +154,6 @@ void CGUIMessageBox::refreshControls() ...@@ -150,7 +154,6 @@ void CGUIMessageBox::refreshControls()
CancelButton->setRelativePosition(btnRect); CancelButton->setRelativePosition(btnRect);
CancelButton->setText(skin->getDefaultText(EGDT_MSG_BOX_CANCEL)); CancelButton->setText(skin->getDefaultText(EGDT_MSG_BOX_CANCEL));
CancelButton->grab();
btnRect.LowerRightCorner.X += buttonWidth + buttonDistance; btnRect.LowerRightCorner.X += buttonWidth + buttonDistance;
btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance; btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance;
...@@ -305,12 +308,14 @@ bool CGUIMessageBox::OnEvent(SEvent event) ...@@ -305,12 +308,14 @@ bool CGUIMessageBox::OnEvent(SEvent event)
CloseButton->setPressed(true); CloseButton->setPressed(true);
Pressed = true; Pressed = true;
} }
break;
default: // no other key is handled here
break;
} }
} }
else else
if (Pressed) if (Pressed)
{ {
if (OkButton && event.KeyInput.Key == KEY_RETURN) if (OkButton && event.KeyInput.Key == KEY_RETURN)
{ {
outevent.GUIEvent.EventType = EGET_MESSAGEBOX_OK; outevent.GUIEvent.EventType = EGET_MESSAGEBOX_OK;
...@@ -392,11 +397,11 @@ void CGUIMessageBox::serializeAttributes(io::IAttributes* out, io::SAttributeRea ...@@ -392,11 +397,11 @@ void CGUIMessageBox::serializeAttributes(io::IAttributes* out, io::SAttributeRea
CGUIWindow::serializeAttributes(out,options); CGUIWindow::serializeAttributes(out,options);
out->addBool ("OkayButton", (Flags & EMBF_OK) != 0 ); out->addBool ("OkayButton", (Flags & EMBF_OK) != 0 );
out->addBool ("CancelButton", (Flags & EMBF_CANCEL)!= 0 ); out->addBool ("CancelButton", (Flags & EMBF_CANCEL) != 0 );
out->addBool ("YesButton", (Flags & EMBF_YES) != 0 ); out->addBool ("YesButton", (Flags & EMBF_YES) != 0 );
out->addBool ("NoButton", (Flags & EMBF_NO) != 0 ); out->addBool ("NoButton", (Flags & EMBF_NO) != 0 );
out->addString ("MessageText", MessageText.c_str() ); out->addString ("MessageText", MessageText.c_str());
} }
//! Reads attributes of the element //! Reads attributes of the element
...@@ -414,7 +419,6 @@ void CGUIMessageBox::deserializeAttributes(io::IAttributes* in, io::SAttributeRe ...@@ -414,7 +419,6 @@ void CGUIMessageBox::deserializeAttributes(io::IAttributes* in, io::SAttributeRe
CGUIWindow::deserializeAttributes(in,options); CGUIWindow::deserializeAttributes(in,options);
refreshControls(); refreshControls();
} }
...@@ -423,3 +427,4 @@ void CGUIMessageBox::deserializeAttributes(io::IAttributes* in, io::SAttributeRe ...@@ -423,3 +427,4 @@ void CGUIMessageBox::deserializeAttributes(io::IAttributes* in, io::SAttributeRe
#endif // _IRR_COMPILE_WITH_GUI_ #endif // _IRR_COMPILE_WITH_GUI_
This diff is collapsed.
...@@ -27,22 +27,22 @@ namespace gui ...@@ -27,22 +27,22 @@ namespace gui
CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver); CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver);
//! destructor //! destructor
~CGUISkin(); virtual ~CGUISkin();
//! returns default color //! returns default color
virtual video::SColor getColor(EGUI_DEFAULT_COLOR color); virtual video::SColor getColor(EGUI_DEFAULT_COLOR color) const;
//! sets a default color //! sets a default color
virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor); virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor);
//! returns default color //! returns default color
virtual s32 getSize(EGUI_DEFAULT_SIZE size); virtual s32 getSize(EGUI_DEFAULT_SIZE size) const;
//! sets a default size //! sets a default size
virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size); virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size);
//! returns the default font //! returns the default font
virtual IGUIFont* getFont(EGUI_DEFAULT_FONT which=EGDF_DEFAULT); virtual IGUIFont* getFont(EGUI_DEFAULT_FONT which=EGDF_DEFAULT) const;
//! sets a default font //! sets a default font
virtual void setFont(IGUIFont* font, EGUI_DEFAULT_FONT which=EGDF_DEFAULT); virtual void setFont(IGUIFont* font, EGUI_DEFAULT_FONT which=EGDF_DEFAULT);
...@@ -51,11 +51,11 @@ namespace gui ...@@ -51,11 +51,11 @@ namespace gui
virtual void setSpriteBank(IGUISpriteBank* bank); virtual void setSpriteBank(IGUISpriteBank* bank);
//! gets the sprite bank used for drawing icons //! gets the sprite bank used for drawing icons
virtual IGUISpriteBank* getSpriteBank(); virtual IGUISpriteBank* getSpriteBank() const;
//! Returns a default icon //! Returns a default icon
/** Returns the sprite index within the sprite bank */ /** Returns the sprite index within the sprite bank */
virtual u32 getIcon(EGUI_DEFAULT_ICON icon); virtual u32 getIcon(EGUI_DEFAULT_ICON icon) const;
//! Sets a default icon //! Sets a default icon
/** Sets the sprite index used for drawing icons like arrows, /** Sets the sprite index used for drawing icons like arrows,
...@@ -67,7 +67,7 @@ namespace gui ...@@ -67,7 +67,7 @@ namespace gui
//! Returns a default text. //! Returns a default text.
/** For example for Message box button captions: /** For example for Message box button captions:
"OK", "Cancel", "Yes", "No" and so on. */ "OK", "Cancel", "Yes", "No" and so on. */
virtual const wchar_t* getDefaultText(EGUI_DEFAULT_TEXT text); virtual const wchar_t* getDefaultText(EGUI_DEFAULT_TEXT text) const;
//! Sets a default text. //! Sets a default text.
/** For example for Message box button captions: /** For example for Message box button captions:
...@@ -111,7 +111,8 @@ namespace gui ...@@ -111,7 +111,8 @@ namespace gui
\param rect: Defining area where to draw. \param rect: Defining area where to draw.
\param clip: Clip area. */ \param clip: Clip area. */
virtual void draw3DSunkenPane(IGUIElement* element, virtual void draw3DSunkenPane(IGUIElement* element,
video::SColor bgcolor, bool flat, bool fillBackGround, video::SColor bgcolor, bool flat,
bool fillBackGround,
const core::rect<s32>& rect, const core::rect<s32>& rect,
const core::rect<s32>* clip=0); const core::rect<s32>* clip=0);
...@@ -174,7 +175,8 @@ namespace gui ...@@ -174,7 +175,8 @@ namespace gui
\param background: Specifies if the background should be drawn. \param background: Specifies if the background should be drawn.
\param rect: Defining area where to draw. \param rect: Defining area where to draw.
\param clip: Clip area. */ \param clip: Clip area. */
virtual void draw3DTabBody(IGUIElement* element, bool border, bool background, virtual void draw3DTabBody(IGUIElement* element, bool border,
bool background,
const core::rect<s32>& rect, const core::rect<s32>& rect,
const core::rect<s32>* clip=0); const core::rect<s32>* clip=0);
...@@ -189,7 +191,8 @@ namespace gui ...@@ -189,7 +191,8 @@ namespace gui
\param loop: Whether the animation should loop or not \param loop: Whether the animation should loop or not
\param clip: Clip area. */ \param clip: Clip area. */
virtual void drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon, virtual void drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon,
const core::position2di position, u32 starttime=0, u32 currenttime=0, const core::position2di position,
u32 starttime=0, u32 currenttime=0,
bool loop=false, const core::rect<s32>* clip=0); bool loop=false, const core::rect<s32>* clip=0);
......
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