]> git.saurik.com Git - wxWidgets.git/commitdiff
patches for wxSTIPPLE_MASK_OPAQUE from Klass Holwerda
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 24 Jan 2000 15:58:33 +0000 (15:58 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 24 Jan 2000 15:58:33 +0000 (15:58 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5634 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/defs.h
src/gtk/brush.cpp
src/gtk/dcclient.cpp
src/gtk1/brush.cpp
src/gtk1/dcclient.cpp
src/msw/brush.cpp
src/msw/dc.cpp

index 537a400f884a36720c512133d9d95780d04d7e10..e717c38ff2c18f906ad9659a637cfd2d8451a65c 100644 (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,
index 2f945402ce47202fb9a70cdabc1bd1c1cffdc481..ca0987080c1b7503d8e0ed4e123f0a7a88442cb0 100644 (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()
index 5b39956468b3cb5d1fb802fc324188f63e574cb1..383dc186bd4843ff2d5e78104193e649d3b6ed9e 100644 (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)
-        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
 
@@ -377,11 +385,19 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h
 
     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 );
@@ -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 );
index 2f945402ce47202fb9a70cdabc1bd1c1cffdc481..ca0987080c1b7503d8e0ed4e123f0a7a88442cb0 100644 (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()
index 5b39956468b3cb5d1fb802fc324188f63e574cb1..383dc186bd4843ff2d5e78104193e649d3b6ed9e 100644 (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)
-        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
 
@@ -377,11 +385,19 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h
 
     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 );
@@ -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 );
index 7e107855c927f359167757ad11f125f5ad95febe..825410a28bdf161b3c5a9d5bac59ce72b3d584af 100644 (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();
@@ -96,7 +100,7 @@ wxBrush::wxBrush(const wxBitmap& stipple)
     wxTheBrushList->AddBrush(this);
 }
 
-bool wxBrush::RealizeResource(void) 
+bool wxBrush::RealizeResource(void)
 {
   if (M_BRUSHDATA && (M_BRUSHDATA->m_hBrush == 0))
   {
@@ -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();
 }
index c280a0573ad35dd7d72d9ad55dc6e761fb88de3e..0a325c7bdd52b46adea9b9f8fb8d3518676fbe6e 100644 (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)