map_win.cc
author alpar
Mon, 24 Oct 2005 08:12:26 +0000
branchgui
changeset 84 09b09efab0a1
parent 81 5ad61c33487c
child 85 0b2217328320
permissions -rw-r--r--
Doxyfile for documenting glemon's architecture.
     1 #include "map_win.h"
     2 #include <set>
     3 
     4 bool MapWin::closeIfEscapeIsPressed(GdkEventKey* e)
     5 {
     6   if(e->keyval==GDK_Escape)
     7   {
     8     hide();
     9   }
    10   return true;
    11 }
    12 
    13 MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc, NewMapWin & newmapwin):gdc(grdispc),ms(mapst), nmw(newmapwin)
    14 {
    15   set_title(title);
    16   set_default_size(200, 50);
    17 
    18   signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::closeIfEscapeIsPressed));
    19 
    20   e_combo_array=new MapSelector * [EDGE_PROPERTY_NUM];
    21 
    22   table=new Gtk::Table(EDGE_PROPERTY_NUM, 1, false);
    23 
    24   for(int i=0;i<EDGE_PROPERTY_NUM;i++)
    25   {
    26     e_combo_array[i]=new MapSelector(gdc, ms, nmw, i, true);
    27 
    28     (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
    29   }
    30 
    31   vbox.pack_start(*(new Gtk::Label("Edge properties")));
    32 
    33   vbox.pack_start(*table);
    34 
    35   vbox.pack_start(*(new Gtk::HSeparator));
    36 
    37   n_combo_array=new MapSelector * [NODE_PROPERTY_NUM];
    38 
    39   table=new Gtk::Table(NODE_PROPERTY_NUM, 1, false);
    40 
    41   for(int i=0;i<NODE_PROPERTY_NUM;i++)
    42   {
    43     n_combo_array[i]=new MapSelector(gdc, ms, nmw, i, false);
    44 
    45     (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
    46   }
    47 
    48   add(vbox);
    49 
    50   vbox.pack_start(*(new Gtk::Label("Node properties")));
    51 
    52   vbox.pack_start(*table);
    53 
    54   show_all_children();
    55 
    56 }
    57 
    58 void MapWin::update()
    59 {
    60   for(int i=0;i<EDGE_PROPERTY_NUM;i++)
    61   {
    62     e_combo_array[i]->update_list();
    63   }
    64 
    65   for(int i=0;i<NODE_PROPERTY_NUM;i++)
    66   {
    67     n_combo_array[i]->update_list();
    68   }
    69 }
    70 
    71 
    72 void MapWin::updateNode(Node node)
    73 {
    74   for(int i=0;i<NODE_PROPERTY_NUM;i++)
    75     {
    76       n_combo_array[i]->update(node);
    77     }
    78 }
    79 
    80 void MapWin::updateEdge(Edge edge)
    81 {
    82   for(int i=0;i<EDGE_PROPERTY_NUM;i++)
    83     {
    84       e_combo_array[i]->update(edge);
    85     }
    86 }
    87 
    88 void MapWin::registerNewEdgeMap(std::string newmapname)
    89 {
    90   for(int i=0;i<EDGE_PROPERTY_NUM;i++)
    91   {
    92     //filling in combo box with choices
    93     e_combo_array[i]->append_text((Glib::ustring)newmapname);
    94   }
    95   //setting text property for the new map
    96   e_combo_array[N_TEXT]->set_active_text((Glib::ustring)newmapname);
    97 }
    98 
    99 void MapWin::registerNewNodeMap(std::string newmapname)
   100 {
   101   for(int i=0;i<NODE_PROPERTY_NUM;i++)
   102   {
   103     //filling in combo box with choices
   104     n_combo_array[i]->append_text((Glib::ustring)newmapname);
   105   }
   106   //setting text property for the new map
   107   n_combo_array[N_TEXT]->set_active_text((Glib::ustring)newmapname);
   108 }