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