From: Mattia B. <mb...@ds...> - 2002-08-27 20:27:19
|
> 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 WOW! This is really impressive! > 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 Yes, it should > 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". Yes; the alternative (as explained in wxDT::wxDT docs) is to override CreateDocument; to be able to do this you need a wxPlDocTemplate class (see below). > 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. Possibly > 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. It is sufficient to override ->CreateObject. > 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 The wxPlFoo classes are used when: 1 - you need to have a C++ virtual function overridable from Perl (for example wxSizer::RecalcSizes) 2 - you want the C++ object to store a reference to the Perl object; for example Wx::Icon does not use a wxPlIcon (just a wxIcon) hence $frame->SetIcon( $icon1 ); $icon2 = $frame->GetIcon(); $icon1 and $icon2 will be different Perl-level objects OTOH when you do $button1 = Wx::Button->new( $parent, ... ); $button2 = ($parent->GetChildren())[0]; $button1 and $button2 should be the same Perl-level object, and this is possible because a wxPlButton is used 3 - some other utility classes are named wxPlFoo or wxPliFoo We need these classes here, because wxDoc/View uses virtual functions a lot. I will post a more detailed explanation in another mail. Regards Mattia |
From: Simon F. <sim...@bb...> - 2002-08-28 15:40:07
|
Hi Mattia, Thanks for the detailed replies. I haven't had much chance to work on this today. I hope to spend some time on this over the next few days. > > We'd need to override Wx::ClassInfo->CreateObject() or > > wxClassInfo::m_objectConstructor. > > It is sufficient to override ->CreateObject. Ok, We might still want to use Wx::ClassInfo for wx(Class) classes. So am I right in saying, we'd have a wxPlClassInfo class which overrides ->CreateObject. How do you see this being used? my $ci_doc = Wx::PlClassInfo::FindClass("My::Doc"); my $ci_view = Wx::PlClassInfo::FindClass("My::View"); $doc_tmpl = Wx::DocTemplate->new($docmgr, ..., ..., ..., $ci_doc, $ci_view, flag); or $doc_tmp = Wx::DocTemplate->new($docmgr, ..., ..., ..., "My::Doc", "My::View", flag); ...and having our wxPlDocTemplate construct wxPlClassInfo objects? If I have any other questions I'll let you know. Thanks Simon - - -- ---- ---------------------------- --- -- - - Simon Flack Software Engineer BBC, Interactive F&L email: sim...@bb... telephone: 020 8752 6436 - - -- ---- ----------------------------------- --- -- - - > -----Original Message----- > From: Mattia Barbon [mailto:mb...@ds...] > Sent: 27 August 2002 19:11 > To: Simon Flack > Cc: wxp...@li... > Subject: Re: [wxperl-users] Document/View Framework > > > > 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 > WOW! This is really impressive! > > > 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 > Yes, it should > > > 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". > Yes; the alternative (as explained in wxDT::wxDT docs) is to override > CreateDocument; to be able to do this you need a wxPlDocTemplate class > (see below). > > > 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. > Possibly > > > 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. > It is sufficient to override ->CreateObject. > > > 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 > The wxPlFoo classes are used when: > 1 - you need to have a C++ virtual function overridable from Perl > (for example wxSizer::RecalcSizes) > 2 - you want the C++ object to store a reference to the Perl object; > for example Wx::Icon does not use a wxPlIcon (just a wxIcon) > hence $frame->SetIcon( $icon1 ); $icon2 = $frame->GetIcon(); > $icon1 and $icon2 will be different Perl-level objects > OTOH when you do $button1 = Wx::Button->new( $parent, ... ); > $button2 = ($parent->GetChildren())[0]; $button1 and $button2 > should be the same Perl-level object, and this is possible because > a wxPlButton is used > 3 - some other utility classes are named wxPlFoo or wxPliFoo > > We need these classes here, because wxDoc/View uses virtual > functions a lot. I will post a more detailed explanation in > another mail. > > Regards > Mattia > 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. |
From: Simon F. <sim...@bb...> - 2002-08-28 15:56:28
|
I suppose the other alternative, is to assume that users will only ever use Wx::ClassInfo for Perl objects and modify Wx::ClassInfo to hook into a wxPlClassInfo. I know the CLASSINFO() is used elsewhere, wxFrameLayout I think. But I suppose it will be much more common to want to use classinfo for perl classes. Simon > -----Original Message----- > > 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 > WOW! This is really impressive! > > > 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 > Yes, it should > > > 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". > Yes; the alternative (as explained in wxDT::wxDT docs) is to override > CreateDocument; to be able to do this you need a wxPlDocTemplate class > (see below). > > > 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. > Possibly > > > 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. > It is sufficient to override ->CreateObject. > > > 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 > The wxPlFoo classes are used when: > 1 - you need to have a C++ virtual function overridable from Perl > (for example wxSizer::RecalcSizes) > 2 - you want the C++ object to store a reference to the Perl object; > for example Wx::Icon does not use a wxPlIcon (just a wxIcon) > hence $frame->SetIcon( $icon1 ); $icon2 = $frame->GetIcon(); > $icon1 and $icon2 will be different Perl-level objects > OTOH when you do $button1 = Wx::Button->new( $parent, ... ); > $button2 = ($parent->GetChildren())[0]; $button1 and $button2 > should be the same Perl-level object, and this is possible because > a wxPlButton is used > 3 - some other utility classes are named wxPlFoo or wxPliFoo > > We need these classes here, because wxDoc/View uses virtual > functions a lot. I will post a more detailed explanation in > another mail. > > Regards > Mattia > 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. |