GtkCTree Constructor

GtkCTree Constructor

GtkCTree (int nColumns, int nTreeGraphicCol, array arColTitles]);

Create a new CtkCTree object with a number of columns. The second parameter contains the index of the column in which the tree lines shall be visible (indent and +/-) and the third parameter can be an array with the column titles.

Notice how much of the code here is actually the arrays of data needed to populate the GtkCTree. It would probably be cleaner to keep your data generation in an include file.

Example 11. Setting up a GtkCTree

<?php
if( !extension_loaded('gtk')) {	
    dl( 'php_gtk.' . PHP_SHLIB_SUFFIX); 
}

/* start of data generation arrays */
$widgets_ = array(
/*level 0*/
array('Object'),
/*level 1*/
array('Widget', 'Data', 'ItemFactory'),
/*level 2*/
array('Misc', 'Container', 'Calendar', 'DrawingArea', 'Editable', 'Ruler', 
'Range', 'Separator', 'Preview', 'Progress'),
array('Adjustment', 'Tooltips'),
/*level 3*/
array('Label', 'Arrow', 'Image', 'Pixmap'),
array('Bin', 'Box', 'CList', 'Fixed', 'Notebook', 'Paned', 'Layout', 'List', 
'MenuShell', 'Packer', 'Socket', 'Table', 'Toolbar', 'Tree'),
array('Curve'),
array('Entry', 'Text'),
array('HRuler', 'VRuler'),
array('Scale', 'Scrollbar'),
array('HSeparator', 'VSeparator'),
array('ProgressBar'),
/*level 4*/
array('AccelLabel', 'TipsQuery'),
array('Alignment', 'Frame', 'Button', 'Item', 'Window', 'EventBox', 
'HandleBox', 'ScrolledWindow', 'Viewport', 'Invisible'),
array('ButtonBox', 'HBox', 'VBox'),
array('CTree'),
array('FontSelection'),
array('HPaned', 'VPaned'),
array('MenuBar', 'Menu'),
array('SpinButton'),
array('HScale', 'VScale'),
array('HScrollbar', 'VScrollbar'),
/*level 5*/
array('AspectFrame'),
array('ToggleButton', 'OptionMenu'),
array('ListItem', 'MenuItem', 'TreeItem'),
array('ColorSelectionDialog', 'Dialog', 'FileSelection', 
'FontSelectionDialog', 'Plug'),
array('HButtonBox', 'VButtonBox'),
array('Combo', 'Statusbar'),
array('ColorSelection', 'GammaCurve'),
/*level 6*/
array('CheckButton'),
array('CheckMenuItem', 'TearoffMenuItem'),
array('InputDialog'),
/*level 7*/
array('RadioButton'),
array('RadioMenuItem')
);

$row = array(0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 4, 5, 5, 5, 5, 5, 5, 7, 9, 9,
13, 13, 13, 13, 14, 14, 14, 23, 24, 25, 29, 30);

$class = array(0, 0, 1, 0, 1, 3, 4, 5, 6, 7, 9, 0, 0, 1, 2, 4, 5, 8, 0, 0, 1,
1, 2, 3, 4, 0, 1, 2, 0, 1, 1, 0, 0);
/* end of data generation arrays */

$window = &new GtkWindow();
$window->set_title('The GTK Class Hierarchy');
$window->set_position(GTK_WIN_POS_CENTER);
$window->set_default_size(300, (gdk::screen_height()-30));
$window->connect_object('destroy', array('gtk', 'main_quit'));

$scrolledwindow = &new GtkScrolledWindow();
$scrolledwindow->set_policy(GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
$window->add($scrolledwindow);

$ctree = &new GtkCTree(1, 0);
$ctree->set_line_style(GTK_CTREE_LINES_SOLID);

for($x = 0; $x < count($widgets_); $x++) {
  $sibling[$x] = array();
  switch($x) {
    case 0:
      $parent = null;
      break;
    default:
      $parent = $sibling[$row[$x-1]][$class[$x-1]];
    break;
  }
  for ($i = 0; $i < count($widgets_[$x]); $i++) {
    $widgets[0] = "Gtk".$widgets_[$x][$i];
    $sibling[$x][$i] = $ctree->insert_node($parent, $sibling[$x][], 
    $widgets, 5, null, null, null, null, false, true);
  }
}

$scrolledwindow->add($ctree);
$ctree->show();

$window->show_all();
gtk::main();

?>

© Copyright 2003-2023 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.