Gantt > Using the Gantt Chart Through Examples > Subclassing IlvGanttChart
 
Subclassing IlvGanttChart
Some methods of the IlvGanttChart class are virtual. These functions are called when the internal states of the Gantt chart are being changed or special actions are taken on the Gantt chart. Users are invited to subclass the IlvGanttChart class for two purposes:
*The virtual functions are called to indicate internal events of the Gantt chart.
*The function can be implemented by users to meet their special needs. The new implementation changes the behavior of the Gantt chart.
In the month example, we show how to override some virtual functions of the IlvGanttChart to customize the grid of the Gantt chart. Here is the definition of the MonthGanttChart class:
class MonthGanttChart
: public LoadGanttChart
{
public:
MonthGanttChart(IlvDisplay* display, const IlvRect& rect,
IlvInt start, IlvInt end,
IlvUShort step, IlvUShort day,
IlvDim rowsize, IlvDim unitsize=40,
IlvUShort gridThickness=4, IlvPalette* palette = 0)
: LoadGanttChart(display, rect, start, end, start, start+7*24,
step, rowsize, unitsize, gridThickness, palette),
_day(day) { makeHolidayPalette(display); }
virtual ~MonthGanttChart();
// ___________________________________________________
virtual void drawGrid(IlvPort* dst, IlvUShort index,
IlvBoolean skipCompute=IlFalse,
const IlvRegion* clip=0,
IlvTransformer* t=0,
IlvDirection d=(IlvDirection)(IlvHorizontal|IlvVertical));
virtual IlvScale* createScale(IlvDisplay*, const IlvPoint& orig,
IlvDim size, IlvInt start, IlvInt end,
IlvUShort step, IlvPosition p=IlvTop) const;
virtual void updateScale(IlvScale*, IlvBoolean redraw=IlTrue) const;
void computeScaleLabels(IlvInt start, IlvInt end, IlvUShort step,
IlvUShort& count, char** labels) const;
IlvUShort getDay() const { return _day; }
DeclareTypeInfo();
DeclareIOConstructors(MonthGanttChart);
protected:
IlvUShort _day;
IlvPalette* _holidayPalette;
void makeHolidayPalette(IlvDisplay*);
};
As you may have noticed, the virtual functions drawGrid(), createScale(), and updateScale() are overridden.
The height and position of the scales can be specified in the Gantt chart constructor. By default, the height is 32 and the location is at the top of the Gantt chart.
Note: If you want to use the copy constructor of the IlvGanttChart class (or IlvGanttChartForm class), make sure that all the items of the Gantt chart (like grid or resources) are not duplicated. When you use these constructors, you must manage the copy of the data and of the graphic objects like the grid.

Version 6.0
Copyright © 2015, Rogue Wave Software, Inc. All Rights Reserved.