// 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,
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 );
}
{
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()
CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset );
}
- if ((m_brush.GetStyle() != wxTRANSPARENT) && m_window)
- gdk_draw_polygon (m_window, m_brushGC, TRUE, gdkpoints, n);
+ 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
if (m_window)
{
- if (m_brush.GetStyle() != wxTRANSPARENT)
- gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh );
-
- if (m_pen.GetStyle() != wxTRANSPARENT)
- gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 );
+ 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 );
+
+ if (m_pen.GetStyle() != wxTRANSPARENT)
+ gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 );
+ }
}
CalcBoundingBox( x, y );
}
case wxTRANSPARENT:
+ case wxSTIPPLE_MASK_OPAQUE:
case wxSTIPPLE:
case wxSOLID:
default:
}
}
+ 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 );
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 );
}
{
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()
CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset );
}
- if ((m_brush.GetStyle() != wxTRANSPARENT) && m_window)
- gdk_draw_polygon (m_window, m_brushGC, TRUE, gdkpoints, n);
+ 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
if (m_window)
{
- if (m_brush.GetStyle() != wxTRANSPARENT)
- gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh );
-
- if (m_pen.GetStyle() != wxTRANSPARENT)
- gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 );
+ 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 );
+
+ if (m_pen.GetStyle() != wxTRANSPARENT)
+ gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 );
+ }
}
CalcBoundingBox( x, y );
}
case wxTRANSPARENT:
+ case wxSTIPPLE_MASK_OPAQUE:
case wxSTIPPLE:
case wxSOLID:
default:
}
}
+ 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 );
{
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();
wxTheBrushList->AddBrush(this);
}
-bool wxBrush::RealizeResource(void)
+bool wxBrush::RealizeResource(void)
{
if (M_BRUSHDATA && (M_BRUSHDATA->m_hBrush == 0))
{
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) ;
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();
}
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)
{
(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)
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;
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)