Small problem with Clist and row_visible()
| From: | lukas at pronet dot lublin dot pl | Date: | Tue, 10 May 2005 13:45:37 +0000 |
| Subject: | Small problem with Clist and row_visible() | ||
| Groups: | php.gtk.general | ||
| Request: | Send a blank email to php-gtk-general+get-5839@lists.php.net to get a copy of this message | ||
Hello
Below is small example which ilustrates "my" problem.
After running this script try to change height of the window.
Messages will be printed to console where will be nr of visible rows and first
visible row.
On my "deveopment platform" (based on Windows) printed values are not always
reflects reality. When I catch bottom border with mouse and drag it lower than i
see for example 10 rows but function CalculateVisibleRows reports previous
state.
Is there any way to fix my problem ?
greetings
<?php
if( !extension_loaded('gtk')) {
dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);
}
$oWindow =& new GtkWindow();
$oScrWindow =& new GtkScrolledWindow();
$oClist =& new GtkClist(3,array('col1','col2','col3'));
$oWindow->add( $oScrWindow );
$oScrWindow->add( $oClist );
$oWindow->show_all();
for( $i=0; $i < 100; $i++)
{
$oClist->append( array('cell1','cell2','cell3'));
}
function theend()
{
gtk::main_quit();
}
function CalculateVisibleRows( &$oClist )
{
$iNrOfRows = $oClist->rows;
for( $i = 0; $i < $iNrOfRows; $i++)
{
switch( $oClist->row_is_visible( $i ) )
{
case GTK_VISIBILITY_NONE:
if( is_numeric( $iFirstVisibleRow ) )
{
$iLastVisibleRow = $i - 1;
break 2;
}
else
{
continue;
}
break;
case ( GTK_VISIBILITY_PARTIAL || GTK_VISIBILITY_FULL ):
$iFirstVisibleRow = ( is_numeric( $iFirstVisibleRow ) ?
$iFirstVisibleRow : $i );
break;
}
}
// jesli nie zostalo ustawione $iLastVisibleRow to oznacza, widocznosc jest az
do ostatniego wiersza
if( !is_numeric( $iLastVisibleRow ) )
{
$iLastVisibleRow = $i;
}
$iNrOfVisibleRows = $iLastVisibleRow - $iFirstVisibleRow + 1;
echo "First visible row is: $iFirstVisibleRow \n";
echo "Nr of visible rows: $iNrOfVisibleRows \n";
echo "--------------------\n";
}
$oWindow->connect('destroy','theend');
$oWindow->connect('delete-event','theend');
$oWindow->connect_object('check-resize', 'CalculateVisibleRows', &$oClist
);
gtk::main();
?>
--
Łukasz Wojciechowski