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