From 178a12204bcdb9d98af14cc133432c7359b1b969 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 16 Mar 2004 21:58:27 +0000 Subject: [PATCH] implement wxBitmapButton::DoGetBestSize git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26237 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/bmpbuttn.h | 1 + include/wx/gtk1/bmpbuttn.h | 1 + src/gtk/bmpbuttn.cpp | 19 ++++++++++++++++--- src/gtk1/bmpbuttn.cpp | 19 ++++++++++++++++--- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/include/wx/gtk/bmpbuttn.h b/include/wx/gtk/bmpbuttn.h index 5a27135aba..c71501e59a 100644 --- a/include/wx/gtk/bmpbuttn.h +++ b/include/wx/gtk/bmpbuttn.h @@ -68,6 +68,7 @@ public: protected: virtual void OnSetBitmap(); + virtual wxSize DoGetBestSize() const; void Init(); diff --git a/include/wx/gtk1/bmpbuttn.h b/include/wx/gtk1/bmpbuttn.h index 5a27135aba..c71501e59a 100644 --- a/include/wx/gtk1/bmpbuttn.h +++ b/include/wx/gtk1/bmpbuttn.h @@ -68,6 +68,7 @@ public: protected: virtual void OnSetBitmap(); + virtual wxSize DoGetBestSize() const; void Init(); diff --git a/src/gtk/bmpbuttn.cpp b/src/gtk/bmpbuttn.cpp index dda2040146..2c7762f095 100644 --- a/src/gtk/bmpbuttn.cpp +++ b/src/gtk/bmpbuttn.cpp @@ -150,11 +150,11 @@ bool wxBitmapButton::Create( wxWindow *parent, if (m_bmpNormal.Ok()) { wxSize newSize = size; - int border = (style & wxNO_BORDER) ? 4 : 10; + wxSize bestSize = DoGetBestSize(); if (newSize.x == -1) - newSize.x = m_bmpNormal.GetWidth()+border; + newSize.x = bestSize.x; if (newSize.y == -1) - newSize.y = m_bmpNormal.GetHeight()+border; + newSize.y = bestSize.y; SetSize( newSize.x, newSize.y ); OnSetBitmap(); } @@ -258,6 +258,19 @@ void wxBitmapButton::OnSetBitmap() } } +wxSize wxBitmapButton::DoGetBestSize() const +{ + wxSize best; + + if (m_bmpNormal.Ok()) + { + int border = HasFlag(wxNO_BORDER) ? 4 : 10; + best.x = m_bmpNormal.GetWidth()+border; + best.y = m_bmpNormal.GetHeight()+border; + } + return best; +} + bool wxBitmapButton::Enable( bool enable ) { if ( !wxWindow::Enable(enable) ) diff --git a/src/gtk1/bmpbuttn.cpp b/src/gtk1/bmpbuttn.cpp index dda2040146..2c7762f095 100644 --- a/src/gtk1/bmpbuttn.cpp +++ b/src/gtk1/bmpbuttn.cpp @@ -150,11 +150,11 @@ bool wxBitmapButton::Create( wxWindow *parent, if (m_bmpNormal.Ok()) { wxSize newSize = size; - int border = (style & wxNO_BORDER) ? 4 : 10; + wxSize bestSize = DoGetBestSize(); if (newSize.x == -1) - newSize.x = m_bmpNormal.GetWidth()+border; + newSize.x = bestSize.x; if (newSize.y == -1) - newSize.y = m_bmpNormal.GetHeight()+border; + newSize.y = bestSize.y; SetSize( newSize.x, newSize.y ); OnSetBitmap(); } @@ -258,6 +258,19 @@ void wxBitmapButton::OnSetBitmap() } } +wxSize wxBitmapButton::DoGetBestSize() const +{ + wxSize best; + + if (m_bmpNormal.Ok()) + { + int border = HasFlag(wxNO_BORDER) ? 4 : 10; + best.x = m_bmpNormal.GetWidth()+border; + best.y = m_bmpNormal.GetHeight()+border; + } + return best; +} + bool wxBitmapButton::Enable( bool enable ) { if ( !wxWindow::Enable(enable) ) -- 2.45.2