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_
...@@ -60,7 +60,6 @@ CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver) ...@@ -60,7 +60,6 @@ CGUISkin::CGUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver)
Sizes[EGDS_TEXT_DISTANCE_X] = 2; Sizes[EGDS_TEXT_DISTANCE_X] = 2;
Sizes[EGDS_TEXT_DISTANCE_Y] = 0; Sizes[EGDS_TEXT_DISTANCE_Y] = 0;
} }
else else
{ {
...@@ -159,24 +158,30 @@ CGUISkin::~CGUISkin() ...@@ -159,24 +158,30 @@ CGUISkin::~CGUISkin()
//! returns default color //! returns default color
video::SColor CGUISkin::getColor(EGUI_DEFAULT_COLOR color) video::SColor CGUISkin::getColor(EGUI_DEFAULT_COLOR color) const
{ {
if ((u32)color < EGDC_COUNT)
return Colors[color]; return Colors[color];
else
return video::SColor();
} }
//! sets a default color //! sets a default color
void CGUISkin::setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor) void CGUISkin::setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor)
{ {
if (which>=0 && which<= EGDC_COUNT) if ((u32)which < EGDC_COUNT)
Colors[which] = newColor; Colors[which] = newColor;
} }
//! returns default color //! returns default color
s32 CGUISkin::getSize(EGUI_DEFAULT_SIZE size) s32 CGUISkin::getSize(EGUI_DEFAULT_SIZE size) const
{ {
if ((u32)size < EGDS_COUNT)
return Sizes[size]; return Sizes[size];
else
return 0;
} }
...@@ -184,16 +189,16 @@ s32 CGUISkin::getSize(EGUI_DEFAULT_SIZE size) ...@@ -184,16 +189,16 @@ s32 CGUISkin::getSize(EGUI_DEFAULT_SIZE size)
//! sets a default size //! sets a default size
void CGUISkin::setSize(EGUI_DEFAULT_SIZE which, s32 size) void CGUISkin::setSize(EGUI_DEFAULT_SIZE which, s32 size)
{ {
if (which >= 0 && which <= EGDS_COUNT) if ((u32)which < EGDS_COUNT)
Sizes[which] = size; Sizes[which] = size;
} }
//! returns the default font //! returns the default font
IGUIFont* CGUISkin::getFont(EGUI_DEFAULT_FONT which) IGUIFont* CGUISkin::getFont(EGUI_DEFAULT_FONT which) const
{ {
if (Fonts[which]) if (((u32)which < EGDS_COUNT) && Fonts[which])
return Fonts[which]; return Fonts[which];
else else
return Fonts[EGDF_DEFAULT]; return Fonts[EGDF_DEFAULT];
...@@ -202,6 +207,9 @@ IGUIFont* CGUISkin::getFont(EGUI_DEFAULT_FONT which) ...@@ -202,6 +207,9 @@ IGUIFont* CGUISkin::getFont(EGUI_DEFAULT_FONT which)
//! sets a default font //! sets a default font
void CGUISkin::setFont(IGUIFont* font, EGUI_DEFAULT_FONT which) void CGUISkin::setFont(IGUIFont* font, EGUI_DEFAULT_FONT which)
{ {
if ((u32)which >= EGDS_COUNT)
return;
if (Fonts[which]) if (Fonts[which])
Fonts[which]->drop(); Fonts[which]->drop();
...@@ -211,11 +219,15 @@ void CGUISkin::setFont(IGUIFont* font, EGUI_DEFAULT_FONT which) ...@@ -211,11 +219,15 @@ void CGUISkin::setFont(IGUIFont* font, EGUI_DEFAULT_FONT which)
Fonts[which]->grab(); Fonts[which]->grab();
} }
IGUISpriteBank* CGUISkin::getSpriteBank()
//! gets the sprite bank stored
IGUISpriteBank* CGUISkin::getSpriteBank() const
{ {
return SpriteBank; return SpriteBank;
} }
//! set a new sprite bank or remove one by passing 0
void CGUISkin::setSpriteBank(IGUISpriteBank* bank) void CGUISkin::setSpriteBank(IGUISpriteBank* bank)
{ {
if (SpriteBank) if (SpriteBank)
...@@ -227,23 +239,31 @@ void CGUISkin::setSpriteBank(IGUISpriteBank* bank) ...@@ -227,23 +239,31 @@ void CGUISkin::setSpriteBank(IGUISpriteBank* bank)
SpriteBank = bank; SpriteBank = bank;
} }
//! Returns a default icon //! Returns a default icon
u32 CGUISkin::getIcon(EGUI_DEFAULT_ICON icon) u32 CGUISkin::getIcon(EGUI_DEFAULT_ICON icon) const
{ {
if ((u32)icon < EGDI_COUNT)
return Icons[icon]; return Icons[icon];
else
return 0;
} }
//! Sets a default icon //! Sets a default icon
void CGUISkin::setIcon(EGUI_DEFAULT_ICON icon, u32 index) void CGUISkin::setIcon(EGUI_DEFAULT_ICON icon, u32 index)
{ {
if ((u32)icon < EGDI_COUNT)
Icons[icon] = index; Icons[icon] = index;
} }
//! Returns a default text. For example for Message box button captions: //! Returns a default text. For example for Message box button captions:
//! "OK", "Cancel", "Yes", "No" and so on. //! "OK", "Cancel", "Yes", "No" and so on.
const wchar_t* CGUISkin::getDefaultText(EGUI_DEFAULT_TEXT text) const wchar_t* CGUISkin::getDefaultText(EGUI_DEFAULT_TEXT text) const
{ {
if ((u32)text < EGDT_COUNT)
return Texts[text].c_str(); return Texts[text].c_str();
else
return Texts[0].c_str();
} }
...@@ -251,6 +271,7 @@ const wchar_t* CGUISkin::getDefaultText(EGUI_DEFAULT_TEXT text) ...@@ -251,6 +271,7 @@ const wchar_t* CGUISkin::getDefaultText(EGUI_DEFAULT_TEXT text)
//! "OK", "Cancel", "Yes", "No" and so on. //! "OK", "Cancel", "Yes", "No" and so on.
void CGUISkin::setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText) void CGUISkin::setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText)
{ {
if ((u32)which < EGDT_COUNT)
Texts[which] = newText; Texts[which] = newText;
} }
...@@ -303,8 +324,8 @@ void CGUISkin::draw3DButtonPaneStandard(IGUIElement* element, ...@@ -303,8 +324,8 @@ void CGUISkin::draw3DButtonPaneStandard(IGUIElement* element,
} }
else else
{ {
video::SColor c1 = getColor(EGDC_3D_FACE); const video::SColor c1 = getColor(EGDC_3D_FACE);
video::SColor c2 = c1.getInterpolated(getColor(EGDC_3D_DARK_SHADOW), 0.4f); const video::SColor c2 = c1.getInterpolated(getColor(EGDC_3D_DARK_SHADOW), 0.4f);
Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip);
} }
} }
...@@ -346,8 +367,8 @@ void CGUISkin::draw3DButtonPanePressed(IGUIElement* element, ...@@ -346,8 +367,8 @@ void CGUISkin::draw3DButtonPanePressed(IGUIElement* element,
} }
else else
{ {
video::SColor c1 = getColor(EGDC_3D_FACE); const video::SColor c1 = getColor(EGDC_3D_FACE);
video::SColor c2 = c1.getInterpolated(getColor(EGDC_3D_DARK_SHADOW), 0.4f); const video::SColor c2 = c1.getInterpolated(getColor(EGDC_3D_DARK_SHADOW), 0.4f);
Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip);
} }
} }
...@@ -363,8 +384,8 @@ implementations to find out how to draw the part exactly. ...@@ -363,8 +384,8 @@ implementations to find out how to draw the part exactly.
deep into the ground. deep into the ground.
\param rect: Defining area where to draw. \param rect: Defining area where to draw.
\param clip: Clip area. */ \param clip: Clip area. */
void CGUISkin::draw3DSunkenPane(IGUIElement* element, void CGUISkin::draw3DSunkenPane(IGUIElement* element, video::SColor bgcolor,
video::SColor bgcolor, bool flat, bool fillBackGround, bool flat, bool fillBackGround,
const core::rect<s32>& r, const core::rect<s32>& r,
const core::rect<s32>* clip) const core::rect<s32>* clip)
{ {
...@@ -373,7 +394,6 @@ void CGUISkin::draw3DSunkenPane(IGUIElement* element, ...@@ -373,7 +394,6 @@ void CGUISkin::draw3DSunkenPane(IGUIElement* element,
core::rect<s32> rect = r; core::rect<s32> rect = r;
if (flat) if (flat)
{ {
// draw flat sunken pane // draw flat sunken pane
...@@ -441,7 +461,6 @@ core::rect<s32> CGUISkin::draw3DWindowBackground(IGUIElement* element, ...@@ -441,7 +461,6 @@ core::rect<s32> CGUISkin::draw3DWindowBackground(IGUIElement* element,
core::rect<s32> rect = r; core::rect<s32> rect = r;
rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1; rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1;
Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, cl); Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, cl);
...@@ -486,15 +505,15 @@ core::rect<s32> CGUISkin::draw3DWindowBackground(IGUIElement* element, ...@@ -486,15 +505,15 @@ core::rect<s32> CGUISkin::draw3DWindowBackground(IGUIElement* element,
else else
if ( Type == EGST_BURNING_SKIN ) if ( Type == EGST_BURNING_SKIN )
{ {
video::SColor c1 = getColor(EGDC_WINDOW).getInterpolated ( 0xFFFFFFFF, 0.9f ); const video::SColor c1 = getColor(EGDC_WINDOW).getInterpolated ( 0xFFFFFFFF, 0.9f );
video::SColor c2 = getColor(EGDC_WINDOW).getInterpolated ( 0xFFFFFFFF, 0.8f ); const video::SColor c2 = getColor(EGDC_WINDOW).getInterpolated ( 0xFFFFFFFF, 0.8f );
Driver->draw2DRectangle(rect, c1, c1, c2, c2, cl); Driver->draw2DRectangle(rect, c1, c1, c2, c2, cl);
} }
else else
{ {
video::SColor c2 = getColor(EGDC_3D_SHADOW); const video::SColor c2 = getColor(EGDC_3D_SHADOW);
video::SColor c1 = getColor(EGDC_3D_FACE); const video::SColor c1 = getColor(EGDC_3D_FACE);
Driver->draw2DRectangle(rect, c1, c1, c1, c2, cl); Driver->draw2DRectangle(rect, c1, c1, c1, c2, cl);
} }
...@@ -512,12 +531,12 @@ core::rect<s32> CGUISkin::draw3DWindowBackground(IGUIElement* element, ...@@ -512,12 +531,12 @@ core::rect<s32> CGUISkin::draw3DWindowBackground(IGUIElement* element,
//else //else
if ( Type == EGST_BURNING_SKIN ) if ( Type == EGST_BURNING_SKIN )
{ {
video::SColor c = titleBarColor.getInterpolated( 0xffffffff, 0.8f); const video::SColor c = titleBarColor.getInterpolated( 0xffffffff, 0.8f);
Driver->draw2DRectangle(rect, titleBarColor, titleBarColor, c, c, cl); Driver->draw2DRectangle(rect, titleBarColor, titleBarColor, c, c, cl);
} }
else else
{ {
video::SColor c = titleBarColor.getInterpolated(video::SColor(255,0,0,0), 0.2f); const video::SColor c = titleBarColor.getInterpolated(video::SColor(255,0,0,0), 0.2f);
Driver->draw2DRectangle(rect, titleBarColor, c, titleBarColor, c, cl); Driver->draw2DRectangle(rect, titleBarColor, c, titleBarColor, c, cl);
} }
} }
...@@ -538,17 +557,18 @@ implementations to find out how to draw the part exactly. ...@@ -538,17 +557,18 @@ implementations to find out how to draw the part exactly.
void CGUISkin::draw3DMenuPane(IGUIElement* element, void CGUISkin::draw3DMenuPane(IGUIElement* element,
const core::rect<s32>& r, const core::rect<s32>* clip) const core::rect<s32>& r, const core::rect<s32>* clip)
{ {
if (!Driver)
return;
core::rect<s32> rect = r;
if ( Type == EGST_BURNING_SKIN ) if ( Type == EGST_BURNING_SKIN )
{ {
core::rect<s32> rect = r;
rect.UpperLeftCorner.Y -= 3; rect.UpperLeftCorner.Y -= 3;
draw3DButtonPaneStandard(element, rect, clip); draw3DButtonPaneStandard(element, rect, clip);
return; return;
} }
if (!Driver)
return;
// in this skin, this is exactly what non pressed buttons look like, // in this skin, this is exactly what non pressed buttons look like,
// so we could simply call // so we could simply call
// draw3DButtonPaneStandard(element, rect, clip); // draw3DButtonPaneStandard(element, rect, clip);
...@@ -557,7 +577,6 @@ void CGUISkin::draw3DMenuPane(IGUIElement* element, ...@@ -557,7 +577,6 @@ void CGUISkin::draw3DMenuPane(IGUIElement* element,
// We draw it a little bit better, with some more draw2DRectangle calls, // We draw it a little bit better, with some more draw2DRectangle calls,
// but there aren't that much menus visible anyway. // but there aren't that much menus visible anyway.
core::rect<s32> rect = r;
rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1; rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1;
Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip); Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), rect, clip);
...@@ -599,8 +618,8 @@ void CGUISkin::draw3DMenuPane(IGUIElement* element, ...@@ -599,8 +618,8 @@ void CGUISkin::draw3DMenuPane(IGUIElement* element,
Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip); Driver->draw2DRectangle(getColor(EGDC_3D_FACE), rect, clip);
else else
{ {
video::SColor c1 = getColor(EGDC_3D_FACE); const video::SColor c1 = getColor(EGDC_3D_FACE);
video::SColor c2 = getColor(EGDC_3D_SHADOW); const video::SColor c2 = getColor(EGDC_3D_SHADOW);
Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip);
} }
} }
...@@ -638,21 +657,21 @@ void CGUISkin::draw3DToolBar(IGUIElement* element, ...@@ -638,21 +657,21 @@ void CGUISkin::draw3DToolBar(IGUIElement* element,
else else
if ( Type == EGST_BURNING_SKIN ) if ( Type == EGST_BURNING_SKIN )
{ {
video::SColor c1 = 0xF0000000 | getColor(EGDC_3D_FACE).color; const video::SColor c1 = 0xF0000000 | getColor(EGDC_3D_FACE).color;
video::SColor c2 = 0xF0000000 | getColor(EGDC_3D_SHADOW).color; const video::SColor c2 = 0xF0000000 | getColor(EGDC_3D_SHADOW).color;
rect.LowerRightCorner.Y += 1; rect.LowerRightCorner.Y += 1;
Driver->draw2DRectangle(rect, c1, c2, c1, c2, clip); Driver->draw2DRectangle(rect, c1, c2, c1, c2, clip);
} }
else else
{ {
video::SColor c1 = getColor(EGDC_3D_FACE); const video::SColor c1 = getColor(EGDC_3D_FACE);
video::SColor c2 = getColor(EGDC_3D_SHADOW); const video::SColor c2 = getColor(EGDC_3D_SHADOW);
Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip); Driver->draw2DRectangle(rect, c1, c1, c2, c2, clip);
} }
} }
//! draws a tab button //! draws a tab button
/** Used for drawing for tab buttons on top of tabs. /** Used for drawing for tab buttons on top of tabs.
\param element: Pointer to the element which whiches to draw this. This parameter \param element: Pointer to the element which whiches to draw this. This parameter
...@@ -662,7 +681,8 @@ implementations to find out how to draw the part exactly. ...@@ -662,7 +681,8 @@ implementations to find out how to draw the part exactly.
\param rect: Defining area where to draw. \param rect: Defining area where to draw.
\param clip: Clip area. */ \param clip: Clip area. */
void CGUISkin::draw3DTabButton(IGUIElement* element, bool active, void CGUISkin::draw3DTabButton(IGUIElement* element, bool active,
const core::rect<s32>& frameRect, const core::rect<s32>* clip) const core::rect<s32>& frameRect,
const core::rect<s32>* clip)
{ {
if (!Driver) if (!Driver)
return; return;
...@@ -746,13 +766,14 @@ void CGUISkin::draw3DTabBody(IGUIElement* element, bool border, bool background, ...@@ -746,13 +766,14 @@ void CGUISkin::draw3DTabBody(IGUIElement* element, bool border, bool background,
Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip); Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip);
else else
{ {
video::SColor c1 = getColor(EGDC_3D_FACE); const video::SColor c1 = getColor(EGDC_3D_FACE);
video::SColor c2 = getColor(EGDC_3D_SHADOW); const video::SColor c2 = getColor(EGDC_3D_SHADOW);
Driver->draw2DRectangle(tr, c1, c1, c2, c2, clip); Driver->draw2DRectangle(tr, c1, c1, c2, c2, clip);
} }
} }
} }
//! draws an icon, usually from the skin's sprite bank //! draws an icon, usually from the skin's sprite bank
/** \param parent: Pointer to the element which wishes to draw this icon. /** \param parent: Pointer to the element which wishes to draw this icon.
This parameter is usually not used by IGUISkin, but can be used for example This parameter is usually not used by IGUISkin, but can be used for example
...@@ -764,7 +785,8 @@ by more complex implementations to find out how to draw the part exactly. ...@@ -764,7 +785,8 @@ by more complex implementations to find out how to draw the part exactly.
\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. */
void CGUISkin::drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon, void CGUISkin::drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon,
const core::position2di position, u32 starttime, u32 currenttime, const core::position2di position,
u32 starttime, u32 currenttime,
bool loop, const core::rect<s32>* clip) bool loop, const core::rect<s32>* clip)
{ {
if (!SpriteBank) if (!SpriteBank)
...@@ -772,14 +794,15 @@ void CGUISkin::drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon, ...@@ -772,14 +794,15 @@ void CGUISkin::drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon,
SpriteBank->draw2DSprite(Icons[icon], position, clip, SpriteBank->draw2DSprite(Icons[icon], position, clip,
video::SColor(255,0,0,0), starttime, currenttime, loop, true); video::SColor(255,0,0,0), starttime, currenttime, loop, true);
} }
EGUI_SKIN_TYPE CGUISkin::getType() const EGUI_SKIN_TYPE CGUISkin::getType() const
{ {
return Type; return Type;
} }
//! draws a 2d rectangle. //! draws a 2d rectangle.
void CGUISkin::draw2DRectangle(IGUIElement* element, void CGUISkin::draw2DRectangle(IGUIElement* element,
const video::SColor &color, const core::rect<s32>& pos, const video::SColor &color, const core::rect<s32>& pos,
...@@ -788,6 +811,7 @@ void CGUISkin::draw2DRectangle(IGUIElement* element, ...@@ -788,6 +811,7 @@ void CGUISkin::draw2DRectangle(IGUIElement* element,
Driver->draw2DRectangle(color, pos, clip); Driver->draw2DRectangle(color, pos, clip);
} }
//! Writes attributes of the object. //! Writes attributes of the object.
//! Implement this to expose the attributes of your scene node animator for //! Implement this to expose the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml serialization purposes. //! scripting languages, editors, debuggers or xml serialization purposes.
...@@ -807,6 +831,7 @@ void CGUISkin::serializeAttributes(io::IAttributes* out, io::SAttributeReadWrite ...@@ -807,6 +831,7 @@ void CGUISkin::serializeAttributes(io::IAttributes* out, io::SAttributeReadWrite
out->addInt(GUISkinIconNames[i], Icons[i]); out->addInt(GUISkinIconNames[i], Icons[i]);
} }
//! Reads attributes of the object. //! Reads attributes of the object.
//! Implement this to set the attributes of your scene node animator for //! Implement this to set the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml deserialization purposes. //! scripting languages, editors, debuggers or xml deserialization purposes.
...@@ -824,7 +849,6 @@ void CGUISkin::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWrit ...@@ -824,7 +849,6 @@ void CGUISkin::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWrit
for (i=0; i<EGDI_COUNT; ++i) for (i=0; i<EGDI_COUNT; ++i)
Icons[i] = in->getAttributeAsInt(GUISkinIconNames[i]); Icons[i] = in->getAttributeAsInt(GUISkinIconNames[i]);
} }
...@@ -832,3 +856,4 @@ void CGUISkin::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWrit ...@@ -832,3 +856,4 @@ void CGUISkin::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWrit
} // end namespace irr } // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_ #endif // _IRR_COMPILE_WITH_GUI_
...@@ -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