From b4b2e4a096fe8fe1ad530a4c181729be05834595 Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Mon, 18 Apr 2022 09:47:11 -0400 Subject: add upstream 11.20 --- wx+/bitmap_button.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'wx+/bitmap_button.h') diff --git a/wx+/bitmap_button.h b/wx+/bitmap_button.h index a3e6b0f6..5ab5411b 100644 --- a/wx+/bitmap_button.h +++ b/wx+/bitmap_button.h @@ -9,6 +9,7 @@ #include #include +#include #include "image_tools.h" #include "dc.h" @@ -37,7 +38,8 @@ public: void setBitmapTextLabel(wxBitmapButton& btn, const wxImage& img, const wxString& text, int gap = fastFromDIP(5), int border = fastFromDIP(5)); //set bitmap label flicker free: -void setImage(wxBitmapButton& button, const wxImage& bmp); +void setImage(wxAnyButton& button, const wxImage& bmp); +void setImage(wxStaticBitmap& staticBmp, const wxImage& img); wxBitmap renderSelectedButton(const wxSize& sz); wxBitmap renderPressedButton(const wxSize& sz); @@ -68,14 +70,12 @@ void setBitmapTextLabel(wxBitmapButton& btn, const wxImage& img, const wxString& btn.SetMinSize({imgTxt.GetWidth () + 2 * border, std::max(imgTxt.GetHeight() + 2 * border, defaultHeight)}); - btn.SetBitmapLabel(imgTxt); - //SetLabel() calls confuse wxBitmapButton in the disabled state and it won't show the image! workaround: - btn.SetBitmapDisabled(imgTxt.ConvertToDisabled()); + setImage(btn, imgTxt); } inline -void setImage(wxBitmapButton& button, const wxImage& img) +void setImage(wxAnyButton& button, const wxImage& img) { if (!img.IsOk()) { @@ -84,11 +84,18 @@ void setImage(wxBitmapButton& button, const wxImage& img) return; } - button.SetBitmapLabel(img); + button.SetBitmapLabel(toBitmapBundle(img)); //wxWidgets excels at screwing up consistently once again: //the first call to SetBitmapLabel() *implicitly* sets the disabled bitmap, too, subsequent calls, DON'T! - button.SetBitmapDisabled(img.ConvertToDisabled()); //inefficiency: wxBitmap::ConvertToDisabled() implicitly converts to wxImage! + button.SetBitmapDisabled(toBitmapBundle(img.ConvertToDisabled())); //inefficiency: wxBitmap::ConvertToDisabled() implicitly converts to wxImage! +} + + +inline +void setImage(wxStaticBitmap& staticBmp, const wxImage& img) +{ + staticBmp.SetBitmap(toBitmapBundle(img)); } -- cgit