]>
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 NOTE: to make doxygen happy about <custom-tags> we're forced to
12 escape all < and > symbols which appear inside a doxygen comment
18 @page xrc_format XRC file format
21 - @ref xrc_format_overview
22 - @ref xrc_format_root
23 - @ref xrc_format_objects
24 - @ref xrc_format_object
25 - @ref xrc_format_object_ref
26 - @ref xrc_format_datatypes
27 - @ref xrc_format_windows
28 - @ref xrc_format_std_props
29 - @ref xrc_format_controls
30 - @ref xrc_format_sizers
31 - @ref xrc_format_other_objects
32 - @ref xrc_format_platform
33 - @ref xrc_format_extending
34 - @ref xrc_format_extending_subclass
35 - @ref xrc_format_extending_unknown
36 - @ref xrc_format_extending_custom
37 - @ref xrc_format_packed
38 - @ref xrc_format_oldversions
40 This document describes the format of XRC resource files, as used by
47 @section xrc_format_overview Overview
49 XRC file is a XML file with all of its elements in the
50 @c http://www.wxwidgets.org/wxxrc namespace. For backward compatibility,
51 @c http://www.wxwindows.org/wxxrc namespace is accepted as well (and treated
52 as identical to @c http://www.wxwidgets.org/wxxrc), but it shouldn't be used
55 XRC file contains definitions for one or more @em objects -- typically
56 windows. The objects may themselves contain child objects.
58 Objects defined at the top level, under the
59 @ref xrc_format_root "root element", can be accessed using
60 wxXmlResource::LoadDialog() and other LoadXXX methods. They must have
61 @c name attribute that is used as LoadXXX's argument (see
62 @ref xrc_format_object for details).
64 Child objects are not directly accessible via wxXmlResource, they can only
65 be accessed using XRCCTRL().
68 @section xrc_format_root Root element: \<resource\>
70 The root element is always @c \<resource\>. It has one optional attribute, @c
71 version. If set, it specifies version of the file. In absence of @c version
72 attribute, the default is @c "0.0.0.0".
74 The version consists of four integers separated by periods. The first three
75 components are major, minor and release number of the wxWidgets release when
76 the change was introduced, the last one is revision number and is 0 for the
77 first incompatible change in given wxWidgets release, 1 for the second and so
78 on. The version changes only if there was an incompatible change introduced;
79 merely adding new kind of objects does not constitute incompatible change.
81 At the time of writing, the latest version is @c "2.5.3.0".
83 Note that even though @c version attribute is optional, it should always be
84 specified to take advantage of the latest capabilities:
88 <resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.5.3.0">
93 @c \<resource\> may have arbitrary number of
94 @ref xrc_format_objects "object elements" as its children; they are referred
95 to as @em toplevel objects in the rest of this document. Unlike objects defined
96 deeper in the hierarchy, toplevel objects @em must have their @c name attribute
97 set and it must be set to a value unique among root's children.
101 @section xrc_format_objects Defining objects
103 @subsection xrc_format_object \<object\>
105 The @c \<object\> element represents a single object (typically a GUI element)
106 and it usually maps directly to a wxWidgets class instance. It has one
107 mandatory attribute, @c class, and optional @c name and @c subclass attributes.
109 The @c class attribute must always be present, it tells XRC what wxWidgets
110 object should be created and by which wxXmlResourceHandler.
112 @c name is the identifier used to identify the object. This name serves three
115 -# It is used by wxXmlResource's various LoadXXX() methods to find the
116 resource by name passed as argument.
117 -# wxWindow's name (see wxWindow::GetName()) is set to it.
118 -# Numeric ID of a window or menu item is derived from the name.
119 If the value represents an integer (in decimal notation), it is used for
120 the numeric ID unmodified. If it is one of the wxID_XXX literals defined
121 by wxWidgets (see @ref page_stockitems), its respective value is used.
122 Otherwise, the name is transformed into dynamically generated ID. See
123 wxXmlResource::GetXRCID() for more information.
125 Name attributes must be unique at the top level (where the name is used to
126 load resources) and should be unique among all controls within the same
127 toplevel window (wxDialog, wxFrame).
129 The @c subclass attribute optional name of class whose constructor will be
130 called instead of the constructor for "class".
131 See @ref xrc_format_extending_subclass for more details.
133 @c \<object\> element may -- and almost always do -- have children elements.
134 These come in two varieties:
136 -# Object's properties. A @em property is a value describing part of object's
137 behaviour, for example the "label" property on wxButton defines its label.
138 In the most common form, property is a single element with text content
139 ("<label>Cancel</label>"), but they may use nested subelements too (e.g.
140 @ref xrc_format_type_font "font property"). A property can only be
141 listed once in an object's definition.
142 -# Child objects. Window childs, sizers, sizer items or notebook pages
143 are all examples of child objects. They are represented using nested
144 @c \<object\> elements and are can be repeated more than once. The specifics
145 of which object classes are allowed as children are class-specific and
146 are documented below in @ref xrc_format_controls.
150 <object class="wxDialog" name="example_dialog">
152 <title>Non-Derived Dialog Example</title>
153 <centered>1</centered>
154 <!-- child objects: -->
155 <object class="wxBoxSizer">
156 <orient>wxVERTICAL</orient>
165 @subsection xrc_format_object_ref <object_ref>
167 Anywhere an @c \<object\> element can be used, @c \<object_ref\> may be used
168 instead. @c \<object_ref\> is a @em reference to another named (i.e. with the
169 @c name attribute) @c \<object\> element. It has one mandatory attribute,
170 @c ref, with value containing the name of a named @c \<object\> element. When an
171 @c \<object_ref\> is encountered, a copy of the referenced @c \<object\> element
172 is made in place of @c \<object_ref\> occurrence and processed as usual.
174 For example, the following code:
176 <object class="wxDialog" name="my_dlg">
179 <object_ref name="my_dlg_alias" ref="my_dlg"/>
183 <object class="wxDialog" name="my_dlg">
186 <object class="wxDialog" name="my_dlg_alias">
187 ... <!-- same as in my_dlg -->
191 Additionally, it is possible to override some parts of the referenced object
192 in the @c \<object_ref\> pointing to it. This is useful for putting repetitive
193 parts of XRC definitions into a template that can be reused and customized in
194 several places. The two parts are merged as follows:
196 -# The referred object is used as the initial content.
197 -# All attributes set on @c \<object_ref\> are added to it.
198 -# All child elements of @c \<object_ref\> are scanned. If an element with
199 the same name (and, if specified, the @c name attribute too) is found
200 in the referred object, they are recursively merged.
201 -# Child elements in @c \<object_ref\> that do not have a match in the referred
202 object are appended to the list of children of the resulting element by
203 default. Optionally, they may have @c insert_at attribute with two possible
204 values, "begin" or "end". When set to "begin", the element is prepended to
205 the list of children instead of appended.
207 For example, "my_dlg" in this snippet:
209 <object class="wxDialog" name="template">
210 <title>Dummy dialog</title>
213 <object_ref ref="template" name="my_dlg">
214 <title>My dialog</title>
215 <centered>1</centered>
220 <object_ref ref="template" name="my_dlg">
221 <title>My dialog</title>
223 <centered>1</centered>
228 @section xrc_format_datatypes Data types
230 There are several property data types that are frequently reused by different
231 properties. Rather than describing their format in the documentation of
232 every property, we list commonly used types in this section and document
236 @subsection xrc_format_type_bool Boolean
238 Boolean values are expressed using either "1" literal (true) or "0" (false).
241 @subsection xrc_format_type_float Floating-point value
243 Floating point values use POSIX (C locale) formatting -- decimal separator
244 is "." regardless of the locale.
247 @subsection xrc_format_type_colour Colour
249 Colour specification can be either any string colour representation accepted
250 by wxColour::Set() or any wxSYS_COLOUR_XXX symbolic name accepted by
251 wxSystemSettings::GetColour(). In particular, the following forms are supported:
253 @li named colours from wxColourDatabase
254 @li HTML-like "#rrggbb" syntax (but not "#rgb")
255 @li CSS-style "rgb(r,g,b)" and "rgba(r,g,b,a)"
256 @li wxSYS_COLOUR_XXX symbolic names
262 <fg>rgb(255,0,0)</fg>
263 <fg>wxSYS_COLOUR_HIGHLIGHT</fg>
267 @subsection xrc_format_type_size Size
269 Sizes and positions have the form of string with two comma-separated integer
270 components, with optional "d" suffix. Semi-formally:
272 size := x "," y ["d"]
274 where x and y are integers. Either of the components (or both) may be "-1" to
275 signify default value. As a shortcut, empty string is equivalent to "-1,-1"
276 (= wxDefaultSize or wxDefaultPosition).
278 When the "d" suffix is used, integer values are interpreted as
279 @ref wxWindow::ConvertDialogToPixels() "dialog units" in the parent window.
288 @subsection xrc_format_type_pos Position
290 Same as @ref xrc_format_type_size.
293 @subsection xrc_format_type_dimension Dimension
295 Similarly to @ref xrc_format_type_size "sizes", dimensions are expressed
296 as integers with optional "d" suffix. When "d" suffix is used, the integer
297 preceding it is interpreted as dialog units in the parent window.
300 @subsection xrc_format_type_text Text
302 String properties use several escape sequences that are translated according to
305 @itemdef{ "_", "&" (used for accelerators in wxWidgets) }
306 @itemdef{ "__", "_" }
307 @itemdef{ "\n", line break }
308 @itemdef{ "\r", carriage return }
309 @itemdef{ "\t", tab }
310 @itemdef{ "\\", "\" }
313 By default, the text is translated using wxLocale::GetTranslation() before
314 it is used. This can be disabled either globally by not passing
315 wxXRC_USE_LOCALE to wxXmlResource constructor, or by setting the @c translate
316 attribute on the property node to "0":
318 <!-- this is not translated: -->
319 <label translate="0">_Unix</label>
320 <!-- but this is: -->
321 <help>Use Unix-style newlines</help>
324 @note Even though the "_" character is used instead of "&" for accelerators,
325 it is still possible to use "&". The latter has to be encoded as "&",
326 though, so using "_" is more convenient.
328 @see @ref xrc_format_pre_v2530, @ref xrc_format_pre_v2301
331 @subsection xrc_format_type_text_notrans Non-translatable text
333 Like @ref xrc_format_type_text, but the text is never translated and
334 @c translate attribute cannot be used.
337 @subsection xrc_format_type_bitmap Bitmap
339 Bitmap properties contain specification of a single bitmap or icon. In the most
340 basic form, their text value is simply a relative filename (or another
341 wxFileSystem URL) of the bitmap to use. For example:
343 <object class="tool" name="wxID_NEW">
344 <tooltip>New</tooltip>
345 <bitmap>new.png</bitmap>
348 The value is interpreted as path relative to the location of XRC file where the
351 Alternatively, it is possible to specify the bitmap using wxArtProvider IDs.
352 In this case, the property element has no textual value (filename) and instead
353 has the @c stock_id XML attribute that contains stock art ID as accepted by
354 wxArtProvider::GetBitmap(). This can be either custom value (if the app uses
355 app-specific art provider) or one of the predefined wxART_XXX constants.
357 Optionally, @c stock_client attribute may be specified too and contain one of
358 the predefined wxArtClient values. If it is not specified, the default client
359 ID most appropriate in the context where the bitmap is referenced will be used.
360 In most cases, specifying @c stock_client is not needed.
362 Examples of stock bitmaps usage:
364 <bitmap stock_id="fixed-width"/> <!-- custom app-specific art -->
365 <bitmap stock_id="wxART_FILE_OPEN"/> <!-- standard art->
368 Specifying the bitmap directly and using @c stock_id are mutually exclusive.
371 @subsection xrc_format_type_style Style
373 Style properties (such as window's style or sizer flags) use syntax similar to
374 C++: the style value is OR-combination of individual flags. Symbolic names
375 identical to those used in C++ code are used for the flags. Flags are separated
376 with "|" (whitespace is allowed but not required around it).
378 The flags that are allowed for a given property are context-dependent.
382 <style>wxCAPTION|wxSYSTEM_MENU | wxRESIZE_BORDER</style>
383 <exstyle>wxDIALOG_EX_CONTEXTHELP</exstyle>
387 @subsection xrc_format_type_font Font
389 XRC uses similar, but more flexible, abstract description of fonts to that
390 used by wxFont class. A font can be described either in terms of its elementary
391 properties, or it can be derived from one of system fonts.
393 The font property element is "composite" element: unlike majority of
394 properties, it doesn't have text value but contains several child elements
395 instead. These children are handled in the same way as object properties
396 and can be one of the following "sub-properties":
399 @hdr3col{property, type, description}
400 @row3col{size, unsigned integer,
401 Pixel size of the font (default: wxNORMAL_FONT's size or @c sysfont's
402 size if the @c sysfont property is used.}
403 @row3col{style, enum,
404 One of "normal", "italic" or "slant" (default: normal).}
405 @row3col{weight, enum,
406 One of "normal", "bold" or "light" (default: normal).}
407 @row3col{family, enum,
408 One of "roman", "script", "decorative", "swiss", "modern" or "teletype"
410 @row3col{underlined, @ref xrc_format_type_bool,
411 Whether the font should be underlined (default: 0).}
413 Comma-separated list of face names; the first one available is used
414 (default: unspecified).}
416 Charset of the font, unused in Unicode build), as string
417 (default: unspecified).}
419 Symbolic name of system standard font(one of wxSYS_*_FONT constants).}
420 @row3col{relativesize, float,
421 Float, font size relative to chosen system font's size; can only be
422 used when 'sysfont' is used and when 'size' is not used.}
425 All of them are optional, if they are missing, appropriate wxFont default is
426 used. If the @c sysfont property is used, then the defaults are taken from it
432 <!-- fixed font: Arial if available, fall back to Helvetica -->
433 <face>arial,helvetica</face>
438 <!-- enlarged, enboldened standard font: -->
439 <sysfont>wxSYS_DEFAULT_GUI_FONT</sysfont>
440 <weight>bold</weight>
441 <relativesize>1.5</relativesize>
446 @section xrc_format_windows Controls and windows
448 This section describes support wxWindow-derived classes in XRC format.
450 @subsection xrc_format_std_props Standard properties
452 The following properties are always (unless stated otherwise in
453 control-specific docs) available for @em windows objects. They are omitted
454 from properties lists below.
457 @hdr3col{property, type, description}
458 @row3col{position, @ref xrc_format_type_pos,
459 Initial position of the window (default: wxDefaultPosition).}
460 @row3col{size, @ref xrc_format_type_size,
461 Initial size of the window (default: wxDefaultSize).}
462 @row3col{style, @ref xrc_format_type_style,
463 Window style for this control. The allowed values depend on what
464 window is being created, consult respective class' constructor
465 documentation for details (default: window-dependent default, usually
466 wxFOO_DEFAULT_STYLE if defined for class wxFoo, 0 if not).}
467 @row3col{exstyle, @ref xrc_format_type_style,
468 Extra style for the window, if any. See wxWindow::SetExtraStyle()
470 @row3col{fg, @ref xrc_format_type_colour,
471 Foreground colour of the window (default: window's default).}
472 @row3col{bg, @ref xrc_format_type_colour,
473 Background colour of the window (default: window's default).}
474 @row3col{enabled, @ref xrc_format_type_bool,
475 If set to 0, the control is disabled (default: 1).}
476 @row3col{hidden, @ref xrc_format_type_bool,
477 If set to 1, the control is created hidden (default: 0).}
478 @row3col{tooltip, @ref xrc_format_type_text,
479 Tooltip to use for the control (default: not set).}
480 @row3col{font, @ref xrc_format_type_font,
481 Font to use for the control (default: window's default).}
482 @row3col{help, @ref xrc_format_type_text,
483 Context-sensitive help for the control, used by wxHelpProvider
487 All of these properties are optional.
490 @subsection xrc_format_controls Supported controls
492 @subsubsection xrc_wxanimationctrl wxAnimationCtrl
495 @subsubsection xrc_wxbitmapbutton wxBitmapButton
498 @subsubsection xrc_wxbitmapcombobox wxBitmapComboBox
501 @subsubsection xrc_wxbutton wxButton
504 @subsubsection xrc_wxcalendarctrl wxCalendarCtrl
507 @subsubsection xrc_wxcheckbox wxCheckBox
510 @subsubsection xrc_wxchecklistbox wxCheckListBox
513 @subsubsection xrc_wxchoice wxChoice
516 @subsubsection xrc_wxchoicebook wxChoicebook
519 @subsubsection xrc_wxcollapsiblepane wxCollapsiblePane
522 @subsubsection xrc_wxcolourpickerctrl wxColourPickerCtrl
525 @subsubsection xrc_wxcombobox wxComboBox
528 @subsubsection xrc_wxdatepickerctrl wxDatePickerCtrl
531 @subsubsection xrc_wxdialog wxDialog
534 @subsubsection xrc_wxdirpickerctrl wxDirPickerCtrl
537 @subsubsection xrc_wxfilepickerctrl wxFilePickerCtrl
540 @subsubsection xrc_wxfontpickerctrl wxFontPickerCtrl
543 @subsubsection xrc_wxfrane wxFrame
546 @subsubsection xrc_wxgauge wxGauge
549 @subsubsection xrc_wxgenericdirctrl wxGenericDirCtrl
552 @subsubsection xrc_wxgrid wxGrid
555 @subsubsection xrc_wxhtmlwindow wxHtmlWindow
558 @subsubsection xrc_wxhyperlinkctrl wxHyperlinkCtrl
561 @subsubsection xrc_wxlistbox wxListBox
564 @subsubsection xrc_wxlistbook wxListbook
567 @subsubsection xrc_wxlistctrl wxListCtrl
570 @subsubsection xrc_wxmdiparentframe wxMDIParentFrame
573 @subsubsection xrc_wxmdichildframe wxMDIChildFrame
576 @subsubsection xrc_wxmenu wxMenu
579 @subsubsection xrc_wxmenubar wxMenuBar
582 @subsubsection xrc_wxnotebook wxNotebook
585 @subsubsection xrc_wxownerdrawncombobox wxOwnerDrawnComboBox
588 @subsubsection xrc_wxpanel wxPanel
591 @subsubsection xrc_wxpropertysheetdialog wxPropertySheetDialog
594 @subsubsection xrc_wxradiobutton wxRadioButton
597 @subsubsection xrc_wxradiobox wxRadioBox
600 @subsubsection xrc_wxrichtextctrl wxRichTextCtrl
603 @subsubsection xrc_wxscrollbar wxScrollBar
606 @subsubsection xrc_wxscrolledwindow wxScrolledWindow
609 @subsubsection xrc_wxsimplehtmllistbox wxSimpleHtmlListBox
612 @subsubsection xrc_wxslider wxSliderq
615 @subsubsection xrc_wxspinctrl wxSpinCtrl
618 @subsubsection xrc_wxsplitterwindow wxSplitterWindow
621 @subsubsection xrc_wxsearchctrl wxSearchCtrl
624 @subsubsection xrc_wxstatusbar wxStatusBar
627 @subsubsection xrc_wxstaticbitmap wxStaticBitmap
630 @subsubsection xrc_wxstaticbox wxStaticBox
633 @subsubsection xrc_wxstaticline wxStaticLine
636 @subsubsection xrc_wxstatictext wxStaticText
639 @subsubsection xrc_wxtextctrl wxTextCtrl
642 @subsubsection xrc_wxtogglebuttton wxToggleButton
645 @subsubsection xrc_wxtoolbar wxToolBar
648 @subsubsection xrc_wxtreectrl wxTreeCtrl
651 @subsubsection xrc_wxtreebook wxTreebook
654 @subsubsection xrc_wxwizard wxWizard
658 @section xrc_format_sizers Sizers
660 Sizers are handled slightly differently in XRC resources than they are in
661 wxWindow hierarchy. wxWindow's sizers hierarchy is parallel to the wxWindow
662 children hieararchy: child windows are children of their parent window and
663 the sizer (or sizers) form separate hierarchy attached to the window with
664 wxWindow::SetSizer().
666 In XRC, the two hierarchies are merged together: sizers are children of other
667 sizers or windows and they can contain child window objects.
669 If a sizer is child of a window object in the resource, it must be the only
670 child and it will be attached to the parent with wxWindow::SetSizer().
671 Additionally, if the window doesn't have its size explicitly set,
672 wxSizer::Fit() is used to resize the window. If the parent window is
673 toplevel window, wxSizer::SetSizeHints() is called to set its hints.
675 A sizer object can have one or more child objects of one of two pseudo-classes:
676 @c sizeritem or @c spacer (see @ref xrc_format_wxstddialogbuttonsizer for
677 an exception). The former specifies an element (another sizer or a window)
678 to include in the sizer, the latter adds empty space to the sizer.
680 @c sizeritem objects have exactly one child object: either another sizer
681 object, or a window object. @c spacer objects don't have any children, but
682 they have one property:
685 @hdr3col{property, type, description}
686 @row3col{size, @ref xrc_format_type_size, Size of the empty space (required).}
689 Both @c sizeritem and @c spacer objects can have any of the following
693 @hdr3col{property, type, description}
694 @row3col{option, integer,
695 The "option" value for sizers. Used by wxBoxSizer to set proportion of
696 the item in the growable direction (default: 0).}
697 @row3col{flag, @ref xrc_format_type_style,
698 wxSizerItem flags (default: 0).}
699 @row3col{border, @ref xrc_format_type_dimension,
700 Size of the border around the item (directions are specified in flags)
702 @row3col{minsize, @ref xrc_format_type_size,
703 Minimal size of this item (default: no min size).}
704 @row3col{ratio, @ref xrc_format_type_size,
705 Item ratio, see wxSizer::SetRatio() (default: no ratio).}
706 @row3col{cellpos, @ref xrc_format_type_pos,
707 (wxGridBagSizer only) Position, see wxGBSizerItem::SetPos() (required). }
708 @row3col{cellspan, @ref xrc_format_type_size,
709 (wxGridBagSizer only) Span, see wxGBSizerItem::SetSpan() (required). }
712 Example of sizers XRC code:
714 <object class="wxDialog" name="derived_dialog">
715 <title>Derived Dialog Example</title>
716 <centered>1</centered>
717 <!-- this sizer is set to be this dialog's sizer: -->
718 <object class="wxFlexGridSizer">
723 <growablecols>0</growablecols>
724 <growablerows>0</growablerows>
725 <object class="sizeritem">
726 <flag>wxALIGN_CENTRE|wxALL</flag>
728 <object class="wxButton" name="my_button">
729 <label>My Button</label>
732 <object class="sizeritem">
733 <flag>wxALIGN_CENTRE|wxALL</flag>
735 <object class="wxBoxSizer">
736 <orient>wxHORIZONTAL</orient>
737 <object class="sizeritem">
738 <flag>wxALIGN_CENTRE|wxALL</flag>
740 <object class="wxCheckBox" name="my_checkbox">
741 <label>Enable this text control:</label>
744 <object class="sizeritem">
745 <flag>wxALIGN_CENTRE|wxALL</flag>
747 <object class="wxTextCtrl" name="my_textctrl">
759 The sizer classes that can be used are listed below, together with their
760 class-specific properties. All classes support the following properties:
763 @hdr3col{property, type, description}
764 @row3col{minsize, @ref xrc_format_type_size,
765 Minimal size that this sizer will have, see wxSizer::SetMinSize()
766 (default: no min size).}
769 @subsection xrc_format_wxboxsizer wxBoxSizer
772 @hdr3col{property, type, description}
773 @row3col{orient, @ref xrc_format_type_style,
774 Sizer orientation, "wxHORIZONTAL" or "wxVERTICAL" (default: wxHORIZONTAL).}
777 @subsection xrc_format_wxstaticsboxizer wxStaticBoxSizer
780 @hdr3col{property, type, description}
781 @row3col{orient, @ref xrc_format_type_style,
782 Sizer orientation, "wxHORIZONTAL" or "wxVERTICAL" (default: wxHORIZONTAL).}
783 @row3col{label, @ref xrc_format_type_text,
784 Label to be used for the static box around the sizer (required).}
787 @subsection xrc_format_wxgridsizer wxGridSizer
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).}
797 @subsection xrc_format_wxflexgridsizer wxFlexGridSizer
800 @hdr3col{property, type, description}
801 @row3col{rows, integer, Number of rows in the grid (required).}
802 @row3col{cols, integer, Number of columns in the grid (required).}
803 @row3col{vgap, integer, Vertical gap between children (default: 0).}
804 @row3col{hgap, integer, Horizontal gap between children (default: 0).}
805 @row3col{growablerows, comma-separated integers list,
806 Comma-separated list of indexes of rows that are growable
808 @row3col{growablecols, comma-separated integers list,
809 Comma-separated list of indexes of columns that are growable
813 @subsection xrc_format_wxgridbagsizer wxGridBagSizer
816 @hdr3col{property, type, description}
817 @row3col{vgap, integer, Vertical gap between children (default: 0).}
818 @row3col{hgap, integer, Horizontal gap between children (default: 0).}
819 @row3col{growablerows, comma-separated integers list,
820 Comma-separated list of indexes of rows that are growable
822 @row3col{growablecols, comma-separated integers list,
823 Comma-separated list of indexes of columns that are growable
827 @subsection xrc_format_wxwrapsizer wxWrapSizer
830 @hdr3col{property, type, description}
831 @row3col{orient, @ref xrc_format_type_style,
832 Sizer orientation, "wxHORIZONTAL" or "wxVERTICAL" (required).}
833 @row3col{flag, @ref xrc_format_type_style, wxWrapSizer flags (default: 0).}
836 @subsection xrc_format_wxstddialogbuttonsizer wxStdDialogButtonSizer
838 Unlike other sizers, wxStdDialogButtonSizer doesn't have neither @c sizeritem
839 nor @c spacer children. Instead, it has one or more children of the
840 @c button pseudo-class. @c button objects have no properties and they must
841 always have exactly one child of the @c wxButton class or a class derived from
846 <object class="wxStdDialogButtonSizer">
847 <object class="button">
848 <object class="wxButton" name="wxID_OK">
852 <object class="button">
853 <object class="wxButton" name="wxID_CANCEL">
854 <label>Cancel</label>
862 @section xrc_format_other_objects Other objects
864 In addition to describing UI elements, XRC files can contain non-windows
865 objects such as bitmaps or icons. This is a concession to Windows developers
866 used to storing them in Win32 resources.
868 Note that unlike Win32 resources, bitmaps included in XRC files are @em not
869 embedded in the XRC file itself. XRC file only contains a reference to another
870 file with bitmap data.
872 @subsection xrc_format_bitmap wxBitmap
874 Bitmaps are stored in @c \<object\> element with class set to @c wxBitmap. Such
875 bitmaps can then be loaded using wxXmlResource::LoadBitmap(). The content of
876 the element is exactly same as in the case of
877 @ref xrc_format_type_bitmap "bitmap properties", except that toplevel
878 @c \<object\> is used.
880 For example, instead of:
882 <bitmap>mybmp.png</bitmap>
883 <bitmap stock_id="wxART_NEW"/>
885 toplevel wxBitmap resources would look like:
887 <object class="wxBitmap" name="my_bitmap">mybmp.png</object>
888 <object class="wxBitmap" name="my_new_bitmap" stock_id="wxART_NEW"/>
892 @subsection xrc_format_icon wxIcon
894 wxIcon resources are identical to @ref xrc_format_bitmap "wxBitmap ones",
895 except that the class is @c wxIcon.
898 @section xrc_format_platform Platform specific content
900 It is possible to conditionally process parts of XRC files on some platforms
901 only and ignore them on other platforms. @em Any element in XRC file, be it
902 toplevel or arbitrarily nested one, can have the @c platform attribute. When
903 used, @c platform contains |-separated list of platforms that this element
904 should be processed on. It is filtered out and ignored on any other platforms.
906 Possible elemental values are:
908 @itemdef{ @c win, Windows }
909 @itemdef{ @c mac, Mac OS X (or Mac Classic in wxWidgets version supporting it }
910 @itemdef{ @c unix, Any Unix platform @em except OS X }
911 @itemdef{ @c os2, OS/2 }
916 <label platform="win">Windows</label>
917 <label platform="unix">Unix</label>
918 <label platform="mac">Mac OS X</label>
919 <help platform="mac|unix">Not a Windows machine</help>
924 @section xrc_format_extending Extending XRC format
926 The XRC format is designed to be extensible and allows specifying and loading
927 custom controls. The three available mechanisms are described in the rest of
928 this section in the order of increasing complexity.
930 @subsection xrc_format_extending_subclass Subclassing
932 The simplest way to add custom controls is to set the @c subclass attribute
933 of @c \<object\> element:
936 <object name="my_value" class="wxTextCtrl" subclass="MyTextCtrl">
937 <style>wxTE_MULTILINE</style>
938 ...etc., setup wxTextCtrl as usual...
942 In that case, wxXmlResource will create an instance of the specified subclass
943 (@c MyTextCtrl in the example above) instead of the class (@c wxTextCtrl above)
944 when loading the resource. However, the rest of the object's loading (calling
945 its Create() method, setting its properties, loading any children etc.)
946 will proceed in @em exactly the same way as it would without @c subclass
947 attribute. In other words, this approach is only sufficient when the custom
948 class is just a small modification (e.g. overridden methods or customized
949 events handling) of an already supported classes.
951 The subclass must satisfy a number of requirements:
953 -# It must be derived from the class specified in @c class attribute.
954 -# It must be visible in wxWidget's pseudo-RTTI mechanism, i.e. there must be
955 a DECLARE_DYNAMIC_CLASS() entry for it.
956 -# It must support two-phase creation. In particular, this means that it has
957 to have default constructor.
958 -# It cannot provide custom Create() method and must be constructible using
959 base @c class' Create() method (this is because XRC will call Create() of
960 @c class, not @c subclass). In other words, @em creation of the control
961 must not be customized.
964 @subsection xrc_format_extending_unknown <object class="unknown">
966 A more flexible solution is to put a @em placeholder in the XRC file and
967 replace it with custom control after the resource is loaded. This is done by
968 using the @c unknown pseudo-class:
971 <object class="unknown" name="my_placeholder"/>
974 The placeholder is inserted as dummy wxPanel that will hold custom control in
975 it. At runtime, after the resource is loaded and a window created from it
976 (using e.g. wxXmlResource::LoadDialog()), use code must call
977 wxXmlResource::AttachUnknownControl() to insert the desired control into
978 placeholder container.
980 This method makes it possible to insert controls that are not known to XRC at
981 all, but it's also impossible to configure the control in XRC description in
982 any way. The only properties that can be specified are
983 the @ref xrc_format_std_props "standard window properties".
985 @note @c unknown class cannot be combined with @c subclass attribute,
986 they are mutually exclusive.
989 @subsection xrc_format_extending_custom Adding custom classes
991 Finally, XRC allows adding completely new classes in addition to the ones
992 listed in this document. A class for which wxXmlResourceHandler is implemented
993 can be used as first-class object in XRC simply by passing class name as the
994 value of @c class attribute:
997 <object name="my_ctrl" class="MyWidget">
998 <my_prop>foo</my_prop>
999 ...etc., whatever MyWidget handler accepts...
1003 The only requirements on the class are that
1004 -# the class must derive from wxObject
1005 -# it must support wxWidget's pseudo-RTTI mechanism
1007 Child elements of @c \<object\> are handled by the custom handler and there are
1008 no limitations on them imposed by XRC format.
1010 This is the only mechanism that works for toplevel objects -- custom controls
1011 are accessible using type-unsafe wxXmlResource::LoadObject() method.
1015 @section xrc_format_packed Packed XRC files
1017 In addition to plain XRC files, wxXmlResource supports (if wxFileSystem support
1018 is compiled in) compressed XRC resources. Compressed resources have either
1019 .zip or .xrs extension and are simply ZIP files that contain arbitrary
1020 number of XRC files and their dependencies (bitmaps, icons etc.).
1024 @section xrc_format_oldversions Older format versions
1026 This section describes differences in older revisions of XRC format (i.e.
1027 files with older values of @c version attribute of @c \<resource\>).
1030 @subsection xrc_format_pre_v2530 Versions before 2.5.3.0
1032 Version 2.5.3.0 introduced C-like handling of "\\" in text. In older versions,
1033 "\n", "\t" and "\r" escape sequences were replaced with respective characters
1034 in the same matter it's done in C, but "\\" was left intact instead of being
1035 replaced with single "\", as one would expect. Starting with 2.5.3.0, all of
1036 them are handled in C-like manner.
1039 @subsection xrc_format_pre_v2301 Versions before 2.3.0.1
1041 Prior to version 2.3.0.1, "$" was used for accelerators instead of "_"
1042 or "&". For example,
1044 <label>$File</label>
1046 was used in place of current version's
1048 <label>_File</label>