Hi,
If you wish to create your own wxSizer class you must inherit from
Wx::PlSizer and override the abstract methods 'RecalcSizes' and 'CalcMin'.
The 'glue' that would allow you to usefully create a Kephra::App::Sizer
inheriting from Wx::BoxSizer (or any other sizer class) is not
implemented. The 'glue' is the code that connects the Perl data for your
Kephra::App::Sizer to the C++ data for the Wx::BoxSizer instance, and
ensures that both bits of data are deleted at the appropriate time.
The reason for the none implementation I would guess is that the useful
virtual methods in Wx::Sizer - 'RecalcSizes' and 'CalcMin', have
none-virtual implementations in Wx::BoxSizer. So for the main job that a
sizer does - laying out children - inheriting from Wx::BoxSizer gives
limited possibilities.
Having said that, looking at the implementation for wxSizer classes it
should be possible to implement the necessary 'glue' reasonably easily
by following the existing code for wxEvtHandler classes. But this is one
of those cases where the coding seems relatively straightforward but the
test plan would need quite a bit of effort ( for me at least) and I'm
unsure that the effort required gives any real benefit?
I don't know if your example represents the sum of what you wish to do,
but if the only reason for requiring a Kephra::App::Sizer class is to
affect the constructor, then
use strict;
use warnings;
use Kephra::API;
use Wx;
package Kephra::App::SizerFactory;
sub CreateBoxSizer {
my $orient = shift;
if (lc substr($orient, 0, 1) eq 'v') { $orient =&Wx::wxVERTICAL }
elsif (lc substr($orient, 0, 1) eq 'h') { $orient =&Wx::wxHORIZONTAL }
#elsif (not defined $orient) { $orient =&Wx::wxHORIZONTAL }
else {
return Kephra::Log::error
("need h|horizontal or v|vertical as first parameter, not
$orient", 1)
}
my $sizer = Wx::BoxSizer->new( $orient );
$sizer->append(@_);
return $sizer;
}
On 03/08/2012 00:03, herbert breunung wrote:
hai comerads,
thats pretty my message.
i could not came up with an examplewhere i inherit from Boxsizer but with an
own extended class.
whats wrong with:
use strict;
use warnings;
use Kephra::API;
use Wx;
package Kephra::App::Sizer;
our @ISA = 'Wx::BoxSizer';
sub new {
my $class = shift;
my $orient = shift;
if (lc substr($orient, 0, 1) eq 'v') { $orient =&Wx::wxVERTICAL }
elsif (lc substr($orient, 0, 1) eq 'h') { $orient =&Wx::wxHORIZONTAL }
#elsif (not defined $orient) { $orient =&Wx::wxHORIZONTAL }
else {
return Kephra::Log::error
("need h|horizontal or v|vertical as first parameter, not
$orient", 1)
}
my $self = $class->SUPER::new( $orient );
print $self,"-----------------------\n" if $self->isa('Wx::Sizer');
$self->append(@_);
$self;
}
print say its a Boxsizer not Kephra::App::Sizer
thanks for any advise
PS the books is slowly starting to pace up
best
herbert