GtkCList::set_column_widget

GtkCList::set_column_widget

Sets a widget to be used as the specified column's title. This can be used to place a pixmap or something else as the column title, instead of the standard text.

Example 7. Using a custom widget in title of a GtkCList

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

$win = &new GtkWindow();
$win->set_default_size(250,250);
$win->connect('destroy', 'destroy');

function destroy() {
	Gtk::main_quit();
}

$arStatistics	= array(
 array( 'Paris', 9.1),
 array( 'Moscow', 9.0),
 array( 'London', 6.8),
 array( 'Rome', 3.8),
 array( 'Berlin', 3.4),
 array( 'Athena', 3.0)
);

$scrolled_win = &new GtkScrolledWindow();
$scrolled_win->set_policy( GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

$list = &new GtkCList( 2, array( "City", "Inhabitants"));

foreach( $arStatistics as $arStat) {
	$list->insert( 0, $arStat);
}

$list->set_column_width( 0, 90);

$list->set_selection_mode( GTK_SELECTION_MULTIPLE);


function mnuActivated( $mnuItem, $strLabel) {
	global $list;
	$chShow	= $strLabel[0];
	for( $nA = 0; $nA < count( $list->row_list); $nA++) {
		$nSize	= $list->get_text( $nA, 1);
		if( $chShow == 'A' || ( $chShow == '<' && $nSize < 5)
		 || ( $chShow == '>' && $nSize >= 5)) {
			$list->select_row( $nA, 0);
		} else {
			$list->unselect_row( $nA, 0);
		}
	}
}

$arMenus	= array( 'All', '> 5 million', '< 5 million', 'none');

$mnuSizes	= &new GtkMenu();
foreach( $arMenus as $strLabel) {
	$mnu = &new GtkMenuItem( $strLabel);
	$mnu->connect( 'activate', 'mnuactivated', $strLabel);
	$mnuSizes->append( $mnu);
}
$mnuSizes->show_all();

$om	= &new GtkOptionMenu();
$om->set_menu( $mnuSizes);

$list->set_column_widget( 1, $om);

$scrolled_win->add( $list);
$win->add( $scrolled_win);
$win->show_all();
GTK::main();
?>
© Copyright 2003-2023 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.