
This program subclasses the class TMyWindow from TOAD's window class TWindow and displays it.
The command
g++ `toad-config --cxxflags --libs` hello.cc
will compile the program.
// include declarations of TOAD basic classes
#include <toad.hh>
// use the TOAD namespace
using namespace toad;
// define a new window class, based on TWindow
class TMyWindow:
public TWindow
{
public:
// typical constructor for windows
TMyWindow(TWindow *parent, const string &title)
:TWindow(parent, title) {}
// define a new method to paint the windows content
void paint() {
// create a pen for this window and use it to...
TPen pen(this);
// ...draw a text at position (50, 50)
pen.drawString(50, 50, "Hello World!!!");
}
};
// initialize TOAD, create window and enter the message loop
int
main(int argc, char **argv, char **envv)
{
// initialize TOAD library
toad::initialize(argc, argv, envv);
// create window
TMyWindow *window = new TMyWindow(0, "Hello World");
// show window and handle user input until window is closed
toad::mainLoop();
// the window has been closed so we dispose of the object
delete window;
// clean up TOAD
toad::terminate();
return 0;
}