gui/main_win.cc
changeset 1435 8e85e6bbefdf
parent 1412 c7fab5a1174a
child 1441 fd4b6f6d592a
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gui/main_win.cc	Mon May 23 04:48:14 2005 +0000
     1.3 @@ -0,0 +1,69 @@
     1.4 +#include <main_win.h>
     1.5 +
     1.6 +MainWin::MainWin(const std::string& title, Graph & graph, CoordinatesMap & cm, MapStorage & ms):mapwin("Map Setup", ms, gd_canvas),gd_canvas(graph, cm, ms)
     1.7 +{
     1.8 +  set_title (title);
     1.9 +  set_default_size(WIN_WIDTH,WIN_HEIGHT);
    1.10 +  add(vbox);
    1.11 +
    1.12 +  ag=Gtk::ActionGroup::create();
    1.13 +  ag->add( Gtk::Action::create("ShowMenu", "_Show") );
    1.14 +  ag->add( Gtk::Action::create("ShowMaps", "_Maps"), sigc::mem_fun(*this, &MainWin::showMaps));
    1.15 +  ag->add( Gtk::Action::create("FileMenu", "_File") );
    1.16 +  ag->add( Gtk::Action::create("FileQuit", "_Quit"), sigc::mem_fun(*this, &MainWin::quit));
    1.17 +  ag->add( Gtk::Action::create("ZoomMenu", "_Zoom") );
    1.18 +  ag->add( Gtk::Action::create("ZoomRezoom", "_Rezoom"), sigc::mem_fun(*this, &MainWin::rezoom)); //!!!!!!
    1.19 +
    1.20 +  uim=Gtk::UIManager::create();
    1.21 +  uim->insert_action_group(ag);
    1.22 +  add_accel_group(uim->get_accel_group());
    1.23 +
    1.24 +  try
    1.25 +  {
    1.26 +
    1.27 +    Glib::ustring ui_info =
    1.28 +      "<ui>"
    1.29 +      "  <menubar name='MenuBar'>"
    1.30 +      "    <menu action='FileMenu'>"
    1.31 +      "      <menuitem action='FileQuit'/>"
    1.32 +      "    </menu>"
    1.33 +      "    <menu action='ShowMenu'>"
    1.34 +      "      <menuitem action='ShowMaps'/>"
    1.35 +      "    </menu>"
    1.36 +      "    <menu action='ZoomMenu'>"
    1.37 +      "      <menuitem action='ZoomRezoom'/>"
    1.38 +      "    </menu>"
    1.39 +      "  </menubar>"
    1.40 +      "</ui>";
    1.41 +
    1.42 +    uim->add_ui_from_string(ui_info);
    1.43 +
    1.44 +  }
    1.45 +  catch(const Glib::Error& ex)
    1.46 +  {
    1.47 +    std::cerr << "building menus failed: " <<  ex.what();
    1.48 +  }
    1.49 +
    1.50 +  Gtk::Widget* menubar = uim->get_widget("/MenuBar");
    1.51 +  if(menubar)vbox.pack_start(*menubar, Gtk::PACK_SHRINK);
    1.52 +
    1.53 +  vbox.pack_start(gd_canvas);
    1.54 +
    1.55 +  show_all_children();
    1.56 +}
    1.57 +
    1.58 +void MainWin::showMaps()
    1.59 +{
    1.60 +  mapwin.show();
    1.61 +}
    1.62 +
    1.63 +void MainWin::quit()
    1.64 +{
    1.65 +  hide();
    1.66 +}
    1.67 +
    1.68 +void MainWin::rezoom()
    1.69 +{
    1.70 +  gd_canvas.rezoom();
    1.71 +}
    1.72 +