예제 #1
0
 /**
  * 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);
 }