[130] | 1 | #ifdef HAVE_CONFIG_H |
---|
| 2 | #include <config.h> |
---|
| 3 | #endif |
---|
| 4 | |
---|
[53] | 5 | #include "main_win.h" |
---|
[100] | 6 | #include "guipixbufs.h" |
---|
[6] | 7 | |
---|
[130] | 8 | #include "gettext.h" |
---|
| 9 | #define _(string) gettext (string) |
---|
| 10 | |
---|
[96] | 11 | MainWin::MainWin() |
---|
[6] | 12 | { |
---|
[96] | 13 | set_title ("no file"); |
---|
[6] | 14 | set_default_size(WIN_WIDTH,WIN_HEIGHT); |
---|
| 15 | add(vbox); |
---|
| 16 | |
---|
[60] | 17 | // custom icons for the toolbar |
---|
| 18 | Glib::RefPtr<Gtk::IconFactory> p_icon_factory = Gtk::IconFactory::create(); |
---|
| 19 | |
---|
[61] | 20 | Glib::RefPtr<Gdk::Pixbuf> p_move_pixbuf = Gdk::Pixbuf::create_from_inline( |
---|
| 21 | 2328, gui_icons_move); |
---|
| 22 | Glib::RefPtr<Gdk::Pixbuf> p_addnode_pixbuf = Gdk::Pixbuf::create_from_inline( |
---|
| 23 | 2328, gui_icons_addnode); |
---|
| 24 | Glib::RefPtr<Gdk::Pixbuf> p_addlink_pixbuf = Gdk::Pixbuf::create_from_inline( |
---|
| 25 | 2328, gui_icons_addlink); |
---|
| 26 | Glib::RefPtr<Gdk::Pixbuf> p_delete_pixbuf = Gdk::Pixbuf::create_from_inline( |
---|
| 27 | 2328, gui_icons_delete); |
---|
| 28 | Glib::RefPtr<Gdk::Pixbuf> p_editlink_pixbuf = Gdk::Pixbuf::create_from_inline( |
---|
| 29 | 2328, gui_icons_editlink); |
---|
| 30 | Glib::RefPtr<Gdk::Pixbuf> p_editnode_pixbuf = Gdk::Pixbuf::create_from_inline( |
---|
| 31 | 2328, gui_icons_editnode); |
---|
| 32 | Glib::RefPtr<Gdk::Pixbuf> p_newmap_pixbuf = Gdk::Pixbuf::create_from_inline( |
---|
| 33 | 2328, gui_icons_newmap); |
---|
[60] | 34 | |
---|
| 35 | Gtk::IconSource move_icon_source; |
---|
[61] | 36 | move_icon_source.set_pixbuf(p_move_pixbuf); |
---|
[60] | 37 | Gtk::IconSet move_icon_set; |
---|
| 38 | move_icon_set.add_source(move_icon_source); |
---|
| 39 | p_icon_factory->add(Gtk::StockID("gd-move"), move_icon_set); |
---|
| 40 | |
---|
| 41 | Gtk::IconSource addnode_icon_source; |
---|
[61] | 42 | addnode_icon_source.set_pixbuf(p_addnode_pixbuf); |
---|
[60] | 43 | Gtk::IconSet addnode_icon_set; |
---|
| 44 | addnode_icon_set.add_source(addnode_icon_source); |
---|
| 45 | p_icon_factory->add(Gtk::StockID("gd-addnode"), addnode_icon_set); |
---|
| 46 | |
---|
| 47 | Gtk::IconSource addlink_icon_source; |
---|
[61] | 48 | addlink_icon_source.set_pixbuf(p_addlink_pixbuf); |
---|
[60] | 49 | Gtk::IconSet addlink_icon_set; |
---|
| 50 | addlink_icon_set.add_source(addlink_icon_source); |
---|
| 51 | p_icon_factory->add(Gtk::StockID("gd-addlink"), addlink_icon_set); |
---|
| 52 | |
---|
| 53 | Gtk::IconSource delete_icon_source; |
---|
[61] | 54 | delete_icon_source.set_pixbuf(p_delete_pixbuf); |
---|
[60] | 55 | Gtk::IconSet delete_icon_set; |
---|
| 56 | delete_icon_set.add_source(delete_icon_source); |
---|
| 57 | p_icon_factory->add(Gtk::StockID("gd-delete"), delete_icon_set); |
---|
| 58 | |
---|
| 59 | Gtk::IconSource editlink_icon_source; |
---|
[61] | 60 | editlink_icon_source.set_pixbuf(p_editlink_pixbuf); |
---|
[60] | 61 | Gtk::IconSet editlink_icon_set; |
---|
| 62 | editlink_icon_set.add_source(editlink_icon_source); |
---|
| 63 | p_icon_factory->add(Gtk::StockID("gd-editlink"), editlink_icon_set); |
---|
| 64 | |
---|
| 65 | Gtk::IconSource editnode_icon_source; |
---|
[61] | 66 | editnode_icon_source.set_pixbuf(p_editnode_pixbuf); |
---|
[60] | 67 | Gtk::IconSet editnode_icon_set; |
---|
| 68 | editnode_icon_set.add_source(editnode_icon_source); |
---|
| 69 | p_icon_factory->add(Gtk::StockID("gd-editnode"), editnode_icon_set); |
---|
| 70 | |
---|
| 71 | Gtk::IconSource newmap_icon_source; |
---|
[61] | 72 | newmap_icon_source.set_pixbuf(p_newmap_pixbuf); |
---|
[60] | 73 | Gtk::IconSet newmap_icon_set; |
---|
| 74 | newmap_icon_set.add_source(newmap_icon_source); |
---|
| 75 | p_icon_factory->add(Gtk::StockID("gd-newmap"), newmap_icon_set); |
---|
| 76 | |
---|
| 77 | p_icon_factory->add_default(); |
---|
| 78 | |
---|
[6] | 79 | ag=Gtk::ActionGroup::create(); |
---|
| 80 | |
---|
[130] | 81 | ag->add( Gtk::Action::create("FileMenu", _("_File")) ); |
---|
[102] | 82 | ag->add( Gtk::Action::create("FileNew", Gtk::Stock::NEW), |
---|
[96] | 83 | sigc::mem_fun(*this, &MainWin::newTab)); |
---|
[6] | 84 | ag->add( Gtk::Action::create("FileOpen", Gtk::Stock::OPEN), |
---|
| 85 | sigc::mem_fun(*this, &MainWin::openFile)); |
---|
[130] | 86 | ag->add( Gtk::Action::create("FileClearTab", _("Clear Tab")), |
---|
[102] | 87 | sigc::mem_fun(*this, &MainWin::newFile)); |
---|
[6] | 88 | ag->add( Gtk::Action::create("FileSave", Gtk::Stock::SAVE), |
---|
| 89 | sigc::mem_fun(*this, &MainWin::saveFile)); |
---|
| 90 | ag->add( Gtk::Action::create("FileSaveAs", Gtk::Stock::SAVE_AS), |
---|
| 91 | sigc::mem_fun(*this, &MainWin::saveFileAs)); |
---|
[53] | 92 | ag->add( Gtk::Action::create("Close", Gtk::Stock::CLOSE), |
---|
[102] | 93 | sigc::mem_fun(*this, &MainWin::closeTab)); |
---|
[53] | 94 | ag->add( Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
---|
[47] | 95 | sigc::mem_fun(*this, &MainWin::hide)); |
---|
[6] | 96 | |
---|
[130] | 97 | ag->add( Gtk::Action::create("ViewMenu", _("_View")) ); |
---|
[6] | 98 | ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN), |
---|
[96] | 99 | sigc::mem_fun(*this, &MainWin::zoomIn)); |
---|
[6] | 100 | ag->add( Gtk::Action::create("ViewZoomOut", Gtk::Stock::ZOOM_OUT), |
---|
[96] | 101 | sigc::mem_fun(*this, &MainWin::zoomOut)); |
---|
[6] | 102 | ag->add( Gtk::Action::create("ViewZoomFit", Gtk::Stock::ZOOM_FIT), |
---|
[96] | 103 | sigc::mem_fun(*this, &MainWin::zoomFit)); |
---|
[6] | 104 | ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100), |
---|
[96] | 105 | sigc::mem_fun(*this, &MainWin::zoom100)); |
---|
[6] | 106 | |
---|
[130] | 107 | ag->add( Gtk::Action::create("ShowMenu", _("_Show")) ); |
---|
| 108 | ag->add( Gtk::Action::create("ShowMaps", _("_Maps")), |
---|
[95] | 109 | sigc::mem_fun(*this, &MainWin::createMapWin)); |
---|
[6] | 110 | |
---|
[130] | 111 | ag->add( Gtk::Action::create("AlgoMenu", _("_Algorithms")) ); |
---|
| 112 | ag->add( Gtk::Action::create("AlgoGeneral", _("_General")), |
---|
[103] | 113 | sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 0) ); |
---|
[130] | 114 | ag->add( Gtk::Action::create("AlgoKruskal", _("_Kruskal")), |
---|
[106] | 115 | sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 1) ); |
---|
[103] | 116 | |
---|
[53] | 117 | Gtk::RadioAction::Group tool_group; |
---|
[130] | 118 | ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), _("Move")), |
---|
[96] | 119 | sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 0) ); |
---|
[130] | 120 | ag->add( Gtk::RadioAction::create(tool_group, "CreateNode", Gtk::StockID("gd-addnode"), _("Create node")), |
---|
[96] | 121 | sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 1) ); |
---|
[130] | 122 | ag->add( Gtk::RadioAction::create(tool_group, "CreateEdge", Gtk::StockID("gd-addlink"), _("Create edge")), |
---|
[96] | 123 | sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 2) ); |
---|
[130] | 124 | ag->add( Gtk::RadioAction::create(tool_group, "EraseItem", Gtk::StockID("gd-delete"), _("Delete")), |
---|
[96] | 125 | sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 3) ); |
---|
[60] | 126 | |
---|
[130] | 127 | ag->add( Gtk::RadioAction::create(tool_group, "EditEdgeMap", Gtk::StockID("gd-editlink"), _("Edit edge map")), |
---|
[96] | 128 | sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 4) ); |
---|
[130] | 129 | ag->add( Gtk::RadioAction::create(tool_group, "EditNodeMap", Gtk::StockID("gd-editnode"), _("Edit node map")), |
---|
[96] | 130 | sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 5) ); |
---|
[60] | 131 | |
---|
| 132 | ag->add( Gtk::Action::create("AddMap", Gtk::StockID("gd-newmap")), |
---|
[96] | 133 | sigc::mem_fun ( *this , &MainWin::createNewMapWin ) ); |
---|
[22] | 134 | |
---|
[6] | 135 | uim=Gtk::UIManager::create(); |
---|
| 136 | uim->insert_action_group(ag); |
---|
| 137 | add_accel_group(uim->get_accel_group()); |
---|
| 138 | |
---|
| 139 | try |
---|
| 140 | { |
---|
| 141 | |
---|
| 142 | Glib::ustring ui_info = |
---|
| 143 | "<ui>" |
---|
| 144 | " <menubar name='MenuBar'>" |
---|
| 145 | " <menu action='FileMenu'>" |
---|
| 146 | " <menuitem action='FileNew'/>" |
---|
| 147 | " <menuitem action='FileOpen'/>" |
---|
[102] | 148 | " <menuitem action='FileClearTab'/>" |
---|
[6] | 149 | " <menuitem action='FileSave'/>" |
---|
| 150 | " <menuitem action='FileSaveAs'/>" |
---|
[53] | 151 | " <menuitem action='Close'/>" |
---|
| 152 | " <menuitem action='Quit'/>" |
---|
[6] | 153 | " </menu>" |
---|
| 154 | " <menu action='ViewMenu'>" |
---|
| 155 | " <menuitem action='ViewZoomIn' />" |
---|
| 156 | " <menuitem action='ViewZoomOut' />" |
---|
| 157 | " <menuitem action='ViewZoom100' />" |
---|
[87] | 158 | " <menuitem action='ViewZoomFit' />" |
---|
[6] | 159 | " </menu>" |
---|
| 160 | " <menu action='ShowMenu'>" |
---|
| 161 | " <menuitem action='ShowMaps'/>" |
---|
| 162 | " </menu>" |
---|
[103] | 163 | " <menu action='AlgoMenu'>" |
---|
| 164 | " <menuitem action='AlgoGeneral'/>" |
---|
[106] | 165 | " <menuitem action='AlgoKruskal'/>" |
---|
[103] | 166 | " </menu>" |
---|
[6] | 167 | " </menubar>" |
---|
| 168 | " <toolbar name='ToolBar'>" |
---|
| 169 | " <toolitem action='FileNew' />" |
---|
| 170 | " <toolitem action='FileOpen' />" |
---|
| 171 | " <toolitem action='FileSave' />" |
---|
[53] | 172 | " <toolitem action='Close' />" |
---|
[6] | 173 | " <separator />" |
---|
| 174 | " <toolitem action='ViewZoomIn' />" |
---|
| 175 | " <toolitem action='ViewZoomOut' />" |
---|
| 176 | " <toolitem action='ViewZoom100' />" |
---|
[87] | 177 | " <toolitem action='ViewZoomFit' />" |
---|
[22] | 178 | " <separator />" |
---|
[53] | 179 | " <toolitem action='MoveItem' />" |
---|
[22] | 180 | " <toolitem action='CreateNode' />" |
---|
| 181 | " <toolitem action='CreateEdge' />" |
---|
| 182 | " <toolitem action='EraseItem' />" |
---|
[32] | 183 | " <toolitem action='EditEdgeMap' />" |
---|
| 184 | " <toolitem action='EditNodeMap' />" |
---|
[60] | 185 | " <separator />" |
---|
[41] | 186 | " <toolitem action='AddMap' />" |
---|
[6] | 187 | " </toolbar>" |
---|
| 188 | "</ui>"; |
---|
| 189 | |
---|
| 190 | uim->add_ui_from_string(ui_info); |
---|
| 191 | |
---|
| 192 | } |
---|
| 193 | catch(const Glib::Error& ex) |
---|
| 194 | { |
---|
| 195 | std::cerr << "building menus failed: " << ex.what(); |
---|
| 196 | } |
---|
| 197 | |
---|
| 198 | Gtk::Widget* menubar = uim->get_widget("/MenuBar"); |
---|
| 199 | if (menubar){ |
---|
| 200 | vbox.pack_start(*menubar, Gtk::PACK_SHRINK); |
---|
| 201 | } |
---|
| 202 | |
---|
| 203 | Gtk::Widget* toolbar = uim->get_widget("/ToolBar"); |
---|
| 204 | if (toolbar) |
---|
| 205 | { |
---|
| 206 | static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS); |
---|
| 207 | vbox.pack_start(*toolbar, Gtk::PACK_SHRINK); |
---|
| 208 | } |
---|
| 209 | |
---|
[50] | 210 | tooltips.set_tip(*(uim->get_widget("/ToolBar/CreateNode")),"Create Node"); |
---|
| 211 | tooltips.enable(); |
---|
[6] | 212 | |
---|
[96] | 213 | active_tab=-1; |
---|
| 214 | notebook.signal_switch_page().connect(sigc::mem_fun(*this, &MainWin::onChangeTab)); |
---|
| 215 | |
---|
[107] | 216 | active_tool = MOVE; |
---|
| 217 | |
---|
[96] | 218 | vbox.pack_start(notebook); |
---|
| 219 | |
---|
[6] | 220 | show_all_children(); |
---|
| 221 | } |
---|
| 222 | |
---|
[96] | 223 | void MainWin::set_tabtitle(std::string name) |
---|
[57] | 224 | { |
---|
[104] | 225 | if(strinst.find(name)==strinst.end()) |
---|
| 226 | { |
---|
| 227 | tabnames[active_tab]=name; |
---|
| 228 | strinst[name]=1; |
---|
| 229 | } |
---|
| 230 | else |
---|
| 231 | { |
---|
| 232 | strinst[name]++; |
---|
| 233 | std::ostringstream o; |
---|
| 234 | o << strinst[name]; |
---|
| 235 | tabnames[active_tab]=name+" - "+o.str(); |
---|
| 236 | } |
---|
[96] | 237 | set_title(tabnames[active_tab] + " - " + prog_name); |
---|
| 238 | notebook.set_tab_label_text((Widget&)*(tabs[active_tab]), tabnames[active_tab]); |
---|
[106] | 239 | updateAlgoWinTabs(); |
---|
[96] | 240 | } |
---|
| 241 | |
---|
| 242 | void MainWin::readFile(const std::string & filename) |
---|
| 243 | { |
---|
| 244 | newTab(); |
---|
| 245 | tabs[active_tab]->readFile(filename); |
---|
| 246 | } |
---|
| 247 | |
---|
| 248 | void MainWin::newTab() |
---|
| 249 | { |
---|
| 250 | int size=tabs.size(); |
---|
| 251 | tabs.resize(size+1); |
---|
| 252 | tabnames.resize(size+1); |
---|
| 253 | active_tab=size; |
---|
| 254 | tabs[active_tab]=new NoteBookTab(); |
---|
| 255 | tabs[active_tab]->signal_title_ch().connect(sigc::mem_fun(*this, &MainWin::set_tabtitle)); |
---|
| 256 | tabs[active_tab]->signal_newmap_needed().connect(sigc::mem_fun(*this, &MainWin::createNewMapWinAfterSignal)); |
---|
| 257 | tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool); |
---|
| 258 | notebook.append_page((Gtk::Widget&)(*(tabs[active_tab]))); |
---|
| 259 | notebook.set_current_page(size); |
---|
[130] | 260 | set_tabtitle(_("unsaved file")); |
---|
[106] | 261 | updateAlgoWinTabs(); |
---|
[96] | 262 | } |
---|
| 263 | |
---|
[97] | 264 | void MainWin::closeTab() |
---|
| 265 | { |
---|
| 266 | if(active_tab!=-1) |
---|
| 267 | { |
---|
[102] | 268 | if (tabs[active_tab]->mapstorage.modified) |
---|
| 269 | { |
---|
[130] | 270 | Gtk::MessageDialog mdialog(_("<b>Save changes before closing?</b>"), true, |
---|
[102] | 271 | Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE); |
---|
[130] | 272 | mdialog.add_button(_("Close file _without Saving"), Gtk::RESPONSE_REJECT); |
---|
[102] | 273 | mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
---|
| 274 | mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT); |
---|
| 275 | switch (mdialog.run()) |
---|
| 276 | { |
---|
| 277 | case Gtk::RESPONSE_CANCEL: |
---|
| 278 | return; |
---|
| 279 | case Gtk::RESPONSE_REJECT: |
---|
| 280 | break; |
---|
| 281 | case Gtk::RESPONSE_ACCEPT: |
---|
| 282 | tabs[active_tab]->saveFile(); |
---|
| 283 | break; |
---|
| 284 | } |
---|
| 285 | } |
---|
[97] | 286 | //tabs vector will be decreased with the deleted value |
---|
| 287 | int size=tabs.size(); |
---|
| 288 | if(size>1) |
---|
| 289 | { |
---|
| 290 | for(int i=active_tab+1;i<size;i++) |
---|
| 291 | { |
---|
[103] | 292 | tabnames[i-1]=tabnames[i]; |
---|
[97] | 293 | tabs[i-1]=tabs[i]; |
---|
| 294 | } |
---|
| 295 | } |
---|
| 296 | //if size==1 resize will delete the only element |
---|
| 297 | tabs.resize(size-1); |
---|
[103] | 298 | tabnames.resize(size-1); |
---|
[97] | 299 | |
---|
| 300 | int old_active_tab=active_tab; |
---|
| 301 | notebook.remove_page(active_tab); |
---|
| 302 | |
---|
| 303 | //If the first tab was active, upon delete notebook |
---|
| 304 | //will first switch one tab upper and not lower like |
---|
| 305 | //in the case, when not the first tab was active. |
---|
| 306 | //But after deletion it will become the first tab, |
---|
| 307 | //and this should be registrated in tabs vector, |
---|
| 308 | //as well. |
---|
[103] | 309 | if((old_active_tab==0)&&(size!=1)) |
---|
[97] | 310 | { |
---|
| 311 | onChangeTab(NULL,0); |
---|
| 312 | } |
---|
| 313 | |
---|
| 314 | //if this was the last page in notebook, there is |
---|
| 315 | //no active_tab now |
---|
| 316 | if(size==1) |
---|
| 317 | { |
---|
| 318 | active_tab=-1; |
---|
| 319 | } |
---|
[103] | 320 | |
---|
[106] | 321 | updateAlgoWinTabs(); |
---|
[97] | 322 | } |
---|
| 323 | } |
---|
| 324 | |
---|
[96] | 325 | void MainWin::onChangeTab(GtkNotebookPage* page, guint page_num) |
---|
| 326 | { |
---|
| 327 | page=page; |
---|
| 328 | active_tab=page_num; |
---|
| 329 | tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool); |
---|
| 330 | set_title(tabnames[active_tab]); |
---|
| 331 | } |
---|
| 332 | |
---|
[6] | 333 | void MainWin::newFile() |
---|
| 334 | { |
---|
[96] | 335 | if(active_tab!=-1) |
---|
[53] | 336 | { |
---|
[96] | 337 | tabs[active_tab]->newFile(); |
---|
[53] | 338 | } |
---|
[6] | 339 | } |
---|
[96] | 340 | |
---|
[6] | 341 | void MainWin::openFile() |
---|
| 342 | { |
---|
[96] | 343 | if(active_tab!=-1) |
---|
[53] | 344 | { |
---|
[96] | 345 | tabs[active_tab]->openFile(); |
---|
[53] | 346 | } |
---|
[6] | 347 | } |
---|
[96] | 348 | |
---|
[6] | 349 | void MainWin::saveFile() |
---|
| 350 | { |
---|
[96] | 351 | if(active_tab!=-1) |
---|
| 352 | { |
---|
| 353 | tabs[active_tab]->saveFile(); |
---|
| 354 | } |
---|
[6] | 355 | } |
---|
[96] | 356 | |
---|
[6] | 357 | void MainWin::saveFileAs() |
---|
| 358 | { |
---|
[96] | 359 | if(active_tab!=-1) |
---|
| 360 | { |
---|
| 361 | tabs[active_tab]->saveFileAs(); |
---|
| 362 | } |
---|
[6] | 363 | } |
---|
[96] | 364 | |
---|
[53] | 365 | void MainWin::close() |
---|
| 366 | { |
---|
[96] | 367 | if(active_tab!=-1) |
---|
[53] | 368 | { |
---|
[96] | 369 | tabs[active_tab]->close(); |
---|
[95] | 370 | } |
---|
[94] | 371 | } |
---|
| 372 | |
---|
[96] | 373 | void MainWin::zoomIn() |
---|
[94] | 374 | { |
---|
[96] | 375 | if(active_tab!=-1) |
---|
[95] | 376 | { |
---|
[96] | 377 | tabs[active_tab]->gd_canvas->zoomIn(); |
---|
| 378 | } |
---|
| 379 | } |
---|
| 380 | |
---|
| 381 | void MainWin::zoomOut() |
---|
| 382 | { |
---|
| 383 | if(active_tab!=-1) |
---|
| 384 | { |
---|
| 385 | tabs[active_tab]->gd_canvas->zoomOut(); |
---|
| 386 | } |
---|
| 387 | } |
---|
| 388 | |
---|
| 389 | void MainWin::zoomFit() |
---|
| 390 | { |
---|
| 391 | if(active_tab!=-1) |
---|
| 392 | { |
---|
| 393 | tabs[active_tab]->gd_canvas->zoomFit(); |
---|
| 394 | } |
---|
| 395 | } |
---|
| 396 | |
---|
| 397 | void MainWin::zoom100() |
---|
| 398 | { |
---|
| 399 | if(active_tab!=-1) |
---|
| 400 | { |
---|
| 401 | tabs[active_tab]->gd_canvas->zoom100(); |
---|
[95] | 402 | } |
---|
[94] | 403 | } |
---|
[95] | 404 | |
---|
| 405 | void MainWin::createMapWin() |
---|
| 406 | { |
---|
[96] | 407 | if(active_tab!=-1) |
---|
[95] | 408 | { |
---|
[96] | 409 | tabs[active_tab]->createMapWin(tabnames[active_tab]); |
---|
[95] | 410 | } |
---|
| 411 | } |
---|
| 412 | |
---|
[103] | 413 | void MainWin::createAlgoWin(int algoid) |
---|
| 414 | { |
---|
[108] | 415 | AlgoWin * aw=new AlgoWin(algoid, tabnames); |
---|
[103] | 416 | aw->signal_closing().connect(sigc::mem_fun(*this, &MainWin::deRegisterAlgoWin)); |
---|
[106] | 417 | aw->signal_maplist_needed().connect(sigc::mem_fun(*this, &MainWin::updateAlgoWinMaps)); |
---|
[114] | 418 | aw->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MainWin::createNewMapWinTabString)); |
---|
[103] | 419 | aws.insert(aw); |
---|
| 420 | aw->show(); |
---|
| 421 | } |
---|
| 422 | |
---|
[106] | 423 | void MainWin::updateAlgoWinTabs() |
---|
[103] | 424 | { |
---|
| 425 | std::set< AlgoWin* >::iterator awsi=aws.begin(); |
---|
| 426 | for(;awsi!=aws.end();awsi++) |
---|
| 427 | { |
---|
| 428 | (*awsi)->update_tablist(tabnames); |
---|
| 429 | } |
---|
| 430 | } |
---|
| 431 | |
---|
[108] | 432 | void MainWin::updateAlgoWinMaps(AlgoWin * awp, std::string tabname) |
---|
| 433 | { |
---|
| 434 | int i=0; |
---|
| 435 | for(;(i<(int)tabnames.size())&&(tabnames[i]!=tabname);i++) |
---|
| 436 | { |
---|
| 437 | } |
---|
| 438 | awp->update_maplist(&(tabs[i]->mapstorage)); |
---|
| 439 | } |
---|
| 440 | |
---|
| 441 | void MainWin::deRegisterAlgoWin(AlgoWin * awp) |
---|
| 442 | { |
---|
| 443 | aws.erase(awp); |
---|
| 444 | } |
---|
| 445 | |
---|
[96] | 446 | void MainWin::changeEditorialTool(int tool) |
---|
[95] | 447 | { |
---|
[96] | 448 | active_tool=tool; |
---|
| 449 | if(active_tab!=-1) |
---|
| 450 | { |
---|
| 451 | tabs[active_tab]->gd_canvas->changeEditorialTool(tool); |
---|
| 452 | } |
---|
[95] | 453 | } |
---|
[96] | 454 | |
---|
| 455 | void MainWin::createNewMapWin() |
---|
| 456 | { |
---|
| 457 | if(active_tab!=-1) |
---|
| 458 | { |
---|
[130] | 459 | NewMapWin * nmw=new NewMapWin(_("Create New Map - ")+tabnames[active_tab], *(tabs[active_tab])); |
---|
[96] | 460 | nmw->show(); |
---|
| 461 | } |
---|
| 462 | } |
---|
| 463 | |
---|
[114] | 464 | void MainWin::createNewMapWinTabString(std::string tabname, bool itisedge) |
---|
| 465 | { |
---|
| 466 | int i=0; |
---|
[120] | 467 | for(;((i<(int)tabnames.size())&&(tabnames[i]!=tabname));i++) |
---|
[114] | 468 | { |
---|
| 469 | } |
---|
| 470 | createNewMapWinAfterSignal(tabs[i], itisedge); |
---|
| 471 | } |
---|
| 472 | |
---|
[96] | 473 | void MainWin::createNewMapWinAfterSignal(NoteBookTab * nbt, bool itisedge) |
---|
| 474 | { |
---|
| 475 | std::vector<NoteBookTab*>::iterator nbti=tabs.begin(); |
---|
| 476 | int i=0; |
---|
| 477 | for(;nbti!=tabs.end();nbti++) |
---|
| 478 | { |
---|
| 479 | if(*nbti!=nbt) |
---|
| 480 | { |
---|
| 481 | i++; |
---|
| 482 | } |
---|
| 483 | else |
---|
| 484 | { |
---|
| 485 | continue; |
---|
| 486 | } |
---|
| 487 | } |
---|
[130] | 488 | NewMapWin * nmw=new NewMapWin(_("Create New Map - ")+tabnames[i], *nbt, itisedge, false); |
---|
[96] | 489 | nmw->run(); |
---|
| 490 | } |
---|