]> git.tdb.fi Git - r2c2.git/blobdiff - source/engineer/timetabledialog.cpp
Fix remaining exception class names
[r2c2.git] / source / engineer / timetabledialog.cpp
index 978b14bcb53a9e73d0e82fb913a1862ca05ab540..8a185cd156f85b7e072deda6b202280c88630f1d 100644 (file)
@@ -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 <msp/gltk/button.h>
 #include <msp/io/print.h>
 #include <msp/strings/utils.h>
@@ -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<string> lines = split(ent_timetable->get_text(), '\n');
                vector<Timetable::Row> rows;
                rows.reserve(lines.size());
@@ -67,10 +59,11 @@ void TimetableDialog::on_response(int code)
                {
                        for(vector<string>::const_iterator i=lines.begin(); i!=lines.end(); ++i)
                                rows.push_back(Timetable::Row::parse(*i));
+                       timetable.clear();
                        for(vector<Timetable::Row>::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());