]> git.tdb.fi Git - r2c2.git/blobdiff - source/remote/remote.cpp
Send and receive power/halt states over network
[r2c2.git] / source / remote / remote.cpp
index a193b2bf599ef87507fa9aedc037c4572c7a3c10..21689867a8f58c02a908537e919e883b30bfc123 100644 (file)
@@ -1,13 +1,15 @@
 /* $Id$
 
-This file is part of the MSP Märklin suite
+This file is part of R²C²
 Copyright © 2009-2010  Mikkosoft Productions, Mikko Rasa
 Distributed under the GPL
 */
 
+#include <gtkmm/scrolledwindow.h>
 #include <gtkmm/separator.h>
 #include <msp/net/resolve.h>
 #include <msp/time/units.h>
+#include "mainpanel.h"
 #include "remote.h"
 #include "trainpanel.h"
 
@@ -38,8 +40,15 @@ Remote::Remote(int argc, char **argv):
        window.set_default_size(300, 200);
        window.set_border_width(5);
 
-       train_box = new Gtk::VBox(false, 5);
-       window.add(*manage(train_box));
+       Gtk::ScrolledWindow *scroll = new Gtk::ScrolledWindow;
+       window.add(*manage(scroll));
+       scroll->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
+
+       panel_box = new Gtk::VBox(false, 5);
+       scroll->add(*manage(panel_box));
+
+       main_panel = new MainPanel(*this, client);
+       panel_box->pack_start(*manage(main_panel), false, true);
 
        window.show_all();
 }
@@ -50,15 +59,13 @@ void Remote::tick()
        gtk.iteration(false);
 }
 
-void Remote::train_added(Marklin::NetTrain &t)
+void Remote::train_added(R2C2::NetTrain &t)
 {
+       Gtk::HSeparator *sep = new Gtk::HSeparator;
+       panel_box->pack_start(*manage(sep), false, true);
+       sep->show();
+
        TrainPanel *panel = new TrainPanel(*this, client, t);
-       if(!train_panels.empty())
-       {
-               Gtk::HSeparator *sep = new Gtk::HSeparator;
-               train_box->pack_start(*manage(sep), false, true);
-               sep->show();
-       }
-       train_box->pack_start(*manage(panel), false, true);
+       panel_box->pack_start(*manage(panel), false, true);
        train_panels.push_back(panel);
 }