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