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 has the 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.
102 Finally, an optional "insert_at" property may be present. Currently only the
103 values "begin" and "end" are supported, meaning to insert the object in the
104 beginning of the parent node objects list or to append it at the end (which is
105 the default if this property is absent).
109 <object name="MyList1" class="wxListCtrl" subclass="MyListCtrlClass">
113 <object> node may have arbitrary child nodes. What child nodes and their
114 semantics are class-dependent and are defined later in this document. The user
115 is allowed to register new object handlers within XRC and extend it to accept
116 new <object> classes (and therefore different <object>'s child nodes).
118 <object_ref> node is identical to <object>, except that it does _not_ have
119 "class" property and has additional required property "ref". Its concept is
120 similar to Unix symlinks: value of the "ref" property is equal to the value of
121 "name" property of some existing node (called referred node) in the resources
122 (not necessary top-level). Referred node's "class" property and all subnodes
123 are copied in place of the referee <object_ref> node which is then processed as
124 regular <object> node. If the <object_ref> node itself has child nodes, then
125 these nodes _override_ any nodes from the referred node.
129 <object name="foo" class="wxTextCtrl">
133 <object_ref name="bar" ref="foo">
134 <value>bar</value> <!-- override! -->
139 <object name="foo" class="wxTextCtrl">
143 <object name="bar" class="wxTextCtrl">
150 3. Common attribute types
151 =========================
153 There are several attribute types (see section 1. Terminology) that are common
154 to many attributes of different classes:
158 Any text. Some characters have special interpretation and are translated
159 by XRC parser according to this table:
160 "_" -> "&" ('&' is used to underline e.g. menu items in wxWidgets)
162 "\n" -> line break (C character '\n')
163 "\r" -> carriage return (C character '\r')
164 "\t" -> tab (C character '\t')
166 (introduced in version 2.5.3.0, not done in earlier versions)
169 '$' was used instead of '_' prior to version 2.3.0.1.
174 Like String, but the value is translated to native language using wxLocale
175 at runtime (unless it was disabled by not passing wxXRC_USE_LOCALE flag to
176 wxXmlResource constructor). Used for strings that are "visible" in the GUI.
181 This is obvious. Only digits 0-9 may be present and there must be at least
187 Like UnsignedInteger but may be prefixed with '-' (ints less than zero).
192 Specifies (window's) position in 2D space. Syntax is <integer>,<integer>[d]
193 where <integer> is valid value of Integer type.
198 Syntax is same as Position's syntax, but the values are interpreted as window
199 size (wxSize type) and not position (wxPosition type).
204 List of style flags that can be passed to wxSomeClass' constructor. Flags are
205 written in same way as in C++ code (e.g. "wxSUNKEN_BORDER",
206 "wxHW_SCROLLBAR_NEVER") and are delimited with any combination of whitespaces
207 and '|'. Possible flags are class-dependent and are not described in this
208 technote. Please refer to wxWidgets manual for all styles that given class can
209 accept; if XRC does not accept a flag listed in wxWidgets documentation, it is
215 Attribute value is interpreted as filename (either absolute or relative to
216 the location of XRC resource file). In addition, attribute node may have
217 "stock_id" and "stock_client" properties. Their values may be any of wxArtID (or
218 wxArtClient respectively) values as used by wxArtProvider (because the user may
219 define own constants, effectively any string is legal here). Examples are
220 "wxART_FILE_OPEN" (id) or "wxART_MENU" (client).
222 Any of "stock_id" or "stock_client" properties or the filename may be omitted.
223 XRC determines the bitmap to use according to this algorithm:
224 1. If there is non-empty "stock_id" property, query wxArtProvider for the
225 bitmap (if there is no "stock_client", use default one, which is usually
226 wxART_OTHER; exceptions are noted in class-specific sections below). If
227 the query fails, continue to 2.
228 2. Load the bitmap from the file in attribute value.
233 Boolean value, either "0" (false) or "1" (true).
238 Font value. A font can be described either in terms of its elementary
239 properties, or it can be derived from one of system fonts. The font node
240 may contain following subnodes (the table lists subnode name on the left and
241 variable type as per the definitions above on the right side):
244 style normal | italic | slant
245 weight normal | bold | light
246 family roman | script | decorative | swiss | modern | teletype
248 face comma-separated list of faces
249 encoding charset of the font (meaningless in Unicode build), as string
250 sysfont symbolic name of system standard font
251 (one of wxSYS_*_FONT constants)
252 relativesize Float, font size relative to chosen system font's size;
253 can only be used when 'sysfont' is used and when 'size' is not
256 All of them are optional, if they are missing, wxFont default is used.
261 <face>arial,helvetica</face>
266 <sysfont>wxSYS_DEFAULT_GUI_FONT</sysfont>
267 <weight>bold</weight>
268 <relativesize>1.5</relativesize>
274 A colour value is either explicit RGB value in the standard #rrggbb format
275 where rr, gg and bb are hexadecimal case-insensitive values in the 00..FF
276 range, or a symbolic name. Symbolic names are wxSYS_COLOUR_* constants defined
277 by wxWidgets, written as strings.
281 <bg>wxSYS_COLOUR_SCROLLBAR</bg>
289 Attributes are listed in tables in the following format:
290 attribute name attribute type default value, if any
291 [(optional remarks....................
292 ...................................)]
296 These attributes are supported by all windows:
302 focused Boolean false
310 This is a special case, because it does not create a wxWindow instance but
311 creates wxBitmap instead. Another exceptional thing is that it does not have
312 any attributes. Instead, the node itself is interpreted as if it were attribute
315 Example: <object class="wxBitmap">bitmaps/foo.gif</object>
320 Identical to wxBitmap class, except that it creates wxIcon instead of wxBitmap.
327 style Style[wxButton]
330 default Boolean false
331 (Is the button default button?)
338 style Style[wxCalendarCtrl]
345 style Style[wxCheckBox]
346 checked Boolean false
353 style Style[wxCheckList]
354 content (see below) (empty)
356 Optional "content" attribute does not have attribute value. Instead,
357 arbitrary number of <item> nodes may be rooted under it (the control
358 is filled with strings contained in these nodes). Each <item>
359 node must contain I18nString value and may have "checked" property
360 with possible values "0" or "1" indicating the the item is initially
364 <object class="wxCheckList">
367 <item checked="1">Two</item>
368 <item checked="1">Three</item>
378 style Style[wxDatePickerCtrl]
385 style Style[wxDialog] wxDEFAULT_DIALOG_STYLE
388 centered Boolean false
390 wxDialog may have children objects.
397 style Style[wxDialog] wxDEFAULT_FRAME_STYLE
400 centered Boolean false
402 wxFrame may have children objects. There can be at most one wxToolBar,
403 wxMenuBar and wxStatusBar children; objects of these types are automatically
404 set as frame's tool-, menu- and statusbar respectively.
410 wxMenu objects can contain objects of class "separator" and "break" as well as
411 normal menu items, of class "wxMenuItem" described below. The menu itself can
412 also have the following elements:
417 style Style[wxMenu] only wxMENU_TEAROFF currently
424 bitmap Bitmap (empty)
425 bitmap2 Bitmap checked bitmap, wxMSW only
426 checkable Boolean false
429 checked Boolean false ("checkable" and "radio")
434 Supports same attributes and children nodes as wxFrame. Additionally, children
435 may be of the wxMDIChildFrame type.
441 Supports same attributes and children nodes as wxFrame.
447 This control may have "dimension" (major dimension) and (initial) "selection"
448 Integer subelements and a composite "content" element similar to wxCheckList
449 except that <item> subelements can have additional attributes:
451 tooltip I18nString ""
452 helptext I18nString ""
461 style Style[wxScrolledWindow] wxHSCROLL | wxVSCROLL
464 wxScolledWindow may have children objects.
471 style Style[wxSplitterWindow] wxSP_3D
473 (Initial sash position)
476 orientation "horizontal"|"vertical" horizontal
478 wxSplitterWindow must have at least one and at most two children objects.
479 If there's only one child object, it is passed to wxSplitterWindow::Initialize
480 and the splitter is created unsplit. If there are two children, the
481 splitter is created split, either horizontally or vertically depending
482 on the value of "orientation" attribute.
488 wxStaticText supports one class-specific attribute which wraps the controls
489 contents at the specified boundary:
491 wrap Integer, in pixels None
495 fields Integer number of fields
496 widths Width1, Width2, Width3, ...
503 style Style[wxToolBar] wxNO_BORDER|wxTB_HORIZONTAL
504 bitmapsize Size -1,-1
505 (Size of contained bitmaps)
508 separation Integer -1
509 bg Background colour None
510 dontattachtoframe Boolean False
512 wxToolBar node may have children <object> and <object_ref> nodes. Their class
513 may be either "tool", "separator" or any wxWidgets class derived from
514 wxControl. "tool" and "separator" are special pseudo-classes that may only
515 appear within wxToolBar node. Their attributes are as follows:
519 (doesn't have any attributes)
524 bitmap2 Bitmap wxNullBitmap
529 tooltip I18nString ""
530 longhelp I18nString ""
533 At most one of "toggle" and "radio" attributes may be 1.
535 Children objects are added to the toolbar using AddTool for "tool" class,
536 AddSeparator for "separator" and AddControl for other classes.
543 FIXME -- "platform" property handling