]> git.saurik.com Git - wxWidgets.git/blame - docs/tech/tn0014.txt
Use a working dir for the uninstaller that does exist.
[wxWidgets.git] / docs / tech / tn0014.txt
CommitLineData
50ccbaaa
VS
1 XRC resources format specification
2 ==================================
3
4 !!!!! NOT YET FINISHED !!!!!
5
60. Introduction
2b5f62a0 7===============
50ccbaaa
VS
8
9This note describes the file format used for storing XRC resources that are
10used by wxXmlResource class. It is probably only useful for those implementing
11dialog editors with XRC support.
12
13If 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)
18
19The XRC format is based on XML 1.0 (please consult W3C's specification). There
20is no DTD available since it is not possible to fully describe the format with
21the limited expressive power of DTDs.
22
2b5f62a0 23
b2ec1c82
VS
24Note: see also http://ldaptool.sourceforge.net/XRCGuide/XRCGuideSingle/
25
26
2b5f62a0 27
50ccbaaa 281. Terminology
2b5f62a0 29==============
50ccbaaa
VS
30
31The usual XML terminology applies. In particular, we shall use the terms
2b5f62a0 32NODE, PROPERTY and VALUE in the XML sense:
50ccbaaa
VS
33
34 <node property1="value1" property2="value2">...</node>
35
2b5f62a0
VZ
36The term ATTRIBUTE is specific to XRC and refers to a subnode
37of an <object> or <object_ref> node that is itself not <object> or <object_ref>.
984c33c9 38In the example below, <pos>, <label> and <style> are attributes, while neither
2b5f62a0 39<resource> nor either of <object>s is:
50ccbaaa
VS
40
41 <?xml version="1.0" encoding="utf-8">
984c33c9 42 <resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.5.3.0">
50ccbaaa 43 <object class="wxPanel">
2b5f62a0 44 <style>wxSUNKEN_BORDER</style> <!-- attr -->
50ccbaaa 45 <object class="wxStaticText">
2b5f62a0
VZ
46 <label>A label</label> <!-- attr -->
47 <pos>10,10</pos> <!-- attr -->
50ccbaaa
VS
48 </object>
49 </object>
50 </resource>
51
2b5f62a0
VZ
52ATTRIBUTE VALUE is the content of all text elements within attribute tag. In the
53above example, "wxSUNKEN_BORDER", "A label" and "10,10" are attribute values.
54ATTRIBUTE TYPE defines what attribute values are valid for given attribute (you
55can think of it as attribute value syntax definition).
56
57
58
50ccbaaa 592. Elementary description
2b5f62a0 60=========================
50ccbaaa 61
432be5aa 62XRC resource file is a well-formed XML 1.0 document. All elements of XRC file
fc2171bd 63are from the http://www.wxwidgets.org/wxxrc namespace.
50ccbaaa
VS
64
65The root node of XRC document must be <resource>. The <resource> node has
66optional "version" property. Default version (in absence of the version
67property) is "0.0.0.0". The version consists of four integers separated by
68periods. Version of XRC format changes only if there was an incompatible
69change introduced (i.e. either the library cannot understand old resource
70files or older versions of the library wouldn't understand the new format).
fc2171bd 71The first three integers are major, minor and release number of the wxWidgets
50ccbaaa 72release when the change was introduced, the last one is revision number and
fc2171bd 73is 0 for the first incompatible change in given wxWidgets release, 1 for
50ccbaaa
VS
74the second etc.
75
76Differences between versions are described within this document in paragraphs
2b5f62a0 77entitled "Version Note".
50ccbaaa 78
40e2d134
VS
79The <resource> node contains namespace declaration, too:
80
984c33c9 81 <resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.5.3.0">
40e2d134 82
50ccbaaa
VS
83The <resource> node is only allowed to have <object> and <object_ref>
84subnodes, all of which must have the "name" property.
85
2b5f62a0 86The <object> node represents a single object (GUI element) and it usually maps
fc2171bd
JS
87directly to a wxWidgets class instance. It three properties: "name", "class"
88and "subclass". "class" must always be present, it tells XRC what wxWidgets
432be5aa
VS
89object should be created in this place. The other two are optional. "name" is
90ID used to identify the object. It is the value passed to the XRCID() macro and
91is also used to construct wxWindow's id and name attributes and must be unique
92among all children of the neareset container object (wxDialog, wxFrame,
93wxPanel, wxNotebook) upside from the object in XML nodes hiearchy (two distinct
94containers may contain objects with same "name", though). "subclass" is
95optional name of class whose constructor will be called instead of the
96constructor for "class". Subclass must be available in the program that loads
97the resource, must be derived from "class" and must be registered within
fc2171bd 98wxWidgets' RTTI system.
2b5f62a0
VZ
99
100Example:
101
102 <object name="MyList1" class="wxListCtrl" subclass="MyListCtrlClass">
103 ...
104 </object>
105
432be5aa
VS
106<object> node may have arbitrary child nodes. What child nodes and their
107semantics are class-dependent and are defined later in this document. The user
108is allowed to register new object handlers within XRC and extend it to accept
109new <object> classes (and therefore different <object>'s child nodes).
110
111<object_ref> node is identical to <object>, except that it does _not_ have
112"class" property and has additonal required property "ref". It's concept is
113similar to Unix symlinks: value of the "ref" property is equal to the value of
114"name" property of some existing node (called referred node) in the resources
115(not neccessary top-level). Referred node's "class" property and all subnodes
116are copied in place of the referee <object_ref> node which is then processed as
117regular <object> node. If the <object_ref> node itself has child nodes, then
118these nodes _override_ any nodes from the referred node.
2b5f62a0
VZ
119
120Example:
121
122 <object name="foo" class="wxTextCtrl">
123 <value>hello</value>
124 <size>100,-1d</size>
125 </object>
126 <object_ref name="bar" ref="foo">
127 <value>bar</value> <!-- override! -->
0fa2e104 128 </object_ref>
2b5f62a0
VZ
129
130is identical to:
131
132 <object name="foo" class="wxTextCtrl">
133 <value>hello</value>
134 <size>100,-1d</size>
135 </object>
136 <object name="bar" class="wxTextCtrl">
137 <value>bar</value>
138 <size>100,-1d</size>
139 </object>
140
141
142
1433. Common attribute types
144=========================
145
146There are several attribute types (see section 1. Terminology) that are common
147to many attributes of different classes:
148
149String
150------
151Any text. Some characters have special interpretation and are translated
152by XRC parser according to this table:
fc2171bd 153 "_" -> "&" ('&' is used to underline e.g. menu items in wxWidgets)
2b5f62a0
VZ
154 "__" -> "_"
155 "\n" -> line break (C character '\n')
156 "\r" -> carriage return (C character '\r')
157 "\t" -> tabelator (C character '\t')
984c33c9
VS
158 "\\" -> "\"
159 (introduced in version 2.5.3.0, not done in earlier versions)
2b5f62a0
VZ
160
161Version Note:
162 '$' was used instead of '_' prior to version 2.3.0.1.
163
164
165I18nString
166----------
167Like String, but the value is translated to native language using wxLocale
168at runtime (unless it was disabled by not passing wxXRC_USE_LOCALE flag to
169wxXmlResource constructor). Used for strings that are "visible" in the GUI.
170
171
172UnsignedInteger
173---------------
174This is obvious. Only digits 0-9 may be present and there must be at least
175one digit.
176
177
178Integer
179-------
180Like UnsignedInteger but may be prefixed with '-' (ints less than zero).
181
182
183Position
184--------
185Specifies (window's) position in 2D space. Syntax is <integer>,<integer>[d]
186where <integer> is valid value of Integer type.
187
50ccbaaa 188
2b5f62a0
VZ
189Size
190----
191Syntax is same as Position's syntax, but the values are interpreted as window
192size (wxSize type) and not position (wxPosition type).
50ccbaaa
VS
193
194
2b5f62a0
VZ
195Style[wxSomeClass]
196------------------
197List of style flags that can be passed to wxSomeClass' constructor. Flags are
432be5aa
VS
198written in same way as in C++ code (e.g. "wxSUNKEN_BORDER",
199"wxHW_SCROLLBAR_NEVER") and are delimined with any combination of whitespaces
200and '|'. Possible flags are class-dependent and are not described in this
fc2171bd
JS
201technote. Please refer to wxWidgets manual for all styles that given class can
202accept; if XRC does not accept a flag listed in wxWidgets documentation, it is
432be5aa 203a bug.
2b5f62a0
VZ
204
205
206Bitmap
207------
208Attribute value is interpreted as filename (either absolute or relative to
209the location of XRC resource file). In addition, attribute node may have
210"stock_id" and "stock_client" properties. Their values may be any of wxArtID (or
211wxArtClient respectively) values as used by wxArtProvider (because the user may
212define own constants, efectively any string is legal here). Examples are
213"wxART_FILE_OPEN" (id) or "wxART_MENU" (client).
214
432be5aa
VS
215Any of "stock_id" or "stock_client" properties or the filename may be omitted.
216XRC determines the bitmap to use according to this algorithm:
217 1. If there is non-empty "stock_id" property, query wxArtProvider for the
218 bitmap (if there is no "stock_client", use default one, which is usually
984c33c9 219 wxART_OTHER; exceptions are noted in class-specific sections below). If
432be5aa 220 the query fails, continue to 2.
2b5f62a0
VZ
221 2. Load the bitmap from the file in attribute value.
222
223
224Boolean
225-------
226Boolean value, either "0" (false) or "1" (true).
227
50ccbaaa 228
50ccbaaa
VS
229
2304. Supported classes
2b5f62a0
VZ
231====================
232
233Attributes are listed in tables in the following format:
234attribute name attribute type default value, if any
235 [(optional remarks....................
236 ...................................)]
237
238wxBitmap
239--------
240This is a special case, because it does not create a wxWindow instance but
241creates wxBitmap instead. Another exceptional thing is that it does not have
242any attributes. Instead, the node itself is interpreted as if it were attribute
243of type Bitmap.
244
245Example: <object class="wxBitmap">bitmaps/foo.gif</object>
246
247
248wxIcon
249------
250Identical to wxBitmap class, except that it creates wxIcon instead of wxBitmap.
251
252
253wxButton
254--------
255position Position -1,-1
256size Size -1,-1
257style Style[wxButton]
258
259label I18nString
260default Boolean false
261 (Is the button default button?)
262
263
264wxCalendarCtrl
265--------------
266position Position -1,-1
267size Size -1,-1
268style Style[wxCalendarCtrl]
269
270
271wxCheckBox
272----------
273position Position -1,-1
274size Size -1,-1
275style Style[wxCheckBox]
276checked Boolean false
277
278
279wxCheckList
280-----------
281position Position -1,-1
282size Size -1,-1
283style Style[wxCheckList]
984c33c9 284content (see below) (empty)
2b5f62a0
VZ
285
286Optional "content" attribute does not have attribute value. Instead,
287arbitrary number of <item> nodes may be rooted under it (the control
288is filled with strings contained in these nodes). Each <item>
289node must contain I18nString value and may have "checked" property
290with possible values "0" or "1" indicating the the item is initially
291checked.
292
293Example:
294<object class="wxCheckList">
295 <content>
296 <item>One</item>
297 <item checked="1">Two</item>
298 <item checked="1">Three</item>
299 <item>Four</item>
300 </content>
301</object>
302
303
304wxScrolledWindow
305----------------
306position Position -1,-1
307size Size -1,-1
308style Style[wxScrolledWindow] wxHSCROLL | wxVSCROLL
309
310
2f5b93fb
VS
311wxSplitterWindow
312----------------
313position Position -1,-1
314size Size -1,-1
315style Style[wxSplitterWindow] wxSP_3D
316sashpos Integer 0
317 (Initial sash position)
318minsize Integer -1
319 (Minimal panel size)
320orientation "horizontal"|"vertical" horizontal
321
322wxSplitterWindow must have at least one and at most two children objects.
323If there's only one child object, it is passed to wxSplitterWindow::Initialize
324and the splitter is created unsplitted. If there are two children, the
325splitter is created splitted, either horizontally or vertically depending
326on the value of "orientation" attribute.
327
b0fb0f3c
JS
328wxStatusBar
329-----------
330fields Integer number of fields
331widths Width1, Width2, Width3, ...
2f5b93fb 332
432be5aa
VS
333wxToolBar
334---------
335position Position -1,-1
336size Size -1,-1
337style Style[wxToolBar] wxNO_BORDER|wxTB_HORIZONTAL
338bitmapsize Size -1,-1
339 (Size of contained bitmaps)
340margins Size -1,-1
341packing Integer -1
342separation Integer -1
343
344wxToolBar node may have children <object> and <object_ref> nodes. Their class
fc2171bd 345may be either "tool", "separator" or any wxWidgets class derived from
432be5aa
VS
346wxControl. "tool" and "separator" are special pseudo-classes that may only
347appear within wxToolBar node. Their attributes are as follows:
348
349 separator
350 ---------
351 (doesn't have any attributes)
352
353 tool
354 ----
355 bitmap Bitmap
356 bitmap2 Bitmap wxNullBitmap
357 toggle Boolean 0
358 radio Boolean 0
359 label I18nString ""
360 tooltip I18nString ""
361 longhelp I18nString ""
362 position Position -1,-1
363
364 Constraints:
365 At most one of "toggle" and "radio" attributes may be 1.
366 Attribute "position" may not appear if "label" or "radio" attributes
367 are used or if parent wxToolBar's style contains wxTB_TEXT.
368
369 Note:
370 Use of "position" attribute is strongly discouraged, it is deprecated
371 usage of wxToolBar and it is not supported by MSW and GTK
372 implementations.
373
374Children objects are added to the toolbar using AddTool for "tool" class,
375AddSeparator for "separator" and AddControl for other classes.
376
377
2b5f62a0
VZ
378
3795. More features
380================
381
382FIXME -- "platform" property handling
50ccbaaa 383
50ccbaaa
VS
384
385=== EOF ===
386
387Version: $Id$