line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tk::HexEntry; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2032
|
use Tk (); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use Tk::Frame; |
5
|
|
|
|
|
|
|
use Tk::Derived; |
6
|
|
|
|
|
|
|
use strict; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use vars qw(@ISA $VERSION); |
9
|
|
|
|
|
|
|
@ISA = qw(Tk::Derived Tk::Frame); |
10
|
|
|
|
|
|
|
$VERSION = sprintf("%d.%02d", q$Revision: 0.01 $ =~ /(\d+)\.(\d+)/); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Construct Tk::Widget 'HexEntry'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
{ my $foo = $Tk::FireButton::INCBITMAP; |
15
|
|
|
|
|
|
|
$foo = $Tk::FireButton::DECBITMAP; # peacify -w |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub Populate { |
19
|
|
|
|
|
|
|
my($f,$args) = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
require Tk::FireButton; |
22
|
|
|
|
|
|
|
require Tk::HexEntryPlain; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $orient = delete $args->{-orient} || "vertical"; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $readonly = delete $args->{-readonly}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $e = $f->Component( $f->HexEntryPlainWidget => 'entry', |
29
|
|
|
|
|
|
|
-borderwidth => 0, |
30
|
|
|
|
|
|
|
-highlightthickness => 0, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
if ($readonly) { |
33
|
|
|
|
|
|
|
$e->bindtags([]); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $binc = $f->Component( $f->IncFireButtonWidget() => 'inc', |
37
|
|
|
|
|
|
|
-command => sub { $e->incdec($e->cget(-increment)) }, |
38
|
|
|
|
|
|
|
-takefocus => 0, |
39
|
|
|
|
|
|
|
-highlightthickness => 0, |
40
|
|
|
|
|
|
|
-anchor => 'center', |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
$binc->configure(-bitmap => ($orient =~ /^vert/ |
43
|
|
|
|
|
|
|
? $binc->INCBITMAP |
44
|
|
|
|
|
|
|
: $binc->HORIZINCBITMAP |
45
|
|
|
|
|
|
|
) |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $bdec = $f->Component( $f->DecFireButtonWidget() => 'dec', |
49
|
|
|
|
|
|
|
-command => sub { $e->incdec(- $e->cget(-increment)) }, |
50
|
|
|
|
|
|
|
-takefocus => 0, |
51
|
|
|
|
|
|
|
-highlightthickness => 0, |
52
|
|
|
|
|
|
|
-anchor => 'center', |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
$bdec->configure(-bitmap => ($orient =~ /^vert/ |
55
|
|
|
|
|
|
|
? $bdec->DECBITMAP |
56
|
|
|
|
|
|
|
: $bdec->HORIZDECBITMAP |
57
|
|
|
|
|
|
|
) |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$f->gridColumnconfigure(0, -weight => 1); |
61
|
|
|
|
|
|
|
$f->gridColumnconfigure(1, -weight => 0); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$f->gridRowconfigure(0, -weight => 1); |
64
|
|
|
|
|
|
|
$f->gridRowconfigure(1, -weight => 1); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
if ($orient eq 'vertical') { |
67
|
|
|
|
|
|
|
$binc->grid(-row => 0, -column => 1, -sticky => 'news'); |
68
|
|
|
|
|
|
|
$bdec->grid(-row => 1, -column => 1, -sticky => 'news'); |
69
|
|
|
|
|
|
|
} else { |
70
|
|
|
|
|
|
|
$binc->grid(-row => 0, -column => 2, -sticky => 'news'); |
71
|
|
|
|
|
|
|
$bdec->grid(-row => 0, -column => 1, -sticky => 'news'); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$e->grid(-row => 0, -column => 0, -rowspan => 2, -sticky => 'news'); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
$f->ConfigSpecs( |
77
|
|
|
|
|
|
|
-borderwidth => ['SELF' => "borderWidth", "BorderWidth", 2 ], |
78
|
|
|
|
|
|
|
-relief => ['SELF' => "relief", "Relief", "sunken" ], |
79
|
|
|
|
|
|
|
-background => ['CHILDREN' => "background", "Background", Tk::NORMAL_BG ], |
80
|
|
|
|
|
|
|
-foreground => ['CHILDREN' => "background", "Background", Tk::BLACK ], |
81
|
|
|
|
|
|
|
-buttons => ['METHOD' => undef, undef, 1 ], |
82
|
|
|
|
|
|
|
-state => ['CHILDREN' => "state", "State", "normal" ], |
83
|
|
|
|
|
|
|
-repeatdelay => [[$binc,$bdec] |
84
|
|
|
|
|
|
|
=> "repeatDelay", "RepeatDelay", 300 ], |
85
|
|
|
|
|
|
|
-repeatinterval |
86
|
|
|
|
|
|
|
=> [[$binc,$bdec] |
87
|
|
|
|
|
|
|
=> "repeatInterval", |
88
|
|
|
|
|
|
|
"RepeatInterval", |
89
|
|
|
|
|
|
|
100 ], |
90
|
|
|
|
|
|
|
-highlightthickness |
91
|
|
|
|
|
|
|
=> [SELF => "highlightThickness", |
92
|
|
|
|
|
|
|
"HighlightThickness", |
93
|
|
|
|
|
|
|
2 ], |
94
|
|
|
|
|
|
|
DEFAULT => [$e], |
95
|
|
|
|
|
|
|
); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
$f->Delegates(DEFAULT => $e); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$f; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub HexEntryPlainWidget { "HexEntryPlain" } |
103
|
|
|
|
|
|
|
sub FireButtonWidget { "FireButton" } |
104
|
|
|
|
|
|
|
sub IncFireButtonWidget { shift->FireButtonWidget } |
105
|
|
|
|
|
|
|
sub DecFireButtonWidget { shift->FireButtonWidget } |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub buttons { |
108
|
|
|
|
|
|
|
my $f = shift; |
109
|
|
|
|
|
|
|
my $var = \$f->{Configure}{'-buttons'}; |
110
|
|
|
|
|
|
|
my $old = $$var; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
if(@_) { |
113
|
|
|
|
|
|
|
my $val = shift; |
114
|
|
|
|
|
|
|
$$var = $val ? 1 : 0; |
115
|
|
|
|
|
|
|
my $e = $f->Subwidget('entry'); |
116
|
|
|
|
|
|
|
my %info = $e->gridInfo; $info{'-sticky'} = 'news'; |
117
|
|
|
|
|
|
|
delete $info{' -sticky'}; |
118
|
|
|
|
|
|
|
$e->grid(%info, -columnspan => $val ? 1 : 2); |
119
|
|
|
|
|
|
|
$e->raise; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
$old; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
1; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
__END__ |