map_win.cc
author hegyi
Mon, 21 Nov 2005 18:03:20 +0000
branchgui
changeset 90 e9f8f44f12a3
parent 85 0b2217328320
child 94 adfdc2f70548
permissions -rw-r--r--
NewMapWin has become Dialog instead of Window. Therefore it is created dynamically, when there is need for it, instead of keeping one instance in memory. This solution is slower, but more correct than before.
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@8
     8
    hide();
hegyi@8
     9
  }
hegyi@8
    10
  return true;
hegyi@8
    11
}
ladanyi@6
    12
hegyi@90
    13
MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst)
hegyi@8
    14
{
hegyi@8
    15
  set_title(title);
hegyi@8
    16
  set_default_size(200, 50);
ladanyi@6
    17
hegyi@30
    18
  signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::closeIfEscapeIsPressed));
ladanyi@6
    19
hegyi@81
    20
  e_combo_array=new MapSelector * [EDGE_PROPERTY_NUM];
hegyi@8
    21
hegyi@81
    22
  table=new Gtk::Table(EDGE_PROPERTY_NUM, 1, false);
hegyi@28
    23
hegyi@28
    24
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
ladanyi@6
    25
  {
hegyi@90
    26
    e_combo_array[i]=new MapSelector(gdc, ms, i, true);
hegyi@8
    27
hegyi@81
    28
    (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
ladanyi@6
    29
  }
ladanyi@6
    30
hegyi@28
    31
  vbox.pack_start(*(new Gtk::Label("Edge properties")));
hegyi@8
    32
hegyi@28
    33
  vbox.pack_start(*table);
hegyi@28
    34
hegyi@28
    35
  vbox.pack_start(*(new Gtk::HSeparator));
hegyi@28
    36
hegyi@81
    37
  n_combo_array=new MapSelector * [NODE_PROPERTY_NUM];
hegyi@28
    38
hegyi@81
    39
  table=new Gtk::Table(NODE_PROPERTY_NUM, 1, false);
hegyi@28
    40
hegyi@28
    41
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
hegyi@28
    42
  {
hegyi@90
    43
    n_combo_array[i]=new MapSelector(gdc, ms, i, false);
hegyi@28
    44
hegyi@81
    45
    (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
hegyi@28
    46
  }
hegyi@28
    47
hegyi@28
    48
  add(vbox);
hegyi@28
    49
hegyi@28
    50
  vbox.pack_start(*(new Gtk::Label("Node properties")));
hegyi@28
    51
hegyi@28
    52
  vbox.pack_start(*table);
ladanyi@6
    53
ladanyi@6
    54
  show_all_children();
ladanyi@6
    55
ladanyi@6
    56
}
ladanyi@6
    57
ladanyi@53
    58
void MapWin::update()
ladanyi@53
    59
{
ladanyi@53
    60
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
ladanyi@53
    61
  {
hegyi@81
    62
    e_combo_array[i]->update_list();
hegyi@81
    63
  }
ladanyi@53
    64
ladanyi@53
    65
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
ladanyi@53
    66
  {
hegyi@81
    67
    n_combo_array[i]->update_list();
ladanyi@53
    68
  }
ladanyi@53
    69
}
ladanyi@53
    70
hegyi@28
    71
alpar@62
    72
void MapWin::updateNode(Node node)
hegyi@28
    73
{
hegyi@28
    74
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
hegyi@28
    75
    {
hegyi@81
    76
      n_combo_array[i]->update(node);
hegyi@28
    77
    }
hegyi@28
    78
}
hegyi@28
    79
alpar@62
    80
void MapWin::updateEdge(Edge edge)
hegyi@28
    81
{
hegyi@28
    82
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
hegyi@28
    83
    {
hegyi@81
    84
      e_combo_array[i]->update(edge);
hegyi@28
    85
    }
hegyi@28
    86
}
hegyi@38
    87
hegyi@40
    88
void MapWin::registerNewEdgeMap(std::string newmapname)
hegyi@38
    89
{
hegyi@40
    90
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
hegyi@40
    91
  {
hegyi@40
    92
    //filling in combo box with choices
hegyi@81
    93
    e_combo_array[i]->append_text((Glib::ustring)newmapname);
hegyi@40
    94
  }
hegyi@38
    95
}
hegyi@38
    96
hegyi@40
    97
void MapWin::registerNewNodeMap(std::string newmapname)
hegyi@38
    98
{
hegyi@41
    99
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
hegyi@40
   100
  {
hegyi@40
   101
    //filling in combo box with choices
hegyi@82
   102
    n_combo_array[i]->append_text((Glib::ustring)newmapname);
hegyi@40
   103
  }
hegyi@38
   104
}