Mark Dootson wrote:

  Hi,

I thought I'd chip in with a populated template for Steve to test. However, basic testing here brought up a problem. wxRichTextPrinting has no wxRTTI information (there's no IMPLEMENT_CLASS macro) so the wxPerl code ( wxPli_object_2_sv ) throws warnings.

The attached patch wraps wxRichTextPrinting but is not applied to SVN as the wxRichTextPrinting constructor code is none standard. It does what wxPli_object_2_sv would do if wxRichTextPrinting had ClassInfo. I'm fairly sure this is OK because wxRichTextPrinting inherits directly from wxObject and, as there is no need to wrap wxRichTextPrinting to handle Perl virtual methods, I don't think there is anywhere else in the wxPerl code that would attempt to reference the missing class info.

Just a clarification: RTTI is not needed to handle virtual methods, it's required to bless a Perl object into the correct class when there is a C++ method returning a pointer to some base class.

For example, in C++, wxWindow::GetParent returns a wxWindow*, but Perl uses the RTTI info to return an object blessed into the subclass the object really belongs to.

My question to Mattia is, this seems wrong and a bit of a hack. Is there a better way to handle it?

The "correct hack" is to use O_NON_WXOBJECT(_THR) in the typemap; the result is the same, but you avoid the copy-pasted code in the constructor, and get the correct conversion code in case there is some other method returning a wxRichTextPrinting instance.

I suppose the correct fix is to patch wxRichTextPrinting to implement wxRTTI, but this would not help any existing 2.8.x installations.

  Both correct.

Some simple usage has been added to wxDemo in SVN. I've tested the patch building and with the basic wxDemo usage on msw/linux/mac with wxWidgets 2.8.10, and all seems to work OK.

Thanks!
Mattia

On 10/04/2010 09:40, Mattia Barbon wrote:
Steve Cookson wrote:

Hi,

I'm not sure whether I should be sending this to the group or directly
to Mattia

Better to the group (it will be in the archives, and there are other
people beside me that have some experience in wrapping wxWidgets classes).

but I'm trying to understand how to print a wxRichTextCtrl from
wxPerl. I understand that wxRichTextPrinting and wxRichTextPrintout
are not implemented yet in wxPerl.

Correct.

So I need to do something to access the original C++ code (maybe wrap
or re-write). Re-writing seems to be an easier route as I don't
understand the Wx XS framework that Mattia uses. However, it would be
a bit anti-social. It would be better to use the current wxPerl
framework.

I wouldn't call it antisocial, but wrapping the C++ code is definitely
more maintainable in the long run.

As far as I can see the wxPerl framework is dll driven and provides an
XS-based interface to the dlls? Is that right?

Correct.

 > There seems to be some
automation/facilitation of the process, but it's not clear to me how
it works. I've also never used XS before.

Are there some instructions about how to do this available?

I'm sure I answered this on the mailing list, but can't find the mails;
I just committed some documentation that should at least get you
started; see lib/Wx/NewClass.pod. I think that wxRichTextPrinting should
be reasonably easy to wrap.

Regards,
Mattia


Reply via email to