]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/brush.cpp
another segfault fix
[wxWidgets.git] / src / msw / brush.cpp
index 9c33fc9eddd345af0dac585414b1ce0023646fba..66206940e6eeb252df6dd25eb9ab459d4945eff5 100644 (file)
@@ -33,9 +33,7 @@
 
 #include "assert.h"
 
-#if !USE_SHARED_LIBRARIES
 IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
-#endif
 
 wxBrushRefData::wxBrushRefData(void)
 {
@@ -60,14 +58,10 @@ wxBrushRefData::~wxBrushRefData(void)
 // Brushes
 wxBrush::wxBrush(void)
 {
-  if ( wxTheBrushList )
-    wxTheBrushList->AddBrush(this);
 }
 
 wxBrush::~wxBrush()
 {
-    if (wxTheBrushList)
-        wxTheBrushList->RemoveBrush(this);
 }
 
 wxBrush::wxBrush(const wxColour& col, int Style)
@@ -80,25 +74,25 @@ wxBrush::wxBrush(const wxColour& col, int Style)
 
   RealizeResource();
 
-  if ( wxTheBrushList )
-    wxTheBrushList->AddBrush(this);
 }
 
 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();
 
-  if ( wxTheBrushList )
-    wxTheBrushList->AddBrush(this);
 }
 
-bool wxBrush::RealizeResource(void) 
+bool wxBrush::RealizeResource(void)
 {
   if (M_BRUSHDATA && (M_BRUSHDATA->m_hBrush == 0))
   {
@@ -125,6 +119,7 @@ bool wxBrush::RealizeResource(void)
                       // - could choose white always for a quick solution
       break;
 ***/
+#ifndef __WXMICROWIN__
       case wxBDIAGONAL_HATCH:
         M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateHatchBrush(HS_BDIAGONAL,ms_colour) ;
         break ;
@@ -149,6 +144,13 @@ 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 ;
+#endif
       case wxSOLID:
       default:
         M_BRUSHDATA->m_hBrush = (WXHBRUSH) CreateSolidBrush(ms_colour) ;
@@ -179,7 +181,7 @@ bool wxBrush::FreeResource(bool WXUNUSED(force))
   else return FALSE;
 }
 
-bool wxBrush::IsFree(void)
+bool wxBrush::IsFree() const
 {
   return (M_BRUSHDATA && (M_BRUSHDATA->m_hBrush == 0));
 }
@@ -232,6 +234,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();
 }