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