File Coverage

blib/lib/Tk/Splash.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             # -*- perl -*-
2              
3             #
4             # $Id: Splash.pm,v 1.12 2005/08/25 22:15:09 eserte Exp $
5             # Author: Slaven Rezic
6             #
7             # Copyright (C) 1999,2003,2005 Slaven Rezic. All rights reserved.
8             # This package is free software; you can redistribute it and/or
9             # modify it under the same terms as Perl itself.
10             #
11             # Mail: srezic@cpan.org
12             # WWW: http://www.rezic.de/eserte/
13             #
14              
15             package Tk::Splash;
16 1     1   2269 use Tk;
  0            
  0            
17             use strict;
18             use vars qw($VERSION @ISA);
19              
20             $VERSION = 0.07;
21              
22             @ISA = qw(Tk::Widget);
23              
24             sub Show {
25             my($pkg,
26             $image_file, $image_width, $image_height, $title, $override) = @_;
27             $title = $0 if !defined $title;
28             my $splash_screen = {};
29             $splash_screen = new MainWindow;
30             $splash_screen->title($title);
31             if ($override) {
32             $splash_screen->overrideredirect(1);
33             }
34             my $splashphoto = $splash_screen->{Photo} = $splash_screen->Photo(-file => $image_file);
35             my $sw = $splash_screen->screenwidth;
36             my $sh = $splash_screen->screenheight;
37             $image_width = $splashphoto->width unless defined $image_width;
38             $splash_screen->{ImageWidth} = $image_width;
39             $image_height = $splashphoto->height unless defined $image_height;
40             $splash_screen->geometry("+" . int($sw/2 - $image_width/2) .
41             "+" . int($sh/2 - $image_height/2));
42             my $l = $splash_screen->Label(-image => $splashphoto, -bd => 0)->pack
43             (-fill => 'both', -expand => 1);
44             $splash_screen->update;
45             $splash_screen->{"Exists"} = 1;
46             bless $splash_screen, $pkg;
47             }
48              
49             sub Raise {
50             my $w = shift;
51             if ($w->{"Exists"}) {
52             Tk::catch(sub { Tk::raise($w) });
53             }
54             }
55              
56             sub Destroy {
57             my $w = shift;
58             if ($w->{Photo}) {
59             $w->{Photo}->delete;
60             undef $w->{Photo};
61             }
62             if ($w->{"Exists"}) {
63             Tk::catch(sub { Tk::destroy($w) });
64             }
65             }
66              
67             1;
68              
69             =head1 NAME
70              
71             Tk::Splash - create a splash screen
72              
73             =head1 SYNOPSIS
74              
75             BEGIN {
76             require Tk::Splash;
77             $splash = Tk::Splash->Show($image, $width, $height, $title,
78             $overrideredirect);
79             }
80             ...
81             use Tk;
82             ...
83             $splash->Destroy;
84             MainLoop;
85              
86             =head1 DESCRIPTION
87              
88             This module is another way to create a splash screen. It is slower
89             than L, but tries to be compatible by using standard
90             Tk methods for creation.
91              
92             The arguments to the B are the same as in B. For
93             further documentation, see L.
94              
95             =head1 NOTES
96              
97             Since displaying the splash screen is done during compile time, the
98             splash screen will also occur if the script is started using perl's C<-c>
99             (check) switch.
100              
101             =head1 AUTHOR
102              
103             Slaven Rezic
104              
105             =head1 SEE ALSO
106              
107             L
108              
109             =cut
110              
111             __END__