patches for wxSTIPPLE_MASK_OPAQUE from Klass Holwerda

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5634 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-01-24 15:58:33 +00:00
parent bf3dab485a
commit de2d2cdc86
7 changed files with 166 additions and 16 deletions

View File

@@ -1316,6 +1316,8 @@ enum {
// Brush & Pen Stippling. Note that a stippled pen cannot be dashed!!
// Note also that stippling a Pen IS meaningfull, because a Line is
wxSTIPPLE_MASK_OPAQUE, //mask is used for blitting monochrome using text fore and back ground colors
wxSTIPPLE_MASK, //mask is used for masking areas in the stipple bitmap (TO DO)
// drawn with a Pen, and without any Brush -- and it can be stippled.
wxSTIPPLE = 110,
wxBDIAGONAL_HATCH,

View File

@@ -65,9 +65,16 @@ wxBrush::wxBrush( const wxColour &colour, int style )
wxBrush::wxBrush( const wxBitmap &stippleBitmap )
{
m_refData = new wxBrushRefData();
M_BRUSHDATA->m_style = wxSTIPPLE;
M_BRUSHDATA->m_colour = *wxBLACK;
M_BRUSHDATA->m_stipple = stippleBitmap;
if (M_BRUSHDATA->m_stipple.GetMask())
{
M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
}
else
{
M_BRUSHDATA->m_style = wxSTIPPLE;
}
if (wxTheBrushList) wxTheBrushList->AddBrush( this );
}
@@ -161,6 +168,14 @@ void wxBrush::SetStipple( const wxBitmap& stipple )
{
Unshare();
M_BRUSHDATA->m_stipple = stipple;
if (M_BRUSHDATA->m_stipple.GetMask())
{
M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
}
else
{
M_BRUSHDATA->m_style = wxSTIPPLE;
}
}
void wxBrush::Unshare()

View File

@@ -339,8 +339,16 @@ void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], wxCoord xoffset, wxCoor
CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset );
}
if ((m_brush.GetStyle() != wxTRANSPARENT) && m_window)
if (m_window)
{
if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
gdk_draw_polygon (m_window, m_textGC, TRUE, gdkpoints, n);
else
{
if ((m_brush.GetStyle() != wxTRANSPARENT))
gdk_draw_polygon (m_window, m_brushGC, TRUE, gdkpoints, n);
}
}
// To do: Fillstyle
@@ -376,6 +384,13 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h
if (hh < 0) { hh = -hh; yy = yy - hh; }
if (m_window)
{
if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
{
gdk_draw_rectangle( m_window, m_textGC, TRUE, xx, yy, ww, hh );
gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 );
}
else
{
if (m_brush.GetStyle() != wxTRANSPARENT)
gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh );
@@ -383,6 +398,7 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h
if (m_pen.GetStyle() != wxTRANSPARENT)
gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 );
}
}
CalcBoundingBox( x, y );
CalcBoundingBox( x + width, y + height );
@@ -1083,6 +1099,7 @@ void wxWindowDC::SetPen( const wxPen &pen )
}
case wxTRANSPARENT:
case wxSTIPPLE_MASK_OPAQUE:
case wxSTIPPLE:
case wxSOLID:
default:
@@ -1166,6 +1183,12 @@ void wxWindowDC::SetBrush( const wxBrush &brush )
}
}
if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
{
gdk_gc_set_fill( m_textGC, GDK_OPAQUE_STIPPLED);
gdk_gc_set_stipple( m_textGC, m_brush.GetStipple()->GetMask()->GetBitmap() );
}
if (IS_HATCH(m_brush.GetStyle()))
{
gdk_gc_set_fill( m_brushGC, GDK_STIPPLED );

View File

@@ -65,9 +65,16 @@ wxBrush::wxBrush( const wxColour &colour, int style )
wxBrush::wxBrush( const wxBitmap &stippleBitmap )
{
m_refData = new wxBrushRefData();
M_BRUSHDATA->m_style = wxSTIPPLE;
M_BRUSHDATA->m_colour = *wxBLACK;
M_BRUSHDATA->m_stipple = stippleBitmap;
if (M_BRUSHDATA->m_stipple.GetMask())
{
M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
}
else
{
M_BRUSHDATA->m_style = wxSTIPPLE;
}
if (wxTheBrushList) wxTheBrushList->AddBrush( this );
}
@@ -161,6 +168,14 @@ void wxBrush::SetStipple( const wxBitmap& stipple )
{
Unshare();
M_BRUSHDATA->m_stipple = stipple;
if (M_BRUSHDATA->m_stipple.GetMask())
{
M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
}
else
{
M_BRUSHDATA->m_style = wxSTIPPLE;
}
}
void wxBrush::Unshare()

View File

@@ -339,8 +339,16 @@ void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], wxCoord xoffset, wxCoor
CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset );
}
if ((m_brush.GetStyle() != wxTRANSPARENT) && m_window)
if (m_window)
{
if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
gdk_draw_polygon (m_window, m_textGC, TRUE, gdkpoints, n);
else
{
if ((m_brush.GetStyle() != wxTRANSPARENT))
gdk_draw_polygon (m_window, m_brushGC, TRUE, gdkpoints, n);
}
}
// To do: Fillstyle
@@ -376,6 +384,13 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h
if (hh < 0) { hh = -hh; yy = yy - hh; }
if (m_window)
{
if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
{
gdk_draw_rectangle( m_window, m_textGC, TRUE, xx, yy, ww, hh );
gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 );
}
else
{
if (m_brush.GetStyle() != wxTRANSPARENT)
gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh );
@@ -383,6 +398,7 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h
if (m_pen.GetStyle() != wxTRANSPARENT)
gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 );
}
}
CalcBoundingBox( x, y );
CalcBoundingBox( x + width, y + height );
@@ -1083,6 +1099,7 @@ void wxWindowDC::SetPen( const wxPen &pen )
}
case wxTRANSPARENT:
case wxSTIPPLE_MASK_OPAQUE:
case wxSTIPPLE:
case wxSOLID:
default:
@@ -1166,6 +1183,12 @@ void wxWindowDC::SetBrush( const wxBrush &brush )
}
}
if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
{
gdk_gc_set_fill( m_textGC, GDK_OPAQUE_STIPPLED);
gdk_gc_set_stipple( m_textGC, m_brush.GetStipple()->GetMask()->GetBitmap() );
}
if (IS_HATCH(m_brush.GetStyle()))
{
gdk_gc_set_fill( m_brushGC, GDK_STIPPLED );

View File

@@ -86,8 +86,12 @@ wxBrush::wxBrush(const wxBitmap& stipple)
{
m_refData = new wxBrushRefData;
M_BRUSHDATA->m_style = wxSTIPPLE;
M_BRUSHDATA->m_stipple = stipple;
if (M_BRUSHDATA->m_stipple.GetMask())
M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
else
M_BRUSHDATA->m_style = wxSTIPPLE;
M_BRUSHDATA->m_hBrush = 0;
RealizeResource();
@@ -147,6 +151,12 @@ bool wxBrush::RealizeResource(void)
else
M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateSolidBrush(ms_colour) ;
break ;
case wxSTIPPLE_MASK_OPAQUE:
if (M_BRUSHDATA->m_stipple.Ok() && M_BRUSHDATA->m_stipple.GetMask())
M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreatePatternBrush((HBITMAP) M_BRUSHDATA->m_stipple.GetMask()->GetMaskBitmap());
else
M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateSolidBrush(ms_colour) ;
break ;
case wxSOLID:
default:
M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateSolidBrush(ms_colour) ;
@@ -230,6 +240,10 @@ void wxBrush::SetStipple(const wxBitmap& Stipple)
Unshare();
M_BRUSHDATA->m_stipple = Stipple;
if (M_BRUSHDATA->m_stipple.GetMask())
M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
else
M_BRUSHDATA->m_style = wxSTIPPLE;
RealizeResource();
}

View File

@@ -405,6 +405,28 @@ void wxDC::DoDrawPoint(wxCoord x, wxCoord y)
void wxDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,int fillStyle)
{
COLORREF old_textground = ::GetTextColor(GetHdc());
COLORREF old_background = ::GetBkColor(GetHdc());
if (m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE)
{
if (m_textForegroundColour.Ok())
{ //just the oposite from what is expected see help on pattern brush
// 1 in mask becomes bk color
::SetBkColor(GetHdc(), m_textForegroundColour.GetPixel() );
}
if (m_textBackgroundColour.Ok())
{ //just the oposite from what is expected
// 0 in mask becomes text color
::SetTextColor(GetHdc(), m_textBackgroundColour.GetPixel() );
}
if (m_backgroundMode == wxTRANSPARENT)
SetBkMode(GetHdc(), TRANSPARENT);
else
SetBkMode(GetHdc(), OPAQUE);
}
// Do things less efficiently if we have offsets
if (xoffset != 0 || yoffset != 0)
{
@@ -432,6 +454,13 @@ void wxDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffs
(void)Polygon(GetHdc(), (POINT*) points, n);
SetPolyFillMode(GetHdc(),prev);
}
if (m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE)
{
::SetBkMode(GetHdc(), TRANSPARENT);
::SetTextColor(GetHdc(), old_textground);
::SetBkColor(GetHdc(), old_background);
}
}
void wxDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
@@ -463,6 +492,28 @@ void wxDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset
void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
COLORREF old_textground = ::GetTextColor(GetHdc());
COLORREF old_background = ::GetBkColor(GetHdc());
if (m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE)
{
if (m_textForegroundColour.Ok())
{ //just the oposite from what is expected see help on pattern brush
// 1 in mask becomes bk color
::SetBkColor(GetHdc(), m_textForegroundColour.GetPixel() );
}
if (m_textBackgroundColour.Ok())
{ //just the oposite from what is expected
// 0 in mask becomes text color
::SetTextColor(GetHdc(), m_textBackgroundColour.GetPixel() );
}
if (m_backgroundMode == wxTRANSPARENT)
SetBkMode(GetHdc(), TRANSPARENT);
else
SetBkMode(GetHdc(), OPAQUE);
}
wxCoord x2 = x + width;
wxCoord y2 = y + height;
@@ -503,6 +554,13 @@ void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
CalcBoundingBox(x, y);
CalcBoundingBox(x2, y2);
if (m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE)
{
::SetBkMode(GetHdc(), TRANSPARENT);
::SetTextColor(GetHdc(), old_textground);
::SetBkColor(GetHdc(), old_background);
}
}
void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)