tn0024.txt 1.6 KB

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