X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/95912bdddeb21afe1cabc0401c0f8b8475a5e5c6..cd15bcaf50ead53ccf9d50965312f0dc754affb4:/samples/widgets/button.cpp diff --git a/samples/widgets/button.cpp b/samples/widgets/button.cpp index 99ca62a9a8..4376e39ae2 100644 --- a/samples/widgets/button.cpp +++ b/samples/widgets/button.cpp @@ -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() ) @@ -497,19 +513,21 @@ void ButtonWidgetsPage::CreateButton() wxLEFT, wxRIGHT, wxTOP, wxBOTTOM }; - m_button->SetBitmap(wxArtProvider::GetIcon(wxART_INFORMATION), + m_button->SetBitmap(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_BUTTON), positions[m_radioImagePos->GetSelection()]); if ( m_chkUsePressed->GetValue() ) - m_button->SetBitmapPressed(wxArtProvider::GetIcon(wxART_HELP)); + m_button->SetBitmapPressed(wxArtProvider::GetIcon(wxART_HELP, wxART_BUTTON)); if ( m_chkUseFocused->GetValue() ) - m_button->SetBitmapFocus(wxArtProvider::GetIcon(wxART_ERROR)); + m_button->SetBitmapFocus(wxArtProvider::GetIcon(wxART_ERROR, wxART_BUTTON)); if ( m_chkUseCurrent->GetValue() ) - m_button->SetBitmapCurrent(wxArtProvider::GetIcon(wxART_WARNING)); + m_button->SetBitmapCurrent(wxArtProvider::GetIcon(wxART_WARNING, wxART_BUTTON)); if ( m_chkUseDisabled->GetValue() ) - m_button->SetBitmapDisabled(wxArtProvider::GetIcon(wxART_MISSING_IMAGE)); + 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); @@ -601,7 +619,7 @@ wxBitmap ButtonWidgetsPage::CreateBitmap(const wxString& label) wxBitmap bmp(180, 70); // shouldn't hardcode but it's simpler like this wxMemoryDC dc; dc.SelectObject(bmp); - dc.SetBackground(wxBrush(*wxCYAN)); + dc.SetBackground(*wxCYAN_BRUSH); dc.Clear(); dc.SetTextForeground(*wxBLACK); dc.DrawLabel(wxStripMenuCodes(m_textLabel->GetValue()) + wxT("\n")