]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/dc.cpp
wxUniversal fixes:
[wxWidgets.git] / src / os2 / dc.cpp
index 9912e149cecb2426c6488abf65d80daa23f775f7..9a58657da1af201924e7fac723b0ebee3c370bbc 100644 (file)
@@ -557,7 +557,7 @@ void wxDC::Clear()
     ::GpiErase(m_hPS);
 } // end of wxDC::Clear
 
-void wxDC::DoFloodFill(
+bool wxDC::DoFloodFill(
   wxCoord                           vX
 , wxCoord                           vY
 , const wxColour&                   rCol
@@ -567,6 +567,8 @@ void wxDC::DoFloodFill(
     POINTL                          vPtlPos;
     LONG                            lColor;
     LONG                            lOptions;
+    LONG                            lHits;
+    bool                            bSuccess = FALSE;
 
     vPtlPos.x = vX;             // Loads x-coordinate
     vPtlPos.y = OS2Y(vY,0);     // Loads y-coordinate
@@ -576,7 +578,9 @@ void wxDC::DoFloodFill(
     if(wxFLOOD_SURFACE == nStyle)
         lOptions = FF_SURFACE;
 
-    ::GpiFloodFill(m_hPS, lOptions, lColor);
+    if ((lHits = ::GpiFloodFill(m_hPS, lOptions, lColor)) != GPI_ERROR)
+        bSuccess = TRUE;
+    return TRUE;
 } // end of wxDC::DoFloodFill
 
 bool wxDC::DoGetPixel(
@@ -974,7 +978,14 @@ void wxDC::DoDrawRectangle(
     LONG                            lBorderColor;
     int                             nIsTRANSPARENT = 0;
 
-    vY = OS2Y(vY,vHeight);
+    //
+    // Might be a memory DC with no Paint rect
+    //
+    if (!(m_vRclPaint.yTop == 0 &&
+          m_vRclPaint.yBottom == 0 &&
+          m_vRclPaint.xRight == 0 &&
+          m_vRclPaint.xLeft == 0))
+        vY = OS2Y(vY,vHeight);
 
     wxCoord                         vX2 = vX + vWidth;
     wxCoord                         vY2 = vY + vHeight;
@@ -1029,6 +1040,54 @@ void wxDC::DoDrawRectangle(
                  ,0L
                  ,0L
                 );
+        //
+        // Debug testing:
+        //
+        if (m_vSelectedBitmap != wxNullBitmap)
+        {
+            BITMAPINFOHEADER2           vHeader;
+            BITMAPINFO2                 vInfo;
+
+            vHeader.cbFix = 16L;
+            if (::GpiQueryBitmapInfoHeader(m_hPS, &vHeader))
+            {
+                int                     nBytesPerLine = vHeader.cBitCount/8;
+                unsigned char*          pucData = NULL;
+                unsigned char*          pucBits;
+                LONG                    lScans = 0L;
+
+                vInfo.cbFix = 16;
+                vInfo.cx              = vHeader.cx;
+                vInfo.cy              = vHeader.cy;
+                vInfo.cPlanes         = vHeader.cPlanes;
+                vInfo.cBitCount       = vHeader.cBitCount;
+                pucData = (unsigned char*)malloc(nBytesPerLine * vHeight);
+                pucBits = pucData;
+                for (int i = 0; i < vHeight; i++)
+                {
+                    if (i <= m_vSelectedBitmap.GetHeight())
+                    {
+                        for (int j = 0; j < vWidth; j++)
+                        {
+                            if (j <= m_vSelectedBitmap.GetWidth())
+                            {
+                                vPoint[0].x = j; vPoint[0].y = i;
+                                lColor = ::GpiQueryPel(m_hPS, &vPoint[0]);
+                                *(pucBits++) = lColor >> 24;
+                                *(pucBits++) = lColor >> 16;
+                                *(pucBits++) = lColor >> 8;
+                            }
+                        }
+                    }
+                }
+                lScans = ::GpiSetBitmapBits( m_hPS
+                                            ,0             // Start at the bottom
+                                            ,(LONG)vHeight // One line per scan
+                                            ,(PBYTE)pucData
+                                            ,&vInfo
+                                           );
+            }
+        }
     }
     CalcBoundingBox(vX, vY);
     CalcBoundingBox(vX2, vY2);
@@ -1198,16 +1257,51 @@ void wxDC::DoDrawBitmap(
 , bool                              bUseMask
 )
 {
-    POINTL                          vPoint = {vX, vY};
+    if (!bUseMask && !IsKindOf(CLASSINFO(wxPrinterDC)))
+    {
+        HBITMAP                         hBitmap =  (HBITMAP)rBmp.GetHBITMAP();
+        wxBitmap                        vNewBitmap( rBmp.GetWidth()
+                                                   ,rBmp.GetHeight()
+                                                   ,rBmp.GetDepth()
+                                                  );
+        HBITMAP                         hBitmapOld = ::GpiSetBitmap((HPS)GetHPS(), vNewBitmap.GetHBITMAP());
+        LONG                            lOldTextground = ::GpiQueryColor((HPS)GetHPS());
+        LONG                            lOldBackground = ::GpiQueryBackColor((HPS)GetHPS());
+
+        if (m_textForegroundColour.Ok())
+        {
+            ::GpiSetColor( (HPS)GetHPS()
+                           ,m_textForegroundColour.GetPixel()
+                          );
+        }
+        if (m_textBackgroundColour.Ok())
+        {
+            ::GpiSetBackColor( (HPS)GetHPS()
+                              ,m_textBackgroundColour.GetPixel()
+                             );
+        }
 
-    ::WinDrawBitmap( GetHPS()
-                    ,(HBITMAP)GetHbitmapOf(rBmp)
-                    ,NULL
-                    ,&vPoint
-                    ,0L
-                    ,0L
-                    ,DBM_NORMAL
-                   );
+        vY = OS2Y(vY,rBmp.GetHeight());
+
+        //
+        // Flip the picture as OS/2 is upside-down
+        //
+        POINTL                      vPoint[4] = { vX, vY + rBmp.GetHeight()
+                                                 ,vX + rBmp.GetWidth(), vY
+                                                 ,0, 0
+                                                 ,rBmp.GetWidth(), rBmp.GetHeight()
+                                                };
+        ::GpiWCBitBlt( (HPS)GetHPS()
+                      ,hBitmap
+                      ,4
+                      ,vPoint
+                      ,ROP_SRCCOPY
+                      ,BBO_IGNORE
+                     );
+        ::GpiSetBitmap((HPS)GetHPS(), hBitmapOld);
+        ::GpiSetColor((HPS)GetHPS(), lOldTextground);
+        ::GpiSetBackColor((HPS)GetHPS(), lOldBackground);
+    }
 } // end of wxDC::DoDrawBitmap
 
 void wxDC::DoDrawText(