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