#include <toad/toad.hh> using namespace toad; int main(int argc, char **argv, char **envv) { toad::initialize(argc, argv, envv); // connect to X11 server TWindow *parent = new TWindow(0, "main window"); TWindow *child1 = new TWindow(parent, "child 1"); TWindow *child2 = new TWindow(parent, "child 2"); parent->setSize(320, 200); child1->setShape(20, 20, 160, 100); // set x, y, width and height child1->setBackground(255, 0, 0); // red background child2->setShape(140, 80, 160, 100); child2->setBackground(0, 0, 255); // blue background toad::mainLoop(); // handle events until window closed delete parent; // delete window and its children toad::terminate(); // disconnect from X11 server return 0; }Each window class constructor like TWindow, TPushButton, TTable, etc. takes a minium of two arguments:
Table 2-1. The 2 arguments of every window constructor.
Argument | Description |
---|---|
parent | The window hierachy (which window contains which window) is defined during object creation. The parent window defines in which window the new window will be contained in. A value of '0' means that the new window will be placed onto the desktop. |
title | The title of the window for identification within layouts, resource files and the like, usually written in lower case to avoid confusion with titles or text intended to be read by the user. When a text is intended to be read by the user, class TLabelOwner should be used. |