Wx-Perl-Throbber
view release on metacpan or search on metacpan
demo/main.xrc view on Meta::CPAN
</object>
</object>
<object class="sizeritem">
<object class="wxCheckBox" name="main_chk_tlabel">
<label>Show Text Label</label>
</object>
<flag>wxALL</flag>
<border>2</border>
</object>
<object class="sizeritem">
<object class="wxCheckBox" name="main_chk_overlay">
<label>Show image overlay</label>
</object>
<flag>wxALL</flag>
<border>2</border>
</object>
<object class="sizeritem">
<object class="wxCheckBox" name="main_chk_reverse">
<label>Auto-reverse</label>
</object>
<flag>wxALL</flag>
<border>2</border>
demo/throbber.pl view on Meta::CPAN
}
sub _init {
my $self = shift;
my %ctrl = (
gauge => $self -> find_window ('main_gauge'),
txt_tlabel => $self -> find_window ('main_txt_tlabel'),
spin_framedelay => $self -> find_window ('main_spin_framedelay'),
chk_tlabel => $self -> find_window ('main_chk_tlabel'),
chk_overlay => $self -> find_window ('main_chk_overlay'),
chk_reverse => $self -> find_window ('main_chk_reverse'),
btn_tlabel => $self -> find_window ('main_btn_tlabel'),
btn_start => $self -> find_window ('main_btn_start'),
btn_pause => $self -> find_window ('main_btn_pause'),
btn_stop => $self -> find_window ('main_btn_stop'),
btn_reverse => $self -> find_window ('main_btn_reverse'),
);
my $throbber_f = $self -> {throbber_frame};
my $throbber_c = $self -> {throbber_composite};
$throbber_f -> SetToolTip ('Throbber with individual frames');
$throbber_c -> SetToolTip ('Throbber using a composite bitmap');
# Load the defaults from the controls
foreach my $throbber ($throbber_f, $throbber_c) {
$throbber -> SetFrameDelay ($ctrl {spin_framedelay} -> GetValue);
$throbber -> SetLabel ($ctrl {txt_tlabel} -> GetValue);
$throbber -> ShowLabel ($ctrl {chk_tlabel} -> IsChecked);
$throbber -> SetOverlay (throbber_overlay());
$throbber -> ShowOverlay ($ctrl {chk_overlay} -> IsChecked);
$throbber -> SetAutoReverse ($ctrl {chk_reverse} -> IsChecked);
}
# Button Actions
EVT_BUTTON($self, $ctrl {btn_start},
sub {$throbber_f -> Start(); $throbber_c -> Start()});
EVT_BUTTON($self, $ctrl {btn_pause},
sub {$throbber_f -> Stop(); $throbber_c -> Stop()});
EVT_BUTTON($self, $ctrl {btn_stop},
sub {$throbber_f -> Rest(); $throbber_c -> Rest()});
demo/throbber.pl view on Meta::CPAN
EVT_CHECKBOX($self, $ctrl {chk_reverse},
sub {
$throbber_f -> SetAutoReverse($_[1]->IsChecked);
$throbber_c -> SetAutoReverse($_[1]->IsChecked);
});
EVT_CHECKBOX($self, $ctrl {chk_tlabel},
sub {
$throbber_f -> ShowLabel($_[1]->IsChecked);
$throbber_c -> ShowLabel($_[1]->IsChecked);
});
EVT_CHECKBOX($self, $ctrl {chk_overlay},
sub {
$throbber_f -> ShowOverlay($_[1]->IsChecked);
$throbber_c -> ShowOverlay($_[1]->IsChecked);
});
# Throbber Event
$ctrl {gauge} -> SetRange (100);
EVT_UPDATE_THROBBER($throbber_f, sub {$self -> ShowGauge(@_)});
}
demo/throbber.pl view on Meta::CPAN
sub throbber_composite {
my ($parent, $size) = @_;
my $bitmap_path = catfile($FindBin::RealBin, 'images');
my $bitmap = new Wx::Bitmap(catfile($bitmap_path, 'eclouds.png'),
wxBITMAP_TYPE_PNG);
return new Wx::Perl::Throbber($parent, -1, $bitmap, wxDefaultPosition,
$size, undef, 12, 48);
}
sub throbber_overlay {
my $bitmap_path = catfile($FindBin::RealBin, 'images');
my $bitmap = new Wx::Bitmap(catfile($bitmap_path, 'logo.png'),
wxBITMAP_TYPE_PNG);
}
sub ShowGauge {
my ($self, $throbber, $evt) = @_;
my $gauge = $self -> find_window ('main_gauge');
my $curval = $gauge -> GetValue() || 1;
lib/Wx/Perl/Throbber.pm view on Meta::CPAN
sub EVT_UPDATE_THROBBER { $_[0]->Connect(-1, -1, THROBBER_EVENT, $_[1]) }
sub UpdateThrobberEvent {
my $event = new Wx::PlEvent($_[0]->GetId, THROBBER_EVENT);
}
sub new {
my $class = shift;
my ($parent, $id, $bitmap, $pos, $size, $frameDelay, $frames, $framesWidth,
$label, $overlay, $reverse, $style, $name) = @_;
$id = '-1' unless defined $id;
$name = 'throbber' unless defined $name;
$pos = wxDefaultPosition unless defined $pos;
$size = wxDefaultSize unless defined $size;
$label = '' unless defined $label;
$reverse = 0 unless defined $reverse;
my $self = $class -> SUPER::new ($parent, $id, $pos, $size, $style, $name);
$self -> SetClientSize ($size);
$self -> SetFrameDelay ($frameDelay ? $frameDelay : DFLT_FRAMEDELAY);
$self -> SetAutoReverse ($reverse);
if (defined $bitmap) {
$self -> SetBitmap ($bitmap, $frames, $framesWidth);
$self -> SetLabel ($label) if defined $label;
$self -> SetOverlay ($overlay) if defined $overlay;
$self -> ShowLabel (defined $label);
}
$self -> _init($reverse, defined $label);
EVT_UPDATE_THROBBER ($self, \&Rotate);
EVT_PAINT ($self, \&OnPaint);
EVT_TIMER ($self, $self -> {timerID}, \&OnTimer);
bless $self, $class;
}
lib/Wx/Perl/Throbber.pm view on Meta::CPAN
sub Draw {
my $self = shift;
my ($dc) = @_;
$dc -> DrawBitmap (
$self -> {submaps} [$self -> {current}],
0,
0,
1
);
if ($self -> {overlay} && $self -> {showOverlay}) {
$dc->DrawBitmap (
$self -> {overlay},
$self -> {overlayX},
$self -> {overlayY},
1
);
}
if ($self -> {label} && $self -> {showLabel}) {
$dc->DrawText (
$self -> {label},
$self -> {labelX},
$self -> {labelY}
);
$dc->SetTextForeground (wxWHITE);
lib/Wx/Perl/Throbber.pm view on Meta::CPAN
return 1;
}
sub GetAutoReverse {
my $self = shift;
return $self -> {autoReverse};
}
sub SetOverlay {
my $self = shift;
my $overlay = shift;
croak "SetOverlay: requires a bitmap"
unless ref $overlay && UNIVERSAL::isa($overlay, 'Wx::Bitmap');
return unless $self -> {sequence} && scalar $self -> {sequence};
if ($overlay) {
$self -> {overlay} = $overlay;
$self -> {overlayX} = int(($self->{width} - $overlay -> GetWidth)/2);
$self -> {overlayY} = int(($self->{height} - $overlay -> GetHeight)/2);
return 1;
}
}
sub GetOverlay {
my $self = shift;
return unless $self -> {overlay};
return new Wx::Bitmap ($self -> {overlay});
}
sub ShowOverlay {
my $self = shift;
my ($state) = @_;
$self -> {showOverlay} = not (defined $state && !$state);
$self -> Draw(new Wx::ClientDC($self));
return 1;
}
lib/Wx/Perl/Throbber.pm view on Meta::CPAN
unless ref $font && UNIVERSAL::isa($font, 'Wx::Font');
$self -> SetFont ($font);
$self -> SetLabel ($self -> {label});
$self -> Draw(new Wx::ClientDC($self));
return 1;
}
# Private
# Set the bitmap with and size (for use by overlay/label)
sub _set_bitmap_size {
my $self = shift;
my ($bitmap, $framesWidth) = @_;
my ($width, $height) = $self -> GetSizeWH();
if ($width == -1) {
if (ref $bitmap && ref $bitmap eq 'ARRAY') {
$width = $bitmap -> [0] -> GetWidth;
} else {
$width = $framesWidth ? $framesWidth : $width
lib/Wx/Perl/Throbber.pm view on Meta::CPAN
etc. Useful for showing an ongoing process (like most web browsers use) or
simply for adding eye-candy to an application.
Throbbers utilize a Wx::Timer so that normal processing can continue
unencumbered.
=head1 METHODS
=over 4
=item $throbber = new($parent, $id, $bitmap, $position, $size, $frameDelay, $frames, $framesWidth, $label, $overlay, $reverse, $style, $name)
$parent (parent window)
$id = -1 (window identifier)
$bitmap = undef (throbber bitmap. see SetBitmap())
$position = wxDefaultPosition (window position)
$size = wxDefaultSize (window size)
$frameDelay = 75 (milliseconds. See SetFrameDelay)
$frames = undef (number of frames. see SetBitmap())
$framesWidth = undef (width of frames. see SetBitmap())
$label = '' (text label. see SetLabel())
$overlay = undef (overlay bitmap. see SetOverlay())
$reverse = 0 (auto-reverse)
$style = undef (window style)
$name = "throbber" (window name)
=item SetBitmap($bitmap, $frames, $framesWidth)
C<$bitmap> is either a single C<Wx::Bitmap> that will be split into frames (a
composite image) or a list of C<Wx::Bitmap> objects that will be treated as
individual frames.
lib/Wx/Perl/Throbber.pm view on Meta::CPAN
Turn on/off auto-reverse. When auto-reverse is set, the throbber will change
direction when it reaches the start/end of the animation. Otherwise it jumps
back to the beginning.
=item GetAutoReverse()
Get the auto-reverse state
=item SetOverlay($bitmap)
Sets an overlay bitmap to be displayed above the throbber animation
=item GetOverlay()
Returns a copy of the overlay bitmap set for the throbber
=item ShowOverlay($state)
Set true/false whether the overlay bitmap is shown
=item SetLabel($label)
Set the text of the label. The text label appears above the throbber animation
and overlay (if applicable)
=item GetLabel()
Returns the label set for the throbber
=item ShowLabel($state)
Set true/false whether the text label is shown
=item SetFont ($font)
( run in 0.545 second using v1.01-cache-2.11-cpan-3b35f9de6a3 )