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