]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/tech/tn0014.txt
added wxDatePickerCtrl XRC control
[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) 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
23
24Note: see also http://ldaptool.sourceforge.net/XRCGuide/XRCGuideSingle/
25
26
27
281. Terminology
29==============
30
31The usual XML terminology applies. In particular, we shall use the terms
32NODE, PROPERTY and VALUE in the XML sense:
33
34 <node property1="value1" property2="value2">...</node>
35
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>.
38In the example below, <pos>, <label> and <style> are attributes, while neither
39<resource> nor either of <object>s is:
40
41 <?xml version="1.0" encoding="utf-8">
42 <resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.5.3.0">
43 <object class="wxPanel">
44 <style>wxSUNKEN_BORDER</style> <!-- attr -->
45 <object class="wxStaticText">
46 <label>A label</label> <!-- attr -->
47 <pos>10,10</pos> <!-- attr -->
48 </object>
49 </object>
50 </resource>
51
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
592. Elementary description
60=========================
61
62XRC resource file is a well-formed XML 1.0 document. All elements of XRC file
63are from the http://www.wxwidgets.org/wxxrc namespace.
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).
71The first three integers are major, minor and release number of the wxWidgets
72release when the change was introduced, the last one is revision number and
73is 0 for the first incompatible change in given wxWidgets release, 1 for
74the second etc.
75
76Differences between versions are described within this document in paragraphs
77entitled "Version Note".
78
79The <resource> node contains namespace declaration, too:
80
81 <resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.5.3.0">
82
83The <resource> node is only allowed to have <object> and <object_ref>
84subnodes, all of which must have the "name" property.
85
86The <object> node represents a single object (GUI element) and it usually maps
87directly to a wxWidgets class instance. It three properties: "name", "class"
88and "subclass". "class" must always be present, it tells XRC what wxWidgets
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 nearest container object (wxDialog, wxFrame,
93wxPanel, wxNotebook) upside from the object in XML nodes hierarchy (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
98wxWidgets' RTTI system.
99
100Example:
101
102 <object name="MyList1" class="wxListCtrl" subclass="MyListCtrlClass">
103 ...
104 </object>
105
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 additional 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 necessary 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.
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! -->
128 </object_ref>
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:
153 "_" -> "&" ('&' is used to underline e.g. menu items in wxWidgets)
154 "__" -> "_"
155 "\n" -> line break (C character '\n')
156 "\r" -> carriage return (C character '\r')
157 "\t" -> tab (C character '\t')
158 "\\" -> "\"
159 (introduced in version 2.5.3.0, not done in earlier versions)
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
188
189Size
190----
191Syntax is same as Position's syntax, but the values are interpreted as window
192size (wxSize type) and not position (wxPosition type).
193
194
195Style[wxSomeClass]
196------------------
197List of style flags that can be passed to wxSomeClass' constructor. Flags are
198written in same way as in C++ code (e.g. "wxSUNKEN_BORDER",
199"wxHW_SCROLLBAR_NEVER") and are delimited with any combination of whitespaces
200and '|'. Possible flags are class-dependent and are not described in this
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
203a bug.
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, effectively any string is legal here). Examples are
213"wxART_FILE_OPEN" (id) or "wxART_MENU" (client).
214
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
219 wxART_OTHER; exceptions are noted in class-specific sections below). If
220 the query fails, continue to 2.
221 2. Load the bitmap from the file in attribute value.
222
223
224Boolean
225-------
226Boolean value, either "0" (false) or "1" (true).
227
228
229Font
230----
231Font value. A font can be described either in terms of its elementary
232properties, or it can be derived from one of system fonts. The font node
233may contain following subnodes (the table lists subnode name on the left and
234variable type as per the definitions above on the right side):
235
236size UnsignedInteger
237style normal | italic | slant
238weight normal | bold | light
239family roman | script | decorative | swiss | modern | teletype
240underlined Boolean
241face comma-separated list of faces
242encoding charset of the font (meaningless in Unicode build), as string
243sysfont symbolic name of system standard font
244 (one of wxSYS_*_FONT constants)
245relativesize Float, font size relative to choosen system font's size;
246 can only be used when 'sysfont' is used and when 'size' is not
247 used
248
249All of them are optional, if they are missing, wxFont default is used.
250
251Examples:
252
253 <font>
254 <face>arial,helvetica</face>
255 <size>12</size>
256 </font>
257
258 <font>
259 <sysfont>wxSYS_DEFAULT_GUI_FONT</sysfont>
260 <weight>bold</weight>
261 <relativesize>1.5</relativesize>
262 </font>
263
264
265Colour
266------
267A colour value is either explicit RGB value in the standard #rrggbb format
268where rr, gg and bb are hexadecimal case-insensitive values in the 00..FF
269range, or a symbolic name. Symbolic names are wxSYS_COLOUR_* constants defined
270by wxWidgets, written as strings.
271
272Example:
273
274 <bg>wxSYS_COLOUR_SCROLLBAR</bg>
275 <fg>#FF0000</fg>
276
277
278
2794. Supported classes
280====================
281
282Attributes are listed in tables in the following format:
283attribute name attribute type default value, if any
284 [(optional remarks....................
285 ...................................)]
286
287wxBitmap
288--------
289This is a special case, because it does not create a wxWindow instance but
290creates wxBitmap instead. Another exceptional thing is that it does not have
291any attributes. Instead, the node itself is interpreted as if it were attribute
292of type Bitmap.
293
294Example: <object class="wxBitmap">bitmaps/foo.gif</object>
295
296
297wxIcon
298------
299Identical to wxBitmap class, except that it creates wxIcon instead of wxBitmap.
300
301
302wxButton
303--------
304pos Position -1,-1
305size Size -1,-1
306style Style[wxButton]
307
308label I18nString
309default Boolean false
310 (Is the button default button?)
311
312
313wxCalendarCtrl
314--------------
315pos Position -1,-1
316size Size -1,-1
317style Style[wxCalendarCtrl]
318
319
320wxCheckBox
321----------
322pos Position -1,-1
323size Size -1,-1
324style Style[wxCheckBox]
325checked Boolean false
326
327
328wxCheckList
329-----------
330pos Position -1,-1
331size Size -1,-1
332style Style[wxCheckList]
333content (see below) (empty)
334
335Optional "content" attribute does not have attribute value. Instead,
336arbitrary number of <item> nodes may be rooted under it (the control
337is filled with strings contained in these nodes). Each <item>
338node must contain I18nString value and may have "checked" property
339with possible values "0" or "1" indicating the the item is initially
340checked.
341
342Example:
343<object class="wxCheckList">
344 <content>
345 <item>One</item>
346 <item checked="1">Two</item>
347 <item checked="1">Three</item>
348 <item>Four</item>
349 </content>
350</object>
351
352
353wxDatePickerCtrl
354----------------
355pos Position -1,-1
356size Size -1,-1
357style Style[wxDatePickerCtrl]
358
359
360wxDialog
361--------
362pos Position -1,-1
363size Size -1,-1
364style Style[wxDialog] wxDEFAULT_DIALOG_STYLE
365title I18nString ""
366icon Bitmap (empty)
367centered Boolean false
368
369wxDialog may have children objects.
370
371
372wxFrame
373--------
374pos Position -1,-1
375size Size -1,-1
376style Style[wxDialog] wxDEFAULT_FRAME_STYLE
377title I18nString ""
378icon Bitmap (empty)
379centered Boolean false
380
381wxFrame may have children objects. There can be at most one wxToolBar,
382wxMenuBar and wxStatusBar children; objects of these types are automatically
383set as frame's tool-, menu- and statusbar respectively.
384
385
386wxScrolledWindow
387----------------
388pos Position -1,-1
389size Size -1,-1
390style Style[wxScrolledWindow] wxHSCROLL | wxVSCROLL
391
392wxScolledWindow may have children objects.
393
394
395wxSplitterWindow
396----------------
397pos Position -1,-1
398size Size -1,-1
399style Style[wxSplitterWindow] wxSP_3D
400sashpos Integer 0
401 (Initial sash position)
402minsize Integer -1
403 (Minimal panel size)
404orientation "horizontal"|"vertical" horizontal
405
406wxSplitterWindow must have at least one and at most two children objects.
407If there's only one child object, it is passed to wxSplitterWindow::Initialize
408and the splitter is created unsplit. If there are two children, the
409splitter is created split, either horizontally or vertically depending
410on the value of "orientation" attribute.
411
412
413wxStatusBar
414-----------
415fields Integer number of fields
416widths Width1, Width2, Width3, ...
417
418
419wxToolBar
420---------
421pos Position -1,-1
422size Size -1,-1
423style Style[wxToolBar] wxNO_BORDER|wxTB_HORIZONTAL
424bitmapsize Size -1,-1
425 (Size of contained bitmaps)
426margins Size -1,-1
427packing Integer -1
428separation Integer -1
429
430wxToolBar node may have children <object> and <object_ref> nodes. Their class
431may be either "tool", "separator" or any wxWidgets class derived from
432wxControl. "tool" and "separator" are special pseudo-classes that may only
433appear within wxToolBar node. Their attributes are as follows:
434
435 separator
436 ---------
437 (doesn't have any attributes)
438
439 tool
440 ----
441 bitmap Bitmap
442 bitmap2 Bitmap wxNullBitmap
443 toggle Boolean 0
444 radio Boolean 0
445 label I18nString ""
446 tooltip I18nString ""
447 longhelp I18nString ""
448 pos Position -1,-1
449
450 Constraints:
451 At most one of "toggle" and "radio" attributes may be 1.
452 Attribute "pos" may not appear if "label" or "radio" attributes
453 are used or if parent wxToolBar's style contains wxTB_TEXT.
454
455 Note:
456 Use of "pos" attribute is strongly discouraged, it is deprecated
457 usage of wxToolBar and it is not supported by MSW and GTK
458 implementations.
459
460Children objects are added to the toolbar using AddTool for "tool" class,
461AddSeparator for "separator" and AddControl for other classes.
462
463
464
4655. More features
466================
467
468FIXME -- "platform" property handling
469
470
471=== EOF ===
472
473Version: $Id$