3
BEGIN { $^W= 1; $| = 1; print "1..6\n"; }
4
END {print "not ok 1\n" unless $loaded;}
8
print "ok " . $ok++ . "\n";
10
######################################################################
11
# This test script defines a new NumEntry class, consisting of new
12
# FireButton and NumEntryPlain classes.
14
# The MyFireButton class replaces the increment and decrement pictures
15
# with some predefined Tk bitmaps.
17
# The MyNumEntryPlain class adds new key events: Prior and Next for
18
# fast keyboard spinning and Home to reset to the default value.
20
######################################################################
21
# define own FireButton class
22
package Tk::MyFireButton;
23
use base qw(Tk::FireButton);
24
Construct Tk::Widget "MyFireButton";
26
sub INCBITMAP { "error" }
27
sub DECBITMAP { "gray75" }
28
sub HORIZINCBITMAP { "gray50" }
29
sub HORIZDECBITMAP { "gray25" }
31
######################################################################
32
# define own NumEntryPlain class
33
package Tk::MyNumEntryPlain;
34
use base qw(Tk::NumEntryPlain);
35
Construct Tk::Widget "MyNumEntryPlain";
39
$class->SUPER::ClassInit($mw);
40
$mw->bind($class, '<Shift-Prior>', 'Up10');
41
$mw->bind($class, '<Shift-Next>', 'Down10');
42
$mw->bind($class, '<Shift-Home>', 'Set0');
45
sub Set0 { my $w = shift;
46
$w->_parent->value($w->cget(-defaultvalue));
48
sub Up10 { shift->_parent->incdec(10,'initial') }
49
sub Down10 { shift->_parent->incdec(-10,'initial') }
52
######################################################################
53
# define own NumEntry class
54
package Tk::MyNumEntry;
55
use base qw(Tk::NumEntry);
56
Construct Tk::Widget "MyNumEntry";
58
sub FireButtonWidget { "MyFireButton" }
59
sub NumEntryPlainWidget { "MyNumEntryPlain" }
61
######################################################################
65
my $top = new MainWindow;
68
$ne = $top->MyNumEntry(-defaultvalue => 42,
69
-increment => '1.0')->pack;
71
if ($@) { print "not " } print "ok " . $ok++ . "\n";
74
$top->MyNumEntry(-orient => "horizontal",
75
-defaultvalue => 4711,
79
-bigincrement => 50)->pack;
81
if ($@) { print "not " } print "ok " . $ok++ . "\n";
83
$ne->configure(-value => 1);
84
if ($ne->cget(-value) != 1) { print "not " } print "ok " . $ok++ . "\n";
87
if ($ne->cget(-value) != 2) { print "not " } print "ok " . $ok++ . "\n";
90
if ($ne->cget(-value) != 1) { print "not " } print "ok " . $ok++ . "\n";