Added translucent stipple brush support under wxQt
This commit is contained in:
parent
f9c2d24bb6
commit
eebb5a587f
2 changed files with 30 additions and 22 deletions
|
|
@ -13,6 +13,7 @@
|
||||||
#include "wx/qt/private/utils.h"
|
#include "wx/qt/private/utils.h"
|
||||||
#include "wx/bitmap.h"
|
#include "wx/bitmap.h"
|
||||||
|
|
||||||
|
#include <QtGui/QBitmap>
|
||||||
#include <QtGui/QBrush>
|
#include <QtGui/QBrush>
|
||||||
|
|
||||||
wxIMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject);
|
wxIMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject);
|
||||||
|
|
@ -76,11 +77,34 @@ public:
|
||||||
|
|
||||||
void DoSetStipple(const wxBitmap& stipple)
|
void DoSetStipple(const wxBitmap& stipple)
|
||||||
{
|
{
|
||||||
m_qtBrush.setTexture(*stipple.GetHandle());
|
|
||||||
if (stipple.GetMask() != nullptr)
|
|
||||||
m_style = wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE;
|
|
||||||
else
|
|
||||||
m_style = wxBRUSHSTYLE_STIPPLE;
|
m_style = wxBRUSHSTYLE_STIPPLE;
|
||||||
|
|
||||||
|
if ( !stipple.GetMask() && stipple.GetDepth() == 32 )
|
||||||
|
{
|
||||||
|
m_qtBrush.setTextureImage(stipple.GetHandle()->toImage());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( stipple.GetMask() || stipple.GetDepth() == 1 )
|
||||||
|
{
|
||||||
|
auto pixmap = stipple.GetMask() ? stipple.GetMask()->GetBitmap().GetHandle()
|
||||||
|
: stipple.GetHandle();
|
||||||
|
m_qtBrush.setTexture(*pixmap);
|
||||||
|
m_style = wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_qtBrush.setTexture(*stipple.GetHandle());
|
||||||
|
|
||||||
|
// Note: This code used to be in wxQtDCImpl::SetBrush().
|
||||||
|
// But, do we really need to do it ?
|
||||||
|
|
||||||
|
//Don't use the mask
|
||||||
|
QPixmap p = m_qtBrush.texture();
|
||||||
|
p.setMask(QBitmap());
|
||||||
|
m_qtBrush.setTexture(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator == (const wxBrushRefData& data) const
|
bool operator == (const wxBrushRefData& data) const
|
||||||
|
|
|
||||||
|
|
@ -194,26 +194,10 @@ void wxQtDCImpl::SetBrush(const wxBrush& brush)
|
||||||
if (brush.GetStyle() == wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE)
|
if (brush.GetStyle() == wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE)
|
||||||
{
|
{
|
||||||
// Use a monochrome mask: use foreground color for the mask
|
// Use a monochrome mask: use foreground color for the mask
|
||||||
QBrush b(brush.GetHandle());
|
m_brush.SetColour(m_textForegroundColour);
|
||||||
b.setColor(m_textForegroundColour.GetQColor());
|
|
||||||
b.setTexture(b.texture().mask());
|
|
||||||
m_qtPainter->setBrush(b);
|
|
||||||
}
|
}
|
||||||
else if (brush.GetStyle() == wxBRUSHSTYLE_STIPPLE)
|
|
||||||
{
|
|
||||||
//Don't use the mask
|
|
||||||
QBrush b(brush.GetHandle());
|
|
||||||
|
|
||||||
QPixmap p = b.texture();
|
m_qtPainter->setBrush(m_brush.GetHandle());
|
||||||
p.setMask(QBitmap());
|
|
||||||
b.setTexture(p);
|
|
||||||
|
|
||||||
m_qtPainter->setBrush(b);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_qtPainter->setBrush(brush.GetHandle());
|
|
||||||
}
|
|
||||||
|
|
||||||
ApplyRasterColourOp();
|
ApplyRasterColourOp();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue