From 7c855d11f23dc03d64a0099473a95402f3175280 Mon Sep 17 00:00:00 2001 From: B Stack Date: Tue, 15 Jan 2019 08:16:08 -0500 Subject: 10.8 --- wx+/bitmap_button.h | 10 ++++------ wx+/image_tools.h | 12 ++++++++---- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'wx+') diff --git a/wx+/bitmap_button.h b/wx+/bitmap_button.h index dc7615c1..738a62ff 100755 --- a/wx+/bitmap_button.h +++ b/wx+/bitmap_button.h @@ -29,6 +29,7 @@ public: wxBitmapButton(parent, id, wxNullBitmap, pos, size, style | wxBU_AUTODRAW, validator, name) { SetLabel(label); } }; +//wxButton::SetBitmap() also supports "image + text", but screws up proper gap and border handling void setBitmapTextLabel(wxBitmapButton& btn, const wxImage& img, const wxString& text, int gap = fastFromDIP(5), int border = fastFromDIP(5)); //set bitmap label flicker free: @@ -54,12 +55,9 @@ void setBitmapTextLabel(wxBitmapButton& btn, const wxImage& img, const wxString& wxImage dynImage = createImageFromText(text, btn.GetFont(), btn.GetForegroundColour()); if (img.IsOk()) - { - if (btn.GetLayoutDirection() != wxLayout_RightToLeft) - dynImage = stackImages(img, dynImage, ImageStackLayout::HORIZONTAL, ImageStackAlignment::CENTER, gap); - else - dynImage = stackImages(dynImage, img, ImageStackLayout::HORIZONTAL, ImageStackAlignment::CENTER, gap); - } + dynImage = btn.GetLayoutDirection() != wxLayout_RightToLeft ? + stackImages(img, dynImage, ImageStackLayout::HORIZONTAL, ImageStackAlignment::CENTER, gap) : + stackImages(dynImage, img, ImageStackLayout::HORIZONTAL, ImageStackAlignment::CENTER, gap); //SetMinSize() instead of SetSize() is needed here for wxWindows layout determination to work corretly const int defaultHeight = wxButton::GetDefaultSize().GetHeight(); diff --git a/wx+/image_tools.h b/wx+/image_tools.h index 06d7f0ba..bef4cb67 100755 --- a/wx+/image_tools.h +++ b/wx+/image_tools.h @@ -53,10 +53,14 @@ void convertToVanillaImage(wxImage& img); //add alpha channel if missing + remov //wxColor hsvColor(double h, double s, double v); //h within [0, 360), s, v within [0, 1] - - - - +inline +wxImage getTransparentPixel() +{ + wxImage dummyImage(1, 1); + dummyImage.SetAlpha(); + ::memset(dummyImage.GetAlpha(), 1 /*opacity*/, 1 * 1); //suprise: can't use wxIMAGE_ALPHA_TRANSPARENT(0), painted black on Windows! + return dummyImage; +} -- cgit