Leser: 2
8 Einträge, 1 Seite |
my $geom = $Konfig{canvas}->geometry();
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
=item get_corners Return the corners of the visible part of the canvas as a list: (minx, miny, maxx, maxy). This will not work if the scrollregion is smaller than the visible region. =cut sub get_corners { my $c = shift; $c->view_to_coords($c->xview, $c->yview); } =item view_to_coords($xv1,$xv2,$yv1,$yv2) Convert the result of xview/yview to coordinates. See comment in C<get_corners>. The result is the list ($x1,$y1,$x2,$y2). (Please note that the order is not the same as in the argument list! This is too make it easier to pass the arguments from xview and yview and to use the result in a scrollregion configuration.) =cut sub view_to_coords { my($c,$xv1,$xv2,$yv1,$yv2) = @_; my(@scrollregion) = ($Tk::VERSION == 800.017 ? $c->cget(-scrollregion) : @{$c->cget(-scrollregion)}); my $width = ($scrollregion[2]-$scrollregion[0]); my $height = ($scrollregion[3]-$scrollregion[1]); ($xv1 * $width + $scrollregion[0], $yv1 * $height + $scrollregion[1], $xv2 * $width + $scrollregion[0], $yv2 * $height + $scrollregion[1], ); }
8 Einträge, 1 Seite |