Debian Codegraph @

src/GUI/layout.hxx

raw symbols SCIP
1 #ifndef __LAYOUT_HXX
2 #define __LAYOUT_HXX
3
4 #include <simgear/props/props.hxx>
5
6 class puFont;
7
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.
15 //
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.
20 class LayoutWidget {
21 public:
22 static void setDefaultFont(puFont* font, int pixels);
23
24 LayoutWidget() { _prop = 0; }
25 LayoutWidget(SGPropertyNode* p) { _prop = p; }
26
27 std::string type();
28 bool hasParent();
29 LayoutWidget parent();
30 int nChildren();
31 LayoutWidget getChild(int i);
32 bool hasField(const char* f);
33 int getNum(const char* f);
34 bool getBool(const char* f, bool dflt = false);
35 std::string getStr(const char* f);
36 void setNum(const char* f, int num);
37
38 void calcPrefSize(int* w, int* h);
39 void layout(int x, int y, int w, int h);
40
41 private:
42 static int UNIT;
43 static puFont FONT;
44
45 static bool eq(const char* a, const char* b);
46 bool isType(const char* t) { return (t == type()); }
47
48 int padding();
49 int stringLength(const char* s); // must handle null argument
50
51 void doHVBox(bool doLayout, bool vertical, int* w=0, int* h=0);
52 void doTable(bool doLayout, int* w=0, int* h=0);
53
54 SGPropertyNode_ptr _prop;
55 };
56
57 #endif // __LAYOUT_HXX