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