| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
############################################################################# |
|
2
|
|
|
|
|
|
|
## Name: lib/Wx/DemoModules/lib/Utility.pm |
|
3
|
|
|
|
|
|
|
## Purpose: wxPerl demo helper |
|
4
|
|
|
|
|
|
|
## Author: Mattia Barbon |
|
5
|
|
|
|
|
|
|
## Modified by: |
|
6
|
|
|
|
|
|
|
## Created: 03/12/2006 |
|
7
|
|
|
|
|
|
|
## RCS-ID: $Id: Utility.pm 2772 2010-02-01 14:23:16Z mdootson $ |
|
8
|
|
|
|
|
|
|
## Copyright: (c) 2006 Mattia Barbon |
|
9
|
|
|
|
|
|
|
## Licence: This program is free software; you can redistribute it and/or |
|
10
|
|
|
|
|
|
|
## modify it under the same terms as Perl itself |
|
11
|
|
|
|
|
|
|
############################################################################# |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package Wx::DemoModules::lib::Utility; |
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
29
|
|
|
16
|
1
|
|
|
1
|
|
4
|
use base qw(Exporter); # for Perl 5.8.1 or earlier |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
222
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our @EXPORT = qw(resize_to); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub resize_to { |
|
21
|
0
|
|
|
0
|
0
|
|
my( $image, $size ) = @_; |
|
22
|
|
|
|
|
|
|
# seems not to work on Mac |
|
23
|
0
|
0
|
|
|
|
|
return $image if Wx::wxMAC(); |
|
24
|
0
|
0
|
0
|
|
|
|
if( $image->GetWidth != $size || $image->GetHeight != $size ) { |
|
25
|
0
|
|
|
|
|
|
return Wx::Bitmap->new |
|
26
|
|
|
|
|
|
|
( Wx::Image->new( $image )->Rescale( $size, $size ) ); |
|
27
|
|
|
|
|
|
|
} else { |
|
28
|
0
|
|
|
|
|
|
return $image; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |