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