From: John R. <jr...@ce...> - 2006-07-06 16:25:15
|
On Jul 5, 2006, at 12:25 AM, Mattia Barbon wrote: > [Forwarding to the correct list] > > Hello, > > I am trying to subclass controls created using XRC but I am having > difficulty with the initialisation. > > The problem is that the controls are created with the 2-step > process using > the default contructor when subclassed by the XRC loading mechanism. > > For example, > > Wx::SomeCtrl->new; # without parameters > Wx::SomeCtrl::Create( @_ ); # all parameters specified here > > Unfortunately the Create() method is not virtual (is that the correct > terminology?) or I cannot override this method, so I am unable to > "assist" > woth the control creation, and provide additional initialisation > parameters > > Is this possible in plain Perl or do I need to go deeper to the XS > level? > > Many thanks > Mark I hope Mark is actually reading this list... Yes, it appears that it isn't possible to override Create nor to pass it arguments. The way I work around that is to write an init function for my subclasses which I call explicitly after loading a resource which uses them. It's neither elegant nor convenient, but it can be done in Perl. I think that the way to fire off the subclass's create (as well as to parse and pass additional parameters from the resource file) is to write a custom XmlResourceHandler, but I have not tried this myself. Regards, John Ralls |