]> git.saurik.com Git - wxWidgets.git/blob - docs/tech/tn0024.txt
Fix wrong configure test for abi::__forced_unwind in previous commit.
[wxWidgets.git] / docs / tech / tn0024.txt
1 How to add a new XRC handler
2 ============================
3
4 0. Purpose
5 ----------
6
7 This note describes what needs to be done to add a new XRC handler, i.e. add
8 support for loading the objects of some class wxFoo from XRC.
9
10
11 1. Implement the handler
12 ------------------------
13
14 By convention, the XRC handler for a class wxFoo declared in wx/foo.h is called
15 wxFooXmlHandler and is declared in the file wx/xrc/xh_foo.h (this last rule
16 wasn't always respected in the past, however it's not a reason to not respect
17 it in the future). The steps for adding a new handler are:
18
19 a) Add handler declaration in include/wx/xrc/xh_foo.h, it will usually be the
20 same as in the other files so you can get inspiration for your brand new
21 handler from e.g. wx/xrc/xh_srchctrl.h. Notice the use of wxUSE_FOO if wxFoo
22 is guarded by this symbol.
23
24 b) Add implementation in src/xrc/xh_foo.cpp: again, it will be almost always
25 very similar to the existing controls. You will need to add support for
26 the control-specific styles.
27
28
29 2. Update the other files
30 -------------------------
31
32 There are a few other files to update to make wxWidgets aware of the new
33 handler:
34
35 a) Add the new files created above to build/bakefiles/files.bkl: search for
36 "xh_srchctrl" to see where you need to add them
37
38 b) Add #include "wx/xrc/xh_foo.h" to wx/xrc/xh_all.h.
39
40 c) Register the new handler in wxXmlResource::InitAllHandlers() in
41 src/xrc/xmlrsall.cpp
42
43
44 3. Update the sample
45 --------------------
46
47 Demonstrate that the new handler works by adding a control using it to
48 samples/xrc/rc/controls.xrc.
49
50
51 === EOF ===
52
53 Author: VZ
54 Version: $Id: tn0021.txt 47865 2007-08-03 20:00:32Z VZ $
55