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) DialogBlocks (wxPython/tools)
18 and others listed on the Resources section of the wxWidgets web
21 The XRC format is based on XML 1.0 (please consult W3C's specification). There
22 is no DTD available since it is not possible to fully describe the format with
23 the limited expressive power of DTDs.
26 Note: see also http://ldaptool.sourceforge.net/XRCGuide/XRCGuideSingle/
33 The usual XML terminology applies. In particular, we shall use the terms
34 NODE, PROPERTY and VALUE in the XML sense:
36 <node property1="value1" property2="value2">...</node>
38 The term ATTRIBUTE is specific to XRC and refers to a subnode
39 of an <object> or <object_ref> node that is itself not <object> or <object_ref>.
40 In the example below, <pos>, <label> and <style> are attributes, while neither
41 <resource> nor either of <object>s is:
43 <?xml version="1.0" encoding="utf-8">
44 <resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.5.3.0">
45 <object class="wxPanel">
46 <style>wxSUNKEN_BORDER</style> <!-- attr -->
47 <object class="wxStaticText">
48 <label>A label</label> <!-- attr -->
49 <pos>10,10</pos> <!-- attr -->
54 ATTRIBUTE VALUE is the content of all text elements within attribute tag. In the
55 above example, "wxSUNKEN_BORDER", "A label" and "10,10" are attribute values.
56 ATTRIBUTE TYPE defines what attribute values are valid for given attribute (you
57 can think of it as attribute value syntax definition).
61 2. Elementary description
62 =========================
64 XRC resource file is a well-formed XML 1.0 document. All elements of XRC file
65 are from the http://www.wxwidgets.org/wxxrc namespace.
67 The root node of XRC document must be <resource>. The <resource> node has
68 optional "version" property. Default version (in absence of the version
69 property) is "0.0.0.0". The version consists of four integers separated by
70 periods. Version of XRC format changes only if there was an incompatible
71 change introduced (i.e. either the library cannot understand old resource
72 files or older versions of the library wouldn't understand the new format).
73 The first three integers are major, minor and release number of the wxWidgets
74 release when the change was introduced, the last one is revision number and
75 is 0 for the first incompatible change in given wxWidgets release, 1 for
78 Differences between versions are described within this document in paragraphs
79 entitled "Version Note".
81 The <resource> node contains namespace declaration, too:
83 <resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.5.3.0">
85 The <resource> node is only allowed to have <object> and <object_ref>
86 subnodes, all of which must have the "name" property.
88 The <object> node represents a single object (GUI element) and it usually maps
89 directly to a wxWidgets class instance. It three properties: "name", "class"
90 and "subclass". "class" must always be present, it tells XRC what wxWidgets
91 object should be created in this place. The other two are optional. "name" is
92 ID used to identify the object. It is the value passed to the XRCID() macro and
93 is also used to construct wxWindow's id and name attributes and must be unique
94 among all children of the nearest container object (wxDialog, wxFrame,
95 wxPanel, wxNotebook) upside from the object in XML nodes hierarchy (two distinct
96 containers may contain objects with same "name", though). "subclass" is
97 optional name of class whose constructor will be called instead of the
98 constructor for "class". Subclass must be available in the program that loads
99 the resource, must be derived from "class" and must be registered within
100 wxWidgets' RTTI system.
104 <object name="MyList1" class="wxListCtrl" subclass="MyListCtrlClass">
108 <object> node may have arbitrary child nodes. What child nodes and their
109 semantics are class-dependent and are defined later in this document. The user
110 is allowed to register new object handlers within XRC and extend it to accept
111 new <object> classes (and therefore different <object>'s child nodes).
113 <object_ref> node is identical to <object>, except that it does _not_ have
114 "class" property and has additional required property "ref". Its concept is
115 similar to Unix symlinks: value of the "ref" property is equal to the value of
116 "name" property of some existing node (called referred node) in the resources
117 (not necessary top-level). Referred node's "class" property and all subnodes
118 are copied in place of the referee <object_ref> node which is then processed as
119 regular <object> node. If the <object_ref> node itself has child nodes, then
120 these nodes _override_ any nodes from the referred node.
124 <object name="foo" class="wxTextCtrl">
128 <object_ref name="bar" ref="foo">
129 <value>bar</value> <!-- override! -->
134 <object name="foo" class="wxTextCtrl">
138 <object name="bar" class="wxTextCtrl">
145 3. Common attribute types
146 =========================
148 There are several attribute types (see section 1. Terminology) that are common
149 to many attributes of different classes:
153 Any text. Some characters have special interpretation and are translated
154 by XRC parser according to this table:
155 "_" -> "&" ('&' is used to underline e.g. menu items in wxWidgets)
157 "\n" -> line break (C character '\n')
158 "\r" -> carriage return (C character '\r')
159 "\t" -> tab (C character '\t')
161 (introduced in version 2.5.3.0, not done in earlier versions)
164 '$' was used instead of '_' prior to version 2.3.0.1.
169 Like String, but the value is translated to native language using wxLocale
170 at runtime (unless it was disabled by not passing wxXRC_USE_LOCALE flag to
171 wxXmlResource constructor). Used for strings that are "visible" in the GUI.
176 This is obvious. Only digits 0-9 may be present and there must be at least
182 Like UnsignedInteger but may be prefixed with '-' (ints less than zero).
187 Specifies (window's) position in 2D space. Syntax is <integer>,<integer>[d]
188 where <integer> is valid value of Integer type.
193 Syntax is same as Position's syntax, but the values are interpreted as window
194 size (wxSize type) and not position (wxPosition type).
199 List of style flags that can be passed to wxSomeClass' constructor. Flags are
200 written in same way as in C++ code (e.g. "wxSUNKEN_BORDER",
201 "wxHW_SCROLLBAR_NEVER") and are delimited with any combination of whitespaces
202 and '|'. Possible flags are class-dependent and are not described in this
203 technote. Please refer to wxWidgets manual for all styles that given class can
204 accept; if XRC does not accept a flag listed in wxWidgets documentation, it is
210 Attribute value is interpreted as filename (either absolute or relative to
211 the location of XRC resource file). In addition, attribute node may have
212 "stock_id" and "stock_client" properties. Their values may be any of wxArtID (or
213 wxArtClient respectively) values as used by wxArtProvider (because the user may
214 define own constants, effectively any string is legal here). Examples are
215 "wxART_FILE_OPEN" (id) or "wxART_MENU" (client).
217 Any of "stock_id" or "stock_client" properties or the filename may be omitted.
218 XRC determines the bitmap to use according to this algorithm:
219 1. If there is non-empty "stock_id" property, query wxArtProvider for the
220 bitmap (if there is no "stock_client", use default one, which is usually
221 wxART_OTHER; exceptions are noted in class-specific sections below). If
222 the query fails, continue to 2.
223 2. Load the bitmap from the file in attribute value.
228 Boolean value, either "0" (false) or "1" (true).
233 Font value. A font can be described either in terms of its elementary
234 properties, or it can be derived from one of system fonts. The font node
235 may contain following subnodes (the table lists subnode name on the left and
236 variable type as per the definitions above on the right side):
239 style normal | italic | slant
240 weight normal | bold | light
241 family roman | script | decorative | swiss | modern | teletype
243 face comma-separated list of faces
244 encoding charset of the font (meaningless in Unicode build), as string
245 sysfont symbolic name of system standard font
246 (one of wxSYS_*_FONT constants)
247 relativesize Float, font size relative to choosen system font's size;
248 can only be used when 'sysfont' is used and when 'size' is not
251 All of them are optional, if they are missing, wxFont default is used.
256 <face>arial,helvetica</face>
261 <sysfont>wxSYS_DEFAULT_GUI_FONT</sysfont>
262 <weight>bold</weight>
263 <relativesize>1.5</relativesize>
269 A colour value is either explicit RGB value in the standard #rrggbb format
270 where rr, gg and bb are hexadecimal case-insensitive values in the 00..FF
271 range, or a symbolic name. Symbolic names are wxSYS_COLOUR_* constants defined
272 by wxWidgets, written as strings.
276 <bg>wxSYS_COLOUR_SCROLLBAR</bg>
284 Attributes are listed in tables in the following format:
285 attribute name attribute type default value, if any
286 [(optional remarks....................
287 ...................................)]
291 This is a special case, because it does not create a wxWindow instance but
292 creates wxBitmap instead. Another exceptional thing is that it does not have
293 any attributes. Instead, the node itself is interpreted as if it were attribute
296 Example: <object class="wxBitmap">bitmaps/foo.gif</object>
301 Identical to wxBitmap class, except that it creates wxIcon instead of wxBitmap.
308 style Style[wxButton]
311 default Boolean false
312 (Is the button default button?)
319 style Style[wxCalendarCtrl]
326 style Style[wxCheckBox]
327 checked Boolean false
334 style Style[wxCheckList]
335 content (see below) (empty)
337 Optional "content" attribute does not have attribute value. Instead,
338 arbitrary number of <item> nodes may be rooted under it (the control
339 is filled with strings contained in these nodes). Each <item>
340 node must contain I18nString value and may have "checked" property
341 with possible values "0" or "1" indicating the the item is initially
345 <object class="wxCheckList">
348 <item checked="1">Two</item>
349 <item checked="1">Three</item>
359 style Style[wxDatePickerCtrl]
366 style Style[wxDialog] wxDEFAULT_DIALOG_STYLE
369 centered Boolean false
371 wxDialog may have children objects.
378 style Style[wxDialog] wxDEFAULT_FRAME_STYLE
381 centered Boolean false
383 wxFrame may have children objects. There can be at most one wxToolBar,
384 wxMenuBar and wxStatusBar children; objects of these types are automatically
385 set as frame's tool-, menu- and statusbar respectively.
391 Supports same attributes and children nodes as wxFrame. Additionally, children
392 may be of the wxMDIChildFrame type.
398 Supports same attributes and children nodes as wxFrame.
405 style Style[wxScrolledWindow] wxHSCROLL | wxVSCROLL
407 wxScolledWindow may have children objects.
414 style Style[wxSplitterWindow] wxSP_3D
416 (Initial sash position)
419 orientation "horizontal"|"vertical" horizontal
421 wxSplitterWindow must have at least one and at most two children objects.
422 If there's only one child object, it is passed to wxSplitterWindow::Initialize
423 and the splitter is created unsplit. If there are two children, the
424 splitter is created split, either horizontally or vertically depending
425 on the value of "orientation" attribute.
430 fields Integer number of fields
431 widths Width1, Width2, Width3, ...
438 style Style[wxToolBar] wxNO_BORDER|wxTB_HORIZONTAL
439 bitmapsize Size -1,-1
440 (Size of contained bitmaps)
443 separation Integer -1
445 wxToolBar node may have children <object> and <object_ref> nodes. Their class
446 may be either "tool", "separator" or any wxWidgets class derived from
447 wxControl. "tool" and "separator" are special pseudo-classes that may only
448 appear within wxToolBar node. Their attributes are as follows:
452 (doesn't have any attributes)
457 bitmap2 Bitmap wxNullBitmap
461 tooltip I18nString ""
462 longhelp I18nString ""
466 At most one of "toggle" and "radio" attributes may be 1.
467 Attribute "pos" may not appear if "label" or "radio" attributes
468 are used or if parent wxToolBar's style contains wxTB_TEXT.
471 Use of "pos" attribute is strongly discouraged, it is deprecated
472 usage of wxToolBar and it is not supported by MSW and GTK
475 Children objects are added to the toolbar using AddTool for "tool" class,
476 AddSeparator for "separator" and AddControl for other classes.
483 FIXME -- "platform" property handling