| dotReader documentation | Contained in the dotReader distribution. |
WxPerl::ShortCuts - shorter constants
As an alternative to 'use Wx qw(:everything)', this module exports a handful of methods into your namespace which act as shorthand for several wxFOO constants.
WX'FOO';
WX('FOO');
Returns Wx::wxFOO(). Multiple suffixes can be joined with '|' symbols.
WX('FOO|BAR');
Returns Wx::wxFOO() | Wx::wxBAR().
Wx::wxTE_*
TE'FOO';
Wx::wxBITMAP_TYPE_*
BT'ANY';
Wx::wxSP_*
Wx::wxTR_*
wxDEFAULT
wxDefaultPosition
wxDefaultSize
Returns a list of two values.
wxDefaultPosition, wxDefaultSize
my $const = _mk_constant($prefix, $string);
Expects a fully qualified subname such as 'Wx::wxALIGN_RIGHT'.
my $const = get_constant($name);
Eric Wilhelm <ewilhelm at cpan dot org>
http://scratchcomputing.com/
If you found this module on CPAN, please report any bugs or feature requests through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
If you pulled this development version from my /svn/, please contact me directly.
Copyright (C) 2007 Eric L. Wilhelm, All Rights Reserved.
Absolutely, positively NO WARRANTY, neither express or implied, is offered with this software. You use this software at your own risk. In case of loss, no person or entity owes you anything whatsoever. You have been warned.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| dotReader documentation | Contained in the dotReader distribution. |
package WxPerl::ShortCuts; $VERSION = eval{require version}?version::qv($_):$_ for(0.10.1); use warnings; use strict; use Carp; BEGIN { require Exporter; *{import} = \&Exporter::import; our @EXPORT = qw( WX TE BT SP TR Def DefP DefS DefPS Exp Ams wV wH ); } use Wx ();
sub WX ($) {_mk_constant('Wx::wx', shift);}
sub TE ($) {_mk_constant('Wx::wxTE_', shift);}
sub BT ($) {_mk_constant('Wx::wxBITMAP_TYPE_', shift);}
sub SP ($) {_mk_constant('Wx::wxSP_', shift);}
sub TR ($) {_mk_constant('Wx::wxTR_', shift);}
use constant Def => Wx::wxDEFAULT(); use constant DefP => Wx::wxDefaultPosition(); use constant DefS => Wx::wxDefaultSize(); use constant DefPS => Wx::wxDefaultPosition(), Wx::wxDefaultSize(); use constant Ams => Wx::wxADJUST_MINSIZE(); use constant Exp => Wx::wxEXPAND(); use constant wV => Wx::wxVERTICAL(); use constant wH => Wx::wxHORIZONTAL(); # NOTE EVT->NAME_OF_EVENT($obj, λ{foo()});, though that should maybe be # an AUTOLOAD in the WxPerl::SelfServe package.
sub _mk_constant { my ($p, $string) = @_; my $val = 0; foreach my $part (split(/\|/, $string)) { $val |= get_constant($p . $part); } return($val); } # end subroutine _mk_constant definition ########################################################################
sub get_constant { my ($name) = @_; $name =~ m/^Wx::[0-9A-Za-z:_]+$/ or croak("invalid constant '$name'"); # TODO cache? my $v = eval("$name()"); $@ and croak("no such constant: '$name'"); return($v); } # end subroutine get_constant definition ########################################################################
# vi:ts=2:sw=2:et:sta 1;