From: Mark W. <ma...@ne...> - 2006-07-24 17:31:22
|
Hi, I have some code as below: if (my $grid = $dialog->FindWindow(MyGrid')) { bless $grid, 'Grid::MyGrid'; print "Grid::MyGrid => $grid\n"; } Using wxPerl 0.54 on wxWidgets 2.6.3 I get: Grid::MyGrid => Grid::MyGrid=HASH(0x7015a00) Using wxPerl 0.54 on wxWidgets 2.7.0 I get: Grid::MyGrid => Grid::MyGrid=SCALAR(........) Any idea what could be causing this? Regards Mark |
From: Mattia B. <mat...@li...> - 2006-07-24 19:37:06
|
On Mon, 24 Jul 2006 19:30:41 +0200 "Mark Wardell" <ma...@ne...> wrote: Hello, > I have some code as below: > > if (my $grid = $dialog->FindWindow(MyGrid')) { > bless $grid, 'Grid::MyGrid'; > print "Grid::MyGrid => $grid\n"; > } > > Using wxPerl 0.54 on wxWidgets 2.6.3 I get: > Grid::MyGrid => Grid::MyGrid=HASH(0x7015a00) > > Using wxPerl 0.54 on wxWidgets 2.7.0 I get: > Grid::MyGrid => Grid::MyGrid=SCALAR(........) Honestly I have no idea why this should be so; the different wxWidgets version should not influence this. Regards Mattia P.S.: reblessing like this is _BAD_ |
From: Mark W. <ma...@ne...> - 2006-07-25 07:17:18
|
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 -----Original Message----- From: Mattia Barbon [mailto:mat...@li...] Sent: 24 July 2006 09:13 PM To: Mark Wardell Cc: 'wxperl-users' Subject: Re: [wxperl-users] Differences using wxWidgets 2.7.0 On Mon, 24 Jul 2006 19:30:41 +0200 "Mark Wardell" <ma...@ne...> wrote: Hello, > I have some code as below: > > if (my $grid = $dialog->FindWindow(MyGrid')) { > bless $grid, 'Grid::MyGrid'; > print "Grid::MyGrid => $grid\n"; > } > > Using wxPerl 0.54 on wxWidgets 2.6.3 I get: > Grid::MyGrid => Grid::MyGrid=HASH(0x7015a00) > > Using wxPerl 0.54 on wxWidgets 2.7.0 I get: > Grid::MyGrid => Grid::MyGrid=SCALAR(........) Honestly I have no idea why this should be so; the different wxWidgets version should not influence this. Regards Mattia P.S.: reblessing like this is _BAD_ |
From: Mark W. <ma...@ne...> - 2006-07-25 09:42:57
|
Hi Mattia, I have made these changes and generated this patch file using WinCvs (so I hope the format is correct) and the problems described below are now fixed. I do not know what side effects may be caused by these changes so please advise if these changes are the recommended way as per the 'Mattia' way of doing things. Many thanks Mark *** Grid.xs 15 Sep 2005 21:08:54 -0000 1.25 --- Grid.xs 25 Jul 2006 08:59:53 -0000 *************** *** 11,16 **** --- 11,17 ---- ############################################################################ # #include <wx/grid.h> + #include "cpp/overload.h" MODULE=Wx PACKAGE=Wx::GridCellCoords *************** *** 44,51 **** MODULE=Wx PACKAGE=Wx::Grid wxGrid* ! wxGrid::new( parent, id, pos = wxDefaultPosition, size = wxDefaultSize, style = wxWANTS_CHARS, name = wxPanelNameStr ) wxWindow* parent wxWindowID id wxPoint pos --- 45,69 ---- MODULE=Wx PACKAGE=Wx::Grid + void + new( ... ) + PPCODE: + BEGIN_OVERLOAD() + MATCH_VOIDM_REDISP( newDefault ) + MATCH_ANY_REDISP( newFull ) + END_OVERLOAD( "Wx::Grid::new" ) + + wxGrid* + newDefault( CLASS ) + PlClassName CLASS + CODE: + RETVAL = new wxGrid(); + wxPli_create_evthandler( aTHX_ RETVAL, CLASS ); + OUTPUT: RETVAL + wxGrid* ! newFull( CLASS, parent, id, pos = wxDefaultPosition, size = wxDefaultSize, style = wxWANTS_CHARS, name = wxPanelNameStr ) ! PlClassName CLASS wxWindow* parent wxWindowID id wxPoint pos -----Original Message----- From: wxp...@li... [mailto:wxp...@li...] On Behalf Of Mark Wardell Sent: 25 July 2006 09:17 AM To: 'Mattia Barbon' Cc: 'wxperl-users' Subject: Re: [wxperl-users] Differences using wxWidgets 2.7.0 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 -----Original Message----- From: Mattia Barbon [mailto:mat...@li...] Sent: 24 July 2006 09:13 PM To: Mark Wardell Cc: 'wxperl-users' Subject: Re: [wxperl-users] Differences using wxWidgets 2.7.0 On Mon, 24 Jul 2006 19:30:41 +0200 "Mark Wardell" <ma...@ne...> wrote: Hello, > I have some code as below: > > if (my $grid = $dialog->FindWindow(MyGrid')) { > bless $grid, 'Grid::MyGrid'; > print "Grid::MyGrid => $grid\n"; > } > > Using wxPerl 0.54 on wxWidgets 2.6.3 I get: > Grid::MyGrid => Grid::MyGrid=HASH(0x7015a00) > > Using wxPerl 0.54 on wxWidgets 2.7.0 I get: > Grid::MyGrid => Grid::MyGrid=SCALAR(........) Honestly I have no idea why this should be so; the different wxWidgets version should not influence this. Regards Mattia P.S.: reblessing like this is _BAD_ ------------------------------------------------------------------------- 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: Mattia B. <mat...@li...> - 2006-07-28 03:16:27
|
On Tue, 25 Jul 2006 11:42:24 +0200 "Mark Wardell" <ma...@ne...> wrote: Hello, > I have made these changes and generated this patch file using WinCvs (so I > hope the format is correct) and the problems described below are now fixed. > I do not know what side effects may be caused by these changes so please > advise if these changes are the recommended way as per the 'Mattia' way of > doing things. :-D yes they are (after all, this is the way it is done in other wxWindow-derived classes). The Create() method is missing, though (added). Applied. Thanks! Mattia |
From: John R. <jr...@ce...> - 2006-07-25 15:49:01
|
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 |
From: Mark W. <ma...@ne...> - 2006-07-25 17:39:06
|
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: wxp...@li... [mailto:wxp...@li...] 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 wxp...@li... https://lists.sourceforge.net/lists/listinfo/wxperl-users |