98 sigc::mem_fun(*this, &MainWin::zoom100)); |
98 sigc::mem_fun(*this, &MainWin::zoom100)); |
99 |
99 |
100 ag->add( Gtk::Action::create("ShowMenu", "_Show") ); |
100 ag->add( Gtk::Action::create("ShowMenu", "_Show") ); |
101 ag->add( Gtk::Action::create("ShowMaps", "_Maps"), |
101 ag->add( Gtk::Action::create("ShowMaps", "_Maps"), |
102 sigc::mem_fun(*this, &MainWin::createMapWin)); |
102 sigc::mem_fun(*this, &MainWin::createMapWin)); |
|
103 |
|
104 ag->add( Gtk::Action::create("AlgoMenu", "_Algorithms") ); |
|
105 ag->add( Gtk::Action::create("AlgoGeneral", "_General"), |
|
106 sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 0) ); |
103 |
107 |
104 Gtk::RadioAction::Group tool_group; |
108 Gtk::RadioAction::Group tool_group; |
105 ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), "Move"), |
109 ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), "Move"), |
106 sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 0) ); |
110 sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 0) ); |
107 ag->add( Gtk::RadioAction::create(tool_group, "CreateNode", Gtk::StockID("gd-addnode"), "Create node"), |
111 ag->add( Gtk::RadioAction::create(tool_group, "CreateNode", Gtk::StockID("gd-addnode"), "Create node"), |
144 " <menuitem action='ViewZoom100' />" |
148 " <menuitem action='ViewZoom100' />" |
145 " <menuitem action='ViewZoomFit' />" |
149 " <menuitem action='ViewZoomFit' />" |
146 " </menu>" |
150 " </menu>" |
147 " <menu action='ShowMenu'>" |
151 " <menu action='ShowMenu'>" |
148 " <menuitem action='ShowMaps'/>" |
152 " <menuitem action='ShowMaps'/>" |
|
153 " </menu>" |
|
154 " <menu action='AlgoMenu'>" |
|
155 " <menuitem action='AlgoGeneral'/>" |
149 " </menu>" |
156 " </menu>" |
150 " </menubar>" |
157 " </menubar>" |
151 " <toolbar name='ToolBar'>" |
158 " <toolbar name='ToolBar'>" |
152 " <toolitem action='FileNew' />" |
159 " <toolitem action='FileNew' />" |
153 " <toolitem action='FileOpen' />" |
160 " <toolitem action='FileOpen' />" |
204 void MainWin::set_tabtitle(std::string name) |
211 void MainWin::set_tabtitle(std::string name) |
205 { |
212 { |
206 tabnames[active_tab]=name; |
213 tabnames[active_tab]=name; |
207 set_title(tabnames[active_tab] + " - " + prog_name); |
214 set_title(tabnames[active_tab] + " - " + prog_name); |
208 notebook.set_tab_label_text((Widget&)*(tabs[active_tab]), tabnames[active_tab]); |
215 notebook.set_tab_label_text((Widget&)*(tabs[active_tab]), tabnames[active_tab]); |
|
216 updateAlgoWins(); |
209 } |
217 } |
210 |
218 |
211 void MainWin::readFile(const std::string & filename) |
219 void MainWin::readFile(const std::string & filename) |
212 { |
220 { |
213 newTab(); |
221 newTab(); |
226 tabs[active_tab]->signal_newmap_needed().connect(sigc::mem_fun(*this, &MainWin::createNewMapWinAfterSignal)); |
234 tabs[active_tab]->signal_newmap_needed().connect(sigc::mem_fun(*this, &MainWin::createNewMapWinAfterSignal)); |
227 tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool); |
235 tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool); |
228 notebook.append_page((Gtk::Widget&)(*(tabs[active_tab]))); |
236 notebook.append_page((Gtk::Widget&)(*(tabs[active_tab]))); |
229 notebook.set_current_page(size); |
237 notebook.set_current_page(size); |
230 set_tabtitle(tabnames[active_tab]); |
238 set_tabtitle(tabnames[active_tab]); |
|
239 updateAlgoWins(); |
231 } |
240 } |
232 |
241 |
233 void MainWin::closeTab() |
242 void MainWin::closeTab() |
234 { |
243 { |
235 if(active_tab!=-1) |
244 if(active_tab!=-1) |
256 int size=tabs.size(); |
265 int size=tabs.size(); |
257 if(size>1) |
266 if(size>1) |
258 { |
267 { |
259 for(int i=active_tab+1;i<size;i++) |
268 for(int i=active_tab+1;i<size;i++) |
260 { |
269 { |
|
270 tabnames[i-1]=tabnames[i]; |
261 tabs[i-1]=tabs[i]; |
271 tabs[i-1]=tabs[i]; |
262 } |
272 } |
263 } |
273 } |
264 |
|
265 //if size==1 resize will delete the only element |
274 //if size==1 resize will delete the only element |
266 tabs.resize(size-1); |
275 tabs.resize(size-1); |
|
276 tabnames.resize(size-1); |
267 |
277 |
268 int old_active_tab=active_tab; |
278 int old_active_tab=active_tab; |
269 notebook.remove_page(active_tab); |
279 notebook.remove_page(active_tab); |
270 |
280 |
271 //If the first tab was active, upon delete notebook |
281 //If the first tab was active, upon delete notebook |
272 //will first switch one tab upper and not lower like |
282 //will first switch one tab upper and not lower like |
273 //in the case, when not the first tab was active. |
283 //in the case, when not the first tab was active. |
274 //But after deletion it will become the first tab, |
284 //But after deletion it will become the first tab, |
275 //and this should be registrated in tabs vector, |
285 //and this should be registrated in tabs vector, |
276 //as well. |
286 //as well. |
277 if(old_active_tab==0) |
287 if((old_active_tab==0)&&(size!=1)) |
278 { |
288 { |
279 onChangeTab(NULL,0); |
289 onChangeTab(NULL,0); |
280 } |
290 } |
|
291 |
|
292 std::cout << "NAAAA" << std::endl; |
281 |
293 |
282 //if this was the last page in notebook, there is |
294 //if this was the last page in notebook, there is |
283 //no active_tab now |
295 //no active_tab now |
284 if(size==1) |
296 if(size==1) |
285 { |
297 { |
286 active_tab=-1; |
298 active_tab=-1; |
287 } |
299 } |
|
300 |
|
301 updateAlgoWins(); |
288 } |
302 } |
289 } |
303 } |
290 |
304 |
291 void MainWin::onChangeTab(GtkNotebookPage* page, guint page_num) |
305 void MainWin::onChangeTab(GtkNotebookPage* page, guint page_num) |
292 { |
306 { |
378 { |
392 { |
379 tabs[active_tab]->createMapWin(tabnames[active_tab]); |
393 tabs[active_tab]->createMapWin(tabnames[active_tab]); |
380 } |
394 } |
381 } |
395 } |
382 |
396 |
|
397 void MainWin::createAlgoWin(int algoid) |
|
398 { |
|
399 AlgoWin * aw=new AlgoWin(algoid, tabnames); |
|
400 aw->signal_closing().connect(sigc::mem_fun(*this, &MainWin::deRegisterAlgoWin)); |
|
401 aws.insert(aw); |
|
402 aw->show(); |
|
403 } |
|
404 |
|
405 void MainWin::deRegisterAlgoWin(AlgoWin * awp) |
|
406 { |
|
407 aws.erase(awp); |
|
408 } |
|
409 |
|
410 void MainWin::updateAlgoWins() |
|
411 { |
|
412 std::set< AlgoWin* >::iterator awsi=aws.begin(); |
|
413 for(;awsi!=aws.end();awsi++) |
|
414 { |
|
415 (*awsi)->update_tablist(tabnames); |
|
416 } |
|
417 } |
|
418 |
383 void MainWin::changeEditorialTool(int tool) |
419 void MainWin::changeEditorialTool(int tool) |
384 { |
420 { |
385 active_tool=tool; |
421 active_tool=tool; |
386 if(active_tab!=-1) |
422 if(active_tab!=-1) |
387 { |
423 { |