From 2b94729a33db549569cd7802f0eef6b8afdd400d Mon Sep 17 00:00:00 2001 From: Alexander Koshelev Date: Fri, 14 Jan 2022 16:12:02 +0300 Subject: [PATCH] Change wxBitmap to wxBitmapBundle in wxBannerWindow --- include/wx/bannerwindow.h | 7 +++---- interface/wx/bannerwindow.h | 2 +- src/generic/bannerwindow.cpp | 27 ++++++++++++++------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/wx/bannerwindow.h b/include/wx/bannerwindow.h index a10f7e1532..6c9ac86f0e 100644 --- a/include/wx/bannerwindow.h +++ b/include/wx/bannerwindow.h @@ -14,11 +14,10 @@ #if wxUSE_BANNERWINDOW -#include "wx/bitmap.h" +#include "wx/bmpbndl.h" #include "wx/event.h" #include "wx/window.h" -class WXDLLIMPEXP_FWD_CORE wxBitmap; class WXDLLIMPEXP_FWD_CORE wxColour; class WXDLLIMPEXP_FWD_CORE wxDC; @@ -75,7 +74,7 @@ public: // truncated from the top, for wxTOP and wxBOTTOM -- from the right and for // wxRIGHT -- from the bottom, so put the most important part of the bitmap // information in the opposite direction. - void SetBitmap(const wxBitmap& bmp); + void SetBitmap(const wxBitmapBundle& bmp); // Set the text to display. This is mutually exclusive with SetBitmap(). // Title is rendered in bold and should be single line, message can have @@ -120,7 +119,7 @@ private: wxDirection m_direction; // If valid, this bitmap is drawn as is. - wxBitmap m_bitmap; + wxBitmapBundle m_bitmapBundle; // If bitmap is valid, this is the colour we use to extend it if the bitmap // is smaller than this window. It is computed on demand by GetBitmapBg(). diff --git a/interface/wx/bannerwindow.h b/interface/wx/bannerwindow.h index ca5454610a..0dd5405f63 100644 --- a/interface/wx/bannerwindow.h +++ b/interface/wx/bannerwindow.h @@ -134,7 +134,7 @@ public: @param bmp Bitmap to use as background. May be invalid to indicate that no background bitmap should be used. */ - void SetBitmap(const wxBitmap& bmp); + void SetBitmap(const wxBitmapBundle& bmp); /** Set the text to display. diff --git a/src/generic/bannerwindow.cpp b/src/generic/bannerwindow.cpp index 85e0164b1c..c942a785c6 100644 --- a/src/generic/bannerwindow.cpp +++ b/src/generic/bannerwindow.cpp @@ -71,9 +71,9 @@ wxBannerWindow::Create(wxWindow* parent, return true; } -void wxBannerWindow::SetBitmap(const wxBitmap& bmp) +void wxBannerWindow::SetBitmap(const wxBitmapBundle& bmp) { - m_bitmap = bmp; + m_bitmapBundle = bmp; m_colBitmapBg = wxColour(); @@ -109,9 +109,9 @@ wxFont wxBannerWindow::GetTitleFont() const wxSize wxBannerWindow::DoGetBestClientSize() const { - if ( m_bitmap.IsOk() ) + if ( m_bitmapBundle.IsOk() ) { - return m_bitmap.GetSize(); + return m_bitmapBundle.GetPreferredLogicalSizeFor(this); } else { @@ -143,7 +143,7 @@ void wxBannerWindow::OnSize(wxSizeEvent& event) void wxBannerWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) { - if ( m_bitmap.IsOk() && m_title.empty() && m_message.empty() ) + if ( m_bitmapBundle.IsOk() && m_title.empty() && m_message.empty() ) { // No need for buffering in this case. wxPaintDC dc(this); @@ -155,7 +155,7 @@ void wxBannerWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) wxAutoBufferedPaintDC dc(this); // Deal with the background first. - if ( m_bitmap.IsOk() ) + if ( m_bitmapBundle.IsOk() ) { DrawBitmapBackground(dc); } @@ -207,7 +207,7 @@ wxColour wxBannerWindow::GetBitmapBg() // Determine the colour to use to extend the bitmap. It's the colour of the // bitmap pixels at the edge closest to the area where it can be extended. - wxImage image(m_bitmap.ConvertToImage()); + wxImage image(m_bitmapBundle.GetBitmapFor(this).ConvertToImage()); // The point we get the colour from. The choice is arbitrary and in general // the bitmap should have the same colour on the entire edge of this point @@ -260,6 +260,7 @@ void wxBannerWindow::DrawBitmapBackground(wxDC& dc) wxRect rectSolid; const wxSize size = GetClientSize(); + const wxBitmap currentBitmap = m_bitmapBundle.GetBitmapFor(this); switch ( m_direction ) { @@ -267,9 +268,9 @@ void wxBannerWindow::DrawBitmapBackground(wxDC& dc) case wxBOTTOM: // Draw the bitmap at the origin, its rightmost could be truncated, // as it's meant to be. - dc.DrawBitmap(m_bitmap, 0, 0); + dc.DrawBitmap(currentBitmap, 0, 0); - rectSolid.x = m_bitmap.GetWidth(); + rectSolid.x = currentBitmap.GetLogicalWidth(); rectSolid.width = size.x - rectSolid.x; rectSolid.height = size.y; break; @@ -279,16 +280,16 @@ void wxBannerWindow::DrawBitmapBackground(wxDC& dc) // must be always visible so intentionally draw it possibly partly // outside of the window. rectSolid.width = size.x; - rectSolid.height = size.y - m_bitmap.GetHeight(); - dc.DrawBitmap(m_bitmap, 0, rectSolid.height); + rectSolid.height = size.y - currentBitmap.GetLogicalHeight(); + dc.DrawBitmap(currentBitmap, 0, rectSolid.height); break; case wxRIGHT: // Draw the bitmap at the origin, possibly truncating its // bottommost part. - dc.DrawBitmap(m_bitmap, 0, 0); + dc.DrawBitmap(currentBitmap, 0, 0); - rectSolid.y = m_bitmap.GetHeight(); + rectSolid.y = currentBitmap.GetLogicalHeight(); rectSolid.height = size.y - rectSolid.y; rectSolid.width = size.x; break;