gui/main_win.cc
author hegyi
Thu, 28 Jul 2005 14:31:32 +0000
changeset 1598 739df601808d
parent 1592 4708b716d2f4
child 1601 70d169a8313a
permissions -rw-r--r--
Redundant functions from main_win disappeared, entry is now bigger, properties refresh upon edition, edgewidth is zoomable.
ladanyi@1442
     1
#include <main_win.h>
ladanyi@1442
     2
ladanyi@1442
     3
MainWin::MainWin(const std::string& title, Graph & graph, CoordinatesMap & cm,
hegyi@1598
     4
    MapStorage & ms):mapwin("Map Setup", ms, gd_canvas),newmapwin("Creating new map",gd_canvas),gd_canvas(graph, cm, ms, &mapwin)
ladanyi@1442
     5
{
hegyi@1592
     6
ladanyi@1442
     7
  set_title (title);
ladanyi@1442
     8
  set_default_size(WIN_WIDTH,WIN_HEIGHT);
ladanyi@1442
     9
  add(vbox);
ladanyi@1442
    10
ladanyi@1442
    11
  ag=Gtk::ActionGroup::create();
ladanyi@1442
    12
ladanyi@1442
    13
  ag->add( Gtk::Action::create("FileMenu", "_File") );
ladanyi@1442
    14
  ag->add( Gtk::Action::create("FileNew", Gtk::Stock::NEW),
ladanyi@1442
    15
      sigc::mem_fun(*this, &MainWin::newFile));
ladanyi@1442
    16
  ag->add( Gtk::Action::create("FileOpen", Gtk::Stock::OPEN),
ladanyi@1442
    17
      sigc::mem_fun(*this, &MainWin::openFile));
ladanyi@1442
    18
  ag->add( Gtk::Action::create("FileSave", Gtk::Stock::SAVE),
ladanyi@1442
    19
      sigc::mem_fun(*this, &MainWin::saveFile));
ladanyi@1442
    20
  ag->add( Gtk::Action::create("FileSaveAs", Gtk::Stock::SAVE_AS),
ladanyi@1442
    21
      sigc::mem_fun(*this, &MainWin::saveFileAs));
ladanyi@1442
    22
  ag->add( Gtk::Action::create("FileQuit", Gtk::Stock::QUIT),
hegyi@1598
    23
      sigc::mem_fun(*this, &MainWin::hide));
ladanyi@1442
    24
ladanyi@1442
    25
  ag->add( Gtk::Action::create("ViewMenu", "_View") );
ladanyi@1442
    26
  ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN),
ladanyi@1442
    27
      sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomIn));
ladanyi@1442
    28
  ag->add( Gtk::Action::create("ViewZoomOut", Gtk::Stock::ZOOM_OUT),
ladanyi@1442
    29
      sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomOut));
ladanyi@1442
    30
  ag->add( Gtk::Action::create("ViewZoomFit", Gtk::Stock::ZOOM_FIT),
ladanyi@1442
    31
      sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomFit));
ladanyi@1442
    32
  ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100),
ladanyi@1442
    33
      sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoom100));
ladanyi@1442
    34
  
ladanyi@1442
    35
  ag->add( Gtk::Action::create("ShowMenu", "_Show") );
ladanyi@1442
    36
  ag->add( Gtk::Action::create("ShowMaps", "_Maps"),
hegyi@1598
    37
      sigc::mem_fun(this->mapwin, &MapWin::show));
ladanyi@1442
    38
hegyi@1502
    39
  ag->add( Gtk::Action::create("CreateNode", Gtk::Stock::NO),
hegyi@1502
    40
      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 1) );
hegyi@1502
    41
  ag->add( Gtk::Action::create("CreateEdge", Gtk::Stock::REMOVE),
hegyi@1502
    42
      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 2) );
hegyi@1502
    43
  ag->add( Gtk::Action::create("EraseItem", Gtk::Stock::DELETE),
hegyi@1502
    44
      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 3) );
hegyi@1502
    45
  ag->add( Gtk::Action::create("MoveItem", Gtk::Stock::CONVERT),
hegyi@1502
    46
      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 0) );
hegyi@1550
    47
  ag->add( Gtk::Action::create("EditEdgeMap", Gtk::Stock::PROPERTIES),
hegyi@1550
    48
      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 4) );
hegyi@1550
    49
  ag->add( Gtk::Action::create("EditNodeMap", Gtk::Stock::PREFERENCES),
hegyi@1550
    50
      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 5) );
hegyi@1592
    51
  ag->add( Gtk::Action::create("AddMap", Gtk::Stock::NEW),
hegyi@1592
    52
      sigc::mem_fun ( this->newmapwin, &NewMapWin::show ) );
hegyi@1502
    53
ladanyi@1442
    54
  uim=Gtk::UIManager::create();
ladanyi@1442
    55
  uim->insert_action_group(ag);
ladanyi@1442
    56
  add_accel_group(uim->get_accel_group());
ladanyi@1442
    57
ladanyi@1442
    58
  try
ladanyi@1442
    59
  {
ladanyi@1442
    60
ladanyi@1442
    61
    Glib::ustring ui_info =
ladanyi@1442
    62
      "<ui>"
ladanyi@1442
    63
      "  <menubar name='MenuBar'>"
ladanyi@1442
    64
      "    <menu action='FileMenu'>"
ladanyi@1442
    65
      "      <menuitem action='FileNew'/>"
ladanyi@1442
    66
      "      <menuitem action='FileOpen'/>"
ladanyi@1442
    67
      "      <menuitem action='FileSave'/>"
ladanyi@1442
    68
      "      <menuitem action='FileSaveAs'/>"
ladanyi@1442
    69
      "      <menuitem action='FileQuit'/>"
ladanyi@1442
    70
      "    </menu>"
ladanyi@1442
    71
      "    <menu action='ViewMenu'>"
ladanyi@1442
    72
      "      <menuitem action='ViewZoomIn' />"
ladanyi@1442
    73
      "      <menuitem action='ViewZoomOut' />"
ladanyi@1442
    74
      "      <menuitem action='ViewZoomFit' />"
ladanyi@1442
    75
      "      <menuitem action='ViewZoom100' />"
ladanyi@1442
    76
      "    </menu>"
ladanyi@1442
    77
      "    <menu action='ShowMenu'>"
ladanyi@1442
    78
      "      <menuitem action='ShowMaps'/>"
ladanyi@1442
    79
      "    </menu>"
ladanyi@1442
    80
      "  </menubar>"
ladanyi@1442
    81
      "  <toolbar name='ToolBar'>"
ladanyi@1442
    82
      "    <toolitem action='FileNew' />"
ladanyi@1442
    83
      "    <toolitem action='FileOpen' />"
ladanyi@1442
    84
      "    <toolitem action='FileSave' />"
ladanyi@1442
    85
      "    <separator />"
ladanyi@1442
    86
      "    <toolitem action='ViewZoomIn' />"
ladanyi@1442
    87
      "    <toolitem action='ViewZoomOut' />"
ladanyi@1442
    88
      "    <toolitem action='ViewZoomFit' />"
ladanyi@1442
    89
      "    <toolitem action='ViewZoom100' />"
hegyi@1502
    90
      "    <separator />"
hegyi@1502
    91
      "    <toolitem action='CreateNode' />"
hegyi@1502
    92
      "    <toolitem action='CreateEdge' />"
hegyi@1502
    93
      "    <toolitem action='EraseItem' />"
hegyi@1502
    94
      "    <toolitem action='MoveItem' />"
hegyi@1550
    95
      "    <toolitem action='EditEdgeMap' />"
hegyi@1550
    96
      "    <toolitem action='EditNodeMap' />"
hegyi@1592
    97
      "    <toolitem action='AddMap' />"
ladanyi@1442
    98
      "  </toolbar>"
ladanyi@1442
    99
      "</ui>";
ladanyi@1442
   100
ladanyi@1442
   101
    uim->add_ui_from_string(ui_info);
ladanyi@1442
   102
ladanyi@1442
   103
  }
ladanyi@1442
   104
  catch(const Glib::Error& ex)
ladanyi@1442
   105
  {
ladanyi@1442
   106
    std::cerr << "building menus failed: " <<  ex.what();
ladanyi@1442
   107
  }
ladanyi@1442
   108
ladanyi@1442
   109
  Gtk::Widget* menubar = uim->get_widget("/MenuBar");
ladanyi@1442
   110
  if (menubar){
ladanyi@1442
   111
    vbox.pack_start(*menubar, Gtk::PACK_SHRINK);
ladanyi@1442
   112
  }
ladanyi@1442
   113
ladanyi@1442
   114
  Gtk::Widget* toolbar = uim->get_widget("/ToolBar");
ladanyi@1442
   115
  if (toolbar)
ladanyi@1442
   116
  {
ladanyi@1442
   117
    static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS);
ladanyi@1442
   118
    vbox.pack_start(*toolbar, Gtk::PACK_SHRINK);
ladanyi@1442
   119
  }
ladanyi@1442
   120
ladanyi@1442
   121
  Gtk::ScrolledWindow* pScrolledWindow = manage(new Gtk::ScrolledWindow());
ladanyi@1442
   122
  pScrolledWindow->add(gd_canvas);
ladanyi@1442
   123
  vbox.pack_start(*pScrolledWindow);
ladanyi@1442
   124
  //vbox.pack_start(gd_canvas);
ladanyi@1442
   125
ladanyi@1442
   126
  show_all_children();
ladanyi@1442
   127
}
ladanyi@1442
   128
ladanyi@1442
   129
void MainWin::newFile()
ladanyi@1442
   130
{
ladanyi@1442
   131
  std::cerr << "MainWin::newFile(): not yet implemented" << std::endl;
ladanyi@1442
   132
}
ladanyi@1442
   133
ladanyi@1442
   134
void MainWin::openFile()
ladanyi@1442
   135
{
ladanyi@1442
   136
  std::cerr << "MainWin::openFile(): not yet implemented" << std::endl;
ladanyi@1442
   137
}
ladanyi@1442
   138
ladanyi@1442
   139
void MainWin::saveFile()
ladanyi@1442
   140
{
ladanyi@1442
   141
  std::cerr << "MainWin::saveFile(): not yet implemented" << std::endl;
ladanyi@1442
   142
}
ladanyi@1442
   143
ladanyi@1442
   144
void MainWin::saveFileAs()
ladanyi@1442
   145
{
ladanyi@1442
   146
  std::cerr << "MainWin::saveFileAs(): not yet implemented" << std::endl;
ladanyi@1442
   147
}