map_win.cc
author ladanyi
Wed, 25 Oct 2006 17:50:02 +0000
changeset 173 8339178ae43d
parent 146 afd1d8bfcccd
child 174 95872af46fc4
permissions -rw-r--r--
Added two new classes.
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@146
    19
  set_resizable(false);
hegyi@146
    20
hegyi@30
    21
  signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::closeIfEscapeIsPressed));
ladanyi@6
    22
hegyi@172
    23
  mytab.signal_title_ch().connect(sigc::mem_fun(*this, &MapWin::set_title));
hegyi@172
    24
hegyi@81
    25
  e_combo_array=new MapSelector * [EDGE_PROPERTY_NUM];
hegyi@8
    26
hegyi@81
    27
  table=new Gtk::Table(EDGE_PROPERTY_NUM, 1, false);
hegyi@28
    28
hegyi@28
    29
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
ladanyi@6
    30
  {
hegyi@114
    31
    e_combo_array[i]=new MapSelector(eml, mytab.getActiveEdgeMap(i), edge_property_strings[i], true);
hegyi@8
    32
hegyi@81
    33
    (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
hegyi@94
    34
hegyi@94
    35
    e_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::edgeMapChanged), i));
hegyi@121
    36
    e_combo_array[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MapWin::newMapWinNeeded));
ladanyi@6
    37
  }
ladanyi@6
    38
hegyi@28
    39
  vbox.pack_start(*(new Gtk::Label("Edge properties")));
hegyi@8
    40
hegyi@28
    41
  vbox.pack_start(*table);
hegyi@28
    42
hegyi@28
    43
  vbox.pack_start(*(new Gtk::HSeparator));
hegyi@28
    44
hegyi@81
    45
  n_combo_array=new MapSelector * [NODE_PROPERTY_NUM];
hegyi@28
    46
hegyi@81
    47
  table=new Gtk::Table(NODE_PROPERTY_NUM, 1, false);
hegyi@28
    48
hegyi@28
    49
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
hegyi@28
    50
  {
hegyi@114
    51
    n_combo_array[i]=new MapSelector(nml, mytab.getActiveNodeMap(i), node_property_strings[i], false);
hegyi@28
    52
hegyi@81
    53
    (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
hegyi@94
    54
hegyi@94
    55
    n_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::nodeMapChanged), i));
hegyi@121
    56
    n_combo_array[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MapWin::newMapWinNeeded));
hegyi@28
    57
  }
hegyi@28
    58
hegyi@28
    59
  add(vbox);
hegyi@28
    60
hegyi@28
    61
  vbox.pack_start(*(new Gtk::Label("Node properties")));
hegyi@28
    62
hegyi@28
    63
  vbox.pack_start(*table);
ladanyi@6
    64
ladanyi@6
    65
  show_all_children();
ladanyi@6
    66
ladanyi@6
    67
}
ladanyi@6
    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@121
    79
void MapWin::newMapWinNeeded(bool itisedge)
hegyi@94
    80
{
hegyi@121
    81
  mytab.popupNewMapWin(itisedge);
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
  }
hegyi@172
    95
hegyi@172
    96
  mytab.active_maps_needed();
ladanyi@53
    97
}
ladanyi@53
    98
hegyi@40
    99
void MapWin::registerNewEdgeMap(std::string newmapname)
hegyi@38
   100
{
hegyi@40
   101
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
hegyi@40
   102
  {
hegyi@40
   103
    //filling in combo box with choices
hegyi@81
   104
    e_combo_array[i]->append_text((Glib::ustring)newmapname);
hegyi@40
   105
  }
hegyi@38
   106
}
hegyi@38
   107
hegyi@40
   108
void MapWin::registerNewNodeMap(std::string newmapname)
hegyi@38
   109
{
hegyi@41
   110
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
hegyi@40
   111
  {
hegyi@40
   112
    //filling in combo box with choices
hegyi@82
   113
    n_combo_array[i]->append_text((Glib::ustring)newmapname);
hegyi@40
   114
  }
hegyi@38
   115
}
hegyi@95
   116
hegyi@95
   117
bool MapWin::on_delete_event(GdkEventAny * event)
hegyi@95
   118
{
hegyi@95
   119
  event=event;
hegyi@96
   120
  mytab.closeMapWin();
hegyi@95
   121
  return true;
hegyi@95
   122
}
hegyi@172
   123
hegyi@172
   124
void MapWin::changeEntry(bool isitedge, int prop, std::string mapname)
hegyi@172
   125
{
hegyi@172
   126
  if(isitedge)
hegyi@172
   127
    {
hegyi@172
   128
      e_combo_array[prop]->set_active_text(mapname);
hegyi@172
   129
    }
hegyi@172
   130
  else
hegyi@172
   131
    {
hegyi@172
   132
      n_combo_array[prop]->set_active_text(mapname);
hegyi@172
   133
    }
hegyi@172
   134
}
hegyi@172
   135
hegyi@172
   136
void MapWin::set_title(std::string tabname)
hegyi@172
   137
{
hegyi@172
   138
  Gtk::Window::set_title("Map Setup - "+tabname);
hegyi@172
   139
}