]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/dc.cpp
missing commit, see #10269
[wxWidgets.git] / src / os2 / dc.cpp
index 9fb6ea2f9d024af6f67c3f5b94f909fbf6d9f3ed..14d766ba38c74bf0bc916d3f19a4d426d3f0ea0b 100644 (file)
@@ -386,7 +386,7 @@ void wxPMDCImpl::SelectOldObjects(
         if (m_hOldBitmap)
         {
             ::GpiSetBitmap(hPS, (HBITMAP) m_hOldBitmap);
-            if (m_vSelectedBitmap.Ok())
+            if (m_vSelectedBitmap.IsOk())
             {
                 m_vSelectedBitmap.SetSelectedInto(NULL);
             }
@@ -444,7 +444,7 @@ void wxPMDCImpl::DoSetClippingRegion(
     DO_SET_CLIPPING_BOX()
 } // end of wxPMDCImpl::DoSetClippingRegion
 
-void wxPMDCImpl::DoSetClippingRegionAsRegion(
+void wxPMDCImpl::DoSetDeviceClippingRegion(
   const wxRegion&                   rRegion
 )
 {
@@ -457,7 +457,7 @@ void wxPMDCImpl::DoSetClippingRegionAsRegion(
                         ,&hRgnOld
                        );
     DO_SET_CLIPPING_BOX()
-} // end of wxPMDCImpl::DoSetClippingRegionAsRegion
+} // end of wxPMDCImpl::DoSetDeviceClippingRegion
 
 void wxPMDCImpl::DestroyClippingRegion(void)
 {
@@ -501,16 +501,16 @@ bool wxPMDCImpl::CanGetTextExtent() const
 
 int wxPMDCImpl::GetDepth() const
 {
-    LONG                            lArray[CAPS_COLOR_BITCOUNT];
+    LONG                            lCapsColorBitcount;
     int                             nBitsPerPixel = 0;
 
     if(::DevQueryCaps( GetHDC()
-                      ,CAPS_FAMILY
                       ,CAPS_COLOR_BITCOUNT
-                      ,lArray
+                      ,1L
+                      ,&lCapsColorBitcount
                      ))
     {
-        nBitsPerPixel = (int)lArray[CAPS_COLOR_BITCOUNT];
+        nBitsPerPixel = (int)lCapsColorBitcount;
     }
     return nBitsPerPixel;
 } // end of wxPMDCImpl::GetDepth
@@ -540,7 +540,7 @@ bool wxPMDCImpl::DoFloodFill(
   wxCoord                           vX
 , wxCoord                           vY
 , const wxColour&                   rCol
-, int                               nStyle
+, wxFloodFillStyle                  nStyle
 )
 {
     POINTL                          vPtlPos;
@@ -644,7 +644,7 @@ void wxPMDCImpl::DoDrawLine(
     }
     else
     {
-        if (m_vSelectedBitmap.Ok())
+        if (m_vSelectedBitmap.IsOk())
         {
             m_vRclPaint.yTop = m_vSelectedBitmap.GetHeight();
             m_vRclPaint.xRight = m_vSelectedBitmap.GetWidth();
@@ -656,7 +656,7 @@ void wxPMDCImpl::DoDrawLine(
     vPoint[0].y = vY1;
     vPoint[1].x = vX2;
     vPoint[1].y = vY2;
-    if (m_pen.Ok())
+    if (m_pen.IsOk())
     {
         vColor = m_pen.GetColour().GetPixel();
     }
@@ -822,7 +822,7 @@ void wxPMDCImpl::DoDrawPoint(
     POINTL                          vPoint;
     COLORREF                        vColor = 0x00ffffff;
 
-    if (m_pen.Ok())
+    if (m_pen.IsOk())
     {
         vColor = m_pen.GetColour().GetPixel();
     }
@@ -839,7 +839,7 @@ void wxPMDCImpl::DoDrawPolygon( int n,
                           wxPoint vPoints[],
                           wxCoord vXoffset,
                           wxCoord vYoffset,
-                          int nFillStyle )
+                          wxPolygonFillMode nFillStyle )
 {
     ULONG     ulCount = 1;    // Number of polygons.
     POLYGON   vPlgn;          // polygon.
@@ -974,7 +974,7 @@ void wxPMDCImpl::DoDrawRectangle(
         vY = OS2Y(vY,vHeight);
     else
     {
-        if (m_vSelectedBitmap.Ok())
+        if (m_vSelectedBitmap.IsOk())
         {
             m_vRclPaint.yTop = m_vSelectedBitmap.GetHeight();
             m_vRclPaint.xRight = m_vSelectedBitmap.GetWidth();
@@ -1064,7 +1064,7 @@ void wxPMDCImpl::DoDrawRoundedRectangle(
         vY = OS2Y(vY,vHeight);
     else
     {
-        if (m_vSelectedBitmap.Ok())
+        if (m_vSelectedBitmap.IsOk())
         {
             m_vRclPaint.yTop = m_vSelectedBitmap.GetHeight();
             m_vRclPaint.xRight = m_vSelectedBitmap.GetWidth();
@@ -1359,7 +1359,7 @@ void wxPMDCImpl::DoDrawBitmap(
 
                     lColor = pWindowDC->m_pCanvas->GetBackgroundColour().GetPixel();
                 }
-                else if (GetBrush().Ok())
+                else if (GetBrush().IsOk())
                     lColor = GetBrush().GetColour().GetPixel();
                 else
                     lColor = m_textBackgroundColour.GetPixel();
@@ -1526,13 +1526,13 @@ void wxPMDCImpl::DoDrawBitmap(
             ULONG                       lOldForeGround = ::GpiQueryColor((HPS)GetHPS());
             ULONG                       lOldBackGround = ::GpiQueryBackColor((HPS)GetHPS());
 
-            if (m_textForegroundColour.Ok())
+            if (m_textForegroundColour.IsOk())
             {
                 ::GpiSetColor( (HPS)GetHPS()
                                ,m_textForegroundColour.GetPixel()
                               );
             }
-            if (m_textBackgroundColour.Ok())
+            if (m_textBackgroundColour.IsOk())
             {
                 ::GpiSetBackColor( (HPS)GetHPS()
                                   ,m_textBackgroundColour.GetPixel()
@@ -1579,6 +1579,7 @@ void wxPMDCImpl::DoDrawBitmap(
                 {
                     vError = ::WinGetLastError(vHabmain);
                     sError = wxPMErrorToStr(vError);
+                    delete [] pucBits;
                     return;
                 }
                 if ((lScans = ::GpiQueryBitmapBits( hPS
@@ -1590,6 +1591,7 @@ void wxPMDCImpl::DoDrawBitmap(
                 {
                     vError = ::WinGetLastError(vHabmain);
                     sError = wxPMErrorToStr(vError);
+                    delete [] pucBits;
                     return;
                 }
                 unsigned char           cOldRedFore   = (unsigned char)(lOldForeGround >> 16);
@@ -1701,14 +1703,14 @@ void wxPMDCImpl::DrawAnyText( const wxString& rsText,
     //
     // Set text color attributes
     //
-    if (m_textForegroundColour.Ok())
+    if (m_textForegroundColour.IsOk())
     {
         SetTextColor( m_hPS
                      ,(int)m_textForegroundColour.GetPixel()
                     );
     }
 
-    if (m_textBackgroundColour.Ok())
+    if (m_textBackgroundColour.IsOk())
     {
         nOldBackground = SetTextBkColor( m_hPS
                                         ,(int)m_textBackgroundColour.GetPixel()
@@ -1731,7 +1733,7 @@ void wxPMDCImpl::DrawAnyText( const wxString& rsText,
     }
     else
     {
-        if (m_vSelectedBitmap.Ok())
+        if (m_vSelectedBitmap.IsOk())
         {
             m_vRclPaint.yTop = m_vSelectedBitmap.GetHeight();
             m_vRclPaint.xRight = m_vSelectedBitmap.GetWidth();
@@ -1756,7 +1758,7 @@ void wxPMDCImpl::DrawAnyText( const wxString& rsText,
     // it never is set to anything else, but background should remain
     // transparent even if we just drew an opaque string)
     //
-    if (m_textBackgroundColour.Ok())
+    if (m_textBackgroundColour.IsOk())
             SetTextBkColor( m_hPS
                            ,nOldBackground
                           );
@@ -1847,7 +1849,7 @@ void wxPMDCImpl::DoSelectPalette( bool WXUNUSED(bRealize) )
         m_hOldPalette = 0;
     }
 
-    if (m_palette.Ok())
+    if (m_palette.IsOk())
     {
         HPALETTE                    hOldPal;
 
@@ -1889,7 +1891,7 @@ void wxPMDCImpl::SetPalette(
         m_hOldFont = 0;
     }
     m_palette = rPalette;
-    if (!rPalette.Ok())
+    if (!rPalette.IsOk())
     {
         if (m_hOldFont)
         {
@@ -1914,14 +1916,14 @@ void wxPMDCImpl::SetFont(
         m_hOldFont = 0;
     }
     m_font = rFont;
-    if (!rFont.Ok())
+    if (!rFont.IsOk())
     {
         m_hOldFont = 0;
     }
 
     m_font.SetPS(m_hPS); // this will realize the font
 
-    if (m_font.Ok())
+    if (m_font.IsOk())
     {
         HFONT                       hFont = m_font.GetResourceHandle();
         if (hFont == (HFONT) NULL)
@@ -1940,14 +1942,14 @@ void wxPMDCImpl::SetPen(
     if (m_pen == rPen)
         return;
     m_pen = rPen;
-    if (!m_pen.Ok())
+    if (!m_pen.IsOk())
         return;
 
     if (m_hOldPen)
         m_hOldPen = 0L;
     m_pen = rPen;
 
-    if (!m_pen.Ok())
+    if (!m_pen.IsOk())
     {
         if (m_hOldPen)
         {
@@ -1956,7 +1958,7 @@ void wxPMDCImpl::SetPen(
         m_hOldPen = 0L;
     }
 
-    if (m_pen.Ok())
+    if (m_pen.IsOk())
     {
         if (m_pen.GetResourceHandle())
         {
@@ -1975,14 +1977,14 @@ void wxPMDCImpl::SetBrush(
     if (m_hOldBrush)
         m_hOldBrush = 0L;
     m_brush = rBrush;
-    if (!m_brush.Ok())
+    if (!m_brush.IsOk())
     if (m_brush == rBrush)
         return;
-    if (!m_brush.Ok())
+    if (!m_brush.IsOk())
         if (m_hOldBrush)
             m_hOldBrush = 0L;
 
-    if (!m_brush.Ok())
+    if (!m_brush.IsOk())
     {
         if (m_hOldBrush)
         {
@@ -1991,7 +1993,7 @@ void wxPMDCImpl::SetBrush(
         m_hOldBrush = 0L;
     }
 
-    if (m_brush.Ok())
+    if (m_brush.IsOk())
     {
         if (m_brush.GetResourceHandle())
         {
@@ -2006,7 +2008,7 @@ void wxPMDCImpl::SetBackground(const wxBrush& rBrush)
 {
     m_backgroundBrush = rBrush;
 
-    if (m_backgroundBrush.Ok())
+    if (m_backgroundBrush.IsOk())
     {
         (void)::GpiSetBackColor((HPS)m_hPS, m_backgroundBrush.GetColour().GetPixel());
     }
@@ -2017,7 +2019,7 @@ void wxPMDCImpl::SetBackgroundMode(int nMode)
     m_backgroundMode = nMode;
 } // end of wxPMDCImpl::SetBackgroundMode
 
-void wxPMDCImpl::SetLogicalFunction(int nFunction)
+void wxPMDCImpl::SetLogicalFunction(wxRasterOperationMode nFunction)
 {
     m_logicalFunction = nFunction;
     SetRop((WXHDC)m_hDC);
@@ -2160,12 +2162,12 @@ void wxPMDCImpl::DoGetTextExtent(
     //
     if (!m_hPS)
     {
-       (void)wxMessageBox( _T("wxWidgets core library")
-                           ,"Using uninitialized DC for measuring text!\n"
-                           ,wxICON_INFORMATION
-                           );
+    (void)wxMessageBox( wxT("wxWidgets core library")
+                ,"Using uninitialized DC for measuring text!\n"
+                ,wxICON_INFORMATION
+                );
     }
-       
+
     bRc = ::GpiQueryTextBox( m_hPS
                             ,l
                             ,rsString.char_str()
@@ -2177,8 +2179,8 @@ void wxPMDCImpl::DoGetTextExtent(
        vErrorCode = ::WinGetLastError(wxGetInstance());
        sError = wxPMErrorToStr(vErrorCode);
        // DEBUG
-       wxSprintf(zMsg, _T("GpiQueryTextBox for %s: failed with Error: %lx - %s"), rsString.c_str(), vErrorCode, sError.c_str());
-       (void)wxMessageBox( _T("wxWidgets core library")
+       wxSprintf(zMsg, wxT("GpiQueryTextBox for %s: failed with Error: %lx - %s"), rsString.c_str(), vErrorCode, sError.c_str());
+       (void)wxMessageBox( wxT("wxWidgets core library")
                           ,zMsg
                           ,wxICON_INFORMATION
                          );
@@ -2211,7 +2213,7 @@ void wxPMDCImpl::DoGetTextExtent(
 }
 
 void wxPMDCImpl::SetMapMode(
-  int                               nMode
+  wxMappingMode                     nMode
 )
 {
     int                             nPixelWidth = 0;
@@ -2285,7 +2287,7 @@ void wxPMDCImpl::SetMapMode(
         ::GpiSetPS(m_hPS, &vSize, ulOptions);
     }
     ComputeScaleAndOrigin();
-    
+
 }; // end of wxPMDCImpl::SetMapMode
 
 void wxPMDCImpl::SetUserScale( double dX,
@@ -2357,7 +2359,7 @@ bool wxPMDCImpl::DoBlit( wxCoord vXdest,
                    wxDC*   pSource,
                    wxCoord vXsrc,
                    wxCoord vYsrc,
-                   int     nRop,
+                   wxRasterOperationMode     nRop,
                    bool    bUseMask,
                    wxCoord WXUNUSED(vXsrcMask),
                    wxCoord WXUNUSED(vYsrcMask) )
@@ -2381,7 +2383,7 @@ bool wxPMDCImpl::DoBlit( wxCoord vXdest,
         const wxBitmap&             rBmp = pm_impl->GetSelectedBitmap();
 
         pMask = rBmp.GetMask();
-        if (!(rBmp.Ok() && pMask && pMask->GetMaskBitmap()))
+        if (!(rBmp.IsOk() && pMask && pMask->GetMaskBitmap()))
         {
             bUseMask = false;
         }
@@ -2394,7 +2396,7 @@ bool wxPMDCImpl::DoBlit( wxCoord vXdest,
                    );
     vOldTextColor = (COLORREF)vCbnd.lColor;
 
-    if (m_textForegroundColour.Ok())
+    if (m_textForegroundColour.IsOk())
     {
         vCbnd.lColor = (LONG)m_textForegroundColour.GetPixel();
         ::GpiSetAttrs( m_hPS           // presentation-space handle
@@ -2404,7 +2406,7 @@ bool wxPMDCImpl::DoBlit( wxCoord vXdest,
                       ,&vCbnd          // buffer for attributes.
                      );
     }
-    if (m_textBackgroundColour.Ok())
+    if (m_textBackgroundColour.IsOk())
     {
         ::GpiSetBackColor(m_hPS, (LONG)m_textBackgroundColour.GetPixel());
     }
@@ -2652,57 +2654,61 @@ bool wxPMDCImpl::DoBlit( wxCoord vXdest,
 }
 
 void wxPMDCImpl::DoGetSize( int* pnWidth,
-                      int* pnHeight ) const
+                            int* pnHeight ) const
 {
-    LONG lArray[CAPS_HEIGHT];
+    LONG lArray[CAPS_HEIGHT+1];
 
     if(::DevQueryCaps( m_hDC
                       ,CAPS_FAMILY
-                      ,CAPS_HEIGHT
+                      ,CAPS_HEIGHT+1
                       ,lArray
                      ))
     {
-        *pnWidth  = lArray[CAPS_WIDTH];
-        *pnHeight = lArray[CAPS_HEIGHT];
+        if (pnWidth)
+            *pnWidth  = lArray[CAPS_WIDTH];
+        if (pnHeight)
+            *pnHeight = lArray[CAPS_HEIGHT];
     }
 }; // end of wxPMDCImpl::DoGetSize(
 
 void wxPMDCImpl::DoGetSizeMM( int* pnWidth,
                         int* pnHeight ) const
 {
-    LONG                            lArray[CAPS_VERTICAL_RESOLUTION];
+    LONG                            lArray[CAPS_VERTICAL_RESOLUTION+1];
 
     if(::DevQueryCaps( m_hDC
                       ,CAPS_FAMILY
-                      ,CAPS_VERTICAL_RESOLUTION
+                      ,CAPS_VERTICAL_RESOLUTION+1
                       ,lArray
                      ))
     {
         if(pnWidth)
         {
-            int nWidth = lArray[CAPS_WIDTH];
-            int nHorzRes  = lArray[CAPS_HORIZONTAL_RESOLUTION]; // returns pel/meter
-            *pnWidth  = (nHorzRes/1000) * nWidth;
+            int nWidth   = lArray[CAPS_WIDTH];
+            int nHorzRes = lArray[CAPS_HORIZONTAL_RESOLUTION]; // returns pel/meter
+            // use fp to avoid returning 0 if nHorzRes < 1000
+            *pnWidth  = (int)((nHorzRes/1000.0) * nWidth);
         }
 
         if(pnHeight)
         {
-            int nHeight   = lArray[CAPS_HEIGHT];
+            int nHeight  = lArray[CAPS_HEIGHT];
             int nVertRes = lArray[CAPS_VERTICAL_RESOLUTION];   // returns pel/meter
-            *pnHeight = (nVertRes/1000) * nHeight;
+            // use fp to avoid returning 0 if nVertRes < 1000
+            *pnHeight = (int)((nVertRes/1000.0) * nHeight);
         }
     }
 }; // end of wxPMDCImpl::DoGetSizeMM
 
 wxSize wxPMDCImpl::GetPPI() const
 {
-    LONG                            lArray[CAPS_VERTICAL_RESOLUTION];
+    LONG                            lArray[CAPS_VERTICAL_RESOLUTION+1];
     int                             nWidth = 0;
     int                             nHeight = 0;
 
     if(::DevQueryCaps( m_hDC
                       ,CAPS_FAMILY
-                      ,CAPS_VERTICAL_RESOLUTION
+                      ,CAPS_VERTICAL_RESOLUTION+1
                       ,lArray
                      ))
     {