The XP Graphics Toolkit consists of a set of interface classes for drawing and toolkit primitives modelled on Java. These classes allow you to create a single set of source code for drawing and events on both Motif and Microsoft Windows in the same way you can already single source user interface code using the MotifXP libraries. You write code using this toolkit and the libraries translate it according to your target platform. The source code for these libraries is accessible, allowing you to add your own code if you should wish to provide extra functionality for certain widgets.
The following lines show a simple example of how the toolkit may be used:
Toolkit *tk = Toolkit::getDefaultToolkit();
Graphics *g = tk->getGraphics(drawingArea);
g->drawLine(10,10,100,100);
The graphics toolkit also encompasses double buffering and takes care of the slightly more complex issues of X and WIN32 GDI memory allocation issues that overcomplicate what should be simple drawing routines.
The toolkit can also handle abstract events with classes which remove any platform specifics regarding event driven interfaces. In exactly the same way as is shown for the line drawing example above, you could fetch the toolkit object and ask it for any outstanding events and process them generically in your own code. The XP Graphics toolkit libraries would then handle the specifics according to the toolkit you are targeting.
See also: