map_win.cc
author hegyi
Thu, 05 Jan 2006 12:30:09 +0000
branchgui
changeset 108 bf355fd6563e
parent 95 628c0b383d2f
child 114 0ace7edbb06f
permissions -rw-r--r--
Several changes. \n If new map is added to mapstorage it emits signal with the name of the new map. This was important, because from now on not only tha mapwin should be updated. \n Furthermore algobox gets a pointer to mapstorage instead of only the mapnames from it. This is important because without it it would be complicated to pass all of the required maps to algobox.
ladanyi@53
     1
#include "map_win.h"
ladanyi@6
     2
#include <set>
ladanyi@6
     3
hegyi@30
     4
bool MapWin::closeIfEscapeIsPressed(GdkEventKey* e)
ladanyi@6
     5
{
hegyi@8
     6
  if(e->keyval==GDK_Escape)
hegyi@8
     7
  {
hegyi@96
     8
    mytab.closeMapWin();
hegyi@95
     9
    //    hide();
hegyi@8
    10
  }
hegyi@8
    11
  return true;
hegyi@8
    12
}
ladanyi@6
    13
hegyi@96
    14
MapWin::MapWin(const std::string& title, std::vector<std::string> eml, std::vector<std::string> nml, NoteBookTab & mw):mytab(mw)
hegyi@8
    15
{
hegyi@8
    16
  set_title(title);
hegyi@8
    17
  set_default_size(200, 50);
ladanyi@6
    18
hegyi@30
    19
  signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::closeIfEscapeIsPressed));
ladanyi@6
    20
hegyi@81
    21
  e_combo_array=new MapSelector * [EDGE_PROPERTY_NUM];
hegyi@8
    22
hegyi@81
    23
  table=new Gtk::Table(EDGE_PROPERTY_NUM, 1, false);
hegyi@28
    24
hegyi@28
    25
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
ladanyi@6
    26
  {
hegyi@96
    27
    e_combo_array[i]=new MapSelector(eml, mytab.getActiveEdgeMap(i), i, true);
hegyi@8
    28
hegyi@81
    29
    (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
hegyi@94
    30
hegyi@94
    31
    e_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::edgeMapChanged), i));
hegyi@94
    32
    e_combo_array[i]->signal_newmapwin_needed().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::newMapWinNeeded), i));
ladanyi@6
    33
  }
ladanyi@6
    34
hegyi@28
    35
  vbox.pack_start(*(new Gtk::Label("Edge properties")));
hegyi@8
    36
hegyi@28
    37
  vbox.pack_start(*table);
hegyi@28
    38
hegyi@28
    39
  vbox.pack_start(*(new Gtk::HSeparator));
hegyi@28
    40
hegyi@81
    41
  n_combo_array=new MapSelector * [NODE_PROPERTY_NUM];
hegyi@28
    42
hegyi@81
    43
  table=new Gtk::Table(NODE_PROPERTY_NUM, 1, false);
hegyi@28
    44
hegyi@28
    45
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
hegyi@28
    46
  {
hegyi@96
    47
    n_combo_array[i]=new MapSelector(nml, mytab.getActiveNodeMap(i), i, false);
hegyi@28
    48
hegyi@81
    49
    (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
hegyi@94
    50
hegyi@94
    51
    n_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::nodeMapChanged), i));
hegyi@94
    52
    n_combo_array[i]->signal_newmapwin_needed().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::newMapWinNeeded), i));
hegyi@28
    53
  }
hegyi@28
    54
hegyi@28
    55
  add(vbox);
hegyi@28
    56
hegyi@28
    57
  vbox.pack_start(*(new Gtk::Label("Node properties")));
hegyi@28
    58
hegyi@28
    59
  vbox.pack_start(*table);
ladanyi@6
    60
ladanyi@6
    61
  show_all_children();
ladanyi@6
    62
ladanyi@6
    63
}
ladanyi@6
    64
hegyi@95
    65
MapWin::~MapWin()
hegyi@95
    66
{
hegyi@95
    67
}
hegyi@95
    68
hegyi@94
    69
void MapWin::nodeMapChanged(std::string mapname, int prop)
hegyi@94
    70
{
hegyi@96
    71
  mytab.propertyChange(false, prop, mapname);
hegyi@94
    72
}
hegyi@94
    73
hegyi@94
    74
void MapWin::edgeMapChanged(std::string mapname, int prop)
hegyi@94
    75
{
hegyi@96
    76
  mytab.propertyChange(true, prop, mapname);
hegyi@94
    77
}
hegyi@94
    78
hegyi@94
    79
void MapWin::newMapWinNeeded(bool itisedge, int prop)
hegyi@94
    80
{
hegyi@96
    81
  mytab.popupNewMapWin(itisedge, prop);
hegyi@94
    82
}
hegyi@94
    83
hegyi@94
    84
void MapWin::update(std::vector<std::string> eml, std::vector<std::string> nml)
ladanyi@53
    85
{
ladanyi@53
    86
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
ladanyi@53
    87
  {
hegyi@94
    88
    e_combo_array[i]->update_list(eml);
hegyi@81
    89
  }
ladanyi@53
    90
ladanyi@53
    91
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
ladanyi@53
    92
  {
hegyi@94
    93
    n_combo_array[i]->update_list(nml);
ladanyi@53
    94
  }
ladanyi@53
    95
}
ladanyi@53
    96
hegyi@40
    97
void MapWin::registerNewEdgeMap(std::string newmapname)
hegyi@38
    98
{
hegyi@40
    99
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
hegyi@40
   100
  {
hegyi@40
   101
    //filling in combo box with choices
hegyi@81
   102
    e_combo_array[i]->append_text((Glib::ustring)newmapname);
hegyi@40
   103
  }
hegyi@38
   104
}
hegyi@38
   105
hegyi@40
   106
void MapWin::registerNewNodeMap(std::string newmapname)
hegyi@38
   107
{
hegyi@41
   108
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
hegyi@40
   109
  {
hegyi@40
   110
    //filling in combo box with choices
hegyi@82
   111
    n_combo_array[i]->append_text((Glib::ustring)newmapname);
hegyi@40
   112
  }
hegyi@38
   113
}
hegyi@95
   114
hegyi@95
   115
bool MapWin::on_delete_event(GdkEventAny * event)
hegyi@95
   116
{
hegyi@95
   117
  event=event;
hegyi@96
   118
  mytab.closeMapWin();
hegyi@95
   119
  return true;
hegyi@95
   120
}