void ControlPanel::view_clicked()
{
- GLtk::Container *root = parent;
- while(root->get_parent())
- root = root->get_parent();
-
TrainView *dlg = new TrainView(engineer, train);
- root->add(*dlg);
+ find_ancestor<GLtk::Root>()->add(*dlg);
dlg->autosize();
}
void MainWindow::trains_clicked()
{
- GLtk::Container *root = parent;
- while(root->get_parent())
- root = root->get_parent();
-
TrainListDialog *dlg = new TrainListDialog(engineer);
- root->add(*dlg);
+ find_ancestor<GLtk::Root>()->add(*dlg);
dlg->autosize();
}
Train *train = new Train(engineer.get_layout(), type, address, protocol);
train->set_name(ent_name->get_text());
- GLtk::Container *root = parent;
- while(root->get_parent())
- root = root->get_parent();
-
TrainDialog *dlg = new TrainDialog(engineer, *train);
- root->add(*dlg);
+ find_ancestor<GLtk::Root>()->add(*dlg);
dlg->autosize();
}
}
void TrainListDialog::new_clicked()
{
- GLtk::Container *root = parent;
- while(root->get_parent())
- root = root->get_parent();
-
NewTrainDialog *dlg = new NewTrainDialog(engineer);
- root->add(*dlg);
+ find_ancestor<GLtk::Root>()->add(*dlg);
dlg->autosize();
}
int index = lst_trains->get_selected_index();
if(index>=0)
{
- GLtk::Container *root = parent;
- while(root->get_parent())
- root = root->get_parent();
-
TrainDialog *dlg = new TrainDialog(engineer, *trains.get(index));
- root->add(*dlg);
+ find_ancestor<GLtk::Root>()->add(*dlg);
dlg->autosize();
}
}
#include <msp/core/maputils.h>
#include <msp/gltk/button.h>
+#include <msp/gltk/root.h>
#include <msp/strings/format.h>
#include "libr2c2/layout.h"
#include "libr2c2/vehicle.h"
void VehiclesPanel::add_clicked()
{
- GLtk::Container *root = parent;
- while(root->get_parent())
- root = root->get_parent();
-
NewVehicleDialog *dlg = new NewVehicleDialog(train);
- root->add(*dlg);
+ find_ancestor<GLtk::Root>()->add(*dlg);
dlg->autosize();
}