[SOLVED]problems creating a new IGUIElement...
Posted: Wed Jun 13, 2007 8:40 pm
i want to create a new IGUIElement which would just draw a background of a certain color, but can't get something to work :s
my class def :
^ nothing which differs much from a IGUIImage by example..
and in the .cpp :
I have tried to draw an image (as in the CGUIImage class), but it doesn't help.... so either this doesn't work, or (and there is a high chance for that) my init is screwed and my GUIBackground is not attached to the GUIEnvironment, and thus isn't drawn in the loop....
anyway, thanks to anyone with an advice on this
ps : i don't intend to modify the IGUIEnvironment class and as of now i just my constructor and set the color directly (not via a "addBg" fonction)... i have looked at the addXX functions to see if they did add important things and it seems it is not the case, thus i doubt the problem comes from this (i am saying it just in case ^^)
my class def :
Code: Select all
protected :
irr::video::SColor color;
public:
//! constructor
/*!
constructor (cf Irrlicht's IGUIElements)
\param irr::gui::IGUIEnvironment* environment
\param irr::gui::IGUIElement* parent
\param irr::s32 id
\param irr::core::rect<irr::s32> rectangle : where to draw
*/
MaximaGUIBackground(
irr::gui::IGUIEnvironment* environment,
irr::gui::IGUIElement* parent, irr::s32 id,
irr::core::rect<irr::s32> rectangle);
//! destructor
~MaximaGUIBackground();
//! sets the background color
virtual void setColor(irr::video::SColor color);
//! draws the element and its children
virtual void draw();
and in the .cpp :
Code: Select all
// constructor (i am sure i screwed up something, though there ain't much ^^")
GUIBackground::GUIBackground(
irr::gui::IGUIEnvironment* environment,
irr::gui::IGUIElement* parent,
s32 id,
core::rect<s32> rectangle)
: IGUIElement(EGUIET_ELEMENT, environment, parent, id, rectangle)
{
// by default, the color is black and without transparency
this->color = SColor(0, 0, 0, 0); // ARGB
}
// just to set a new color :
void GUIBackground::setColor(irr::video::SColor color)
{
this->color = color;
}
// and the draw :
void GUIBackground::draw()
{
if (!IsVisible)
return;
// we draw the background color
Environment->getVideoDriver()->draw2DRectangle(this->color, AbsoluteRect, &AbsoluteClippingRect);
// ^ i don't know exactly what are these absoluteRect and clippingRect, but i intended
// to discover it once i could get something to be actually drawn....
IGUIElement::draw();
}
anyway, thanks to anyone with an advice on this
ps : i don't intend to modify the IGUIEnvironment class and as of now i just my constructor and set the color directly (not via a "addBg" fonction)... i have looked at the addXX functions to see if they did add important things and it seems it is not the case, thus i doubt the problem comes from this (i am saying it just in case ^^)