Added an extra build function.

In some cases it's easier to use an existing grid in the grid builder.
So added a new function which takes a grid pointer as parameter.
This commit is contained in:
Mark de Wever 2008-12-08 21:10:23 +00:00
parent ea5cf19d46
commit f1861c66a9
2 changed files with 11 additions and 4 deletions

View file

@ -1009,7 +1009,8 @@ twidget* tbuilder_scroll_label::build() const
init_control(widget);
boost::intrusive_ptr<const tscroll_label_definition::tresolution> conf =
boost::dynamic_pointer_cast<const tscroll_label_definition::tresolution>(widget->config());
boost::dynamic_pointer_cast
<const tscroll_label_definition::tresolution>(widget->config());
assert(conf);
tgrid* grid = dynamic_cast<tgrid*>(conf->grid->build());
@ -1250,14 +1251,18 @@ twidget* tbuilder_vertical_scrollbar::build() const
twidget* tbuilder_grid::build() const
{
tgrid* grid = new tgrid();
return build(new tgrid());
}
twidget* tbuilder_grid::build (tgrid* grid) const
{
grid->set_id(id);
grid->set_rows_cols(rows, cols);
log_scope2(gui, "Window builder: building grid");
DBG_GUI << "Window builder: grid has " << rows << " rows and "
DBG_GUI << "Window builder: grid '" << id
<< "' has " << rows << " rows and "
<< cols << " columns.\n";
for(unsigned x = 0; x < rows; ++x) {

View file

@ -28,6 +28,7 @@ class CVideo;
namespace gui2 {
class twidget;
class tgrid;
class twindow;
twindow build(CVideo& video, const std::string& type);
@ -75,7 +76,8 @@ public:
/** The widgets per grid cell. */
std::vector<tbuilder_widget_ptr> widgets;
twidget* build () const;
twidget* build() const;
twidget* build(tgrid* grid) const;
private:
/** After reading the general part in the constructor read extra data. */