1 #include <msp/gltk/button.h>
2 #include <msp/gltk/column.h>
3 #include <msp/gltk/label.h>
4 #include <msp/gltk/row.h>
5 #include "zoneproperties.h"
11 ZoneProperties::ZoneProperties(Zone &z):
14 set_layout(new GLtk::Layout);
15 GLtk::Column col(*layout);
17 GLtk::Label *lbl1, *lbl2;
19 add(*(lbl1 = new GLtk::Label("Zone properties")));
20 lbl1->set_style("title");
23 GLtk::Row row(*layout);
24 add(*(lbl1 = new GLtk::Label("Group")));
25 add(*(ent_group = new GLtk::Entry(zone.get_group())));
26 ent_group->set_edit_size(30, 1);
30 GLtk::Row row(*layout);
31 add(*(lbl2 = new GLtk::Label("Qualifier")));
32 layout->add_constraint(*lbl1, GLtk::Layout::COPY_WIDTH, *lbl2);
34 add(*(drp_qualifier = new GLtk::Dropdown));
35 GLtk::ListDataStore<string> &data = dynamic_cast<GLtk::ListDataStore<string> &>(drp_qualifier->get_data());
36 const char *qualifiers[] = { "track", "platform", "siding", 0 };
37 for(unsigned i=0; qualifiers[i]; ++i)
39 data.append(qualifiers[i]);
40 if(zone.get_qualifier()==qualifiers[i])
41 drp_qualifier->set_selected_index(i);
46 GLtk::Row row(*layout);
47 add(*(lbl1 = new GLtk::Label("Number")));
48 layout->add_constraint(*lbl1, GLtk::Layout::COPY_WIDTH, *lbl2);
49 add(*(ent_number = new GLtk::Entry(lexical_cast<string>(zone.get_number()))));
50 ent_number->set_edit_size(4, 1);
56 GLtk::Row row(*layout);
58 add_button(*(btn = new GLtk::Button("Cncl")), 0);
59 btn->set_style("red");
61 add_button(*(btn = new GLtk::Button("OK")), 1);
62 btn->set_style("green");
66 void ZoneProperties::on_response(int code)
71 int sel = drp_qualifier->get_selected_index();
73 qualifier = drp_qualifier->get_data().get_string(sel);
74 unsigned number = lexical_cast<unsigned>(ent_number->get_text());
75 zone.set_name(ent_group->get_text(), qualifier, number);