From c046274e38081407d9f229915e091b000f847010 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 16 Mar 2004 21:58:53 +0000 Subject: [PATCH] implment wxBitmapButton::DoGetBestSize git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26238 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/bmpbuttn.h | 3 +++ src/msw/bmpbuttn.cpp | 24 +++++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/include/wx/msw/bmpbuttn.h b/include/wx/msw/bmpbuttn.h index ed6508684c..f1716a5473 100644 --- a/include/wx/msw/bmpbuttn.h +++ b/include/wx/msw/bmpbuttn.h @@ -54,6 +54,9 @@ public: virtual void DrawButtonFocus( WXHDC dc, int left, int top, int right, int bottom, bool sel ); virtual void DrawButtonDisable( WXHDC dc, int left, int top, int right, int bottom, bool with_marg ); +protected: + virtual wxSize DoGetBestSize() const; + private: DECLARE_DYNAMIC_CLASS_NO_COPY(wxBitmapButton) }; diff --git a/src/msw/bmpbuttn.cpp b/src/msw/bmpbuttn.cpp index 9821e4a385..ee417d6608 100644 --- a/src/msw/bmpbuttn.cpp +++ b/src/msw/bmpbuttn.cpp @@ -136,11 +136,14 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, else m_windowId = id; - if ( width == -1 && bitmap.Ok()) - width = bitmap.GetWidth() + 2*m_marginX; - - if ( height == -1 && bitmap.Ok()) - height = bitmap.GetHeight() + 2*m_marginY; + if ( bitmap.Ok() ) + { + wxSize newSize = DoGetBestSize(); + if ( width == -1 ) + width = newSize.x; + if ( height == -1 ) + height = newSize.y; + } long msStyle = WS_VISIBLE | WS_TABSTOP | WS_CHILD | BS_OWNERDRAW ; @@ -455,4 +458,15 @@ void wxBitmapButton::SetDefault() wxButton::SetDefault(); } +wxSize wxBitmapButton::DoGetBestSize() const +{ + wxSize best; + if (m_bmpNormal.Ok()) + { + best.x = m_bmpNormal.GetWidth() + 2*m_marginX; + best.y = m_bmpNormal.GetHeight() + 2*m_marginY; + } + return best; +} + #endif // wxUSE_BMPBUTTON -- 2.45.2