diff options
author | B. Stack <bgstack15@gmail.com> | 2023-11-27 10:33:00 -0500 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2023-11-27 10:33:00 -0500 |
commit | 2e61b9b6258f29c03cb3b0da48282f3a87590702 (patch) | |
tree | 2be66dfaf965d246ea2df6248c7890208887e6bb /wx+/bitmap_button.h | |
parent | add upstream 13.1 (diff) | |
download | FreeFileSync-2e61b9b6258f29c03cb3b0da48282f3a87590702.tar.gz FreeFileSync-2e61b9b6258f29c03cb3b0da48282f3a87590702.tar.bz2 FreeFileSync-2e61b9b6258f29c03cb3b0da48282f3a87590702.zip |
add upstream 13.213.2
Diffstat (limited to 'wx+/bitmap_button.h')
-rw-r--r-- | wx+/bitmap_button.h | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/wx+/bitmap_button.h b/wx+/bitmap_button.h index bbae6397..a3f160e8 100644 --- a/wx+/bitmap_button.h +++ b/wx+/bitmap_button.h @@ -36,7 +36,7 @@ public: }; //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)); +void setBitmapTextLabel(wxBitmapButton& btn, const wxImage& img, const wxString& text, int gap = dipToWxsize(5), int border = dipToWxsize(5)); //set bitmap label flicker free: void setImage(wxAnyButton& button, const wxImage& bmp); @@ -65,12 +65,12 @@ void setBitmapTextLabel(wxBitmapButton& btn, const wxImage& img, const wxString& wxImage imgTxt = createImageFromText(text, btn.GetFont(), btn.GetForegroundColour()); if (img.IsOk()) imgTxt = btn.GetLayoutDirection() != wxLayout_RightToLeft ? - stackImages(img, imgTxt, ImageStackLayout::horizontal, ImageStackAlignment::center, gap) : - stackImages(imgTxt, img, ImageStackLayout::horizontal, ImageStackAlignment::center, gap); + stackImages(img, imgTxt, ImageStackLayout::horizontal, ImageStackAlignment::center, wxsizeToScreen(gap)) : + stackImages(imgTxt, img, ImageStackLayout::horizontal, ImageStackAlignment::center, wxsizeToScreen(gap)); //SetMinSize() instead of SetSize() is needed here for wxWindows layout determination to work correctly - btn.SetMinSize({imgTxt.GetWidth () + 2 * border, - std::max(imgTxt.GetHeight() + 2 * border, getDefaultButtonHeight())}); + btn.SetMinSize({screenToWxsize(imgTxt.GetWidth()) + 2 * border, + std::max(screenToWxsize(imgTxt.GetHeight()) + 2 * border, getDefaultButtonHeight())}); setImage(btn, imgTxt); } @@ -107,11 +107,12 @@ inline wxImage generatePressedButtonBack(const wxSize& sz) { #if 1 - return rectangleImage(sz, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), {0x11, 0x79, 0xfe} /*light blue*/, fastFromDIP(2)); + return rectangleImage(sz, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), {0x11, 0x79, 0xfe} /*light blue*/, dipToScreen(2)); #else //rectangle border with gradient as background - wxBitmap bmp(sz); //seems we don't need to pass 24-bit depth here even for high-contrast color schemes - bmp.SetScaleFactor(getDisplayScaleFactor()); + wxBitmap bmp(wxsizeToScreen(sz.x), + wxsizeToScreen(sz.y)); //seems we don't need to pass 24-bit depth here even for high-contrast color schemes + bmp.SetScaleFactor(getScreenDpiScale()); { //draw rectangle border with gradient const wxColor colFrom = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE); @@ -120,9 +121,9 @@ wxImage generatePressedButtonBack(const wxSize& sz) wxMemoryDC dc(bmp); dc.SetPen(*wxTRANSPARENT_PEN); //wxTRANSPARENT_PEN is about 2x faster than redundantly drawing with col! - wxRect rect(bmp.GetSize()); + wxRect rect(sz); - const int borderSize = fastFromDIP(3); + const int borderSize = dipToWxsize(3); for (int i = 1 ; i <= borderSize; ++i) { const wxColor colGradient((colFrom.Red () * (borderSize - i) + colTo.Red () * i) / borderSize, @@ -130,7 +131,7 @@ wxImage generatePressedButtonBack(const wxSize& sz) (colFrom.Blue () * (borderSize - i) + colTo.Blue () * i) / borderSize); dc.SetBrush(colGradient); dc.DrawRectangle(rect); - rect.Deflate(1); + rect.Deflate(dipToWxsize(1)); } dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); |