gui/map_win.cc
author ladanyi
Sat, 17 Dec 2005 21:51:10 +0000
changeset 1861 5f204c7a1318
parent 1838 b61682f0ee96
child 1884 9c061834b33b
permissions -rw-r--r--
Distribute xml.h too.
ladanyi@1606
     1
#include "map_win.h"
ladanyi@1442
     2
#include <set>
ladanyi@1442
     3
hegyi@1524
     4
bool MapWin::closeIfEscapeIsPressed(GdkEventKey* e)
ladanyi@1442
     5
{
hegyi@1446
     6
  if(e->keyval==GDK_Escape)
hegyi@1446
     7
  {
hegyi@1849
     8
    mytab.closeMapWin();
hegyi@1838
     9
    //    hide();
hegyi@1446
    10
  }
hegyi@1446
    11
  return true;
hegyi@1446
    12
}
ladanyi@1442
    13
hegyi@1849
    14
MapWin::MapWin(const std::string& title, std::vector<std::string> eml, std::vector<std::string> nml, NoteBookTab & mw):mytab(mw)
hegyi@1446
    15
{
hegyi@1446
    16
  set_title(title);
hegyi@1446
    17
  set_default_size(200, 50);
ladanyi@1442
    18
hegyi@1524
    19
  signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::closeIfEscapeIsPressed));
ladanyi@1442
    20
hegyi@1731
    21
  e_combo_array=new MapSelector * [EDGE_PROPERTY_NUM];
hegyi@1446
    22
hegyi@1731
    23
  table=new Gtk::Table(EDGE_PROPERTY_NUM, 1, false);
hegyi@1512
    24
hegyi@1512
    25
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
ladanyi@1442
    26
  {
hegyi@1849
    27
    e_combo_array[i]=new MapSelector(eml, mytab.getActiveEdgeMap(i), i, true);
hegyi@1446
    28
hegyi@1731
    29
    (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
hegyi@1837
    30
hegyi@1837
    31
    e_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::edgeMapChanged), i));
hegyi@1837
    32
    e_combo_array[i]->signal_newmapwin_needed().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::newMapWinNeeded), i));
ladanyi@1442
    33
  }
ladanyi@1442
    34
hegyi@1512
    35
  vbox.pack_start(*(new Gtk::Label("Edge properties")));
hegyi@1446
    36
hegyi@1512
    37
  vbox.pack_start(*table);
hegyi@1512
    38
hegyi@1512
    39
  vbox.pack_start(*(new Gtk::HSeparator));
hegyi@1512
    40
hegyi@1731
    41
  n_combo_array=new MapSelector * [NODE_PROPERTY_NUM];
hegyi@1512
    42
hegyi@1731
    43
  table=new Gtk::Table(NODE_PROPERTY_NUM, 1, false);
hegyi@1512
    44
hegyi@1512
    45
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
hegyi@1512
    46
  {
hegyi@1849
    47
    n_combo_array[i]=new MapSelector(nml, mytab.getActiveNodeMap(i), i, false);
hegyi@1512
    48
hegyi@1731
    49
    (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
hegyi@1837
    50
hegyi@1837
    51
    n_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::nodeMapChanged), i));
hegyi@1837
    52
    n_combo_array[i]->signal_newmapwin_needed().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::newMapWinNeeded), i));
hegyi@1512
    53
  }
hegyi@1512
    54
hegyi@1512
    55
  add(vbox);
hegyi@1512
    56
hegyi@1512
    57
  vbox.pack_start(*(new Gtk::Label("Node properties")));
hegyi@1512
    58
hegyi@1512
    59
  vbox.pack_start(*table);
ladanyi@1442
    60
ladanyi@1442
    61
  show_all_children();
ladanyi@1442
    62
ladanyi@1442
    63
}
ladanyi@1442
    64
hegyi@1838
    65
MapWin::~MapWin()
hegyi@1838
    66
{
hegyi@1838
    67
}
hegyi@1838
    68
hegyi@1837
    69
void MapWin::nodeMapChanged(std::string mapname, int prop)
hegyi@1837
    70
{
hegyi@1849
    71
  mytab.propertyChange(false, prop, mapname);
hegyi@1837
    72
}
hegyi@1837
    73
hegyi@1837
    74
void MapWin::edgeMapChanged(std::string mapname, int prop)
hegyi@1837
    75
{
hegyi@1849
    76
  mytab.propertyChange(true, prop, mapname);
hegyi@1837
    77
}
hegyi@1837
    78
hegyi@1837
    79
void MapWin::newMapWinNeeded(bool itisedge, int prop)
hegyi@1837
    80
{
hegyi@1849
    81
  mytab.popupNewMapWin(itisedge, prop);
hegyi@1837
    82
}
hegyi@1837
    83
hegyi@1837
    84
void MapWin::update(std::vector<std::string> eml, std::vector<std::string> nml)
ladanyi@1606
    85
{
ladanyi@1606
    86
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
ladanyi@1606
    87
  {
hegyi@1837
    88
    e_combo_array[i]->update_list(eml);
hegyi@1731
    89
  }
ladanyi@1606
    90
ladanyi@1606
    91
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
ladanyi@1606
    92
  {
hegyi@1837
    93
    n_combo_array[i]->update_list(nml);
ladanyi@1606
    94
  }
ladanyi@1606
    95
}
ladanyi@1606
    96
hegyi@1589
    97
void MapWin::registerNewEdgeMap(std::string newmapname)
hegyi@1586
    98
{
hegyi@1589
    99
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
hegyi@1589
   100
  {
hegyi@1589
   101
    //filling in combo box with choices
hegyi@1731
   102
    e_combo_array[i]->append_text((Glib::ustring)newmapname);
hegyi@1589
   103
  }
hegyi@1586
   104
}
hegyi@1586
   105
hegyi@1589
   106
void MapWin::registerNewNodeMap(std::string newmapname)
hegyi@1586
   107
{
hegyi@1592
   108
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
hegyi@1589
   109
  {
hegyi@1589
   110
    //filling in combo box with choices
hegyi@1733
   111
    n_combo_array[i]->append_text((Glib::ustring)newmapname);
hegyi@1589
   112
  }
hegyi@1586
   113
}
hegyi@1838
   114
hegyi@1838
   115
bool MapWin::on_delete_event(GdkEventAny * event)
hegyi@1838
   116
{
hegyi@1838
   117
  event=event;
hegyi@1849
   118
  mytab.closeMapWin();
hegyi@1838
   119
  return true;
hegyi@1838
   120
}