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