Do not use stipple when drawing text, use solid foreground/background

colour instead.
  Use XSetTile/FillTiled instead of XSetStipple/FillStippled, otherwise
BadMatch errors occur in wxDC::SetBrush.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19162 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Mattia Barbon
2003-02-09 20:21:54 +00:00
parent b64c979322
commit 2b830c41f7

View File

@@ -1105,6 +1105,18 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
int ascent = 0; int ascent = 0;
int slen; int slen;
// Set FillStyle, otherwise X will use current stipple!
XGCValues gcV, gcBackingV;
XGetGCValues ((Display*) m_display, (GC)m_gc, GCFillStyle, &gcV);
XSetFillStyle ((Display*) m_display, (GC) m_gc, FillSolid);
if (m_window && m_window->GetBackingPixmap())
{
XGetGCValues ((Display*) m_display, (GC)m_gcBacking, GCFillStyle,
&gcBackingV );
XSetFillStyle ((Display*) m_display, (GC) m_gcBacking, FillSolid);
}
slen = strlen(text); slen = strlen(text);
if (m_font.Ok()) if (m_font.Ok())
@@ -1213,6 +1225,12 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent, (char*) (const char*) text, slen); XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent, (char*) (const char*) text, slen);
} }
// restore fill style
XSetFillStyle ((Display*) m_display, (GC) m_gc, gcV.fill_style);
if (m_window && m_window->GetBackingPixmap())
XSetFillStyle ((Display*) m_display, (GC) m_gcBacking,
gcBackingV.fill_style);
wxCoord w, h; wxCoord w, h;
GetTextExtent (text, &w, &h); GetTextExtent (text, &w, &h);
CalcBoundingBox (x + w, y + h); CalcBoundingBox (x + w, y + h);
@@ -1872,23 +1890,33 @@ void wxWindowDC::SetBrush( const wxBrush &brush )
(oldBrushColour.Green () == m_currentColour.Green ()) && (oldBrushColour.Green () == m_currentColour.Green ()) &&
(oldBrushColour.GetPixel() == m_currentColour.GetPixel())); (oldBrushColour.GetPixel() == m_currentColour.GetPixel()));
int stippleDepth = -1;
if ((oldFill != m_brush.GetStyle ()) || !GetOptimization()) if ((oldFill != m_brush.GetStyle ()) || !GetOptimization())
{ {
switch (brush.GetStyle ()) switch (brush.GetStyle ())
{ {
case wxTRANSPARENT: case wxTRANSPARENT:
break; break;
case wxSTIPPLE:
stippleDepth = m_currentStipple.GetDepth();
// fall through!
case wxBDIAGONAL_HATCH: case wxBDIAGONAL_HATCH:
case wxCROSSDIAG_HATCH: case wxCROSSDIAG_HATCH:
case wxFDIAGONAL_HATCH: case wxFDIAGONAL_HATCH:
case wxCROSS_HATCH: case wxCROSS_HATCH:
case wxHORIZONTAL_HATCH: case wxHORIZONTAL_HATCH:
case wxVERTICAL_HATCH: case wxVERTICAL_HATCH:
case wxSTIPPLE:
{ {
// Chris Breeze 23/07/97: use background mode to determine whether if (stippleDepth == -1) stippleDepth = 1;
// fill style should be solid or transparent
int style = (m_backgroundMode == wxSOLID ? FillOpaqueStippled : FillStippled); // Chris Breeze 23/07/97: use background mode to
// determine whether fill style should be solid or
// transparent
int style = stippleDepth == 1 ?
(m_backgroundMode == wxSOLID ?
FillOpaqueStippled : FillStippled) :
FillTiled;
XSetFillStyle ((Display*) m_display, (GC) m_gc, style); XSetFillStyle ((Display*) m_display, (GC) m_gc, style);
if (m_window && m_window->GetBackingPixmap()) if (m_window && m_window->GetBackingPixmap())
XSetFillStyle ((Display*) m_display,(GC) m_gcBacking, style); XSetFillStyle ((Display*) m_display,(GC) m_gcBacking, style);
@@ -1898,7 +1926,8 @@ void wxWindowDC::SetBrush( const wxBrush &brush )
default: default:
XSetFillStyle ((Display*) m_display, (GC) m_gc, FillSolid); XSetFillStyle ((Display*) m_display, (GC) m_gc, FillSolid);
if (m_window && m_window->GetBackingPixmap()) if (m_window && m_window->GetBackingPixmap())
XSetFillStyle ((Display*) m_display,(GC) m_gcBacking, FillSolid); XSetFillStyle ((Display*) m_display,(GC) m_gcBacking,
FillSolid);
} }
} }
@@ -1959,11 +1988,25 @@ void wxWindowDC::SetBrush( const wxBrush &brush )
} }
// X can forget the stipple value when resizing a window (apparently) // X can forget the stipple value when resizing a window (apparently)
// so always set the stipple. // so always set the stipple.
else if (m_currentStipple.Ok()) // && m_currentStipple != oldStipple) else if (m_currentFill != wxSOLID && m_currentFill != wxTRANSPARENT &&
m_currentStipple.Ok()) // && m_currentStipple != oldStipple)
{ {
XSetStipple ((Display*) m_display, (GC) m_gc, (Pixmap) m_currentStipple.GetPixmap()); if (m_currentStipple.GetDepth() == 1)
{
XSetStipple ((Display*) m_display, (GC) m_gc,
(Pixmap) m_currentStipple.GetPixmap());
if (m_window && m_window->GetBackingPixmap()) if (m_window && m_window->GetBackingPixmap())
XSetStipple ((Display*) m_display,(GC) m_gcBacking, (Pixmap) m_currentStipple.GetPixmap()); XSetStipple ((Display*) m_display,(GC) m_gcBacking,
(Pixmap) m_currentStipple.GetPixmap());
}
else
{
XSetTile ((Display*) m_display, (GC) m_gc,
(Pixmap) m_currentStipple.GetPixmap());
if (m_window && m_window->GetBackingPixmap())
XSetTile ((Display*) m_display,(GC) m_gcBacking,
(Pixmap) m_currentStipple.GetPixmap());
}
} }
// must test m_logicalFunction, because it involves background! // must test m_logicalFunction, because it involves background!