line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2007, 2008, 2009, 2010, 2011, 2012 Kevin Ryde |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# This file is part of Gtk2-Ex-WidgetBits. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Gtk2-Ex-WidgetBits is free software; you can redistribute it and/or |
6
|
|
|
|
|
|
|
# modify it under the terms of the GNU General Public License as published |
7
|
|
|
|
|
|
|
# by the Free Software Foundation; either version 3, or (at your option) any |
8
|
|
|
|
|
|
|
# later version. |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Gtk2-Ex-WidgetBits is distributed in the hope that it will be useful, |
11
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
13
|
|
|
|
|
|
|
# Public License for more details. |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License along |
16
|
|
|
|
|
|
|
# with Gtk2-Ex-WidgetBits. If not, see . |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package Gtk2::Ex::GdkBits; |
19
|
2
|
|
|
2
|
|
37942
|
use 5.008; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
97
|
|
20
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
69
|
|
21
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
72
|
|
22
|
2
|
|
|
2
|
|
12
|
use Carp; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
197
|
|
23
|
2
|
|
|
2
|
|
18
|
use List::Util 'min'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
232
|
|
24
|
2
|
|
|
2
|
|
2969
|
use Gtk2; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use Exporter; |
27
|
|
|
|
|
|
|
our @ISA = ('Exporter'); |
28
|
|
|
|
|
|
|
our @EXPORT_OK = qw(draw_rectangle_corners |
29
|
|
|
|
|
|
|
window_get_root_position |
30
|
|
|
|
|
|
|
window_clear_region); |
31
|
|
|
|
|
|
|
our $VERSION = 48; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# The loop here is similar to what gtk_widget_translate_coordinates() does |
35
|
|
|
|
|
|
|
# chasing up through window ancestors. |
36
|
|
|
|
|
|
|
# |
37
|
|
|
|
|
|
|
sub window_get_root_position { |
38
|
|
|
|
|
|
|
my ($window) = @_; |
39
|
|
|
|
|
|
|
my $x = 0; |
40
|
|
|
|
|
|
|
my $y = 0; |
41
|
|
|
|
|
|
|
while ($window->get_window_type ne 'root') { |
42
|
|
|
|
|
|
|
my ($parent_x, $parent_y) = $window->get_position; |
43
|
|
|
|
|
|
|
$x += $parent_x; |
44
|
|
|
|
|
|
|
$y += $parent_y; |
45
|
|
|
|
|
|
|
$window = $window->get_parent |
46
|
|
|
|
|
|
|
|| croak 'Gtk2::Ex::GdkBits::window_get_root_position(): oops, didn\'t reach root window'; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
return ($x, $y); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub window_clear_region { |
52
|
|
|
|
|
|
|
my ($win, $region) = @_; |
53
|
|
|
|
|
|
|
foreach my $rect ($region->get_rectangles) { |
54
|
|
|
|
|
|
|
$win->clear_area ($rect->values); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub draw_rectangle_corners { |
59
|
|
|
|
|
|
|
my ($drawable, $gc, $filled, $x1,$y1, $x2,$y2) = @_; |
60
|
|
|
|
|
|
|
#### draw rect: "$x1,$y1 - $x2,$y2" |
61
|
|
|
|
|
|
|
$drawable->draw_rectangle ($gc, $filled, |
62
|
|
|
|
|
|
|
min ($x1, $x2), |
63
|
|
|
|
|
|
|
min ($y1, $y2), |
64
|
|
|
|
|
|
|
abs ($x1 - $x2) + ($filled ? 1 : 0), |
65
|
|
|
|
|
|
|
abs ($y1 - $y2) + ($filled ? 1 : 0)); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Not yet documented, might move elsewhere ... |
69
|
|
|
|
|
|
|
# Or maybe better $rect->intersect not undef ... |
70
|
|
|
|
|
|
|
sub rect_contains_rect { |
71
|
|
|
|
|
|
|
my ($rect, $part) = @_; |
72
|
|
|
|
|
|
|
return $rect->x <= $part->x |
73
|
|
|
|
|
|
|
&& $rect->y <= $part->y |
74
|
|
|
|
|
|
|
&& $rect->x + $rect->width >= $part->x + $part->width |
75
|
|
|
|
|
|
|
&& $rect->y + $rect->height >= $part->y + $part->height; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
__END__ |