X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdesigner%2Ftrackproperties.cpp;h=c95ad02887f24d3bd99868aa7a6a6a83afe73253;hb=05b95b6b6b095821f1e79dabed802b853c296c9d;hp=ce806c5d64dacbfbda94c637b5e3097c74570a49;hpb=c6b9a38300cc2ecfc0df66af162620b9ea5a1e3e;p=r2c2.git diff --git a/source/designer/trackproperties.cpp b/source/designer/trackproperties.cpp index ce806c5..c95ad02 100644 --- a/source/designer/trackproperties.cpp +++ b/source/designer/trackproperties.cpp @@ -1,12 +1,8 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2010 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #include +#include #include +#include +#include "libr2c2/track.h" #include "libr2c2/tracktype.h" #include "selection.h" #include "trackproperties.h" @@ -18,42 +14,48 @@ using namespace R2C2; TrackProperties::TrackProperties(const Selection &s): selection(s) { - set_size(300, 110); - - GLtk::Label *lbl; + set_layout(new GLtk::Layout); + GLtk::Column col(*layout); - add(*(lbl = new GLtk::Label("Track properties"))); - lbl->set_geometry(GLtk::Geometry(10, geom.h-30, geom.w-20, 20)); + GLtk::Label *lbl1, *lbl2; - add(*(lbl = new GLtk::Label("Turnout ID"))); - lbl->set_geometry(GLtk::Geometry(10, geom.h-65, 70, 20)); + add(*(lbl1 = new GLtk::Label("Track properties"))); + lbl1->set_style("title"); - add(*(ent_turnout_id = new GLtk::Entry)); - ent_turnout_id->set_geometry(GLtk::Geometry(80, geom.h-65, 50, 20)); - - add(*(lbl = new GLtk::Label("Sensor ID"))); - lbl->set_geometry(GLtk::Geometry(150, geom.h-65, 70, 20)); + { + GLtk::Row row(*layout); + add(*(lbl1 = new GLtk::Label("Turnout ID"))); + add(*(ent_turnout_id = new GLtk::Entry)); + ent_turnout_id->set_edit_size(5, 1); + } - add(*(ent_sensor_id = new GLtk::Entry)); - ent_sensor_id->set_geometry(GLtk::Geometry(220, geom.h-65, 50, 20)); + { + GLtk::Row row(*layout); + add(*(lbl2 = new GLtk::Label("Sensor ID"))); + layout->add_constraint(*lbl1, GLtk::Layout::COPY_WIDTH, *lbl2); + add(*(ent_sensor_id = new GLtk::Entry)); + ent_sensor_id->set_edit_size(5, 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"); + } if(selection.size()==1) { - if(unsigned tid = selection.get_track()->get_turnout_id()) - ent_turnout_id->set_text(lexical_cast(tid)); + if(unsigned tid = selection.get_object()->get_turnout_id()) + ent_turnout_id->set_text(lexical_cast(tid)); } - const set &tracks = selection.get_tracks(); + const set &tracks = selection.get_objects(); int sensor_id = -1; for(set::const_iterator i=tracks.begin(); i!=tracks.end(); ++i) { @@ -67,7 +69,7 @@ TrackProperties::TrackProperties(const Selection &s): } if(sensor_id>=0) - ent_sensor_id->set_text(lexical_cast(sensor_id)); + ent_sensor_id->set_text(lexical_cast(sensor_id)); } void TrackProperties::on_response(int code) @@ -76,7 +78,7 @@ void TrackProperties::on_response(int code) { if(selection.size()==1) { - Track *track = selection.get_track(); + Track *track = selection.get_object(); if(track->get_type().is_turnout()) track->set_turnout_id(lexical_cast(ent_turnout_id->get_text())); } @@ -85,7 +87,7 @@ void TrackProperties::on_response(int code) if(!sensor_id_text.empty()) { unsigned sensor_id = lexical_cast(sensor_id_text); - const set &tracks = selection.get_tracks(); + const set &tracks = selection.get_objects(); for(set::const_iterator i=tracks.begin(); i!=tracks.end(); ++i) if(!(*i)->get_type().is_turnout()) (*i)->set_sensor_id(sensor_id);