Ticket URL: <
http://trac.wxwidgets.org/ticket/14632#comment:3>
#14632: XRC derive font from enclosing control
------------------------------------+---------------------------------------
Reporter: sodev | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 2.9.5
Component: XRC | Version: 2.9-svn
Keywords: xrc wxFont inheritance | Blockedby:
Patch: 1 | Blocking:
------------------------------------+---------------------------------------
Comment(by sodev):
Yes, you are missing something, the toggle button and unknown control
handlers are the only ones that do not use the XRC_MAKE_INSTANCE macro so
i had to patch them additionally, every handler that uses
XRC_MAKE_INSTANCE to create the object works without modification ;).
Compatibility with existing XRC files and handlers were my main goal, i
thought about that extra parameter for {{{GetFont()}}} as well, but if any
handler uses it on its own it needs to be changed to actually use this new
feature. I looked around the sources to understand how the xrc handlers
work and what all the members are for and {{{m_instance}}} catched my
attention. If it is non-NULL XRC_MAKE_INSTANCE simply returns it, however
if its not, it creates a new object and returns that pointer. Now the
problem is that this new object can only be accessed locally at the
location where that macro is used because the pointer is nowhere stored in
the handler object.
So if i supply a pre-created object to the handler the whole handler can
access it and even my GetFont()-modification works out of the box, however
if the object gets created no part of the handler has access to it but the
function that actually created it. I don't see any reason why the handler
shouldn't be able to access the created object, actually it looks like an
error to me that it cannot access that new object from other parts in that
case.
I checked all handlers in the source tree if they do something with
{{{m_instance}}}, but all they do is check if it's non-NULL to create a
new object instead of using it. And actually i found another location that
does modify {{{m_instance}}}:
{{{wxXmlResourceHandler::CreateResource(wxXmlNode*, wxObject*,
wxObject*)}}}. If you use subclassing it stores the created object
directly in it. So if any custom handler relies on the fact that
{{{m_instance}}} is never populated if the object is pre-created they
break if you use subclassing ;). So i think it is a symmetric solution to
let {{{m_instance}}} always point to the object that the handler is
processing, if it was pre-created or if it was created on demand.
----
My name, Steffen Olszewski, is no secret at all, i am signed up with it
here and was even a little surprised that it wasn't used for my
wxThreadEvent patch previously. Also my boss has no problem at all if our
company, Gero Meßsysteme GmbH, gets mentioned as well ;).
I'm going to add another patch for the examples next week.
--
Ticket URL: <
http://trac.wxwidgets.org/ticket/14632#comment:3>