Add "pressed" and "current" wxBitmapButton XRC properties
New names are consistent with the names of the preferred SetBitmapXXX() functions. Document them and show using one of them in the sample.
This commit is contained in:
@@ -832,14 +832,18 @@ Refer to the section @ref xrc_wxtoolbar for more details.
|
|||||||
3.1.5.}
|
3.1.5.}
|
||||||
@row3col{bitmap, @ref overview_xrcformat_type_bitmap,
|
@row3col{bitmap, @ref overview_xrcformat_type_bitmap,
|
||||||
Bitmap to show on the button (default: none).}
|
Bitmap to show on the button (default: none).}
|
||||||
@row3col{selected, @ref overview_xrcformat_type_bitmap,
|
@row3col{pressed, @ref overview_xrcformat_type_bitmap,
|
||||||
Bitmap to show when the button is selected (default: none, same as @c bitmap).}
|
Bitmap to show when the button is pressed (default: none, same as @c bitmap).
|
||||||
|
This property exists since wxWidgets 3.1.6, but the equivalent (and still
|
||||||
|
supported) "selected" property can be used in the older versions.}
|
||||||
@row3col{focus, @ref overview_xrcformat_type_bitmap,
|
@row3col{focus, @ref overview_xrcformat_type_bitmap,
|
||||||
Bitmap to show when the button has focus (default: none, same as @c bitmap).}
|
Bitmap to show when the button has focus (default: none, same as @c bitmap).}
|
||||||
@row3col{disabled, @ref overview_xrcformat_type_bitmap,
|
@row3col{disabled, @ref overview_xrcformat_type_bitmap,
|
||||||
Bitmap to show when the button is disabled (default: none, same as @c bitmap).}
|
Bitmap to show when the button is disabled (default: none, same as @c bitmap).}
|
||||||
@row3col{hover, @ref overview_xrcformat_type_bitmap,
|
@row3col{current, @ref overview_xrcformat_type_bitmap,
|
||||||
Bitmap to show when mouse cursor hovers above the bitmap (default: none, same as @c bitmap).}
|
Bitmap to show when mouse cursor hovers above the bitmap (default: none, same as @c bitmap).
|
||||||
|
This property exists since wxWidgets 3.1.6, but the equivalent (and still
|
||||||
|
supported) "hover" property can be used in the older versions.}
|
||||||
@endTable
|
@endTable
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ private:
|
|||||||
|
|
||||||
void SetBitmapIfSpecified(wxBitmapButton* button,
|
void SetBitmapIfSpecified(wxBitmapButton* button,
|
||||||
BitmapSetter setter,
|
BitmapSetter setter,
|
||||||
const char* paramName);
|
const char* paramName,
|
||||||
|
const char* paramNameAlt = NULL);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // wxUSE_XRC && wxUSE_BMPBUTTON
|
#endif // wxUSE_XRC && wxUSE_BMPBUTTON
|
||||||
|
|||||||
@@ -219,6 +219,7 @@
|
|||||||
<border>5</border>
|
<border>5</border>
|
||||||
<object class="wxBitmapButton" name="controls_bitmapbutton">
|
<object class="wxBitmapButton" name="controls_bitmapbutton">
|
||||||
<bitmap>controls.xpm</bitmap>
|
<bitmap>controls.xpm</bitmap>
|
||||||
|
<current>custclas.xpm</current>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="sizeritem">
|
<object class="sizeritem">
|
||||||
|
|||||||
@@ -31,14 +31,23 @@ wxBitmapButtonXmlHandler::wxBitmapButtonXmlHandler()
|
|||||||
|
|
||||||
// Function calls the given setter with the contents of the node with the given
|
// Function calls the given setter with the contents of the node with the given
|
||||||
// name, if present.
|
// name, if present.
|
||||||
|
//
|
||||||
|
// If alternative parameter name is specified, it is used too.
|
||||||
void
|
void
|
||||||
wxBitmapButtonXmlHandler::SetBitmapIfSpecified(wxBitmapButton* button,
|
wxBitmapButtonXmlHandler::SetBitmapIfSpecified(wxBitmapButton* button,
|
||||||
BitmapSetter setter,
|
BitmapSetter setter,
|
||||||
const char* paramName)
|
const char* paramName,
|
||||||
|
const char* paramNameAlt)
|
||||||
{
|
{
|
||||||
wxXmlNode* const node = GetParamNode(paramName);
|
if ( wxXmlNode* const node = GetParamNode(paramName) )
|
||||||
if ( node )
|
{
|
||||||
(button->*setter)(GetBitmapBundle(node));
|
(button->*setter)(GetBitmapBundle(node));
|
||||||
|
}
|
||||||
|
else if ( paramNameAlt )
|
||||||
|
{
|
||||||
|
if ( wxXmlNode* const nodeAlt = GetParamNode(paramNameAlt) )
|
||||||
|
(button->*setter)(GetBitmap(nodeAlt));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxObject *wxBitmapButtonXmlHandler::DoCreateResource()
|
wxObject *wxBitmapButtonXmlHandler::DoCreateResource()
|
||||||
@@ -66,10 +75,12 @@ wxObject *wxBitmapButtonXmlHandler::DoCreateResource()
|
|||||||
button->SetDefault();
|
button->SetDefault();
|
||||||
SetupWindow(button);
|
SetupWindow(button);
|
||||||
|
|
||||||
SetBitmapIfSpecified(button, &wxBitmapButton::SetBitmapPressed, "selected");
|
SetBitmapIfSpecified(button, &wxBitmapButton::SetBitmapPressed,
|
||||||
|
"pressed", "selected");
|
||||||
SetBitmapIfSpecified(button, &wxBitmapButton::SetBitmapFocus, "focus");
|
SetBitmapIfSpecified(button, &wxBitmapButton::SetBitmapFocus, "focus");
|
||||||
SetBitmapIfSpecified(button, &wxBitmapButton::SetBitmapDisabled, "disabled");
|
SetBitmapIfSpecified(button, &wxBitmapButton::SetBitmapDisabled, "disabled");
|
||||||
SetBitmapIfSpecified(button, &wxBitmapButton::SetBitmapCurrent, "hover");
|
SetBitmapIfSpecified(button, &wxBitmapButton::SetBitmapCurrent,
|
||||||
|
"current", "hover");
|
||||||
|
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user