Add libwx-perl
[pkg-perl] / deb-src / libwx-perl / libwx-perl-0.96 / blib / lib / Wx / Perl / SplashFast.pm
1 #############################################################################
2 ## Name:        ext/pperl/splashfast/SplashFast.pm
3 ## Purpose:     Wx::Perl::SplashFast -> Show a splash before loading Wx.
4 ## Author:      Graciliano M. P.
5 ## Modified by:
6 ## Created:     30/06/2002
7 ## RCS-ID:      $Id: SplashFast.pm 2723 2009-12-25 17:35:15Z mbarbon $
8 ## Copyright:   (c) 2002-2006, 2009 Graciliano M. P.
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 use strict;
14
15 package Wx::Perl::SplashFast ;
16 use vars qw($VERSION) ;
17
18 $VERSION = '0.02'; # for wxPerl 0.15+
19
20 sub import {
21   Wx::Perl::SplashFast::new(@_) if @_ > 1;
22 }
23
24 sub new {
25   my $class = shift;
26
27   Wx::Perl::SplashFast::App->new() ;
28   Wx::InitAllImageHandlers() ;
29
30   my $dummy;
31   my $any = Wx::constant( 'wxBITMAP_TYPE_ANY', 0, $dummy );
32   my $spl_c = Wx::constant( 'wxSPLASH_CENTRE_ON_SCREEN', 0, $dummy );
33   my $spl_ti = Wx::constant( 'wxSPLASH_TIMEOUT', 0, $dummy );
34   my $bitmap = Wx::Bitmap->new( $_[0], $any );
35
36   my $splash = Wx::SplashScreen->new( $bitmap , $spl_c|$spl_ti ,
37                                       $_[1] || 1000 , undef , -1 );
38
39   return $splash ;
40 }
41
42 ###################
43 # SPLASHFAST::APP #
44 ###################
45
46 # Ghost package for your APP.
47 use Wx::App;
48 package Wx::Perl::SplashFast::App ;
49 use vars qw(@ISA) ;
50 @ISA = qw(Wx::App) ;
51
52 sub OnInit { return 1 }
53
54 ###############################################################################
55 ## WX BASICS: #################################################################
56 ###############################################################################
57
58 use Wx::Mini;
59
60 Wx::_start();
61
62 #######
63 # END #
64 #######
65
66 1;
67
68 __END__
69
70 =head1 NAME
71
72 Wx::Perl::SplashFast - Fast splash screen for the Wx module.
73
74 =head1 SYNOPSIS
75
76   use Wx::Perl::SplashFast ('/path/to/logo.jpg',3000);
77   # timeout in milliseconds
78
79   package myApp ;
80   # subclass Wx::App ...
81
82   package myFrame;
83   # subclass Wx::Frame ...
84
85   package main;
86
87   my $myApp = myApp->new();
88   my $frame = myFrame->new();
89
90   $myApp->MainLoop();
91
92
93 =head1 DESCRIPTION
94
95 Using Wx::SplashScreen from Wx::App::OnInit may cause a high delay
96 before the splash screen is shown on low end machines.
97
98 This module works around this limitation; you just need to follow the
99 example.
100
101 =head1 USAGE
102
103 Just put the code inside the 'BEGIN {}' of your main app, like:
104
105   sub BEGIN {
106     use Wx::Perl::SplashFast ;
107     Wx::Perl::SplashFast->new("./logo.jpg",5000);
108   }
109
110 or load the module before any other:
111
112   use Wx::Perl::SplashFast ("./logo.jpg",5000) ;
113   use Wx ;
114   ...
115
116 =head2 import ( IMG_FILE, SPLASH_TIMEOUT )
117
118 =over 10
119
120 =item IMG_FILE
121
122 Path of the image file to show.
123
124 =item SPLASH_TIMEOUT
125
126 Timeout of the splash screen in milliseconds.
127
128 =back
129
130 If you C<use Wx::Perl::SplashFast './logo.jpg', 1000;> this has the same
131 affetc as.
132
133   BEGIN {
134     require Wx::Perl::SplashFast;
135     Wx::Perl::SplashFast->new( './logo.jpg', 1000 );
136   }
137
138 =head2 new ( IMG_FILE , SPLASH_TIMEOUT )
139
140 Show the splash screen.
141
142 =over 10
143
144 =item IMG_FILE
145
146 Path of the image file to show.
147
148 =item SPLASH_TIMEOUT
149
150 Timeout of the splash screen in milliseconds.
151
152 =back
153
154 =head1 EXAMPLE
155
156   use Wx::Perl::SplashFast ("./logo.jpg",5000) ;
157   # Don't forget to put your own image in the same path. Duh
158
159   package myApp ;
160   use base 'Wx::App';
161   sub OnInit { return(@_[0]) ;}
162
163   package myFrame ;
164   use base 'Wx::Frame';
165   use Wx qw( wxDEFAULT_FRAME_STYLE );
166
167   sub new {
168     my $app = shift ;
169     my( $frame ) = $app->SUPER::new( @_[0] , -1, 'wxPerl Test' ,
170                                      [0,0] , [400,300] ) ;
171     return( $frame ) ;
172   }
173
174   package main ;
175   use Wx ;
176
177   my $myApp = myApp->new() ;
178
179   print "window\n" ;
180   my $win = myFrame->new() ;
181   $win->Show(1) ;
182
183   $myApp->SetTopWindow( $win ) ;
184   $myApp->MainLoop();
185
186 =head1 SEE ALSO
187
188 L<Wx>, L<Wx:SplashScreen>
189
190 =head1 AUTHOR
191
192 Graciliano M. P. <gm@virtuasites.com.br>
193 Thanks to wxWidgets people and Mattia Barbon for wxPerl! :P
194
195 =head1 COPYRIGHT
196
197 This program is free software; you can redistribute it and/or
198 modify it under the same terms as Perl itself.
199
200 =cut
201
202 # Local variables: #
203 # mode: cperl #
204 # End: #