EdgeMap and NodeMap creation is done, at last. Bach 4ever.
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),newmapwin("Creating new map",gd_canvas),gd_canvas(graph, cm, ms, &mapwin)
6 //Creating a window for setting new maps.
7 // newmapwin=new NewMapWi("Creating new map",*this);
11 set_default_size(WIN_WIDTH,WIN_HEIGHT);
14 ag=Gtk::ActionGroup::create();
16 ag->add( Gtk::Action::create("FileMenu", "_File") );
17 ag->add( Gtk::Action::create("FileNew", Gtk::Stock::NEW),
18 sigc::mem_fun(*this, &MainWin::newFile));
19 ag->add( Gtk::Action::create("FileOpen", Gtk::Stock::OPEN),
20 sigc::mem_fun(*this, &MainWin::openFile));
21 ag->add( Gtk::Action::create("FileSave", Gtk::Stock::SAVE),
22 sigc::mem_fun(*this, &MainWin::saveFile));
23 ag->add( Gtk::Action::create("FileSaveAs", Gtk::Stock::SAVE_AS),
24 sigc::mem_fun(*this, &MainWin::saveFileAs));
25 ag->add( Gtk::Action::create("FileQuit", Gtk::Stock::QUIT),
26 sigc::mem_fun(*this, &MainWin::quit));
28 ag->add( Gtk::Action::create("ViewMenu", "_View") );
29 ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN),
30 sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomIn));
31 ag->add( Gtk::Action::create("ViewZoomOut", Gtk::Stock::ZOOM_OUT),
32 sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomOut));
33 ag->add( Gtk::Action::create("ViewZoomFit", Gtk::Stock::ZOOM_FIT),
34 sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomFit));
35 ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100),
36 sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoom100));
38 ag->add( Gtk::Action::create("ShowMenu", "_Show") );
39 ag->add( Gtk::Action::create("ShowMaps", "_Maps"),
40 sigc::mem_fun(*this, &MainWin::showMaps));
41 ag->add( Gtk::Action::create("ShowEditorials", "_Editorials"),
42 sigc::mem_fun(*this, &MainWin::showEditorials));
44 ag->add( Gtk::Action::create("CreateNode", Gtk::Stock::NO),
45 sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 1) );
46 ag->add( Gtk::Action::create("CreateEdge", Gtk::Stock::REMOVE),
47 sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 2) );
48 ag->add( Gtk::Action::create("EraseItem", Gtk::Stock::DELETE),
49 sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 3) );
50 ag->add( Gtk::Action::create("MoveItem", Gtk::Stock::CONVERT),
51 sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 0) );
52 ag->add( Gtk::Action::create("EditEdgeMap", Gtk::Stock::PROPERTIES),
53 sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 4) );
54 ag->add( Gtk::Action::create("EditNodeMap", Gtk::Stock::PREFERENCES),
55 sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 5) );
56 ag->add( Gtk::Action::create("AddMap", Gtk::Stock::NEW),
57 sigc::mem_fun ( this->newmapwin, &NewMapWin::show ) );
59 uim=Gtk::UIManager::create();
60 uim->insert_action_group(ag);
61 add_accel_group(uim->get_accel_group());
66 Glib::ustring ui_info =
68 " <menubar name='MenuBar'>"
69 " <menu action='FileMenu'>"
70 " <menuitem action='FileNew'/>"
71 " <menuitem action='FileOpen'/>"
72 " <menuitem action='FileSave'/>"
73 " <menuitem action='FileSaveAs'/>"
74 " <menuitem action='FileQuit'/>"
76 " <menu action='ViewMenu'>"
77 " <menuitem action='ViewZoomIn' />"
78 " <menuitem action='ViewZoomOut' />"
79 " <menuitem action='ViewZoomFit' />"
80 " <menuitem action='ViewZoom100' />"
82 " <menu action='ShowMenu'>"
83 " <menuitem action='ShowMaps'/>"
84 " <menuitem action='ShowEditorials'/>"
87 " <toolbar name='ToolBar'>"
88 " <toolitem action='FileNew' />"
89 " <toolitem action='FileOpen' />"
90 " <toolitem action='FileSave' />"
92 " <toolitem action='ViewZoomIn' />"
93 " <toolitem action='ViewZoomOut' />"
94 " <toolitem action='ViewZoomFit' />"
95 " <toolitem action='ViewZoom100' />"
97 " <toolitem action='CreateNode' />"
98 " <toolitem action='CreateEdge' />"
99 " <toolitem action='EraseItem' />"
100 " <toolitem action='MoveItem' />"
101 " <toolitem action='EditEdgeMap' />"
102 " <toolitem action='EditNodeMap' />"
103 " <toolitem action='AddMap' />"
107 uim->add_ui_from_string(ui_info);
110 catch(const Glib::Error& ex)
112 std::cerr << "building menus failed: " << ex.what();
115 Gtk::Widget* menubar = uim->get_widget("/MenuBar");
117 vbox.pack_start(*menubar, Gtk::PACK_SHRINK);
120 Gtk::Widget* toolbar = uim->get_widget("/ToolBar");
123 static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS);
124 vbox.pack_start(*toolbar, Gtk::PACK_SHRINK);
127 Gtk::ScrolledWindow* pScrolledWindow = manage(new Gtk::ScrolledWindow());
128 pScrolledWindow->add(gd_canvas);
129 vbox.pack_start(*pScrolledWindow);
130 //vbox.pack_start(gd_canvas);
135 void MainWin::showMaps()
140 void MainWin::showEditorials()
150 void MainWin::newFile()
152 std::cerr << "MainWin::newFile(): not yet implemented" << std::endl;
155 void MainWin::openFile()
157 std::cerr << "MainWin::openFile(): not yet implemented" << std::endl;
160 void MainWin::saveFile()
162 std::cerr << "MainWin::saveFile(): not yet implemented" << std::endl;
165 void MainWin::saveFileAs()
167 std::cerr << "MainWin::saveFileAs(): not yet implemented" << std::endl;