Games::Sudoku::Component::TkPlayer::Splashscreen - shows a splashscreen with a progress bar


Games-Sudoku-Component-TkPlayer documentation Contained in the Games-Sudoku-Component-TkPlayer distribution.

Index


Code Index:

NAME

Top

Games::Sudoku::Component::TkPlayer::Splashscreen - shows a splashscreen with a progress bar

SYNOPSIS

Top

    use Games::Sudoku::Component::TkPlayer::Selector;
    my $popup = MainWindow->Selector;
    $popup->Show;

DESCRIPTION

Top

This is an internal class.

METHODS

Top

progress

changes a value of the progress bar.

TK METHODS

Top

Consult appropriate pods for details.

Populate, Show, Hide

AUTHOR

Top

Kenichi Ishigaki, <ishigaki at cpan.org>

COPYRIGHT AND LICENSE

Top


Games-Sudoku-Component-TkPlayer documentation Contained in the Games-Sudoku-Component-TkPlayer distribution.

package Games::Sudoku::Component::TkPlayer::Splashscreen;
{
  use strict;
  use warnings;
  use Carp;

  use Tk::widgets qw/Toplevel/;
  use base qw/Tk::Toplevel/;

  Construct Tk::Widget 'Splashscreen';

  use Tk::ProgressBar;

  sub Populate {
    my $this = shift;

    $this->withdraw;
    $this->geometry('300x50+0+0');
    $this->overrideredirect(1);

    $this->SUPER::Populate(@_);

    $this->Label(
      -text => 'Loading...',
    )->pack(
      -fill => 'x',
      -expand => 1,
    );
    $this->{pbar} = $this->ProgressBar(
      -anchor => 'w',
      -colors => [0, 'blue'],
    )->pack(
      -side  => 'top',
      -fill  => 'x',
      -padx  => 10,
      -pady  => 10,
    );
  }

  sub progress {
    my ($this, $value) = @_;

    $this->{pbar}->value($value);
  }

  sub Show {
    my ($this, %args) = @_;

    $this->{pbar}->configure(
      -blocks => int($args{-max} / 5),
      -to     => $args{-max},
    );

    $this->{old_focus} = $this->focusSave;
    $this->{old_grab}  = $this->grabSave;

    $this->transient($this->Parent->toplevel);

    $this->Popup(
      -popover => $this->Parent,
      -overanchor => 'c',
      -popanchor => 'se',
    );

    $this->grab;

    if (my $focusw = $this->cget(-focus)) {
      $focusw->focus;
    }
    else {
      $this->focus;
    }
  }

  sub Hide {
    my $this = shift;

    $this->grabRelease;

    $this->{old_focus}->();
    $this->{old_grab}->();

    $this->withdraw;
  }
}

1;

__END__