Eric Wilhelm > wxPerl-Constructors-v0.0.4 > wxPerl::Constructors

Download:
wxPerl-Constructors-v0.0.4.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

wxPerl::Constructors - parameterized constructors

SYNOPSIS ^

This package provides a mix of named and positional parameters which mirrors the original C++ API, allowing you to omit default values, even if you need to specify arguments which would otherwise follow them.

By applying s/Wx::([^-]*-)/wxPerl::$1-/g (and some editing) to your code:

  use wxPerl::Constructors;

  my $ctrl = wxPerl::TextCtrl->new($self, $label,
    style => wxTE_MULTILINE|wxTE_READONLY|wxTE_DONTWRAP);

Usage ^

Note the mixed positional/named arguments. Required values are positional and must come before key-value pairs.

  my $ctrl = wxPerl::Foo->new($parent, $req_arg, key => $value);

The exception is when there are no arguments. This goes directly to the Wx::Foo->new() call with no intermediate processing.

  my $ctrl = wxPerl::Foo->new();

All constructors also accept a ($parent, \%params) syntax, which may be useful if you are building a data-driven class generator (or just prefer to use named parameters for everything.)

  my $ctrl = wxPerl::Foo->new($parent,
    {
      req_arg => $req_arg,
      key     => $value,
    }
  );

In this mode, you must still provide the required arguments because there are no default values for them (they're, uh... required.)

Advanced usage ^

The constructors are also (well actually, not yet) available via this longhand form (intended as infrastructure for other packages.)

  my $ctrl = wxPerl::Constructors->new(
    'TextCtrl', $self, $label,
    style => wxTE_MULTILINE|wxTE_READONLY|wxTE_DONTWRAP);

You may inherit from wxPerl::$foo as follows:

  use wxPerl::Constructors;
  use base 'wxPerl::Frame';

CAVEAT: There will probably be no way to deduce that you've accidentally called a wxPerl::foo->new() with the Wx::foo-style positional arguments. Though it might be possible later, for now you have to take care to change the calls.

Methods ^

See wxPerl::Constructors::doc for available classes and details on the argument syntax.

AUTHOR ^

Eric Wilhelm @ <ewilhelm at cpan dot org>

http://scratchcomputing.com/

BUGS ^

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 ^

Copyright (C) 2007 Eric L. Wilhelm, All Rights Reserved.

NO WARRANTY ^

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.

LICENSE ^

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: