]> git.saurik.com Git - wxWidgets.git/blame - docs/tech/tn0014.txt
Added Get/SetItemToolTip
[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)
5a7b6f80
JS
16 c) DialogBlocks (wxPython/tools)
17
18and others listed on the Resources section of the wxWidgets web
19site.
50ccbaaa
VS
20
21The XRC format is based on XML 1.0 (please consult W3C's specification). There
22is no DTD available since it is not possible to fully describe the format with
23the limited expressive power of DTDs.
24
2b5f62a0 25
b2ec1c82
VS
26Note: see also http://ldaptool.sourceforge.net/XRCGuide/XRCGuideSingle/
27
28
2b5f62a0 29
50ccbaaa 301. Terminology
2b5f62a0 31==============
50ccbaaa 32
b26a650c 33The usual XML terminology applies. In particular, we shall use the terms
2b5f62a0 34NODE, PROPERTY and VALUE in the XML sense:
50ccbaaa
VS
35
36 <node property1="value1" property2="value2">...</node>
37
b26a650c
VZ
38The term ATTRIBUTE is specific to XRC and refers to a subnode
39of an <object> or <object_ref> node that is itself not <object> or <object_ref>.
40In the example below, <pos>, <label> and <style> are attributes, while neither
2b5f62a0 41<resource> nor either of <object>s is:
50ccbaaa
VS
42
43 <?xml version="1.0" encoding="utf-8">
984c33c9 44 <resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.5.3.0">
50ccbaaa 45 <object class="wxPanel">
2b5f62a0 46 <style>wxSUNKEN_BORDER</style> <!-- attr -->
50ccbaaa 47 <object class="wxStaticText">
2b5f62a0
VZ
48 <label>A label</label> <!-- attr -->
49 <pos>10,10</pos> <!-- attr -->
50ccbaaa
VS
50 </object>
51 </object>
52 </resource>
53
2b5f62a0
VZ
54ATTRIBUTE VALUE is the content of all text elements within attribute tag. In the
55above example, "wxSUNKEN_BORDER", "A label" and "10,10" are attribute values.
56ATTRIBUTE TYPE defines what attribute values are valid for given attribute (you
57can think of it as attribute value syntax definition).
58
59
60
50ccbaaa 612. Elementary description
2b5f62a0 62=========================
50ccbaaa 63
432be5aa 64XRC resource file is a well-formed XML 1.0 document. All elements of XRC file
b26a650c 65are from the http://www.wxwidgets.org/wxxrc namespace.
50ccbaaa 66
b26a650c
VZ
67The root node of XRC document must be <resource>. The <resource> node has
68optional "version" property. Default version (in absence of the version
69property) is "0.0.0.0". The version consists of four integers separated by
70periods. Version of XRC format changes only if there was an incompatible
71change introduced (i.e. either the library cannot understand old resource
50ccbaaa 72files or older versions of the library wouldn't understand the new format).
b26a650c
VZ
73The first three integers are major, minor and release number of the wxWidgets
74release when the change was introduced, the last one is revision number and
75is 0 for the first incompatible change in given wxWidgets release, 1 for
50ccbaaa
VS
76the second etc.
77
78Differences between versions are described within this document in paragraphs
2b5f62a0 79entitled "Version Note".
50ccbaaa 80
40e2d134
VS
81The <resource> node contains namespace declaration, too:
82
984c33c9 83 <resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.5.3.0">
40e2d134 84
50ccbaaa
VS
85The <resource> node is only allowed to have <object> and <object_ref>
86subnodes, all of which must have the "name" property.
87
2b5f62a0 88The <object> node represents a single object (GUI element) and it usually maps
b26a650c 89directly to a wxWidgets class instance. It has the properties: "name", "class"
fc2171bd 90and "subclass". "class" must always be present, it tells XRC what wxWidgets
432be5aa
VS
91object should be created in this place. The other two are optional. "name" is
92ID used to identify the object. It is the value passed to the XRCID() macro and
93is also used to construct wxWindow's id and name attributes and must be unique
dbd94b75
KH
94among all children of the nearest container object (wxDialog, wxFrame,
95wxPanel, wxNotebook) upside from the object in XML nodes hierarchy (two distinct
432be5aa
VS
96containers may contain objects with same "name", though). "subclass" is
97optional name of class whose constructor will be called instead of the
98constructor for "class". Subclass must be available in the program that loads
99the resource, must be derived from "class" and must be registered within
fc2171bd 100wxWidgets' RTTI system.
2b5f62a0 101
b26a650c
VZ
102Finally, an optional "insert_at" property may be present. Currently only the
103values "begin" and "end" are supported, meaning to insert the object in the
104beginning of the parent node objects list or to append it at the end (which is
105the default if this property is absent).
106
2b5f62a0
VZ
107Example:
108
109 <object name="MyList1" class="wxListCtrl" subclass="MyListCtrlClass">
110 ...
b26a650c
VZ
111 </object>
112
432be5aa
VS
113<object> node may have arbitrary child nodes. What child nodes and their
114semantics are class-dependent and are defined later in this document. The user
115is allowed to register new object handlers within XRC and extend it to accept
116new <object> classes (and therefore different <object>'s child nodes).
117
118<object_ref> node is identical to <object>, except that it does _not_ have
3103e8a9 119"class" property and has additional required property "ref". Its concept is
432be5aa
VS
120similar 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
dbd94b75 122(not necessary top-level). Referred node's "class" property and all subnodes
432be5aa
VS
123are copied in place of the referee <object_ref> node which is then processed as
124regular <object> node. If the <object_ref> node itself has child nodes, then
125these nodes _override_ any nodes from the referred node.
2b5f62a0
VZ
126
127Example:
128
129 <object name="foo" class="wxTextCtrl">
130 <value>hello</value>
131 <size>100,-1d</size>
132 </object>
133 <object_ref name="bar" ref="foo">
134 <value>bar</value> <!-- override! -->
0fa2e104 135 </object_ref>
2b5f62a0 136
b26a650c 137is identical to:
2b5f62a0
VZ
138
139 <object name="foo" class="wxTextCtrl">
140 <value>hello</value>
141 <size>100,-1d</size>
142 </object>
143 <object name="bar" class="wxTextCtrl">
144 <value>bar</value>
145 <size>100,-1d</size>
146 </object>
147
148
149
1503. Common attribute types
151=========================
152
153There are several attribute types (see section 1. Terminology) that are common
154to many attributes of different classes:
155
156String
157------
158Any text. Some characters have special interpretation and are translated
159by XRC parser according to this table:
fc2171bd 160 "_" -> "&" ('&' is used to underline e.g. menu items in wxWidgets)
2b5f62a0
VZ
161 "__" -> "_"
162 "\n" -> line break (C character '\n')
163 "\r" -> carriage return (C character '\r')
dbd94b75 164 "\t" -> tab (C character '\t')
984c33c9
VS
165 "\\" -> "\"
166 (introduced in version 2.5.3.0, not done in earlier versions)
2b5f62a0
VZ
167
168Version Note:
169 '$' was used instead of '_' prior to version 2.3.0.1.
170
171
172I18nString
173----------
174Like String, but the value is translated to native language using wxLocale
175at runtime (unless it was disabled by not passing wxXRC_USE_LOCALE flag to
176wxXmlResource constructor). Used for strings that are "visible" in the GUI.
177
178
179UnsignedInteger
180---------------
181This is obvious. Only digits 0-9 may be present and there must be at least
182one digit.
183
184
185Integer
186-------
187Like UnsignedInteger but may be prefixed with '-' (ints less than zero).
188
189
190Position
191--------
192Specifies (window's) position in 2D space. Syntax is <integer>,<integer>[d]
193where <integer> is valid value of Integer type.
194
50ccbaaa 195
2b5f62a0
VZ
196Size
197----
198Syntax is same as Position's syntax, but the values are interpreted as window
199size (wxSize type) and not position (wxPosition type).
50ccbaaa
VS
200
201
2b5f62a0
VZ
202Style[wxSomeClass]
203------------------
204List of style flags that can be passed to wxSomeClass' constructor. Flags are
432be5aa 205written in same way as in C++ code (e.g. "wxSUNKEN_BORDER",
dbd94b75 206"wxHW_SCROLLBAR_NEVER") and are delimited with any combination of whitespaces
432be5aa 207and '|'. Possible flags are class-dependent and are not described in this
fc2171bd
JS
208technote. Please refer to wxWidgets manual for all styles that given class can
209accept; if XRC does not accept a flag listed in wxWidgets documentation, it is
432be5aa 210a bug.
2b5f62a0
VZ
211
212
213Bitmap
214------
215Attribute value is interpreted as filename (either absolute or relative to
216the 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
218wxArtClient respectively) values as used by wxArtProvider (because the user may
dbd94b75 219define own constants, effectively any string is legal here). Examples are
2b5f62a0
VZ
220"wxART_FILE_OPEN" (id) or "wxART_MENU" (client).
221
432be5aa 222Any of "stock_id" or "stock_client" properties or the filename may be omitted.
b26a650c 223XRC determines the bitmap to use according to this algorithm:
432be5aa
VS
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
984c33c9 226 wxART_OTHER; exceptions are noted in class-specific sections below). If
432be5aa 227 the query fails, continue to 2.
2b5f62a0
VZ
228 2. Load the bitmap from the file in attribute value.
229
230
231Boolean
232-------
233Boolean value, either "0" (false) or "1" (true).
234
50ccbaaa 235
1df61962
VS
236Font
237----
238Font value. A font can be described either in terms of its elementary
239properties, or it can be derived from one of system fonts. The font node
240may contain following subnodes (the table lists subnode name on the left and
241variable type as per the definitions above on the right side):
242
243size UnsignedInteger
244style normal | italic | slant
245weight normal | bold | light
246family roman | script | decorative | swiss | modern | teletype
247underlined Boolean
248face comma-separated list of faces
249encoding charset of the font (meaningless in Unicode build), as string
250sysfont symbolic name of system standard font
251 (one of wxSYS_*_FONT constants)
252relativesize Float, font size relative to choosen system font's size;
253 can only be used when 'sysfont' is used and when 'size' is not
254 used
255
256All of them are optional, if they are missing, wxFont default is used.
257
258Examples:
b26a650c 259
1df61962
VS
260 <font>
261 <face>arial,helvetica</face>
262 <size>12</size>
263 </font>
b26a650c 264
1df61962
VS
265 <font>
266 <sysfont>wxSYS_DEFAULT_GUI_FONT</sysfont>
267 <weight>bold</weight>
268 <relativesize>1.5</relativesize>
269 </font>
270
271
272Colour
273------
274A colour value is either explicit RGB value in the standard #rrggbb format
275where rr, gg and bb are hexadecimal case-insensitive values in the 00..FF
276range, or a symbolic name. Symbolic names are wxSYS_COLOUR_* constants defined
277by wxWidgets, written as strings.
278
279Example:
280
281 <bg>wxSYS_COLOUR_SCROLLBAR</bg>
282 <fg>#FF0000</fg>
283
284
50ccbaaa
VS
285
2864. Supported classes
2b5f62a0
VZ
287====================
288
289Attributes are listed in tables in the following format:
290attribute name attribute type default value, if any
291 [(optional remarks....................
292 ...................................)]
293
294wxBitmap
295--------
b26a650c 296This is a special case, because it does not create a wxWindow instance but
2b5f62a0
VZ
297creates wxBitmap instead. Another exceptional thing is that it does not have
298any attributes. Instead, the node itself is interpreted as if it were attribute
299of type Bitmap.
300
301Example: <object class="wxBitmap">bitmaps/foo.gif</object>
302
303
304wxIcon
305------
306Identical to wxBitmap class, except that it creates wxIcon instead of wxBitmap.
307
308
309wxButton
310--------
9c0a4cb4 311pos Position -1,-1
2b5f62a0 312size Size -1,-1
b26a650c 313style Style[wxButton]
2b5f62a0
VZ
314
315label I18nString
316default Boolean false
317 (Is the button default button?)
318
319
320wxCalendarCtrl
321--------------
9c0a4cb4 322pos Position -1,-1
2b5f62a0
VZ
323size Size -1,-1
324style Style[wxCalendarCtrl]
325
326
327wxCheckBox
328----------
9c0a4cb4 329pos Position -1,-1
2b5f62a0
VZ
330size Size -1,-1
331style Style[wxCheckBox]
332checked Boolean false
333
334
335wxCheckList
336-----------
9c0a4cb4 337pos Position -1,-1
2b5f62a0
VZ
338size Size -1,-1
339style Style[wxCheckList]
984c33c9 340content (see below) (empty)
2b5f62a0
VZ
341
342Optional "content" attribute does not have attribute value. Instead,
343arbitrary number of <item> nodes may be rooted under it (the control
344is filled with strings contained in these nodes). Each <item>
345node must contain I18nString value and may have "checked" property
346with possible values "0" or "1" indicating the the item is initially
347checked.
348
349Example:
350<object class="wxCheckList">
351 <content>
352 <item>One</item>
353 <item checked="1">Two</item>
354 <item checked="1">Three</item>
355 <item>Four</item>
356 </content>
357</object>
358
359
310e47b3
VS
360wxDatePickerCtrl
361----------------
362pos Position -1,-1
363size Size -1,-1
364style Style[wxDatePickerCtrl]
365
366
8b34993d
VS
367wxDialog
368--------
9c0a4cb4 369pos Position -1,-1
8b34993d
VS
370size Size -1,-1
371style Style[wxDialog] wxDEFAULT_DIALOG_STYLE
372title I18nString ""
373icon Bitmap (empty)
374centered Boolean false
375
376wxDialog may have children objects.
377
378
379wxFrame
380--------
9c0a4cb4 381pos Position -1,-1
8b34993d
VS
382size Size -1,-1
383style Style[wxDialog] wxDEFAULT_FRAME_STYLE
384title I18nString ""
385icon Bitmap (empty)
386centered Boolean false
387
388wxFrame may have children objects. There can be at most one wxToolBar,
389wxMenuBar and wxStatusBar children; objects of these types are automatically
390set as frame's tool-, menu- and statusbar respectively.
391
392
5a0348c4
VS
393wxMDIParentFrame
394----------------
395
396Supports same attributes and children nodes as wxFrame. Additionally, children
397may be of the wxMDIChildFrame type.
398
399
400wxMDIChildFrame
401---------------
402
403Supports same attributes and children nodes as wxFrame.
404
405
d5e20cd8
VZ
406wxRadioBox
407----------
408
409This control may have "dimension" (major dimension) and (initial) "selection"
410Integer subelements and a composite "content" element similar to wxCheckList.
411
2b5f62a0
VZ
412wxScrolledWindow
413----------------
9c0a4cb4 414pos Position -1,-1
2b5f62a0
VZ
415size Size -1,-1
416style Style[wxScrolledWindow] wxHSCROLL | wxVSCROLL
417
8b34993d
VS
418wxScolledWindow may have children objects.
419
2b5f62a0 420
2f5b93fb
VS
421wxSplitterWindow
422----------------
9c0a4cb4 423pos Position -1,-1
2f5b93fb
VS
424size Size -1,-1
425style Style[wxSplitterWindow] wxSP_3D
426sashpos Integer 0
427 (Initial sash position)
428minsize Integer -1
429 (Minimal panel size)
430orientation "horizontal"|"vertical" horizontal
431
432wxSplitterWindow must have at least one and at most two children objects.
433If there's only one child object, it is passed to wxSplitterWindow::Initialize
dbd94b75
KH
434and the splitter is created unsplit. If there are two children, the
435splitter is created split, either horizontally or vertically depending
2f5b93fb
VS
436on the value of "orientation" attribute.
437
8b34993d 438
b0fb0f3c
JS
439wxStatusBar
440-----------
441fields Integer number of fields
442widths Width1, Width2, Width3, ...
2f5b93fb 443
8b34993d 444
432be5aa
VS
445wxToolBar
446---------
9c0a4cb4 447pos Position -1,-1
432be5aa
VS
448size Size -1,-1
449style Style[wxToolBar] wxNO_BORDER|wxTB_HORIZONTAL
450bitmapsize Size -1,-1
451 (Size of contained bitmaps)
452margins Size -1,-1
453packing Integer -1
454separation Integer -1
700dbceb 455bg Background colour None
0699a648 456dontattachtoframe Boolean False
432be5aa
VS
457
458wxToolBar node may have children <object> and <object_ref> nodes. Their class
fc2171bd 459may be either "tool", "separator" or any wxWidgets class derived from
432be5aa
VS
460wxControl. "tool" and "separator" are special pseudo-classes that may only
461appear within wxToolBar node. Their attributes are as follows:
462
463 separator
464 ---------
465 (doesn't have any attributes)
466
467 tool
468 ----
b26a650c 469 bitmap Bitmap
432be5aa
VS
470 bitmap2 Bitmap wxNullBitmap
471 toggle Boolean 0
472 radio Boolean 0
114807c0 473 disabled Boolean 0
432be5aa
VS
474 label I18nString ""
475 tooltip I18nString ""
476 longhelp I18nString ""
9c0a4cb4 477 pos Position -1,-1
432be5aa
VS
478
479 Constraints:
480 At most one of "toggle" and "radio" attributes may be 1.
9c0a4cb4 481 Attribute "pos" may not appear if "label" or "radio" attributes
432be5aa 482 are used or if parent wxToolBar's style contains wxTB_TEXT.
b26a650c 483
432be5aa 484 Note:
9c0a4cb4 485 Use of "pos" attribute is strongly discouraged, it is deprecated
432be5aa
VS
486 usage of wxToolBar and it is not supported by MSW and GTK
487 implementations.
488
489Children objects are added to the toolbar using AddTool for "tool" class,
490AddSeparator for "separator" and AddControl for other classes.
491
492
2b5f62a0
VZ
493
4945. More features
495================
496
497FIXME -- "platform" property handling
50ccbaaa 498
50ccbaaa
VS
499
500=== EOF ===
501
502Version: $Id$