John,
The SubclassFactory is exactly the mechanism I am using but it wasn't
working for subclasses of Wx::Grid. This was my hack to get around the
problem at the time.
But I have learnt quite a bit more about the XS layer, so you will see in
later mails I have now added code to Grid.XS to wrap the default constructor
(without parameters).
Thanks for your input.
Regards
Mark
-----Original Message-----
From: wxperl-users-bounces@xxxxxxxxxxxxxxxxxxxxx
[mailto:wxperl-users-bounces@xxxxxxxxxxxxxxxxxxxxx] On Behalf Of John Ralls
Sent: 25 July 2006 05:49 PM
To: wxperl-users
Subject: Re: [wxperl-users] Differences using wxWidgets 2.7.0
On Jul 25, 2006, at 12:16 AM, Mark Wardell wrote:
> Hello,
>
> Further investigation has revealed that $this->FindWindow( $name )
> returns a HASH ref for all other controls I have tested but ONLY
> returns a SCALAR ref for controls of type Wx::Grid.
>
> I use this _BAD_ method of reblessing as a way of initialising
> subclassed controls (as below) that I am loading from XRC and have no
> other way of initialising them. SubclassFactory provides a way to
> override the default
> ->new() method (with no parameters), but there is no other way to
> override a
> Create or Show to provide any further customisation. So I am forced to
> manually Init each control in my OnInitDialog handler.
>
> if (my $grid = $self->FindWindow('DiscountGrid')) {
> bless $grid, 'Grid::DiscountGrid';
> print "Grid::DiscountGrid => $grid\n";
> $grid->InitControl( $self );
> }
>
> I suppose I could prevent the reblessing by simply declaring the
> subclassing in the XRC definition but I would still have the problem
> of FindWindow returned a SCALAR instead of a HASH and I need the HASH
> as I use a lot of code like below:
>
> $self->{Option1} = $var;
>
> Can anyone offer any pointers where I can start looking or possible
> alternative solutions.
>
> Thanks in advance.
>
> Mark
Yeah, http://wxperl.pvoice.org/kwiki/index.cgi?SubclassingXRC.
Perl's OO works, but it's a hack, and a bit fragile because it doesn't
enforce anything (which is why you can rebless in the first place, but also
why it will produce interesting results sometimes).
If you declare
your subclass the documented way (either with use base or by putting the
superclass in the @ISA) then call SUPER::new in your own new (or don't write
a new at all) then your subclass object will be correctly blessed.
Regards,
John Ralls
-------------------------------------------------------------------------
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
wxperl-users@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/wxperl-users
-------------------------------------------------------------------------
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
|