ladanyi@1442: #include ladanyi@1442: ladanyi@1442: MainWin::MainWin(const std::string& title, Graph & graph, CoordinatesMap & cm, hegyi@1512: MapStorage & ms):mapwin("Map Setup", ms, gd_canvas),editwin("Editorial Window", gd_canvas),gd_canvas(graph, cm, ms, &mapwin) ladanyi@1442: { ladanyi@1442: set_title (title); ladanyi@1442: set_default_size(WIN_WIDTH,WIN_HEIGHT); ladanyi@1442: add(vbox); ladanyi@1442: ladanyi@1442: ag=Gtk::ActionGroup::create(); ladanyi@1442: ladanyi@1442: ag->add( Gtk::Action::create("FileMenu", "_File") ); ladanyi@1442: ag->add( Gtk::Action::create("FileNew", Gtk::Stock::NEW), ladanyi@1442: sigc::mem_fun(*this, &MainWin::newFile)); ladanyi@1442: ag->add( Gtk::Action::create("FileOpen", Gtk::Stock::OPEN), ladanyi@1442: sigc::mem_fun(*this, &MainWin::openFile)); ladanyi@1442: ag->add( Gtk::Action::create("FileSave", Gtk::Stock::SAVE), ladanyi@1442: sigc::mem_fun(*this, &MainWin::saveFile)); ladanyi@1442: ag->add( Gtk::Action::create("FileSaveAs", Gtk::Stock::SAVE_AS), ladanyi@1442: sigc::mem_fun(*this, &MainWin::saveFileAs)); ladanyi@1442: ag->add( Gtk::Action::create("FileQuit", Gtk::Stock::QUIT), ladanyi@1442: sigc::mem_fun(*this, &MainWin::quit)); ladanyi@1442: ladanyi@1442: ag->add( Gtk::Action::create("ViewMenu", "_View") ); ladanyi@1442: ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN), ladanyi@1442: sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomIn)); ladanyi@1442: ag->add( Gtk::Action::create("ViewZoomOut", Gtk::Stock::ZOOM_OUT), ladanyi@1442: sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomOut)); ladanyi@1442: ag->add( Gtk::Action::create("ViewZoomFit", Gtk::Stock::ZOOM_FIT), ladanyi@1442: sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomFit)); ladanyi@1442: ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100), ladanyi@1442: sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoom100)); ladanyi@1442: ladanyi@1442: ag->add( Gtk::Action::create("ShowMenu", "_Show") ); ladanyi@1442: ag->add( Gtk::Action::create("ShowMaps", "_Maps"), ladanyi@1442: sigc::mem_fun(*this, &MainWin::showMaps)); hegyi@1468: ag->add( Gtk::Action::create("ShowEditorials", "_Editorials"), hegyi@1468: sigc::mem_fun(*this, &MainWin::showEditorials)); ladanyi@1442: hegyi@1502: ag->add( Gtk::Action::create("CreateNode", Gtk::Stock::NO), hegyi@1502: sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 1) ); hegyi@1502: ag->add( Gtk::Action::create("CreateEdge", Gtk::Stock::REMOVE), hegyi@1502: sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 2) ); hegyi@1502: ag->add( Gtk::Action::create("EraseItem", Gtk::Stock::DELETE), hegyi@1502: sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 3) ); hegyi@1502: ag->add( Gtk::Action::create("MoveItem", Gtk::Stock::CONVERT), hegyi@1502: sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 0) ); hegyi@1550: ag->add( Gtk::Action::create("EditEdgeMap", Gtk::Stock::PROPERTIES), hegyi@1550: sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 4) ); hegyi@1550: ag->add( Gtk::Action::create("EditNodeMap", Gtk::Stock::PREFERENCES), hegyi@1550: sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 5) ); hegyi@1502: ladanyi@1442: uim=Gtk::UIManager::create(); ladanyi@1442: uim->insert_action_group(ag); ladanyi@1442: add_accel_group(uim->get_accel_group()); ladanyi@1442: ladanyi@1442: try ladanyi@1442: { ladanyi@1442: ladanyi@1442: Glib::ustring ui_info = ladanyi@1442: "" ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " hegyi@1468: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " ladanyi@1442: " " hegyi@1502: " " hegyi@1502: " " hegyi@1502: " " hegyi@1502: " " hegyi@1502: " " hegyi@1550: " " hegyi@1550: " " ladanyi@1442: " " ladanyi@1442: ""; ladanyi@1442: ladanyi@1442: uim->add_ui_from_string(ui_info); ladanyi@1442: ladanyi@1442: } ladanyi@1442: catch(const Glib::Error& ex) ladanyi@1442: { ladanyi@1442: std::cerr << "building menus failed: " << ex.what(); ladanyi@1442: } ladanyi@1442: ladanyi@1442: Gtk::Widget* menubar = uim->get_widget("/MenuBar"); ladanyi@1442: if (menubar){ ladanyi@1442: vbox.pack_start(*menubar, Gtk::PACK_SHRINK); ladanyi@1442: } ladanyi@1442: ladanyi@1442: Gtk::Widget* toolbar = uim->get_widget("/ToolBar"); ladanyi@1442: if (toolbar) ladanyi@1442: { ladanyi@1442: static_cast(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS); ladanyi@1442: vbox.pack_start(*toolbar, Gtk::PACK_SHRINK); ladanyi@1442: } ladanyi@1442: ladanyi@1442: Gtk::ScrolledWindow* pScrolledWindow = manage(new Gtk::ScrolledWindow()); ladanyi@1442: pScrolledWindow->add(gd_canvas); ladanyi@1442: vbox.pack_start(*pScrolledWindow); ladanyi@1442: //vbox.pack_start(gd_canvas); ladanyi@1442: ladanyi@1442: show_all_children(); ladanyi@1442: } ladanyi@1442: ladanyi@1442: void MainWin::showMaps() ladanyi@1442: { ladanyi@1442: mapwin.show(); ladanyi@1442: } ladanyi@1442: hegyi@1468: void MainWin::showEditorials() hegyi@1468: { hegyi@1468: editwin.show(); hegyi@1468: } hegyi@1468: ladanyi@1442: void MainWin::quit() ladanyi@1442: { ladanyi@1442: hide(); ladanyi@1442: } ladanyi@1442: ladanyi@1442: void MainWin::newFile() ladanyi@1442: { ladanyi@1442: std::cerr << "MainWin::newFile(): not yet implemented" << std::endl; ladanyi@1442: } ladanyi@1442: ladanyi@1442: void MainWin::openFile() ladanyi@1442: { ladanyi@1442: std::cerr << "MainWin::openFile(): not yet implemented" << std::endl; ladanyi@1442: } ladanyi@1442: ladanyi@1442: void MainWin::saveFile() ladanyi@1442: { ladanyi@1442: std::cerr << "MainWin::saveFile(): not yet implemented" << std::endl; ladanyi@1442: } ladanyi@1442: ladanyi@1442: void MainWin::saveFileAs() ladanyi@1442: { ladanyi@1442: std::cerr << "MainWin::saveFileAs(): not yet implemented" << std::endl; ladanyi@1442: }