]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mgl/dc.cpp
Test case for MSW display corruption in 2.3.3
[wxWidgets.git] / src / mgl / dc.cpp
index 692ac021d420f8f06e7b6ccf1324cb327aa49a2b..4a2a4909ec10484ae491edc7eda9827bf55cd51d 100644 (file)
@@ -4,7 +4,7 @@
 // Author:      Vaclav Slavik
 // Created:     2001/03/09
 // RCS-ID:      $Id$
-// Copyright:   (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
+// Copyright:   (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // constants
 //-----------------------------------------------------------------------------
 
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
 const double mm2inches      = 0.0393700787402;
 const double inches2mm      = 25.4;
 const double mm2twips       = 56.6929133859;
@@ -245,6 +249,7 @@ void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
     // check if the DC is scaled or moved, and if yes, then
     // convert rg to device coordinates:
     if ( m_deviceOriginX != 0 || m_deviceOriginY != 0 ||
+         m_logicalOriginX != 0 || m_logicalOriginY != 0 ||
          XLOG2DEVREL(500) != 500 || YLOG2DEVREL(500) != 500 )
     {
         region_t *mrg = rg.GetMGLRegion().rgnPointer();
@@ -329,7 +334,34 @@ void wxDC::Clear()
 
 void wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style)
 {
-    wxFAIL_MSG( wxT("wxDC::DoFloodFill not implemented") );
+    if (GetBrush().GetStyle() == wxTRANSPARENT)
+    {
+        wxLogDebug(wxT("In FloodFill, Current Brush is transparent, no filling done"));
+        return ;
+    }
+    int height = 0;
+    int width  = 0;
+    this->GetSize(&width, &height);
+    //it would be nice to fail if we don't get a sensible size...
+    if (width < 1 || height < 1)
+    {
+        wxLogError(wxT("In FloodFill, dc.GetSize routine failed, method not supported by this DC"));
+        return ;
+    }
+
+    //this is much faster than doing the individual pixels
+    wxMemoryDC memdc;
+    wxBitmap bitmap(width, height);
+    memdc.SelectObject(bitmap);
+    memdc.Blit(0, 0, width, height, (wxDC*) this, 0, 0);
+    memdc.SelectObject(wxNullBitmap);
+
+    wxImage image(bitmap);
+    image.DoFloodFill (x,y, GetBrush(), col, style, GetLogicalFunction());
+    bitmap = wxBitmap(image);
+    memdc.SelectObject(bitmap);
+    this->Blit(0, 0, width, height, &memdc, 0, 0);
+    memdc.SelectObject(wxNullBitmap);
 }
 
 bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
@@ -553,6 +585,7 @@ void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
     {
         if ( !m_penSelected ) 
             SelectPen();
+
         m_MGLDC->rect(xx + m_penOfsX, yy + m_penOfsY, 
                       xx + ww + m_penOfsX, yy + hh + m_penOfsY);
     }    
@@ -726,7 +759,7 @@ bool wxDC::SelectMGLFont()
              !wxTestFontEncoding(nativeEnc) )
         {
 #if wxUSE_FONTMAP
-            if ( !wxTheFontMapper->GetAltForEncoding(encoding, &nativeEnc) )
+            if ( !wxFontMapper::Get()->GetAltForEncoding(encoding, &nativeEnc) )
 #endif
             {
                 nativeEnc.mglEncoding = MGL_ENCODING_ASCII;
@@ -1097,7 +1130,8 @@ void wxDC::SetPalette(const wxPalette& palette)
     
     if ( palette == wxNullPalette )
     {
-        SetPalette(m_oldPalette);
+        if ( m_oldPalette.Ok() )
+            SetPalette(m_oldPalette);
         return;
     }