3 MainWin::MainWin(const std::string& title, Graph & graph, CoordinatesMap & cm,
4 MapStorage & ms):mapwin("Map Setup", ms, gd_canvas),gd_canvas(graph, cm, ms)
7 set_default_size(WIN_WIDTH,WIN_HEIGHT);
10 ag=Gtk::ActionGroup::create();
12 ag->add( Gtk::Action::create("FileMenu", "_File") );
13 ag->add( Gtk::Action::create("FileNew", Gtk::Stock::NEW),
14 sigc::mem_fun(*this, &MainWin::newFile));
15 ag->add( Gtk::Action::create("FileOpen", Gtk::Stock::OPEN),
16 sigc::mem_fun(*this, &MainWin::openFile));
17 ag->add( Gtk::Action::create("FileSave", Gtk::Stock::SAVE),
18 sigc::mem_fun(*this, &MainWin::saveFile));
19 ag->add( Gtk::Action::create("FileSaveAs", Gtk::Stock::SAVE_AS),
20 sigc::mem_fun(*this, &MainWin::saveFileAs));
21 ag->add( Gtk::Action::create("FileQuit", Gtk::Stock::QUIT),
22 sigc::mem_fun(*this, &MainWin::quit));
24 ag->add( Gtk::Action::create("ViewMenu", "_View") );
25 ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN),
26 sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomIn));
27 ag->add( Gtk::Action::create("ViewZoomOut", Gtk::Stock::ZOOM_OUT),
28 sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomOut));
29 ag->add( Gtk::Action::create("ViewZoomFit", Gtk::Stock::ZOOM_FIT),
30 sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomFit));
31 ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100),
32 sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoom100));
34 ag->add( Gtk::Action::create("ShowMenu", "_Show") );
35 ag->add( Gtk::Action::create("ShowMaps", "_Maps"),
36 sigc::mem_fun(*this, &MainWin::showMaps));
38 uim=Gtk::UIManager::create();
39 uim->insert_action_group(ag);
40 add_accel_group(uim->get_accel_group());
45 Glib::ustring ui_info =
47 " <menubar name='MenuBar'>"
48 " <menu action='FileMenu'>"
49 " <menuitem action='FileNew'/>"
50 " <menuitem action='FileOpen'/>"
51 " <menuitem action='FileSave'/>"
52 " <menuitem action='FileSaveAs'/>"
53 " <menuitem action='FileQuit'/>"
55 " <menu action='ViewMenu'>"
56 " <menuitem action='ViewZoomIn' />"
57 " <menuitem action='ViewZoomOut' />"
58 " <menuitem action='ViewZoomFit' />"
59 " <menuitem action='ViewZoom100' />"
61 " <menu action='ShowMenu'>"
62 " <menuitem action='ShowMaps'/>"
65 " <toolbar name='ToolBar'>"
66 " <toolitem action='FileNew' />"
67 " <toolitem action='FileOpen' />"
68 " <toolitem action='FileSave' />"
70 " <toolitem action='ViewZoomIn' />"
71 " <toolitem action='ViewZoomOut' />"
72 " <toolitem action='ViewZoomFit' />"
73 " <toolitem action='ViewZoom100' />"
77 uim->add_ui_from_string(ui_info);
80 catch(const Glib::Error& ex)
82 std::cerr << "building menus failed: " << ex.what();
85 Gtk::Widget* menubar = uim->get_widget("/MenuBar");
87 vbox.pack_start(*menubar, Gtk::PACK_SHRINK);
90 Gtk::Widget* toolbar = uim->get_widget("/ToolBar");
93 static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS);
94 vbox.pack_start(*toolbar, Gtk::PACK_SHRINK);
97 Gtk::ScrolledWindow* pScrolledWindow = manage(new Gtk::ScrolledWindow());
98 pScrolledWindow->add(gd_canvas);
99 vbox.pack_start(*pScrolledWindow);
100 //vbox.pack_start(gd_canvas);
105 void MainWin::showMaps()
115 void MainWin::newFile()
117 std::cerr << "MainWin::newFile(): not yet implemented" << std::endl;
120 void MainWin::openFile()
122 std::cerr << "MainWin::openFile(): not yet implemented" << std::endl;
125 void MainWin::saveFile()
127 std::cerr << "MainWin::saveFile(): not yet implemented" << std::endl;
130 void MainWin::saveFileAs()
132 std::cerr << "MainWin::saveFileAs(): not yet implemented" << std::endl;