/** * 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, $inform = TRUE) { if ($inform) { $row = $this->table_fields->addRow(); $label = new TLabel("<i>{$text}</i>"); $n = $this->count; $object->setName("{$this->name}_text{$n}"); $row->addCell($label); $row->addCell($object); $this->fields[$name] = array($text, $object, $size, FALSE); } $this->allfields[$name] = array($text, $object, $size, FALSE); if (get_class($object) == 'TComboCombined') { $column = new GtkTreeViewColumn('ID'); } else { $column = new GtkTreeViewColumn($text); } $cell_renderer = new GtkCellRendererText(); $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') { $tname = $object->getTextName(); $this->fields[$tname] = array($text, $object, $size, TRUE); $column = new GtkTreeViewColumn($text); $cell_renderer = new GtkCellRendererText(); $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); $this->columns[$tname] = $this->count; $this->count++; } }
/** * 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++; } }