gui/main_win.cc
author deba
Thu, 01 Dec 2005 15:08:46 +0000
changeset 1842 8abf74160dc4
parent 1837 8dd6160ff699
child 1849 a4d1362397fe
permissions -rw-r--r--
NewEdgeSetAdaptor -> ListEdgeSet
and moved to edge_set.h
ladanyi@1606
     1
#include "main_win.h"
alpar@1659
     2
#include "icons/guipixbufs.h"
ladanyi@1442
     3
hegyi@1838
     4
MainWin::MainWin():mapwinexists(false)
ladanyi@1442
     5
{
hegyi@1837
     6
  gd_canvas=new GraphDisplayerCanvas(*this);
hegyi@1837
     7
ladanyi@1650
     8
  set_title ("unsaved file - " + prog_name);
ladanyi@1442
     9
  set_default_size(WIN_WIDTH,WIN_HEIGHT);
ladanyi@1442
    10
  add(vbox);
ladanyi@1442
    11
hegyi@1837
    12
  //connecting signals - controller character
hegyi@1837
    13
  mapstorage.signal_prop_ch().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::propertyChange));
ladanyi@1634
    14
ladanyi@1634
    15
  // custom icons for the toolbar
ladanyi@1634
    16
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@1634
    78
ladanyi@1442
    79
  ag=Gtk::ActionGroup::create();
ladanyi@1442
    80
ladanyi@1442
    81
  ag->add( Gtk::Action::create("FileMenu", "_File") );
ladanyi@1442
    82
  ag->add( Gtk::Action::create("FileNew", Gtk::Stock::NEW),
ladanyi@1442
    83
      sigc::mem_fun(*this, &MainWin::newFile));
ladanyi@1442
    84
  ag->add( Gtk::Action::create("FileOpen", Gtk::Stock::OPEN),
ladanyi@1442
    85
      sigc::mem_fun(*this, &MainWin::openFile));
ladanyi@1442
    86
  ag->add( Gtk::Action::create("FileSave", Gtk::Stock::SAVE),
ladanyi@1442
    87
      sigc::mem_fun(*this, &MainWin::saveFile));
ladanyi@1442
    88
  ag->add( Gtk::Action::create("FileSaveAs", Gtk::Stock::SAVE_AS),
ladanyi@1442
    89
      sigc::mem_fun(*this, &MainWin::saveFileAs));
ladanyi@1606
    90
  ag->add( Gtk::Action::create("Close", Gtk::Stock::CLOSE),
ladanyi@1606
    91
      sigc::mem_fun(*this, &MainWin::close));
ladanyi@1606
    92
  ag->add( Gtk::Action::create("Quit", Gtk::Stock::QUIT),
hegyi@1598
    93
      sigc::mem_fun(*this, &MainWin::hide));
ladanyi@1442
    94
ladanyi@1442
    95
  ag->add( Gtk::Action::create("ViewMenu", "_View") );
ladanyi@1442
    96
  ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN),
hegyi@1837
    97
      sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoomIn));
ladanyi@1442
    98
  ag->add( Gtk::Action::create("ViewZoomOut", Gtk::Stock::ZOOM_OUT),
hegyi@1837
    99
      sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoomOut));
ladanyi@1442
   100
  ag->add( Gtk::Action::create("ViewZoomFit", Gtk::Stock::ZOOM_FIT),
hegyi@1837
   101
      sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoomFit));
ladanyi@1442
   102
  ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100),
hegyi@1837
   103
      sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoom100));
ladanyi@1442
   104
  
ladanyi@1442
   105
  ag->add( Gtk::Action::create("ShowMenu", "_Show") );
ladanyi@1442
   106
  ag->add( Gtk::Action::create("ShowMaps", "_Maps"),
hegyi@1838
   107
	   sigc::mem_fun(*this, &MainWin::createMapWin));
ladanyi@1442
   108
ladanyi@1606
   109
  Gtk::RadioAction::Group tool_group;
ladanyi@1634
   110
  ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), "Move"),
hegyi@1837
   111
      sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 0) );
ladanyi@1634
   112
  ag->add( Gtk::RadioAction::create(tool_group, "CreateNode", Gtk::StockID("gd-addnode"), "Create node"),
hegyi@1837
   113
      sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 1) );
ladanyi@1634
   114
  ag->add( Gtk::RadioAction::create(tool_group, "CreateEdge", Gtk::StockID("gd-addlink"), "Create edge"),
hegyi@1837
   115
      sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 2) );
ladanyi@1634
   116
  ag->add( Gtk::RadioAction::create(tool_group, "EraseItem", Gtk::StockID("gd-delete"), "Delete"),
hegyi@1837
   117
      sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 3) );
ladanyi@1634
   118
ladanyi@1634
   119
  ag->add( Gtk::RadioAction::create(tool_group, "EditEdgeMap", Gtk::StockID("gd-editlink"), "Edit edge map"),
hegyi@1837
   120
      sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 4) );
ladanyi@1634
   121
  ag->add( Gtk::RadioAction::create(tool_group, "EditNodeMap", Gtk::StockID("gd-editnode"), "Edit node map"),
hegyi@1837
   122
      sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 5) );
ladanyi@1634
   123
ladanyi@1634
   124
  ag->add( Gtk::Action::create("AddMap", Gtk::StockID("gd-newmap")),
hegyi@1837
   125
      sigc::mem_fun (new NewMapWin("NewMapWin", *this), &NewMapWin::show ) );
hegyi@1502
   126
ladanyi@1442
   127
  uim=Gtk::UIManager::create();
ladanyi@1442
   128
  uim->insert_action_group(ag);
ladanyi@1442
   129
  add_accel_group(uim->get_accel_group());
ladanyi@1442
   130
ladanyi@1442
   131
  try
ladanyi@1442
   132
  {
ladanyi@1442
   133
ladanyi@1442
   134
    Glib::ustring ui_info =
ladanyi@1442
   135
      "<ui>"
ladanyi@1442
   136
      "  <menubar name='MenuBar'>"
ladanyi@1442
   137
      "    <menu action='FileMenu'>"
ladanyi@1442
   138
      "      <menuitem action='FileNew'/>"
ladanyi@1442
   139
      "      <menuitem action='FileOpen'/>"
ladanyi@1442
   140
      "      <menuitem action='FileSave'/>"
ladanyi@1442
   141
      "      <menuitem action='FileSaveAs'/>"
ladanyi@1606
   142
      "      <menuitem action='Close'/>"
ladanyi@1606
   143
      "      <menuitem action='Quit'/>"
ladanyi@1442
   144
      "    </menu>"
ladanyi@1442
   145
      "    <menu action='ViewMenu'>"
ladanyi@1442
   146
      "      <menuitem action='ViewZoomIn' />"
ladanyi@1442
   147
      "      <menuitem action='ViewZoomOut' />"
ladanyi@1442
   148
      "      <menuitem action='ViewZoom100' />"
ladanyi@1777
   149
      "      <menuitem action='ViewZoomFit' />"
ladanyi@1442
   150
      "    </menu>"
ladanyi@1442
   151
      "    <menu action='ShowMenu'>"
ladanyi@1442
   152
      "      <menuitem action='ShowMaps'/>"
ladanyi@1442
   153
      "    </menu>"
ladanyi@1442
   154
      "  </menubar>"
ladanyi@1442
   155
      "  <toolbar name='ToolBar'>"
ladanyi@1442
   156
      "    <toolitem action='FileNew' />"
ladanyi@1442
   157
      "    <toolitem action='FileOpen' />"
ladanyi@1442
   158
      "    <toolitem action='FileSave' />"
ladanyi@1606
   159
      "    <toolitem action='Close' />"
ladanyi@1442
   160
      "    <separator />"
ladanyi@1442
   161
      "    <toolitem action='ViewZoomIn' />"
ladanyi@1442
   162
      "    <toolitem action='ViewZoomOut' />"
ladanyi@1442
   163
      "    <toolitem action='ViewZoom100' />"
ladanyi@1777
   164
      "    <toolitem action='ViewZoomFit' />"
hegyi@1502
   165
      "    <separator />"
ladanyi@1606
   166
      "    <toolitem action='MoveItem' />"
hegyi@1502
   167
      "    <toolitem action='CreateNode' />"
hegyi@1502
   168
      "    <toolitem action='CreateEdge' />"
hegyi@1502
   169
      "    <toolitem action='EraseItem' />"
hegyi@1550
   170
      "    <toolitem action='EditEdgeMap' />"
hegyi@1550
   171
      "    <toolitem action='EditNodeMap' />"
ladanyi@1634
   172
      "    <separator />"
hegyi@1592
   173
      "    <toolitem action='AddMap' />"
ladanyi@1442
   174
      "  </toolbar>"
ladanyi@1442
   175
      "</ui>";
ladanyi@1442
   176
ladanyi@1442
   177
    uim->add_ui_from_string(ui_info);
ladanyi@1442
   178
ladanyi@1442
   179
  }
ladanyi@1442
   180
  catch(const Glib::Error& ex)
ladanyi@1442
   181
  {
ladanyi@1442
   182
    std::cerr << "building menus failed: " <<  ex.what();
ladanyi@1442
   183
  }
ladanyi@1442
   184
ladanyi@1442
   185
  Gtk::Widget* menubar = uim->get_widget("/MenuBar");
ladanyi@1442
   186
  if (menubar){
ladanyi@1442
   187
    vbox.pack_start(*menubar, Gtk::PACK_SHRINK);
ladanyi@1442
   188
  }
ladanyi@1442
   189
ladanyi@1442
   190
  Gtk::Widget* toolbar = uim->get_widget("/ToolBar");
ladanyi@1442
   191
  if (toolbar)
ladanyi@1442
   192
  {
ladanyi@1442
   193
    static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS);
ladanyi@1442
   194
    vbox.pack_start(*toolbar, Gtk::PACK_SHRINK);
ladanyi@1442
   195
  }
ladanyi@1442
   196
ladanyi@1442
   197
  Gtk::ScrolledWindow* pScrolledWindow = manage(new Gtk::ScrolledWindow());
ladanyi@1777
   198
  pScrolledWindow->set_shadow_type(Gtk::SHADOW_IN);
hegyi@1837
   199
  pScrolledWindow->add(*gd_canvas);
ladanyi@1442
   200
  vbox.pack_start(*pScrolledWindow);
hegyi@1601
   201
hegyi@1601
   202
  tooltips.set_tip(*(uim->get_widget("/ToolBar/CreateNode")),"Create Node");
hegyi@1601
   203
  tooltips.enable();
ladanyi@1442
   204
ladanyi@1442
   205
  show_all_children();
ladanyi@1442
   206
}
ladanyi@1442
   207
ladanyi@1616
   208
void MainWin::readFile(const std::string &file)
ladanyi@1616
   209
{
ladanyi@1616
   210
  mapstorage.readFromFile(file);
ladanyi@1616
   211
  mapstorage.file_name = file;
ladanyi@1616
   212
  mapstorage.modified = false;
hegyi@1837
   213
  gd_canvas->drawGraph();
hegyi@1838
   214
  if(mapwinexists)
hegyi@1838
   215
    {
hegyi@1838
   216
      mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
hegyi@1838
   217
    }
ladanyi@1650
   218
  set_title(Glib::filename_display_basename(file) + " - " + prog_name);
ladanyi@1616
   219
}
ladanyi@1616
   220
ladanyi@1442
   221
void MainWin::newFile()
ladanyi@1442
   222
{
ladanyi@1606
   223
  if (mapstorage.modified)
ladanyi@1606
   224
  {
ladanyi@1615
   225
    Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
ladanyi@1615
   226
        Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
ladanyi@1606
   227
    mdialog.add_button("Close _without Saving", Gtk::RESPONSE_REJECT);
ladanyi@1606
   228
    mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
ladanyi@1606
   229
    mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
ladanyi@1606
   230
    switch (mdialog.run())
ladanyi@1606
   231
    {
ladanyi@1606
   232
      case Gtk::RESPONSE_CANCEL:
ladanyi@1606
   233
        return;
ladanyi@1606
   234
      case Gtk::RESPONSE_REJECT:
ladanyi@1606
   235
        break;
ladanyi@1606
   236
      case Gtk::RESPONSE_ACCEPT:
ladanyi@1606
   237
        saveFile();
ladanyi@1606
   238
        break;
ladanyi@1606
   239
    }
ladanyi@1606
   240
  }
hegyi@1837
   241
  gd_canvas->clear();
ladanyi@1606
   242
  mapstorage.clear();
hegyi@1838
   243
  if(mapwinexists)
hegyi@1838
   244
    {
hegyi@1838
   245
      mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
hegyi@1838
   246
    }
ladanyi@1650
   247
  set_title("unsaved file - " + prog_name);
ladanyi@1442
   248
}
ladanyi@1442
   249
ladanyi@1442
   250
void MainWin::openFile()
ladanyi@1442
   251
{
ladanyi@1606
   252
  if (mapstorage.modified)
ladanyi@1606
   253
  {
ladanyi@1615
   254
    Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true, 
ladanyi@1615
   255
        Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
ladanyi@1606
   256
    mdialog.add_button("Close _without Saving", Gtk::RESPONSE_REJECT);
ladanyi@1606
   257
    mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
ladanyi@1606
   258
    mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
ladanyi@1606
   259
    switch (mdialog.run())
ladanyi@1606
   260
    {
ladanyi@1606
   261
      case Gtk::RESPONSE_CANCEL:
ladanyi@1606
   262
        return;
ladanyi@1606
   263
      case Gtk::RESPONSE_REJECT:
ladanyi@1606
   264
        break;
ladanyi@1606
   265
      case Gtk::RESPONSE_ACCEPT:
ladanyi@1606
   266
        saveFile();
ladanyi@1606
   267
        break;
ladanyi@1606
   268
    }
ladanyi@1606
   269
  }
ladanyi@1606
   270
  Gtk::FileChooserDialog fcdialog("Open File");
ladanyi@1606
   271
  fcdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
ladanyi@1606
   272
  fcdialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT);
ladanyi@1606
   273
  if (fcdialog.run() == Gtk::RESPONSE_ACCEPT)
ladanyi@1606
   274
  {
hegyi@1837
   275
    gd_canvas->clear();
ladanyi@1650
   276
    mapstorage.clear();
ladanyi@1606
   277
    Glib::ustring filename = fcdialog.get_filename();
ladanyi@1645
   278
    if (!mapstorage.readFromFile(filename))
ladanyi@1645
   279
    {
ladanyi@1645
   280
      mapstorage.file_name = filename;
ladanyi@1645
   281
      mapstorage.modified = false;
hegyi@1837
   282
      gd_canvas->drawGraph();
hegyi@1838
   283
      if(mapwinexists)
hegyi@1838
   284
	{
hegyi@1838
   285
	  mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
hegyi@1838
   286
	}
ladanyi@1650
   287
      set_title(Glib::filename_display_basename(filename) + " - " + prog_name);
ladanyi@1645
   288
    }
ladanyi@1606
   289
  }
ladanyi@1442
   290
}
ladanyi@1442
   291
ladanyi@1442
   292
void MainWin::saveFile()
ladanyi@1442
   293
{
ladanyi@1606
   294
  if (mapstorage.file_name == "") {
ladanyi@1606
   295
    saveFileAs();
ladanyi@1606
   296
  }
ladanyi@1606
   297
  else
ladanyi@1606
   298
  {
ladanyi@1606
   299
    mapstorage.writeToFile(mapstorage.file_name);
ladanyi@1606
   300
    mapstorage.modified = false;
ladanyi@1650
   301
    set_title(Glib::filename_display_basename(mapstorage.file_name) + " - " +
ladanyi@1650
   302
        prog_name);
ladanyi@1606
   303
  }
ladanyi@1442
   304
}
ladanyi@1442
   305
ladanyi@1442
   306
void MainWin::saveFileAs()
ladanyi@1442
   307
{
ladanyi@1606
   308
  Gtk::FileChooserDialog fcdialog("Save File", Gtk::FILE_CHOOSER_ACTION_SAVE);
ladanyi@1606
   309
  fcdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
ladanyi@1606
   310
  fcdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
ladanyi@1606
   311
  if (fcdialog.run() == Gtk::RESPONSE_ACCEPT)
ladanyi@1606
   312
  {
ladanyi@1606
   313
    Glib::ustring filename = fcdialog.get_filename();
ladanyi@1606
   314
    mapstorage.file_name = filename;
ladanyi@1606
   315
    mapstorage.writeToFile(filename);
ladanyi@1606
   316
    mapstorage.modified = false;
ladanyi@1650
   317
    set_title(Glib::filename_display_basename(filename) + " - " + prog_name);
ladanyi@1606
   318
  }
ladanyi@1442
   319
}
ladanyi@1606
   320
ladanyi@1606
   321
void MainWin::close()
ladanyi@1606
   322
{
ladanyi@1606
   323
  if (mapstorage.modified)
ladanyi@1606
   324
  {
ladanyi@1615
   325
    Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
ladanyi@1615
   326
        Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
ladanyi@1606
   327
    mdialog.add_button("Close _without Saving", Gtk::RESPONSE_REJECT);
ladanyi@1606
   328
    mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
ladanyi@1606
   329
    mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
ladanyi@1606
   330
    switch (mdialog.run())
ladanyi@1606
   331
    {
ladanyi@1606
   332
      case Gtk::RESPONSE_CANCEL:
ladanyi@1606
   333
        return;
ladanyi@1606
   334
      case Gtk::RESPONSE_REJECT:
ladanyi@1606
   335
        break;
ladanyi@1606
   336
      case Gtk::RESPONSE_ACCEPT:
ladanyi@1606
   337
        saveFile();
ladanyi@1606
   338
        break;
ladanyi@1606
   339
    }
ladanyi@1606
   340
  }
hegyi@1837
   341
  gd_canvas->clear();
ladanyi@1606
   342
  mapstorage.clear();
hegyi@1838
   343
  if(mapwinexists)
hegyi@1838
   344
    {
hegyi@1838
   345
      mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
hegyi@1838
   346
    }
ladanyi@1650
   347
  set_title("unsaved file - " + prog_name);
ladanyi@1606
   348
}
hegyi@1837
   349
hegyi@1837
   350
void MainWin::propertyChange(bool itisedge, int prop, std::string mapname)
hegyi@1837
   351
{
hegyi@1837
   352
  mapstorage.changeActiveMap(itisedge, prop, mapname);
hegyi@1837
   353
}
hegyi@1837
   354
hegyi@1837
   355
void MainWin::popupNewMapWin(bool itisedge, int prop)
hegyi@1837
   356
{
hegyi@1837
   357
  prop=prop;
hegyi@1837
   358
  (new NewMapWin("NewMapWin", *this, itisedge, false))->run();
hegyi@1837
   359
}
hegyi@1837
   360
hegyi@1837
   361
std::string MainWin::getActiveEdgeMap(int prop)
hegyi@1837
   362
{
hegyi@1837
   363
  return mapstorage.getActiveEdgeMap(prop);
hegyi@1837
   364
}
hegyi@1837
   365
hegyi@1837
   366
std::string MainWin::getActiveNodeMap(int prop)
hegyi@1837
   367
{
hegyi@1837
   368
  return mapstorage.getActiveNodeMap(prop);
hegyi@1837
   369
}
hegyi@1837
   370
hegyi@1837
   371
void MainWin::registerNewEdgeMap(std::string mapname)
hegyi@1837
   372
{
hegyi@1838
   373
  if(mapwinexists)
hegyi@1838
   374
    {
hegyi@1838
   375
      mapwin->registerNewEdgeMap(mapname);
hegyi@1838
   376
    }
hegyi@1837
   377
}
hegyi@1837
   378
hegyi@1837
   379
void MainWin::registerNewNodeMap(std::string mapname)
hegyi@1837
   380
{
hegyi@1838
   381
  if(mapwinexists)
hegyi@1838
   382
    {
hegyi@1838
   383
      mapwin->registerNewNodeMap(mapname);
hegyi@1838
   384
    }
hegyi@1837
   385
}
hegyi@1838
   386
hegyi@1838
   387
void MainWin::createMapWin()
hegyi@1838
   388
{
hegyi@1838
   389
  if(!mapwinexists)
hegyi@1838
   390
    {
hegyi@1838
   391
      mapwin=new MapWin("Map Setup", mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this);
hegyi@1838
   392
      mapwin->show();
hegyi@1838
   393
      mapwinexists=true;
hegyi@1838
   394
    }
hegyi@1838
   395
}
hegyi@1838
   396
hegyi@1838
   397
void MainWin::closeMapWin()
hegyi@1838
   398
{
hegyi@1838
   399
  mapwinexists=false;
hegyi@1838
   400
  delete mapwin;
hegyi@1838
   401
}