|
From: Mark D. <mar...@zn...> - 2007-03-18 12:20:32
|
Hi,
I'd been working on the basis below. Its just a snippet but gives the idea.
Mark
#############################################################################
#
# Package VP::Frame
#
#############################################################################
package VP::Frame;
use base qw( Wx::Frame VP::TopLevelWindow );
sub newVP {
my $class = shift;
my %parms = @_;
my @allowedparms = qw(parent id title position size style name
vpname sizertype saveposition topwindow );
if(VP::__vp_param_check(\%parms, \@allowedparms) ) {
VP::croak("$class allowed params = '" . join(',',@allowedparms) ); }
$parms{parent} ||= VP->GetTopWindow();
$parms{id} ||= -1;
$parms{title} ||= VP->App->GetAppName();
$parms{postition} ||= Wx::wxDefaultPosition;
$parms{size} ||= Wx::wxDefaultSize;
$parms{style} ||= Wx::wxDEFAULT_FRAME_STYLE;
$parms{name} ||= '';
$parms{vpname} ||= $parms{name};
$parms{sizertype} ||= 'v';
$parms{saveposition} ||= 'v';
$parms{topwindow} ||= '0';
$parms{id} = $VP::MAINWINDOW_ID if($parms{topwindow});
my @args = ($parms{parent}, $parms{id}, $parms{title},
$parms{postition}, $parms{size}, $parms{style}, $parms{vpname},
$parms{sizertype}, $parms{saveposition}, $parms{topwindow} );
my $self = $class->new(@args);
return $self;
}
sub new {
my $vpname = '';
if( exists($_->[10]) && $_->[10] eq 'vptopwindow' ) {
$_->[1] = $VP::MAINWINDOW_ID;
if( exists($_->[7]) ) {
if( $_->[7] !~ /[A-Za-z]/ ) { $_->[7] = 'TopWindow'; }
} else {
$vpname = 'TopWindow';
}
}
$_->[1] = VP->GetTopWindow() if not exists $_->[1];
$_->[2] = -1 if not exists $_->[2];
$_->[3] = VP->App->GetAppName() if not exists $_->[3];
$_->[4] = Wx::wxDefaultPosition if not exists $_->[4];
$_->[5] = Wx::wxDefaultSize if not exists $_->[5];
$_->[6] = Wx::wxDEFAULT_FRAME_STYLE if not exists $_->[6];
$vpname = $_->[7] if exists $_->[7];
my $sizertype = $_->[8] if exists $_->[8];
$sizertype ||= 'v';
my $saveposition = $_->[9] if exists $_->[9];
$saveposition ||= 0;
while(@_ > 7) { pop(@_); }
my $self = shift->SUPER::new(@_);
#-----------------------------------
#-- Set The Main Sizer
#-----------------------------------
$self->SetSizer( VP->CreateBoxSizer( style => $sizertype ) );
#-----------------------------------
#-- Initialize
#-----------------------------------
$self->__vp_init_class( $vpname, 'VP_Frame' );
#-----------------------------------
#-- Restore a saved screen position
#-----------------------------------
$self->{__vp_saveposition} = $saveposition;
if( $self->{__vp_saveposition} && $self->IsVPNamedInstance() ) {
# load the previous screen position
my $left = VP->ReadConfig('winpositions/' . $self->{__vp_vpname}
. '/left', '0');
my $top = VP->ReadConfig('winpositions/' . $self->{__vp_vpname}
. '/top', '0');
my $width = VP->ReadConfig('winpositions/' .
$self->{__vp_vpname} . '/width', '0');
my $height = VP->ReadConfig('winpositions/' .
$self->{__vp_vpname} . '/height', '0');
my $saved = VP->ReadConfig('winpositions/' .
$self->{__vp_vpname} . '/saved', '0');
if($saved) {
$self->SetSize($left, $top, $width, $height);
} else {
$self->Centre();
}
} else {
$self->Centre();
}
#-----------------------------------
#-- Return Frame
#-----------------------------------
return $self;
}
Mattia Barbon wrote:
> On Sun, 18 Mar 2007 02:24:07 -0700
> Eric Wilhelm <scr...@gm...> wrote:
>
> Hi,
>
>> I'm still not sure what I'm doing with the declarative syntax, but I'm
>> currently working on a module that will create constructors with 1-2
>> required parameters, followed by key => value pairs. This is just a
>> dump of the autogenerated pod chunk which will accompany it.
>>
>> http://scratchcomputing.com/tmp/WxPerl-foo.html
>
> Looks fine to me, and I believe this is a very useful feature (I
> wanted to do it myself).
>
>> Let me know if there's anything glaringly wrong about that chunk of pod.
>>
>> At the moment, the only classes that I'm mapping are the ones that match
>> newFull() in the XS source. The code for this is at:
>>
>> http://scratchcomputing.com/svn/WxPerl-Constructors/trunk/build/xs_proto_map
>
> WxPerl::TreeCtrl->new(
> $parent,
> id => -1,
> pos => Wx::wxDefaultPosition(),
> size => Wx::wxDefaultSize(),
> style => Wx::wxTR_HAS_BUTTONS(),
> validator => Wx::wxDefaultValidator(),
> name => treeCtrl,
> );
>
> There are two things I do not like about this.
>
> The first is "WxPerl"; right name, wrong capitalization. But this
> might be my flawed sense of aesthetics...
>
> The second is: I suppose I will need to derive all my classes from
> WxPerl::*. Wouldn't it be better if Wx::Perl::Constructors added a
> 'create' or 'make' (or whatever) method to all wxPerl classes? For
> example:
>
> use Wx::Perl::Constructors;
>
> Wx::TreeCtrl->create(
> $parent,
> id => -1,
> pos => Wx::wxDefaultPosition(),
> size => Wx::wxDefaultSize(),
> style => Wx::wxTR_HAS_BUTTONS(),
> validator => Wx::wxDefaultValidator(),
> name => treeCtrl,
> );
>
> What do you think?
>
> Regards
> Mattia
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> wxperl-users mailing list
> wxp...@li...
> https://lists.sourceforge.net/lists/listinfo/wxperl-users
|