diff --git a/docs/doxygen/overviews/xrc_format.h b/docs/doxygen/overviews/xrc_format.h
index 187d8677d1..66dada62a6 100644
--- a/docs/doxygen/overviews/xrc_format.h
+++ b/docs/doxygen/overviews/xrc_format.h
@@ -2416,6 +2416,9 @@ support the following properties:
Sizer orientation, "wxHORIZONTAL" or "wxVERTICAL" (default: wxHORIZONTAL).}
@row3col{label, @ref overview_xrcformat_type_text,
Label to be used for the static box around the sizer (default: empty).}
+@row3col{windowlabel, any window,
+ Window to be used instead of the plain text label (default: none).
+ This property is only available since wxWidgets 3.1.1.}}
@endTable
@subsection overview_xrcformat_wxgridsizer wxGridSizer
diff --git a/samples/xrc/rc/controls.xrc b/samples/xrc/rc/controls.xrc
index bac4812e5e..8072505d22 100644
--- a/samples/xrc/rc/controls.xrc
+++ b/samples/xrc/rc/controls.xrc
@@ -983,6 +983,58 @@ lay them out using wxSizers, absolute positioning, everything you like!
+
+
+ wxGROW|wxALL
+ 5
+
+ wxVERTICAL
+
+
+
+ 1
+
+
+
+ wxALL
+ 5
+
+
+
+
+
+
+ wxALL
+ 5
+
+
+ 1
+
+
diff --git a/src/xrc/xh_sizer.cpp b/src/xrc/xh_sizer.cpp
index 8a91eb91e9..2a17184a55 100644
--- a/src/xrc/xh_sizer.cpp
+++ b/src/xrc/xh_sizer.cpp
@@ -320,14 +320,63 @@ wxSizer* wxSizerXmlHandler::Handle_wxBoxSizer()
#if wxUSE_STATBOX
wxSizer* wxSizerXmlHandler::Handle_wxStaticBoxSizer()
{
- return new wxStaticBoxSizer(
- new wxStaticBox(m_parentAsWindow,
- GetID(),
- GetText(wxT("label")),
- wxDefaultPosition, wxDefaultSize,
- 0/*style*/,
- GetName()),
- GetStyle(wxT("orient"), wxHORIZONTAL));
+ wxXmlNode* nodeWindowLabel = GetParamNode(wxS("windowlabel"));
+ wxString const& labelText = GetText(wxS("label"));
+
+ wxStaticBox* box = NULL;
+ if ( nodeWindowLabel )
+ {
+ if ( !labelText.empty() )
+ {
+ ReportError("Either label or windowlabel can be used, but not both");
+ return NULL;
+ }
+
+#ifdef wxHAS_WINDOW_LABEL_IN_STATIC_BOX
+ wxXmlNode* n = nodeWindowLabel->GetChildren();
+ if ( !n )
+ {
+ ReportError("windowlabel must have a window child");
+ return NULL;
+ }
+
+ if ( n->GetNext() )
+ {
+ ReportError("windowlabel can only have a single child");
+ return NULL;
+ }
+
+ wxObject* const item = CreateResFromNode(n, m_parent, NULL);
+ wxWindow* const wndLabel = wxDynamicCast(item, wxWindow);
+ if ( !wndLabel )
+ {
+ ReportError(n, "windowlabel child must be a window");
+ return NULL;
+ }
+
+ box = new wxStaticBox(m_parentAsWindow,
+ GetID(),
+ wndLabel,
+ wxDefaultPosition, wxDefaultSize,
+ 0/*style*/,
+ GetName());
+#else // !wxHAS_WINDOW_LABEL_IN_STATIC_BOX
+ ReportError("Support for using windows as wxStaticBox labels is "
+ "missing in this build of wxWidgets.");
+ return NULL;
+#endif // wxHAS_WINDOW_LABEL_IN_STATIC_BOX/!wxHAS_WINDOW_LABEL_IN_STATIC_BOX
+ }
+ else // Using plain text label.
+ {
+ box = new wxStaticBox(m_parentAsWindow,
+ GetID(),
+ labelText,
+ wxDefaultPosition, wxDefaultSize,
+ 0/*style*/,
+ GetName());
+ }
+
+ return new wxStaticBoxSizer(box, GetStyle(wxS("orient"), wxHORIZONTAL));
}
#endif // wxUSE_STATBOX