#include <msp/gltk/button.h>
+#include <msp/gltk/column.h>
#include <msp/gltk/label.h>
-#include <msp/gltk/mixedrows.h>
+#include <msp/gltk/row.h>
#include "zoneproperties.h"
using namespace std;
ZoneProperties::ZoneProperties(Zone &z):
zone(z)
{
- GLtk::MixedRows *rows = new GLtk::MixedRows;
- set_layout(rows);
+ set_layout(new GLtk::Layout);
+ GLtk::Column col(*layout);
GLtk::Label *lbl1, *lbl2;
add(*(lbl1 = new GLtk::Label("Zone properties")));
- layout->set_expand(*lbl1, true, false);
lbl1->set_style("title");
- rows->start_row();
- add(*(lbl1 = new GLtk::Label("Group")));
- add(*(ent_group = new GLtk::Entry(zone.get_group())));
- ent_group->set_edit_size(30, 1);
-
- rows->start_row();
- add(*(lbl2 = new GLtk::Label("Qualifier")));
- rows->add_constraint(*lbl1, GLtk::Layout::COPY_WIDTH, *lbl2);
+ {
+ GLtk::Row row(*layout);
+ add(*(lbl1 = new GLtk::Label("Group")));
+ add(*(ent_group = new GLtk::Entry(zone.get_group())));
+ ent_group->set_edit_size(30, 1);
+ }
- add(*(drp_qualifier = new GLtk::Dropdown));
- const char *qualifiers[] = { "track", "platform", "siding", 0 };
- for(unsigned i=0; qualifiers[i]; ++i)
{
- drp_qualifier->append(qualifiers[i]);
- if(zone.get_qualifier()==qualifiers[i])
- drp_qualifier->set_selected_index(i);
+ GLtk::Row row(*layout);
+ add(*(lbl2 = new GLtk::Label("Qualifier")));
+ layout->add_constraint(*lbl1, GLtk::Layout::COPY_WIDTH, *lbl2);
+
+ add(*(drp_qualifier = new GLtk::Dropdown));
+ GLtk::ListDataStore<string> &data = dynamic_cast<GLtk::ListDataStore<string> &>(drp_qualifier->get_data());
+ const char *qualifiers[] = { "track", "platform", "siding", 0 };
+ for(unsigned i=0; qualifiers[i]; ++i)
+ {
+ data.append(qualifiers[i]);
+ if(zone.get_qualifier()==qualifiers[i])
+ drp_qualifier->set_selected_index(i);
+ }
}
- rows->start_row();
- add(*(lbl1 = new GLtk::Label("Number")));
- rows->add_constraint(*lbl1, GLtk::Layout::COPY_WIDTH, *lbl2);
- add(*(ent_number = new GLtk::Entry(lexical_cast<string>(zone.get_number()))));
- ent_number->set_edit_size(4, 1);
+ {
+ GLtk::Row row(*layout);
+ add(*(lbl1 = new GLtk::Label("Number")));
+ layout->add_constraint(*lbl1, GLtk::Layout::COPY_WIDTH, *lbl2);
+ add(*(ent_number = new GLtk::Entry(lexical_cast<string>(zone.get_number()))));
+ ent_number->set_edit_size(4, 1);
+ }
GLtk::Button *btn;
- rows->start_row();
- rows->split_columns();
- add_button(*(btn = new GLtk::Button("Cncl")), 0);
- btn->set_style("red");
+ {
+ GLtk::Row row(*layout);
+ row.split();
+ add_button(*(btn = new GLtk::Button("Cncl")), 0);
+ btn->set_style("red");
- add_button(*(btn = new GLtk::Button("OK")), 1);
- btn->set_style("green");
+ add_button(*(btn = new GLtk::Button("OK")), 1);
+ btn->set_style("green");
+ }
}
void ZoneProperties::on_response(int code)
if(code==1)
{
string qualifier;
- if(drp_qualifier->get_selected_index()>=0)
- qualifier = drp_qualifier->get_selected();
+ int sel = drp_qualifier->get_selected_index();
+ if(sel>=0)
+ qualifier = drp_qualifier->get_data().get_string(sel);
unsigned number = lexical_cast<unsigned>(ent_number->get_text());
zone.set_name(ent_group->get_text(), qualifier, number);
}