From 06bb8d923df9ce02e522c661a11ff685466067a6 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 1 Mar 2010 23:20:35 +0000 Subject: [PATCH] Invalidate best size when the bitmap or bitmap position changes. Add GetBitmapMargins git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63595 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/button.h | 3 ++- include/wx/osx/button.h | 1 + src/gtk/button.cpp | 1 + src/msw/button.cpp | 2 ++ src/osx/button_osx.cpp | 2 ++ 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/wx/button.h b/include/wx/button.h index b6827dc002..49613d09db 100644 --- a/include/wx/button.h +++ b/include/wx/button.h @@ -109,7 +109,8 @@ public: // set the margins around the image void SetBitmapMargins(wxCoord x, wxCoord y) { DoSetBitmapMargins(x, y); } void SetBitmapMargins(const wxSize& sz) { DoSetBitmapMargins(sz.x, sz.y); } - + wxSize GetBitmapMargins() { return DoGetBitmapMargins(); } + // set the image position relative to the text, i.e. wxLEFT means that the // image is to the left of the text (this is the default) void SetBitmapPosition(wxDirection dir); diff --git a/include/wx/osx/button.h b/include/wx/osx/button.h index 75108eeb24..5b189fc940 100644 --- a/include/wx/osx/button.h +++ b/include/wx/osx/button.h @@ -65,6 +65,7 @@ protected: { m_marginX = x; m_marginY = y; + InvalidateBestSize(); } // the margins around the bitmap diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index 8fe4d861bb..88e29ac4f3 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -664,6 +664,7 @@ void wxButton::DoSetBitmapPosition(wxDirection dir) } gtk_button_set_image_position(GTK_BUTTON(m_widget), gtkpos); + InvalidateBestSize(); } #endif // GTK+ 2.10+ } diff --git a/src/msw/button.cpp b/src/msw/button.cpp index 4f9f577f78..407981a03a 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -1040,6 +1040,7 @@ 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) @@ -1047,6 +1048,7 @@ void wxButton::DoSetBitmapPosition(wxDirection dir) wxCHECK_RET( m_imageData, "SetBitmap() must be called first" ); m_imageData->SetBitmapPosition(dir); + InvalidateBestSize(); } // ---------------------------------------------------------------------------- diff --git a/src/osx/button_osx.cpp b/src/osx/button_osx.cpp index b61d296384..2fef7837da 100644 --- a/src/osx/button_osx.cpp +++ b/src/osx/button_osx.cpp @@ -104,11 +104,13 @@ void wxButton::DoSetBitmap(const wxBitmap& bitmap, State which) if ( bi ) bi->SetPressedBitmap(bitmap); } + InvalidateBestSize(); } void wxButton::DoSetBitmapPosition(wxDirection dir) { m_peer->SetBitmapPosition(dir); + InvalidateBestSize(); } wxWindow *wxButton::SetDefault() -- 2.45.2