]> git.saurik.com Git - wxWidgets.git/blame - docs/tech/tn0014.txt
updated wxToolBar handler to support new wxToolBar features
[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
VZ
23
24
50ccbaaa 251. Terminology
2b5f62a0 26==============
50ccbaaa
VS
27
28The usual XML terminology applies. In particular, we shall use the terms
2b5f62a0 29NODE, PROPERTY and VALUE in the XML sense:
50ccbaaa
VS
30
31 <node property1="value1" property2="value2">...</node>
32
2b5f62a0
VZ
33The term ATTRIBUTE is specific to XRC and refers to a subnode
34of an <object> or <object_ref> node that is itself not <object> or <object_ref>.
35In the example bellow, <pos>, <label> and <style> are attributes, while neither
36<resource> nor either of <object>s is:
50ccbaaa
VS
37
38 <?xml version="1.0" encoding="utf-8">
40e2d134 39 <resource xmlns="http://www.wxwindows.org/wxxrc" version="2.3.0.1">
50ccbaaa 40 <object class="wxPanel">
2b5f62a0 41 <style>wxSUNKEN_BORDER</style> <!-- attr -->
50ccbaaa 42 <object class="wxStaticText">
2b5f62a0
VZ
43 <label>A label</label> <!-- attr -->
44 <pos>10,10</pos> <!-- attr -->
50ccbaaa
VS
45 </object>
46 </object>
47 </resource>
48
2b5f62a0
VZ
49ATTRIBUTE VALUE is the content of all text elements within attribute tag. In the
50above example, "wxSUNKEN_BORDER", "A label" and "10,10" are attribute values.
51ATTRIBUTE TYPE defines what attribute values are valid for given attribute (you
52can think of it as attribute value syntax definition).
53
54
55
50ccbaaa 562. Elementary description
2b5f62a0 57=========================
50ccbaaa 58
40e2d134
VS
59XRC resource file is a well-formed XML 1.0 document. All elements of XRC file are
60from the http://www.wxwindows.org/wxxrc namespace.
50ccbaaa
VS
61
62The root node of XRC document must be <resource>. The <resource> node has
63optional "version" property. Default version (in absence of the version
64property) is "0.0.0.0". The version consists of four integers separated by
65periods. Version of XRC format changes only if there was an incompatible
66change introduced (i.e. either the library cannot understand old resource
67files or older versions of the library wouldn't understand the new format).
68The first three integers are major, minor and release number of the wxWindows
69release when the change was introduced, the last one is revision number and
70is 0 for the first incompatible change in given wxWindows release, 1 for
71the second etc.
72
73Differences between versions are described within this document in paragraphs
2b5f62a0 74entitled "Version Note".
50ccbaaa 75
40e2d134
VS
76The <resource> node contains namespace declaration, too:
77
78 <resource xmlns="http://www.wxwindows.org/wxxrc" version="2.3.0.1">
79
50ccbaaa
VS
80The <resource> node is only allowed to have <object> and <object_ref>
81subnodes, all of which must have the "name" property.
82
2b5f62a0
VZ
83The <object> node represents a single object (GUI element) and it usually maps
84directly to a wxWindows class instance. It three properties: "name", "class"
85and "subclass". "class" must always be present, it tells XRC what wxWindows
86object should be created in this place. The other two are optional.
87"name" is ID used to identify the object. It is the value passed to the XRCID() macro
88and is also used to construct wxWindow's id and name attributes and must be unique
89among all children of the neareset container object (wxDialog, wxFrame, wxPanel,
90wxNotebook) upside from the object in XML nodes hiearchy (two distinct containers
91may contain objects with same "name", though). "subclass" is
92optional name of class whose constructor will be called instead of the constructor
93for "class". Subclass must be available in the program that loads the resource,
94must be derived from "class" and must be registered within wxWindows' RTTI system.
95
96Example:
97
98 <object name="MyList1" class="wxListCtrl" subclass="MyListCtrlClass">
99 ...
100 </object>
101
102<object> node may have arbitrary child nodes. What child nodes and their semantics
103are class-dependent and are defined later in this document. The user is allowed
104to register new object handlers within XRC and extend it to accept new <object>
105classes (and therefore different <object>'s child nodes).
106
107<object_ref> node is identical to <object>, except that it does _not_ have "class"
108property and has additonal required property "ref". It's concept is similar to Unix
109symlinks: value of the "ref" property is equal to the value of "name" property of
110some existing node (called referred node) in the resources (not neccessary top-level).
111Referred node's "class" property and all subnodes are copied in place of the referee
112<object_ref> node which is then processed as regular <object> node. If the <object_ref>
113node itself has child nodes, then these nodes _override_ any nodes from the referred node.
114
115Example:
116
117 <object name="foo" class="wxTextCtrl">
118 <value>hello</value>
119 <size>100,-1d</size>
120 </object>
121 <object_ref name="bar" ref="foo">
122 <value>bar</value> <!-- override! -->
0fa2e104 123 </object_ref>
2b5f62a0
VZ
124
125is identical to:
126
127 <object name="foo" class="wxTextCtrl">
128 <value>hello</value>
129 <size>100,-1d</size>
130 </object>
131 <object name="bar" class="wxTextCtrl">
132 <value>bar</value>
133 <size>100,-1d</size>
134 </object>
135
136
137
1383. Common attribute types
139=========================
140
141There are several attribute types (see section 1. Terminology) that are common
142to many attributes of different classes:
143
144String
145------
146Any text. Some characters have special interpretation and are translated
147by XRC parser according to this table:
148 "_" -> "&" ('&' is used to underline e.g. menu items in wxWindows)
149 "__" -> "_"
150 "\n" -> line break (C character '\n')
151 "\r" -> carriage return (C character '\r')
152 "\t" -> tabelator (C character '\t')
153
154Version Note:
155 '$' was used instead of '_' prior to version 2.3.0.1.
156
157
158I18nString
159----------
160Like String, but the value is translated to native language using wxLocale
161at runtime (unless it was disabled by not passing wxXRC_USE_LOCALE flag to
162wxXmlResource constructor). Used for strings that are "visible" in the GUI.
163
164
165UnsignedInteger
166---------------
167This is obvious. Only digits 0-9 may be present and there must be at least
168one digit.
169
170
171Integer
172-------
173Like UnsignedInteger but may be prefixed with '-' (ints less than zero).
174
175
176Position
177--------
178Specifies (window's) position in 2D space. Syntax is <integer>,<integer>[d]
179where <integer> is valid value of Integer type.
180
50ccbaaa 181
2b5f62a0
VZ
182Size
183----
184Syntax is same as Position's syntax, but the values are interpreted as window
185size (wxSize type) and not position (wxPosition type).
50ccbaaa
VS
186
187
2b5f62a0
VZ
188Style[wxSomeClass]
189------------------
190List of style flags that can be passed to wxSomeClass' constructor. Flags are
191written in same way as in C++ code (e.g. "wxSUNKEN_BORDER", "wxHW_SCROLLBAR_NEVER")
192and are delimined with any combination of whitespaces and '|'. Possible flags
193are class-dependent and are not described in this technote. Please refer to wxWindows
194manual for all styles that given class can accept; if XRC does not accept a flag
195listed in wxWindows documentation, it is a bug.
196
197
198Bitmap
199------
200Attribute value is interpreted as filename (either absolute or relative to
201the location of XRC resource file). In addition, attribute node may have
202"stock_id" and "stock_client" properties. Their values may be any of wxArtID (or
203wxArtClient respectively) values as used by wxArtProvider (because the user may
204define own constants, efectively any string is legal here). Examples are
205"wxART_FILE_OPEN" (id) or "wxART_MENU" (client).
206
207Any of "stock_id" or "stock_client" properties or the filename may be omitted. XRC
208determines the bitmap to use according to this algorithm:
209 1. If there is non-empty "stock_id" property, query wxArtProvider for the bitmap
210 (if there is no "stock_client", use default one, which is usually wxART_OTHER;
211 exceptions are noted in class-specific sections bellow). If the query fails,
212 continue to 2.
213 2. Load the bitmap from the file in attribute value.
214
215
216Boolean
217-------
218Boolean value, either "0" (false) or "1" (true).
219
50ccbaaa 220
50ccbaaa
VS
221
2224. Supported classes
2b5f62a0
VZ
223====================
224
225Attributes are listed in tables in the following format:
226attribute name attribute type default value, if any
227 [(optional remarks....................
228 ...................................)]
229
230wxBitmap
231--------
232This is a special case, because it does not create a wxWindow instance but
233creates wxBitmap instead. Another exceptional thing is that it does not have
234any attributes. Instead, the node itself is interpreted as if it were attribute
235of type Bitmap.
236
237Example: <object class="wxBitmap">bitmaps/foo.gif</object>
238
239
240wxIcon
241------
242Identical to wxBitmap class, except that it creates wxIcon instead of wxBitmap.
243
244
245wxButton
246--------
247position Position -1,-1
248size Size -1,-1
249style Style[wxButton]
250
251label I18nString
252default Boolean false
253 (Is the button default button?)
254
255
256wxCalendarCtrl
257--------------
258position Position -1,-1
259size Size -1,-1
260style Style[wxCalendarCtrl]
261
262
263wxCheckBox
264----------
265position Position -1,-1
266size Size -1,-1
267style Style[wxCheckBox]
268checked Boolean false
269
270
271wxCheckList
272-----------
273position Position -1,-1
274size Size -1,-1
275style Style[wxCheckList]
276content (see bellow) (empty)
277
278Optional "content" attribute does not have attribute value. Instead,
279arbitrary number of <item> nodes may be rooted under it (the control
280is filled with strings contained in these nodes). Each <item>
281node must contain I18nString value and may have "checked" property
282with possible values "0" or "1" indicating the the item is initially
283checked.
284
285Example:
286<object class="wxCheckList">
287 <content>
288 <item>One</item>
289 <item checked="1">Two</item>
290 <item checked="1">Three</item>
291 <item>Four</item>
292 </content>
293</object>
294
295
296wxScrolledWindow
297----------------
298position Position -1,-1
299size Size -1,-1
300style Style[wxScrolledWindow] wxHSCROLL | wxVSCROLL
301
302
303
3045. More features
305================
306
307FIXME -- "platform" property handling
50ccbaaa 308
50ccbaaa
VS
309
310=== EOF ===
311
312Version: $Id$