gui/map_win.cc
author hegyi
Tue, 29 Nov 2005 19:31:58 +0000
changeset 1837 8dd6160ff699
parent 1823 cb082cdf3667
child 1838 b61682f0ee96
permissions -rw-r--r--
Structure of GUI is now more clear-cut than before.
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@1446
     8
    hide();
hegyi@1446
     9
  }
hegyi@1446
    10
  return true;
hegyi@1446
    11
}
ladanyi@1442
    12
hegyi@1837
    13
MapWin::MapWin(const std::string& title, std::vector<std::string> eml, std::vector<std::string> nml, MainWin & mw):mainwin(mw)
hegyi@1446
    14
{
hegyi@1446
    15
  set_title(title);
hegyi@1446
    16
  set_default_size(200, 50);
ladanyi@1442
    17
hegyi@1524
    18
  signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::closeIfEscapeIsPressed));
ladanyi@1442
    19
hegyi@1731
    20
  e_combo_array=new MapSelector * [EDGE_PROPERTY_NUM];
hegyi@1446
    21
hegyi@1731
    22
  table=new Gtk::Table(EDGE_PROPERTY_NUM, 1, false);
hegyi@1512
    23
hegyi@1512
    24
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
ladanyi@1442
    25
  {
hegyi@1837
    26
    e_combo_array[i]=new MapSelector(eml, i, true);
hegyi@1446
    27
hegyi@1731
    28
    (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
hegyi@1837
    29
hegyi@1837
    30
    e_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::edgeMapChanged), i));
hegyi@1837
    31
    e_combo_array[i]->signal_newmapwin_needed().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::newMapWinNeeded), i));
ladanyi@1442
    32
  }
ladanyi@1442
    33
hegyi@1512
    34
  vbox.pack_start(*(new Gtk::Label("Edge properties")));
hegyi@1446
    35
hegyi@1512
    36
  vbox.pack_start(*table);
hegyi@1512
    37
hegyi@1512
    38
  vbox.pack_start(*(new Gtk::HSeparator));
hegyi@1512
    39
hegyi@1731
    40
  n_combo_array=new MapSelector * [NODE_PROPERTY_NUM];
hegyi@1512
    41
hegyi@1731
    42
  table=new Gtk::Table(NODE_PROPERTY_NUM, 1, false);
hegyi@1512
    43
hegyi@1512
    44
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
hegyi@1512
    45
  {
hegyi@1837
    46
    n_combo_array[i]=new MapSelector(nml, i, false);
hegyi@1512
    47
hegyi@1731
    48
    (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
hegyi@1837
    49
hegyi@1837
    50
    n_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::nodeMapChanged), i));
hegyi@1837
    51
    n_combo_array[i]->signal_newmapwin_needed().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::newMapWinNeeded), i));
hegyi@1512
    52
  }
hegyi@1512
    53
hegyi@1512
    54
  add(vbox);
hegyi@1512
    55
hegyi@1512
    56
  vbox.pack_start(*(new Gtk::Label("Node properties")));
hegyi@1512
    57
hegyi@1512
    58
  vbox.pack_start(*table);
ladanyi@1442
    59
ladanyi@1442
    60
  show_all_children();
ladanyi@1442
    61
ladanyi@1442
    62
}
ladanyi@1442
    63
hegyi@1837
    64
void MapWin::nodeMapChanged(std::string mapname, int prop)
hegyi@1837
    65
{
hegyi@1837
    66
  mainwin.propertyChange(false, prop, mapname);
hegyi@1837
    67
}
hegyi@1837
    68
hegyi@1837
    69
void MapWin::edgeMapChanged(std::string mapname, int prop)
hegyi@1837
    70
{
hegyi@1837
    71
  mainwin.propertyChange(true, prop, mapname);
hegyi@1837
    72
}
hegyi@1837
    73
hegyi@1837
    74
void MapWin::newMapWinNeeded(bool itisedge, int prop)
hegyi@1837
    75
{
hegyi@1837
    76
  mainwin.popupNewMapWin(itisedge, prop);
hegyi@1837
    77
}
hegyi@1837
    78
hegyi@1837
    79
void MapWin::update(std::vector<std::string> eml, std::vector<std::string> nml)
ladanyi@1606
    80
{
ladanyi@1606
    81
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
ladanyi@1606
    82
  {
hegyi@1837
    83
    e_combo_array[i]->update_list(eml);
hegyi@1731
    84
  }
ladanyi@1606
    85
ladanyi@1606
    86
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
ladanyi@1606
    87
  {
hegyi@1837
    88
    n_combo_array[i]->update_list(nml);
ladanyi@1606
    89
  }
ladanyi@1606
    90
}
ladanyi@1606
    91
hegyi@1589
    92
void MapWin::registerNewEdgeMap(std::string newmapname)
hegyi@1586
    93
{
hegyi@1589
    94
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
hegyi@1589
    95
  {
hegyi@1589
    96
    //filling in combo box with choices
hegyi@1731
    97
    e_combo_array[i]->append_text((Glib::ustring)newmapname);
hegyi@1589
    98
  }
hegyi@1586
    99
}
hegyi@1586
   100
hegyi@1589
   101
void MapWin::registerNewNodeMap(std::string newmapname)
hegyi@1586
   102
{
hegyi@1592
   103
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
hegyi@1589
   104
  {
hegyi@1589
   105
    //filling in combo box with choices
hegyi@1733
   106
    n_combo_array[i]->append_text((Glib::ustring)newmapname);
hegyi@1589
   107
  }
hegyi@1586
   108
}