]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/rgncmn.cpp
Hardware defines spec.
[wxWidgets.git] / src / common / rgncmn.cpp
index c192366f293ae8afeeb84096da81819d65c42bc0..2368fbc13376581da968c9e7a21156a6a19abe34 100644 (file)
@@ -9,7 +9,7 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
 #pragma implementation "rgncmn.h"
 #endif
 
 #pragma implementation "rgncmn.h"
 #endif
 
@@ -23,7 +23,9 @@
 
 #include "wx/region.h"
 #include "wx/bitmap.h"
 
 #include "wx/region.h"
 #include "wx/bitmap.h"
+#if wxUSE_IMAGE
 #include "wx/image.h"
 #include "wx/image.h"
+#endif
 #include "wx/dcmemory.h"
 
 
 #include "wx/dcmemory.h"
 
 
@@ -48,32 +50,16 @@ wxBitmap wxRegion::ConvertToBitmap() const
 
 //---------------------------------------------------------------------------
 
 
 //---------------------------------------------------------------------------
 
-bool wxRegion::Union(const wxBitmap& bmp,
-                     const wxColour& transColour,
-                     int   tolerance)
+#if wxUSE_IMAGE
+static bool DoRegionUnion(wxRegion& region,
+                          const wxImage& image,
+                          unsigned char loR,
+                          unsigned char loG,
+                          unsigned char loB,
+                          int tolerance)
 {
 {
-    unsigned char loR, loG, loB;
     unsigned char hiR, hiG, hiB;
 
     unsigned char hiR, hiG, hiB;
 
-    wxCHECK_MSG((bmp.GetMask() != NULL) || transColour.Ok(),
-                FALSE,
-                wxT("Either the bitmap should have a mask or a colour should be given."));
-
-    wxImage image = bmp.ConvertToImage();
-
-    if (image.HasMask())
-    {
-        loR = image.GetMaskRed();
-        loG = image.GetMaskGreen();
-        loB = image.GetMaskBlue();
-    }
-    else
-    {
-        loR = transColour.Red();
-        loG = transColour.Green();
-        loB = transColour.Blue();
-    }
-
     hiR = wxMin(0xFF, loR + tolerance);
     hiG = wxMin(0xFF, loG + tolerance);
     hiB = wxMin(0xFF, loB + tolerance);
     hiR = wxMin(0xFF, loR + tolerance);
     hiG = wxMin(0xFF, loG + tolerance);
     hiB = wxMin(0xFF, loB + tolerance);
@@ -108,12 +94,61 @@ bool wxRegion::Union(const wxBitmap& bmp,
             if (x > x0) {
                 rect.x = x0;
                 rect.width = x - x0;
             if (x > x0) {
                 rect.x = x0;
                 rect.width = x - x0;
-                Union(rect);
+                region.Union(rect);
             }
         }
     }
 
             }
         }
     }
 
-    return TRUE;
+    return true;
+}
+
+
+bool wxRegion::Union(const wxBitmap& bmp)
+{
+    if (bmp.GetMask())
+    {
+        wxImage image = bmp.ConvertToImage();
+        wxASSERT_MSG( image.HasMask(), _T("wxBitmap::ConvertToImage doesn't preserve mask?") );
+        return DoRegionUnion(*this, image,
+                             image.GetMaskRed(),
+                             image.GetMaskGreen(),
+                             image.GetMaskBlue(),
+                             0);
+    }
+    else
+    {
+        return Union(0, 0, bmp.GetWidth(), bmp.GetHeight());
+    }
+}
+
+bool wxRegion::Union(const wxBitmap& bmp,
+                     const wxColour& transColour,
+                     int   tolerance)
+{
+    wxImage image = bmp.ConvertToImage();
+    return DoRegionUnion(*this, image,
+                         transColour.Red(),
+                         transColour.Green(),
+                         transColour.Blue(),
+                         tolerance);
 }
 
 }
 
+#else
+
+bool wxRegion::Union(const wxBitmap& WXUNUSED(bmp))
+{
+    // No wxImage support
+    return false;
+}
+
+bool wxRegion::Union(const wxBitmap& WXUNUSED(bmp),
+                     const wxColour& WXUNUSED(transColour),
+                     int   WXUNUSED(tolerance))
+{
+    // No wxImage support
+    return false;
+}
+
+#endif
+
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------