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