From: Eric W. <scr...@gm...> - 2007-03-18 09:24:13
|
Hi all, 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 Basically, I'm tired of looking at '-1,' and 'wxDefaultPosition'. This lets me jump straight to the style parameter. Additionally, the code which does the mapping from names to indices should be useful in something like an xrc replacement where everything is named parameters. 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 Suggestions welcome. Thanks, Eric -- So malloc calls a timeout and starts rummaging around the free chain, sorting things out, and merging adjacent small free blocks into larger blocks. This takes 3 1/2 days. --Joel Spolsky --------------------------------------------------- http://scratchcomputing.com --------------------------------------------------- |
From: Mattia B. <mat...@li...> - 2007-03-18 11:19:53
|
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 |
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 |
From: Eric W. <scr...@gm...> - 2007-03-18 17:56:32
|
# from Mattia Barbon # on Sunday 18 March 2007 04:19 am: >=A0 The first is "WxPerl"; right name, wrong capitalization. =A0But this >might be my flawed sense of aesthetics... Well, it could be wxPerl::*. I've been using 'WxPerl::*' in the few=20 extensions and convenience modules that I've done thus far for=20 dotReader, but haven't broken any of those into separate dists. What would be the ideal namespace for extensions? I guess my sense of=20 aesthetics doesn't like the de-facto Wx::Perl::*. >=A0 The second is: I suppose I will need to derive all my classes from >WxPerl::*. =A0 Yep. The benefit here is maybe that you get to add more methods to=20 those classes from elsewhere. If we can decide on an "enhancements"=20 namespace, we could conceivably have a whole pile of cooperating mixins=20 available as we figure out how to grow the API. I'm not certain if=20 much is needed beyond the constructors though, so ponder that=20 accordingly. use wxPerl::Constructors; use wxPerl::TreeCtrl::FlyingSquirrel; >Wouldn't it be better if Wx::Perl::Constructors added a=20 >'create' or 'make' (or whatever) method to all wxPerl classes? For >example: Hmm, I prefer Something->new(), but I've considered a complete=20 switcharoo on the Wx:: constructors via an import() option. This=20 would, of course, need to be aware of caller() in order to not disturb=20 the rest of the system (though it would add a level to the call-stack=20 by the time we got to Wx::Button->new(), etc. I'm thinking the whole=20 scheme will be installed via globs anyway, so where I install them=20 isn't that big of a deal. =2D-Eric =2D-=20 Cult: A small, unpopular religion. Religion: A large, popular cult. =2D- Unknown =2D-------------------------------------------------- http://scratchcomputing.com =2D-------------------------------------------------- |