1.1 --- a/gui/main_win.cc Wed Jun 01 23:30:13 2005 +0000
1.2 +++ b/gui/main_win.cc Wed Jun 01 23:33:26 2005 +0000
1.3 @@ -1,133 +1,133 @@
1.4 -#include <main_win.h>
1.5 -
1.6 -MainWin::MainWin(const std::string& title, Graph & graph, CoordinatesMap & cm,
1.7 - MapStorage & ms):mapwin("Map Setup", ms, gd_canvas),gd_canvas(graph, cm, ms)
1.8 -{
1.9 - set_title (title);
1.10 - set_default_size(WIN_WIDTH,WIN_HEIGHT);
1.11 - add(vbox);
1.12 -
1.13 - ag=Gtk::ActionGroup::create();
1.14 -
1.15 - ag->add( Gtk::Action::create("FileMenu", "_File") );
1.16 - ag->add( Gtk::Action::create("FileNew", Gtk::Stock::NEW),
1.17 - sigc::mem_fun(*this, &MainWin::newFile));
1.18 - ag->add( Gtk::Action::create("FileOpen", Gtk::Stock::OPEN),
1.19 - sigc::mem_fun(*this, &MainWin::openFile));
1.20 - ag->add( Gtk::Action::create("FileSave", Gtk::Stock::SAVE),
1.21 - sigc::mem_fun(*this, &MainWin::saveFile));
1.22 - ag->add( Gtk::Action::create("FileSaveAs", Gtk::Stock::SAVE_AS),
1.23 - sigc::mem_fun(*this, &MainWin::saveFileAs));
1.24 - ag->add( Gtk::Action::create("FileQuit", Gtk::Stock::QUIT),
1.25 - sigc::mem_fun(*this, &MainWin::quit));
1.26 -
1.27 - ag->add( Gtk::Action::create("ViewMenu", "_View") );
1.28 - ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN),
1.29 - sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomIn));
1.30 - ag->add( Gtk::Action::create("ViewZoomOut", Gtk::Stock::ZOOM_OUT),
1.31 - sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomOut));
1.32 - ag->add( Gtk::Action::create("ViewZoomFit", Gtk::Stock::ZOOM_FIT),
1.33 - sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomFit));
1.34 - ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100),
1.35 - sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoom100));
1.36 -
1.37 - ag->add( Gtk::Action::create("ShowMenu", "_Show") );
1.38 - ag->add( Gtk::Action::create("ShowMaps", "_Maps"),
1.39 - sigc::mem_fun(*this, &MainWin::showMaps));
1.40 -
1.41 - uim=Gtk::UIManager::create();
1.42 - uim->insert_action_group(ag);
1.43 - add_accel_group(uim->get_accel_group());
1.44 -
1.45 - try
1.46 - {
1.47 -
1.48 - Glib::ustring ui_info =
1.49 - "<ui>"
1.50 - " <menubar name='MenuBar'>"
1.51 - " <menu action='FileMenu'>"
1.52 - " <menuitem action='FileNew'/>"
1.53 - " <menuitem action='FileOpen'/>"
1.54 - " <menuitem action='FileSave'/>"
1.55 - " <menuitem action='FileSaveAs'/>"
1.56 - " <menuitem action='FileQuit'/>"
1.57 - " </menu>"
1.58 - " <menu action='ViewMenu'>"
1.59 - " <menuitem action='ViewZoomIn' />"
1.60 - " <menuitem action='ViewZoomOut' />"
1.61 - " <menuitem action='ViewZoomFit' />"
1.62 - " <menuitem action='ViewZoom100' />"
1.63 - " </menu>"
1.64 - " <menu action='ShowMenu'>"
1.65 - " <menuitem action='ShowMaps'/>"
1.66 - " </menu>"
1.67 - " </menubar>"
1.68 - " <toolbar name='ToolBar'>"
1.69 - " <toolitem action='FileNew' />"
1.70 - " <toolitem action='FileOpen' />"
1.71 - " <toolitem action='FileSave' />"
1.72 - " <separator />"
1.73 - " <toolitem action='ViewZoomIn' />"
1.74 - " <toolitem action='ViewZoomOut' />"
1.75 - " <toolitem action='ViewZoomFit' />"
1.76 - " <toolitem action='ViewZoom100' />"
1.77 - " </toolbar>"
1.78 - "</ui>";
1.79 -
1.80 - uim->add_ui_from_string(ui_info);
1.81 -
1.82 - }
1.83 - catch(const Glib::Error& ex)
1.84 - {
1.85 - std::cerr << "building menus failed: " << ex.what();
1.86 - }
1.87 -
1.88 - Gtk::Widget* menubar = uim->get_widget("/MenuBar");
1.89 - if (menubar){
1.90 - vbox.pack_start(*menubar, Gtk::PACK_SHRINK);
1.91 - }
1.92 -
1.93 - Gtk::Widget* toolbar = uim->get_widget("/ToolBar");
1.94 - if (toolbar)
1.95 - {
1.96 - static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS);
1.97 - vbox.pack_start(*toolbar, Gtk::PACK_SHRINK);
1.98 - }
1.99 -
1.100 - Gtk::ScrolledWindow* pScrolledWindow = manage(new Gtk::ScrolledWindow());
1.101 - pScrolledWindow->add(gd_canvas);
1.102 - vbox.pack_start(*pScrolledWindow);
1.103 - //vbox.pack_start(gd_canvas);
1.104 -
1.105 - show_all_children();
1.106 -}
1.107 -
1.108 -void MainWin::showMaps()
1.109 -{
1.110 - mapwin.show();
1.111 -}
1.112 -
1.113 -void MainWin::quit()
1.114 -{
1.115 - hide();
1.116 -}
1.117 -
1.118 -void MainWin::newFile()
1.119 -{
1.120 - std::cerr << "MainWin::newFile(): not yet implemented" << std::endl;
1.121 -}
1.122 -
1.123 -void MainWin::openFile()
1.124 -{
1.125 - std::cerr << "MainWin::openFile(): not yet implemented" << std::endl;
1.126 -}
1.127 -
1.128 -void MainWin::saveFile()
1.129 -{
1.130 - std::cerr << "MainWin::saveFile(): not yet implemented" << std::endl;
1.131 -}
1.132 -
1.133 -void MainWin::saveFileAs()
1.134 -{
1.135 - std::cerr << "MainWin::saveFileAs(): not yet implemented" << std::endl;
1.136 -}
1.137 +#include <main_win.h>
1.138 +
1.139 +MainWin::MainWin(const std::string& title, Graph & graph, CoordinatesMap & cm,
1.140 + MapStorage & ms):mapwin("Map Setup", ms, gd_canvas),gd_canvas(graph, cm, ms)
1.141 +{
1.142 + set_title (title);
1.143 + set_default_size(WIN_WIDTH,WIN_HEIGHT);
1.144 + add(vbox);
1.145 +
1.146 + ag=Gtk::ActionGroup::create();
1.147 +
1.148 + ag->add( Gtk::Action::create("FileMenu", "_File") );
1.149 + ag->add( Gtk::Action::create("FileNew", Gtk::Stock::NEW),
1.150 + sigc::mem_fun(*this, &MainWin::newFile));
1.151 + ag->add( Gtk::Action::create("FileOpen", Gtk::Stock::OPEN),
1.152 + sigc::mem_fun(*this, &MainWin::openFile));
1.153 + ag->add( Gtk::Action::create("FileSave", Gtk::Stock::SAVE),
1.154 + sigc::mem_fun(*this, &MainWin::saveFile));
1.155 + ag->add( Gtk::Action::create("FileSaveAs", Gtk::Stock::SAVE_AS),
1.156 + sigc::mem_fun(*this, &MainWin::saveFileAs));
1.157 + ag->add( Gtk::Action::create("FileQuit", Gtk::Stock::QUIT),
1.158 + sigc::mem_fun(*this, &MainWin::quit));
1.159 +
1.160 + ag->add( Gtk::Action::create("ViewMenu", "_View") );
1.161 + ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN),
1.162 + sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomIn));
1.163 + ag->add( Gtk::Action::create("ViewZoomOut", Gtk::Stock::ZOOM_OUT),
1.164 + sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomOut));
1.165 + ag->add( Gtk::Action::create("ViewZoomFit", Gtk::Stock::ZOOM_FIT),
1.166 + sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomFit));
1.167 + ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100),
1.168 + sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoom100));
1.169 +
1.170 + ag->add( Gtk::Action::create("ShowMenu", "_Show") );
1.171 + ag->add( Gtk::Action::create("ShowMaps", "_Maps"),
1.172 + sigc::mem_fun(*this, &MainWin::showMaps));
1.173 +
1.174 + uim=Gtk::UIManager::create();
1.175 + uim->insert_action_group(ag);
1.176 + add_accel_group(uim->get_accel_group());
1.177 +
1.178 + try
1.179 + {
1.180 +
1.181 + Glib::ustring ui_info =
1.182 + "<ui>"
1.183 + " <menubar name='MenuBar'>"
1.184 + " <menu action='FileMenu'>"
1.185 + " <menuitem action='FileNew'/>"
1.186 + " <menuitem action='FileOpen'/>"
1.187 + " <menuitem action='FileSave'/>"
1.188 + " <menuitem action='FileSaveAs'/>"
1.189 + " <menuitem action='FileQuit'/>"
1.190 + " </menu>"
1.191 + " <menu action='ViewMenu'>"
1.192 + " <menuitem action='ViewZoomIn' />"
1.193 + " <menuitem action='ViewZoomOut' />"
1.194 + " <menuitem action='ViewZoomFit' />"
1.195 + " <menuitem action='ViewZoom100' />"
1.196 + " </menu>"
1.197 + " <menu action='ShowMenu'>"
1.198 + " <menuitem action='ShowMaps'/>"
1.199 + " </menu>"
1.200 + " </menubar>"
1.201 + " <toolbar name='ToolBar'>"
1.202 + " <toolitem action='FileNew' />"
1.203 + " <toolitem action='FileOpen' />"
1.204 + " <toolitem action='FileSave' />"
1.205 + " <separator />"
1.206 + " <toolitem action='ViewZoomIn' />"
1.207 + " <toolitem action='ViewZoomOut' />"
1.208 + " <toolitem action='ViewZoomFit' />"
1.209 + " <toolitem action='ViewZoom100' />"
1.210 + " </toolbar>"
1.211 + "</ui>";
1.212 +
1.213 + uim->add_ui_from_string(ui_info);
1.214 +
1.215 + }
1.216 + catch(const Glib::Error& ex)
1.217 + {
1.218 + std::cerr << "building menus failed: " << ex.what();
1.219 + }
1.220 +
1.221 + Gtk::Widget* menubar = uim->get_widget("/MenuBar");
1.222 + if (menubar){
1.223 + vbox.pack_start(*menubar, Gtk::PACK_SHRINK);
1.224 + }
1.225 +
1.226 + Gtk::Widget* toolbar = uim->get_widget("/ToolBar");
1.227 + if (toolbar)
1.228 + {
1.229 + static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS);
1.230 + vbox.pack_start(*toolbar, Gtk::PACK_SHRINK);
1.231 + }
1.232 +
1.233 + Gtk::ScrolledWindow* pScrolledWindow = manage(new Gtk::ScrolledWindow());
1.234 + pScrolledWindow->add(gd_canvas);
1.235 + vbox.pack_start(*pScrolledWindow);
1.236 + //vbox.pack_start(gd_canvas);
1.237 +
1.238 + show_all_children();
1.239 +}
1.240 +
1.241 +void MainWin::showMaps()
1.242 +{
1.243 + mapwin.show();
1.244 +}
1.245 +
1.246 +void MainWin::quit()
1.247 +{
1.248 + hide();
1.249 +}
1.250 +
1.251 +void MainWin::newFile()
1.252 +{
1.253 + std::cerr << "MainWin::newFile(): not yet implemented" << std::endl;
1.254 +}
1.255 +
1.256 +void MainWin::openFile()
1.257 +{
1.258 + std::cerr << "MainWin::openFile(): not yet implemented" << std::endl;
1.259 +}
1.260 +
1.261 +void MainWin::saveFile()
1.262 +{
1.263 + std::cerr << "MainWin::saveFile(): not yet implemented" << std::endl;
1.264 +}
1.265 +
1.266 +void MainWin::saveFileAs()
1.267 +{
1.268 + std::cerr << "MainWin::saveFileAs(): not yet implemented" << std::endl;
1.269 +}