Use wxBitmapBundle in wxHtmlWindow

This commit is contained in:
Alexander Koshelev
2022-02-11 16:16:45 +03:00
parent f0c6b42ad0
commit 7a2a1e9074
5 changed files with 17 additions and 13 deletions

View File

@@ -21,7 +21,7 @@
#include "wx/filesys.h"
#include "wx/html/htmlfilt.h"
#include "wx/filename.h"
#include "wx/bitmap.h"
#include "wx/bmpbndl.h"
class wxHtmlProcessor;
class wxHtmlWinModule;
@@ -106,7 +106,7 @@ public:
virtual void SetHTMLBackgroundColour(const wxColour& clr) = 0;
/// Sets window's background to given bitmap.
virtual void SetHTMLBackgroundImage(const wxBitmap& bmpBg) = 0;
virtual void SetHTMLBackgroundImage(const wxBitmapBundle& bmpBg) = 0;
/// Sets status bar text.
virtual void SetHTMLStatusText(const wxString& text) = 0;
@@ -315,7 +315,7 @@ public:
// Sets the bitmap to use for background (currnetly it will be tiled,
// when/if we have CSS support we could add other possibilities...)
void SetBackgroundImage(const wxBitmap& bmpBg) { m_bmpBg = bmpBg; }
void SetBackgroundImage(const wxBitmapBundle& bmpBg) { m_bmpBg = bmpBg; }
#if wxUSE_CONFIG
// Saves custom settings into cfg config. it will use the path 'path'
@@ -460,7 +460,7 @@ public:
virtual wxWindow* GetHTMLWindow() wxOVERRIDE;
virtual wxColour GetHTMLBackgroundColour() const wxOVERRIDE;
virtual void SetHTMLBackgroundColour(const wxColour& clr) wxOVERRIDE;
virtual void SetHTMLBackgroundImage(const wxBitmap& bmpBg) wxOVERRIDE;
virtual void SetHTMLBackgroundImage(const wxBitmapBundle& bmpBg) wxOVERRIDE;
virtual void SetHTMLStatusText(const wxString& text) wxOVERRIDE;
virtual wxCursor GetHTMLCursor(HTMLCursor type) const wxOVERRIDE;
@@ -523,7 +523,7 @@ private:
wxBitmap m_backBuffer;
// background image, may be invalid
wxBitmap m_bmpBg;
wxBitmapBundle m_bmpBg;
// variables used when user is selecting text
wxPoint m_tmpSelFromPos;

View File

@@ -145,7 +145,7 @@ private:
virtual wxWindow* GetHTMLWindow() wxOVERRIDE;
virtual wxColour GetHTMLBackgroundColour() const wxOVERRIDE;
virtual void SetHTMLBackgroundColour(const wxColour& clr) wxOVERRIDE;
virtual void SetHTMLBackgroundImage(const wxBitmap& bmpBg) wxOVERRIDE;
virtual void SetHTMLBackgroundImage(const wxBitmapBundle& bmpBg) wxOVERRIDE;
virtual void SetHTMLStatusText(const wxString& text) wxOVERRIDE;
virtual wxCursor GetHTMLCursor(HTMLCursor type) const wxOVERRIDE;

View File

@@ -83,7 +83,7 @@ public:
virtual void SetHTMLBackgroundColour(const wxColour& clr) = 0;
/// Sets window's background to given bitmap.
virtual void SetHTMLBackgroundImage(const wxBitmap& bmpBg) = 0;
virtual void SetHTMLBackgroundImage(const wxBitmapBundle& bmpBg) = 0;
/// Sets status bar text.
virtual void SetHTMLStatusText(const wxString& text) = 0;

View File

@@ -488,7 +488,7 @@ void wxHtmlListBox::SetHTMLBackgroundColour(const wxColour& WXUNUSED(clr))
// nothing to do
}
void wxHtmlListBox::SetHTMLBackgroundImage(const wxBitmap& WXUNUSED(bmpBg))
void wxHtmlListBox::SetHTMLBackgroundImage(const wxBitmapBundle& WXUNUSED(bmpBg))
{
// nothing to do
}

View File

@@ -1045,25 +1045,27 @@ void wxHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link)
void wxHtmlWindow::DoEraseBackground(wxDC& dc)
{
wxBitmap bmp = m_bmpBg.GetBitmapFor(this);
// if we don't have any background bitmap we just fill it with background
// colour and we also must do it if the background bitmap is not fully
// opaque as otherwise junk could be left there
if ( !m_bmpBg.IsOk() || m_bmpBg.GetMask() )
if ( !bmp.IsOk() || bmp.GetMask() )
{
dc.SetBackground(GetBackgroundColour());
dc.Clear();
}
if ( m_bmpBg.IsOk() )
if ( bmp.IsOk() )
{
// draw the background bitmap tiling it over the entire window area
const wxSize sz = GetVirtualSize();
const wxSize sizeBmp(m_bmpBg.GetWidth(), m_bmpBg.GetHeight());
const wxSize sizeBmp(bmp.GetLogicalWidth(), bmp.GetLogicalHeight());
for ( wxCoord x = 0; x < sz.x; x += sizeBmp.x )
{
for ( wxCoord y = 0; y < sz.y; y += sizeBmp.y )
{
dc.DrawBitmap(m_bmpBg, x, y, true /* use mask */);
dc.DrawBitmap(bmp, x, y, true /* use mask */);
}
}
}
@@ -1321,7 +1323,9 @@ void wxHtmlWindow::OnSize(wxSizeEvent& event)
void wxHtmlWindow::OnDPIChanged(wxDPIChangedEvent& WXUNUSED(event))
{
wxBitmapBundle bmpBg = m_bmpBg;
DoSetPage(*(m_Parser->GetSource()));
SetBackgroundImage(bmpBg);
}
void wxHtmlWindow::OnMouseMove(wxMouseEvent& WXUNUSED(event))
@@ -1827,7 +1831,7 @@ void wxHtmlWindow::SetHTMLBackgroundColour(const wxColour& clr)
SetBackgroundColour(clr);
}
void wxHtmlWindow::SetHTMLBackgroundImage(const wxBitmap& bmpBg)
void wxHtmlWindow::SetHTMLBackgroundImage(const wxBitmapBundle& bmpBg)
{
SetBackgroundImage(bmpBg);
}