Re: image viewing, geometry...



On Friday 03 May 2002 06:46 pm, eichin-gtk-perl thok org wrote:
...
      2) Is there a *symbolic* way, instead of ->[2] and ->[3], to
get the width/height out of an allocation?  Even for perl code, that's
ugly :-)
...
          $widget_x = $w->allocation->[2];
          $widget_y = $w->allocation->[3];
          print "x: $widget_x  y: $widget_y\n";
...

You can always define constants, which I do for the more common special 
integers:

use constant Gtk_true => 1;
use constant Gtk_fill => Gtk_true;
...
use constant widget_width => 2;
use constant widget_height => 3;

but keeping track of every piddly little one is a pain.

Here's what I usually do for something like this:

my ($widget_width, $widget_height) = @{$w->allocation}[2,3];

That's pretty much painless and self-documenting.

<Joe




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