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