it's me again!
In my project I needed something like a background for my gui-elements that is not as complete gui window.
So i have a little gui class that renders that background. In my project it looks like that:

Header:
Code: Select all
#ifndef _INCLUDE_C_GUI_COLORED_BACKGROUND_
#define _INCLUDE_C_GUI_COLORED_BACKGROUND_
#include <irrlicht.h>
namespace irr
{
namespace gui
{
class CGUIColoredBackground : public IGUIElement
{
public:
CGUIColoredBackground(IGUIElement* parent, IGUIEnvironment* guiEnv, core::rect<s32> rect,
video::SColor color, video::SColor borderColor, s32 borderThickness, s32 id = -1);
video::SColor getColor() const;
void setColor(video::SColor newColor);
video::SColor getBorderColor() const;
void setBorderColor(video::SColor newBorderColor);
s32 getBorderThickness() const;
void setBorderThickness(s32 newValue);
virtual void draw();
private:
s32 BorderThickness;
video::SColor Color, BorderColor;
IGUIEnvironment* GuiEnv;
};
} //! end namespace gui
} //! end namespace irr
#endifCode: Select all
#include "CGUIColoredBackground.h"
namespace irr
{
namespace gui
{
CGUIColoredBackground::CGUIColoredBackground(IGUIElement* parent, IGUIEnvironment* guiEnv, core::rect<s32> rect, video::SColor color,
video::SColor borderColor, s32 borderThickness, s32 id)
: IGUIElement(EGUIET_ELEMENT, guiEnv, parent, id, rect), BorderThickness(borderThickness), GuiEnv(guiEnv)
{
this->setColor(color);
this->setBorderColor(borderColor);
}
video::SColor CGUIColoredBackground::getColor() const
{
return Color;
}
void CGUIColoredBackground::setColor(video::SColor newColor)
{
Color = newColor;
}
video::SColor CGUIColoredBackground::getBorderColor() const
{
return BorderColor;
}
void CGUIColoredBackground::setBorderColor(video::SColor newBorderColor)
{
BorderColor = newBorderColor;
}
s32 CGUIColoredBackground::getBorderThickness() const
{
return BorderThickness;
}
void CGUIColoredBackground::setBorderThickness(s32 newValue)
{
BorderThickness = newValue;
}
void CGUIColoredBackground::draw()
{
core::rect<s32> borderRect(AbsoluteClippingRect.UpperLeftCorner - core::position2di(BorderThickness, BorderThickness),
AbsoluteClippingRect.LowerRightCorner + core::position2di(BorderThickness, BorderThickness));
GuiEnv->getSkin()->draw2DRectangle(this, BorderColor, borderRect, 0);
GuiEnv->getSkin()->draw2DRectangle(this, Color, AbsoluteClippingRect, 0);
IGUIElement::draw();
}
} //! end namespace gui
} //! end namepsace irr
greets,
Halan