gui/map_win.cc
author hegyi
Thu, 20 Oct 2005 15:50:23 +0000
changeset 1731 616bc933c2bc
parent 1648 dd8672338691
child 1733 5e0d97823ba2
permissions -rw-r--r--
Mapselector widget reached its first release, but there are still work to do on it, I know...
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@1512
    13
MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst)
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@1731
    26
    e_combo_array[i]=new MapSelector(gdc, ms, *this, 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);
ladanyi@1442
    29
  }
ladanyi@1442
    30
hegyi@1512
    31
  vbox.pack_start(*(new Gtk::Label("Edge properties")));
hegyi@1446
    32
hegyi@1512
    33
  vbox.pack_start(*table);
hegyi@1512
    34
hegyi@1512
    35
  vbox.pack_start(*(new Gtk::HSeparator));
hegyi@1512
    36
hegyi@1731
    37
  n_combo_array=new MapSelector * [NODE_PROPERTY_NUM];
hegyi@1512
    38
hegyi@1731
    39
  table=new Gtk::Table(NODE_PROPERTY_NUM, 1, false);
hegyi@1512
    40
hegyi@1512
    41
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
hegyi@1512
    42
  {
hegyi@1731
    43
    n_combo_array[i]=new MapSelector(gdc, ms, *this, i, false);
hegyi@1512
    44
hegyi@1731
    45
    (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
hegyi@1512
    46
  }
hegyi@1512
    47
hegyi@1512
    48
  add(vbox);
hegyi@1512
    49
hegyi@1512
    50
  vbox.pack_start(*(new Gtk::Label("Node properties")));
hegyi@1512
    51
hegyi@1512
    52
  vbox.pack_start(*table);
ladanyi@1442
    53
ladanyi@1442
    54
  show_all_children();
ladanyi@1442
    55
ladanyi@1442
    56
}
ladanyi@1442
    57
ladanyi@1606
    58
void MapWin::update()
ladanyi@1606
    59
{
ladanyi@1606
    60
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
ladanyi@1606
    61
  {
hegyi@1731
    62
    e_combo_array[i]->update_list();
hegyi@1731
    63
  }
ladanyi@1606
    64
ladanyi@1606
    65
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
ladanyi@1606
    66
  {
hegyi@1731
    67
    n_combo_array[i]->update_list();
ladanyi@1606
    68
  }
ladanyi@1606
    69
}
ladanyi@1606
    70
hegyi@1512
    71
alpar@1643
    72
void MapWin::updateNode(Node node)
hegyi@1512
    73
{
hegyi@1512
    74
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
hegyi@1512
    75
    {
hegyi@1731
    76
      n_combo_array[i]->update(node);
hegyi@1512
    77
    }
hegyi@1512
    78
}
hegyi@1512
    79
alpar@1643
    80
void MapWin::updateEdge(Edge edge)
hegyi@1512
    81
{
hegyi@1512
    82
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
hegyi@1512
    83
    {
hegyi@1731
    84
      e_combo_array[i]->update(edge);
hegyi@1512
    85
    }
hegyi@1512
    86
}
hegyi@1586
    87
hegyi@1589
    88
void MapWin::registerNewEdgeMap(std::string newmapname)
hegyi@1586
    89
{
hegyi@1589
    90
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
hegyi@1589
    91
  {
hegyi@1589
    92
    //filling in combo box with choices
hegyi@1731
    93
    e_combo_array[i]->append_text((Glib::ustring)newmapname);
hegyi@1589
    94
  }
hegyi@1594
    95
  //setting text property for the new map
hegyi@1731
    96
  e_combo_array[N_TEXT]->set_active_text((Glib::ustring)newmapname);
hegyi@1586
    97
}
hegyi@1586
    98
hegyi@1589
    99
void MapWin::registerNewNodeMap(std::string newmapname)
hegyi@1586
   100
{
hegyi@1592
   101
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
hegyi@1589
   102
  {
hegyi@1589
   103
    //filling in combo box with choices
hegyi@1731
   104
    e_combo_array[i]->append_text((Glib::ustring)newmapname);
hegyi@1589
   105
  }
hegyi@1594
   106
  //setting text property for the new map
hegyi@1731
   107
  n_combo_array[N_TEXT]->set_active_text((Glib::ustring)newmapname);
hegyi@1586
   108
}