diff --git a/src/gui/box.h b/src/gui/box.h index 07f23100f..bd2d76490 100644 --- a/src/gui/box.h +++ b/src/gui/box.h @@ -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 diff --git a/src/xml_widgets.cpp b/src/xml_widgets.cpp index 38ded6af9..dea19c3d8 100644 --- a/src/xml_widgets.cpp +++ b/src/xml_widgets.cpp @@ -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");