Add window variant support to XRC.

Fixes #16247.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76996 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 2014-08-03 17:10:24 +00:00
parent ab50aed57b
commit 964352934e
4 changed files with 31 additions and 0 deletions

View File

@ -519,6 +519,8 @@ from properties lists below.
If set to 1, the control is created hidden (default: 0).}
@row3col{tooltip, @ref overview_xrcformat_type_text,
Tooltip to use for the control (default: not set).}
@row3col{variant, @ref overview_xrcformat_type_string,
Window variant (see wxWindow::SetWindowVariant()), one of "normal", "small", "mini" or "large" (default: "normal") (new since wxWidgets 3.0.2).}
@row3col{font, @ref overview_xrcformat_type_font,
Font to use for the control (default: window's default).}
@row3col{ownfont, @ref overview_xrcformat_type_font,

View File

@ -395,6 +395,7 @@ stdWindowProperties =
[xrc:p="o"] element focused {_, t_bool }* &
[xrc:p="o"] element hidden {_, t_bool }* &
[xrc:p="o"] element tooltip {_, t_text }* &
[xrc:p="o"] element variant {_, t_variant }* &
[xrc:p="o"] element font {_, t_font }* &
[xrc:p="o"] element ownfont {_, t_font }* &
[xrc:p="o"] element help {_, t_text }*
@ -450,6 +451,8 @@ t_font = (
[xrc:p="o"] element relativesize {_, t_float }*
)
t_variant = "normal" | "small" | "mini" | "large"
t_imagelist = (
[xrc:p="o"] element mask {_, t_bool }* &
[xrc:p="o"] element size {_, t_size }* &

View File

@ -27,6 +27,7 @@
<border>5</border>
<object class="wxButton" name="my_button">
<label>My Button</label>
<variant>small</variant>
</object>
</object>
<object class="sizeritem">

View File

@ -2418,6 +2418,31 @@ void wxXmlResourceHandlerImpl::SetupWindow(wxWindow *wnd)
{
//FIXME : add cursor
const wxString variant = GetParamValue(wxS("variant"));
if (!variant.empty())
{
if (variant == wxS("normal"))
wnd->SetWindowVariant(wxWINDOW_VARIANT_NORMAL);
else if (variant == wxS("small"))
wnd->SetWindowVariant(wxWINDOW_VARIANT_SMALL);
else if (variant == wxS("mini"))
wnd->SetWindowVariant(wxWINDOW_VARIANT_MINI);
else if (variant == wxS("large"))
wnd->SetWindowVariant(wxWINDOW_VARIANT_LARGE);
else
{
ReportParamError
(
wxS("variant"),
wxString::Format
(
"Invalid window variant \"%s\": must be one of "
"normal|small|mini|large.",
variant
)
);
}
}
if (HasParam(wxT("exstyle")))
// Have to OR it with existing style, since
// some implementations (e.g. wxGTK) use the extra style