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