#15686 closed enhancement (fixed)

wxAuiToolbar XML Handler

Reported by: R.U.10 Owned by:
Priority: normal Milestone: 3.1.0
Component: XRC Version: 3.0.0
Keywords: wxAuiToolBarXmlHandler Cc:
Blocked By: #15694 Blocking:
Patch: yes

Description

Here is a proposal of XRC handler for wxAuiToolbar class.
The wxAuiToolbar object built by XRC is fully autonomous thanks to the management of the DropDown menu events directly in wxAuiToolBarXmlHandler.

Please update the documentation given in the patch with the chosen release milestone:
(...) support in XRC is available in wxWidgets 3.x.x and later (...)

Attachments (4)

wxAuiToolbarXmlHandler.patch download (25.7 KB) - added by R.U.10 13 months ago.
wxAuiToolbar XRC handler, doc and bakefile
wxAuiToolbarXmlHandler_version-script.in.patch download (1.6 KB) - added by R.U.10 13 months ago.
version-script.in update
multilib.bkl.patch download (384 bytes) - added by R.U.10 11 months ago.
wxAuiToolbarXmlHandler_linking_issue.patch download (7.2 KB) - added by R.U.10 11 months ago.

Download all attachments as: .zip

Change History (22)

comment:1 follow-up: Changed 13 months ago by vadz

  • Status changed from new to confirmed

This looks good to me, thanks! The only issues I see are some minor stylistic things (opening braces not on their own line, a method starting with lower case 'o', ...) which are easy to fix.

One question I have is about the use of "#ifdef __WXMSW__" in the code: why is it needed?

I also wonder if we could have an AUI XRC handlers demo somewhere, I think it would be great to have an example of using this handler somewhere as it risks being difficult to understand how to do it otherwise (especially because the GUI editors don't support it yet, so XRC would need to be written by hand).

And last but not least: could you please update misc/schema/xrc_schema.rnc to recognize the new elements?

comment:2 Changed 13 months ago by R.U.10

  • Blocked By 15694 added

comment:3 in reply to: ↑ 1 Changed 13 months ago by R.U.10

I brought all the expected corrections and improvements.
I created a "AUI XRC demo" dialog in the XRC sample which also exhibits the wxAuiNotebook (which allowed to discover the defect #15694).

Replying to vadz:

One question I have is about the use of "#ifdef __WXMSW__" in the code: why is it needed?

I don't know, it is borrowed as is from the code of wxToolBarXmlHandler...

Changed 13 months ago by R.U.10

wxAuiToolbar XRC handler, doc and bakefile

comment:4 follow-up: Changed 13 months ago by vadz

  • Resolution set to port to stable
  • Status changed from confirmed to portneeded

Thanks for the update!

Looks good to me so I'm going to commit it to the trunk. In principle, this could be backported to 3.0 but I'd prefer to get some testing for it first. And if this goes to 3.0, version-script.in would need to be updated too (and the new header taken inside #if wxABI_VERSION >= 30100 check).

Thanks again!

comment:5 Changed 13 months ago by VZ

  • Blocked By

(In #15694) (In [75269]) Initialize wxAuiNotebookXmlHandler::m_isInside in ctor.

Closes #15694.

comment:6 Changed 13 months ago by VZ

(In [75271]) Add XRC handler for wxAuiToolBar.

Also add the demonstration of AUI handlers (this one and the existing one for
wxAuiNotebook) to the xrc sample.

See #15686.

comment:7 in reply to: ↑ 4 Changed 13 months ago by R.U.10

Replying to vadz:

if this goes to 3.0, version-script.in would need to be updated

Done

Changed 13 months ago by R.U.10

version-script.in update

comment:8 Changed 13 months ago by R.U.10

I'm the author of the XRC sample, the documentation and the final integration and 'WXification' of the code, but the originally author of wxAuiToolbarXmlHandler is one of my colleagues, I thus modified the name in the header.

comment:9 Changed 13 months ago by VZ

(In [75286]) Correct the author of wxAuiToolBarXmlHandler.

See #15686.

comment:10 Changed 11 months ago by vadz

  • Blocked By
  • Milestone set to 3.1.0
  • Status changed from portneeded to new

Unfortunately this change broke DLL build under MSW:

   Creating library ..\..\lib\vc120_dll\wxmsw31ud_aui.lib and object ..\..\lib\vc120_dll\wxmsw31ud_aui.exp
auidll_xh_auitoolb.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: enum wxXmlNodeType __thiscall wxXmlNode::GetType(void)const " (__imp_?GetType@wxXmlNode@@QBE?AW4wxXmlNodeType@@XZ) referenced in function "public: virtual class wxObject * __thiscall wxAuiToolBarXmlHandler::DoCreateResource(void)" (?DoCreateResource@wxAuiToolBarXmlHandler@@UAEPAVwxObject@@XZ)
auidll_xh_auitoolb.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class wxString const & __thiscall wxXmlNode::GetName(void)const " (__imp_?GetName@wxXmlNode@@QBEABVwxString@@XZ) referenced in function "public: virtual class wxObject * __thiscall wxAuiToolBarXmlHandler::DoCreateResource(void)" (?DoCreateResource@wxAuiToolBarXmlHandler@@UAEPAVwxObject@@XZ)
auidll_xh_auitoolb.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class wxXmlNode * __thiscall wxXmlNode::GetNext(void)const " (__imp_?GetNext@wxXmlNode@@QBEPAV1@XZ) referenced in function "public: virtual class wxObject * __thiscall wxAuiToolBarXmlHandler::DoCreateResource(void)" (?DoCreateResource@wxAuiToolBarXmlHandler@@UAEPAVwxObject@@XZ)
auidll_xh_auitoolb.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class wxXmlNode * __thiscall wxXmlNode::GetChildren(void)const " (__imp_?GetChildren@wxXmlNode@@QBEPAV1@XZ) referenced in function "public: virtual class wxObject * __thiscall wxAuiToolBarXmlHandler::DoCreateResource(void)" (?DoCreateResource@wxAuiToolBarXmlHandler@@UAEPAVwxObject@@XZ)
..\..\lib\vc120_dll\wxmsw310ud_aui_vc_custom.dll : fatal error LNK1120: 4 unresolved externals

The reason is that we can't use wxXmlNode directly outside of the XRC library but these 4 methods are used directly in src/xrc/xh_auitoolb.cpp. If we really can't do without them, we must virtualize them via wxXmlResourceHandlerImpl, i.e. add GetNodeType() and so on.

But we must fix the build somehow...

comment:11 Changed 11 months ago by R.U.10

It seems that I forgot to add the modifications of multilib.bkl in the patch.

Changed 11 months ago by R.U.10

comment:12 Changed 11 months ago by vadz

I'd strongly prefer to avoid adding this dependency, it's perfectly possible (and, indeed, much more common) to use AUI without XRC. And we did all this XRC virtualization thing exactly in order to allow having XRC handlers in the library without linking with XRC library itself.

comment:13 Changed 11 months ago by R.U.10

I'm in trouble with the return value of GetNodeType if the node param is NULL.
I would like to do something like that:

In file xmlres.h

enum  WXDLLIMPEXP_FWD_XML wxXmlNodeType;

class WXDLLIMPEXP_XRC wxXmlResourceHandlerImpl : public wxXmlResourceHandlerImplBase
{
public:
    wxXmlNodeType GetNodeType(const wxXmlNode *node) const
    {
        if (node == NULL) return 0;
        return node->GetType();
    }    
};

But there is no enum value for an unknown wxXmlNodeType.

Do you prefer to add an enum value wxXML_UNKNOWN_NODE = 0, in xml.h ?
Or to replace the return type of wxXmlResourceHandlerImpl::GetNodeType by size_t ?
Or perhaps do you have an other idea (no check of the node pointer value...) ?

comment:14 Changed 11 months ago by vadz

Notice that you can't forward declare an enum. Of course, we could work around this (using an enum doesn't require linking with anything), but perhaps it would be better to not provide GetNodeType() but just IsXmlNode()? Looking at the existing handlers, no elements of this enum other than wxXML_ELEMENT_NODE are used currently, so it seems to be the only information that we need.

Thanks for looking at this!

comment:15 Changed 11 months ago by R.U.10

Thank you for your proposals!

But I probably missed something because related to my implementation (see wxAuiToolbarXmlHandler_linking_issue.patch) the linking errors are just put back a little further:

   Creating library ..\..\lib\vc_dll\wxmsw31ud_aui.lib and object ..\..\lib\vc_dll\wxmsw31ud_aui.exp
auidll_xh_auitoolb.obj : error LNK2019: unresolved external "__declspec(dllimport) protected: class wxString const & __thiscall wxXmlResourceHandler::GetNodeName(class wxXmlNode const *)const " (__imp_?GetNodeName@wxXmlResourceHandler@@IBEABVwxString@@PBVwxXmlNode@@@Z) referenced in function "public: virtual class wxObject * __thiscall wxAuiToolBarXmlHandler::DoCreateResource(void)" (?DoCreateResource@wxAuiToolBarXmlHandler@@UAEPAVwxObject@@XZ)
auidll_xh_auitoolb.obj : error LNK2019: unresolved external "__declspec(dllimport) protected: bool __thiscall wxXmlResourceHandler::IsElementNode(class wxXmlNode const *)const " (__imp_?IsElementNode@wxXmlResourceHandler@@IBE_NPBVwxXmlNode@@@Z) referenced in function "public: virtual class wxObject * __thiscall wxAuiToolBarXmlHandler::DoCreateResource(void)" (?DoCreateResource@wxAuiToolBarXmlHandler@@UAEPAVwxObject@@XZ)
auidll_xh_auitoolb.obj : error LNK2019: unresolved external "__declspec(dllimport) protected: class wxXmlNode * __thiscall wxXmlResourceHandler::GetNodeNext(class wxXmlNode const *)const " (__imp_?GetNodeNext@wxXmlResourceHandler@@IBEPAVwxXmlNode@@PBV2@@Z) referenced in function "public: virtual class wxObject * __thiscall wxAuiToolBarXmlHandler::DoCreateResource(void)" (?DoCreateResource@wxAuiToolBarXmlHandler@@UAEPAVwxObject@@XZ)
auidll_xh_auitoolb.obj : error LNK2019: unresolved external "__declspec(dllimport) protected: class wxXmlNode * __thiscall wxXmlResourceHandler::GetNodeChildren(class wxXmlNode const *)const " (__imp_?GetNodeChildren@wxXmlResourceHandler@@IBEPAVwxXmlNode@@PBV2@@Z) referenced in function "public: virtual class wxObject * __thiscall wxAuiToolBarXmlHandler::DoCreateResource(void)" (?DoCreateResource@wxAuiToolBarXmlHandler@@UAEPAVwxObject@@XZ)
..\..\lib\vc_dll\wxmsw310ud_aui_vc_custom.dll : fatal error LNK1120: 4 unresolved externals

comment:16 Changed 11 months ago by vadz

I don't understand this, everything looks fine to me. Sorry for a stupid question, but did you rebuild the core library? It should really have these symbols now...

comment:17 Changed 11 months ago by R.U.10

You are right, just a clean up and it compiles...

So the latest submitted patch should correct the linking issues you reported (I also added the doc).

Regards,
KH

comment:18 Changed 11 months ago by VZ

  • Resolution changed from port to stable to fixed
  • Status changed from new to closed

(In [75734]) Virtualize wxXmlNode methods used by wxAuiToolBarXmlHandler.

This fixes the DLL build of aui library as it can now be linked without
leaving any unresolved dependencies to the code in xml library (where
wxXmlNode is implemented).

Closes #15686.

Note: See TracTickets for help on using tickets.