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