gui/main_win.cc
author ladanyi
Mon, 23 May 2005 04:48:14 +0000
changeset 1435 8e85e6bbefdf
parent 1412 src/gui/main_win.cc@c7fab5a1174a
child 1441 fd4b6f6d592a
permissions -rw-r--r--
trunk/src/* move to trunk/
     1 #include <main_win.h>
     2 
     3 MainWin::MainWin(const std::string& title, Graph & graph, CoordinatesMap & cm, MapStorage & ms):mapwin("Map Setup", ms, gd_canvas),gd_canvas(graph, cm, ms)
     4 {
     5   set_title (title);
     6   set_default_size(WIN_WIDTH,WIN_HEIGHT);
     7   add(vbox);
     8 
     9   ag=Gtk::ActionGroup::create();
    10   ag->add( Gtk::Action::create("ShowMenu", "_Show") );
    11   ag->add( Gtk::Action::create("ShowMaps", "_Maps"), sigc::mem_fun(*this, &MainWin::showMaps));
    12   ag->add( Gtk::Action::create("FileMenu", "_File") );
    13   ag->add( Gtk::Action::create("FileQuit", "_Quit"), sigc::mem_fun(*this, &MainWin::quit));
    14   ag->add( Gtk::Action::create("ZoomMenu", "_Zoom") );
    15   ag->add( Gtk::Action::create("ZoomRezoom", "_Rezoom"), sigc::mem_fun(*this, &MainWin::rezoom)); //!!!!!!
    16 
    17   uim=Gtk::UIManager::create();
    18   uim->insert_action_group(ag);
    19   add_accel_group(uim->get_accel_group());
    20 
    21   try
    22   {
    23 
    24     Glib::ustring ui_info =
    25       "<ui>"
    26       "  <menubar name='MenuBar'>"
    27       "    <menu action='FileMenu'>"
    28       "      <menuitem action='FileQuit'/>"
    29       "    </menu>"
    30       "    <menu action='ShowMenu'>"
    31       "      <menuitem action='ShowMaps'/>"
    32       "    </menu>"
    33       "    <menu action='ZoomMenu'>"
    34       "      <menuitem action='ZoomRezoom'/>"
    35       "    </menu>"
    36       "  </menubar>"
    37       "</ui>";
    38 
    39     uim->add_ui_from_string(ui_info);
    40 
    41   }
    42   catch(const Glib::Error& ex)
    43   {
    44     std::cerr << "building menus failed: " <<  ex.what();
    45   }
    46 
    47   Gtk::Widget* menubar = uim->get_widget("/MenuBar");
    48   if(menubar)vbox.pack_start(*menubar, Gtk::PACK_SHRINK);
    49 
    50   vbox.pack_start(gd_canvas);
    51 
    52   show_all_children();
    53 }
    54 
    55 void MainWin::showMaps()
    56 {
    57   mapwin.show();
    58 }
    59 
    60 void MainWin::quit()
    61 {
    62   hide();
    63 }
    64 
    65 void MainWin::rezoom()
    66 {
    67   gd_canvas.rezoom();
    68 }
    69