1 XRC resources format specification
2 ==================================
4 !!!!! NOT YET FINISHED !!!!!
9 This note describes the file format used for storing XRC resources that are
10 used by wxXmlResource class. It is probably only useful for those implementing
11 dialog editors with XRC support.
13 If you only want to use the resources, you can choose from a number of editors:
14 a) wxDesigner (http://www.roebling.de)
15 b) XRCed (wxPython/tools)
16 c) wxWorkshop (http://wxworkshop.sf.net)
17 b) wxrcedit (contrib/utils/wxrcedit)
19 The XRC format is based on XML 1.0 (please consult W3C's specification). There
20 is no DTD available since it is not possible to fully describe the format with
21 the limited expressive power of DTDs.
28 The usual XML terminology applies. In particular, we shall use the terms
29 NODE, PROPERTY and VALUE in the XML sense:
31 <node property1="value1" property2="value2">...</node>
33 The term ATTRIBUTE is specific to XRC and refers to a subnode
34 of an <object> or <object_ref> node that is itself not <object> or <object_ref>.
35 In the example bellow, <pos>, <label> and <style> are attributes, while neither
36 <resource> nor either of <object>s is:
38 <?xml version="1.0" encoding="utf-8">
39 <resource xmlns="http://www.wxwindows.org/wxxrc" version="2.3.0.1">
40 <object class="wxPanel">
41 <style>wxSUNKEN_BORDER</style> <!-- attr -->
42 <object class="wxStaticText">
43 <label>A label</label> <!-- attr -->
44 <pos>10,10</pos> <!-- attr -->
49 ATTRIBUTE VALUE is the content of all text elements within attribute tag. In the
50 above example, "wxSUNKEN_BORDER", "A label" and "10,10" are attribute values.
51 ATTRIBUTE TYPE defines what attribute values are valid for given attribute (you
52 can think of it as attribute value syntax definition).
56 2. Elementary description
57 =========================
59 XRC resource file is a well-formed XML 1.0 document. All elements of XRC file are
60 from the http://www.wxwindows.org/wxxrc namespace.
62 The root node of XRC document must be <resource>. The <resource> node has
63 optional "version" property. Default version (in absence of the version
64 property) is "0.0.0.0". The version consists of four integers separated by
65 periods. Version of XRC format changes only if there was an incompatible
66 change introduced (i.e. either the library cannot understand old resource
67 files or older versions of the library wouldn't understand the new format).
68 The first three integers are major, minor and release number of the wxWindows
69 release when the change was introduced, the last one is revision number and
70 is 0 for the first incompatible change in given wxWindows release, 1 for
73 Differences between versions are described within this document in paragraphs
74 entitled "Version Note".
76 The <resource> node contains namespace declaration, too:
78 <resource xmlns="http://www.wxwindows.org/wxxrc" version="2.3.0.1">
80 The <resource> node is only allowed to have <object> and <object_ref>
81 subnodes, all of which must have the "name" property.
83 The <object> node represents a single object (GUI element) and it usually maps
84 directly to a wxWindows class instance. It three properties: "name", "class"
85 and "subclass". "class" must always be present, it tells XRC what wxWindows
86 object should be created in this place. The other two are optional.
87 "name" is ID used to identify the object. It is the value passed to the XRCID() macro
88 and is also used to construct wxWindow's id and name attributes and must be unique
89 among all children of the neareset container object (wxDialog, wxFrame, wxPanel,
90 wxNotebook) upside from the object in XML nodes hiearchy (two distinct containers
91 may contain objects with same "name", though). "subclass" is
92 optional name of class whose constructor will be called instead of the constructor
93 for "class". Subclass must be available in the program that loads the resource,
94 must be derived from "class" and must be registered within wxWindows' RTTI system.
98 <object name="MyList1" class="wxListCtrl" subclass="MyListCtrlClass">
102 <object> node may have arbitrary child nodes. What child nodes and their semantics
103 are class-dependent and are defined later in this document. The user is allowed
104 to register new object handlers within XRC and extend it to accept new <object>
105 classes (and therefore different <object>'s child nodes).
107 <object_ref> node is identical to <object>, except that it does _not_ have "class"
108 property and has additonal required property "ref". It's concept is similar to Unix
109 symlinks: value of the "ref" property is equal to the value of "name" property of
110 some existing node (called referred node) in the resources (not neccessary top-level).
111 Referred node's "class" property and all subnodes are copied in place of the referee
112 <object_ref> node which is then processed as regular <object> node. If the <object_ref>
113 node itself has child nodes, then these nodes _override_ any nodes from the referred node.
117 <object name="foo" class="wxTextCtrl">
121 <object_ref name="bar" ref="foo">
122 <value>bar</value> <!-- override! -->
127 <object name="foo" class="wxTextCtrl">
131 <object name="bar" class="wxTextCtrl">
138 3. Common attribute types
139 =========================
141 There are several attribute types (see section 1. Terminology) that are common
142 to many attributes of different classes:
146 Any text. Some characters have special interpretation and are translated
147 by XRC parser according to this table:
148 "_" -> "&" ('&' is used to underline e.g. menu items in wxWindows)
150 "\n" -> line break (C character '\n')
151 "\r" -> carriage return (C character '\r')
152 "\t" -> tabelator (C character '\t')
155 '$' was used instead of '_' prior to version 2.3.0.1.
160 Like String, but the value is translated to native language using wxLocale
161 at runtime (unless it was disabled by not passing wxXRC_USE_LOCALE flag to
162 wxXmlResource constructor). Used for strings that are "visible" in the GUI.
167 This is obvious. Only digits 0-9 may be present and there must be at least
173 Like UnsignedInteger but may be prefixed with '-' (ints less than zero).
178 Specifies (window's) position in 2D space. Syntax is <integer>,<integer>[d]
179 where <integer> is valid value of Integer type.
184 Syntax is same as Position's syntax, but the values are interpreted as window
185 size (wxSize type) and not position (wxPosition type).
190 List of style flags that can be passed to wxSomeClass' constructor. Flags are
191 written in same way as in C++ code (e.g. "wxSUNKEN_BORDER", "wxHW_SCROLLBAR_NEVER")
192 and are delimined with any combination of whitespaces and '|'. Possible flags
193 are class-dependent and are not described in this technote. Please refer to wxWindows
194 manual for all styles that given class can accept; if XRC does not accept a flag
195 listed in wxWindows documentation, it is a bug.
200 Attribute value is interpreted as filename (either absolute or relative to
201 the location of XRC resource file). In addition, attribute node may have
202 "stock_id" and "stock_client" properties. Their values may be any of wxArtID (or
203 wxArtClient respectively) values as used by wxArtProvider (because the user may
204 define own constants, efectively any string is legal here). Examples are
205 "wxART_FILE_OPEN" (id) or "wxART_MENU" (client).
207 Any of "stock_id" or "stock_client" properties or the filename may be omitted. XRC
208 determines the bitmap to use according to this algorithm:
209 1. If there is non-empty "stock_id" property, query wxArtProvider for the bitmap
210 (if there is no "stock_client", use default one, which is usually wxART_OTHER;
211 exceptions are noted in class-specific sections bellow). If the query fails,
213 2. Load the bitmap from the file in attribute value.
218 Boolean value, either "0" (false) or "1" (true).
225 Attributes are listed in tables in the following format:
226 attribute name attribute type default value, if any
227 [(optional remarks....................
228 ...................................)]
232 This is a special case, because it does not create a wxWindow instance but
233 creates wxBitmap instead. Another exceptional thing is that it does not have
234 any attributes. Instead, the node itself is interpreted as if it were attribute
237 Example: <object class="wxBitmap">bitmaps/foo.gif</object>
242 Identical to wxBitmap class, except that it creates wxIcon instead of wxBitmap.
247 position Position -1,-1
249 style Style[wxButton]
252 default Boolean false
253 (Is the button default button?)
258 position Position -1,-1
260 style Style[wxCalendarCtrl]
265 position Position -1,-1
267 style Style[wxCheckBox]
268 checked Boolean false
273 position Position -1,-1
275 style Style[wxCheckList]
276 content (see bellow) (empty)
278 Optional "content" attribute does not have attribute value. Instead,
279 arbitrary number of <item> nodes may be rooted under it (the control
280 is filled with strings contained in these nodes). Each <item>
281 node must contain I18nString value and may have "checked" property
282 with possible values "0" or "1" indicating the the item is initially
286 <object class="wxCheckList">
289 <item checked="1">Two</item>
290 <item checked="1">Three</item>
298 position Position -1,-1
300 style Style[wxScrolledWindow] wxHSCROLL | wxVSCROLL
307 FIXME -- "platform" property handling