| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package wxPerl::Styles; |
|
2
|
|
|
|
|
|
|
$VERSION = eval{require version}?version::qv($_):$_ for(0.0.1); |
|
3
|
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
145542
|
use warnings; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
268
|
|
|
5
|
2
|
|
|
2
|
|
12
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
547
|
|
|
6
|
2
|
|
|
2
|
|
54
|
use Carp; |
|
|
2
|
|
|
|
|
10
|
|
|
|
2
|
|
|
|
|
219
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# hmm, might as well depend on it, though caller probably does already |
|
9
|
2
|
|
|
2
|
|
1257
|
use Wx (); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# or do this at runtime: |
|
11
|
|
|
|
|
|
|
# croak("you need to require Wx first") unless(Wx->VERSION); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
wxPerl::Styles - shortcuts for wxFOO style constants |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
This package encapsulates stringwise access to wxPerl constants, |
|
20
|
|
|
|
|
|
|
primarily for use in specifying styles, but also for comparing |
|
21
|
|
|
|
|
|
|
constants. |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use Wx qw( |
|
24
|
|
|
|
|
|
|
ALIGN_RIGHT |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
... wxALIGN_RIGHT ... ; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Becomes: |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
use Wx (); |
|
31
|
|
|
|
|
|
|
use wxPerl::Styles 'wxVal'; |
|
32
|
|
|
|
|
|
|
... wxVal('align_right') ... ; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Names will be uppercased automatically. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
When using wxPerl::Constructors, style is always a named parameter, so |
|
37
|
|
|
|
|
|
|
this gives you the 'style => ...' bit: |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
use Wx (); |
|
40
|
|
|
|
|
|
|
use wxPerl::Constructors; |
|
41
|
|
|
|
|
|
|
use wxPerl::Styles 'style'; |
|
42
|
|
|
|
|
|
|
... |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $text_ctrl = wxPerl::TextCtrl->new($self, 'some text here', |
|
45
|
|
|
|
|
|
|
style('hscroll', te => 'process_enter|multiline') |
|
46
|
|
|
|
|
|
|
); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NOTE |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
This does delay typo errors until run-time, but widget-construction is |
|
51
|
|
|
|
|
|
|
pretty close to compile time, and the error messages are likely to be |
|
52
|
|
|
|
|
|
|
more informative than 'syntax error'. Also, I think that's a small |
|
53
|
|
|
|
|
|
|
price to pay for not having all of those extra methods kicking around in |
|
54
|
|
|
|
|
|
|
your class. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
BEGIN { |
|
59
|
|
|
|
|
|
|
require Exporter; |
|
60
|
|
|
|
|
|
|
*{import} = \&Exporter::import; |
|
61
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
|
62
|
|
|
|
|
|
|
style |
|
63
|
|
|
|
|
|
|
wxVal |
|
64
|
|
|
|
|
|
|
ID |
|
65
|
|
|
|
|
|
|
); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 wxVal |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $style = wxVal('align_right', |
|
72
|
|
|
|
|
|
|
te => 'PROCESS_ENTER|MULTILINE' |
|
73
|
|
|
|
|
|
|
); |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub wxVal { |
|
78
|
|
|
|
|
|
|
my $bare; |
|
79
|
|
|
|
|
|
|
if(@_ % 2) { |
|
80
|
|
|
|
|
|
|
$bare = shift(@_); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
my (%args) = @_; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my $val = defined($bare) ? _mk_constant('', $bare) : 0; |
|
85
|
|
|
|
|
|
|
foreach my $key (keys(%args)) { |
|
86
|
|
|
|
|
|
|
$val |= _mk_constant(uc($key) . '_', $args{$key}); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
return($val); |
|
89
|
|
|
|
|
|
|
} # end subroutine wxVal definition |
|
90
|
|
|
|
|
|
|
######################################################################## |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 style |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Same as wxVal(), but returns (style => $style) for use with |
|
95
|
|
|
|
|
|
|
wxPerl::Constructors named parameter lists. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
my %param = style(@list); |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub style { |
|
102
|
|
|
|
|
|
|
return(style => wxVal(@_)); |
|
103
|
|
|
|
|
|
|
} # end subroutine style definition |
|
104
|
|
|
|
|
|
|
######################################################################## |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 ID |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Hash-parameter shortcut for 'id => Wx::wxID_OK()' and etc. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
my %param = ID('ok'); |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub ID ($) { |
|
115
|
|
|
|
|
|
|
my ($val, @and) = @_; |
|
116
|
|
|
|
|
|
|
@and and croak("too many arguments for ID"); |
|
117
|
|
|
|
|
|
|
return(id => wxVal(id => $val)); |
|
118
|
|
|
|
|
|
|
} # end subroutine ID definition |
|
119
|
|
|
|
|
|
|
######################################################################## |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 _mk_constant |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
my $const = _mk_constant($prefix, $string); |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub _mk_constant { |
|
128
|
|
|
|
|
|
|
my ($p, $string) = @_; |
|
129
|
|
|
|
|
|
|
my $val = 0; |
|
130
|
|
|
|
|
|
|
foreach my $part (split(/\|/, uc($string))) { |
|
131
|
|
|
|
|
|
|
$val |= _get_constant($p . $part); |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
return($val); |
|
134
|
|
|
|
|
|
|
} # end subroutine _mk_constant definition |
|
135
|
|
|
|
|
|
|
######################################################################## |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 _get_constant |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Expects a fully qualified subname such as 'Wx::wxALIGN_RIGHT'. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
my $const = _get_constant($name); |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
my %cache; |
|
146
|
|
|
|
|
|
|
sub _get_constant { |
|
147
|
|
|
|
|
|
|
my ($name) = @_; |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
exists($cache{$name}) and return($cache{$name}); |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
$name =~ m/^[A-Z][0-9A-Z_]+$/ or croak("invalid constant '$name'"); |
|
152
|
|
|
|
|
|
|
my $v = eval("Wx::wx$name()"); |
|
153
|
|
|
|
|
|
|
$@ and croak("no such constant: '$name'"); |
|
154
|
|
|
|
|
|
|
return($cache{$name} = $v); |
|
155
|
|
|
|
|
|
|
} # end subroutine _get_constant definition |
|
156
|
|
|
|
|
|
|
######################################################################## |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 AUTHOR |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Eric Wilhelm @ |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
http://scratchcomputing.com/ |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 BUGS |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
If you found this module on CPAN, please report any bugs or feature |
|
167
|
|
|
|
|
|
|
requests through the web interface at L. I will be |
|
168
|
|
|
|
|
|
|
notified, and then you'll automatically be notified of progress on your |
|
169
|
|
|
|
|
|
|
bug as I make changes. |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
If you pulled this development version from my /svn/, please contact me |
|
172
|
|
|
|
|
|
|
directly. |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Copyright (C) 2007 Eric L. Wilhelm, All Rights Reserved. |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 NO WARRANTY |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Absolutely, positively NO WARRANTY, neither express or implied, is |
|
181
|
|
|
|
|
|
|
offered with this software. You use this software at your own risk. In |
|
182
|
|
|
|
|
|
|
case of loss, no person or entity owes you anything whatsoever. You |
|
183
|
|
|
|
|
|
|
have been warned. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 LICENSE |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
188
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=cut |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
# vi:ts=2:sw=2:et:sta |
|
193
|
|
|
|
|
|
|
1; |