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