1 #############################################################################
2 ## Name: ext/pperl/splashfast/SplashFast.pm
3 ## Purpose: Wx::Perl::SplashFast -> Show a splash before loading Wx.
4 ## Author: Graciliano M. P.
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 #############################################################################
15 package Wx::Perl::SplashFast ;
16 use vars qw($VERSION) ;
18 $VERSION = '0.02'; # for wxPerl 0.15+
21 Wx::Perl::SplashFast::new(@_) if @_ > 1;
27 Wx::Perl::SplashFast::App->new() ;
28 Wx::InitAllImageHandlers() ;
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 );
36 my $splash = Wx::SplashScreen->new( $bitmap , $spl_c|$spl_ti ,
37 $_[1] || 1000 , undef , -1 );
46 # Ghost package for your APP.
48 package Wx::Perl::SplashFast::App ;
52 sub OnInit { return 1 }
54 ###############################################################################
55 ## WX BASICS: #################################################################
56 ###############################################################################
72 Wx::Perl::SplashFast - Fast splash screen for the Wx module.
76 use Wx::Perl::SplashFast ('/path/to/logo.jpg',3000);
77 # timeout in milliseconds
80 # subclass Wx::App ...
83 # subclass Wx::Frame ...
87 my $myApp = myApp->new();
88 my $frame = myFrame->new();
95 Using Wx::SplashScreen from Wx::App::OnInit may cause a high delay
96 before the splash screen is shown on low end machines.
98 This module works around this limitation; you just need to follow the
103 Just put the code inside the 'BEGIN {}' of your main app, like:
106 use Wx::Perl::SplashFast ;
107 Wx::Perl::SplashFast->new("./logo.jpg",5000);
110 or load the module before any other:
112 use Wx::Perl::SplashFast ("./logo.jpg",5000) ;
116 =head2 import ( IMG_FILE, SPLASH_TIMEOUT )
122 Path of the image file to show.
126 Timeout of the splash screen in milliseconds.
130 If you C<use Wx::Perl::SplashFast './logo.jpg', 1000;> this has the same
134 require Wx::Perl::SplashFast;
135 Wx::Perl::SplashFast->new( './logo.jpg', 1000 );
138 =head2 new ( IMG_FILE , SPLASH_TIMEOUT )
140 Show the splash screen.
146 Path of the image file to show.
150 Timeout of the splash screen in milliseconds.
156 use Wx::Perl::SplashFast ("./logo.jpg",5000) ;
157 # Don't forget to put your own image in the same path. Duh
161 sub OnInit { return(@_[0]) ;}
164 use base 'Wx::Frame';
165 use Wx qw( wxDEFAULT_FRAME_STYLE );
169 my( $frame ) = $app->SUPER::new( @_[0] , -1, 'wxPerl Test' ,
170 [0,0] , [400,300] ) ;
177 my $myApp = myApp->new() ;
180 my $win = myFrame->new() ;
183 $myApp->SetTopWindow( $win ) ;
188 L<Wx>, L<Wx:SplashScreen>
192 Graciliano M. P. <gm@virtuasites.com.br>
193 Thanks to wxWidgets people and Mattia Barbon for wxPerl! :P
197 This program is free software; you can redistribute it and/or
198 modify it under the same terms as Perl itself.