Add VBox, HBox, and BoxFiller micro-classes.

This commit is contained in:
David Capello 2011-03-29 21:13:08 -03:00
parent 3ad44e3004
commit c7bf667f0d
2 changed files with 40 additions and 3 deletions

View File

@ -25,4 +25,24 @@ private:
void box_set_position(JRect rect);
};
class VBox : public Box
{
public:
VBox() : Box(JI_VERTICAL) { }
};
class HBox : public Box
{
public:
HBox() : Box(JI_HORIZONTAL) { }
};
class BoxFiller : public Box
{
public:
BoxFiller() : Box(JI_HORIZONTAL) {
jwidget_expansive(this, true);
}
};
#endif

View File

@ -89,7 +89,7 @@ static Widget* convert_xmlelement_to_widget(TiXmlElement* elem, Widget* root)
/* TODO error handling: add a message if the widget is bad specified */
/* box */
// Boxes
if (ustrcmp(elem_name, "box") == 0) {
bool horizontal = bool_attr_is_true(elem, "horizontal");
bool vertical = bool_attr_is_true(elem, "vertical");
@ -99,7 +99,24 @@ static Widget* convert_xmlelement_to_widget(TiXmlElement* elem, Widget* root)
vertical ? JI_VERTICAL: 0) |
(homogeneous ? JI_HOMOGENEOUS: 0));
}
/* button */
else if (ustrcmp(elem_name, "vbox") == 0) {
bool homogeneous = bool_attr_is_true(elem, "homogeneous");
widget = new VBox();
if (homogeneous)
widget->setAlign(widget->getAlign() | JI_HOMOGENEOUS);
}
else if (ustrcmp(elem_name, "hbox") == 0) {
bool homogeneous = bool_attr_is_true(elem, "homogeneous");
widget = new HBox();
if (homogeneous)
widget->setAlign(widget->getAlign() | JI_HOMOGENEOUS);
}
else if (ustrcmp(elem_name, "boxfiller") == 0) {
widget = new BoxFiller();
}
// Button
else if (ustrcmp(elem_name, "button") == 0) {
const char *text = elem->Attribute("text");
@ -142,7 +159,7 @@ static Widget* convert_xmlelement_to_widget(TiXmlElement* elem, Widget* root)
}
}
}
/* check */
// Check
else if (ustrcmp(elem_name, "check") == 0) {
const char *text = elem->Attribute("text");
const char *looklike = elem->Attribute("looklike");