File: tn0024.txt

package info (click to toggle)
wxwidgets3.0 3.0.5.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 120,464 kB
  • sloc: cpp: 896,633; makefile: 52,303; ansic: 21,971; sh: 5,713; python: 2,940; xml: 1,534; perl: 264; javascript: 33
file content (54 lines) | stat: -rw-r--r-- 1,652 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
                         How to add a new XRC handler
                         ============================

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:

a) Add handler declaration in include/wx/xrc/xh_foo.h, it will usually be the
   same as in the other files so you can get inspiration for your brand new
   handler from e.g. wx/xrc/xh_srchctrl.h. Notice the use of wxUSE_FOO if wxFoo
   is guarded by this symbol.

b) Add implementation in src/xrc/xh_foo.cpp: again, it will be almost always
   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:

a) Add the new files created above to build/bakefiles/files.bkl: search for
   "xh_srchctrl" to see where you need to add them

b) Add #include "wx/xrc/xh_foo.h" to wx/xrc/xh_all.h.

c) Register the new handler in wxXmlResource::InitAllHandlers() in
   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.


=== EOF ===

Author:  VZ