COIN-OR::LEMON - Graph Library

source: lemon-0.x/gui/main_win.cc @ 1601:70d169a8313a

Last change on this file since 1601:70d169a8313a was 1601:70d169a8313a, checked in by Hegyi Péter, 15 years ago

Tooltip should be turn up on CreateNode? tool.

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