Foundation > Graphic Objects > Creating a New Graphic Object Class > Creating the Header File
 
Creating the Header File
For this example, you create a header file that declares the new class and the necessary overloaded member functions.
The header file shadellp.h contains the following lines:
#define DefaultShadowThickness 4
 
class ShadowEllipse
: public IlvSimpleGraphic {
public:
ShadowEllipse(IlvDisplay* display,
const IlvRect& rect,
IlUShort thickness = DefaultShadowThickness,
IlvPalette* palette = 0)
: IlvSimpleGraphic(display, palette),
_rect(rect), _thickness(thickness)
{
_invertedPalette = 0;
computeInvertedPalette();
}
~ShadowEllipse();
 
virtual void draw(IlvPort*, const IlvTransformer* t = 0,
const IlvRegion* clip = 0) const;
virtual IlBoolean contains(const IlvPoint& p,
const IlvPoint& tp,
const IlvTransformer* t) const;
virtual void boundingBox(IlvRect& rect,
const IlvTransformer* t = 0) const;
virtual void applyTransform(const IlvTransformer* t);
IlUShort getThickness() const
{ return _thickness; }
void setThickness(IlUShort thickness)
{ _thickness = thickness; }
 
virtual void setBackground(IlvColor* c);
virtual void setForeground(IlvColor* c);
virtual void setMode(IlvDrawMode m);
virtual void setPalette(IlvPalette* p);
 
DeclareTypeInfo();
DeclareIOConstructors(ShadowEllipse);
protected:
IlvRect _rect;
IlUShort _thickness;
IlvPalette* _invertedPalette;
void computeInvertedPalette();
};
This object, like a few others in the standard Rogue Wave Views library, makes use of two different IlvPalette objects. This is a common practice when you want your object to be very efficient in terms of drawing time, since you do not need to create dummy palette objects when drawing the ellipse itself and its shadow.
The ShadowEllipse class defines the member functions draw, contains, and boundingBox. It also defines the necessary palette-management related member functions to update both the standard palette object (the one stored in the IlvSimpleGraphic class) and the new one, _invertedPalette.
No input/output member functions are declared in this synopsis. In fact, they are declared by the DeclareTypeInfo macro that declares them as external. These member functions are read, write, and copy. They have no default implementation, and you must provide a version of these for each of your subclasses of the IlvGraphic class. There is a second version of this macro, called DeclareTypeInfoRO, that does not declare the member function write, if you know this object type will never be saved.

Version 6.1
Copyright © 2016, Rogue Wave Software, Inc. All Rights Reserved.