COIN-OR::LEMON - Graph Library

source: lemon-0.x/gui/main_win.cc @ 1467:638124c0ef08

Last change on this file since 1467:638124c0ef08 was 1442:1e3c69aa035b, checked in by Akos Ladanyi, 19 years ago

dos2unix

File size: 4.0 KB
Line 
1#include <main_win.h>
2
3MainWin::MainWin(const std::string& title, Graph & graph, CoordinatesMap & cm,
4    MapStorage & ms):mapwin("Map Setup", ms, gd_canvas),gd_canvas(graph, cm, ms)
5{
6  set_title (title);
7  set_default_size(WIN_WIDTH,WIN_HEIGHT);
8  add(vbox);
9
10  ag=Gtk::ActionGroup::create();
11
12  ag->add( Gtk::Action::create("FileMenu", "_File") );
13  ag->add( Gtk::Action::create("FileNew", Gtk::Stock::NEW),
14      sigc::mem_fun(*this, &MainWin::newFile));
15  ag->add( Gtk::Action::create("FileOpen", Gtk::Stock::OPEN),
16      sigc::mem_fun(*this, &MainWin::openFile));
17  ag->add( Gtk::Action::create("FileSave", Gtk::Stock::SAVE),
18      sigc::mem_fun(*this, &MainWin::saveFile));
19  ag->add( Gtk::Action::create("FileSaveAs", Gtk::Stock::SAVE_AS),
20      sigc::mem_fun(*this, &MainWin::saveFileAs));
21  ag->add( Gtk::Action::create("FileQuit", Gtk::Stock::QUIT),
22      sigc::mem_fun(*this, &MainWin::quit));
23
24  ag->add( Gtk::Action::create("ViewMenu", "_View") );
25  ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN),
26      sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomIn));
27  ag->add( Gtk::Action::create("ViewZoomOut", Gtk::Stock::ZOOM_OUT),
28      sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomOut));
29  ag->add( Gtk::Action::create("ViewZoomFit", Gtk::Stock::ZOOM_FIT),
30      sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomFit));
31  ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100),
32      sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoom100));
33 
34  ag->add( Gtk::Action::create("ShowMenu", "_Show") );
35  ag->add( Gtk::Action::create("ShowMaps", "_Maps"),
36      sigc::mem_fun(*this, &MainWin::showMaps));
37
38  uim=Gtk::UIManager::create();
39  uim->insert_action_group(ag);
40  add_accel_group(uim->get_accel_group());
41
42  try
43  {
44
45    Glib::ustring ui_info =
46      "<ui>"
47      "  <menubar name='MenuBar'>"
48      "    <menu action='FileMenu'>"
49      "      <menuitem action='FileNew'/>"
50      "      <menuitem action='FileOpen'/>"
51      "      <menuitem action='FileSave'/>"
52      "      <menuitem action='FileSaveAs'/>"
53      "      <menuitem action='FileQuit'/>"
54      "    </menu>"
55      "    <menu action='ViewMenu'>"
56      "      <menuitem action='ViewZoomIn' />"
57      "      <menuitem action='ViewZoomOut' />"
58      "      <menuitem action='ViewZoomFit' />"
59      "      <menuitem action='ViewZoom100' />"
60      "    </menu>"
61      "    <menu action='ShowMenu'>"
62      "      <menuitem action='ShowMaps'/>"
63      "    </menu>"
64      "  </menubar>"
65      "  <toolbar name='ToolBar'>"
66      "    <toolitem action='FileNew' />"
67      "    <toolitem action='FileOpen' />"
68      "    <toolitem action='FileSave' />"
69      "    <separator />"
70      "    <toolitem action='ViewZoomIn' />"
71      "    <toolitem action='ViewZoomOut' />"
72      "    <toolitem action='ViewZoomFit' />"
73      "    <toolitem action='ViewZoom100' />"
74      "  </toolbar>"
75      "</ui>";
76
77    uim->add_ui_from_string(ui_info);
78
79  }
80  catch(const Glib::Error& ex)
81  {
82    std::cerr << "building menus failed: " <<  ex.what();
83  }
84
85  Gtk::Widget* menubar = uim->get_widget("/MenuBar");
86  if (menubar){
87    vbox.pack_start(*menubar, Gtk::PACK_SHRINK);
88  }
89
90  Gtk::Widget* toolbar = uim->get_widget("/ToolBar");
91  if (toolbar)
92  {
93    static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS);
94    vbox.pack_start(*toolbar, Gtk::PACK_SHRINK);
95  }
96
97  Gtk::ScrolledWindow* pScrolledWindow = manage(new Gtk::ScrolledWindow());
98  pScrolledWindow->add(gd_canvas);
99  vbox.pack_start(*pScrolledWindow);
100  //vbox.pack_start(gd_canvas);
101
102  show_all_children();
103}
104
105void MainWin::showMaps()
106{
107  mapwin.show();
108}
109
110void MainWin::quit()
111{
112  hide();
113}
114
115void MainWin::newFile()
116{
117  std::cerr << "MainWin::newFile(): not yet implemented" << std::endl;
118}
119
120void MainWin::openFile()
121{
122  std::cerr << "MainWin::openFile(): not yet implemented" << std::endl;
123}
124
125void MainWin::saveFile()
126{
127  std::cerr << "MainWin::saveFile(): not yet implemented" << std::endl;
128}
129
130void MainWin::saveFileAs()
131{
132  std::cerr << "MainWin::saveFileAs(): not yet implemented" << std::endl;
133}
Note: See TracBrowser for help on using the repository browser.