Re: Graphical glitch in a scrolled window



On Sun, 27 Jul 2008 15:02:27 +0200
Tian <tian-ml c-sait net> wrote:

Hello,

I have a quiet weird problem. I have a VBox in a ScrolledWindow. I want to
have a background picture there. And I am packing some images in the VBox.
These images are made by compositing the background with other pictures. If
you want to see what it is used for, check that screenshot :

http://www.gcstar.org/images/screenshots/MoviesGlass.png


Hi, I will report that scrolling works good if placed on a Gnome2::Canvas,
rather than a vbox, but you do get the luxury of specifying exact x any y
positions.

#!/usr/bin/perl
use warnings;
use strict;
use Gtk2 -init;
use Gnome2::Canvas;

my $window = Gtk2::Window->new;
$window ->signal_connect( 'destroy' => sub{Gtk2->main_quit } );
my $scroller = Gtk2::ScrolledWindow->new;

my $canvas = Gnome2::Canvas->new();
my $white = Gtk2::Gdk::Color->new (0xFF00,0xFF00,0xFF00);
$canvas->modify_bg('normal',$white);
$canvas->set_center_scroll_region (0);
my $root = $canvas->root;

my $im = Gtk2::Gdk::Pixbuf->new_from_file('./bg.png');
my $w = $im->get_width;
my $h = $im->get_height;

my $x = 0;
my $y = 0;

foreach (1..200){
 my $image = Gnome2::Canvas::Item->new ($root,
       'Gnome2::Canvas::Pixbuf',
       pixbuf => $im,
       x      => $x ,
       y      => $y,
       width  => $w,
       height => $h,
       anchor => 'nw',
 );

  Gnome2::Canvas::Item->new ($root, 
   'Gnome2::Canvas::Text',
    x => $x + $w/2,
    y => $y,
    fill_color => 'black',
   font => 'Sans 18',
   anchor => 'GTK_ANCHOR_NW',
   text => $_);

 $y += $h;

}

$scroller->add ($canvas);
$window->add ($scroller);
$window->set_default_size (350, 350);
$canvas->set_scroll_region (0, 0, $x, 200*$h);
$window->show_all;

Gtk2->main;
__END__


zentara

-- 
I'm not really a human, but I play one on earth.
http://zentara.net/Remember_How_Lucky_You_Are.html 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]