Using XML Resources with XRC

From WxWiki
Revision as of 15:54, 24 February 2007 by Tierra (talk | contribs) (initial page import, 30% cleaned up, 70% to go)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This article has been rescued from this archive, and has not been completely reformatted for this wiki. Please be patient, and use the original article for now.

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.

The two main advantages of XML resources, except that it is XML, is that it is quite readable and runtime processed.

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 the wxXmlResource Class

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.

Example 1. wxXmlResource initialization

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.

Using the wxXmlResource Class to Create 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 :

  • Directly by using the following form wxDialog *Dlg;
Dlg = wxXmlResource::Get()->LoadDialog( FrameObjectPointer, "dialog_resource" );
Dlg->ShowModal();
  • 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();
  • 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.

XML Resource File (XRC) Format

XRC files are standard XML files. The format should be the following :

Example 2. XRC resource file

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

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.

wxWindow Derived 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:

Common properties for wxWindow derived elements

exstyle
extended window style: wxSIMPLE_BORDER, wxSUNKEN_BORDER, wxDOUBLE_BORDER, wxRAISED_BORDER, wxSTATIC_BORDER, wxNO_BORDER, wxWANTS_CHARS, wxNO_FULL_REPAINT_ON_RESIZE
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: italic, slant
weight
font weight: bold, light
family
font family: decorative, roman, script, swiss, modern
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.

Properties (as XML sub-elements)

orient
wxBoxSizer orientation: wxVERTICAL, wxHORIZONTAL

Example 3. wxBoxSizer sample

<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.

Properties (as XML sub-elements)

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.

Properties (as XML sub-elements)

rows</span>
Number of rows.
cols</span>
Number of cols.
vgap</span>
vertical space between to elements.
hgap</span>
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.

Properties (as XML sub-elements)

rows</span>
Number of rows.
cols</span>
Number of cols.
vgap</span>
vertical space between to elements.
hgap</span>
horizontal space between to elements.
growablecols</span>
list: comma separated list of cols indexes that will grow with the container.
growablerows</span>
list: comma separated list of rows indexes that will grow with the container.

5.3. wxBitmapButton

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxBU_AUTODRAW wxBU_LEFT wxBU_RIGHT wxBU_TOP wxBU_BOTTOM
Button styles
bitmap</span>
The bitmap path and filename
default</span>
bool value (0/1) : 1 if this button is the default button of the dialog or panel.
selected</span>
This is the selected bitmap specifier. Contains a bitmap tag
focus</span>
This is the focused bitmap specifier. Contains a bitmap tag
disabled</span>
This is the disabled bitmap specifier. Contains a bitmap tag

Example 4. wxBitmapButton sample

<?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>
                     <bitmap>bt_buttonbitmaps.xpm</bitmap>
                 </selected>
                 <focus>
                     <bitmap>bt_buttonbitmapf.xpm</bitmap>
                 </focus>
                 <disabled>
                     <bitmap>bt_buttonbitmapd.xpm</bitmap>
                 </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>

5.4. wxButton

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxBU_LEFT wxBU_RIGHT wxBU_TOP wxBU_BOTTOM
The button style
label</span>
The label of the button
default</span>
bool value (0/1): 1 if this button is the default button of the dialog or panel.

Example 5. wxButton sample


<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>

5.5. wxCalendarCtrl

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
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.

Example 6. wxCalendarCtrl sample

<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>

5.6. wxCheckBox

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

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

Example 7. wxCheckBox sample

<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>

5.7. wxCheckList

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

content</span>
list of item tags describing the elements in the "checklist" control.
item tag attribute
checked</span>
bool value (0/1) : 1 if the element is checked

Example 8. wxCheckList sample

<object class="wxCheckList" 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>

5.8. wxChoice

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

selection</span>
integer value: index ( 0 based ) of the selected entry
content</span>
list of item tags describing the elements in the "checklist" control.
item tag attribute
checked</span>
bool value (0/1) : 1 if the element is checked

Example 9. wxChoice sample

<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>

5.9. wxComboBox

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxCB_SIMPLE wxCB_SORT wxCB_READONLY wxCB_DROPDOWN
combo style
value</span>
initial value of the combo as text
selection</span>
integer value: index ( 0 based ) of the selected entry
content</span>
list of item tags describing the elements in the "checklist" control.
item tag attribute
checked</span>
bool value (0/1) : this has no meaning in a combo

Example 10. wxComboBox sample

<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>

5.10. wxDialog

Inherits wxWindow properties.

This is a top-level component, and it can have multiple sub elements ( sizers, controls).

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

title</span>
Title of the dialog as text
style</span>
wxSTAY_ON_TOP wxCAPTION wxDEFAULT_DIALOG_STYLE wxTHICK_FRAME wxSYSTEM_MENU
wxRESIZE_BORDER wxRESIZE_BOX wxDIALOG_MODAL wxDIALOG_MODELESS wxNO_3D
wxTAB_TRAVERSAL wxWS_EX_VALIDATE_RECURSIVELY wxCLIP_CHILDREN wxMAXIMIZE_BOX wxMINIMIZE_BOX
Dialog styles
centered</span>
bool value(0/1) : 1 if the dialog should be centered on it's parent screen.

Example 11. wxDialog sample

<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>

5.11. wxFrame

Inherits wxWindow properties.

This is a top-level component, and it can have multiple sub elements ( sizers, controls ).

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

title</span>
Title of the frame as text
style</span>
wxSTAY_ON_TOP wxCAPTION wxDEFAULT_DIALOG_STYLE wxDEFAULT_FRAME_STYLE wxTHICK_FRAME
wxSYSTEM_MENU wxRESIZE_BORDER wxRESIZE_BOX wxFRAME_TOOL_WINDOW wxFRAME_FLOAT_ON_PARENT
wxMAXIMIZE_BOX wxMINIMIZE_BOX wxSTAY_ON_TOP wxNO_3D wxTAB_TRAVERSAL
wxWS_EX_VALIDATE_RECURSIVELY wxCLIP_CHILDREN
Frame style
centered</span>
bool value(0/1) : 1 if the frame should be centered on it's parent screen.

Example 12. wxFrame sample

<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>

5.12. wxGauge

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxGA_HORIZONTAL wxGA_VERTICAL wxGA_PROGRESSBAR wxGA_SMOOTH
Gauge style
range</span>
integer value: maximum value for the gauge.
value</span>
integer value: initial value for the gauge position.
shadow</span>
integer value: width of the shadow.
bezel</span>
integer value: width of the bezel face.

Example 13. wxGauge sample

<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>

5.13. wxGenericDirCtrl

Inherits wxWindow properties

Tip

default size of this control seems to be 0,0. So you should always put a size tag.

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxDIRCTRL_DIR_ONLY wxDIRCTRL_3D_INTERNAL wxDIRCTRL_SELECT_FIRST wxDIRCTRL_SHOW_FILTERS
Control style
defaultfolder</span>
Text value: path of the default directory.
filter</span>
Text value: expression of the files to be displayed (wild card enabled).
defaultfilter</span>
long value: index of the default filter.

Example 14. wxGenericDirCtrl sample

<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>

5.14. wxHtmlWindow

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxHW_SCROLLBAR_NEVER wxHW_SCROLLBAR_AUTO
HTML window style
borders</span>
integer value: border size to leave between the left and top border of the window, and the HTML display.
htmlcode</span>
text value: the HTML the control should display.
url</span>
text: path to an HTML file to display.

Example 15. xwHtmlWindow sample

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

5.15. wxListBox

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxLB_SINGLE wxLB_MULTIPLE wxLB_EXTENDED wxLB_HSCROLL wxLB_ALWAYS_SB
wxLB_NEEDED_SB wxLB_SORT
List box style
selection</span>
integer value: index ( 0 based ) of the selected entry
content</span>
list of item tags describing the elements in the "list box" control.

Example 16. wxListBox sample

<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>

5.16. wxListCtrl

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxLC_LIST wxLC_REPORT wxLC_ICON wxLC_SMALL_ICON wxLC_ALIGN_TOP
wxLC_ALIGN_LEFT wxLC_AUTOARRANGE wxLC_USER_TEXT wxLC_EDIT_LABELS wxLC_NO_HEADER
wxLC_SINGLE_SEL wxLC_SORT_DESCENDING wxLC_SORT_ASCENDING
List control style

Example 17. wxListCtrl sample

<object class="wxListCtrl" name="listctrl_id">
<style>wxLC_REPORT|wxLC_ICON</style>
</object>

5.17. wxMenuBar

Does not inherit wxWindow properties. A wxMenuBar can contain one or more wxMenu sub-elements.

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxMB_DOCKABLE
Menu bar style

Example 18. wxMenuBar sample

<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>

5.18. wxMenu

Does not inherit wxWindow properties. A menu contains one or more wxMenuItem tags.

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxMENU_TEAROFF
Menu style
label</span>
Text: label of the menu.
help</span>
Text: displayed help string.

5.19. wxMenuItem

Does not inherit wxWindow properties.

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxMENU_TEAROFF
Menu style
label</span>
Text: label of the menu.
accel</span>
Text: accelerator associated to this item ( Alt-X for example ).
help</span>
Text: displayed help string.
radio</span>
bool value(0/1): 1 if this item is a radio menu item.
checkable</span>
bool value(0/1): 1 if this item is a check menu item.
enabled</span>
bool value(0/1): 1 if this item is initially enabled.
checked</span>
bool value(0/1): 1 if this (check) item is initially checked.
bitmap</span>
Text: path to a bitmap to draw at the left of the item.

5.20. wxNotebook

Does not Inherit wxWindow properties. A wxNotebook tag contains one or more notebookpage tags.

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxNB_FIXEDWIDTH wxNB_LEFT wxNB_RIGHT wxNB_BOTTOM
Notebook style
usenotebooksizer</span>
bool value(0/1): 1 if a notebook sizer is to be used to handle notebook pages.

Example 19. wxNotebook sample

<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>
</object>

5.21. notebookpage

A notebookpage can only appear inside a wxNotebook. It contains one or more objects like panels and controls.

label</span>
Text: label of the page.
selected</span>
bool value(0/1): is this page the selected one.

5.22. wxPanel

Inherits wxWindow properties. A panel contains zero or more sizers and controls.

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxNO_3D wxTAB_TRAVERSAL wxWS_EX_VALIDATE_RECURSIVELY wxCLIP_CHILDREN
Panel style.

5.23. wxRadioButton

Inherits wxWindow properties.

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxRB_GROUP
Radio button style
label</span>
Text: label of the button.
value</span>
bool value(0/1): 1 if the button is selected.

Example 20. wxRadioButton sample

<object class="wxRadioButton" name="radiobutton_id">
<label>Radio button</label>
<value>1</value>
</object>

5.24. wxRadioBox

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxRA_SPECIFY_COLS wxRA_HORIZONTAL wxRA_SPECIFY_ROWS wxRA_VERTICAL
Radio box style
selection</span>
integer value: index ( 0 based ) of the selected entry
content</span>
list of item tags describing the elements in the "radiobox" control.

Example 21. wxRadioBox sample

<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>

5.25. wxScrollBar

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxSB_HORIZONTAL wxSB_VERTICAL
Scroll bar style
value</span>
long: current position
thumbsize</span>
long: view size
range</span>
long: max value of the scrollbar
pagesize</span>
long: size of one scrolled page

Example 22. wxScrollBar sample

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

5.26. wxScrolledWindow

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxHSCROLL wxVSCROLL
Scrolled window style

Example 23. wxScrolledWindow sample

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

5.27. wxSlider

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxSL_HORIZONTAL wxSL_VERTICAL wxSL_AUTOTICKS wxSL_LABELS wxSL_LEFT
wxSL_RIGHT wxSL_BOTTOM wxSL_BOTH wxSL_SELRANGE
Slider style
value</span>
long: current position of the slider
min</span>
long: minimum position of the slider
max</span>
long: maximum position of the slider
tickfreq</span>
long: tick frequency
pagesize</span>
long: The number of steps the slider moves when the user pages up or down
linesize</span>
long: the number of steps the slider moves when the user moves it up or down a line
thumb</span>
long: sets the thumb length
tick</span>
long: position of a tick
selmin, </span>selmax</span>
long: sets minimum and maximum selection position

Example 24. wxSlider sample

<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>

5.28. wxSpinButton

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxSP_HORIZONTAL wxSP_VERTICAL wxSP_ARROW_KEYS wxSP_WRAP
Spin button style
value</span>
long: current value of the spin button
min</span>
long: minimum value of the spin button
max</span>
long: maximum value of the spin button

Example 25. wxSpinButton sample

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

5.29. wxSpinCtrl

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxSP_HORIZONTAL wxSP_VERTICAL wxSP_ARROW_KEYS wxSP_WRAP
Spin control style
value</span>
long: current value of the spin control
min</span>
long: minimum value of the spin control
max</span>
long: maximum value of the spin control

Example 26. wxSpinCtrl sample

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

5.30. wxStaticBitmap

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

bitmap</span>
Text: Bitmap file name

Example 27. wxStaticBitmap sample

<object class="wxStaticBitmap" name="bitmap_id">
<bitmap>bt_buttonbitmap.xpm</bitmap>
</object>

5.31. wxStaticBox

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

label</span>
Text: label of the static box

Example 28. wxStaticBox sample

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

5.32. wxStaticLine

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxLI_HORIZONTAL wxLI_VERTICAL
Static line style

Tip

The size property should be present to size the static line. Default size is 0,0.

Example 29. wxStaticLine sample

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

5.33. wxStaticText

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxST_NO_AUTORESIZE wxALIGN_LEFT wxALIGN_RIGHT wxALIGN_CENTRE
Static text style
label</span>
Text: label of the static text

Example 30. wxStaticText sample

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

5.34. wxTextCtrl

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxTE_PROCESS_ENTER wxTE_PROCESS_TAB wxTE_MULTILINE wxTE_PASSWORD wxTE_READONLY
wxHSCROLL wxTE_RICH wxTE_RICH2 wxTE_AUTO_URL wxTE_NOHIDESEL
wxTE_LEFT wxTE_CENTRE wxTE_RIGHT wxTE_DONTWRAP wxTE_LINEWRAP
wxTE_WORDWRAP
Text control style
value</span>
Text: initial value of the text control

Example 31. wxTextCtrl sample

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

5.35. wxToolBar

A wxToolBar contains zero or more tool and separator tags.

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxTB_FLAT wxTB_DOCKABLE wxTB_VERTICAL wxTB_HORIZONTAL
Toolbar style
bitmapsize</span>
size: size of the tools bitmaps ( 16,16 for example )
margins</span>
size: margins size
packing</span>
long: space between tools
separation</span>
long: size of the separator

Example 32. wxToolBar sample

<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>

5.36. tool

A tool can only appear in a wxToolBar tag and describes a item of this tool bar.

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

bitmap</span>
Text: path to the main bitmap file
bitmap2</span>
Text: path to the second bitmap file (pressed)
toggle</span>
bool value(0/1): 1 if the button should toggle when pressed
tooltip</span>
Text: tooltip associated to the tool
longhelp</span>
Text: help string associated to the tool

5.37. separator

A separator tag can only appear inside a wxToolBar tag and has not properties and no attributes.

5.38. wxTreeCtrl

Inherits wxWindow properties

Attributes

name</span>
string:unique identifier for the resource

Properties(as XML sub-elements)

style</span>
wxTR_EDIT_LABELS wxTR_NO_BUTTONS wxTR_HAS_BUTTONS wxTR_TWIST_BUTTONS wxTR_NO_LINES
wxTR_FULL_ROW_HIGHLIGHT wxTR_LINES_AT_ROOT wxTR_HIDE_ROOT wxTR_ROW_LINES wxTR_HAS_VARIABLE_ROW_HEIGHT
wxTR_SINGLE wxTR_MULTIPLE wxTR_EXTENDED wxTR_DEFAULT_STYLE
Tree control style

Example 33. wxTreeCtrl sample

<object class="wxTreeCtrl" name="treectrl_id">
<style>wxTR_EDIT_LABELS|wxTR_HAS_BUTTONS|wxTR_HAS_VARIABLE_ROW_HEIGHT</style>
</object>