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