COIN-OR::LEMON - Graph Library

source: lemon-0.x/gui/main_win.cc @ 1592:4708b716d2f4

Last change on this file since 1592:4708b716d2f4 was 1592:4708b716d2f4, checked in by Hegyi Péter, 15 years ago

EdgeMap? and NodeMap? creation is done, at last. Bach 4ever.

File size: 5.9 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),editwin("Editorial Window", gd_canvas),newmapwin("Creating new map",gd_canvas),gd_canvas(graph, cm, ms, &mapwin)
5{
6  //Creating a window for setting new maps.
7//   newmapwin=new NewMapWi("Creating new map",*this);
8
9
10  set_title (title);
11  set_default_size(WIN_WIDTH,WIN_HEIGHT);
12  add(vbox);
13
14  ag=Gtk::ActionGroup::create();
15
16  ag->add( Gtk::Action::create("FileMenu", "_File") );
17  ag->add( Gtk::Action::create("FileNew", Gtk::Stock::NEW),
18      sigc::mem_fun(*this, &MainWin::newFile));
19  ag->add( Gtk::Action::create("FileOpen", Gtk::Stock::OPEN),
20      sigc::mem_fun(*this, &MainWin::openFile));
21  ag->add( Gtk::Action::create("FileSave", Gtk::Stock::SAVE),
22      sigc::mem_fun(*this, &MainWin::saveFile));
23  ag->add( Gtk::Action::create("FileSaveAs", Gtk::Stock::SAVE_AS),
24      sigc::mem_fun(*this, &MainWin::saveFileAs));
25  ag->add( Gtk::Action::create("FileQuit", Gtk::Stock::QUIT),
26      sigc::mem_fun(*this, &MainWin::quit));
27
28  ag->add( Gtk::Action::create("ViewMenu", "_View") );
29  ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN),
30      sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomIn));
31  ag->add( Gtk::Action::create("ViewZoomOut", Gtk::Stock::ZOOM_OUT),
32      sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomOut));
33  ag->add( Gtk::Action::create("ViewZoomFit", Gtk::Stock::ZOOM_FIT),
34      sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomFit));
35  ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100),
36      sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoom100));
37 
38  ag->add( Gtk::Action::create("ShowMenu", "_Show") );
39  ag->add( Gtk::Action::create("ShowMaps", "_Maps"),
40      sigc::mem_fun(*this, &MainWin::showMaps));
41  ag->add( Gtk::Action::create("ShowEditorials", "_Editorials"),
42      sigc::mem_fun(*this, &MainWin::showEditorials));
43
44  ag->add( Gtk::Action::create("CreateNode", Gtk::Stock::NO),
45      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 1) );
46  ag->add( Gtk::Action::create("CreateEdge", Gtk::Stock::REMOVE),
47      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 2) );
48  ag->add( Gtk::Action::create("EraseItem", Gtk::Stock::DELETE),
49      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 3) );
50  ag->add( Gtk::Action::create("MoveItem", Gtk::Stock::CONVERT),
51      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 0) );
52  ag->add( Gtk::Action::create("EditEdgeMap", Gtk::Stock::PROPERTIES),
53      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 4) );
54  ag->add( Gtk::Action::create("EditNodeMap", Gtk::Stock::PREFERENCES),
55      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 5) );
56  ag->add( Gtk::Action::create("AddMap", Gtk::Stock::NEW),
57      sigc::mem_fun ( this->newmapwin, &NewMapWin::show ) );
58
59  uim=Gtk::UIManager::create();
60  uim->insert_action_group(ag);
61  add_accel_group(uim->get_accel_group());
62
63  try
64  {
65
66    Glib::ustring ui_info =
67      "<ui>"
68      "  <menubar name='MenuBar'>"
69      "    <menu action='FileMenu'>"
70      "      <menuitem action='FileNew'/>"
71      "      <menuitem action='FileOpen'/>"
72      "      <menuitem action='FileSave'/>"
73      "      <menuitem action='FileSaveAs'/>"
74      "      <menuitem action='FileQuit'/>"
75      "    </menu>"
76      "    <menu action='ViewMenu'>"
77      "      <menuitem action='ViewZoomIn' />"
78      "      <menuitem action='ViewZoomOut' />"
79      "      <menuitem action='ViewZoomFit' />"
80      "      <menuitem action='ViewZoom100' />"
81      "    </menu>"
82      "    <menu action='ShowMenu'>"
83      "      <menuitem action='ShowMaps'/>"
84      "      <menuitem action='ShowEditorials'/>"
85      "    </menu>"
86      "  </menubar>"
87      "  <toolbar name='ToolBar'>"
88      "    <toolitem action='FileNew' />"
89      "    <toolitem action='FileOpen' />"
90      "    <toolitem action='FileSave' />"
91      "    <separator />"
92      "    <toolitem action='ViewZoomIn' />"
93      "    <toolitem action='ViewZoomOut' />"
94      "    <toolitem action='ViewZoomFit' />"
95      "    <toolitem action='ViewZoom100' />"
96      "    <separator />"
97      "    <toolitem action='CreateNode' />"
98      "    <toolitem action='CreateEdge' />"
99      "    <toolitem action='EraseItem' />"
100      "    <toolitem action='MoveItem' />"
101      "    <toolitem action='EditEdgeMap' />"
102      "    <toolitem action='EditNodeMap' />"
103      "    <toolitem action='AddMap' />"
104      "  </toolbar>"
105      "</ui>";
106
107    uim->add_ui_from_string(ui_info);
108
109  }
110  catch(const Glib::Error& ex)
111  {
112    std::cerr << "building menus failed: " <<  ex.what();
113  }
114
115  Gtk::Widget* menubar = uim->get_widget("/MenuBar");
116  if (menubar){
117    vbox.pack_start(*menubar, Gtk::PACK_SHRINK);
118  }
119
120  Gtk::Widget* toolbar = uim->get_widget("/ToolBar");
121  if (toolbar)
122  {
123    static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS);
124    vbox.pack_start(*toolbar, Gtk::PACK_SHRINK);
125  }
126
127  Gtk::ScrolledWindow* pScrolledWindow = manage(new Gtk::ScrolledWindow());
128  pScrolledWindow->add(gd_canvas);
129  vbox.pack_start(*pScrolledWindow);
130  //vbox.pack_start(gd_canvas);
131
132  show_all_children();
133}
134
135void MainWin::showMaps()
136{
137  mapwin.show();
138}
139
140void MainWin::showEditorials()
141{
142  editwin.show();
143}
144
145void MainWin::quit()
146{
147  hide();
148}
149
150void MainWin::newFile()
151{
152  std::cerr << "MainWin::newFile(): not yet implemented" << std::endl;
153}
154
155void MainWin::openFile()
156{
157  std::cerr << "MainWin::openFile(): not yet implemented" << std::endl;
158}
159
160void MainWin::saveFile()
161{
162  std::cerr << "MainWin::saveFile(): not yet implemented" << std::endl;
163}
164
165void MainWin::saveFileAs()
166{
167  std::cerr << "MainWin::saveFileAs(): not yet implemented" << std::endl;
168}
Note: See TracBrowser for help on using the repository browser.