]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/dc.cpp
check that wxString is valid before dumping it
[wxWidgets.git] / src / os2 / dc.cpp
index 696c32f4a1176bca7aa8a2bf4661ddbd7484ce6b..c433083e44f6fc8bafa3a38b7d1d95268a162617 100644 (file)
@@ -32,7 +32,6 @@
 #include "wx/dcprint.h"
 
 #include <string.h>
-#include <math.h>
 
 #include "wx/os2/private.h"
 
@@ -68,11 +67,6 @@ static const int VIEWPORT_EXTENT = 1000;
 static const int MM_POINTS = 9;
 static const int MM_METRIC = 10;
 
-// usually this is defined in math.h
-#ifndef M_PI
-    static const double M_PI = 3.14159265358979323846;
-#endif // M_PI
-
 // ---------------------------------------------------------------------------
 // private functions
 // ---------------------------------------------------------------------------
@@ -584,7 +578,7 @@ bool wxDC::DoFloodFill(
     if ((lHits = ::GpiFloodFill(m_hPS, lOptions, lColor)) != GPI_ERROR)
         bSuccess = true;
 
-    return true;
+    return bSuccess;
 } // end of wxDC::DoFloodFill
 
 bool wxDC::DoGetPixel(
@@ -598,17 +592,7 @@ bool wxDC::DoGetPixel(
 
     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
@@ -618,7 +602,7 @@ bool wxDC::DoGetPixel(
                   ,GetGValue(lColor)
                   ,GetBValue(lColor)
                  );
-    return(lColor == lPencolor);
+    return true;
 } // end of wxDC::DoGetPixel
 
 void wxDC::DoCrossHair(
@@ -1310,7 +1294,7 @@ void wxDC::DoDrawBitmap(
     if (!IsKindOf(CLASSINFO(wxPrinterDC)))
     {
         HBITMAP                         hBitmap =  (HBITMAP)rBmp.GetHBITMAP();
-        HBITMAP                         hBitmapOld;
+        HBITMAP                         hBitmapOld = NULLHANDLE;
         POINTL                          vPoint[4];
 
         vY = OS2Y(vY,rBmp.GetHeight());
@@ -1403,7 +1387,7 @@ void wxDC::DoDrawBitmap(
                     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)
@@ -2244,24 +2228,22 @@ void wxDC::DoGetTextExtent(
     int                             l;
     FONTMETRICS                     vFM; // metrics structure
     BOOL                            bRc;
-    char*                           pStr;
     ERRORID                         vErrorCode; // last error id code
     wxFont*                         pFontToUse = (wxFont*)pTheFont;
 
-    char                            zMsg[128]; // DEBUG
+    wxChar                          zMsg[128]; // DEBUG
     wxString                        sError;
 
     if (!pFontToUse)
         pFontToUse = (wxFont*)&m_font;
     l = rsString.length();
-    pStr = (PCH) rsString.c_str();
 
     //
     // In world coordinates.
     //
     bRc = ::GpiQueryTextBox( m_hPS
                             ,l
-                            ,pStr
+                            ,(PCH)rsString.c_str()
                             ,TXTBOX_COUNT // return maximum information
                             ,avPoint      // array of coordinates points
                            );
@@ -2270,8 +2252,8 @@ void wxDC::DoGetTextExtent(
        vErrorCode = ::WinGetLastError(wxGetInstance());
        sError = wxPMErrorToStr(vErrorCode);
        // DEBUG
-       sprintf(zMsg, "GpiQueryTextBox for %s: failed with Error: %lx - %s", pStr, vErrorCode, sError.c_str());
-       (void)wxMessageBox( "wxWidgets Menu sample"
+       wxSprintf(zMsg, _T("GpiQueryTextBox for %s: failed with Error: %lx - %s"), rsString.c_str(), vErrorCode, sError.c_str());
+       (void)wxMessageBox( _T("wxWidgets Menu sample")
                           ,zMsg
                           ,wxICON_INFORMATION
                          );
@@ -2848,8 +2830,8 @@ void wxDC::DoGetSizeMM(
 wxSize wxDC::GetPPI() const
 {
     LONG                            lArray[CAPS_VERTICAL_RESOLUTION];
-    int                             nWidth;
-    int                             nHeight;
+    int                             nWidth = 0;
+    int                             nHeight = 0;
 
     if(::DevQueryCaps( m_hDC
                       ,CAPS_FAMILY