1 #include "main_win.h" |
1 #include "main_win.h" |
2 #include "icons/guipixbufs.h" |
2 #include "icons/guipixbufs.h" |
3 |
3 |
4 MainWin::MainWin() |
4 MainWin::MainWin():mapwinexists(false) |
5 { |
5 { |
6 mapwin=new MapWin("Map Setup", mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this); |
|
7 gd_canvas=new GraphDisplayerCanvas(*this); |
6 gd_canvas=new GraphDisplayerCanvas(*this); |
8 |
7 |
9 set_title ("unsaved file - " + prog_name); |
8 set_title ("unsaved file - " + prog_name); |
10 set_default_size(WIN_WIDTH,WIN_HEIGHT); |
9 set_default_size(WIN_WIDTH,WIN_HEIGHT); |
11 add(vbox); |
10 add(vbox); |
103 ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100), |
102 ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100), |
104 sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoom100)); |
103 sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoom100)); |
105 |
104 |
106 ag->add( Gtk::Action::create("ShowMenu", "_Show") ); |
105 ag->add( Gtk::Action::create("ShowMenu", "_Show") ); |
107 ag->add( Gtk::Action::create("ShowMaps", "_Maps"), |
106 ag->add( Gtk::Action::create("ShowMaps", "_Maps"), |
108 sigc::mem_fun(*(this->mapwin), &MapWin::show)); |
107 sigc::mem_fun(*this, &MainWin::createMapWin)); |
109 |
108 |
110 Gtk::RadioAction::Group tool_group; |
109 Gtk::RadioAction::Group tool_group; |
111 ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), "Move"), |
110 ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), "Move"), |
112 sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 0) ); |
111 sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 0) ); |
113 ag->add( Gtk::RadioAction::create(tool_group, "CreateNode", Gtk::StockID("gd-addnode"), "Create node"), |
112 ag->add( Gtk::RadioAction::create(tool_group, "CreateNode", Gtk::StockID("gd-addnode"), "Create node"), |
210 { |
209 { |
211 mapstorage.readFromFile(file); |
210 mapstorage.readFromFile(file); |
212 mapstorage.file_name = file; |
211 mapstorage.file_name = file; |
213 mapstorage.modified = false; |
212 mapstorage.modified = false; |
214 gd_canvas->drawGraph(); |
213 gd_canvas->drawGraph(); |
215 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); |
214 if(mapwinexists) |
|
215 { |
|
216 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); |
|
217 } |
216 set_title(Glib::filename_display_basename(file) + " - " + prog_name); |
218 set_title(Glib::filename_display_basename(file) + " - " + prog_name); |
217 } |
219 } |
218 |
220 |
219 void MainWin::newFile() |
221 void MainWin::newFile() |
220 { |
222 { |
273 if (!mapstorage.readFromFile(filename)) |
278 if (!mapstorage.readFromFile(filename)) |
274 { |
279 { |
275 mapstorage.file_name = filename; |
280 mapstorage.file_name = filename; |
276 mapstorage.modified = false; |
281 mapstorage.modified = false; |
277 gd_canvas->drawGraph(); |
282 gd_canvas->drawGraph(); |
278 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); |
283 if(mapwinexists) |
|
284 { |
|
285 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); |
|
286 } |
279 set_title(Glib::filename_display_basename(filename) + " - " + prog_name); |
287 set_title(Glib::filename_display_basename(filename) + " - " + prog_name); |
280 } |
288 } |
281 } |
289 } |
282 } |
290 } |
283 |
291 |
357 return mapstorage.getActiveNodeMap(prop); |
368 return mapstorage.getActiveNodeMap(prop); |
358 } |
369 } |
359 |
370 |
360 void MainWin::registerNewEdgeMap(std::string mapname) |
371 void MainWin::registerNewEdgeMap(std::string mapname) |
361 { |
372 { |
362 mapwin->registerNewEdgeMap(mapname); |
373 if(mapwinexists) |
|
374 { |
|
375 mapwin->registerNewEdgeMap(mapname); |
|
376 } |
363 } |
377 } |
364 |
378 |
365 void MainWin::registerNewNodeMap(std::string mapname) |
379 void MainWin::registerNewNodeMap(std::string mapname) |
366 { |
380 { |
367 mapwin->registerNewNodeMap(mapname); |
381 if(mapwinexists) |
368 } |
382 { |
|
383 mapwin->registerNewNodeMap(mapname); |
|
384 } |
|
385 } |
|
386 |
|
387 void MainWin::createMapWin() |
|
388 { |
|
389 if(!mapwinexists) |
|
390 { |
|
391 mapwin=new MapWin("Map Setup", mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this); |
|
392 mapwin->show(); |
|
393 mapwinexists=true; |
|
394 } |
|
395 } |
|
396 |
|
397 void MainWin::closeMapWin() |
|
398 { |
|
399 mapwinexists=false; |
|
400 delete mapwin; |
|
401 } |