Add support for wxStaticBoxSizer "windowlabel" property to XRC
Allow specifying arbitrary windows as labels for the static boxes created from XRC. Note that wxStaticBox XRC handler itself wasn't updated to support this, as this handler seems to be quite useless because it's impossible to define any box children with it, so only wxStaticBoxSizer XRC handler really matters, anyhow.
This commit is contained in:
@@ -2416,6 +2416,9 @@ support the following properties:
|
|||||||
Sizer orientation, "wxHORIZONTAL" or "wxVERTICAL" (default: wxHORIZONTAL).}
|
Sizer orientation, "wxHORIZONTAL" or "wxVERTICAL" (default: wxHORIZONTAL).}
|
||||||
@row3col{label, @ref overview_xrcformat_type_text,
|
@row3col{label, @ref overview_xrcformat_type_text,
|
||||||
Label to be used for the static box around the sizer (default: empty).}
|
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
|
@endTable
|
||||||
|
|
||||||
@subsection overview_xrcformat_wxgridsizer wxGridSizer
|
@subsection overview_xrcformat_wxgridsizer wxGridSizer
|
||||||
|
@@ -983,6 +983,58 @@ lay them out using wxSizers, absolute positioning, everything you like!
|
|||||||
<object class="wxStaticBoxSizer">
|
<object class="wxStaticBoxSizer">
|
||||||
<orient>wxVERTICAL</orient>
|
<orient>wxVERTICAL</orient>
|
||||||
<label>Internet options</label>
|
<label>Internet options</label>
|
||||||
|
<object class="sizeritem">
|
||||||
|
<flag>wxALL</flag>
|
||||||
|
<border>5</border>
|
||||||
|
<object class="wxRadioButton">
|
||||||
|
<style>wxRB_GROUP</style>
|
||||||
|
<label>Use _proxy</label>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
<object class="sizeritem">
|
||||||
|
<flag>wxALL</flag>
|
||||||
|
<border>5</border>
|
||||||
|
<object class="wxRadioButton">
|
||||||
|
<label>Use _VPN</label>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
<object class="sizeritem">
|
||||||
|
<flag>wxALL</flag>
|
||||||
|
<border>5</border>
|
||||||
|
<object class="wxRadioButton">
|
||||||
|
<label>Use _Tor</label>
|
||||||
|
<value>1</value>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
<object class="sizeritem">
|
||||||
|
<flag>wxGROW|wxALL</flag>
|
||||||
|
<border>5</border>
|
||||||
|
<object class="wxStaticBoxSizer">
|
||||||
|
<orient>wxVERTICAL</orient>
|
||||||
|
<windowlabel>
|
||||||
|
<object class="wxCheckBox">
|
||||||
|
<label>Enable quantum mechanics</label>
|
||||||
|
<checked>1</checked>
|
||||||
|
</object>
|
||||||
|
</windowlabel>
|
||||||
|
<object class="sizeritem">
|
||||||
|
<flag>wxALL</flag>
|
||||||
|
<border>5</border>
|
||||||
|
<object class="wxRadioButton">
|
||||||
|
<style>wxRB_GROUP</style>
|
||||||
|
<label>Cat is dead</label>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
<object class="sizeritem">
|
||||||
|
<flag>wxALL</flag>
|
||||||
|
<border>5</border>
|
||||||
|
<object class="wxRadioButton">
|
||||||
|
<label>Cat is alive</label>
|
||||||
|
<value>1</value>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
|
@@ -320,14 +320,63 @@ wxSizer* wxSizerXmlHandler::Handle_wxBoxSizer()
|
|||||||
#if wxUSE_STATBOX
|
#if wxUSE_STATBOX
|
||||||
wxSizer* wxSizerXmlHandler::Handle_wxStaticBoxSizer()
|
wxSizer* wxSizerXmlHandler::Handle_wxStaticBoxSizer()
|
||||||
{
|
{
|
||||||
return new wxStaticBoxSizer(
|
wxXmlNode* nodeWindowLabel = GetParamNode(wxS("windowlabel"));
|
||||||
new wxStaticBox(m_parentAsWindow,
|
wxString const& labelText = GetText(wxS("label"));
|
||||||
GetID(),
|
|
||||||
GetText(wxT("label")),
|
wxStaticBox* box = NULL;
|
||||||
wxDefaultPosition, wxDefaultSize,
|
if ( nodeWindowLabel )
|
||||||
0/*style*/,
|
{
|
||||||
GetName()),
|
if ( !labelText.empty() )
|
||||||
GetStyle(wxT("orient"), wxHORIZONTAL));
|
{
|
||||||
|
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
|
#endif // wxUSE_STATBOX
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user