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

Re: Gnome2::Canvas --> do I really need to worry about pixels_per_unit?



On Mon, 23 Jun 2008 11:18:57 -0700
walt <w41ter gmail com> wrote:

>zentara wrote:
>> On Sun, 22 Jun 2008 20:20:33 -0700
>> walt<w41ter gmail com>  wrote:
>>
>>> ...
>>> The problem is that the vertical scroll region will just ignore
>>> any height value below some arbitrary limit.
>>> ...
>
>> Could you post a small example where the data point can't
>> be scrolled to, and the "arbitrary limit" is hit?
>>
>> It sounds to me like you have a predefined size set somewhere,
>> like a set_default_size in your mainwindow, or something.
>>
>> I just posted a similar question recently, where my coordinates
>> seemed way off, and I couldn't explain it..... I figured it out as follows
>>
>> ################################
>> Doh!!!  Sorry I see the mistake. If the scrollregion is smaller than the default
>> canvas size, weird coordinate transforms occur. Maybe a bug?
>>
>> $scroller->add( $canvas );
>> $window->add( $scroller );
>> $window->set_default_size( 500, 500 );
>>
>> #if scrollregion is smaller than default size, odd
>> # coordinate problems occur
>> #$canvas->set_scroll_region( 0, 0, 400, 400 ); #bad
>>
>> $canvas->set_scroll_region( 0, 0, 700, 700 );   #good and works fine
>>
>> It would be a good "trick" question to throw at someone. :-)
>> ########################################
>>
>>
>> See if that is it, otherwise post a minimal example.
>
>My example is very similar to yours, but the numbers are smaller to show
>the problem in an exaggerated way:
>
>my $line = Gnome2::Canvas::Item->new
>                             (
>                             $root,
>                              'Gnome2::Canvas::Line',
>                              points=> [0,0,50,50],
>                              width_pixels=> 1,
>                              fill_color => 'black',
>                              line_style => 'solid'
>                             );
>
>$window->set_default_size (500, 500);
>$canvas->set_scroll_region(0,0,50,50);
>
>my @region = $canvas->get_scroll_region;
>print "@region\n";


Didn't you read the code fragment I sent?

>> $window->set_default_size( 500, 500 );
>>
>> #if scrollregion is smaller than default size, odd
>> # coordinate problems occur
>> #$canvas->set_scroll_region( 0, 0, 400, 400 ); #bad
>>
>> $canvas->set_scroll_region( 0, 0, 700, 700 );   #good and works fine
>>

Your scroll region 50,50 is less than 500,500 so a weird
coordinate transform occurs. 

Either make sure your scroll_region is greater than the default_size
OR
don't use default_size, try set_size
$window->set_size_request(300,200);

set_default_size is very strong, and usually not wanted.  


zentara





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


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