Difference between revisions of "Using XML Resources with XRC"
(finished cleaning up) |
m (Text replacement - "\<syntaxhighlight title="([^"]+)"\>" to "<syntaxhighlight lang="cpp" title="$1">") |
||
(11 intermediate revisions by 6 users not shown) | |||
Line 11: | Line 11: | ||
This document deals with the third solution in a C/C++ application context. | This document deals with the third solution in a C/C++ application context. | ||
− | This resource system in not a part of the standard wxWidgets library, but is delivered with the standard source packages in the contrib directory as a library. | + | This resource system in not a part of the standard wxWidgets library, but is delivered with the standard source packages in the contrib directory as a library. To build the "wxrc" library refer to the [https://docs.wxwidgets.org/stable/ wxWidgets documentation]. |
− | + | XML resources are readable and processed at run-time. The goal of this article is to explain how XRC works, and show how to write XRC files by hand. There are a number of [[Tools|RAD tools]] that simplify this process by allowing you to build windows and dialogs graphically, and automatically generate XRC files for you, it is still helpful to know how to edit XRC directly, since not all components are supported by all tools. | |
− | |||
− | The | ||
<div style="background: #fcc; margin: 1em 3em; padding: 0.2em 0.5em;"> | <div style="background: #fcc; margin: 1em 3em; padding: 0.2em 0.5em;"> | ||
Line 39: | Line 37: | ||
A simple way to initialize the resource system is to call <tt>InitAllHandlers</tt> method of <tt>wxXmlResource</tt> class so you don't have to worry about all the handlers you could add. | A simple way to initialize the resource system is to call <tt>InitAllHandlers</tt> method of <tt>wxXmlResource</tt> class so you don't have to worry about all the handlers you could add. | ||
− | < | + | <syntaxhighlight lang="cpp" title="wxXmlResource Initialization Example"> |
wxXmlResource::Get()->InitAllHandlers(); | wxXmlResource::Get()->InitAllHandlers(); | ||
bRet = wxXmlResource::Get()->Load( Path ); | bRet = wxXmlResource::Get()->Load( Path ); | ||
Line 47: | Line 45: | ||
return false; | return false; | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
The individual resource handlers available (depending on compilation options in <tt>setup.h</tt>) are: | The individual resource handlers available (depending on compilation options in <tt>setup.h</tt>) are: | ||
Line 143: | Line 141: | ||
'''XRC''' files are standard XML files. The format should be the following : | '''XRC''' files are standard XML files. The format should be the following : | ||
− | < | + | <syntaxhighlight lang="xml"> |
<?xml version="1.0"?> | <?xml version="1.0"?> | ||
<resource version="2.3.0.1"> | <resource version="2.3.0.1"> | ||
Line 151: | Line 149: | ||
</object> | </object> | ||
</resource> | </resource> | ||
− | </ | + | </syntaxhighlight> |
+ | |||
+ | See the [https://docs.wxwidgets.org/trunk/xrc_format.html XRC format specification] for detailed description. | ||
== Internationalization (i18n) == | == Internationalization (i18n) == | ||
Line 163: | Line 163: | ||
== XRC Object Descriptions == | == XRC Object Descriptions == | ||
− | This part describes each resource type available in '''XRC''' files. | + | This part describes each resource type available in '''XRC''' files. This information is also provided in the [https://docs.wxwidgets.org/trunk/xrc_format.html XRC format specification], which is the authoritative resource. |
+ | |||
+ | |||
+ | All "object" nodes have an optional "name" parameter used as an ID for that object, which can be retieved with the <tt>XRCID()</tt> macro in code. | ||
=== wxWindow Elements === | === wxWindow Elements === | ||
Line 170: | Line 173: | ||
; exstyle | ; exstyle | ||
− | : window styles, see the [ | + | : window styles, see the [https://docs.wxwidgets.org/stable/classwx_window.html wxWindow documentation] for possible styles (separate multiple styles with the "|" (pipe) character) |
; bg | ; bg | ||
: background window color: RGB color in the #RRGGBB format (HTML like) | : background window color: RGB color in the #RRGGBB format (HTML like) | ||
Line 209: | Line 212: | ||
; flag | ; flag | ||
− | : See the [ | + | : See the [https://docs.wxwidgets.org/stable/classwx_sizer.html#wxsizer_flags wxSizer documentation] for a list of possible values. |
; minsize | ; minsize | ||
: pair: minimum size of the sizer (200,200 for example). | : pair: minimum size of the sizer (200,200 for example). | ||
Line 224: | Line 227: | ||
: wxBoxSizer orientation: wxVERTICAL, wxHORIZONTAL | : wxBoxSizer orientation: wxVERTICAL, wxHORIZONTAL | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxBoxSizer"> | <object class="wxBoxSizer"> | ||
<orient>wxHORIZONTAL</orient> | <orient>wxHORIZONTAL</orient> | ||
Line 230: | Line 233: | ||
<object class="sizeritem">Right control</object> | <object class="sizeritem">Right control</object> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
==== wxStaticBoxSizer ==== | ==== wxStaticBoxSizer ==== | ||
Line 254: | Line 257: | ||
: horizontal space between to elements. | : horizontal space between to elements. | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxGridSizer"> | <object class="wxGridSizer"> | ||
<rows>2</rows> | <rows>2</rows> | ||
Line 263: | Line 266: | ||
<object class="sizeritem">control in 1,1 (row,col)</object> | <object class="sizeritem">control in 1,1 (row,col)</object> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
==== wxFlexGridSizer ==== | ==== wxFlexGridSizer ==== | ||
Line 299: | Line 302: | ||
: This is the disabled bitmap specifier. Contains a bitmap tag | : This is the disabled bitmap specifier. Contains a bitmap tag | ||
− | < | + | <syntaxhighlight lang="xml"> |
<?xml version="1.0"?> | <?xml version="1.0"?> | ||
<resource version="2.4.0"> | <resource version="2.4.0"> | ||
Line 313: | Line 316: | ||
<style>wxBU_LEFT</style> | <style>wxBU_LEFT</style> | ||
<bitmap>bt_buttonbitmap.xpm</bitmap> | <bitmap>bt_buttonbitmap.xpm</bitmap> | ||
− | <selected | + | <selected>bt_buttonbitmaps.xpm</selected> |
− | <focus | + | <focus>bt_buttonbitmapf.xpm</focus> |
− | <disabled | + | <disabled>bt_buttonbitmapd.xpm</disabled> |
</object> | </object> | ||
</object> | </object> | ||
Line 328: | Line 331: | ||
</object> | </object> | ||
</resource> | </resource> | ||
− | </ | + | </syntaxhighlight> |
=== wxButton === | === wxButton === | ||
Line 341: | Line 344: | ||
: bool value (0/1): 1 if this button is the default button of the dialog or panel. | : bool value (0/1): 1 if this button is the default button of the dialog or panel. | ||
− | < | + | <syntaxhighlight lang="xml"> |
<resource version="2.4.0"> | <resource version="2.4.0"> | ||
<object class="wxFrame" name="main_frame"> | <object class="wxFrame" name="main_frame"> | ||
Line 366: | Line 369: | ||
</object> | </object> | ||
</resource> | </resource> | ||
− | </ | + | </syntaxhighlight> |
=== wxCalendarCtrl === | === wxCalendarCtrl === | ||
Line 375: | Line 378: | ||
: Calendar styles defining how the calendar control should work: wxCAL_SUNDAY_FIRST, wxCAL_MONDAY_FIRST, wxCAL_SHOW_HOLIDAYS, wxCAL_NO_YEAR_CHANGE, wxCAL_NO_MONTH_CHANGE | : Calendar styles defining how the calendar control should work: wxCAL_SUNDAY_FIRST, wxCAL_MONDAY_FIRST, wxCAL_SHOW_HOLIDAYS, wxCAL_NO_YEAR_CHANGE, wxCAL_NO_MONTH_CHANGE | ||
− | < | + | <syntaxhighlight lang="xml"> |
<resource version="2.4.0"> | <resource version="2.4.0"> | ||
<object class="wxFrame" name="main_frame"> | <object class="wxFrame" name="main_frame"> | ||
Line 399: | Line 402: | ||
</object> | </object> | ||
</resource> | </resource> | ||
− | </ | + | </syntaxhighlight> |
=== wxCheckBox === | === wxCheckBox === | ||
Line 410: | Line 413: | ||
: bool value (1/0): 1 if the check box is checked on creation | : bool value (1/0): 1 if the check box is checked on creation | ||
− | < | + | <syntaxhighlight lang="xml"> |
<resource version="2.4.0"> | <resource version="2.4.0"> | ||
<object class="wxFrame" name="main_frame"> | <object class="wxFrame" name="main_frame"> | ||
Line 435: | Line 438: | ||
</object> | </object> | ||
</resource> | </resource> | ||
− | </ | + | </syntaxhighlight> |
− | === | + | === wxCheckListBox === |
Inherits <tt>wxWindow</tt> properties | Inherits <tt>wxWindow</tt> properties | ||
Line 446: | Line 449: | ||
:: bool value (0/1) : 1 if the element is checked | :: bool value (0/1) : 1 if the element is checked | ||
− | < | + | <syntaxhighlight lang="xml"> |
− | <object class=" | + | <object class="wxCheckListBox" name="checklistbox_id"> |
<size>200,100</size> | <size>200,100</size> | ||
<content> | <content> | ||
Line 457: | Line 460: | ||
</content> | </content> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxChoice === | === wxChoice === | ||
Line 470: | Line 473: | ||
:: bool value (0/1) : 1 if the element is checked | :: bool value (0/1) : 1 if the element is checked | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxChoice" name="choice_id"> | <object class="wxChoice" name="choice_id"> | ||
<size>200,100</size> | <size>200,100</size> | ||
Line 482: | Line 485: | ||
</content> | </content> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxComboBox === | === wxComboBox === | ||
Line 499: | Line 502: | ||
:: bool value (0/1) : 1 if the element is checked | :: bool value (0/1) : 1 if the element is checked | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxComboBox" name="combo_id"> | <object class="wxComboBox" name="combo_id"> | ||
<size>200,100</size> | <size>200,100</size> | ||
Line 512: | Line 515: | ||
</content> | </content> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxDialog === | === wxDialog === | ||
Line 521: | Line 524: | ||
: Title of the dialog as text | : Title of the dialog as text | ||
; style | ; style | ||
− | : see the [ | + | : see the [https://docs.wxwidgets.org/stable/classwx_dialog.html wxDialog documentation] for a list of styles |
; centered | ; centered | ||
: bool value(0/1) : 1 if the dialog should be centered on it's parent screen. | : bool value(0/1) : 1 if the dialog should be centered on it's parent screen. | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxDialog" name="test_dialog"> | <object class="wxDialog" name="test_dialog"> | ||
<title>My Dialog</title> | <title>My Dialog</title> | ||
Line 545: | Line 548: | ||
</object> | </object> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxFrame === | === wxFrame === | ||
Line 554: | Line 557: | ||
: Title of the frame as text | : Title of the frame as text | ||
; style | ; style | ||
− | : see the [ | + | : see the [https://docs.wxwidgets.org/stable/classwx_frame.html wxFrame documentation] for a list of styles. |
; centered | ; centered | ||
: bool value(0/1) : 1 if the frame should be centered on it's parent screen. | : bool value(0/1) : 1 if the frame should be centered on it's parent screen. | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxFrame" name="main_frame"> | <object class="wxFrame" name="main_frame"> | ||
<title>Testing the XRC resource system</title> | <title>Testing the XRC resource system</title> | ||
Line 579: | Line 582: | ||
</object> | </object> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxGauge === | === wxGauge === | ||
Line 596: | Line 599: | ||
: integer value: width of the bezel face. | : integer value: width of the bezel face. | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxGauge" name="gauge_id"> | <object class="wxGauge" name="gauge_id"> | ||
<style>wxGA_HORIZONTAL|wxGA_PROGRESSBAR|wxGA_SMOOTH</style> | <style>wxGA_HORIZONTAL|wxGA_PROGRESSBAR|wxGA_SMOOTH</style> | ||
Line 604: | Line 607: | ||
<value>33</value> | <value>33</value> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxGenericDirCtrl === | === wxGenericDirCtrl === | ||
Line 625: | Line 628: | ||
: long value: index of the default filter. | : long value: index of the default filter. | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxGenericDirCtrl" name="dirctrl_id"> | <object class="wxGenericDirCtrl" name="dirctrl_id"> | ||
<size>200,200</size> | <size>200,200</size> | ||
Line 635: | Line 638: | ||
<filter>*.zip</filter> | <filter>*.zip</filter> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxHtmlWindow === | === wxHtmlWindow === | ||
Line 650: | Line 653: | ||
: text: path to an HTML file to display. | : text: path to an HTML file to display. | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxHtmlWindow" name="htmlid_id"> | <object class="wxHtmlWindow" name="htmlid_id"> | ||
<size>200,200</size> | <size>200,200</size> | ||
Line 656: | Line 659: | ||
<htmlcode><b>This is a simple text</b></htmlcode> | <htmlcode><b>This is a simple text</b></htmlcode> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxListBox === | === wxListBox === | ||
Line 669: | Line 672: | ||
: list of '''item''' tags describing the elements in the control. | : list of '''item''' tags describing the elements in the control. | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxListBox" name="listbox_id"> | <object class="wxListBox" name="listbox_id"> | ||
<selection>2</selection> | <selection>2</selection> | ||
Line 680: | Line 683: | ||
</content> | </content> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxListCtrl === | === wxListCtrl === | ||
Line 687: | Line 690: | ||
; style | ; style | ||
− | : List control style, see the [ | + | : List control style, see the [https://docs.wxwidgets.org/stable/classwx_list_ctrl.html wxListCtrl documentation] for a list of styles. |
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxListCtrl" name="listctrl_id"> | <object class="wxListCtrl" name="listctrl_id"> | ||
<style>wxLC_REPORT|wxLC_ICON</style> | <style>wxLC_REPORT|wxLC_ICON</style> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxMenuBar === | === wxMenuBar === | ||
Line 736: | Line 739: | ||
: Text: path to a bitmap to draw at the left of the item. | : Text: path to a bitmap to draw at the left of the item. | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxMenuBar" name="main_menu_bar"> | <object class="wxMenuBar" name="main_menu_bar"> | ||
<object class="wxMenu" name="file_menu"> | <object class="wxMenu" name="file_menu"> | ||
Line 771: | Line 774: | ||
</object> | </object> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxNotebook === | === wxNotebook === | ||
Line 778: | Line 781: | ||
; style | ; style | ||
− | : Notebook style: wxNB_FIXEDWIDTH, wxNB_LEFT, wxNB_RIGHT, wxNB_BOTTOM | + | : Notebook style: wxNB_FIXEDWIDTH, wxNB_MULTILINE, wxNB_NOPAGETHEME, wxBK_LEFT, wxBK_RIGHT, wxBK_BOTTOM and wxBK_TOP (wxNB_LEFT, wxNB_RIGHT, wxNB_BOTTOM and wxNB_TOP for 2.6 and below) |
; usenotebooksizer | ; usenotebooksizer | ||
: bool value(0/1): 1 if a notebook sizer is to be used to handle notebook pages. | : bool value(0/1): 1 if a notebook sizer is to be used to handle notebook pages. | ||
Line 791: | Line 794: | ||
: bool value(0/1): is this page the selected one. | : bool value(0/1): is this page the selected one. | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxNotebook" name="main_notebook"> | <object class="wxNotebook" name="main_notebook"> | ||
<object class="notebookpage" name="firstnotepage"> | <object class="notebookpage" name="firstnotepage"> | ||
Line 832: | Line 835: | ||
</object> | </object> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxPanel === | === wxPanel === | ||
Line 852: | Line 855: | ||
: bool value(0/1): 1 if the button is selected. | : bool value(0/1): 1 if the button is selected. | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxRadioButton" name="radiobutton_id"> | <object class="wxRadioButton" name="radiobutton_id"> | ||
<label>Radio button</label> | <label>Radio button</label> | ||
<value>1</value> | <value>1</value> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxRadioBox === | === wxRadioBox === | ||
Line 870: | Line 873: | ||
: list of '''item''' tags describing the elements in the control. | : list of '''item''' tags describing the elements in the control. | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxRadioBox" name="radiobox_id"> | <object class="wxRadioBox" name="radiobox_id"> | ||
<label>Radio box</label> | <label>Radio box</label> | ||
Line 884: | Line 887: | ||
</content> | </content> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxScrollBar === | === wxScrollBar === | ||
Line 901: | Line 904: | ||
: long: size of one scrolled page | : long: size of one scrolled page | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxScrollBar" name="scrollbar_id"> | <object class="wxScrollBar" name="scrollbar_id"> | ||
<size>-1,100</size> | <size>-1,100</size> | ||
Line 909: | Line 912: | ||
<style>wxSB_VERTICAL</style> | <style>wxSB_VERTICAL</style> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxScrolledWindow === | === wxScrolledWindow === | ||
Line 918: | Line 921: | ||
: Scrolled window style: wxHSCROLL, wxVSCROLL | : Scrolled window style: wxHSCROLL, wxVSCROLL | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxScrolledWindow" name="scrolledwindow_id"> | <object class="wxScrolledWindow" name="scrolledwindow_id"> | ||
<bg>#FFFFFF</bg> | <bg>#FFFFFF</bg> | ||
Line 924: | Line 927: | ||
<size>200,200</size> | <size>200,200</size> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxSlider === | === wxSlider === | ||
Line 931: | Line 934: | ||
; style | ; style | ||
− | : Slider style, see the [ | + | : Slider style, see the [https://docs.wxwidgets.org/stable/classwx_slider.html wxSlider documentation] for a list of styles. |
; value | ; value | ||
: long: current position of the slider | : long: current position of the slider | ||
Line 951: | Line 954: | ||
: long: sets minimum and maximum selection position | : long: sets minimum and maximum selection position | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxSlider" name="slider_id"> | <object class="wxSlider" name="slider_id"> | ||
<style>wxSL_HORIZONTAL|wxSL_AUTOTICKS</style> | <style>wxSL_HORIZONTAL|wxSL_AUTOTICKS</style> | ||
Line 960: | Line 963: | ||
<max>200</max> | <max>200</max> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxSpinButton === | === wxSpinButton === | ||
Line 975: | Line 978: | ||
: long: maximum value of the spin button | : long: maximum value of the spin button | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxSpinButton" name="spinbutton_id"> | <object class="wxSpinButton" name="spinbutton_id"> | ||
<style>wxSP_HORIZONTAL|wxSP_ARROW_KEYS</style> | <style>wxSP_HORIZONTAL|wxSP_ARROW_KEYS</style> | ||
Line 982: | Line 985: | ||
<max>200</max> | <max>200</max> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxSpinCtrl === | === wxSpinCtrl === | ||
Line 997: | Line 1,000: | ||
: long: maximum value of the spin control | : long: maximum value of the spin control | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxSpinCtrl" name="spincontrol_id"> | <object class="wxSpinCtrl" name="spincontrol_id"> | ||
<style>wxSP_HORIZONTAL|wxSP_ARROW_KEYS</style> | <style>wxSP_HORIZONTAL|wxSP_ARROW_KEYS</style> | ||
Line 1,004: | Line 1,007: | ||
<max>200</max> | <max>200</max> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxStaticBitmap === | === wxStaticBitmap === | ||
Line 1,013: | Line 1,016: | ||
: Text: Bitmap file name | : Text: Bitmap file name | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxStaticBitmap" name="bitmap_id"> | <object class="wxStaticBitmap" name="bitmap_id"> | ||
<bitmap>bt_buttonbitmap.xpm</bitmap> | <bitmap>bt_buttonbitmap.xpm</bitmap> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxStaticBox === | === wxStaticBox === | ||
Line 1,026: | Line 1,029: | ||
: Text: label of the static box | : Text: label of the static box | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxStaticBox" name="stbox_id"> | <object class="wxStaticBox" name="stbox_id"> | ||
<size>200,200</size> | <size>200,200</size> | ||
<label>Static box sample</label> | <label>Static box sample</label> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxStaticLine === | === wxStaticLine === | ||
Line 1,046: | Line 1,049: | ||
</div> | </div> | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxStaticLine" name="stline_id"> | <object class="wxStaticLine" name="stline_id"> | ||
<size>200,5</size> | <size>200,5</size> | ||
<style>wxLI_HORIZONTAL</style> | <style>wxLI_HORIZONTAL</style> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxStaticText === | === wxStaticText === | ||
Line 1,062: | Line 1,065: | ||
: Text: label of the static text | : Text: label of the static text | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxStaticText" name="sttext_id"> | <object class="wxStaticText" name="sttext_id"> | ||
<style>wxALIGN_CENTRE</style> | <style>wxALIGN_CENTRE</style> | ||
<label>Hello, World!!!</label> | <label>Hello, World!!!</label> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxTextCtrl === | === wxTextCtrl === | ||
Line 1,074: | Line 1,077: | ||
; style | ; style | ||
− | : Text control style, see the [ | + | : Text control style, see the [https://docs.wxwidgets.org/stable/classwx_text_ctrl.html wxTextCtrl documentation] for a list of styles. |
; value | ; value | ||
: Text: initial value of the text control | : Text: initial value of the text control | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxTextCtrl" name="textctrl_id"> | <object class="wxTextCtrl" name="textctrl_id"> | ||
<style>wxTE_MULTILINE</style> | <style>wxTE_MULTILINE</style> | ||
<value>Hello, World!!!</value> | <value>Hello, World!!!</value> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxToolBar === | === wxToolBar === | ||
Line 1,119: | Line 1,122: | ||
A <tt>separator</tt> tag can only appear inside a <tt>wxToolBar</tt> tag and has not properties and no attributes. | A <tt>separator</tt> tag can only appear inside a <tt>wxToolBar</tt> tag and has not properties and no attributes. | ||
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxToolBar" name="main_toolbar"> | <object class="wxToolBar" name="main_toolbar"> | ||
<bitmapsize>50,50</bitmapsize> | <bitmapsize>50,50</bitmapsize> | ||
Line 1,139: | Line 1,142: | ||
</object> | </object> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
=== wxTreeCtrl === | === wxTreeCtrl === | ||
Line 1,146: | Line 1,149: | ||
; style | ; style | ||
− | : Tree control style, see the [ | + | : Tree control style, see the [https://docs.wxwidgets.org/stable/classwx_tree_ctrl.html wxTreeCtrl documentation] for a list of styles. |
− | < | + | <syntaxhighlight lang="xml"> |
<object class="wxTreeCtrl" name="treectrl_id"> | <object class="wxTreeCtrl" name="treectrl_id"> | ||
<style>wxTR_EDIT_LABELS|wxTR_HAS_BUTTONS|wxTR_HAS_VARIABLE_ROW_HEIGHT</style> | <style>wxTR_EDIT_LABELS|wxTR_HAS_BUTTONS|wxTR_HAS_VARIABLE_ROW_HEIGHT</style> | ||
</object> | </object> | ||
− | </ | + | </syntaxhighlight> |
Latest revision as of 19:33, 19 October 2018
Introduction
Building a user interface with wxWidgets is quite easy, and three non exclusive solutions are available:
- you can directly handle graphical objects and layout in your code
- you can make use of the wxWidgets standard resource files (wxr)
- you can make use of XML resource files (XRC files)
This document deals with the third solution in a C/C++ application context.
This resource system in not a part of the standard wxWidgets library, but is delivered with the standard source packages in the contrib directory as a library. To build the "wxrc" library refer to the wxWidgets documentation.
XML resources are readable and processed at run-time. The goal of this article is to explain how XRC works, and show how to write XRC files by hand. There are a number of RAD tools that simplify this process by allowing you to build windows and dialogs graphically, and automatically generate XRC files for you, it is still helpful to know how to edit XRC directly, since not all components are supported by all tools.
Warning
This document is not a C/C++ tutorial for wxWidgets as other tutorials are available including the wxWidgets documentation and samples which is a good starting point.
Using wxXmlResource
The wxXmlResource is the only class you have to deal with in order to make use of XRC files in your C/C++ application. A typical use is the following
Initialization
wxXmlResource handles a reference to a unique resource handler (smart pointer), which must be initialized before you can use it. It is accessed in the following manner :
wxXmlResource::Get()->methodname
This initialization could be done in the OnInit method of your wxApp derived class.
Each resource type has its own handler, and if you intend to use it in your application you should add it to the wxXmlResource object.
A simple way to initialize the resource system is to call InitAllHandlers method of wxXmlResource class so you don't have to worry about all the handlers you could add.
wxXmlResource::Get()->InitAllHandlers();
bRet = wxXmlResource::Get()->Load( Path );
if( !bRet )
{
cout << "Could not load resource file" << Path << endl;
return false;
}
The individual resource handlers available (depending on compilation options in setup.h) are:
- wxBitmapXmlHandler
- wxIconXmlHandler
- wxMenuXmlHandler
- wxMenuBarXmlHandler
- wxDialogXmlHandler
- wxPanelXmlHandler
- wxSizerXmlHandler
- wxButtonXmlHandler
- wxBitmapButtonXmlHandler
- wxStaticTextXmlHandler
- wxStaticBitmapXmlHandler
- wxTreeCtrlXmlHandler
- wxCalendarCtrlXmlHandler
- wxListCtrlXmlHandler
- wxCheckListXmlHandler
- wxChoiceXmlHandler
- wxSliderXmlHandler
- wxGaugeXmlHandler
- wxCheckBoxXmlHandler
- wxHtmlWindowXmlHandler
- wxSpinButtonXmlHandler
- wxSpinCtrlXmlHandler
- wxScrollBarXmlHandler
- wxRadioBoxXmlHandler
- wxRadioButtonXmlHandler
- wxComboBoxXmlHandler
- wxNotebookXmlHandler
- wxTextCtrlXmlHandler
- wxListBoxXmlHandler
- wxToolBarXmlHandler
- wxStaticLineXmlHandler
- wxUnknownWidgetXmlHandler
- wxGenericDirCtrlXmlHandler
- wxFrameXmlHandler
- wxScrolledWindowXmlHandler
wxWidgets controls and windows that are not listed here are not handled in XRC files. But however you can write your own handler to handle them by deriving wxUnknownWidgetXmlHandler
Now that handlers are added to the resource handler you have to specify which XRC file(s) you want to load by calling the Load method. The parameter you pass to this method must be a valid path to the file you wand to load.
Creating UI Elements
There are 8 top level resource types that you can describe in a XRC file.
- Frames (LoadFrame method)
- Dialogs (LoadDialog method)
- Panels (LoadPanel method)
- MenuBars (LoadMenuBar method)
- Menus (LoadMenu method)
- Toolbars (LoadToolBar method)
- Bitmaps (LoadBitmap method)
- Icons (LoadIcon method)
Except for bitmaps and icons, the resource system handles all the resource types contained in the resource description, but you cannot directly load an wxTextCtrl for example.
LoadBitmap, LoadIcon, LoadMenu, LoadMenuBar, LoadToolBar methods return new created objects. The cannot be used to initialize existing object as LoadFrame, LoadDialog and LoadPanel do.
For example there are three ways to create a dialog :
1. Directly by using the following form wxDialog *Dlg;
Dlg = wxXmlResource::Get()->LoadDialog( FrameObjectPointer, "dialog_resource" ); Dlg->ShowModal();
2. Indirectly by using the following form wxDialog Dlg;
wxXmlResource::Get()->LoadDialog( &Dlg, FrameObjectPointer, "dialog_resource" ); Dlg.ShowModal();
where "dialog_resource" is the name of the resource in the XML file, or
MyDerivedDialog Dlg; wxXmlResource::Get()->LoadDialog( &Dlg, FrameObjectPointer, "dialog_resource" ); Dlg.ShowModal();
3. Indirectly in a derived class of wxDialog
MyDerivedDialog::MyDerivedDialog( wxWindow *p_Parent ) { wxXmlResource::Get()->LoadDialog( this, p_Parent, "dialog_resource" ); }
Important
Note that in the last example the wxDialog base class constructor is not called, and should not be.
XRC File Format
XRC files are standard XML files. The format should be the following :
<?xml version="1.0"?>
<resource version="2.3.0.1">
<object class="wxFrame" name="my_main_frame">
<size>200,300</size>
...
</object>
</resource>
See the XRC format specification for detailed description.
Internationalization (i18n)
The wxWidgets source distribution contains a project name wxrc in the contrib/utils directory. This utility is used to produce zipped XRC resource files, but can also extract strings for i18n:
wxrc.exe [/g] [-o] [outputfile] [resourcefile]
outputfile will contain strings in the wxWidgets classical i18n compatible form _("string") and which can be processed by xgettext.
XRC Object Descriptions
This part describes each resource type available in XRC files. This information is also provided in the XRC format specification, which is the authoritative resource.
All "object" nodes have an optional "name" parameter used as an ID for that object, which can be retieved with the XRCID() macro in code.
wxWindow Elements
Many of the elements (windows, controls) that are described in an XRC file are derived from the wxWindow class. The all have common properties available:
- exstyle
- window styles, see the wxWindow documentation for possible styles (separate multiple styles with the "|" (pipe) character)
- bg
- background window color: RGB color in the #RRGGBB format (HTML like)
- fg
- foreground window color: RGB color in the #RRGGBB format (HTML like)
- enabled
- is the window enabled? bool value (0/1)
- focused
- should this window have the focus? bool value (0/1)
- hidden
- should this window be hidden? bool value (0/1)
- tooltip
- free texttooltip text associated to the window (must have been enabled in setup.h)
- font
- font description
- size
- font size in points
- style
- font style: normal, italic, slant
- weight
- font weight: normal, bold, light
- family
- font family: decorative, modern, roman, script, swiss, teletype
- underlined
- should the font be underlined? bool value (0/1)
- encoding
- CHARSET in text formatfont encoding
- face
- font for this window: FACENAME in text formatfont face
Sizers
Sizers are a very important part of the XRC resources. Their goal is to let you lay out the controls you need in a panel, a window or a frame.
sizeritem
All sizer types contain one or more sizeritem. A sizeritem contains one object (control).
- flag
- See the wxSizer documentation for a list of possible values.
- minsize
- pair: minimum size of the sizer (200,200 for example).
- option
- long: used to tell the sizer item it has a certain "weight" in the proportions among all sizer items.
- border
- long: border size (for borders specified in "flag").
wxBoxSizer
The box sizer divides the layout into two components either horizontally or vertically. It contains one or more sizeritem tags.
- orient
- wxBoxSizer orientation: wxVERTICAL, wxHORIZONTAL
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">Left control</object>
<object class="sizeritem">Right control</object>
</object>
wxStaticBoxSizer
A static box sizer is a box sizer with a surrounding box and a label.
- orient
- wxBoxSizer orientation: wxVERTICAL, wxHORIZONTAL
- label
- Text: label of the static box.
wxGridSizer
A grid sizer divides the layout into rows and cols of identical sizes.
- rows
- Number of rows.
- cols
- Number of cols.
- vgap
- vertical space between to elements.
- hgap
- horizontal space between to elements.
<object class="wxGridSizer">
<rows>2</rows>
<cols>2</cols>
<object class="sizeritem">control in 0,0 (row,col)</object>
<object class="sizeritem">control in 0,1 (row,col)</object>
<object class="sizeritem">control in 1,0 (row,col)</object>
<object class="sizeritem">control in 1,1 (row,col)</object>
</object>
wxFlexGridSizer
A grid sizer divides the layout into rows and cols of identical sizes.
- rows
- Number of rows.
- cols
- Number of cols.
- vgap
- vertical space between to elements.
- hgap
- horizontal space between to elements.
- growablecols
- list: comma separated list of cols indexes that will grow with the container.
- growablerows
- list: comma separated list of rows indexes that will grow with the container.
wxBitmapButton
Inherits wxWindow properties.
- style
- button style: wxBU_AUTODRAW, wxBU_LEFT, wxBU_RIGHT, wxBU_TOP, wxBU_BOTTOM
- bitmap
- The bitmap path and filename
- default
- bool value (0/1) - 1 if this button is the default button of the dialog or panel.
- selected
- This is the selected bitmap specifier. Contains a bitmap tag
- focus
- This is the focused bitmap specifier. Contains a bitmap tag
- disabled
- This is the disabled bitmap specifier. Contains a bitmap tag
<?xml version="1.0"?>
<resource version="2.4.0">
<object class="wxFrame" name="main_frame">
<title>Testing the XRC resource system</title>
<object class="wxPanel" name="main_panel">
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<flag>wxALL|wxGROW</flag>
<option>1</option>
<object class="wxBitmapButton" name="bt_bitmapbutton">
<style>wxBU_LEFT</style>
<bitmap>bt_buttonbitmap.xpm</bitmap>
<selected>bt_buttonbitmaps.xpm</selected>
<focus>bt_buttonbitmapf.xpm</focus>
<disabled>bt_buttonbitmapd.xpm</disabled>
</object>
</object>
<object class="sizeritem">
<flag>wxALL</flag>
<object class="wxStaticText" name="st_description">
<label>wxBitmapButton test</label>
</object>
</object>
</object>
</object>
</object>
</resource>
wxButton
Inherits wxWindow properties
- style
- The button style: wxBU_LEFT, wxBU_RIGHT, wxBU_TOP, wxBU_BOTTOM
- label
- The label of the button
- default
- bool value (0/1): 1 if this button is the default button of the dialog or panel.
<resource version="2.4.0">
<object class="wxFrame" name="main_frame">
<title>Testing the XRC resource system</title>
<object class="wxPanel" name="main_panel">
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<flag>wxALL|wxGROW</flag>
<option>1</option>
<object class="wxButton" name="bt_button">
<style>wxBU_LEFT</style>
<label>Button label</label>
</object>
</object>
<object class="sizeritem">
<flag>wxALL</flag>
<object class="wxStaticText" name="st_description">
<label>wxButton test</label>
</object>
</object>
</object>
</object>
</object>
</resource>
wxCalendarCtrl
Inherits wxWindow properties
- style
- Calendar styles defining how the calendar control should work: wxCAL_SUNDAY_FIRST, wxCAL_MONDAY_FIRST, wxCAL_SHOW_HOLIDAYS, wxCAL_NO_YEAR_CHANGE, wxCAL_NO_MONTH_CHANGE
<resource version="2.4.0">
<object class="wxFrame" name="main_frame">
<title>Testing the XRC resource system</title>
<object class="wxPanel" name="main_panel">
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<flag>wxALL|wxGROW</flag>
<option>1</option>
<object class="wxCalendarCtrl" name="calendar">
<style>wxCAL_MONDAY_FIRST|wxCAL_SHOW_HOLIDAYS</style>
</object>
</object>
<object class="sizeritem">
<flag>wxALL</flag>
<object class="wxStaticText" name="st_description">
<label>wxCalendarCtrl test</label>
</object>
</object>
</object>
</object>
</object>
</resource>
wxCheckBox
Inherits wxWindow properties
- label
- Label of the check box
- checked
- bool value (1/0): 1 if the check box is checked on creation
<resource version="2.4.0">
<object class="wxFrame" name="main_frame">
<title>Testing the XRC resource system</title>
<object class="wxPanel" name="main_panel">
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<flag>wxALL|wxGROW</flag>
<object class="wxCheckBox" name="checkbox_id">
<size>200,50</size>
<label>CheckBoxItem</label>
<checked>1</checked>
</object>
</object>
<object class="sizeritem">
<flag>wxALL</flag>
<object class="wxStaticText" name="st_description">
<label>wxCheckBox test</label>
</object>
</object>
</object>
</object>
</object>
</resource>
wxCheckListBox
Inherits wxWindow properties
- content
- list of item tags describing the elements in the control, item tag attributes:
- checked
- bool value (0/1) : 1 if the element is checked
<object class="wxCheckListBox" name="checklistbox_id">
<size>200,100</size>
<content>
<item checked="1">Item value 1</item>
<item checked="0">Item value 2</item>
<item checked="1">Item value 3</item>
<item checked="0">Item value 4</item>
<item checked="1">Item value 5</item>
</content>
</object>
wxChoice
Inherits wxWindow properties
- selection
- integer value: index (0 based) of the selected entry
- content
- list of item tags describing the elements in the control, item tag attributes:
- checked
- bool value (0/1) : 1 if the element is checked
<object class="wxChoice" name="choice_id">
<size>200,100</size>
<selection>2</selection>
<content>
<item checked="1">Item value 1</item>
<item checked="0">Item value 2</item>
<item checked="1">Item value 3</item>
<item checked="0">Item value 4</item>
<item checked="1">Item value 5</item>
</content>
</object>
wxComboBox
Inherits wxWindow properties
- style
- combo style: wxCB_SIMPLE, wxCB_SORT, wxCB_READONLY, wxCB_DROPDOWN
- value
- initial value of the combo as text
- selection
- integer value: index ( 0 based ) of the selected entry
- content
- list of item tags describing the elements in the control, item tag attributes:
- checked
- bool value (0/1) : 1 if the element is checked
<object class="wxComboBox" name="combo_id">
<size>200,100</size>
<style>wxCB_DROPDOWN</style>
<selection>2</selection>
<content>
<item checked="1">Item value 1</item>
<item checked="0">Item value 2</item>
<item checked="1">Item value 3</item>
<item checked="0">Item value 4</item>
<item checked="1">Item value 5</item>
</content>
</object>
wxDialog
Inherits wxWindow properties. This is a top-level component, and it can have multiple sub elements (sizers, controls).
- title
- Title of the dialog as text
- style
- see the wxDialog documentation for a list of styles
- centered
- bool value(0/1) : 1 if the dialog should be centered on it's parent screen.
<object class="wxDialog" name="test_dialog">
<title>My Dialog</title>
<style>wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX</style>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<flag>wxALL</flag>
<object class="wxTextCtrl" name="textctrl_id">
<value>Hello World !!!!</value>
</object>
</object>
<object class="sizeritem">
<flag>wxALL</flag>
<object class="wxStaticText" name="st_description">
<label>wxComboBox test</label>
</object>
</object>
</object>
</object>
wxFrame
Inherits wxWindow properties. This is a top-level component, and it can have multiple sub elements (sizers, controls ).
- title
- Title of the frame as text
- style
- see the wxFrame documentation for a list of styles.
- centered
- bool value(0/1) : 1 if the frame should be centered on it's parent screen.
<object class="wxFrame" name="main_frame">
<title>Testing the XRC resource system</title>
<object class="wxPanel" name="main_panel">
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<flag>wxALL</flag>
<object class="wxTextCtrl" name="textctrl_id">
<value>Hello World !!!!</value>
</object>
</object>
<object class="sizeritem">
<flag>wxALL</flag>
<object class="wxStaticText" name="st_description">
<label>wxComboBox test</label>
</object>
</object>
</object>
</object>
</object>
wxGauge
Inherits wxWindow properties
- style
- Gauge style: wxGA_HORIZONTAL, wxGA_VERTICAL, wxGA_PROGRESSBAR, wxGA_SMOOTH
- range
- integer value: maximum value for the gauge.
- value
- integer value: initial value for the gauge position.
- shadow
- integer value: width of the shadow.
- bezel
- integer value: width of the bezel face.
<object class="wxGauge" name="gauge_id">
<style>wxGA_HORIZONTAL|wxGA_PROGRESSBAR|wxGA_SMOOTH</style>
<shadow>20</shadow>
<bezel>40</bezel>
<range>100</range>
<value>33</value>
</object>
wxGenericDirCtrl
Inherits wxWindow properties
Tip
Default size of this control seems to be 0,0. So you should always put a size tag.
- style
- Control style: wxDIRCTRL_DIR_ONLY, wxDIRCTRL_3D_INTERNAL, wxDIRCTRL_SELECT_FIRST, wxDIRCTRL_SHOW_FILTERS
- defaultfolder
- Text value: path of the default directory.
- filter
- Text value: expression of the files to be displayed (wild card enabled).
- defaultfilter
- long value: index of the default filter.
<object class="wxGenericDirCtrl" name="dirctrl_id">
<size>200,200</size>
<style>wxDIRCTRL_SHOW_FILTERS</style>
<defaultfolder>e:/temp</defaultfolder>
<defaultfilter>1</defaultfilter>
<filter>*.txt</filter>
<filter>*.jpg</filter>
<filter>*.zip</filter>
</object>
wxHtmlWindow
Inherits wxWindow properties
- style
- HTML window style: wxHW_SCROLLBAR_NEVER, wxHW_SCROLLBAR_AUTO
- borders
- integer value: border size to leave between the left and top border of the window, and the HTML display.
- htmlcode
- text value: the HTML the control should display.
- url
- text: path to an HTML file to display.
<object class="wxHtmlWindow" name="htmlid_id">
<size>200,200</size>
<borders>20d</borders>
<htmlcode><b>This is a simple text</b></htmlcode>
</object>
wxListBox
Inherits wxWindow properties
- style
- List box style: wxLB_SINGLE, wxLB_MULTIPLE, wxLB_EXTENDED, wxLB_HSCROLL, wxLB_ALWAYS_SB, wxLB_NEEDED_SB, wxLB_SORT
- selection
- integer value: index (0 based) of the selected entry
- content
- list of item tags describing the elements in the control.
<object class="wxListBox" name="listbox_id">
<selection>2</selection>
<content>
<item>Item value 1</item>
<item>Item value 2</item>
<item>Item value 3</item>
<item>Item value 4</item>
<item>Item value 5</item>
</content>
</object>
wxListCtrl
Inherits wxWindow properties
- style
- List control style, see the wxListCtrl documentation for a list of styles.
<object class="wxListCtrl" name="listctrl_id">
<style>wxLC_REPORT|wxLC_ICON</style>
</object>
wxMenuBar
Does not inherit wxWindow properties. A wxMenuBar can contain one or more wxMenu sub-elements.
- style
- Menu bar style: wxMB_DOCKABLE
wxMenu
Does not inherit wxWindow properties. A menu contains one or more wxMenuItem tags.
- style
- Menu style: wxMENU_TEAROFF
- label
- Text: label of the menu.
- help
- Text: displayed help string.
wxMenuItem
Does not inherit wxWindow properties.
- style
- Menu style: wxMENU_TEAROFF
- label
- Text: label of the menu.
- accel
- Text: accelerator associated to this item ( Alt-X for example ).
- help
- Text: displayed help string.
- radio
- bool value(0/1): 1 if this item is a radio menu item.
- checkable
- bool value(0/1): 1 if this item is a check menu item.
- enabled
- bool value(0/1): 1 if this item is initially enabled.
- checked
- bool value(0/1): 1 if this (check) item is initially checked.
- bitmap
- Text: path to a bitmap to draw at the left of the item.
<object class="wxMenuBar" name="main_menu_bar">
<object class="wxMenu" name="file_menu">
<label>File</label>
<help>File menu</help>
<style>wxMENU_TEAROFF</style>
<object class="wxMenuItem" name="open_menu_item">
<label>Open</label>
<help>Opens a file</help>
<accel>Alt-O</accel>
</object>
<object class="wxMenuItem" name="radio_menu_item">
<label>Radio</label>
<radio>1</radio>
</object>
<object class="wxMenuItem" name="check_menu_item">
<label>Check</label>
<checkable>1</checkable>
<enabled>1</enabled>
<checked>1</checked>
</object>
<object class="break" />
<object class="wxMenuItem" name="close_menu_item">
<label>Close</label>
<help>Closes a file</help>
<bitmap>bt_buttonbitmap.xpm</bitmap>
</object>
<object class="separator" />
<object class="wxMenuItem" name="exit_menu_item">
<label>Exit</label>
<help>Exits the program</help>
<accel>Alt-X</accel>
</object>
</object>
</object>
wxNotebook
Does not Inherit wxWindow properties. A wxNotebook tag contains one or more notebookpage tags.
- style
- Notebook style: wxNB_FIXEDWIDTH, wxNB_MULTILINE, wxNB_NOPAGETHEME, wxBK_LEFT, wxBK_RIGHT, wxBK_BOTTOM and wxBK_TOP (wxNB_LEFT, wxNB_RIGHT, wxNB_BOTTOM and wxNB_TOP for 2.6 and below)
- usenotebooksizer
- bool value(0/1): 1 if a notebook sizer is to be used to handle notebook pages.
notebookpage
A notebookpage can only appear inside a wxNotebook. It contains one or more objects like panels and controls.
- label
- Text: label of the page.
- selected
- bool value(0/1): is this page the selected one.
<object class="wxNotebook" name="main_notebook">
<object class="notebookpage" name="firstnotepage">
<label>First</label>
<selected>1</selected>
<object class="wxPanel" name="main_panel">
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<flag>wxALL</flag>
<object class="wxTextCtrl" name="textctrl_id">
<value>Hello World !!!</value>
</object>
</object>
<object class="sizeritem">
<flag>wxALL</flag>
<object class="wxStaticText" name="st_description">
<label>wxListCtrl test</label>
</object>
</object>
</object>
</object>
</object>
<object class="notebookpage" name="secondnotepage">
<label>Second</label>
<object class="wxPanel" name="secondpanel">
<object class="wxFlexGridSizer">
<cols>1</cols>
<rows>0</rows>
<growablerows>0</growablerows>
<growablecols>1</growablecols>
<object class="sizeritem">
<flag>wxALL</flag>
<object class="wxTextCtrl" name="st_second_text">
<value>Static text</value>
</object>
</object>
</object>
</object>
</object>
</object>
wxPanel
Inherits wxWindow properties. A panel contains zero or more sizers and controls.
- style
- Panel style: wxNO_3D, wxTAB_TRAVERSAL, wxWS_EX_VALIDATE_RECURSIVELY, wxCLIP_CHILDREN
wxRadioButton
Inherits wxWindow properties.
- style
- Radio button style: wxRB_GROUP
- label
- Text: label of the button.
- value
- bool value(0/1): 1 if the button is selected.
<object class="wxRadioButton" name="radiobutton_id">
<label>Radio button</label>
<value>1</value>
</object>
wxRadioBox
Inherits wxWindow properties
- style
- Radio box style: wxRA_SPECIFY_COLS, wxRA_HORIZONTAL, wxRA_SPECIFY_ROWS, wxRA_VERTICAL
- selection
- integer value: index ( 0 based ) of the selected entry
- content
- list of item tags describing the elements in the control.
<object class="wxRadioBox" name="radiobox_id">
<label>Radio box</label>
<selection>1</selection>
<dimension>2</dimension>
<content>
<item>Value 1</item>
<item>Value 2</item>
<item>Value 3</item>
<item>Value 4</item>
<item>Value 5</item>
<item>Value 6</item>
</content>
</object>
wxScrollBar
Inherits wxWindow properties
- style
- Scroll bar style: wxSB_HORIZONTAL, wxSB_VERTICAL
- value
- long: current position
- thumbsize
- long: view size
- range
- long: max value of the scrollbar
- pagesize
- long: size of one scrolled page
<object class="wxScrollBar" name="scrollbar_id">
<size>-1,100</size>
<value>50</value>
<range>100</range>
<thumbsize>30</thumbsize>
<style>wxSB_VERTICAL</style>
</object>
wxScrolledWindow
Inherits wxWindow properties
- style
- Scrolled window style: wxHSCROLL, wxVSCROLL
<object class="wxScrolledWindow" name="scrolledwindow_id">
<bg>#FFFFFF</bg>
<style>wxHSCROLL|wxVSCROLL</style>
<size>200,200</size>
</object>
wxSlider
Inherits wxWindow properties
- style
- Slider style, see the wxSlider documentation for a list of styles.
- value
- long: current position of the slider
- min
- long: minimum position of the slider
- max
- long: maximum position of the slider
- tickfreq
- long: tick frequency
- pagesize
- long: The number of steps the slider moves when the user pages up or down
- linesize
- long: the number of steps the slider moves when the user moves it up or down a line
- thumb
- long: sets the thumb length
- tick
- long: position of a tick
- selmin, selmax
- long: sets minimum and maximum selection position
<object class="wxSlider" name="slider_id">
<style>wxSL_HORIZONTAL|wxSL_AUTOTICKS</style>
<size>200,200</size>
<tickfreq>10</tickfreq>
<value>50</value>
<min>10</min>
<max>200</max>
</object>
wxSpinButton
Inherits wxWindow properties
- style
- Spin button style: wxSP_HORIZONTAL, wxSP_VERTICAL, wxSP_ARROW_KEYS, wxSP_WRAP
- value
- long: current value of the spin button
- min
- long: minimum value of the spin button
- max
- long: maximum value of the spin button
<object class="wxSpinButton" name="spinbutton_id">
<style>wxSP_HORIZONTAL|wxSP_ARROW_KEYS</style>
<value>50</value>
<min>10</min>
<max>200</max>
</object>
wxSpinCtrl
Inherits wxWindow properties
- style
- Spin control style: wxSP_HORIZONTAL, wxSP_VERTICAL, wxSP_ARROW_KEYS, wxSP_WRAP
- value
- long: current value of the spin control
- min
- long: minimum value of the spin control
- max
- long: maximum value of the spin control
<object class="wxSpinCtrl" name="spincontrol_id">
<style>wxSP_HORIZONTAL|wxSP_ARROW_KEYS</style>
<value>50</value>
<min>10</min>
<max>200</max>
</object>
wxStaticBitmap
Inherits wxWindow properties
- bitmap
- Text: Bitmap file name
<object class="wxStaticBitmap" name="bitmap_id">
<bitmap>bt_buttonbitmap.xpm</bitmap>
</object>
wxStaticBox
Inherits wxWindow properties
- label
- Text: label of the static box
<object class="wxStaticBox" name="stbox_id">
<size>200,200</size>
<label>Static box sample</label>
</object>
wxStaticLine
Inherits wxWindow properties
- style
- Static line style: wxLI_HORIZONTAL, wxLI_VERTICAL
Tip
The size property should be present to size the static line. Default size is 0,0.
<object class="wxStaticLine" name="stline_id">
<size>200,5</size>
<style>wxLI_HORIZONTAL</style>
</object>
wxStaticText
Inherits wxWindow properties
- style
- Static text style: wxST_NO_AUTORESIZE, wxALIGN_LEFT, wxALIGN_RIGHT, wxALIGN_CENTRE
- label
- Text: label of the static text
<object class="wxStaticText" name="sttext_id">
<style>wxALIGN_CENTRE</style>
<label>Hello, World!!!</label>
</object>
wxTextCtrl
Inherits wxWindow properties
- style
- Text control style, see the wxTextCtrl documentation for a list of styles.
- value
- Text: initial value of the text control
<object class="wxTextCtrl" name="textctrl_id">
<style>wxTE_MULTILINE</style>
<value>Hello, World!!!</value>
</object>
wxToolBar
A wxToolBar contains zero or more tool and separator tags.
- style
- Toolbar style: wxTB_FLAT, wxTB_DOCKABLE, wxTB_VERTICAL, wxTB_HORIZONTAL
- bitmapsize
- size: size of the tools bitmaps (16,16 for example)
- margins
- size: margins size
- packing
- long: space between tools
- separation
- long: size of the separator
tool
A tool can only appear in a wxToolBar tag and describes a item of this tool bar.
- bitmap
- Text: path to the main bitmap file
- bitmap2
- Text: path to the second bitmap file (pressed)
- toggle
- bool value(0/1): 1 if the button should toggle when pressed
- tooltip
- Text: tooltip associated to the tool
- longhelp
- Text: help string associated to the tool
separator
A separator tag can only appear inside a wxToolBar tag and has not properties and no attributes.
<object class="wxToolBar" name="main_toolbar">
<bitmapsize>50,50</bitmapsize>
<style>wxTB_DOCKABLE|wxTB_HORIZONTAL</style>
<object class="tool" name="tool1">
<bitmap>bt_buttonbitmap.xpm</bitmap>
<bitmap2>bt_buttonbitmapd.xpm</bitmap2>
<toggle>1</toggle>
<tooltip>first button</tooltip>
<longhelp>long help first button</longhelp>
</object>
<object class="separator"/>
<object class="tool" name="tool2">
<bitmap>bt_buttonbitmap.xpm</bitmap>
<bitmap2>bt_buttonbitmapd.xpm</bitmap2>
<toggle>0</toggle>
<tooltip>second button</tooltip>
<longhelp>long help second button</longhelp>
</object>
</object>
wxTreeCtrl
Inherits wxWindow properties
- style
- Tree control style, see the wxTreeCtrl documentation for a list of styles.
<object class="wxTreeCtrl" name="treectrl_id">
<style>wxTR_EDIT_LABELS|wxTR_HAS_BUTTONS|wxTR_HAS_VARIABLE_ROW_HEIGHT</style>
</object>