]>
git.saurik.com Git - wxWidgets.git/blob - docs/doxygen/overviews/xrc_format.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: XRC format specification
4 // Author: Vaclav Slavik
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
11 @page xrc_format XRC file format
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
33 This document describes the format of XRC resource files, as used by
37 @section xrc_format_overview Overview
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
45 XRC file contains definitions for one or more @em objects -- typically
46 windows. The objects may themselves contain child objects.
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).
54 Child objects are not directly accessible via wxXmlResource, they can only
55 be accessed using XRCCTRL().
58 @section xrc_format_root Root element: <resource>
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".
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.
71 At the time of writing, the latest version is @c "2.5.3.0".
73 Note that even though @c version attribute is optional, it should always be
74 specified to take advantage of the latest capabilities:
78 <resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.5.3.0">
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.
91 @section xrc_format_objects Defining objects
93 @subsection xrc_format_object <object>
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.
99 The @c class attribute must always be present, it tells XRC what wxWidgets
100 object should be created and by which wxXmlResourceHandler.
102 @c name is the identifier used to identify the object. This name serves three
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.
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).
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.
123 @c <object> element may -- and almost always do -- have children elements.
124 These come in two varieties:
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.
140 <object class="wxDialog" name="example_dialog">
142 <title>Non-Derived Dialog Example</title>
143 <centered>1</centered>
144 <!-- child objects: -->
145 <object class="wxBoxSizer">
146 <orient>wxVERTICAL</orient>
155 @subsection xrc_format_object_ref <object_ref>
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.
164 For example, the following code:
166 <object class="wxDialog" name="my_dlg">
169 <object_ref name="my_dlg_alias" ref="my_dlg"/>
173 <object class="wxDialog" name="my_dlg">
176 <object class="wxDialog" name="my_dlg_alias">
177 ... <!-- same as in my_dlg -->
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:
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.
197 For example, "my_dlg" in this snippet:
199 <object class="wxDialog" name="template">
200 <title>Dummy dialog</title>
203 <object_ref ref="template" name="my_dlg">
204 <title>My dialog</title>
205 <centered>1</centered>
210 <object_ref ref="template" name="my_dlg">
211 <title>My dialog</title>
213 <centered>1</centered>
218 @section xrc_format_datatypes Data types
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
226 @subsection xrc_format_type_bool Boolean
228 Boolean values are expressed using either "1" literal (true) or "0" (false).
231 @subsection xrc_format_type_float Floating-point value
233 Floating point values use POSIX (C locale) formatting -- decimal separator
234 is "." regardless of the locale.
237 @subsection xrc_format_type_colour Colour
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:
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
252 <fg>rgb(255,0,0)</fg>
253 <fg>wxSYS_COLOUR_HIGHLIGHT</fg>
257 @subsection xrc_format_type_size Size
259 Sizes and positions have the form of string with two comma-separated integer
260 components, with optional "d" suffix. Semi-formally:
262 size := x "," y ["d"]
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).
268 When the "d" suffix is used, integer values are interpreted as
269 @ref wxWindow::ConvertDialogToPixels() "dialog units" in the parent window.
278 @subsection xrc_format_type_pos Position
280 Same as @ref xrc_format_type_size.
283 @subsection xrc_format_type_dimension Dimension
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.
290 @subsection xrc_format_type_text Text
292 String properties use several escape sequences that are translated according to
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{ "\\", "\" }
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":
308 <!-- this is not translated: -->
309 <label translate="0">_Unix</label>
310 <!-- but this is: -->
311 <help>Use Unix-style newlines</help>
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.
318 @see @ref xrc_format_pre_v2530, @ref xrc_format_pre_v2301
321 @subsection xrc_format_type_text_notrans Non-translatable text
323 Like @ref xrc_format_type_text, but the text is never translated and
324 @c translate attribute cannot be used.
327 @subsection xrc_format_type_bitmap Bitmap
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:
333 <object class="tool" name="wxID_NEW">
334 <tooltip>New</tooltip>
335 <bitmap>new.png</bitmap>
338 The value is interpreted as path relative to the location of XRC file where the
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.
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.
352 Examples of stock bitmaps usage:
354 <bitmap stock_id="fixed-width"/> <!-- custom app-specific art -->
355 <bitmap stock_id="wxART_FILE_OPEN"/> <!-- standard art->
358 Specifying the bitmap directly and using @c stock_id are mutually exclusive.
361 @subsection xrc_format_type_style Style
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).
368 The flags that are allowed for a given property are context-dependent.
372 <style>wxCAPTION|wxSYSTEM_MENU | wxRESIZE_BORDER</style>
373 <exstyle>wxDIALOG_EX_CONTEXTHELP</exstyle>
377 @subsection xrc_format_type_font Font
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.
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":
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"
400 @row3col{underlined, @ref xrc_format_type_bool,
401 Whether the font should be underlined (default: 0).}
403 Comma-separated list of face names; the first one available is used
404 (default: unspecified).}
406 Charset of the font, unused in Unicode build), as string
407 (default: unspecified).}
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.}
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
422 <!-- fixed font: Arial if available, fall back to Helvetica -->
423 <face>arial,helvetica</face>
428 <!-- enlarged, enboldened standard font: -->
429 <sysfont>wxSYS_DEFAULT_GUI_FONT</sysfont>
430 <weight>bold</weight>
431 <relativesize>1.5</relativesize>
436 @section xrc_format_windows Controls and windows
438 This section describes support wxWindow-derived classes in XRC format.
440 @subsection xrc_format_std_props Standard properties
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.
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()
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
477 All of these properties are optional.
480 @subsection xrc_format_controls Supported controls
482 @subsubsection xrc_wxanimationctrl wxAnimationCtrl
485 @subsubsection xrc_wxbitmapbutton wxBitmapButton
488 @subsubsection xrc_wxbitmapcombobox wxBitmapComboBox
491 @subsubsection xrc_wxbutton wxButton
494 @subsubsection xrc_wxcalendarctrl wxCalendarCtrl
497 @subsubsection xrc_wxcheckbox wxCheckBox
500 @subsubsection xrc_wxchecklistbox wxCheckListBox
503 @subsubsection xrc_wxchoice wxChoice
506 @subsubsection xrc_wxchoicebook wxChoicebook
509 @subsubsection xrc_wxcollapsiblepane wxCollapsiblePane
512 @subsubsection xrc_wxcolourpickerctrl wxColourPickerCtrl
515 @subsubsection xrc_wxcombobox wxComboBox
518 @subsubsection xrc_wxdatepickerctrl wxDatePickerCtrl
521 @subsubsection xrc_wxdialog wxDialog
524 @subsubsection xrc_wxdirpickerctrl wxDirPickerCtrl
527 @subsubsection xrc_wxfilepickerctrl wxFilePickerCtrl
530 @subsubsection xrc_wxfontpickerctrl wxFontPickerCtrl
533 @subsubsection xrc_wxfrane wxFrame
536 @subsubsection xrc_wxgauge wxGauge
539 @subsubsection xrc_wxgenericdirctrl wxGenericDirCtrl
542 @subsubsection xrc_wxgrid wxGrid
545 @subsubsection xrc_wxhtmlwindow wxHtmlWindow
548 @subsubsection xrc_wxhyperlinkctrl wxHyperlinkCtrl
551 @subsubsection xrc_wxlistbox wxListBox
554 @subsubsection xrc_wxlistbook wxListbook
557 @subsubsection xrc_wxlistctrl wxListCtrl
560 @subsubsection xrc_wxmdiparentframe wxMDIParentFrame
563 @subsubsection xrc_wxmdichildframe wxMDIChildFrame
566 @subsubsection xrc_wxmenu wxMenu
569 @subsubsection xrc_wxmenubar wxMenuBar
572 @subsubsection xrc_wxnotebook wxNotebook
575 @subsubsection xrc_wxownerdrawncombobox wxOwnerDrawnComboBox
578 @subsubsection xrc_wxpanel wxPanel
581 @subsubsection xrc_wxpropertysheetdialog wxPropertySheetDialog
584 @subsubsection xrc_wxradiobutton wxRadioButton
587 @subsubsection xrc_wxradiobox wxRadioBox
590 @subsubsection xrc_wxrichtextctrl wxRichTextCtrl
593 @subsubsection xrc_wxscrollbar wxScrollBar
596 @subsubsection xrc_wxscrolledwindow wxScrolledWindow
599 @subsubsection xrc_wxsimplehtmllistbox wxSimpleHtmlListBox
602 @subsubsection xrc_wxslider wxSliderq
605 @subsubsection xrc_wxspinctrl wxSpinCtrl
608 @subsubsection xrc_wxsplitterwindow wxSplitterWindow
611 @subsubsection xrc_wxsearchctrl wxSearchCtrl
614 @subsubsection xrc_wxstatusbar wxStatusBar
617 @subsubsection xrc_wxstaticbitmap wxStaticBitmap
620 @subsubsection xrc_wxstaticbox wxStaticBox
623 @subsubsection xrc_wxstaticline wxStaticLine
626 @subsubsection xrc_wxstatictext wxStaticText
629 @subsubsection xrc_wxtextctrl wxTextCtrl
632 @subsubsection xrc_wxtogglebuttton wxToggleButton
635 @subsubsection xrc_wxtoolbar wxToolBar
638 @subsubsection xrc_wxtreectrl wxTreeCtrl
641 @subsubsection xrc_wxtreebook wxTreebook
644 @subsubsection xrc_wxwizard wxWizard
648 @section xrc_format_sizers Sizers
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().
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.
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.
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.
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:
675 @hdr3col{property, type, description}
676 @row3col{size, @ref xrc_format_type_size, Size of the empty space (required).}
679 Both @c sizeritem and @c spacer objects can have any of the following
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)
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). }
702 Example of sizers XRC 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">
713 <growablecols>0</growablecols>
714 <growablerows>0</growablerows>
715 <object class="sizeritem">
716 <flag>wxALIGN_CENTRE|wxALL</flag>
718 <object class="wxButton" name="my_button">
719 <label>My Button</label>
722 <object class="sizeritem">
723 <flag>wxALIGN_CENTRE|wxALL</flag>
725 <object class="wxBoxSizer">
726 <orient>wxHORIZONTAL</orient>
727 <object class="sizeritem">
728 <flag>wxALIGN_CENTRE|wxALL</flag>
730 <object class="wxCheckBox" name="my_checkbox">
731 <label>Enable this text control:</label>
734 <object class="sizeritem">
735 <flag>wxALIGN_CENTRE|wxALL</flag>
737 <object class="wxTextCtrl" name="my_textctrl">
749 The sizer classes that can be used are listed below, together with their
750 class-specific properties. All classes support the following properties:
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).}
759 @subsection xrc_format_wxboxsizer wxBoxSizer
762 @hdr3col{property, type, description}
763 @row3col{orient, @ref xrc_format_type_style,
764 Sizer orientation, "wxHORIZONTAL" or "wxVERTICAL" (default: wxHORIZONTAL).}
767 @subsection xrc_format_wxstaticsboxizer wxStaticBoxSizer
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).}
777 @subsection xrc_format_wxgridsizer wxGridSizer
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).}
787 @subsection xrc_format_wxflexgridsizer wxFlexGridSizer
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
798 @row3col{growablecols, comma-separated integers list,
799 Comma-separated list of indexes of columns that are growable
803 @subsection xrc_format_wxgridbagsizer wxGridBagSizer
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
812 @row3col{growablecols, comma-separated integers list,
813 Comma-separated list of indexes of columns that are growable
817 @subsection xrc_format_wxwrapsizer wxWrapSizer
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).}
826 @subsection xrc_format_wxstddialogbuttonsizer wxStdDialogButtonSizer
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
836 <object class="wxStdDialogButtonSizer">
837 <object class="button">
838 <object class="wxButton" name="wxID_OK">
842 <object class="button">
843 <object class="wxButton" name="wxID_CANCEL">
844 <label>Cancel</label>
852 @section xrc_format_other_objects Other objects
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.
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.
862 @subsection xrc_format_bitmap wxBitmap
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
870 For example, instead of:
872 <bitmap>mybmp.png</bitmap>
873 <bitmap stock_id="wxART_NEW"/>
875 toplevel wxBitmap resources would look like:
877 <object class="wxBitmap" name="my_bitmap">mybmp.png</object>
878 <object class="wxBitmap" name="my_new_bitmap" stock_id="wxART_NEW"/>
882 @subsection xrc_format_icon wxIcon
884 wxIcon resources are identical to @ref xrc_format_bitmap "wxBitmap ones",
885 except that the class is @c wxIcon.
888 @section xrc_format_platform Platform specific content
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.
896 Possible elemental values are:
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 }
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>
914 @section xrc_format_extending Extending XRC format
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.
920 @subsection xrc_format_extending_subclass Subclassing
922 The simplest way to add custom controls is to set the @c subclass attribute
923 of @c <object> element:
926 <object name="my_value" class="wxTextCtrl" subclass="MyTextCtrl">
927 <style>wxTE_MULTILINE</style>
928 ...etc., setup wxTextCtrl as usual...
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.
941 The subclass must satisfy a number of requirements:
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.
954 @subsection xrc_format_extending_unknown <object class="unknown">
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:
961 <object class="unknown" name="my_placeholder"/>
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.
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".
975 @note @c unknown class cannot be combined with @c subclass attribute,
976 they are mutually exclusive.
979 @subsection xrc_format_extending_custom Adding custom classes
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:
987 <object name="my_ctrl" class="MyWidget">
988 <my_prop>foo</my_prop>
989 ...etc., whatever MyWidget handler accepts...
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
997 Child elements of @c <object> are handled by the custom handler and there are
998 no limitations on them imposed by XRC format.
1000 This is the only mechanism that works for toplevel objects -- custom controls
1001 are accessible using type-unsafe wxXmlResource::LoadObject() method.
1005 @section xrc_format_packed Packed XRC files
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.).
1014 @section xrc_format_oldversions Older format versions
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>).
1020 @subsection xrc_format_pre_v2530 Versions before 2.5.3.0
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.
1029 @subsection xrc_format_pre_v2301 Versions before 2.3.0.1
1031 Prior to version 2.3.0.1, "$" was used for accelerators instead of "_"
1032 or "&". For example,
1034 <label>$File</label>
1036 was used in place of current version's
1038 <label>_File</label>