]> git.saurik.com Git - wxWidgets.git/blame - docs/tech/tn0014.txt
Include wx/confbase.h which is needed by this file.
[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>.
38In the example bellow, <pos>, <label> and <style> are attributes, while neither
39<resource> nor either of <object>s is:
50ccbaaa
VS
40
41 <?xml version="1.0" encoding="utf-8">
40e2d134 42 <resource xmlns="http://www.wxwindows.org/wxxrc" version="2.3.0.1">
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
VS
62XRC resource file is a well-formed XML 1.0 document. All elements of XRC file
63are from the http://www.wxwindows.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).
71The first three integers are major, minor and release number of the wxWindows
72release when the change was introduced, the last one is revision number and
73is 0 for the first incompatible change in given wxWindows release, 1 for
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
81 <resource xmlns="http://www.wxwindows.org/wxxrc" version="2.3.0.1">
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
VZ
86The <object> node represents a single object (GUI element) and it usually maps
87directly to a wxWindows class instance. It three properties: "name", "class"
88and "subclass". "class" must always be present, it tells XRC what wxWindows
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
98wxWindows' 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:
153 "_" -> "&" ('&' is used to underline e.g. menu items in wxWindows)
154 "__" -> "_"
155 "\n" -> line break (C character '\n')
156 "\r" -> carriage return (C character '\r')
157 "\t" -> tabelator (C character '\t')
158
159Version Note:
160 '$' was used instead of '_' prior to version 2.3.0.1.
161
162
163I18nString
164----------
165Like String, but the value is translated to native language using wxLocale
166at runtime (unless it was disabled by not passing wxXRC_USE_LOCALE flag to
167wxXmlResource constructor). Used for strings that are "visible" in the GUI.
168
169
170UnsignedInteger
171---------------
172This is obvious. Only digits 0-9 may be present and there must be at least
173one digit.
174
175
176Integer
177-------
178Like UnsignedInteger but may be prefixed with '-' (ints less than zero).
179
180
181Position
182--------
183Specifies (window's) position in 2D space. Syntax is <integer>,<integer>[d]
184where <integer> is valid value of Integer type.
185
50ccbaaa 186
2b5f62a0
VZ
187Size
188----
189Syntax is same as Position's syntax, but the values are interpreted as window
190size (wxSize type) and not position (wxPosition type).
50ccbaaa
VS
191
192
2b5f62a0
VZ
193Style[wxSomeClass]
194------------------
195List of style flags that can be passed to wxSomeClass' constructor. Flags are
432be5aa
VS
196written in same way as in C++ code (e.g. "wxSUNKEN_BORDER",
197"wxHW_SCROLLBAR_NEVER") and are delimined with any combination of whitespaces
198and '|'. Possible flags are class-dependent and are not described in this
199technote. Please refer to wxWindows manual for all styles that given class can
200accept; if XRC does not accept a flag listed in wxWindows documentation, it is
201a bug.
2b5f62a0
VZ
202
203
204Bitmap
205------
206Attribute value is interpreted as filename (either absolute or relative to
207the location of XRC resource file). In addition, attribute node may have
208"stock_id" and "stock_client" properties. Their values may be any of wxArtID (or
209wxArtClient respectively) values as used by wxArtProvider (because the user may
210define own constants, efectively any string is legal here). Examples are
211"wxART_FILE_OPEN" (id) or "wxART_MENU" (client).
212
432be5aa
VS
213Any of "stock_id" or "stock_client" properties or the filename may be omitted.
214XRC determines the bitmap to use according to this algorithm:
215 1. If there is non-empty "stock_id" property, query wxArtProvider for the
216 bitmap (if there is no "stock_client", use default one, which is usually
217 wxART_OTHER; exceptions are noted in class-specific sections bellow). If
218 the query fails, continue to 2.
2b5f62a0
VZ
219 2. Load the bitmap from the file in attribute value.
220
221
222Boolean
223-------
224Boolean value, either "0" (false) or "1" (true).
225
50ccbaaa 226
50ccbaaa
VS
227
2284. Supported classes
2b5f62a0
VZ
229====================
230
231Attributes are listed in tables in the following format:
232attribute name attribute type default value, if any
233 [(optional remarks....................
234 ...................................)]
235
236wxBitmap
237--------
238This is a special case, because it does not create a wxWindow instance but
239creates wxBitmap instead. Another exceptional thing is that it does not have
240any attributes. Instead, the node itself is interpreted as if it were attribute
241of type Bitmap.
242
243Example: <object class="wxBitmap">bitmaps/foo.gif</object>
244
245
246wxIcon
247------
248Identical to wxBitmap class, except that it creates wxIcon instead of wxBitmap.
249
250
251wxButton
252--------
253position Position -1,-1
254size Size -1,-1
255style Style[wxButton]
256
257label I18nString
258default Boolean false
259 (Is the button default button?)
260
261
262wxCalendarCtrl
263--------------
264position Position -1,-1
265size Size -1,-1
266style Style[wxCalendarCtrl]
267
268
269wxCheckBox
270----------
271position Position -1,-1
272size Size -1,-1
273style Style[wxCheckBox]
274checked Boolean false
275
276
277wxCheckList
278-----------
279position Position -1,-1
280size Size -1,-1
281style Style[wxCheckList]
282content (see bellow) (empty)
283
284Optional "content" attribute does not have attribute value. Instead,
285arbitrary number of <item> nodes may be rooted under it (the control
286is filled with strings contained in these nodes). Each <item>
287node must contain I18nString value and may have "checked" property
288with possible values "0" or "1" indicating the the item is initially
289checked.
290
291Example:
292<object class="wxCheckList">
293 <content>
294 <item>One</item>
295 <item checked="1">Two</item>
296 <item checked="1">Three</item>
297 <item>Four</item>
298 </content>
299</object>
300
301
302wxScrolledWindow
303----------------
304position Position -1,-1
305size Size -1,-1
306style Style[wxScrolledWindow] wxHSCROLL | wxVSCROLL
307
308
2f5b93fb
VS
309wxSplitterWindow
310----------------
311position Position -1,-1
312size Size -1,-1
313style Style[wxSplitterWindow] wxSP_3D
314sashpos Integer 0
315 (Initial sash position)
316minsize Integer -1
317 (Minimal panel size)
318orientation "horizontal"|"vertical" horizontal
319
320wxSplitterWindow must have at least one and at most two children objects.
321If there's only one child object, it is passed to wxSplitterWindow::Initialize
322and the splitter is created unsplitted. If there are two children, the
323splitter is created splitted, either horizontally or vertically depending
324on the value of "orientation" attribute.
325
326
432be5aa
VS
327wxToolBar
328---------
329position Position -1,-1
330size Size -1,-1
331style Style[wxToolBar] wxNO_BORDER|wxTB_HORIZONTAL
332bitmapsize Size -1,-1
333 (Size of contained bitmaps)
334margins Size -1,-1
335packing Integer -1
336separation Integer -1
337
338wxToolBar node may have children <object> and <object_ref> nodes. Their class
339may be either "tool", "separator" or any wxWindows class derived from
340wxControl. "tool" and "separator" are special pseudo-classes that may only
341appear within wxToolBar node. Their attributes are as follows:
342
343 separator
344 ---------
345 (doesn't have any attributes)
346
347 tool
348 ----
349 bitmap Bitmap
350 bitmap2 Bitmap wxNullBitmap
351 toggle Boolean 0
352 radio Boolean 0
353 label I18nString ""
354 tooltip I18nString ""
355 longhelp I18nString ""
356 position Position -1,-1
357
358 Constraints:
359 At most one of "toggle" and "radio" attributes may be 1.
360 Attribute "position" may not appear if "label" or "radio" attributes
361 are used or if parent wxToolBar's style contains wxTB_TEXT.
362
363 Note:
364 Use of "position" attribute is strongly discouraged, it is deprecated
365 usage of wxToolBar and it is not supported by MSW and GTK
366 implementations.
367
368Children objects are added to the toolbar using AddTool for "tool" class,
369AddSeparator for "separator" and AddControl for other classes.
370
371
2b5f62a0
VZ
372
3735. More features
374================
375
376FIXME -- "platform" property handling
50ccbaaa 377
50ccbaaa
VS
378
379=== EOF ===
380
381Version: $Id$