3 This file is part of R²C²
4 Copyright © 2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #include <msp/gltk/button.h>
9 #include <msp/gltk/label.h>
10 #include "zoneproperties.h"
16 ZoneProperties::ZoneProperties(Zone &z):
23 add(*(lbl = new GLtk::Label("Zone properties")));
24 lbl->set_geometry(GLtk::Geometry(10, geom.h-30, geom.w-20, 20));
26 add(*(lbl = new GLtk::Label("Group")));
27 lbl->set_geometry(GLtk::Geometry(10, geom.h-65, 70, 20));
29 add(*(ent_group = new GLtk::Entry(zone.get_group())));
30 ent_group->set_geometry(GLtk::Geometry(80, geom.h-65, geom.w-90, 20));
32 add(*(lbl = new GLtk::Label("Qualifier")));
33 lbl->set_geometry(GLtk::Geometry(10, geom.h-95, 70, 20));
35 add(*(drp_qualifier = new GLtk::Dropdown));
36 drp_qualifier->set_geometry(GLtk::Geometry(80, geom.h-95, 80, 20));
37 const char *qualifiers[] = { "track", "platform", "siding", 0 };
38 for(unsigned i=0; qualifiers[i]; ++i)
40 drp_qualifier->append(qualifiers[i]);
41 if(zone.get_qualifier()==qualifiers[i])
42 drp_qualifier->set_selected_index(i);
45 add(*(lbl = new GLtk::Label("Number")));
46 lbl->set_geometry(GLtk::Geometry(170, geom.h-95, 70, 20));
48 add(*(ent_number = new GLtk::Entry(lexical_cast(zone.get_number()))));
49 ent_number->set_geometry(GLtk::Geometry(240, geom.h-95, 50, 20));
53 add_button(*(btn = new GLtk::Button("Cncl")), 0);
54 btn->set_geometry(GLtk::Geometry(geom.w-90, 10, 40, 24));
55 btn->set_style("red");
57 add_button(*(btn = new GLtk::Button("OK")), 1);
58 btn->set_geometry(GLtk::Geometry(geom.w-50, 10, 40, 24));
59 btn->set_style("green");
62 void ZoneProperties::on_response(int code)
67 if(drp_qualifier->get_selected_index()>=0)
68 qualifier = drp_qualifier->get_selected();
69 unsigned number = lexical_cast<unsigned>(ent_number->get_text());
70 zone.set_name(ent_group->get_text(), qualifier, number);