Change wxBitmap to wxBitmapBundle in wxBannerWindow

This commit is contained in:
Alexander Koshelev 2022-01-14 16:12:02 +03:00 committed by Vadim Zeitlin
parent 85becc9362
commit 2b94729a33
3 changed files with 18 additions and 18 deletions

View File

@ -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().

View File

@ -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.

View File

@ -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;