The Entry Point of the Sample
The main function of the sample is defined in <ILVHOME>/samples/gantt/month/src/month.cpp. If you look at the source code, you will find the follows tasks accomplished in the main function:
The display is created.
The main window of the sample is created.
The customized Gantt chart object is created and added to the main window.
The toolbar manipulating the Gantt chart is created.
The graphic models of the Gantt chart are specified.
The Gantt chart object is populated with data.
The line grid is created for the Gantt chart.
The colors of the Gantt chart are customized.
The handle of the Gantt chart is hidden to make a mono view Gantt chart.
// --------------------------------------------------------------------------
int
main(int argc, char* argv[])
{
// Create the display
IlvDisplay* display
= new IlvDisplay("Rogue Wave Views Gantt Chart", 0, argc, argv);
if (!display || display->isBad()) {
IlvFatalError("Couldn't create display");
delete display;
return -1;
}
// Add the path to toolbar files
AppendGanttDataPath(display);
// Creating top view
IlvGadgetContainer* top = new IlvGadgetContainer
(display, "GanttChart", "Rogue Wave Views Gantt Chart Month Demo",
IlvRect(200, 100, 720, 376), IlFalse);
top->setDestroyCallback(Quit);
IlInt start, end;
IlUShort step, day;
IlvGanttComputeDay(3, 2002, day, start, end, step);
// Creating Chart
MonthGanttChart* gantt =
new MonthGanttChart(display, IlvRect(0, 32, 720, 344),
start, end, step, day, 160);
// Create the toolbar
IlvGanttToolBar* toolbar = new MonthToolBar(display, gantt);
top->addObject(toolbar);
// Specify the new graphic models
gantt->setSubNodeGraphicModel(CreateSubNodeGraphicModel(display));
gantt->setLineGraphicModel(CreateLineGraphicModel(display));
gantt->setLinkGraphicModel(CreateDoubleLinkGraphicModel(display));
gantt->setBreakGraphicModel(CreateBreakGraphicModel(display));
// Populate the Gantt chart with data
PopulateGanttChart(gantt, start, end, 12L);
// Add horizontal grids
IlvColor* steelblue3 = display->getColor("steelblue3");
IlvColor* midnightblue = display->getColor("midnightblue");
IlvPalette* gridPal = display->getPalette(steelblue3, midnightblue);
IlvGanttLineGrid* linGrid = new IlvGanttLineReliefGrid(gantt, gridPal);
gantt->setLineGrid(linGrid, IlFalse, 0);
// Attach the toolbar
IlvSetAttachment(toolbar, IlvTop, IlvFixedAttach, 0);
IlvSetAttachment(toolbar, IlvLeft, IlvFixedAttach);
IlvSetAttachment(toolbar, IlvRight, IlvFixedAttach);
IlvSetAttachment(toolbar, IlvHorizontal, IlvElasticAttach);
// Attach the Gantt chart
IlvSetAttachment(gantt, IlvTop, IlvFixedAttach, 32);
IlvSetAttachment(gantt, IlvBottom, IlvFixedAttach);
IlvSetAttachment(gantt, IlvLeft, IlvFixedAttach);
IlvSetAttachment(gantt, IlvRight, IlvFixedAttach);
IlvSetAttachment(gantt, IlvVertical, IlvElasticAttach);
IlvSetAttachment(gantt, IlvHorizontal, IlvElasticAttach);
// Add the Gantt chart
top->addObject(gantt);
// Showing top view
top->show();
// Color customizations
IlvColor* cyan = display->getColor("cyan");
IlvColor* darkorange = display->getColor("darkorange");
IlvColor* steelblue4 = display->getColor("steelblue4");
IlvPalette* pal = display->getPalette(cyan, darkorange);
gantt->getScale(0)->setPalette(pal);
gantt->getScale(1)->setPalette(pal);
gantt->setBackground(steelblue4);
gantt->getManagerView(0)->setBackground(steelblue4);
gantt->getManagerView(1)->setBackground(steelblue4);
IlvColor* antiquewhite = display->getColor("antiquewhite");
gantt->getGridPalette()->setBackground(antiquewhite);
// Enable the default grid
gantt->showGrid(IlTrue, IlTrue);
// Enable double buffering
gantt->setDoubleBuffering(IlTrue);
// Make only one view visible
gantt->moveHandle(IlvPoint(2000, 2000));
// Running main loop
IlvMainLoop();
return 0;
}
Version 5.5.1
Copyright © 2012, Rogue Wave Software, Inc. All Rights Reserved.