+// ----------------------------------------------------------------------------
+// authentication needed handling
+// ----------------------------------------------------------------------------
+
+bool wxButton::DoGetAuthNeeded() const
+{
+ return m_authNeeded;
+}
+
+void wxButton::DoSetAuthNeeded(bool show)
+{
+ // show/hide UAC symbol on Windows Vista and later
+ if ( wxGetWinVersion() >= wxWinVersion_6 )
+ {
+ m_authNeeded = show;
+ ::SendMessage(GetHwnd(), BCM_SETSHIELD, 0, show);
+ InvalidateBestSize();
+ }
+}
+
+// ----------------------------------------------------------------------------
+// button images
+// ----------------------------------------------------------------------------
+
+wxBitmap wxButton::DoGetBitmap(State which) const
+{
+ return m_imageData ? m_imageData->GetBitmap(which) : wxBitmap();
+}
+
+void wxButton::DoSetBitmap(const wxBitmap& bitmap, State which)
+{
+#if wxUSE_UXTHEME
+ wxXPButtonImageData *oldData = NULL;
+#endif // wxUSE_UXTHEME
+
+ // Check if we already had bitmaps of different size.
+ if ( m_imageData &&
+ bitmap.GetSize() != m_imageData->GetBitmap(State_Normal).GetSize() )
+ {
+ wxASSERT_MSG( which == State_Normal,
+ "Must set normal bitmap with the new size first" );
+
+#if wxUSE_UXTHEME
+ if ( ShowsLabel() && wxUxThemeEngine::GetIfActive() )
+ {
+ // We can't change the size of the images stored in wxImageList
+ // in wxXPButtonImageData::m_iml so force recreating it below but
+ // keep the current data to copy its values into the new one.
+ oldData = static_cast<wxXPButtonImageData *>(m_imageData);
+ m_imageData = NULL;
+ }
+#endif // wxUSE_UXTHEME
+ //else: wxODButtonImageData doesn't require anything special
+ }
+
+ // allocate the image data when the first bitmap is set
+ if ( !m_imageData )
+ {
+#if wxUSE_UXTHEME
+ // using image list doesn't work correctly if we don't have any label
+ // (even if we use BUTTON_IMAGELIST_ALIGN_CENTER alignment and
+ // BS_BITMAP style), at least under Windows 2003 so use owner drawn
+ // strategy for bitmap-only buttons
+ if ( ShowsLabel() && wxUxThemeEngine::GetIfActive() )
+ {
+ m_imageData = new wxXPButtonImageData(this, bitmap);
+
+ if ( oldData )
+ {
+ // Preserve the old values in case the user changed them.
+ m_imageData->SetBitmapPosition(oldData->GetBitmapPosition());
+
+ const wxSize oldMargins = oldData->GetBitmapMargins();
+ m_imageData->SetBitmapMargins(oldMargins.x, oldMargins.y);
+
+ // No need to preserve the bitmaps though as they were of wrong
+ // size anyhow.
+
+ delete oldData;
+ }
+ }
+ else
+#endif // wxUSE_UXTHEME
+ {
+ m_imageData = new wxODButtonImageData(this, bitmap);
+ MakeOwnerDrawn();
+ }
+ }
+ else
+ {
+ m_imageData->SetBitmap(bitmap, which);
+ }
+
+ // it should be enough to only invalidate the best size when the normal
+ // bitmap changes as all bitmaps assigned to the button should be of the
+ // same size anyhow
+ if ( which == State_Normal )
+ InvalidateBestSize();
+
+ Refresh();
+}
+
+wxSize wxButton::DoGetBitmapMargins() const
+{
+ return m_imageData ? m_imageData->GetBitmapMargins() : wxSize(0, 0);
+}
+
+void wxButton::DoSetBitmapMargins(wxCoord x, wxCoord y)
+{
+ wxCHECK_RET( m_imageData, "SetBitmap() must be called first" );
+
+ m_imageData->SetBitmapMargins(x, y);
+ InvalidateBestSize();
+}
+
+void wxButton::DoSetBitmapPosition(wxDirection dir)
+{
+ wxCHECK_RET( m_imageData, "SetBitmap() must be called first" );
+
+ m_imageData->SetBitmapPosition(dir);
+ InvalidateBestSize();
+}
+
+// ----------------------------------------------------------------------------
+// markup support
+// ----------------------------------------------------------------------------
+
+#if wxUSE_MARKUP
+
+bool wxButton::DoSetLabelMarkup(const wxString& markup)
+{
+ if ( !wxButtonBase::DoSetLabelMarkup(markup) )
+ return false;
+
+ if ( !m_markupText )
+ {
+ m_markupText = new wxMarkupText(markup);
+ MakeOwnerDrawn();
+ }
+ else
+ {
+ // We are already owner-drawn so just update the text.
+ m_markupText->SetMarkup(markup);
+ }
+
+ Refresh();
+
+ return true;
+}
+
+#endif // wxUSE_MARKUP
+