Refactor wxButton and wxToggleButton to derive from wxAnyButton.
Introduce wxAnyButton class, a common base class for wxButton and wxToggleButton, allowing to reuse the same implementation for them. This also allows to implement support for bitmaps in wxToggleButton for all platforms and make wxBitmapToggleButton a trivial subclass of it everywhere, similarly to wxBitmapButton and wxButton. Closes #13198. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67931 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -134,7 +134,8 @@ protected:
|
||||
#if wxUSE_MARKUP
|
||||
*m_chkUseMarkup,
|
||||
#endif // wxUSE_MARKUP
|
||||
*m_chkDefault;
|
||||
*m_chkDefault,
|
||||
*m_chkUseBitmapClass;
|
||||
|
||||
// more checkboxes for wxBitmapButton only
|
||||
wxCheckBox *m_chkUsePressed,
|
||||
@@ -216,6 +217,7 @@ ButtonWidgetsPage::ButtonWidgetsPage(WidgetsBookCtrl *book,
|
||||
m_chkUseMarkup =
|
||||
#endif // wxUSE_MARKUP
|
||||
m_chkDefault =
|
||||
m_chkUseBitmapClass =
|
||||
m_chkUsePressed =
|
||||
m_chkUseFocused =
|
||||
m_chkUseCurrent =
|
||||
@@ -252,6 +254,10 @@ void ButtonWidgetsPage::CreateContent()
|
||||
#endif // wxUSE_MARKUP
|
||||
m_chkDefault = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("&Default"));
|
||||
|
||||
m_chkUseBitmapClass = CreateCheckBoxAndAddToSizer(sizerLeft,
|
||||
"Use wxBitmapButton");
|
||||
m_chkUseBitmapClass->SetValue(true);
|
||||
|
||||
sizerLeft->AddSpacer(5);
|
||||
|
||||
wxSizer *sizerUseLabels =
|
||||
@@ -363,6 +369,7 @@ void ButtonWidgetsPage::Reset()
|
||||
#if wxUSE_MARKUP
|
||||
m_chkUseMarkup->SetValue(false);
|
||||
#endif // wxUSE_MARKUP
|
||||
m_chkUseBitmapClass->SetValue(true);
|
||||
|
||||
m_chkUsePressed->SetValue(true);
|
||||
m_chkUseFocused->SetValue(true);
|
||||
@@ -449,8 +456,17 @@ void ButtonWidgetsPage::CreateButton()
|
||||
{
|
||||
showsBitmap = true;
|
||||
|
||||
wxBitmapButton *bbtn = new wxBitmapButton(this, ButtonPage_Button,
|
||||
CreateBitmap(wxT("normal")));
|
||||
wxButton *bbtn;
|
||||
if ( m_chkUseBitmapClass->GetValue() )
|
||||
{
|
||||
bbtn = new wxBitmapButton(this, ButtonPage_Button,
|
||||
CreateBitmap(wxT("normal")));
|
||||
}
|
||||
else
|
||||
{
|
||||
bbtn = new wxButton(this, ButtonPage_Button);
|
||||
bbtn->SetBitmapLabel(CreateBitmap(wxT("normal")));
|
||||
}
|
||||
if ( m_chkUsePressed->GetValue() )
|
||||
bbtn->SetBitmapPressed(CreateBitmap(wxT("pushed")));
|
||||
if ( m_chkUseFocused->GetValue() )
|
||||
@@ -510,6 +526,8 @@ void ButtonWidgetsPage::CreateButton()
|
||||
m_button->SetBitmapDisabled(wxArtProvider::GetIcon(wxART_MISSING_IMAGE, wxART_BUTTON));
|
||||
}
|
||||
|
||||
m_chkUseBitmapClass->Enable(showsBitmap);
|
||||
|
||||
m_chkUsePressed->Enable(showsBitmap);
|
||||
m_chkUseFocused->Enable(showsBitmap);
|
||||
m_chkUseCurrent->Enable(showsBitmap);
|
||||
|
Reference in New Issue
Block a user