3 This file is part of R²C²
4 Copyright © 2009-2011 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #include <gtkmm/scrolledwindow.h>
9 #include <gtkmm/separator.h>
10 #include <msp/net/resolve.h>
11 #include <msp/time/units.h>
12 #include "mainpanel.h"
14 #include "trainpanel.h"
19 Application::RegApp<Remote> Remote::reg;
21 Remote::Remote(int argc, char **argv):
26 throw UsageError("No address given");
28 DataFile::load(catalogue, "locos.dat");
30 client.use_event_dispatcher(event_disp);
31 client.signal_train_added.connect(sigc::mem_fun(this, &Remote::train_added));
32 string addr_str = argv[1];
33 if(addr_str.find(':')==string::npos)
35 Net::SockAddr *addr = Net::resolve(addr_str);
36 client.connect(*addr);
39 window.signal_hide().connect(sigc::bind(sigc::mem_fun(this, &Remote::exit), 0));
40 window.set_default_size(300, 200);
41 window.set_border_width(5);
43 Gtk::ScrolledWindow *scroll = new Gtk::ScrolledWindow;
44 window.add(*manage(scroll));
45 scroll->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
47 panel_box = new Gtk::VBox(false, 5);
48 scroll->add(*manage(panel_box));
50 main_panel = new MainPanel(*this, client);
51 panel_box->pack_start(*manage(main_panel), false, true);
58 event_disp.tick(Time::zero);
62 void Remote::train_added(R2C2::NetTrain &t)
64 Gtk::HSeparator *sep = new Gtk::HSeparator;
65 panel_box->pack_start(*manage(sep), false, true);
68 TrainPanel *panel = new TrainPanel(*this, client, t);
69 panel_box->pack_start(*manage(panel), false, true);
70 train_panels.push_back(panel);