]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/dc.cpp
Do not allow events to fire after socket is closed (fixes crash on GTK with GDK_Input...
[wxWidgets.git] / src / os2 / dc.cpp
index 7c82a9c6c1820b5a4a7361092338c8ec14cddec1..e21566019854aac44582eee429d6b81ac12e688b 100644 (file)
@@ -221,7 +221,7 @@ wxDCCacheEntry* wxDC::FindBitmapInCache(
                 vBmpHdr.cx        = nWidth;
                 vBmpHdr.cy        = nHeight;
                 vBmpHdr.cPlanes   = 1;
                 vBmpHdr.cx        = nWidth;
                 vBmpHdr.cy        = nHeight;
                 vBmpHdr.cPlanes   = 1;
-                vBmpHdr.cBitCount = nDepth;
+                vBmpHdr.cBitCount = (USHORT)nDepth;
 
                 pEntry->m_hBitmap = (WXHBITMAP) ::GpiCreateBitmap( hPS
                                                                   ,&vBmpHdr
 
                 pEntry->m_hBitmap = (WXHBITMAP) ::GpiCreateBitmap( hPS
                                                                   ,&vBmpHdr
@@ -244,7 +244,7 @@ wxDCCacheEntry* wxDC::FindBitmapInCache(
     vBmpHdr.cx        = nWidth;
     vBmpHdr.cy        = nHeight;
     vBmpHdr.cPlanes   = 1;
     vBmpHdr.cx        = nWidth;
     vBmpHdr.cy        = nHeight;
     vBmpHdr.cPlanes   = 1;
-    vBmpHdr.cBitCount = nDepth;
+    vBmpHdr.cBitCount = (USHORT)nDepth;
 
     WXHBITMAP                       hBitmap = (WXHBITMAP) ::GpiCreateBitmap( hPS
                                                                             ,&vBmpHdr
 
     WXHBITMAP                       hBitmap = (WXHBITMAP) ::GpiCreateBitmap( hPS
                                                                             ,&vBmpHdr
@@ -578,7 +578,7 @@ bool wxDC::DoFloodFill(
     if ((lHits = ::GpiFloodFill(m_hPS, lOptions, lColor)) != GPI_ERROR)
         bSuccess = true;
 
     if ((lHits = ::GpiFloodFill(m_hPS, lOptions, lColor)) != GPI_ERROR)
         bSuccess = true;
 
-    return true;
+    return bSuccess;
 } // end of wxDC::DoFloodFill
 
 bool wxDC::DoGetPixel(
 } // end of wxDC::DoFloodFill
 
 bool wxDC::DoGetPixel(
@@ -592,17 +592,7 @@ bool wxDC::DoGetPixel(
 
     vPoint.x = vX;
     vPoint.y = OS2Y(vY,0);
 
     vPoint.x = vX;
     vPoint.y = OS2Y(vY,0);
-    lColor = ::GpiSetPel(m_hPS, &vPoint);
-
-    //
-    // Get the color of the pen
-    //
-    LONG                            lPencolor = 0x00ffffff;
-
-    if (m_pen.Ok())
-    {
-        lPencolor = m_pen.GetColour().GetPixel();
-    }
+    lColor = ::GpiQueryPel(m_hPS, &vPoint);
 
     //
     // return the color of the pixel
 
     //
     // return the color of the pixel
@@ -612,7 +602,7 @@ bool wxDC::DoGetPixel(
                   ,GetGValue(lColor)
                   ,GetBValue(lColor)
                  );
                   ,GetGValue(lColor)
                   ,GetBValue(lColor)
                  );
-    return(lColor == lPencolor);
+    return true;
 } // end of wxDC::DoGetPixel
 
 void wxDC::DoCrossHair(
 } // end of wxDC::DoGetPixel
 
 void wxDC::DoCrossHair(
@@ -784,7 +774,11 @@ void wxDC::DoDrawArc(
     vPtlArc[0].y = vYm;
     vPtlArc[1].x = vX2;
     vPtlArc[1].y = vY2;
     vPtlArc[0].y = vYm;
     vPtlArc[1].x = vX2;
     vPtlArc[1].y = vY2;
+#if !(defined(__WATCOMC__) && __WATCOMC__ < 1240 )
+// Open Watcom 1.3 had incomplete headers
+// that's reported and should be fixed for OW 1.4
     ::GpiPointArc(m_hPS, vPtlArc); // Draws the arc
     ::GpiPointArc(m_hPS, vPtlArc); // Draws the arc
+#endif
     CalcBoundingBox( (wxCoord)(vXc - dRadius)
                     ,(wxCoord)(vYc - dRadius)
                    );
     CalcBoundingBox( (wxCoord)(vXc - dRadius)
                     ,(wxCoord)(vYc - dRadius)
                    );
@@ -1301,10 +1295,12 @@ void wxDC::DoDrawBitmap(
 , bool                              bUseMask
 )
 {
 , bool                              bUseMask
 )
 {
+#if wxUSE_PRINTING_ARCHITECTURE
     if (!IsKindOf(CLASSINFO(wxPrinterDC)))
     if (!IsKindOf(CLASSINFO(wxPrinterDC)))
+#endif
     {
         HBITMAP                         hBitmap =  (HBITMAP)rBmp.GetHBITMAP();
     {
         HBITMAP                         hBitmap =  (HBITMAP)rBmp.GetHBITMAP();
-        HBITMAP                         hBitmapOld = NULLHANDLE;;
+        HBITMAP                         hBitmapOld = NULLHANDLE;
         POINTL                          vPoint[4];
 
         vY = OS2Y(vY,rBmp.GetHeight());
         POINTL                          vPoint[4];
 
         vY = OS2Y(vY,rBmp.GetHeight());
@@ -1397,7 +1393,7 @@ void wxDC::DoDrawBitmap(
                     lColor = m_textBackgroundColour.GetPixel();
 
                 //
                     lColor = m_textBackgroundColour.GetPixel();
 
                 //
-                // Bitmap must be ina double-word alligned address so we may
+                // Bitmap must be in a double-word aligned address so we may
                 // have some padding to worry about
                 //
                 if (nLineBoundary > 0)
                 // have some padding to worry about
                 //
                 if (nLineBoundary > 0)
@@ -1881,9 +1877,7 @@ void wxDC::DoDrawRotatedText(
 // set GDI objects
 // ---------------------------------------------------------------------------
 
 // set GDI objects
 // ---------------------------------------------------------------------------
 
-void wxDC::DoSelectPalette(
-  bool                              bRealize
-)
+void wxDC::DoSelectPalette( bool WXUNUSED(bRealize) )
 {
     //
     // Set the old object temporarily, in case the assignment deletes an object
 {
     //
     // Set the old object temporarily, in case the assignment deletes an object
@@ -2176,9 +2170,7 @@ void wxDC::SetRop(
     ::GpiSetMix((HPS)hDC, lCRop);
 } // end of wxDC::SetRop
 
     ::GpiSetMix((HPS)hDC, lCRop);
 } // end of wxDC::SetRop
 
-bool wxDC::StartDoc(
-  const wxString&                   rsMessage
-)
+bool wxDC::StartDoc( const wxString& WXUNUSED(rsMessage) )
 {
     // We might be previewing, so return true to let it continue.
     return true;
 {
     // We might be previewing, so return true to let it continue.
     return true;
@@ -2373,10 +2365,8 @@ void wxDC::SetMapMode(
     // ????
 }; // end of wxDC::SetMapMode
 
     // ????
 }; // end of wxDC::SetMapMode
 
-void wxDC::SetUserScale(
-  double                            dX
-, double                            dY
-)
+void wxDC::SetUserScale( double dX,
+                         double dY )
 {
     m_userScaleX = dX;
     m_userScaleY = dY;
 {
     m_userScaleX = dX;
     m_userScaleY = dY;
@@ -2384,10 +2374,8 @@ void wxDC::SetUserScale(
     SetMapMode(m_mappingMode);
 } // end of wxDC::SetUserScale
 
     SetMapMode(m_mappingMode);
 } // end of wxDC::SetUserScale
 
-void wxDC::SetAxisOrientation(
-  bool                              bXLeftRight
-, bool                              bYBottomUp
-)
+void wxDC::SetAxisOrientation( bool bXLeftRight,
+                               bool bYBottomUp )
 {
     m_signX = bXLeftRight ? 1 : -1;
     m_signY = bYBottomUp ? -1 : 1;
 {
     m_signX = bXLeftRight ? 1 : -1;
     m_signY = bYBottomUp ? -1 : 1;
@@ -2498,19 +2486,17 @@ wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
 // bit blit
 // ---------------------------------------------------------------------------
 
 // bit blit
 // ---------------------------------------------------------------------------
 
-bool wxDC::DoBlit(
-  wxCoord                           vXdest
-, wxCoord                           vYdest
-, wxCoord                           vWidth
-, wxCoord                           vHeight
-, wxDC*                             pSource
-, wxCoord                           vXsrc
-, wxCoord                           vYsrc
-, int                               nRop
-, bool                              bUseMask
-, wxCoord                           vXsrcMask
-, wxCoord                           vYsrcMask
-)
+bool wxDC::DoBlit( wxCoord vXdest,
+                   wxCoord vYdest,
+                   wxCoord vWidth,
+                   wxCoord vHeight,
+                   wxDC*   pSource,
+                   wxCoord vXsrc,
+                   wxCoord vYsrc,
+                   int     nRop,
+                   bool    bUseMask,
+                   wxCoord WXUNUSED(vXsrcMask),
+                   wxCoord WXUNUSED(vYsrcMask) )
 {
     wxMask*                         pMask = NULL;
     CHARBUNDLE                      vCbnd;
 {
     wxMask*                         pMask = NULL;
     CHARBUNDLE                      vCbnd;
@@ -2604,7 +2590,6 @@ bool wxDC::DoBlit(
         vBmpHdr.cBitCount = 24;
 
 #if wxUSE_DC_CACHEING
         vBmpHdr.cBitCount = 24;
 
 #if wxUSE_DC_CACHEING
-        if (true)
         {
             //
             // create a temp buffer bitmap and DCs to access it and the mask
         {
             //
             // create a temp buffer bitmap and DCs to access it and the mask
@@ -2623,9 +2608,9 @@ bool wxDC::DoBlit(
             hPSMask = pDCCacheEntry1->m_hPS;
             hDCBuffer = (HDC)pDCCacheEntry2->m_hPS;
             hBufBitmap = (HBITMAP)pBitmapCacheEntry->m_hBitmap;
             hPSMask = pDCCacheEntry1->m_hPS;
             hDCBuffer = (HDC)pDCCacheEntry2->m_hPS;
             hBufBitmap = (HBITMAP)pBitmapCacheEntry->m_hBitmap;
+            wxUnusedVar(hDCMask);
         }
         }
-        else
-#endif
+#else
         {
             hDCMask = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDOP, NULLHANDLE);
             hDCBuffer = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDOP, NULLHANDLE);
         {
             hDCMask = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDOP, NULLHANDLE);
             hDCBuffer = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDOP, NULLHANDLE);
@@ -2633,6 +2618,7 @@ bool wxDC::DoBlit(
             hPSBuffer = ::GpiCreatePS(vHabmain, hDCBuffer, &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC);
             hBufBitmap = ::GpiCreateBitmap(GetHPS(), &vBmpHdr, 0L, NULL, NULL);
         }
             hPSBuffer = ::GpiCreatePS(vHabmain, hDCBuffer, &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC);
             hBufBitmap = ::GpiCreateBitmap(GetHPS(), &vBmpHdr, 0L, NULL, NULL);
         }
+#endif
 
         POINTL                          aPoint1[4] = { {0, 0}
                               ,{vWidth, vHeight}
 
         POINTL                          aPoint1[4] = { {0, 0}
                               ,{vWidth, vHeight}
@@ -2810,10 +2796,8 @@ void wxDC::DoGetSize(
     }
 }; // end of wxDC::DoGetSize(
 
     }
 }; // end of wxDC::DoGetSize(
 
-void wxDC::DoGetSizeMM(
-  int*                              pnWidth
-, int*                              pnHeight
-) const
+void wxDC::DoGetSizeMM( int* pnWidth,
+                        int* pnHeight ) const
 {
     LONG                            lArray[CAPS_VERTICAL_RESOLUTION];
 
 {
     LONG                            lArray[CAPS_VERTICAL_RESOLUTION];
 
@@ -2823,17 +2807,19 @@ void wxDC::DoGetSizeMM(
                       ,lArray
                      ))
     {
                       ,lArray
                      ))
     {
-        int                         nWidth;
-        int                         nHeight;
-        int                         nHorzRes;
-        int                         nVertRes;
+        if(pnWidth)
+        {
+            int nWidth = lArray[CAPS_WIDTH];
+            int nHorzRes  = lArray[CAPS_HORIZONTAL_RESOLUTION]; // returns pel/meter
+            *pnWidth  = (nHorzRes/1000) * nWidth;
+        }
 
 
-        nWidth    = lArray[CAPS_WIDTH];
-        nHeight   = lArray[CAPS_HEIGHT];
-        nHorzRes  = lArray[CAPS_HORIZONTAL_RESOLUTION]; // returns pel/meter
-        nVertRes  = lArray[CAPS_VERTICAL_RESOLUTION];   // returns pel/meter
-        nWidth  = (nHorzRes/1000) * nWidth;
-        nHeight = (nVertRes/1000) * nHeight;
+        if(pnHeight)
+        {
+            int nHeight   = lArray[CAPS_HEIGHT];
+            int nVertRes = lArray[CAPS_VERTICAL_RESOLUTION];   // returns pel/meter
+            *pnHeight = (nVertRes/1000) * nHeight;
+        }
     }
 }; // end of wxDC::DoGetSizeMM
 
     }
 }; // end of wxDC::DoGetSizeMM
 
@@ -2861,7 +2847,8 @@ wxSize wxDC::GetPPI() const
         nWidth   = (int)((nHorzRes/39.3) * nPelWidth);
         nHeight  = (int)((nVertRes/39.3) * nPelHeight);
     }
         nWidth   = (int)((nHorzRes/39.3) * nPelWidth);
         nHeight  = (int)((nVertRes/39.3) * nPelHeight);
     }
-    return (wxSize(nWidth,nHeight));
+    wxSize ppisize(nWidth, nHeight);
+    return ppisize;
 } // end of wxDC::GetPPI
 
 void wxDC::SetLogicalScale(
 } // end of wxDC::GetPPI
 
 void wxDC::SetLogicalScale(
@@ -2872,6 +2859,3 @@ void wxDC::SetLogicalScale(
     m_logicalScaleX = dX;
     m_logicalScaleY = dY;
 }; // end of wxDC::SetLogicalScale
     m_logicalScaleX = dX;
     m_logicalScaleY = dY;
 }; // end of wxDC::SetLogicalScale
-
-
-