From: Mattia B. <mb...@ds...> - 2002-09-05 17:33:06
|
> Something I've found annoying is that some classes are > implemented as scalar references. Say I want to > subclass Wx::MenuBar. Because it is a scalar reference > instead of the normal hash reference, I can't do this: <snip> > I think since wxWindows philosophy/API is very object-oriented, > that perhaps (unless there is a technical reason forbidding it) > those classes should be hash refs. Well, wxPerl classes are arbitrarily divided in "subclassable" and "not subclassable"; Subclassable: 1a. ->new returns an hash ref 1b. wxPerl always returns the original hash ref from wxWindows methods (f.e. from ->GetChildren or ->GetParent) Not subclassable: 2a. -> new returns a scalar ref 2b. wxPerl creates a new scalar ref every time it needs to return such an object from wxWindows methods Having 1b requires a small but nonzero amount of work, so I try not to have it without necessity (BTW subclassing wxMenuBar is unusual, why do you need it? just curious); I could have 1a and 2b, but that would be confusing ---- my $a = Wx::MenuBar->new(...); $frame->SetMenuBar( $a ); my $b = $frame->GetMenuBar; # $a is an hash ref, $b is a scalar ref, OR another hash ref, # different from the first one ---- I can move wxMenuBar (or any other class) to subclassable (or to not subclassable) it just requires some small work. Regards Mattia |