Posted by Anonymous Fri 9th Feb 2007 15:33 - Syntax is PHP - 110 views
Modification of posting from dimitris Fri 9th Feb 2007 15:21
Download | New Post | Modify | Diff | Hide line numbers
Modification of posting from dimitris Fri 9th Feb 2007 15:21
Download | New Post | Modify | Diff | Hide line numbers
PHP parser reported no syntax errors in this post!
-
-
$window = new GtkWindow();
-
$window->set_size_request(400, 312);
-
$window->add($vbox = new GtkVBox());
-
$accel_group = new GtkAccelGroup();
-
$window->add_accel_group($accel_group);
-
-
-
-
-
-
-
// Set up a scroll window
-
$scrolled_win = &new GtkScrolledWindow();
-
$scrolled_win->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
-
$vbox->pack_start($scrolled_win);
-
-
// the 2D table
-
-
display_table ($scrolled_win, $data);
-
-
$window->show_all();
-
Gtk::main();
-
-
function display_table($scrolled_win, $data) {
-
// Creates the list store
-
$model = new GtkListStore(Gtk::TYPE_STRING, Gtk::TYPE_STRING, GTK::TYPE_BOOLEAN,
-
Gtk::TYPE_LONG, Gtk::TYPE_DOUBLE);
-
-
// setup GtkTreeModelSort
-
$modelsort = new GtkTreeModelSort($model); // note 1
-
-
// Creates the view to display the list store
-
$view = new GtkTreeView($modelsort); // note 3
-
$scrolled_win->add($view);
-
-
// Creates the columns
-
for ($col=0; $col
($field_header); ++$col) { -
echo $col;
-
if ($field_header[$col] == 'check') {
-
$render = new GtkCellRendererToggle();
-
$render->set_property('activatable', true);
-
$render->connect('toggled', 'on_toggle',$modelsort);
-
$column = new GtkTreeViewColumn($field_header[$col],$render,'active',$col);
-
$column->set_alignment($field_justification[$col]);
-
}else{
-
$cell_renderer = new GtkCellRendererText();
-
$cell_renderer->set_property("xalign", $field_justification[$col]);
-
$column = new GtkTreeViewColumn($field_header[$col], $cell_renderer, 'text', $col);
-
$column->set_alignment($field_justification[$col]);
-
$column->set_sort_column_id($col);
-
}
-
-
/* // set the header font and color
-
$label = new GtkLabel($field_header[$col]);
-
$label->modify_font(new PangoFontDescription("Arial Bold"));
-
$label->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#0000FF"));
-
$column->set_widget($label);
-
$label->show(); */
-
-
// setup self-defined function to display alternate row color
-
$view->append_column($column);
-
}
-
-
// pupulates the data
-
for ($row=0; $row
($data); ++$row) { -
for ($col=0; $col
($data[$row]); ++$col) { -
$values[] = $data[$row][$col];
-
}
-
$model->append($values);
-
}
-
-
-
-
}
-
-
//function for checkbox
-
function on_toggle($renderer, $row, $modelsort) {
-
$sortiter = $modelsort->get_iter($row);
-
$model = $modelsort -> get_model();
-
$iter = $modelsort -> convert_iter_to_child_iter($sortiter);
-
$model->set($iter, 2,!$model->get_value($iter, 2));
-
}
PermaLink to this entry https://pastebin.co.uk/10167
Posted by Anonymous Fri 9th Feb 2007 15:33 - Syntax is PHP - 110 views
Modification of posting from dimitris Fri 9th Feb 2007 15:21
Download | New Post | Modify | Diff | Hide line numbers
Modification of posting from dimitris Fri 9th Feb 2007 15:21
Download | New Post | Modify | Diff | Hide line numbers
Comments: 0