]>
Commit | Line | Data |
---|---|---|
a302d595 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: xrc_format.h | |
3 | // Purpose: XRC format specification | |
4 | // Author: Vaclav Slavik | |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | ||
11 | @page xrc_format XRC file format | |
12 | ||
13 | Table of contents: | |
14 | - @ref xrc_format_overview | |
15 | - @ref xrc_format_root | |
16 | - @ref xrc_format_objects | |
17 | - @ref xrc_format_object | |
18 | - @ref xrc_format_object_ref | |
19 | - @ref xrc_format_datatypes | |
20 | - @ref xrc_format_windows | |
21 | - @ref xrc_format_std_props | |
22 | - @ref xrc_format_controls | |
23 | - @ref xrc_format_sizers | |
24 | - @ref xrc_format_other_objects | |
25 | - @ref xrc_format_platform | |
26 | - @ref xrc_format_extending | |
27 | - @ref xrc_format_extending_subclass | |
28 | - @ref xrc_format_extending_unknown | |
29 | - @ref xrc_format_extending_custom | |
30 | - @ref xrc_format_packed | |
31 | - @ref xrc_format_oldversions | |
32 | ||
33 | This document describes the format of XRC resource files, as used by | |
34 | wxXmlResource. | |
35 | ||
36 | ||
37 | @section xrc_format_overview Overview | |
38 | ||
39 | XRC file is a XML file with all of its elements in the | |
40 | @c http://www.wxwidgets.org/wxxrc namespace. For backward compatibility, | |
41 | @c http://www.wxwindows.org/wxxrc namespace is accepted as well (and treated | |
42 | as identical to @c http://www.wxwidgets.org/wxxrc), but it shouldn't be used | |
43 | in new XRC files. | |
44 | ||
45 | XRC file contains definitions for one or more @em objects -- typically | |
46 | windows. The objects may themselves contain child objects. | |
47 | ||
48 | Objects defined at the top level, under the | |
49 | @ref xrc_format_root "root element", can be accessed using | |
50 | wxXmlResource::LoadDialog() and other LoadXXX methods. They must have | |
51 | @c name attribute that is used as LoadXXX's argument (see | |
52 | @ref xrc_format_object for details). | |
53 | ||
54 | Child objects are not directly accessible via wxXmlResource, they can only | |
55 | be accessed using XRCCTRL(). | |
56 | ||
57 | ||
58 | @section xrc_format_root Root element: <resource> | |
59 | ||
60 | The root element is always @c <resource>. It has one optional attribute, @c | |
61 | version. If set, it specifies version of the file. In absence of @c version | |
62 | attribute, the default is @c "0.0.0.0". | |
63 | ||
64 | The version consists of four integers separated by periods. The first three | |
65 | components are major, minor and release number of the wxWidgets release when | |
66 | the change was introduced, the last one is revision number and is 0 for the | |
67 | first incompatible change in given wxWidgets release, 1 for the second and so | |
68 | on. The version changes only if there was an incompatible change introduced; | |
69 | merely adding new kind of objects does not constitute incompatible change. | |
70 | ||
71 | At the time of writing, the latest version is @c "2.5.3.0". | |
72 | ||
73 | Note that even though @c version attribute is optional, it should always be | |
74 | specified to take advantage of the latest capabilities: | |
75 | ||
76 | @code | |
77 | <?xml version="1.0"?> | |
78 | <resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.5.3.0"> | |
79 | ... | |
80 | </resource> | |
81 | @endcode | |
82 | ||
83 | @c <resource> may have arbitrary number of | |
84 | @ref xrc_format_objects "object elements" as its children; they are referred | |
85 | to as @em toplevel objects in the rest of this document. Unlike objects defined | |
86 | deeper in the hierarchy, toplevel objects @em must have their @c name attribute | |
87 | set and it must be set to a value unique among root's children. | |
88 | ||
89 | ||
90 | ||
91 | @section xrc_format_objects Defining objects | |
92 | ||
93 | @subsection xrc_format_object <object> | |
94 | ||
95 | The @c <object> element represents a single object (typically a GUI element) | |
96 | and it usually maps directly to a wxWidgets class instance. It has one | |
97 | mandatory attribute, @c class, and optional @c name and @c subclass attributes. | |
98 | ||
99 | The @c class attribute must always be present, it tells XRC what wxWidgets | |
100 | object should be created and by which wxXmlResourceHandler. | |
101 | ||
102 | @c name is the identifier used to identify the object. This name serves three | |
103 | purposes: | |
104 | ||
105 | -# It is used by wxXmlResource's various LoadXXX() methods to find the | |
106 | resource by name passed as argument. | |
107 | -# wxWindow's name (see wxWindow::GetName()) is set to it. | |
108 | -# Numeric ID of a window or menu item is derived from the name. | |
109 | If the value represents an integer (in decimal notation), it is used for | |
110 | the numeric ID unmodified. If it is one of the wxID_XXX literals defined | |
111 | by wxWidgets (see @ref page_stockitems), its respective value is used. | |
112 | Otherwise, the name is transformed into dynamically generated ID. See | |
113 | wxXmlResource::GetXRCID() for more information. | |
114 | ||
115 | Name attributes must be unique at the top level (where the name is used to | |
116 | load resources) and should be unique among all controls within the same | |
117 | toplevel window (wxDialog, wxFrame). | |
118 | ||
119 | The @c subclass attribute optional name of class whose constructor will be | |
120 | called instead of the constructor for "class". | |
121 | See @ref xrc_format_extending_subclass for more details. | |
122 | ||
123 | @c <object> element may -- and almost always do -- have children elements. | |
124 | These come in two varieties: | |
125 | ||
126 | -# Object's properties. A @em property is a value describing part of object's | |
127 | behaviour, for example the "label" property on wxButton defines its label. | |
128 | In the most common form, property is a single element with text content | |
129 | ("<label>Cancel</label"), but they may use nested subelements too (e.g. | |
130 | @ref xrc_format_type_font "font property"). A property can only be | |
131 | listed once in an object's definition. | |
132 | -# Child objects. Window childs, sizers, sizer items or notebook pages | |
133 | are all examples of child objects. They are represented using nested | |
134 | @c <object> elements and are can be repeated more than once. The specifics | |
135 | of which object classes are allowed as children are class-specific and | |
136 | are documented below in @ref xrc_format_controls. | |
137 | ||
138 | Example: | |
139 | @code | |
140 | <object class="wxDialog" name="example_dialog"> | |
141 | <!-- properties: --> | |
142 | <title>Non-Derived Dialog Example</title> | |
143 | <centered>1</centered> | |
144 | <!-- child objects: --> | |
145 | <object class="wxBoxSizer"> | |
146 | <orient>wxVERTICAL</orient> | |
147 | <cols>1</cols> | |
148 | <rows>0</rows> | |
149 | ... | |
150 | </object> | |
151 | </object> | |
152 | @endcode | |
153 | ||
154 | ||
155 | @subsection xrc_format_object_ref <object_ref> | |
156 | ||
157 | Anywhere an @c <object> element can be used, @c <object_ref> may be used | |
158 | instead. @c <object_ref> is a @em reference to another named (i.e. with the | |
159 | @c name attribute) @c <object> element. It has one mandatory attribute, | |
160 | @c ref, with value containing the name of a named @c <object> element. When an | |
161 | @c <object_ref> is encountered, a copy of the referenced @c <object> element | |
162 | is made in place of @c <object_ref> occurrence and processed as usual. | |
163 | ||
164 | For example, the following code: | |
165 | @code | |
166 | <object class="wxDialog" name="my_dlg"> | |
167 | ... | |
168 | </object> | |
169 | <object_ref name="my_dlg_alias" ref="my_dlg"/> | |
170 | @endcode | |
171 | is equivalent to | |
172 | @code | |
173 | <object class="wxDialog" name="my_dlg"> | |
174 | ... | |
175 | </object> | |
176 | <object class="wxDialog" name="my_dlg_alias"> | |
177 | ... <!-- same as in my_dlg --> | |
178 | </object> | |
179 | @endcode | |
180 | ||
181 | Additionally, it is possible to override some parts of the referenced object | |
182 | in the @c <object_ref> pointing to it. This is useful for putting repetitive | |
183 | parts of XRC definitions into a template that can be reused and customized in | |
184 | several places. The two parts are merged as follows: | |
185 | ||
186 | -# The referred object is used as the initial content. | |
187 | -# All attributes set on @c <object_ref> are added to it. | |
188 | -# All child elements of @c <object_ref> are scanned. If an element with | |
189 | the same name (and, if specified, the @c name attribute too) is found | |
190 | in the referred object, they are recursively merged. | |
191 | -# Child elements in @c <object_ref> that do not have a match in the referred | |
192 | object are appended to the list of children of the resulting element by | |
193 | default. Optionally, they may have @c insert_at attribute with two possible | |
194 | values, "begin" or "end". When set to "begin", the element is prepended to | |
195 | the list of children instead of appended. | |
196 | ||
197 | For example, "my_dlg" in this snippet: | |
198 | @code | |
199 | <object class="wxDialog" name="template"> | |
200 | <title>Dummy dialog</title> | |
201 | <size>400,400</size> | |
202 | </object> | |
203 | <object_ref ref="template" name="my_dlg"> | |
204 | <title>My dialog</title> | |
205 | <centered>1</centered> | |
206 | </object> | |
207 | @endcode | |
208 | is identical to: | |
209 | @code | |
210 | <object_ref ref="template" name="my_dlg"> | |
211 | <title>My dialog</title> | |
212 | <size>400,400</size> | |
213 | <centered>1</centered> | |
214 | </object> | |
215 | @endcode | |
216 | ||
217 | ||
218 | @section xrc_format_datatypes Data types | |
219 | ||
220 | There are several property data types that are frequently reused by different | |
221 | properties. Rather than describing their format in the documentation of | |
222 | every property, we list commonly used types in this section and document | |
223 | their format. | |
224 | ||
225 | ||
226 | @subsection xrc_format_type_bool Boolean | |
227 | ||
228 | Boolean values are expressed using either "1" literal (true) or "0" (false). | |
229 | ||
230 | ||
231 | @subsection xrc_format_type_float Floating-point value | |
232 | ||
233 | Floating point values use POSIX (C locale) formatting -- decimal separator | |
234 | is "." regardless of the locale. | |
235 | ||
236 | ||
237 | @subsection xrc_format_type_colour Colour | |
238 | ||
239 | Colour specification can be either any string colour representation accepted | |
240 | by wxColour::Set() or any wxSYS_COLOUR_XXX symbolic name accepted by | |
241 | wxSystemSettings::GetColour(). In particular, the following forms are supported: | |
242 | ||
243 | @li named colours from wxColourDatabase | |
244 | @li HTML-like "#rrggbb" syntax (but not "#rgb") | |
245 | @li CSS-style "rgb(r,g,b)" and "rgba(r,g,b,a)" | |
246 | @li wxSYS_COLOUR_XXX symbolic names | |
247 | ||
248 | Some examples: | |
249 | @code | |
250 | <fg>red</fg> | |
251 | <fg>#ff0000</fg> | |
252 | <fg>rgb(255,0,0)</fg> | |
253 | <fg>wxSYS_COLOUR_HIGHLIGHT</fg> | |
254 | @endcode | |
255 | ||
256 | ||
257 | @subsection xrc_format_type_size Size | |
258 | ||
259 | Sizes and positions have the form of string with two comma-separated integer | |
260 | components, with optional "d" suffix. Semi-formally: | |
261 | ||
262 | size := x "," y ["d"] | |
263 | ||
264 | where x and y are integers. Either of the components (or both) may be "-1" to | |
265 | signify default value. As a shortcut, empty string is equivalent to "-1,-1" | |
266 | (= wxDefaultSize or wxDefaultPosition). | |
267 | ||
268 | When the "d" suffix is used, integer values are interpreted as | |
269 | @ref wxWindow::ConvertDialogToPixels() "dialog units" in the parent window. | |
270 | ||
271 | Examples: | |
272 | @code | |
273 | 42,-1 | |
274 | 100,100 | |
275 | 100,50d | |
276 | @endcode | |
277 | ||
278 | @subsection xrc_format_type_pos Position | |
279 | ||
280 | Same as @ref xrc_format_type_size. | |
281 | ||
282 | ||
283 | @subsection xrc_format_type_dimension Dimension | |
284 | ||
285 | Similarly to @ref xrc_format_type_size "sizes", dimensions are expressed | |
286 | as integers with optional "d" suffix. When "d" suffix is used, the integer | |
287 | preceding it is interpreted as dialog units in the parent window. | |
288 | ||
289 | ||
290 | @subsection xrc_format_type_text Text | |
291 | ||
292 | String properties use several escape sequences that are translated according to | |
293 | the following table: | |
294 | @beginDefList | |
295 | @itemdef{ "_", "&" (used for accelerators in wxWidgets) } | |
296 | @itemdef{ "__", "_" } | |
297 | @itemdef{ "\n", line break } | |
298 | @itemdef{ "\r", carriage return } | |
299 | @itemdef{ "\t", tab } | |
300 | @itemdef{ "\\", "\" } | |
301 | @endDefList | |
302 | ||
303 | By default, the text is translated using wxLocale::GetTranslation() before | |
304 | it is used. This can be disabled either globally by not passing | |
305 | wxXRC_USE_LOCALE to wxXmlResource constructor, or by setting the @c translate | |
306 | attribute on the property node to "0": | |
307 | @code | |
308 | <!-- this is not translated: --> | |
309 | <label translate="0">_Unix</label> | |
310 | <!-- but this is: --> | |
311 | <help>Use Unix-style newlines</help> | |
312 | @endcode | |
313 | ||
314 | @note Even though the "_" character is used instead of "&" for accelerators, | |
315 | it is still possible to use "&". The latter has to be encoded as "&", | |
316 | though, so using "_" is more convenient. | |
317 | ||
318 | @see @ref xrc_format_pre_v2530, @ref xrc_format_pre_v2301 | |
319 | ||
320 | ||
321 | @subsection xrc_format_type_text_notrans Non-translatable text | |
322 | ||
323 | Like @ref xrc_format_type_text, but the text is never translated and | |
324 | @c translate attribute cannot be used. | |
325 | ||
326 | ||
327 | @subsection xrc_format_type_bitmap Bitmap | |
328 | ||
329 | Bitmap properties contain specification of a single bitmap or icon. In the most | |
330 | basic form, their text value is simply a relative filename (or another | |
331 | wxFileSystem URL) of the bitmap to use. For example: | |
332 | @code | |
333 | <object class="tool" name="wxID_NEW"> | |
334 | <tooltip>New</tooltip> | |
335 | <bitmap>new.png</bitmap> | |
336 | </object> | |
337 | @endcode | |
338 | The value is interpreted as path relative to the location of XRC file where the | |
339 | reference occurs. | |
340 | ||
341 | Alternatively, it is possible to specify the bitmap using wxArtProvider IDs. | |
342 | In this case, the property element has no textual value (filename) and instead | |
343 | has the @c stock_id XML attribute that contains stock art ID as accepted by | |
344 | wxArtProvider::GetBitmap(). This can be either custom value (if the app uses | |
345 | app-specific art provider) or one of the predefined wxART_XXX constants. | |
346 | ||
347 | Optionally, @c stock_client attribute may be specified too and contain one of | |
348 | the predefined wxArtClient values. If it is not specified, the default client | |
349 | ID most appropriate in the context where the bitmap is referenced will be used. | |
350 | In most cases, specifying @c stock_client is not needed. | |
351 | ||
352 | Examples of stock bitmaps usage: | |
353 | @code | |
354 | <bitmap stock_id="fixed-width"/> <!-- custom app-specific art --> | |
355 | <bitmap stock_id="wxART_FILE_OPEN"/> <!-- standard art-> | |
356 | @endcode | |
357 | ||
358 | Specifying the bitmap directly and using @c stock_id are mutually exclusive. | |
359 | ||
360 | ||
361 | @subsection xrc_format_type_style Style | |
362 | ||
363 | Style properties (such as window's style or sizer flags) use syntax similar to | |
364 | C++: the style value is OR-combination of individual flags. Symbolic names | |
365 | identical to those used in C++ code are used for the flags. Flags are separated | |
366 | with "|" (whitespace is allowed but not required around it). | |
367 | ||
368 | The flags that are allowed for a given property are context-dependent. | |
369 | ||
370 | Examples: | |
371 | @code | |
372 | <style>wxCAPTION|wxSYSTEM_MENU | wxRESIZE_BORDER</style> | |
373 | <exstyle>wxDIALOG_EX_CONTEXTHELP</exstyle> | |
374 | @endcode | |
375 | ||
376 | ||
377 | @subsection xrc_format_type_font Font | |
378 | ||
379 | XRC uses similar, but more flexible, abstract description of fonts to that | |
380 | used by wxFont class. A font can be described either in terms of its elementary | |
381 | properties, or it can be derived from one of system fonts. | |
382 | ||
383 | The font property element is "composite" element: unlike majority of | |
384 | properties, it doesn't have text value but contains several child elements | |
385 | instead. These children are handled in the same way as object properties | |
386 | and can be one of the following "sub-properties": | |
387 | ||
388 | @beginTable | |
389 | @hdr3col{property, type, description} | |
390 | @row3col{size, unsigned integer, | |
391 | Pixel size of the font (default: wxNORMAL_FONT's size or @c sysfont's | |
392 | size if the @c sysfont property is used.} | |
393 | @row3col{style, enum, | |
394 | One of "normal", "italic" or "slant" (default: normal).} | |
395 | @row3col{weight, enum, | |
396 | One of "normal", "bold" or "light" (default: normal).} | |
397 | @row3col{family, enum, | |
398 | One of "roman", "script", "decorative", "swiss", "modern" or "teletype" | |
399 | (default: roman).} | |
400 | @row3col{underlined, @ref xrc_format_type_bool, | |
401 | Whether the font should be underlined (default: 0).} | |
402 | @row3col{face, , | |
403 | Comma-separated list of face names; the first one available is used | |
404 | (default: unspecified).} | |
405 | @row3col{encoding, , | |
406 | Charset of the font, unused in Unicode build), as string | |
407 | (default: unspecified).} | |
408 | @row3col{sysfont, , | |
409 | Symbolic name of system standard font(one of wxSYS_*_FONT constants).} | |
410 | @row3col{relativesize, float, | |
411 | Float, font size relative to chosen system font's size; can only be | |
412 | used when 'sysfont' is used and when 'size' is not used.} | |
413 | @endTable | |
414 | ||
415 | All of them are optional, if they are missing, appropriate wxFont default is | |
416 | used. If the @c sysfont property is used, then the defaults are taken from it | |
417 | instead. | |
418 | ||
419 | Examples: | |
420 | @code | |
421 | <font> | |
422 | <!-- fixed font: Arial if available, fall back to Helvetica --> | |
423 | <face>arial,helvetica</face> | |
424 | <size>12</size> | |
425 | </font> | |
426 | ||
427 | <font> | |
428 | <!-- enlarged, enboldened standard font: --> | |
429 | <sysfont>wxSYS_DEFAULT_GUI_FONT</sysfont> | |
430 | <weight>bold</weight> | |
431 | <relativesize>1.5</relativesize> | |
432 | </font> | |
433 | @endcode | |
434 | ||
435 | ||
436 | @section xrc_format_windows Controls and windows | |
437 | ||
438 | This section describes support wxWindow-derived classes in XRC format. | |
439 | ||
440 | @subsection xrc_format_std_props Standard properties | |
441 | ||
442 | The following properties are always (unless stated otherwise in | |
443 | control-specific docs) available for @em windows objects. They are omitted | |
444 | from properties lists below. | |
445 | ||
446 | @beginTable | |
447 | @hdr3col{property, type, description} | |
448 | @row3col{position, @ref xrc_format_type_pos, | |
449 | Initial position of the window (default: wxDefaultPosition).} | |
450 | @row3col{size, @ref xrc_format_type_size, | |
451 | Initial size of the window (default: wxDefaultSize).} | |
452 | @row3col{style, @ref xrc_format_type_style, | |
453 | Window style for this control. The allowed values depend on what | |
454 | window is being created, consult respective class' constructor | |
455 | documentation for details (default: window-dependent default, usually | |
456 | wxFOO_DEFAULT_STYLE if defined for class wxFoo, 0 if not).} | |
457 | @row3col{exstyle, @ref xrc_format_type_style, | |
458 | Extra style for the window, if any. See wxWindow::SetExtraStyle() | |
459 | (default: not set).} | |
460 | @row3col{fg, @ref xrc_format_type_colour, | |
461 | Foreground colour of the window (default: window's default).} | |
462 | @row3col{bg, @ref xrc_format_type_colour, | |
463 | Background colour of the window (default: window's default).} | |
464 | @row3col{enabled, @ref xrc_format_type_bool, | |
465 | If set to 0, the control is disabled (default: 1).} | |
466 | @row3col{hidden, @ref xrc_format_type_bool, | |
467 | If set to 1, the control is created hidden (default: 0).} | |
468 | @row3col{tooltip, @ref xrc_format_type_text, | |
469 | Tooltip to use for the control (default: not set).} | |
470 | @row3col{font, @ref xrc_format_type_font, | |
471 | Font to use for the control (default: window's default).} | |
472 | @row3col{help, @ref xrc_format_type_text, | |
473 | Context-sensitive help for the control, used by wxHelpProvider | |
474 | (default: not set).} | |
475 | @endTable | |
476 | ||
477 | All of these properties are optional. | |
478 | ||
479 | ||
480 | @subsection xrc_format_controls Supported controls | |
481 | ||
482 | @subsubsection xrc_wxanimationctrl wxAnimationCtrl | |
483 | FIXME | |
484 | ||
485 | @subsubsection xrc_wxbitmapbutton wxBitmapButton | |
486 | FIXME | |
487 | ||
488 | @subsubsection xrc_wxbitmapcombobox wxBitmapComboBox | |
489 | FIXME | |
490 | ||
491 | @subsubsection xrc_wxbutton wxButton | |
492 | FIXME | |
493 | ||
494 | @subsubsection xrc_wxcalendarctrl wxCalendarCtrl | |
495 | FIXME | |
496 | ||
497 | @subsubsection xrc_wxcheckbox wxCheckBox | |
498 | FIXME | |
499 | ||
500 | @subsubsection xrc_wxchecklistbox wxCheckListBox | |
501 | FIXME | |
502 | ||
503 | @subsubsection xrc_wxchoice wxChoice | |
504 | FIXME | |
505 | ||
506 | @subsubsection xrc_wxchoicebook wxChoicebook | |
507 | FIXME | |
508 | ||
509 | @subsubsection xrc_wxcollapsiblepane wxCollapsiblePane | |
510 | FIXME | |
511 | ||
512 | @subsubsection xrc_wxcolourpickerctrl wxColourPickerCtrl | |
513 | FIXME | |
514 | ||
515 | @subsubsection xrc_wxcombobox wxComboBox | |
516 | FIXME | |
517 | ||
518 | @subsubsection xrc_wxdatepickerctrl wxDatePickerCtrl | |
519 | FIXME | |
520 | ||
521 | @subsubsection xrc_wxdialog wxDialog | |
522 | FIXME | |
523 | ||
524 | @subsubsection xrc_wxdirpickerctrl wxDirPickerCtrl | |
525 | FIXME | |
526 | ||
527 | @subsubsection xrc_wxfilepickerctrl wxFilePickerCtrl | |
528 | FIXME | |
529 | ||
530 | @subsubsection xrc_wxfontpickerctrl wxFontPickerCtrl | |
531 | FIXME | |
532 | ||
533 | @subsubsection xrc_wxfrane wxFrame | |
534 | FIXME | |
535 | ||
536 | @subsubsection xrc_wxgauge wxGauge | |
537 | FIXME | |
538 | ||
539 | @subsubsection xrc_wxgenericdirctrl wxGenericDirCtrl | |
540 | FIXME | |
541 | ||
542 | @subsubsection xrc_wxgrid wxGrid | |
543 | FIXME | |
544 | ||
545 | @subsubsection xrc_wxhtmlwindow wxHtmlWindow | |
546 | FIXME | |
547 | ||
548 | @subsubsection xrc_wxhyperlinkctrl wxHyperlinkCtrl | |
549 | FIXME | |
550 | ||
551 | @subsubsection xrc_wxlistbox wxListBox | |
552 | FIXME | |
553 | ||
554 | @subsubsection xrc_wxlistbook wxListbook | |
555 | FIXME | |
556 | ||
557 | @subsubsection xrc_wxlistctrl wxListCtrl | |
558 | FIXME | |
559 | ||
560 | @subsubsection xrc_wxmdiparentframe wxMDIParentFrame | |
561 | FIXME | |
562 | ||
563 | @subsubsection xrc_wxmdichildframe wxMDIChildFrame | |
564 | FIXME | |
565 | ||
566 | @subsubsection xrc_wxmenu wxMenu | |
567 | FIXME | |
568 | ||
569 | @subsubsection xrc_wxmenubar wxMenuBar | |
570 | FIXME | |
571 | ||
572 | @subsubsection xrc_wxnotebook wxNotebook | |
573 | FIXME | |
574 | ||
575 | @subsubsection xrc_wxownerdrawncombobox wxOwnerDrawnComboBox | |
576 | FIXME | |
577 | ||
578 | @subsubsection xrc_wxpanel wxPanel | |
579 | FIXME | |
580 | ||
581 | @subsubsection xrc_wxpropertysheetdialog wxPropertySheetDialog | |
582 | FIXME | |
583 | ||
584 | @subsubsection xrc_wxradiobutton wxRadioButton | |
585 | FIXME | |
586 | ||
587 | @subsubsection xrc_wxradiobox wxRadioBox | |
588 | FIXME | |
589 | ||
590 | @subsubsection xrc_wxrichtextctrl wxRichTextCtrl | |
591 | FIXME | |
592 | ||
593 | @subsubsection xrc_wxscrollbar wxScrollBar | |
594 | FIXME | |
595 | ||
596 | @subsubsection xrc_wxscrolledwindow wxScrolledWindow | |
597 | FIXME | |
598 | ||
599 | @subsubsection xrc_wxsimplehtmllistbox wxSimpleHtmlListBox | |
600 | FIXME | |
601 | ||
602 | @subsubsection xrc_wxslider wxSliderq | |
603 | FIXME | |
604 | ||
605 | @subsubsection xrc_wxspinctrl wxSpinCtrl | |
606 | FIXME | |
607 | ||
608 | @subsubsection xrc_wxsplitterwindow wxSplitterWindow | |
609 | FIXME | |
610 | ||
611 | @subsubsection xrc_wxsearchctrl wxSearchCtrl | |
612 | FIXME | |
613 | ||
614 | @subsubsection xrc_wxstatusbar wxStatusBar | |
615 | FIXME | |
616 | ||
617 | @subsubsection xrc_wxstaticbitmap wxStaticBitmap | |
618 | FIXME | |
619 | ||
620 | @subsubsection xrc_wxstaticbox wxStaticBox | |
621 | FIXME | |
622 | ||
623 | @subsubsection xrc_wxstaticline wxStaticLine | |
624 | FIXME | |
625 | ||
626 | @subsubsection xrc_wxstatictext wxStaticText | |
627 | FIXME | |
628 | ||
629 | @subsubsection xrc_wxtextctrl wxTextCtrl | |
630 | FIXME | |
631 | ||
632 | @subsubsection xrc_wxtogglebuttton wxToggleButton | |
633 | FIXME | |
634 | ||
635 | @subsubsection xrc_wxtoolbar wxToolBar | |
636 | FIXME | |
637 | ||
638 | @subsubsection xrc_wxtreectrl wxTreeCtrl | |
639 | FIXME | |
640 | ||
641 | @subsubsection xrc_wxtreebook wxTreebook | |
642 | FIXME | |
643 | ||
644 | @subsubsection xrc_wxwizard wxWizard | |
645 | FIXME | |
646 | ||
647 | ||
648 | @section xrc_format_sizers Sizers | |
649 | ||
650 | Sizers are handled slightly differently in XRC resources than they are in | |
651 | wxWindow hierarchy. wxWindow's sizers hierarchy is parallel to the wxWindow | |
652 | children hieararchy: child windows are children of their parent window and | |
653 | the sizer (or sizers) form separate hierarchy attached to the window with | |
654 | wxWindow::SetSizer(). | |
655 | ||
656 | In XRC, the two hierarchies are merged together: sizers are children of other | |
657 | sizers or windows and they can contain child window objects. | |
658 | ||
659 | If a sizer is child of a window object in the resource, it must be the only | |
660 | child and it will be attached to the parent with wxWindow::SetSizer(). | |
661 | Additionally, if the window doesn't have its size explicitly set, | |
662 | wxSizer::Fit() is used to resize the window. If the parent window is | |
663 | toplevel window, wxSizer::SetSizeHints() is called to set its hints. | |
664 | ||
665 | A sizer object can have one or more child objects of one of two pseudo-classes: | |
666 | @c sizeritem or @c spacer (see @ref xrc_format_wxstddialogbuttonsizer for | |
667 | an exception). The former specifies an element (another sizer or a window) | |
668 | to include in the sizer, the latter adds empty space to the sizer. | |
669 | ||
670 | @c sizeritem objects have exactly one child object: either another sizer | |
671 | object, or a window object. @c spacer objects don't have any children, but | |
672 | they have one property: | |
673 | ||
674 | @beginTable | |
675 | @hdr3col{property, type, description} | |
676 | @row3col{size, @ref xrc_format_type_size, Size of the empty space (required).} | |
677 | @endTable | |
678 | ||
679 | Both @c sizeritem and @c spacer objects can have any of the following | |
680 | properties: | |
681 | ||
682 | @beginTable | |
683 | @hdr3col{property, type, description} | |
684 | @row3col{option, integer, | |
685 | The "option" value for sizers. Used by wxBoxSizer to set proportion of | |
686 | the item in the growable direction (default: 0).} | |
687 | @row3col{flag, @ref xrc_format_type_style, | |
688 | wxSizerItem flags (default: 0).} | |
689 | @row3col{border, @ref xrc_format_type_dimension, | |
690 | Size of the border around the item (directions are specified in flags) | |
691 | (default: 0).} | |
692 | @row3col{minsize, @ref xrc_format_type_size, | |
693 | Minimal size of this item (default: no min size).} | |
694 | @row3col{ratio, @ref xrc_format_type_size, | |
695 | Item ratio, see wxSizer::SetRatio() (default: no ratio).} | |
696 | @row3col{cellpos, @ref xrc_format_type_pos, | |
697 | (wxGridBagSizer only) Position, see wxGBSizerItem::SetPos() (required). } | |
698 | @row3col{cellspan, @ref xrc_format_type_size, | |
699 | (wxGridBagSizer only) Span, see wxGBSizerItem::SetSpan() (required). } | |
700 | @endTable | |
701 | ||
702 | Example of sizers XRC code: | |
703 | @code | |
704 | <object class="wxDialog" name="derived_dialog"> | |
705 | <title>Derived Dialog Example</title> | |
706 | <centered>1</centered> | |
707 | <!-- this sizer is set to be this dialog's sizer: --> | |
708 | <object class="wxFlexGridSizer"> | |
709 | <cols>1</cols> | |
710 | <rows>0</rows> | |
711 | <vgap>0</vgap> | |
712 | <hgap>0</hgap> | |
713 | <growablecols>0</growablecols> | |
714 | <growablerows>0</growablerows> | |
715 | <object class="sizeritem"> | |
716 | <flag>wxALIGN_CENTRE|wxALL</flag> | |
717 | <border>5</border> | |
718 | <object class="wxButton" name="my_button"> | |
719 | <label>My Button</label> | |
720 | </object> | |
721 | </object> | |
722 | <object class="sizeritem"> | |
723 | <flag>wxALIGN_CENTRE|wxALL</flag> | |
724 | <border>5</border> | |
725 | <object class="wxBoxSizer"> | |
726 | <orient>wxHORIZONTAL</orient> | |
727 | <object class="sizeritem"> | |
728 | <flag>wxALIGN_CENTRE|wxALL</flag> | |
729 | <border>5</border> | |
730 | <object class="wxCheckBox" name="my_checkbox"> | |
731 | <label>Enable this text control:</label> | |
732 | </object> | |
733 | </object> | |
734 | <object class="sizeritem"> | |
735 | <flag>wxALIGN_CENTRE|wxALL</flag> | |
736 | <border>5</border> | |
737 | <object class="wxTextCtrl" name="my_textctrl"> | |
738 | <size>80,-1</size> | |
739 | <value></value> | |
740 | </object> | |
741 | </object> | |
742 | </object> | |
743 | </object> | |
744 | ... | |
745 | </object> | |
746 | </object> | |
747 | @endcode | |
748 | ||
749 | The sizer classes that can be used are listed below, together with their | |
750 | class-specific properties. All classes support the following properties: | |
751 | ||
752 | @beginTable | |
753 | @hdr3col{property, type, description} | |
754 | @row3col{minsize, @ref xrc_format_type_size, | |
755 | Minimal size that this sizer will have, see wxSizer::SetMinSize() | |
756 | (default: no min size).} | |
757 | @endTable | |
758 | ||
759 | @subsection xrc_format_wxboxsizer wxBoxSizer | |
760 | ||
761 | @beginTable | |
762 | @hdr3col{property, type, description} | |
763 | @row3col{orient, @ref xrc_format_type_style, | |
764 | Sizer orientation, "wxHORIZONTAL" or "wxVERTICAL" (default: wxHORIZONTAL).} | |
765 | @endTable | |
766 | ||
767 | @subsection xrc_format_wxstaticsboxizer wxStaticBoxSizer | |
768 | ||
769 | @beginTable | |
770 | @hdr3col{property, type, description} | |
771 | @row3col{orient, @ref xrc_format_type_style, | |
772 | Sizer orientation, "wxHORIZONTAL" or "wxVERTICAL" (default: wxHORIZONTAL).} | |
773 | @row3col{label, @ref xrc_format_type_text, | |
774 | Label to be used for the static box around the sizer (required).} | |
775 | @endTable | |
776 | ||
777 | @subsection xrc_format_wxgridsizer wxGridSizer | |
778 | ||
779 | @beginTable | |
780 | @hdr3col{property, type, description} | |
781 | @row3col{rows, integer, Number of rows in the grid (required).} | |
782 | @row3col{cols, integer, Number of columns in the grid (required).} | |
783 | @row3col{vgap, integer, Vertical gap between children (default: 0).} | |
784 | @row3col{hgap, integer, Horizontal gap between children (default: 0).} | |
785 | @endTable | |
786 | ||
787 | @subsection xrc_format_wxflexgridsizer wxFlexGridSizer | |
788 | ||
789 | @beginTable | |
790 | @hdr3col{property, type, description} | |
791 | @row3col{rows, integer, Number of rows in the grid (required).} | |
792 | @row3col{cols, integer, Number of columns in the grid (required).} | |
793 | @row3col{vgap, integer, Vertical gap between children (default: 0).} | |
794 | @row3col{hgap, integer, Horizontal gap between children (default: 0).} | |
795 | @row3col{growablerows, comma-separated integers list, | |
796 | Comma-separated list of indexes of rows that are growable | |
797 | (default: none).} | |
798 | @row3col{growablecols, comma-separated integers list, | |
799 | Comma-separated list of indexes of columns that are growable | |
800 | (default: none).} | |
801 | @endTable | |
802 | ||
803 | @subsection xrc_format_wxgridbagsizer wxGridBagSizer | |
804 | ||
805 | @beginTable | |
806 | @hdr3col{property, type, description} | |
807 | @row3col{vgap, integer, Vertical gap between children (default: 0).} | |
808 | @row3col{hgap, integer, Horizontal gap between children (default: 0).} | |
809 | @row3col{growablerows, comma-separated integers list, | |
810 | Comma-separated list of indexes of rows that are growable | |
811 | (default: none).} | |
812 | @row3col{growablecols, comma-separated integers list, | |
813 | Comma-separated list of indexes of columns that are growable | |
814 | (default: none).} | |
815 | @endTable | |
816 | ||
817 | @subsection xrc_format_wxwrapsizer wxWrapSizer | |
818 | ||
819 | @beginTable | |
820 | @hdr3col{property, type, description} | |
821 | @row3col{orient, @ref xrc_format_type_style, | |
822 | Sizer orientation, "wxHORIZONTAL" or "wxVERTICAL" (required).} | |
823 | @row3col{flag, @ref xrc_format_type_style, wxWrapSizer flags (default: 0).} | |
824 | @endTable | |
825 | ||
826 | @subsection xrc_format_wxstddialogbuttonsizer wxStdDialogButtonSizer | |
827 | ||
828 | Unlike other sizers, wxStdDialogButtonSizer doesn't have neither @c sizeritem | |
829 | nor @c spacer children. Instead, it has one or more children of the | |
830 | @c button pseudo-class. @c button objects have no properties and they must | |
831 | always have exactly one child of the @c wxButton class or a class derived from | |
832 | wxButton. | |
833 | ||
834 | Example: | |
835 | @code | |
836 | <object class="wxStdDialogButtonSizer"> | |
837 | <object class="button"> | |
838 | <object class="wxButton" name="wxID_OK"> | |
839 | <label>OK</label> | |
840 | </object> | |
841 | </object> | |
842 | <object class="button"> | |
843 | <object class="wxButton" name="wxID_CANCEL"> | |
844 | <label>Cancel</label> | |
845 | </object> | |
846 | </object> | |
847 | </object> | |
848 | @endcode | |
849 | ||
850 | ||
851 | ||
852 | @section xrc_format_other_objects Other objects | |
853 | ||
854 | In addition to describing UI elements, XRC files can contain non-windows | |
855 | objects such as bitmaps or icons. This is a concession to Windows developers | |
856 | used to storing them in Win32 resources. | |
857 | ||
858 | Note that unlike Win32 resources, bitmaps included in XRC files are @em not | |
859 | embedded in the XRC file itself. XRC file only contains a reference to another | |
860 | file with bitmap data. | |
861 | ||
862 | @subsection xrc_format_bitmap wxBitmap | |
863 | ||
864 | Bitmaps are stored in @c <object> element with class set to @c wxBitmap. Such | |
865 | bitmaps can then be loaded using wxXmlResource::LoadBitmap(). The content of | |
866 | the element is exactly same as in the case of | |
867 | @ref xrc_format_type_bitmap "bitmap properties", except that toplevel | |
868 | @c <object> is used. | |
869 | ||
870 | For example, instead of: | |
871 | @code | |
872 | <bitmap>mybmp.png</bitmap> | |
873 | <bitmap stock_id="wxART_NEW"/> | |
874 | @endcode | |
875 | toplevel wxBitmap resources would look like: | |
876 | @code | |
877 | <object class="wxBitmap" name="my_bitmap">mybmp.png</object> | |
878 | <object class="wxBitmap" name="my_new_bitmap" stock_id="wxART_NEW"/> | |
879 | @endcode | |
880 | ||
881 | ||
882 | @subsection xrc_format_icon wxIcon | |
883 | ||
884 | wxIcon resources are identical to @ref xrc_format_bitmap "wxBitmap ones", | |
885 | except that the class is @c wxIcon. | |
886 | ||
887 | ||
888 | @section xrc_format_platform Platform specific content | |
889 | ||
890 | It is possible to conditionally process parts of XRC files on some platforms | |
891 | only and ignore them on other platforms. @em Any element in XRC file, be it | |
892 | toplevel or arbitrarily nested one, can have the @c platform attribute. When | |
893 | used, @c platform contains |-separated list of platforms that this element | |
894 | should be processed on. It is filtered out and ignored on any other platforms. | |
895 | ||
896 | Possible elemental values are: | |
897 | @beginDefList | |
898 | @itemdef{ @c win, Windows } | |
899 | @itemdef{ @c mac, Mac OS X (or Mac Classic in wxWidgets version supporting it } | |
900 | @itemdef{ @c unix, Any Unix platform @em except OS X } | |
901 | @itemdef{ @c os2, OS/2 } | |
902 | @endDefList | |
903 | ||
904 | Examples: | |
905 | @code | |
906 | <label platform="win">Windows</label> | |
907 | <label platform="unix">Unix</label> | |
908 | <label platform="mac">Mac OS X</label> | |
909 | <help platform="mac|unix">Not a Windows machine</help> | |
910 | @endcode | |
911 | ||
912 | ||
913 | ||
914 | @section xrc_format_extending Extending XRC format | |
915 | ||
916 | The XRC format is designed to be extensible and allows specifying and loading | |
917 | custom controls. The three available mechanisms are described in the rest of | |
918 | this section in the order of increasing complexity. | |
919 | ||
920 | @subsection xrc_format_extending_subclass Subclassing | |
921 | ||
922 | The simplest way to add custom controls is to set the @c subclass attribute | |
923 | of @c <object> element: | |
924 | ||
925 | @code | |
926 | <object name="my_value" class="wxTextCtrl" subclass="MyTextCtrl"> | |
927 | <style>wxTE_MULTILINE</style> | |
928 | ...etc., setup wxTextCtrl as usual... | |
929 | </object> | |
930 | @endcode | |
931 | ||
932 | In that case, wxXmlResource will create an instance of the specified subclass | |
933 | (@c MyTextCtrl in the example above) instead of the class (@c wxTextCtrl above) | |
934 | when loading the resource. However, the rest of the object's loading (calling | |
935 | its Create() method, setting its properties, loading any children etc.) | |
936 | will proceed in @em exactly the same way as it would without @c subclass | |
937 | attribute. In other words, this approach is only sufficient when the custom | |
938 | class is just a small modification (e.g. overridden methods or customized | |
939 | events handling) of an already supported classes. | |
940 | ||
941 | The subclass must satisfy a number of requirements: | |
942 | ||
943 | -# It must be derived from the class specified in @c class attribute. | |
944 | -# It must be visible in wxWidget's pseudo-RTTI mechanism, i.e. there must be | |
945 | a DECLARE_DYNAMIC_CLASS() entry for it. | |
946 | -# It must support two-phase creation. In particular, this means that it has | |
947 | to have default constructor. | |
948 | -# It cannot provide custom Create() method and must be constructible using | |
949 | base @c class' Create() method (this is because XRC will call Create() of | |
950 | @c class, not @c subclass). In other words, @em creation of the control | |
951 | must not be customized. | |
952 | ||
953 | ||
954 | @subsection xrc_format_extending_unknown <object class="unknown"> | |
955 | ||
956 | A more flexible solution is to put a @em placeholder in the XRC file and | |
957 | replace it with custom control after the resource is loaded. This is done by | |
958 | using the @c unknown pseudo-class: | |
959 | ||
960 | @code | |
961 | <object class="unknown" name="my_placeholder"/> | |
962 | @endcode | |
963 | ||
964 | The placeholder is inserted as dummy wxPanel that will hold custom control in | |
965 | it. At runtime, after the resource is loaded and a window created from it | |
966 | (using e.g. wxXmlResource::LoadDialog()), use code must call | |
967 | wxXmlResource::AttachUnknownControl() to insert the desired control into | |
968 | placeholder container. | |
969 | ||
970 | This method makes it possible to insert controls that are not known to XRC at | |
971 | all, but it's also impossible to configure the control in XRC description in | |
972 | any way. The only properties that can be specified are | |
973 | the @ref xrc_format_std_props "standard window properties". | |
974 | ||
975 | @note @c unknown class cannot be combined with @c subclass attribute, | |
976 | they are mutually exclusive. | |
977 | ||
978 | ||
979 | @subsection xrc_format_extending_custom Adding custom classes | |
980 | ||
981 | Finally, XRC allows adding completely new classes in addition to the ones | |
982 | listed in this document. A class for which wxXmlResourceHandler is implemented | |
983 | can be used as first-class object in XRC simply by passing class name as the | |
984 | value of @c class attribute: | |
985 | ||
986 | @code | |
987 | <object name="my_ctrl" class="MyWidget"> | |
988 | <my_prop>foo</my_prop> | |
989 | ...etc., whatever MyWidget handler accepts... | |
990 | </object> | |
991 | @endcode | |
992 | ||
993 | The only requirements on the class are that | |
994 | -# the class must derive from wxObject | |
995 | -# it must support wxWidget's pseudo-RTTI mechanism | |
996 | ||
997 | Child elements of @c <object> are handled by the custom handler and there are | |
998 | no limitations on them imposed by XRC format. | |
999 | ||
1000 | This is the only mechanism that works for toplevel objects -- custom controls | |
1001 | are accessible using type-unsafe wxXmlResource::LoadObject() method. | |
1002 | ||
1003 | ||
1004 | ||
1005 | @section xrc_format_packed Packed XRC files | |
1006 | ||
1007 | In addition to plain XRC files, wxXmlResource supports (if wxFileSystem support | |
1008 | is compiled in) compressed XRC resources. Compressed resources have either | |
1009 | .zip or .xrs extension and are simply ZIP files that contain arbitrary | |
1010 | number of XRC files and their dependencies (bitmaps, icons etc.). | |
1011 | ||
1012 | ||
1013 | ||
1014 | @section xrc_format_oldversions Older format versions | |
1015 | ||
1016 | This section describes differences in older revisions of XRC format (i.e. | |
1017 | files with older values of @c version attribute of @c <resource>). | |
1018 | ||
1019 | ||
1020 | @subsection xrc_format_pre_v2530 Versions before 2.5.3.0 | |
1021 | ||
1022 | Version 2.5.3.0 introduced C-like handling of "\\" in text. In older versions, | |
1023 | "\n", "\t" and "\r" escape sequences were replaced with respective characters | |
1024 | in the same matter it's done in C, but "\\" was left intact instead of being | |
1025 | replaced with single "\", as one would expect. Starting with 2.5.3.0, all of | |
1026 | them are handled in C-like manner. | |
1027 | ||
1028 | ||
1029 | @subsection xrc_format_pre_v2301 Versions before 2.3.0.1 | |
1030 | ||
1031 | Prior to version 2.3.0.1, "$" was used for accelerators instead of "_" | |
1032 | or "&". For example, | |
1033 | @code | |
1034 | <label>$File</label> | |
1035 | @endcode | |
1036 | was used in place of current version's | |
1037 | @code | |
1038 | <label>_File</label> | |
1039 | @endcode | |
1040 | (or "&File"). | |
1041 | ||
1042 | */ |