From fc2cc745300e62c6c0e4413aa882fe315900dbd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C4=83t=C4=83lin=20R=C4=83ceanu?= Date: Wed, 7 Dec 2016 02:32:10 +0200 Subject: [PATCH] Improve UI of the "Button" page of the widgets sample Allow only permitted combinations of text, bitmap and command link. Also avoid null pointer crash when combining "Bitmap only" with "Use command link button". --- samples/widgets/button.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/samples/widgets/button.cpp b/samples/widgets/button.cpp index 74b2bd55bb..178fefb2d8 100644 --- a/samples/widgets/button.cpp +++ b/samples/widgets/button.cpp @@ -446,13 +446,11 @@ void ButtonWidgetsPage::CreateButton() break; } -#if wxUSE_COMMANDLINKBUTTON - m_sizerNote->Show(m_chkCommandLink->GetValue()); -#endif - bool showsBitmap = false; if ( m_chkBitmapOnly->GetValue() ) { + m_chkCommandLink->SetValue(false); // wxCommandLinkButton cannot be "Bitmap only" + showsBitmap = true; wxButton *bbtn; @@ -503,6 +501,10 @@ void ButtonWidgetsPage::CreateButton() } } +#if wxUSE_COMMANDLINKBUTTON + m_sizerNote->Show(m_chkCommandLink->GetValue()); +#endif + if ( !showsBitmap && m_chkTextAndBitmap->GetValue() ) { showsBitmap = true; @@ -525,6 +527,9 @@ void ButtonWidgetsPage::CreateButton() m_button->SetBitmapDisabled(wxArtProvider::GetIcon(wxART_MISSING_IMAGE, wxART_BUTTON)); } + m_chkTextAndBitmap->Enable(!m_chkBitmapOnly->IsChecked()); + m_chkBitmapOnly->Enable(!m_chkTextAndBitmap->IsChecked()); + m_chkCommandLink->Enable(!m_chkBitmapOnly->IsChecked()); m_chkUseBitmapClass->Enable(showsBitmap); m_chkUsePressed->Enable(showsBitmap);