You need to sign in or sign up before continuing.
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:
virtual IGUISkin* getSkin() = 0;
//! Sets a new GUI Skin
/** You can used 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
IGUISkin and set this useing this method.
/** You can use this to change the appearance of the whole GUI Environment. You
can set one of the built-in skins or implement your own class derived from
IGUISkin and enable it using this method.
To set for example the built-in Windows classic skin, use the following code:
\code
gui::IGUISkin* newskin = environment->createSkin(gui::EGST_WINDOWS_CLASSIC);
......@@ -126,7 +126,7 @@ public:
//! Creates a new GUI Skin based on a template.
/** Use setSkin() to set 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. */
virtual IGUISkin* createSkin(EGUI_SKIN_TYPE type) = 0;
......
......@@ -326,21 +326,21 @@ namespace gui
public:
//! destructor
~IGUISkin() {};
virtual ~IGUISkin() {};
//! 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
virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor) = 0;
//! returns default color
virtual s32 getSize(EGUI_DEFAULT_SIZE size) = 0;
virtual s32 getSize(EGUI_DEFAULT_SIZE size) const = 0;
//! Returns a default text.
/** For example for Message box button captions:
"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.
/** For example for Message box button captions:
......@@ -351,20 +351,20 @@ namespace gui
virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size) = 0;
//! 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
virtual void setFont(IGUIFont* font, EGUI_DEFAULT_FONT which=EGDF_DEFAULT) = 0;
//! returns the sprite bank
virtual IGUISpriteBank* getSpriteBank() = 0;
virtual IGUISpriteBank* getSpriteBank() const = 0;
//! sets the sprite bank
virtual void setSpriteBank(IGUISpriteBank* bank) = 0;
//! Returns a default icon
/** 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 the sprite index used for drawing icons like arrows,
......
......@@ -48,24 +48,24 @@ CGUIMessageBox::CGUIMessageBox(IGUIEnvironment* environment, const wchar_t* capt
void CGUIMessageBox::refreshControls()
{
IGUISkin* skin = Environment->getSkin();
const IGUISkin* skin = Environment->getSkin();
IGUIElement* focusMe = 0;
s32 buttonHeight = skin->getSize(EGDS_BUTTON_HEIGHT);
s32 buttonWidth = skin->getSize(EGDS_BUTTON_WIDTH);
s32 titleHeight = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH)+2;
s32 buttonDistance = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH);
const s32 buttonHeight = skin->getSize(EGDS_BUTTON_HEIGHT);
const s32 buttonWidth = skin->getSize(EGDS_BUTTON_WIDTH);
const s32 titleHeight = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH)+2;
const s32 buttonDistance = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH);
// add static multiline text
core::dimension2d<s32> dim(AbsoluteClippingRect.getWidth() - buttonWidth,
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);
if (!StaticText)
{
StaticText = Environment->addStaticText(MessageText.c_str(),
StaticText = Environment->addStaticText(MessageText.c_str(),
core::rect<s32>(pos, dim), false, false, this);
StaticText->setWordWrap(true);
StaticText->setSubElement(true);
......@@ -73,13 +73,13 @@ void CGUIMessageBox::refreshControls()
}
else
{
StaticText->setRelativePosition( core::rect<s32>(pos, dim));
StaticText->setRelativePosition(core::rect<s32>(pos, dim));
StaticText->setText(MessageText.c_str());
}
// adjust static text height
s32 textHeight = StaticText->getTextHeight();
const s32 textHeight = StaticText->getTextHeight();
core::rect<s32> tmp = StaticText->getRelativePosition();
tmp.LowerRightCorner.Y = tmp.UpperLeftCorner.Y + textHeight;
StaticText->setRelativePosition(tmp);
......@@ -88,7 +88,7 @@ void CGUIMessageBox::refreshControls()
// adjust message box height
tmp = getRelativePosition();
s32 msgBoxHeight = textHeight + (s32)(2.5f * buttonHeight) + titleHeight;
s32 msgBoxHeight = textHeight + core::floor32(2.5f * buttonHeight) + titleHeight;
// adjust message box position
......@@ -99,15 +99,19 @@ void CGUIMessageBox::refreshControls()
// add buttons
s32 countButtons = 0;
if (Flags & EMBF_OK) ++countButtons;
if (Flags & EMBF_CANCEL) ++countButtons;
if (Flags & EMBF_YES) ++countButtons;
if (Flags & EMBF_NO) ++countButtons;
if (Flags & EMBF_OK)
++countButtons;
if (Flags & EMBF_CANCEL)
++countButtons;
if (Flags & EMBF_YES)
++countButtons;
if (Flags & EMBF_NO)
++countButtons;
core::rect<s32> btnRect;
btnRect.UpperLeftCorner.Y = pos.Y + dim.Height + buttonHeight / 2;
btnRect.LowerRightCorner.Y = btnRect.UpperLeftCorner.Y + buttonHeight;
btnRect.UpperLeftCorner.X = (AbsoluteClippingRect.getWidth() -
btnRect.UpperLeftCorner.X = (AbsoluteClippingRect.getWidth() -
((buttonWidth + buttonDistance)*countButtons)) / 2;
btnRect.LowerRightCorner.X = btnRect.UpperLeftCorner.X + buttonWidth;
......@@ -134,7 +138,7 @@ void CGUIMessageBox::refreshControls()
{
OkButton->drop();
OkButton->remove();
OkButton =0;
OkButton = 0;
}
// add cancel button
......@@ -150,7 +154,6 @@ void CGUIMessageBox::refreshControls()
CancelButton->setRelativePosition(btnRect);
CancelButton->setText(skin->getDefaultText(EGDT_MSG_BOX_CANCEL));
CancelButton->grab();
btnRect.LowerRightCorner.X += buttonWidth + buttonDistance;
btnRect.UpperLeftCorner.X += buttonWidth + buttonDistance;
......@@ -296,21 +299,23 @@ bool CGUIMessageBox::OnEvent(SEvent event)
else
if (CancelButton)
{
CancelButton->setPressed(true);
CancelButton->setPressed(true);
Pressed = true;
}
}
else
if (CloseButton && CloseButton->isVisible())
{
CloseButton->setPressed(true);
CloseButton->setPressed(true);
Pressed = true;
}
break;
default: // no other key is handled here
break;
}
}
else
if (Pressed)
{
if (OkButton && event.KeyInput.Key == KEY_RETURN)
{
outevent.GUIEvent.EventType = EGET_MESSAGEBOX_OK;
......@@ -355,7 +360,7 @@ bool CGUIMessageBox::OnEvent(SEvent event)
return true;
}
else
if (event.GUIEvent.Caller == CancelButton ||
if (event.GUIEvent.Caller == CancelButton ||
event.GUIEvent.Caller == CloseButton)
{
outevent.GUIEvent.EventType = EGET_MESSAGEBOX_CANCEL;
......@@ -391,12 +396,12 @@ void CGUIMessageBox::serializeAttributes(io::IAttributes* out, io::SAttributeRea
{
CGUIWindow::serializeAttributes(out,options);
out->addBool ("OkayButton", (Flags & EMBF_OK) != 0 );
out->addBool ("CancelButton", (Flags & EMBF_CANCEL)!= 0 );
out->addBool ("YesButton", (Flags & EMBF_YES) != 0 );
out->addBool ("NoButton", (Flags & EMBF_NO) != 0 );
out->addBool ("OkayButton", (Flags & EMBF_OK) != 0 );
out->addBool ("CancelButton", (Flags & EMBF_CANCEL) != 0 );
out->addBool ("YesButton", (Flags & EMBF_YES) != 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
......@@ -414,7 +419,6 @@ void CGUIMessageBox::deserializeAttributes(io::IAttributes* in, io::SAttributeRe
CGUIWindow::deserializeAttributes(in,options);
refreshControls();
}
......@@ -423,3 +427,4 @@ void CGUIMessageBox::deserializeAttributes(io::IAttributes* in, io::SAttributeRe
#endif // _IRR_COMPILE_WITH_GUI_
This diff is collapsed.
......@@ -27,22 +27,22 @@ namespace gui
CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver);
//! destructor
~CGUISkin();
virtual ~CGUISkin();
//! returns default color
virtual video::SColor getColor(EGUI_DEFAULT_COLOR color);
virtual video::SColor getColor(EGUI_DEFAULT_COLOR color) const;
//! sets a default color
virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor);
//! returns default color
virtual s32 getSize(EGUI_DEFAULT_SIZE size);
virtual s32 getSize(EGUI_DEFAULT_SIZE size) const;
//! sets a default size
virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size);
//! 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
virtual void setFont(IGUIFont* font, EGUI_DEFAULT_FONT which=EGDF_DEFAULT);
......@@ -51,11 +51,11 @@ namespace gui
virtual void setSpriteBank(IGUISpriteBank* bank);
//! gets the sprite bank used for drawing icons
virtual IGUISpriteBank* getSpriteBank();
virtual IGUISpriteBank* getSpriteBank() const;
//! Returns a default icon
/** 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 the sprite index used for drawing icons like arrows,
......@@ -67,7 +67,7 @@ namespace gui
//! Returns a default text.
/** For example for Message box button captions:
"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.
/** For example for Message box button captions:
......@@ -84,8 +84,8 @@ namespace gui
is usually not used by ISkin, but can be used for example by more complex
implementations to find out how to draw the part exactly. */
virtual void draw3DButtonPaneStandard(IGUIElement* element,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0);
const core::rect<s32>& rect,
const core::rect<s32>* clip=0);
//! draws a pressed 3d button pane
/** Used for drawing for example buttons in pressed state.
......@@ -97,8 +97,8 @@ namespace gui
is usually not used by ISkin, but can be used for example by more complex
implementations to find out how to draw the part exactly. */
virtual void draw3DButtonPanePressed(IGUIElement* element,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0);
const core::rect<s32>& rect,
const core::rect<s32>* clip=0);
//! draws a sunken 3d pane
/** Used for drawing the background of edit, combo or check boxes.
......@@ -111,9 +111,10 @@ namespace gui
\param rect: Defining area where to draw.
\param clip: Clip area. */
virtual void draw3DSunkenPane(IGUIElement* element,
video::SColor bgcolor, bool flat, bool fillBackGround,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0);
video::SColor bgcolor, bool flat,
bool fillBackGround,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0);
//! draws a window background
/** Used for drawing the background of dialogs and windows.
......@@ -126,9 +127,9 @@ namespace gui
\param clip: Clip area.
\return Returns rect where to draw title bar text. */
virtual core::rect<s32> draw3DWindowBackground(IGUIElement* element,
bool drawTitleBar, video::SColor titleBarColor,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0);
bool drawTitleBar, video::SColor titleBarColor,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0);
//! draws a standard 3d menu pane
/** Used for drawing for menus and context menus.
......@@ -140,8 +141,8 @@ namespace gui
\param rect: Defining area where to draw.
\param clip: Clip area. */
virtual void draw3DMenuPane(IGUIElement* element,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0);
const core::rect<s32>& rect,
const core::rect<s32>* clip=0);
//! draws a standard 3d tool bar
/** Used for drawing for toolbars and menus.
......@@ -151,8 +152,8 @@ namespace gui
\param rect: Defining area where to draw.
\param clip: Clip area. */
virtual void draw3DToolBar(IGUIElement* element,
const core::rect<s32>& rect,
const core::rect<s32>* clip=0);
const core::rect<s32>& rect,
const core::rect<s32>* clip=0);
//! draws a tab button
/** Used for drawing for tab buttons on top of tabs.
......@@ -174,7 +175,8 @@ namespace gui
\param background: Specifies if the background should be drawn.
\param rect: Defining area where to draw.
\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>* clip=0);
......@@ -189,8 +191,9 @@ namespace gui
\param loop: Whether the animation should loop or not
\param clip: Clip area. */
virtual void drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon,
const core::position2di position, u32 starttime=0, u32 currenttime=0,
bool loop=false, const core::rect<s32>* clip=0);
const core::position2di position,
u32 starttime=0, u32 currenttime=0,
bool loop=false, const core::rect<s32>* clip=0);
//! draws a 2d rectangle.
......@@ -203,7 +206,7 @@ namespace gui
\param clip: Pointer to rectangle against which the rectangle will be clipped.
If the pointer is null, no clipping will be performed. */
virtual void draw2DRectangle(IGUIElement* element, const video::SColor &color,
const core::rect<s32>& pos, const core::rect<s32>* clip = 0);
const core::rect<s32>& pos, const core::rect<s32>* clip = 0);
//! get the type of this skin
......
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