Three commits, one after the other! 81 is my, 82 is my fiancee's, 83 is my younger sister's birthyear :) In this commit Alpar's wish came true: editorial buttons are now available directly on toolbar.
3 MainWin::MainWin(const std::string& title, Graph & graph, CoordinatesMap & cm,
4 MapStorage & ms):mapwin("Map Setup", ms, gd_canvas),editwin("Editorial Window", 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));
37 ag->add( Gtk::Action::create("ShowEditorials", "_Editorials"),
38 sigc::mem_fun(*this, &MainWin::showEditorials));
40 ag->add( Gtk::Action::create("CreateNode", Gtk::Stock::NO),
41 sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 1) );
42 ag->add( Gtk::Action::create("CreateEdge", Gtk::Stock::REMOVE),
43 sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 2) );
44 ag->add( Gtk::Action::create("EraseItem", Gtk::Stock::DELETE),
45 sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 3) );
46 ag->add( Gtk::Action::create("MoveItem", Gtk::Stock::CONVERT),
47 sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 0) );
49 uim=Gtk::UIManager::create();
50 uim->insert_action_group(ag);
51 add_accel_group(uim->get_accel_group());
56 Glib::ustring ui_info =
58 " <menubar name='MenuBar'>"
59 " <menu action='FileMenu'>"
60 " <menuitem action='FileNew'/>"
61 " <menuitem action='FileOpen'/>"
62 " <menuitem action='FileSave'/>"
63 " <menuitem action='FileSaveAs'/>"
64 " <menuitem action='FileQuit'/>"
66 " <menu action='ViewMenu'>"
67 " <menuitem action='ViewZoomIn' />"
68 " <menuitem action='ViewZoomOut' />"
69 " <menuitem action='ViewZoomFit' />"
70 " <menuitem action='ViewZoom100' />"
72 " <menu action='ShowMenu'>"
73 " <menuitem action='ShowMaps'/>"
74 " <menuitem action='ShowEditorials'/>"
77 " <toolbar name='ToolBar'>"
78 " <toolitem action='FileNew' />"
79 " <toolitem action='FileOpen' />"
80 " <toolitem action='FileSave' />"
82 " <toolitem action='ViewZoomIn' />"
83 " <toolitem action='ViewZoomOut' />"
84 " <toolitem action='ViewZoomFit' />"
85 " <toolitem action='ViewZoom100' />"
87 " <toolitem action='CreateNode' />"
88 " <toolitem action='CreateEdge' />"
89 " <toolitem action='EraseItem' />"
90 " <toolitem action='MoveItem' />"
94 uim->add_ui_from_string(ui_info);
97 catch(const Glib::Error& ex)
99 std::cerr << "building menus failed: " << ex.what();
102 Gtk::Widget* menubar = uim->get_widget("/MenuBar");
104 vbox.pack_start(*menubar, Gtk::PACK_SHRINK);
107 Gtk::Widget* toolbar = uim->get_widget("/ToolBar");
110 static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS);
111 vbox.pack_start(*toolbar, Gtk::PACK_SHRINK);
114 Gtk::ScrolledWindow* pScrolledWindow = manage(new Gtk::ScrolledWindow());
115 pScrolledWindow->add(gd_canvas);
116 vbox.pack_start(*pScrolledWindow);
117 //vbox.pack_start(gd_canvas);
122 void MainWin::showMaps()
127 void MainWin::showEditorials()
137 void MainWin::newFile()
139 std::cerr << "MainWin::newFile(): not yet implemented" << std::endl;
142 void MainWin::openFile()
144 std::cerr << "MainWin::openFile(): not yet implemented" << std::endl;
147 void MainWin::saveFile()
149 std::cerr << "MainWin::saveFile(): not yet implemented" << std::endl;
152 void MainWin::saveFileAs()
154 std::cerr << "MainWin::saveFileAs(): not yet implemented" << std::endl;