algobox.h
branchgui
changeset 103 3a263e57e1d9
child 106 853dd852abc7
equal deleted inserted replaced
-1:000000000000 0:aeefef905051
       
     1 // -*- C++ -*- //
       
     2 
       
     3 #ifndef ALGOBOX_H
       
     4 #define ALGOBOX_H
       
     5 
       
     6 class AlgoBox;
       
     7 
       
     8 #include <all_include.h>
       
     9 #include <libgnomecanvasmm.h>
       
    10 #include <libgnomecanvasmm/polygon.h>
       
    11 
       
    12 class AlgoBox : public Gtk::VBox
       
    13 {
       
    14   
       
    15   Gtk::Label * label;
       
    16   Gtk::ComboBoxText cbt;
       
    17   
       
    18  public:
       
    19   AlgoBox(std::vector<std::string> tabnames)
       
    20     {
       
    21       update_tablist(tabnames);
       
    22 
       
    23       label=new Gtk::Label("Haliho");
       
    24       
       
    25       pack_start(*label);
       
    26       pack_start(cbt);
       
    27 
       
    28       show_all_children();
       
    29     };
       
    30 
       
    31   void update_tablist( std::vector< std::string > tl )
       
    32     {
       
    33       std::string actname=cbt.get_active_text();
       
    34       int prev_act=-1;
       
    35 
       
    36       cbt.clear();
       
    37       int actptr=0;
       
    38 
       
    39       std::vector< std::string >::iterator emsi=tl.begin();
       
    40       for(;emsi!=tl.end();emsi++)
       
    41 	{
       
    42 	  if(actname==*emsi)
       
    43 	    {
       
    44 	      prev_act=actptr;
       
    45 	    }
       
    46 
       
    47 	  cbt.append_text(*emsi);
       
    48 	  actptr++;
       
    49 	}
       
    50 
       
    51       if(prev_act!=-1)
       
    52 	{
       
    53 	  cbt.set_active(prev_act);
       
    54 	}
       
    55       else if(actptr>0) //so there is item in the list
       
    56 	{
       
    57 	  cbt.set_active(0);
       
    58 	}
       
    59     }
       
    60 
       
    61 };
       
    62 #endif //ALGOBOX_H