4 #include <simgear/props/props.hxx>
8 // For the purposes of doing layout management, widgets have a type,
9 // zero or more children, and string-indexed "fields" which can be
10 // constraints, parameters or x/y/width/height geometry values. It
11 // can provide a "preferred" width and height to its parent, and is
12 // capable of laying itself out into a specified x/y/w/h box. The
13 // widget "type" is not a field for historical reasons having to do
14 // with the way the dialog property format works.
16 // Note that this is a simple wrapper around an SGPropertyNode
17 // pointer. The intent is that these objects will be created on the
18 // stack as needed and passed by value. All persistent data is stored
19 // in the wrapped properties.
22 static void setDefaultFont(puFont* font, int pixels);
24 LayoutWidget() { _prop = 0; }
25 LayoutWidget(SGPropertyNode* p) { _prop = p; }
29 LayoutWidget parent();
31 LayoutWidget getChild(int i);
32 bool hasField(const char* f);
33 int getNum(const char* f);
34 bool getBool(const char* f);
35 const char* getStr(const char* f);
36 void setNum(const char* f, int num);
38 void calcPrefSize(int* w, int* h);
39 void layout(int x, int y, int w, int h);
45 static bool eq(const char* a, const char* b);
46 bool isType(const char* t) { return eq(t, type()); }
49 int stringLength(const char* s); // must handle null argument
51 void doHVBox(bool doLayout, bool vertical, int* w=0, int* h=0);
52 void doTable(bool doLayout, int* w=0, int* h=0);
54 SGPropertyNode_ptr _prop;
57 #endif // __LAYOUT_HXX