X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdesigner%2Fzoneproperties.cpp;h=6ea4f2a330fc1a4b115a597933b01ede9813968d;hb=066170fbc56bb5bd33a5ce0b9b7b668a3f539ee6;hp=91b8868e48f14b47fb31670efca516d81bde9c4e;hpb=d15ac13f2e170f155b4bbd124df48400c339b644;p=r2c2.git diff --git a/source/designer/zoneproperties.cpp b/source/designer/zoneproperties.cpp index 91b8868..6ea4f2a 100644 --- a/source/designer/zoneproperties.cpp +++ b/source/designer/zoneproperties.cpp @@ -1,5 +1,7 @@ #include +#include #include +#include #include "zoneproperties.h" using namespace std; @@ -9,47 +11,56 @@ using namespace R2C2; ZoneProperties::ZoneProperties(Zone &z): zone(z) { - set_size(300, 140); + set_layout(new GLtk::Layout); + GLtk::Column col(*layout); - GLtk::Label *lbl; + GLtk::Label *lbl1, *lbl2; - add(*(lbl = new GLtk::Label("Zone properties"))); - lbl->set_geometry(GLtk::Geometry(10, geom.h-30, geom.w-20, 20)); + add(*(lbl1 = new GLtk::Label("Zone properties"))); + lbl1->set_style("title"); - add(*(lbl = new GLtk::Label("Group"))); - lbl->set_geometry(GLtk::Geometry(10, geom.h-65, 70, 20)); - - add(*(ent_group = new GLtk::Entry(zone.get_group()))); - ent_group->set_geometry(GLtk::Geometry(80, geom.h-65, geom.w-90, 20)); - - add(*(lbl = new GLtk::Label("Qualifier"))); - lbl->set_geometry(GLtk::Geometry(10, geom.h-95, 70, 20)); - - add(*(drp_qualifier = new GLtk::Dropdown)); - drp_qualifier->set_geometry(GLtk::Geometry(80, geom.h-95, 80, 20)); - 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(*(lbl1 = new GLtk::Label("Group"))); + add(*(ent_group = new GLtk::Entry(zone.get_group()))); + ent_group->set_edit_size(30, 1); } - add(*(lbl = new GLtk::Label("Number"))); - lbl->set_geometry(GLtk::Geometry(170, geom.h-95, 70, 20)); + { + GLtk::Row row(*layout); + add(*(lbl2 = new GLtk::Label("Qualifier"))); + layout->add_constraint(*lbl1, GLtk::Layout::COPY_WIDTH, *lbl2); - add(*(ent_number = new GLtk::Entry(lexical_cast(zone.get_number())))); - ent_number->set_geometry(GLtk::Geometry(240, geom.h-95, 50, 20)); + add(*(drp_qualifier = new GLtk::Dropdown)); + GLtk::ListDataStore &data = dynamic_cast &>(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); + } + } + + { + 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(zone.get_number())))); + ent_number->set_edit_size(4, 1); + } GLtk::Button *btn; - add_button(*(btn = new GLtk::Button("Cncl")), 0); - btn->set_geometry(GLtk::Geometry(geom.w-90, 10, 40, 24)); - 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_geometry(GLtk::Geometry(geom.w-50, 10, 40, 24)); - btn->set_style("green"); + add_button(*(btn = new GLtk::Button("OK")), 1); + btn->set_style("green"); + } } void ZoneProperties::on_response(int code) @@ -57,8 +68,9 @@ 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(ent_number->get_text()); zone.set_name(ent_group->get_text(), qualifier, number); }