gui/main_win.cc
author deba
Thu, 18 May 2006 08:04:51 +0000
changeset 2092 fc18c2b50a8f
parent 2012 224cd6aacfc1
permissions -rw-r--r--
Erasing unused parameter names
Omitting Warning
ladanyi@2012
     1
#ifdef HAVE_CONFIG_H
ladanyi@2012
     2
#include <config.h>
ladanyi@2012
     3
#endif
ladanyi@2012
     4
ladanyi@1606
     5
#include "main_win.h"
ladanyi@1862
     6
#include "guipixbufs.h"
ladanyi@1442
     7
ladanyi@2052
     8
#include "i18n.h"
ladanyi@2012
     9
hegyi@1849
    10
MainWin::MainWin()
ladanyi@1442
    11
{
hegyi@1849
    12
  set_title ("no file");
ladanyi@1442
    13
  set_default_size(WIN_WIDTH,WIN_HEIGHT);
ladanyi@1442
    14
  add(vbox);
ladanyi@1442
    15
ladanyi@1634
    16
  // custom icons for the toolbar
ladanyi@1634
    17
  Glib::RefPtr<Gtk::IconFactory> p_icon_factory = Gtk::IconFactory::create();
ladanyi@1634
    18
 
ladanyi@1635
    19
  Glib::RefPtr<Gdk::Pixbuf> p_move_pixbuf = Gdk::Pixbuf::create_from_inline(
ladanyi@1635
    20
      2328, gui_icons_move);
ladanyi@1635
    21
  Glib::RefPtr<Gdk::Pixbuf> p_addnode_pixbuf = Gdk::Pixbuf::create_from_inline(
ladanyi@1635
    22
      2328, gui_icons_addnode);
ladanyi@1635
    23
  Glib::RefPtr<Gdk::Pixbuf> p_addlink_pixbuf = Gdk::Pixbuf::create_from_inline(
ladanyi@1635
    24
      2328, gui_icons_addlink);
ladanyi@1635
    25
  Glib::RefPtr<Gdk::Pixbuf> p_delete_pixbuf = Gdk::Pixbuf::create_from_inline(
ladanyi@1635
    26
      2328, gui_icons_delete);
ladanyi@1635
    27
  Glib::RefPtr<Gdk::Pixbuf> p_editlink_pixbuf = Gdk::Pixbuf::create_from_inline(
ladanyi@1635
    28
      2328, gui_icons_editlink);
ladanyi@1635
    29
  Glib::RefPtr<Gdk::Pixbuf> p_editnode_pixbuf = Gdk::Pixbuf::create_from_inline(
ladanyi@1635
    30
      2328, gui_icons_editnode);
ladanyi@1635
    31
  Glib::RefPtr<Gdk::Pixbuf> p_newmap_pixbuf = Gdk::Pixbuf::create_from_inline(
ladanyi@1635
    32
      2328, gui_icons_newmap);
ladanyi@1634
    33
ladanyi@1634
    34
  Gtk::IconSource move_icon_source;
ladanyi@1635
    35
  move_icon_source.set_pixbuf(p_move_pixbuf);
ladanyi@1634
    36
  Gtk::IconSet move_icon_set;
ladanyi@1634
    37
  move_icon_set.add_source(move_icon_source);
ladanyi@1634
    38
  p_icon_factory->add(Gtk::StockID("gd-move"), move_icon_set);
ladanyi@1634
    39
ladanyi@1634
    40
  Gtk::IconSource addnode_icon_source;
ladanyi@1635
    41
  addnode_icon_source.set_pixbuf(p_addnode_pixbuf);
ladanyi@1634
    42
  Gtk::IconSet addnode_icon_set;
ladanyi@1634
    43
  addnode_icon_set.add_source(addnode_icon_source);
ladanyi@1634
    44
  p_icon_factory->add(Gtk::StockID("gd-addnode"), addnode_icon_set);
ladanyi@1634
    45
ladanyi@1634
    46
  Gtk::IconSource addlink_icon_source;
ladanyi@1635
    47
  addlink_icon_source.set_pixbuf(p_addlink_pixbuf);
ladanyi@1634
    48
  Gtk::IconSet addlink_icon_set;
ladanyi@1634
    49
  addlink_icon_set.add_source(addlink_icon_source);
ladanyi@1634
    50
  p_icon_factory->add(Gtk::StockID("gd-addlink"), addlink_icon_set);
ladanyi@1634
    51
ladanyi@1634
    52
  Gtk::IconSource delete_icon_source;
ladanyi@1635
    53
  delete_icon_source.set_pixbuf(p_delete_pixbuf);
ladanyi@1634
    54
  Gtk::IconSet delete_icon_set;
ladanyi@1634
    55
  delete_icon_set.add_source(delete_icon_source);
ladanyi@1634
    56
  p_icon_factory->add(Gtk::StockID("gd-delete"), delete_icon_set);
ladanyi@1634
    57
ladanyi@1634
    58
  Gtk::IconSource editlink_icon_source;
ladanyi@1635
    59
  editlink_icon_source.set_pixbuf(p_editlink_pixbuf);
ladanyi@1634
    60
  Gtk::IconSet editlink_icon_set;
ladanyi@1634
    61
  editlink_icon_set.add_source(editlink_icon_source);
ladanyi@1634
    62
  p_icon_factory->add(Gtk::StockID("gd-editlink"), editlink_icon_set);
ladanyi@1634
    63
ladanyi@1634
    64
  Gtk::IconSource editnode_icon_source;
ladanyi@1635
    65
  editnode_icon_source.set_pixbuf(p_editnode_pixbuf);
ladanyi@1634
    66
  Gtk::IconSet editnode_icon_set;
ladanyi@1634
    67
  editnode_icon_set.add_source(editnode_icon_source);
ladanyi@1634
    68
  p_icon_factory->add(Gtk::StockID("gd-editnode"), editnode_icon_set);
ladanyi@1634
    69
ladanyi@1634
    70
  Gtk::IconSource newmap_icon_source;
ladanyi@1635
    71
  newmap_icon_source.set_pixbuf(p_newmap_pixbuf);
ladanyi@1634
    72
  Gtk::IconSet newmap_icon_set;
ladanyi@1634
    73
  newmap_icon_set.add_source(newmap_icon_source);
ladanyi@1634
    74
  p_icon_factory->add(Gtk::StockID("gd-newmap"), newmap_icon_set);
ladanyi@1634
    75
ladanyi@1634
    76
  p_icon_factory->add_default();
ladanyi@1634
    77
  
ladanyi@1442
    78
  ag=Gtk::ActionGroup::create();
ladanyi@1442
    79
ladanyi@2012
    80
  ag->add( Gtk::Action::create("FileMenu", _("_File")) );
hegyi@1869
    81
  ag->add( Gtk::Action::create("FileNew", Gtk::Stock::NEW),
hegyi@1849
    82
      sigc::mem_fun(*this, &MainWin::newTab));
ladanyi@1442
    83
  ag->add( Gtk::Action::create("FileOpen", Gtk::Stock::OPEN),
ladanyi@1442
    84
      sigc::mem_fun(*this, &MainWin::openFile));
ladanyi@2012
    85
  ag->add( Gtk::Action::create("FileClearTab", _("Clear Tab")),
hegyi@1869
    86
      sigc::mem_fun(*this, &MainWin::newFile));
ladanyi@1442
    87
  ag->add( Gtk::Action::create("FileSave", Gtk::Stock::SAVE),
ladanyi@1442
    88
      sigc::mem_fun(*this, &MainWin::saveFile));
ladanyi@1442
    89
  ag->add( Gtk::Action::create("FileSaveAs", Gtk::Stock::SAVE_AS),
ladanyi@1442
    90
      sigc::mem_fun(*this, &MainWin::saveFileAs));
ladanyi@1606
    91
  ag->add( Gtk::Action::create("Close", Gtk::Stock::CLOSE),
hegyi@1869
    92
      sigc::mem_fun(*this, &MainWin::closeTab));
ladanyi@1606
    93
  ag->add( Gtk::Action::create("Quit", Gtk::Stock::QUIT),
hegyi@1598
    94
      sigc::mem_fun(*this, &MainWin::hide));
ladanyi@1442
    95
ladanyi@2012
    96
  ag->add( Gtk::Action::create("ViewMenu", _("_View")) );
ladanyi@1442
    97
  ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN),
hegyi@1849
    98
      sigc::mem_fun(*this, &MainWin::zoomIn));
ladanyi@1442
    99
  ag->add( Gtk::Action::create("ViewZoomOut", Gtk::Stock::ZOOM_OUT),
hegyi@1849
   100
      sigc::mem_fun(*this, &MainWin::zoomOut));
ladanyi@1442
   101
  ag->add( Gtk::Action::create("ViewZoomFit", Gtk::Stock::ZOOM_FIT),
hegyi@1849
   102
      sigc::mem_fun(*this, &MainWin::zoomFit));
ladanyi@1442
   103
  ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100),
hegyi@1849
   104
      sigc::mem_fun(*this, &MainWin::zoom100));
ladanyi@1442
   105
  
ladanyi@2012
   106
  ag->add( Gtk::Action::create("ShowMenu", _("_Show")) );
ladanyi@2012
   107
  ag->add( Gtk::Action::create("ShowMaps", _("_Maps")),
hegyi@1838
   108
	   sigc::mem_fun(*this, &MainWin::createMapWin));
ladanyi@1442
   109
ladanyi@2012
   110
  ag->add( Gtk::Action::create("AlgoMenu", _("_Algorithms")) );
ladanyi@2012
   111
  ag->add( Gtk::Action::create("AlgoGeneral", _("_General")),
hegyi@1871
   112
	   sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 0) );
ladanyi@2012
   113
  ag->add( Gtk::Action::create("AlgoKruskal", _("_Kruskal")),
hegyi@1876
   114
	   sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 1) );
hegyi@1871
   115
ladanyi@1606
   116
  Gtk::RadioAction::Group tool_group;
ladanyi@2012
   117
  ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), _("Move")),
hegyi@1849
   118
      sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 0) );
ladanyi@2012
   119
  ag->add( Gtk::RadioAction::create(tool_group, "CreateNode", Gtk::StockID("gd-addnode"), _("Create node")),
hegyi@1849
   120
      sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 1) );
ladanyi@2012
   121
  ag->add( Gtk::RadioAction::create(tool_group, "CreateEdge", Gtk::StockID("gd-addlink"), _("Create edge")),
hegyi@1849
   122
      sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 2) );
ladanyi@2012
   123
  ag->add( Gtk::RadioAction::create(tool_group, "EraseItem", Gtk::StockID("gd-delete"), _("Delete")),
hegyi@1849
   124
      sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 3) );
ladanyi@1634
   125
ladanyi@2012
   126
  ag->add( Gtk::RadioAction::create(tool_group, "EditEdgeMap", Gtk::StockID("gd-editlink"), _("Edit edge map")),
hegyi@1849
   127
      sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 4) );
ladanyi@2012
   128
  ag->add( Gtk::RadioAction::create(tool_group, "EditNodeMap", Gtk::StockID("gd-editnode"), _("Edit node map")),
hegyi@1849
   129
      sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 5) );
ladanyi@1634
   130
ladanyi@1634
   131
  ag->add( Gtk::Action::create("AddMap", Gtk::StockID("gd-newmap")),
hegyi@1849
   132
      sigc::mem_fun ( *this , &MainWin::createNewMapWin ) );
hegyi@1502
   133
ladanyi@1442
   134
  uim=Gtk::UIManager::create();
ladanyi@1442
   135
  uim->insert_action_group(ag);
ladanyi@1442
   136
  add_accel_group(uim->get_accel_group());
ladanyi@1442
   137
ladanyi@1442
   138
  try
ladanyi@1442
   139
  {
ladanyi@1442
   140
ladanyi@1442
   141
    Glib::ustring ui_info =
ladanyi@1442
   142
      "<ui>"
ladanyi@1442
   143
      "  <menubar name='MenuBar'>"
ladanyi@1442
   144
      "    <menu action='FileMenu'>"
ladanyi@1442
   145
      "      <menuitem action='FileNew'/>"
ladanyi@1442
   146
      "      <menuitem action='FileOpen'/>"
hegyi@1869
   147
      "      <menuitem action='FileClearTab'/>"
ladanyi@1442
   148
      "      <menuitem action='FileSave'/>"
ladanyi@1442
   149
      "      <menuitem action='FileSaveAs'/>"
ladanyi@1606
   150
      "      <menuitem action='Close'/>"
ladanyi@1606
   151
      "      <menuitem action='Quit'/>"
ladanyi@1442
   152
      "    </menu>"
ladanyi@1442
   153
      "    <menu action='ViewMenu'>"
ladanyi@1442
   154
      "      <menuitem action='ViewZoomIn' />"
ladanyi@1442
   155
      "      <menuitem action='ViewZoomOut' />"
ladanyi@1442
   156
      "      <menuitem action='ViewZoom100' />"
ladanyi@1777
   157
      "      <menuitem action='ViewZoomFit' />"
ladanyi@1442
   158
      "    </menu>"
ladanyi@1442
   159
      "    <menu action='ShowMenu'>"
ladanyi@1442
   160
      "      <menuitem action='ShowMaps'/>"
ladanyi@1442
   161
      "    </menu>"
hegyi@1871
   162
      "    <menu action='AlgoMenu'>"
hegyi@1871
   163
      "      <menuitem action='AlgoGeneral'/>"
hegyi@1876
   164
      "      <menuitem action='AlgoKruskal'/>"
hegyi@1871
   165
      "    </menu>"
ladanyi@1442
   166
      "  </menubar>"
ladanyi@1442
   167
      "  <toolbar name='ToolBar'>"
ladanyi@1442
   168
      "    <toolitem action='FileNew' />"
ladanyi@1442
   169
      "    <toolitem action='FileOpen' />"
ladanyi@1442
   170
      "    <toolitem action='FileSave' />"
ladanyi@1606
   171
      "    <toolitem action='Close' />"
ladanyi@1442
   172
      "    <separator />"
ladanyi@1442
   173
      "    <toolitem action='ViewZoomIn' />"
ladanyi@1442
   174
      "    <toolitem action='ViewZoomOut' />"
ladanyi@1442
   175
      "    <toolitem action='ViewZoom100' />"
ladanyi@1777
   176
      "    <toolitem action='ViewZoomFit' />"
hegyi@1502
   177
      "    <separator />"
ladanyi@1606
   178
      "    <toolitem action='MoveItem' />"
hegyi@1502
   179
      "    <toolitem action='CreateNode' />"
hegyi@1502
   180
      "    <toolitem action='CreateEdge' />"
hegyi@1502
   181
      "    <toolitem action='EraseItem' />"
hegyi@1550
   182
      "    <toolitem action='EditEdgeMap' />"
hegyi@1550
   183
      "    <toolitem action='EditNodeMap' />"
ladanyi@1634
   184
      "    <separator />"
hegyi@1592
   185
      "    <toolitem action='AddMap' />"
ladanyi@1442
   186
      "  </toolbar>"
ladanyi@1442
   187
      "</ui>";
ladanyi@1442
   188
ladanyi@1442
   189
    uim->add_ui_from_string(ui_info);
ladanyi@1442
   190
ladanyi@1442
   191
  }
ladanyi@1442
   192
  catch(const Glib::Error& ex)
ladanyi@1442
   193
  {
ladanyi@1442
   194
    std::cerr << "building menus failed: " <<  ex.what();
ladanyi@1442
   195
  }
ladanyi@1442
   196
ladanyi@1442
   197
  Gtk::Widget* menubar = uim->get_widget("/MenuBar");
ladanyi@1442
   198
  if (menubar){
ladanyi@1442
   199
    vbox.pack_start(*menubar, Gtk::PACK_SHRINK);
ladanyi@1442
   200
  }
ladanyi@1442
   201
ladanyi@1442
   202
  Gtk::Widget* toolbar = uim->get_widget("/ToolBar");
ladanyi@1442
   203
  if (toolbar)
ladanyi@1442
   204
  {
ladanyi@1442
   205
    static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS);
ladanyi@1442
   206
    vbox.pack_start(*toolbar, Gtk::PACK_SHRINK);
ladanyi@1442
   207
  }
ladanyi@1442
   208
hegyi@1601
   209
  tooltips.set_tip(*(uim->get_widget("/ToolBar/CreateNode")),"Create Node");
hegyi@1601
   210
  tooltips.enable();
ladanyi@1442
   211
hegyi@1849
   212
  active_tab=-1;
hegyi@1849
   213
  notebook.signal_switch_page().connect(sigc::mem_fun(*this, &MainWin::onChangeTab));
hegyi@1849
   214
ladanyi@1877
   215
  active_tool = MOVE;
ladanyi@1877
   216
hegyi@1849
   217
  vbox.pack_start(notebook);
hegyi@1849
   218
  
ladanyi@1442
   219
  show_all_children();
ladanyi@1442
   220
}
ladanyi@1442
   221
hegyi@1849
   222
void MainWin::set_tabtitle(std::string name)
ladanyi@1616
   223
{
hegyi@1872
   224
  if(strinst.find(name)==strinst.end())
hegyi@1872
   225
    {
hegyi@1872
   226
      tabnames[active_tab]=name;
hegyi@1872
   227
      strinst[name]=1;
hegyi@1872
   228
    }
hegyi@1872
   229
  else
hegyi@1872
   230
    {
hegyi@1872
   231
      strinst[name]++;
hegyi@1872
   232
      std::ostringstream o;
hegyi@1872
   233
      o << strinst[name];
hegyi@1872
   234
      tabnames[active_tab]=name+" - "+o.str();
hegyi@1872
   235
    }
hegyi@1849
   236
  set_title(tabnames[active_tab] + " - " + prog_name);
hegyi@1849
   237
  notebook.set_tab_label_text((Widget&)*(tabs[active_tab]), tabnames[active_tab]);
hegyi@1876
   238
  updateAlgoWinTabs();
hegyi@1849
   239
}
hegyi@1849
   240
hegyi@1849
   241
void MainWin::readFile(const std::string & filename)
hegyi@1849
   242
{
hegyi@1849
   243
  newTab();
hegyi@1849
   244
  tabs[active_tab]->readFile(filename);
hegyi@1849
   245
}
hegyi@1849
   246
hegyi@1849
   247
void MainWin::newTab()
hegyi@1849
   248
{
hegyi@1849
   249
  int size=tabs.size();
hegyi@1849
   250
  tabs.resize(size+1);
hegyi@1849
   251
  tabnames.resize(size+1);
hegyi@1849
   252
  active_tab=size;
hegyi@1849
   253
  tabs[active_tab]=new NoteBookTab();
hegyi@1849
   254
  tabs[active_tab]->signal_title_ch().connect(sigc::mem_fun(*this, &MainWin::set_tabtitle));
hegyi@1849
   255
  tabs[active_tab]->signal_newmap_needed().connect(sigc::mem_fun(*this, &MainWin::createNewMapWinAfterSignal));
hegyi@1849
   256
  tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool);
hegyi@1849
   257
  notebook.append_page((Gtk::Widget&)(*(tabs[active_tab])));
hegyi@1849
   258
  notebook.set_current_page(size);
ladanyi@2012
   259
  set_tabtitle(_("unsaved file"));
hegyi@1876
   260
  updateAlgoWinTabs();
hegyi@1849
   261
}
hegyi@1849
   262
hegyi@1856
   263
void MainWin::closeTab()
hegyi@1856
   264
{
hegyi@1856
   265
  if(active_tab!=-1)
hegyi@1856
   266
    {
hegyi@1869
   267
      if (tabs[active_tab]->mapstorage.modified)
hegyi@1869
   268
	{
ladanyi@2012
   269
	  Gtk::MessageDialog mdialog(_("<b>Save changes before closing?</b>"), true, 
hegyi@1869
   270
				     Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
ladanyi@2012
   271
	  mdialog.add_button(_("Close file _without Saving"), Gtk::RESPONSE_REJECT);
hegyi@1869
   272
	  mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
hegyi@1869
   273
	  mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
hegyi@1869
   274
	  switch (mdialog.run())
hegyi@1869
   275
	    {
hegyi@1869
   276
	    case Gtk::RESPONSE_CANCEL:
hegyi@1869
   277
	      return;
hegyi@1869
   278
	    case Gtk::RESPONSE_REJECT:
hegyi@1869
   279
	      break;
hegyi@1869
   280
	    case Gtk::RESPONSE_ACCEPT:
hegyi@1869
   281
	      tabs[active_tab]->saveFile();
hegyi@1869
   282
	      break;
hegyi@1869
   283
	    }
hegyi@1869
   284
	}
hegyi@1856
   285
      //tabs vector will be decreased with the deleted value
hegyi@1856
   286
      int size=tabs.size();
hegyi@1856
   287
      if(size>1)
hegyi@1856
   288
	{
hegyi@1856
   289
	  for(int i=active_tab+1;i<size;i++)
hegyi@1856
   290
	    {
hegyi@1871
   291
	      tabnames[i-1]=tabnames[i];
hegyi@1856
   292
	      tabs[i-1]=tabs[i];
hegyi@1856
   293
	    }
hegyi@1856
   294
	}
hegyi@1856
   295
      //if size==1 resize will delete the only element
hegyi@1856
   296
      tabs.resize(size-1);
hegyi@1871
   297
      tabnames.resize(size-1);
hegyi@1856
   298
hegyi@1856
   299
      int old_active_tab=active_tab;
hegyi@1856
   300
      notebook.remove_page(active_tab);
hegyi@1856
   301
hegyi@1856
   302
      //If the first tab was active, upon delete notebook
hegyi@1856
   303
      //will first switch one tab upper and not lower like
hegyi@1856
   304
      //in the case, when not the first tab was active.
hegyi@1856
   305
      //But after deletion it will become the first tab,
hegyi@1856
   306
      //and this should be registrated in tabs vector,
hegyi@1856
   307
      //as well.
hegyi@1871
   308
      if((old_active_tab==0)&&(size!=1))
hegyi@1856
   309
	{
hegyi@1856
   310
	  onChangeTab(NULL,0);
hegyi@1856
   311
	}
hegyi@1856
   312
hegyi@1856
   313
      //if this was the last page in notebook, there is
hegyi@1856
   314
      //no active_tab now
hegyi@1856
   315
      if(size==1)
hegyi@1856
   316
	{
hegyi@1856
   317
	  active_tab=-1;
hegyi@1856
   318
	}
hegyi@1871
   319
hegyi@1876
   320
      updateAlgoWinTabs();
hegyi@1856
   321
    }
hegyi@1856
   322
}
hegyi@1856
   323
hegyi@1849
   324
void MainWin::onChangeTab(GtkNotebookPage* page, guint page_num)
hegyi@1849
   325
{
hegyi@1849
   326
  page=page;
hegyi@1849
   327
  active_tab=page_num;
hegyi@1849
   328
  tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool);
hegyi@1849
   329
  set_title(tabnames[active_tab]);
hegyi@1849
   330
}
hegyi@1849
   331
ladanyi@1442
   332
void MainWin::newFile()
ladanyi@1442
   333
{
hegyi@1849
   334
  if(active_tab!=-1)
ladanyi@1606
   335
    {
hegyi@1849
   336
      tabs[active_tab]->newFile();
ladanyi@1606
   337
    }
ladanyi@1442
   338
}
hegyi@1849
   339
 
ladanyi@1442
   340
void MainWin::openFile()
ladanyi@1442
   341
{
hegyi@1849
   342
  if(active_tab!=-1)
ladanyi@1606
   343
    {
hegyi@1849
   344
      tabs[active_tab]->openFile();
ladanyi@1606
   345
    }
ladanyi@1442
   346
}
hegyi@1849
   347
 
ladanyi@1442
   348
void MainWin::saveFile()
ladanyi@1442
   349
{
hegyi@1849
   350
  if(active_tab!=-1)
hegyi@1849
   351
    {
hegyi@1849
   352
      tabs[active_tab]->saveFile();
hegyi@1849
   353
    }
ladanyi@1442
   354
}
hegyi@1849
   355
 
ladanyi@1442
   356
void MainWin::saveFileAs()
ladanyi@1442
   357
{
hegyi@1849
   358
  if(active_tab!=-1)
hegyi@1849
   359
    {
hegyi@1849
   360
      tabs[active_tab]->saveFileAs();
hegyi@1849
   361
    }
ladanyi@1442
   362
}
hegyi@1849
   363
 
ladanyi@1606
   364
void MainWin::close()
ladanyi@1606
   365
{
hegyi@1849
   366
  if(active_tab!=-1)
ladanyi@1606
   367
    {
hegyi@1849
   368
      tabs[active_tab]->close();
hegyi@1838
   369
    }
hegyi@1837
   370
}
hegyi@1837
   371
hegyi@1849
   372
void MainWin::zoomIn()
hegyi@1837
   373
{
hegyi@1849
   374
  if(active_tab!=-1)
hegyi@1838
   375
    {
hegyi@1849
   376
      tabs[active_tab]->gd_canvas->zoomIn();
hegyi@1849
   377
    }
hegyi@1849
   378
}
hegyi@1849
   379
hegyi@1849
   380
void MainWin::zoomOut()
hegyi@1849
   381
{
hegyi@1849
   382
  if(active_tab!=-1)
hegyi@1849
   383
    {
hegyi@1849
   384
      tabs[active_tab]->gd_canvas->zoomOut();
hegyi@1849
   385
    }
hegyi@1849
   386
}
hegyi@1849
   387
hegyi@1849
   388
void MainWin::zoomFit()
hegyi@1849
   389
{
hegyi@1849
   390
  if(active_tab!=-1)
hegyi@1849
   391
    {
hegyi@1849
   392
      tabs[active_tab]->gd_canvas->zoomFit();
hegyi@1849
   393
    }
hegyi@1849
   394
}
hegyi@1849
   395
hegyi@1849
   396
void MainWin::zoom100()
hegyi@1849
   397
{
hegyi@1849
   398
  if(active_tab!=-1)
hegyi@1849
   399
    {
hegyi@1849
   400
      tabs[active_tab]->gd_canvas->zoom100();
hegyi@1838
   401
    }
hegyi@1837
   402
}
hegyi@1838
   403
hegyi@1838
   404
void MainWin::createMapWin()
hegyi@1838
   405
{
hegyi@1849
   406
  if(active_tab!=-1)
hegyi@1838
   407
    {
hegyi@1849
   408
      tabs[active_tab]->createMapWin(tabnames[active_tab]);
hegyi@1838
   409
    }
hegyi@1838
   410
}
hegyi@1838
   411
hegyi@1871
   412
void MainWin::createAlgoWin(int algoid)
hegyi@1871
   413
{
hegyi@1878
   414
  AlgoWin * aw=new AlgoWin(algoid, tabnames);
hegyi@1871
   415
  aw->signal_closing().connect(sigc::mem_fun(*this, &MainWin::deRegisterAlgoWin));
hegyi@1876
   416
  aw->signal_maplist_needed().connect(sigc::mem_fun(*this, &MainWin::updateAlgoWinMaps));
hegyi@1884
   417
  aw->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MainWin::createNewMapWinTabString));
hegyi@1871
   418
  aws.insert(aw);
hegyi@1871
   419
  aw->show();
hegyi@1871
   420
}
hegyi@1871
   421
hegyi@1876
   422
void MainWin::updateAlgoWinTabs()
hegyi@1871
   423
{
hegyi@1871
   424
  std::set< AlgoWin* >::iterator awsi=aws.begin();
hegyi@1871
   425
  for(;awsi!=aws.end();awsi++)
hegyi@1871
   426
    {
hegyi@1871
   427
      (*awsi)->update_tablist(tabnames);
hegyi@1871
   428
    }
hegyi@1871
   429
}
hegyi@1871
   430
hegyi@1878
   431
void MainWin::updateAlgoWinMaps(AlgoWin * awp, std::string tabname)
hegyi@1878
   432
{
hegyi@1878
   433
  int i=0;
hegyi@1878
   434
  for(;(i<(int)tabnames.size())&&(tabnames[i]!=tabname);i++)
hegyi@1878
   435
    {
hegyi@1878
   436
    }
hegyi@1878
   437
  awp->update_maplist(&(tabs[i]->mapstorage));
hegyi@1878
   438
}
hegyi@1878
   439
hegyi@1878
   440
void MainWin::deRegisterAlgoWin(AlgoWin * awp)
hegyi@1878
   441
{
hegyi@1878
   442
  aws.erase(awp);
hegyi@1878
   443
}
hegyi@1878
   444
hegyi@1849
   445
void MainWin::changeEditorialTool(int tool)
hegyi@1838
   446
{
hegyi@1849
   447
  active_tool=tool;
hegyi@1849
   448
  if(active_tab!=-1)
hegyi@1849
   449
    {
hegyi@1849
   450
      tabs[active_tab]->gd_canvas->changeEditorialTool(tool);
hegyi@1849
   451
    }
hegyi@1838
   452
}
hegyi@1849
   453
hegyi@1849
   454
void MainWin::createNewMapWin()
hegyi@1849
   455
{
hegyi@1849
   456
  if(active_tab!=-1)
hegyi@1849
   457
    {
ladanyi@2012
   458
      NewMapWin * nmw=new NewMapWin(_("Create New Map - ")+tabnames[active_tab], *(tabs[active_tab]));
hegyi@1849
   459
      nmw->show();
hegyi@1849
   460
    }
hegyi@1849
   461
}
hegyi@1849
   462
hegyi@1884
   463
void MainWin::createNewMapWinTabString(std::string tabname, bool itisedge)
hegyi@1884
   464
{
hegyi@1884
   465
  int i=0;
hegyi@1890
   466
  for(;((i<(int)tabnames.size())&&(tabnames[i]!=tabname));i++)
hegyi@1884
   467
    {
hegyi@1884
   468
    }
hegyi@1884
   469
  createNewMapWinAfterSignal(tabs[i], itisedge);
hegyi@1884
   470
}
hegyi@1884
   471
hegyi@1849
   472
void MainWin::createNewMapWinAfterSignal(NoteBookTab * nbt, bool itisedge)
hegyi@1849
   473
{
hegyi@1849
   474
  std::vector<NoteBookTab*>::iterator nbti=tabs.begin();
hegyi@1849
   475
  int i=0;
hegyi@1849
   476
  for(;nbti!=tabs.end();nbti++)
hegyi@1849
   477
    {
hegyi@1849
   478
      if(*nbti!=nbt)
hegyi@1849
   479
	{
hegyi@1849
   480
	  i++;
hegyi@1849
   481
	}
hegyi@1849
   482
      else
hegyi@1849
   483
	{
hegyi@1849
   484
	  continue;
hegyi@1849
   485
	}
hegyi@1849
   486
    }
ladanyi@2012
   487
  NewMapWin * nmw=new NewMapWin(_("Create New Map - ")+tabnames[i], *nbt, itisedge, false);
hegyi@1849
   488
  nmw->run();
hegyi@1849
   489
}