From: Vadim Zeitlin Date: Thu, 16 Aug 2007 21:12:10 +0000 (+0000) Subject: added a tech note explaining how to write a new XRC handler X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/5c92385e69880be2880249dcc632349e6f45a0ae?ds=inline added a tech note explaining how to write a new XRC handler git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48141 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/tech/index.txt b/docs/tech/index.txt index 1f95a6919f..85582f627d 100644 --- a/docs/tech/index.txt +++ b/docs/tech/index.txt @@ -24,6 +24,6 @@ tn0020.txt Binary compatibility and wxWidgets tn0021.txt How to add a new wxUSE_XXX preprocessor constant tn0022.txt Working with the wxWidgets release system tn0023.txt Adding a new app/screenshot to the wxWidgets.org front page - +tn0024.txt How to add a new XRC handler Version: $Id$ diff --git a/docs/tech/tn0024.txt b/docs/tech/tn0024.txt new file mode 100644 index 0000000000..d835fe4def --- /dev/null +++ b/docs/tech/tn0024.txt @@ -0,0 +1,55 @@ + 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 +Version: $Id: tn0021.txt 47865 2007-08-03 20:00:32Z VZ $ +