Re: Subclassing Gnome2::Canvas
- From: "muppet" <scott asofyet org>
- To: gtk-perl-list gnome org
- Subject: Re: Subclassing Gnome2::Canvas
- Date: Tue, 8 Nov 2005 14:11:54 -0500 (EST)
James Muir said:
I am able to subclass the aliased canvas and instantiate it while
passing a parameter, but I cannot do the same with the anti-aliased
canvas :-( . I would have expected to be able to do this with both
canvases. Is this a bug or, as usual, am I missing something?
You're missing something. :-)
Here's a simple example:
...
my $canvas = can->new_aa(melon=>'x');
# my $canvas = can->new(melon=>'x');
You have two different things going on here. Glib::Object::Subclass aliases
yourpackage::new() to Glib::Object::new(), so the second, commented line
actually resolves to
Glib::Object::new ('can', 'melon', 'x');
On the other hand, nothing special happens with new_aa(), so that is inherited
normally, and evaluates to this:
Gnome2::Canvas::new_aa ('can', 'melon', 'x');
However, GNome2::Canvas::new_aa() is an xsub which binds to a non-virtual
class-static method, which takes only one parameter -- the ignored class.
Even if you take off the extra parameters and just call it as 'can->new_aa()',
it will create a 'Gnome2::Canvas', not a 'can', because it is hardcoded to do
so. In other words, This Is Not How You Do It.
Either:
a) create your own new_aa() method in your custom package and set it up
correctly, or
b) use the 'aa' property to set up your object, like this:
$canvas = can->new (aa => TRUE, melon => 'x');
Hint: if you choose a), it will be implemented as b).
--
muppet <scott at asofyet dot org>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]