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