Using XML Resources with XRC

From WxWiki
Revision as of 19:19, 19 October 2018 by Tierra (talk | contribs) (Text replacement - "\<(\/?)source([^>]+)\>" to "<$1syntaxhighlight$2>")
Jump to navigation Jump to search

Introduction

Building a user interface with wxWidgets is quite easy, and three non exclusive solutions are available:

  1. you can directly handle graphical objects and layout in your code
  2. you can make use of the wxWidgets standard resource files (wxr)
  3. 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.

<syntaxhighlight title="wxXmlResource Initialization Example"> wxXmlResource::Get()->InitAllHandlers(); bRet = wxXmlResource::Get()->Load( Path ); if( !bRet ) { cout << "Could not load resource file" << Path << endl; return false; } </source>

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 :

<syntaxhighlight lang="xml"> <?xml version="1.0"?> <resource version="2.3.0.1"> <object class="wxFrame" name="my_main_frame"> <size>200,300</size> ... </object> </resource> </source>

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

<syntaxhighlight lang="xml"> <object class="wxBoxSizer"> <orient>wxHORIZONTAL</orient> <object class="sizeritem">Left control</object> <object class="sizeritem">Right control</object> </object> </source>

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.

<syntaxhighlight lang="xml"> <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> </source>

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

<syntaxhighlight lang="xml"> <?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> </source>

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.

<syntaxhighlight lang="xml"> <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> </source>

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

<syntaxhighlight lang="xml"> <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> </source>

wxCheckBox

Inherits wxWindow properties

label
Label of the check box
checked
bool value (1/0): 1 if the check box is checked on creation

<syntaxhighlight lang="xml"> <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> </source>

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

<syntaxhighlight lang="xml"> <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> </source>

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

<syntaxhighlight lang="xml"> <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> </source>

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

<syntaxhighlight lang="xml"> <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> </source>

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.

<syntaxhighlight lang="xml"> <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> </source>

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.

<syntaxhighlight lang="xml"> <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> </source>

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.

<syntaxhighlight lang="xml"> <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> </source>

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.

<syntaxhighlight lang="xml"> <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> </source>

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.

<syntaxhighlight lang="xml"> <object class="wxHtmlWindow" name="htmlid_id"> <size>200,200</size> <borders>20d</borders> <htmlcode><b>This is a simple text</b></htmlcode> </object> </source>

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.

<syntaxhighlight lang="xml"> <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> </source>

wxListCtrl

Inherits wxWindow properties

style
List control style, see the wxListCtrl documentation for a list of styles.

<syntaxhighlight lang="xml"> <object class="wxListCtrl" name="listctrl_id"> <style>wxLC_REPORT|wxLC_ICON</style> </object> </source>

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.

<syntaxhighlight lang="xml"> <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> </source>

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.

<syntaxhighlight lang="xml"> <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> </source>

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.

<syntaxhighlight lang="xml"> <object class="wxRadioButton" name="radiobutton_id"> <label>Radio button</label> <value>1</value> </object> </source>

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.

<syntaxhighlight lang="xml"> <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> </source>

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

<syntaxhighlight lang="xml"> <object class="wxScrollBar" name="scrollbar_id"> <size>-1,100</size> <value>50</value> <range>100</range> <thumbsize>30</thumbsize> <style>wxSB_VERTICAL</style> </object> </source>

wxScrolledWindow

Inherits wxWindow properties

style
Scrolled window style: wxHSCROLL, wxVSCROLL

<syntaxhighlight lang="xml"> <object class="wxScrolledWindow" name="scrolledwindow_id"> <bg>#FFFFFF</bg> <style>wxHSCROLL|wxVSCROLL</style> <size>200,200</size> </object> </source>

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

<syntaxhighlight lang="xml"> <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> </source>

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

<syntaxhighlight lang="xml"> <object class="wxSpinButton" name="spinbutton_id"> <style>wxSP_HORIZONTAL|wxSP_ARROW_KEYS</style> <value>50</value> <min>10</min> <max>200</max> </object> </source>

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

<syntaxhighlight lang="xml"> <object class="wxSpinCtrl" name="spincontrol_id"> <style>wxSP_HORIZONTAL|wxSP_ARROW_KEYS</style> <value>50</value> <min>10</min> <max>200</max> </object> </source>

wxStaticBitmap

Inherits wxWindow properties

bitmap
Text: Bitmap file name

<syntaxhighlight lang="xml"> <object class="wxStaticBitmap" name="bitmap_id"> <bitmap>bt_buttonbitmap.xpm</bitmap> </object> </source>

wxStaticBox

Inherits wxWindow properties

label
Text: label of the static box

<syntaxhighlight lang="xml"> <object class="wxStaticBox" name="stbox_id"> <size>200,200</size> <label>Static box sample</label> </object> </source>

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.

<syntaxhighlight lang="xml"> <object class="wxStaticLine" name="stline_id"> <size>200,5</size> <style>wxLI_HORIZONTAL</style> </object> </source>

wxStaticText

Inherits wxWindow properties

style
Static text style: wxST_NO_AUTORESIZE, wxALIGN_LEFT, wxALIGN_RIGHT, wxALIGN_CENTRE
label
Text: label of the static text

<syntaxhighlight lang="xml"> <object class="wxStaticText" name="sttext_id"> <style>wxALIGN_CENTRE</style> <label>Hello, World!!!</label> </object> </source>

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

<syntaxhighlight lang="xml"> <object class="wxTextCtrl" name="textctrl_id"> <style>wxTE_MULTILINE</style> <value>Hello, World!!!</value> </object> </source>

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.

<syntaxhighlight lang="xml"> <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> </source>

wxTreeCtrl

Inherits wxWindow properties

style
Tree control style, see the wxTreeCtrl documentation for a list of styles.

<syntaxhighlight lang="xml"> <object class="wxTreeCtrl" name="treectrl_id"> <style>wxTR_EDIT_LABELS|wxTR_HAS_BUTTONS|wxTR_HAS_VARIABLE_ROW_HEIGHT</style> </object> </source>