[1442] | 1 | #include <main_win.h> |
---|
| 2 | |
---|
| 3 | MainWin::MainWin(const std::string& title, Graph & graph, CoordinatesMap & cm, |
---|
[1592] | 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) |
---|
[1442] | 5 | { |
---|
[1592] | 6 | //Creating a window for setting new maps. |
---|
| 7 | // newmapwin=new NewMapWi("Creating new map",*this); |
---|
| 8 | |
---|
| 9 | |
---|
[1442] | 10 | set_title (title); |
---|
| 11 | set_default_size(WIN_WIDTH,WIN_HEIGHT); |
---|
| 12 | add(vbox); |
---|
| 13 | |
---|
| 14 | ag=Gtk::ActionGroup::create(); |
---|
| 15 | |
---|
| 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)); |
---|
| 27 | |
---|
| 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)); |
---|
| 37 | |
---|
| 38 | ag->add( Gtk::Action::create("ShowMenu", "_Show") ); |
---|
| 39 | ag->add( Gtk::Action::create("ShowMaps", "_Maps"), |
---|
| 40 | sigc::mem_fun(*this, &MainWin::showMaps)); |
---|
[1468] | 41 | ag->add( Gtk::Action::create("ShowEditorials", "_Editorials"), |
---|
| 42 | sigc::mem_fun(*this, &MainWin::showEditorials)); |
---|
[1442] | 43 | |
---|
[1502] | 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) ); |
---|
[1550] | 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) ); |
---|
[1592] | 56 | ag->add( Gtk::Action::create("AddMap", Gtk::Stock::NEW), |
---|
| 57 | sigc::mem_fun ( this->newmapwin, &NewMapWin::show ) ); |
---|
[1502] | 58 | |
---|
[1442] | 59 | uim=Gtk::UIManager::create(); |
---|
| 60 | uim->insert_action_group(ag); |
---|
| 61 | add_accel_group(uim->get_accel_group()); |
---|
| 62 | |
---|
| 63 | try |
---|
| 64 | { |
---|
| 65 | |
---|
| 66 | Glib::ustring ui_info = |
---|
| 67 | "<ui>" |
---|
| 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'/>" |
---|
| 75 | " </menu>" |
---|
| 76 | " <menu action='ViewMenu'>" |
---|
| 77 | " <menuitem action='ViewZoomIn' />" |
---|
| 78 | " <menuitem action='ViewZoomOut' />" |
---|
| 79 | " <menuitem action='ViewZoomFit' />" |
---|
| 80 | " <menuitem action='ViewZoom100' />" |
---|
| 81 | " </menu>" |
---|
| 82 | " <menu action='ShowMenu'>" |
---|
| 83 | " <menuitem action='ShowMaps'/>" |
---|
[1468] | 84 | " <menuitem action='ShowEditorials'/>" |
---|
[1442] | 85 | " </menu>" |
---|
| 86 | " </menubar>" |
---|
| 87 | " <toolbar name='ToolBar'>" |
---|
| 88 | " <toolitem action='FileNew' />" |
---|
| 89 | " <toolitem action='FileOpen' />" |
---|
| 90 | " <toolitem action='FileSave' />" |
---|
| 91 | " <separator />" |
---|
| 92 | " <toolitem action='ViewZoomIn' />" |
---|
| 93 | " <toolitem action='ViewZoomOut' />" |
---|
| 94 | " <toolitem action='ViewZoomFit' />" |
---|
| 95 | " <toolitem action='ViewZoom100' />" |
---|
[1502] | 96 | " <separator />" |
---|
| 97 | " <toolitem action='CreateNode' />" |
---|
| 98 | " <toolitem action='CreateEdge' />" |
---|
| 99 | " <toolitem action='EraseItem' />" |
---|
| 100 | " <toolitem action='MoveItem' />" |
---|
[1550] | 101 | " <toolitem action='EditEdgeMap' />" |
---|
| 102 | " <toolitem action='EditNodeMap' />" |
---|
[1592] | 103 | " <toolitem action='AddMap' />" |
---|
[1442] | 104 | " </toolbar>" |
---|
| 105 | "</ui>"; |
---|
| 106 | |
---|
| 107 | uim->add_ui_from_string(ui_info); |
---|
| 108 | |
---|
| 109 | } |
---|
| 110 | catch(const Glib::Error& ex) |
---|
| 111 | { |
---|
| 112 | std::cerr << "building menus failed: " << ex.what(); |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | Gtk::Widget* menubar = uim->get_widget("/MenuBar"); |
---|
| 116 | if (menubar){ |
---|
| 117 | vbox.pack_start(*menubar, Gtk::PACK_SHRINK); |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | Gtk::Widget* toolbar = uim->get_widget("/ToolBar"); |
---|
| 121 | if (toolbar) |
---|
| 122 | { |
---|
| 123 | static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS); |
---|
| 124 | vbox.pack_start(*toolbar, Gtk::PACK_SHRINK); |
---|
| 125 | } |
---|
| 126 | |
---|
| 127 | Gtk::ScrolledWindow* pScrolledWindow = manage(new Gtk::ScrolledWindow()); |
---|
| 128 | pScrolledWindow->add(gd_canvas); |
---|
| 129 | vbox.pack_start(*pScrolledWindow); |
---|
| 130 | //vbox.pack_start(gd_canvas); |
---|
| 131 | |
---|
| 132 | show_all_children(); |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | void MainWin::showMaps() |
---|
| 136 | { |
---|
| 137 | mapwin.show(); |
---|
| 138 | } |
---|
| 139 | |
---|
[1468] | 140 | void MainWin::showEditorials() |
---|
| 141 | { |
---|
| 142 | editwin.show(); |
---|
| 143 | } |
---|
| 144 | |
---|
[1442] | 145 | void MainWin::quit() |
---|
| 146 | { |
---|
| 147 | hide(); |
---|
| 148 | } |
---|
| 149 | |
---|
| 150 | void MainWin::newFile() |
---|
| 151 | { |
---|
| 152 | std::cerr << "MainWin::newFile(): not yet implemented" << std::endl; |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | void MainWin::openFile() |
---|
| 156 | { |
---|
| 157 | std::cerr << "MainWin::openFile(): not yet implemented" << std::endl; |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | void MainWin::saveFile() |
---|
| 161 | { |
---|
| 162 | std::cerr << "MainWin::saveFile(): not yet implemented" << std::endl; |
---|
| 163 | } |
---|
| 164 | |
---|
| 165 | void MainWin::saveFileAs() |
---|
| 166 | { |
---|
| 167 | std::cerr << "MainWin::saveFileAs(): not yet implemented" << std::endl; |
---|
| 168 | } |
---|