/**
  * Class Constructor
  * @param  $name  = Name of the column in the database
  * @param  $label = Text label that will be shown in the header
  * @param  $align = Column align (left, center, right)
  * @param  $width = Column Width (pixels)
  */
 public function __construct($name, $label, $align, $width = NULL)
 {
     $this->name = $name;
     $this->label = $label;
     $this->align = $align;
     $this->width = (int) $width;
     if ($align == 'left') {
         $alignment = 0.0;
     } else {
         if ($align == 'center') {
             $alignment = 0.5;
         } else {
             if ($align == 'right') {
                 $alignment = 1.0;
             }
         }
     }
     parent::__construct();
     $this->renderer = new GtkCellRendererText();
     if ($width) {
         $this->renderer->set_property('width', $width);
         parent::set_fixed_width($width);
     }
     $this->renderer->set_property('xalign', $alignment);
     parent::pack_start($this->renderer, true);
     parent::set_alignment($alignment);
     parent::set_title($label);
     $header_hbox = new GtkHBox();
     $header_label = new GtkLabel($this->label);
     $header_hbox->pack_start($header_label);
     $this->sort_up = GtkImage::new_from_stock(GTK::STOCK_GO_UP, Gtk::ICON_SIZE_MENU);
     $this->sort_down = GtkImage::new_from_stock(GTK::STOCK_GO_DOWN, Gtk::ICON_SIZE_MENU);
     $header_hbox->pack_start($this->sort_up);
     $header_hbox->pack_start($this->sort_down);
     $header_hbox->show_all();
     // hide the ordering images
     $this->sort_up->hide();
     $this->sort_down->hide();
     parent::set_widget($header_hbox);
 }
 /**
  * Add a field to the MultiField
  * @param $name   Widget's name
  * @param $text   Widget's label
  * @param $object Widget
  * @param $size   Widget's size
  * @param $inform Show the Widget in the form
  */
 public function addField($name, $text, GtkObject $object, $size, $mandatory = FALSE)
 {
     if ($this->orientation == 'horizontal') {
         if (count($this->fields) == 0) {
             $this->row_label = $this->table_fields->addRow();
             $this->row_field = $this->table_fields->addRow();
         }
     } else {
         $row = $this->table_fields->addRow();
         $this->row_label = $row;
         $this->row_field = $row;
     }
     $label = new TLabel("<i>{$text}</i>");
     if ($mandatory) {
         $label->setFontColor('#FF0000');
     }
     $n = $this->count;
     $object->setName("{$this->name}_text{$n}");
     $this->row_label->addCell($label);
     $this->row_field->addCell($object);
     $this->fields[$name] = array($text, $object, $size, FALSE, $mandatory);
     $this->allfields[$name] = array($text, $object, $size, FALSE, $mandatory);
     if (get_class($object) == 'TComboCombined') {
         $column = new GtkTreeViewColumn('ID');
     } else {
         $column = new GtkTreeViewColumn($text);
     }
     $cell_renderer = new GtkCellRendererText();
     $cell_renderer->set_property('width', $size);
     $column->set_fixed_width($size);
     $column->pack_start($cell_renderer, true);
     $column->add_attribute($cell_renderer, 'text', $this->count);
     $this->types[] = GObject::TYPE_STRING;
     $this->view->append_column($column);
     $this->columns[$name] = $this->count;
     $this->count++;
     // combocombined, need to add one more column and treat different
     if (get_class($object) == 'TComboCombined') {
         $cell_renderer->set_property('width', 20);
         $column->set_fixed_width(20);
         $tname = $object->getTextName();
         $this->fields[$tname] = array($text, $object, $size, TRUE, $mandatory);
         $this->fields[$name][2] = 20;
         $this->allfields[$name][2] = 20;
         $column = new GtkTreeViewColumn($text);
         $cell_renderer = new GtkCellRendererText();
         $cell_renderer->set_property('width', $size);
         $column->set_fixed_width($size);
         $column->pack_start($cell_renderer, true);
         $column->add_attribute($cell_renderer, 'text', $this->count);
         $this->types[] = GObject::TYPE_STRING;
         $this->view->append_column($column);
         $this->allfields[$tname] = array($text, $object, $size, TRUE, $mandatory);
         $this->columns[$tname] = $this->count;
         $this->count++;
     }
 }