diff options
author | B. Stack <bgstack15@gmail.com> | 2022-04-18 09:47:11 -0400 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2022-04-18 09:47:40 -0400 |
commit | b4b2e4a096fe8fe1ad530a4c181729be05834595 (patch) | |
tree | 84e67ca0a1fb045a12d015fcffca9cd8087c9332 /wx+/bitmap_button.h | |
parent | Merge branch 'b11.18' into 'master' (diff) | |
download | FreeFileSync-b4b2e4a096fe8fe1ad530a4c181729be05834595.tar.gz FreeFileSync-b4b2e4a096fe8fe1ad530a4c181729be05834595.tar.bz2 FreeFileSync-b4b2e4a096fe8fe1ad530a4c181729be05834595.zip |
add upstream 11.20
Diffstat (limited to 'wx+/bitmap_button.h')
-rw-r--r-- | wx+/bitmap_button.h | 21 |
1 files changed, 14 insertions, 7 deletions
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 <wx/bmpbuttn.h> #include <wx/settings.h> +#include <wx/statbmp.h> #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)); } |