X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fengineer%2Ftimetabledialog.cpp;h=8a185cd156f85b7e072deda6b202280c88630f1d;hb=54392d65e2053d1eacb4cfcc435f1013993f2973;hp=978b14bcb53a9e73d0e82fb913a1862ca05ab540;hpb=cf52013784607dc4d307bd1244c5346ee88336a4;p=r2c2.git diff --git a/source/engineer/timetabledialog.cpp b/source/engineer/timetabledialog.cpp index 978b14b..8a185cd 100644 --- a/source/engineer/timetabledialog.cpp +++ b/source/engineer/timetabledialog.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of the MSP Märklin suite -Copyright © 2010 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #include #include #include @@ -12,32 +5,31 @@ Distributed under the GPL using namespace std; using namespace Msp; -using namespace Marklin; +using namespace R2C2; -TimetableDialog::TimetableDialog(const GLtk::Resources &r, Timetable &tt): - GLtk::Widget(r), - GLtk::Dialog(r), +TimetableDialog::TimetableDialog(Timetable &tt): timetable(tt) { - set_size(200, 200); + set_size(250, 200); GLtk::Button *btn; - add_button(*(btn = new GLtk::Button(res, "Cncl")), 0); + add_button(*(btn = new GLtk::Button("Cncl")), 0); btn->set_geometry(GLtk::Geometry(geom.w-80, 10, 30, 25)); btn->set_style("red"); - add_button(*(btn = new GLtk::Button(res, "OK")), 1); + add_button(*(btn = new GLtk::Button("OK")), 1); btn->set_geometry(GLtk::Geometry(geom.w-40, 10, 30, 25)); btn->set_style("green"); - add(*(tgl_enabled = new GLtk::Toggle(res, "On"))); + add(*(tgl_enabled = new GLtk::Toggle("On"))); tgl_enabled->set_geometry(GLtk::Geometry(10, 10, 40, 27)); tgl_enabled->set_value(timetable.is_enabled()); tgl_enabled->signal_toggled.connect(sigc::mem_fun(this, &TimetableDialog::enabled_toggled)); - add(*(ent_timetable = new GLtk::Entry(res))); + add(*(ent_timetable = new GLtk::Entry)); ent_timetable->set_geometry(GLtk::Geometry(10, 45, geom.w-20, geom.h-55)); + ent_timetable->set_style("multiline"); ent_timetable->set_multiline(true); string text; @@ -53,13 +45,13 @@ TimetableDialog::TimetableDialog(const GLtk::Resources &r, Timetable &tt): void TimetableDialog::enabled_toggled(bool value) { timetable.set_enabled(value); + timetable.reset(); } void TimetableDialog::on_response(int code) { if(code) { - timetable.clear(); vector lines = split(ent_timetable->get_text(), '\n'); vector rows; rows.reserve(lines.size()); @@ -67,10 +59,11 @@ void TimetableDialog::on_response(int code) { for(vector::const_iterator i=lines.begin(); i!=lines.end(); ++i) rows.push_back(Timetable::Row::parse(*i)); + timetable.clear(); for(vector::const_iterator i=rows.begin(); i!=rows.end(); ++i) timetable.append(*i); } - catch(const Exception &e) + catch(const exception &e) { // XXX Need a better way to report errors. Also, should not let the dialog close. IO::print("%s\n", e.what());