]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/tech/tn0014.txt
Patches-1851591 ] dataview sample is crashing (under MSW)
[wxWidgets.git] / docs / tech / tn0014.txt
... / ...
CommitLineData
1 XRC resources format specification
2 ==================================
3
4 !!!!! NOT YET FINISHED !!!!!
5
60. Introduction
7===============
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) DialogBlocks (wxPython/tools)
17
18and others listed on the Resources section of the wxWidgets web
19site.
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
25
26Note: see also http://ldaptool.sourceforge.net/XRCGuide/XRCGuideSingle/
27
28
29
301. Terminology
31==============
32
33The usual XML terminology applies. In particular, we shall use the terms
34NODE, PROPERTY and VALUE in the XML sense:
35
36 <node property1="value1" property2="value2">...</node>
37
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
41<resource> nor either of <object>s is:
42
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 -->
50 </object>
51 </object>
52 </resource>
53
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
612. Elementary description
62=========================
63
64XRC resource file is a well-formed XML 1.0 document. All elements of XRC file
65are from the http://www.wxwidgets.org/wxxrc namespace.
66
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
72files or older versions of the library wouldn't understand the new format).
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
76the second etc.
77
78Differences between versions are described within this document in paragraphs
79entitled "Version Note".
80
81The <resource> node contains namespace declaration, too:
82
83 <resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.5.3.0">
84
85The <resource> node is only allowed to have <object> and <object_ref>
86subnodes, all of which must have the "name" property.
87
88The <object> node represents a single object (GUI element) and it usually maps
89directly to a wxWidgets class instance. It has the properties: "name", "class"
90and "subclass". "class" must always be present, it tells XRC what wxWidgets
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
94among all children of the nearest container object (wxDialog, wxFrame,
95wxPanel, wxNotebook) upside from the object in XML nodes hierarchy (two distinct
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
100wxWidgets' RTTI system.
101
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
107Example:
108
109 <object name="MyList1" class="wxListCtrl" subclass="MyListCtrlClass">
110 ...
111 </object>
112
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
119"class" property and has additional required property "ref". Its concept is
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
122(not necessary top-level). Referred node's "class" property and all subnodes
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.
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! -->
135 </object_ref>
136
137is identical to:
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:
160 "_" -> "&" ('&' is used to underline e.g. menu items in wxWidgets)
161 "__" -> "_"
162 "\n" -> line break (C character '\n')
163 "\r" -> carriage return (C character '\r')
164 "\t" -> tab (C character '\t')
165 "\\" -> "\"
166 (introduced in version 2.5.3.0, not done in earlier versions)
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
195
196Size
197----
198Syntax is same as Position's syntax, but the values are interpreted as window
199size (wxSize type) and not position (wxPosition type).
200
201
202Style[wxSomeClass]
203------------------
204List of style flags that can be passed to wxSomeClass' constructor. Flags are
205written in same way as in C++ code (e.g. "wxSUNKEN_BORDER",
206"wxHW_SCROLLBAR_NEVER") and are delimited with any combination of whitespaces
207and '|'. Possible flags are class-dependent and are not described in this
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
210a bug.
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
219define own constants, effectively any string is legal here). Examples are
220"wxART_FILE_OPEN" (id) or "wxART_MENU" (client).
221
222Any of "stock_id" or "stock_client" properties or the filename may be omitted.
223XRC 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.
229
230
231Boolean
232-------
233Boolean value, either "0" (false) or "1" (true).
234
235
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:
259
260 <font>
261 <face>arial,helvetica</face>
262 <size>12</size>
263 </font>
264
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
285
2864. Supported classes
287====================
288
289Attributes are listed in tables in the following format:
290attribute name attribute type default value, if any
291 [(optional remarks....................
292 ...................................)]
293
294Common attributes
295-----------------
296These attributes are supported by all windows:
297
298exstyle Int
299bg Colour
300fg Colour
301enabled Boolean true
302focused Boolean false
303hidden Boolean false
304tooltip I18nString
305font Font
306help I18nString
307
308wxBitmap
309--------
310This is a special case, because it does not create a wxWindow instance but
311creates wxBitmap instead. Another exceptional thing is that it does not have
312any attributes. Instead, the node itself is interpreted as if it were attribute
313of type Bitmap.
314
315Example: <object class="wxBitmap">bitmaps/foo.gif</object>
316
317
318wxIcon
319------
320Identical to wxBitmap class, except that it creates wxIcon instead of wxBitmap.
321
322
323wxButton
324--------
325pos Position -1,-1
326size Size -1,-1
327style Style[wxButton]
328
329label I18nString
330default Boolean false
331 (Is the button default button?)
332
333
334wxCalendarCtrl
335--------------
336pos Position -1,-1
337size Size -1,-1
338style Style[wxCalendarCtrl]
339
340
341wxCheckBox
342----------
343pos Position -1,-1
344size Size -1,-1
345style Style[wxCheckBox]
346checked Boolean false
347
348
349wxCheckList
350-----------
351pos Position -1,-1
352size Size -1,-1
353style Style[wxCheckList]
354content (see below) (empty)
355
356Optional "content" attribute does not have attribute value. Instead,
357arbitrary number of <item> nodes may be rooted under it (the control
358is filled with strings contained in these nodes). Each <item>
359node must contain I18nString value and may have "checked" property
360with possible values "0" or "1" indicating the the item is initially
361checked.
362
363Example:
364<object class="wxCheckList">
365 <content>
366 <item>One</item>
367 <item checked="1">Two</item>
368 <item checked="1">Three</item>
369 <item>Four</item>
370 </content>
371</object>
372
373
374wxDatePickerCtrl
375----------------
376pos Position -1,-1
377size Size -1,-1
378style Style[wxDatePickerCtrl]
379
380
381wxDialog
382--------
383pos Position -1,-1
384size Size -1,-1
385style Style[wxDialog] wxDEFAULT_DIALOG_STYLE
386title I18nString ""
387icon Bitmap (empty)
388centered Boolean false
389
390wxDialog may have children objects.
391
392
393wxFrame
394--------
395pos Position -1,-1
396size Size -1,-1
397style Style[wxDialog] wxDEFAULT_FRAME_STYLE
398title I18nString ""
399icon Bitmap (empty)
400centered Boolean false
401
402wxFrame may have children objects. There can be at most one wxToolBar,
403wxMenuBar and wxStatusBar children; objects of these types are automatically
404set as frame's tool-, menu- and statusbar respectively.
405
406
407wxMDIParentFrame
408----------------
409
410Supports same attributes and children nodes as wxFrame. Additionally, children
411may be of the wxMDIChildFrame type.
412
413
414wxMDIChildFrame
415---------------
416
417Supports same attributes and children nodes as wxFrame.
418
419
420wxRadioBox
421----------
422
423This control may have "dimension" (major dimension) and (initial) "selection"
424Integer subelements and a composite "content" element similar to wxCheckList.
425The only difference is that the "item" subelements can have an optional
426"tooltip=I18nString" and "helptext=I18nString" attributes to specify
427the per-item tooltip and helptext.
428
429
430wxScrolledWindow
431----------------
432pos Position -1,-1
433size Size -1,-1
434style Style[wxScrolledWindow] wxHSCROLL | wxVSCROLL
435scrollrate Size 0,0
436
437wxScolledWindow may have children objects.
438
439
440wxSplitterWindow
441----------------
442pos Position -1,-1
443size Size -1,-1
444style Style[wxSplitterWindow] wxSP_3D
445sashpos Integer 0
446 (Initial sash position)
447minsize Integer -1
448 (Minimal panel size)
449orientation "horizontal"|"vertical" horizontal
450
451wxSplitterWindow must have at least one and at most two children objects.
452If there's only one child object, it is passed to wxSplitterWindow::Initialize
453and the splitter is created unsplit. If there are two children, the
454splitter is created split, either horizontally or vertically depending
455on the value of "orientation" attribute.
456
457
458wxStatusBar
459-----------
460fields Integer number of fields
461widths Width1, Width2, Width3, ...
462
463
464wxToolBar
465---------
466pos Position -1,-1
467size Size -1,-1
468style Style[wxToolBar] wxNO_BORDER|wxTB_HORIZONTAL
469bitmapsize Size -1,-1
470 (Size of contained bitmaps)
471margins Size -1,-1
472packing Integer -1
473separation Integer -1
474bg Background colour None
475dontattachtoframe Boolean False
476
477wxToolBar node may have children <object> and <object_ref> nodes. Their class
478may be either "tool", "separator" or any wxWidgets class derived from
479wxControl. "tool" and "separator" are special pseudo-classes that may only
480appear within wxToolBar node. Their attributes are as follows:
481
482 separator
483 ---------
484 (doesn't have any attributes)
485
486 tool
487 ----
488 bitmap Bitmap
489 bitmap2 Bitmap wxNullBitmap
490 toggle Boolean 0
491 radio Boolean 0
492 disabled Boolean 0
493 label I18nString ""
494 tooltip I18nString ""
495 longhelp I18nString ""
496 pos Position -1,-1
497
498 Constraints:
499 At most one of "toggle" and "radio" attributes may be 1.
500 Attribute "pos" may not appear if "label" or "radio" attributes
501 are used or if parent wxToolBar's style contains wxTB_TEXT.
502
503 Note:
504 Use of "pos" attribute is strongly discouraged, it is deprecated
505 usage of wxToolBar and it is not supported by MSW and GTK
506 implementations.
507
508Children objects are added to the toolbar using AddTool for "tool" class,
509AddSeparator for "separator" and AddControl for other classes.
510
511
512
5135. More features
514================
515
516FIXME -- "platform" property handling
517
518
519=== EOF ===
520
521Version: $Id$