From: Simon F. <sim...@bb...> - 2002-08-27 14:04:34
|
Hi, I am working on implimenting wxWindows' doc/view framework in wxPerl. I've got about 95% of the XS done and it compiles ok, but I'm having a problem with wxDocTemplate/wxClassInfo. The wxDocTemplate constructor looks like this: Wx_DocTemplate * Wx_DocTemplate::new(manager, descr, filter, dir, ext, docTypeName, viewTypeName, docClassInfo, viewClassInfo, flags) Wx_DocManager* manager wxString descr wxString filter wxString dir wxString ext wxString docTypeName wxString viewTypeName Wx_ClassInfo* docClassInfo Wx_ClassInfo* viewClassInfo long flags The wxDocTemplate needs wxClassInfo objects for the document and view classes, so it can create the documents/views automatically when they are needed. I think this probably works ok if I use c++ classes it already knows about such as wxDocument and wxView. Obviously wxClassInfo doesn't know anything about perl classes, so I can't create a classinfo object for "MyDocument" and "MyView". At the moment, I've got this in my test script: my $ci_doc = Wx::ClassInfo::FindClass("wxDocument"); my $ci_view = Wx::ClassInfo::FindClass("wxView"); my $docmanager = Wx::DocManager->new( 1, 1 ); my $doctemplate = Wx::DocTemplate->new($docmanager, "XML", "*.xml", "", "xml", "MyDoc", "MyView", $ci_doc, $ci_view, 1 ); my $frame = new Wx::DocParentFrame($docmanager, undef, -1, "DocView Demo", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE); So far I'm getting encouraging results for Wx::DocManager. When I click on File -> Open, it automatically pops up a file selector for *.xml files. But when I try and open one it crashes. I think this is because wxView::OnCreate() isn't doing anything. What I'd like to be able to do is something like this: my $ci_doc = Wx::ClassInfo::FindClass("My::Document"); my $ci_view = Wx::ClassInfo::FindClass("My::View"); Although we might need a different method name so we can still handle c++ classes in the same way. My problem is that I don't know how to impliment this. We'd need to override Wx::ClassInfo->CreateObject() or wxClassInfo::m_objectConstructor. I don't think I'm experienced enough to do this, but even if I were, I'd want to make sure that I did it in a way that was compatible with wxPerl development. If I can get this working I'll submit a patch to add the document/view framework. If not, I'll give you what I've done so far so you don't need to repeat what I've already done. By the way Mattia, I'm interested to know what the wxPl...... classes are for? Do we need something like that here? It looks like there are some useful functions in cpp/helpers.cpp Let me know if you want me to send you what I've got so far. Thanks Simon BBCi at http://www.bbc.co.uk This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated. If you have received it in error, please delete it from your system, do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately. Please note that the BBC monitors e-mails sent or received. Further communication will signify your consent to this. |