Tk::Calculator::RPN::HP contains Hewlett-Packard RPN calculators.
SYNOPSIS
use Tk::Calculator::RPN::HP;
$mw->Calculator(
-type => '21' | '16c'
)->pack;
Tk::Calculator::RPN::HP is the OO base class and Exporter module for Perl/Tk Hewlett-Packard Reverse Polish Notation (RPN) calculators. As a base class it provides methods common to all calculators; for instance, stack manipulation, function evaluation, and instance creation activities. As an exporter of data, it provides global variables and function subroutine definitions.
Tk::Calculator::RPN::HP provides a single constructor, Calculator, as shown in the SYNOPSIS section.
Tk::Calculator::RPN::HP provides a Populate method implicity used by all calculator subclasses. The only option that Populate requires is -type, the type of calculator. Given -type, Populate loads the appropriate module, performs common instance pre-initialization, and then calls out to the subclass' Populate method to create the actual calculator.
Subclasses of Tk::Calculator::RPN::HP have this basic structure:
$Tk::Calculator::RPN::HP_21::VERSION = '1.2';
package Tk::Calculator::RPN::HP_21;
use Tk::widgets qw/SlideSwitch/;
use Tk::Calculator::RPN::HP;
use base qw/Tk::Calculator::RPN::HP/;
use strict;
our $HELP;
sub ClassInit {
my ($class, $mw) = @_;
$HELP = $class->build_help_window($mw);
$class->SUPER::ClassInit($mw);
} # end ClassInit
sub Populate {
my ($self, $args) = @_;
...
$self->build_help_button($frame1, $HELP)->pack(qw/-side left/);
...
} # end Populate
# Function key processors.
sub clxclr {
my ($self) = @_;
return unless $self->{ONOFF};
if ($self->{G_PRESSED}) { # clr
$self->clr;
} else { # clx
$self->clx;
}
} # end clxclr
1;
As you can see, the module is simply a standard Perl/Tk mega-widget.
You are required to invoke two methods, build_help_window and build_help_button. build_help_window creates a Toplevel that's exposed when the ? Button is pressed. build_help_button builds the ? Button proper. Because the Toplevel help window is used by all class instances, it's typically created in ClassInit. You call build_help_button when and where you want the ? packed.
Although most calculator functions are provided by the base class, you may find it necessary to write your own function key processors.
Product's homepage
Requirements:
· Perl