gui/mw-mapselector.cc
changeset 1879 01d41844ef46
parent 1837 8dd6160ff699
equal deleted inserted replaced
2:b29deeb4f1f2 3:235541aae096
     1 #include "map_win.h"
     1 #include "map_win.h"
     2 
     2 
     3 MapWin::MapSelector::MapSelector(std::vector<std::string> ml, int identifier, bool edge):id(identifier),itisedge(edge),default_state(true),set_new_map(false)
     3 MapWin::MapSelector::MapSelector(std::vector<std::string> ml, std::string act, int identifier, bool edge):id(identifier),itisedge(edge),set_new_map(false)
     4 {
     4 {
     5   update_list(ml);
     5   update_list(ml);
     6 
     6 
     7   cbt.set_active(0);
     7   if(act=="")
       
     8     {
       
     9       cbt.set_active(0);
       
    10       default_state=true;
       
    11     }
       
    12   else
       
    13     {
       
    14       cbt.set_active_text((Glib::ustring)act);
       
    15       default_state=false;
       
    16     }
     8 
    17 
     9   //binding signal to the actual entry
    18   //binding signal to the actual entry
    10   cbt.signal_changed().connect
    19   cbt.signal_changed().connect
    11     (
    20     (
    12      sigc::mem_fun((*this), &MapWin::MapSelector::comboChanged),
    21      sigc::mem_fun((*this), &MapWin::MapSelector::comboChanged),
    53   signal_newmapwin.emit(itisedge);
    62   signal_newmapwin.emit(itisedge);
    54 }
    63 }
    55 
    64 
    56 void MapWin::MapSelector::update_list( std::vector< std::string > ml )
    65 void MapWin::MapSelector::update_list( std::vector< std::string > ml )
    57 {
    66 {
       
    67   int prev_act=cbt.get_active_row_number();
    58   cbt.clear();
    68   cbt.clear();
    59   std::vector< std::string >::iterator emsi=ml.begin();
    69   std::vector< std::string >::iterator emsi=ml.begin();
    60   for(;emsi!=ml.end();emsi++)
    70   for(;emsi!=ml.end();emsi++)
    61     {
    71     {
    62       cbt.append_text(*emsi);
    72       cbt.append_text(*emsi);
    63     }
    73     }
    64   cbt.prepend_text("Default values");
    74   cbt.prepend_text("Default values");
       
    75   if(prev_act!=-1)
       
    76     {
       
    77       cbt.set_active(prev_act);
       
    78     }
    65 }
    79 }
    66 
    80 
    67 void MapWin::MapSelector::comboChanged()
    81 void MapWin::MapSelector::comboChanged()
    68 {
    82 {
    69   if(cbt.get_active_row_number()!=0)
    83   if(cbt.get_active_row_number()!=0)
    75 	  signal_cbt.emit(mapname);
    89 	  signal_cbt.emit(mapname);
    76 	}
    90 	}
    77     }
    91     }
    78   else if((!default_state)&&(cbt.get_active_row_number()==0))
    92   else if((!default_state)&&(cbt.get_active_row_number()==0))
    79     {
    93     {
    80       signal_cbt.emit("");
       
    81       reset();
    94       reset();
    82     }
    95     }
    83 }
    96 }
    84 
    97 
    85 void MapWin::MapSelector::reset()
    98 void MapWin::MapSelector::reset()
    86 {
    99 {
    87   default_state=true;
   100   default_state=true;
       
   101 
    88   cbt.set_active(0);
   102   cbt.set_active(0);
    89 
   103 
    90   signal_cbt.emit("");
   104   signal_cbt.emit("");
    91 }
   105 }
    92 
   106