2014-06-11 21:14:09 +00:00
|
|
|
How to add a new XRC handler
|
|
|
|
============================
|
2014-06-11 21:14:02 +00:00
|
|
|
|
|
|
|
0. Purpose
|
|
|
|
----------
|
|
|
|
|
|
|
|
This note describes what needs to be done to add a new XRC handler, i.e. add
|
|
|
|
support for loading the objects of some class wxFoo from XRC.
|
|
|
|
|
|
|
|
|
|
|
|
1. Implement the handler
|
|
|
|
------------------------
|
|
|
|
|
|
|
|
By convention, the XRC handler for a class wxFoo declared in wx/foo.h is called
|
|
|
|
wxFooXmlHandler and is declared in the file wx/xrc/xh_foo.h (this last rule
|
|
|
|
wasn't always respected in the past, however it's not a reason to not respect
|
|
|
|
it in the future). The steps for adding a new handler are:
|
|
|
|
|
2014-06-11 21:14:09 +00:00
|
|
|
- Add handler declaration in include/wx/xrc/xh_foo.h, it will usually be the
|
2014-06-11 21:14:02 +00:00
|
|
|
same as in the other files so you can get inspiration for your brand new
|
2014-06-11 21:14:09 +00:00
|
|
|
handler from e.g. wx/xrc/xh_srchctrl.h. Notice the use of `wxUSE_FOO` if wxFoo
|
2014-06-11 21:14:02 +00:00
|
|
|
is guarded by this symbol.
|
|
|
|
|
2014-06-11 21:14:09 +00:00
|
|
|
- Add implementation in src/xrc/xh_foo.cpp: again, it will be almost always
|
2014-06-11 21:14:02 +00:00
|
|
|
very similar to the existing controls. You will need to add support for
|
|
|
|
the control-specific styles.
|
|
|
|
|
|
|
|
|
|
|
|
2. Update the other files
|
|
|
|
-------------------------
|
|
|
|
|
|
|
|
There are a few other files to update to make wxWidgets aware of the new
|
|
|
|
handler:
|
|
|
|
|
2014-06-11 21:14:09 +00:00
|
|
|
- Add the new files created above to build/bakefiles/files.bkl: search for
|
2014-06-11 21:14:02 +00:00
|
|
|
"xh_srchctrl" to see where you need to add them
|
|
|
|
|
2014-06-11 21:14:09 +00:00
|
|
|
- Add #include "wx/xrc/xh_foo.h" to wx/xrc/xh_all.h.
|
2014-06-11 21:14:02 +00:00
|
|
|
|
2014-06-11 21:14:09 +00:00
|
|
|
- Register the new handler in wxXmlResource::InitAllHandlers() in
|
2014-06-11 21:14:02 +00:00
|
|
|
src/xrc/xmlrsall.cpp
|
|
|
|
|
|
|
|
|
|
|
|
3. Update the sample
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
Demonstrate that the new handler works by adding a control using it to
|
|
|
|
samples/xrc/rc/controls.xrc.
|