3 #include <simgear/compiler.h>
7 #include <simgear/props/props.hxx>
8 #include <simgear/props/props_io.hxx>
12 // Takes a property file on the command line, lays it out, and writes
13 // the resulting tree back to stdout. Requires that the
14 // "Helvetica.txf" font file from the base package be in the current
17 // g++ -Wall -g -o layout layout.cxx layout-props.cxx layout-test.cxx
18 // -I/fg/include -L/fg/lib -I.. -lsgprops -lsgdebug -lsgstructure
19 // -lsgmisc -lsgxml -lplibpw -lplibpu -lplibfnt -lplibul -lGL
21 // We can't load a plib fntTexFont without a GL context, so we use the
22 // PW library to initialize things. The callbacks are required, but
24 void exitCB(){ pwCleanup(); exit(0); }
25 void resizeCB(int w, int h){ }
26 void mouseMotionCB(int x, int y){ puMouse(x, y); }
27 void mouseButtonCB(int button, int updn, int x, int y){ puMouse(button, updn, x, y); }
28 void keyboardCB(int key, int updn, int x, int y){ puKeyboard(key, updn, x, y); }
30 const char* FONT_FILE = "Helvetica.txf";
32 int main(int argc, char** argv)
35 if(!(tmp = fopen(FONT_FILE, "r"))) {
36 fprintf(stderr, "Could not open %s for reading.\n", FONT_FILE);
41 pwInit(0, 0, 600, 400, 0, "Layout Test", true, 0);
42 pwSetCallbacks(keyboardCB, mouseButtonCB, mouseMotionCB,
49 LayoutWidget::setDefaultFont(&puhelv, 15);
51 readProperties(argv[1], &props);
52 LayoutWidget w(&props);
54 w.calcPrefSize(&pw, &ph);
55 w.layout(0, 0, pw, ph);
56 writeProperties(cout, &props, true);