]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/bitmap.cpp
Needed to add #include "wx/statusbr.h" to know that wxStatusBar is derived
[wxWidgets.git] / src / os2 / bitmap.cpp
index a5d4955403539763dcee9e93756c4879e55e2913..4f96446eef380ed48071e31e430974b412d6ddb8 100644 (file)
@@ -9,10 +9,6 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-    #pragma implementation "bitmap.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -211,14 +207,14 @@ wxBitmap::wxBitmap(
         {
             for (nCols = 0; nCols < nBytesPerLine; nCols++)
             {
-                unsigned char       ucVal = *pzSrc++;
-                unsigned char       ucReversed = 0;
-                int                 nBits;
+                unsigned char ucVal = *pzSrc++;
+                unsigned char ucReversed = 0;
+                int nBits;
 
                 for (nBits = 0; nBits < 8; nBits++)
                 {
                     ucReversed <<= 1;
-                    ucReversed |= (ucVal & 0x01);
+                    ucReversed = (unsigned char)(ucReversed | (ucVal & 0x01));
                     ucVal >>= 1;
                 }
                 *pzDst++ = ucReversed;
@@ -242,7 +238,7 @@ wxBitmap::wxBitmap(
     vHeader.cx              = (USHORT)nWidth;
     vHeader.cy              = (USHORT)nHeight;
     vHeader.cPlanes         = 1L;
-    vHeader.cBitCount       = nDepth;
+    vHeader.cBitCount       = (USHORT)nDepth;
     vHeader.usReserved      = 0;
 
     memset(&vInfo, '\0', 16);
@@ -250,7 +246,7 @@ wxBitmap::wxBitmap(
     vInfo.cx              = (USHORT)nWidth;
     vInfo.cy              = (USHORT)nHeight;
     vInfo.cPlanes         = 1L;
-    vInfo.cBitCount       = nDepth;
+    vInfo.cBitCount       = (USHORT)nDepth;
 
     HBITMAP                         hBmp = ::GpiCreateBitmap(hPs, &vHeader, CBM_INIT, (PBYTE)pzData, &vInfo);
 
@@ -369,7 +365,7 @@ bool wxBitmap::Create(
         vHeader.cx        = nW;
         vHeader.cy        = nH;
         vHeader.cPlanes   = 1;
-        vHeader.cBitCount = lBitCount;
+        vHeader.cBitCount = (USHORT)lBitCount;
 
         hBmp = ::GpiCreateBitmap( hPSScreen
                                  ,&vHeader
@@ -407,6 +403,34 @@ bool wxBitmap::CreateFromXpm(
 #endif
 } // end of wxBitmap::CreateFromXpm
 
+bool wxBitmap::LoadFile(const wxString& filename, long type)
+{
+    UnRef();
+
+    wxBitmapHandler *handler = wxDynamicCast(FindHandler(type), wxBitmapHandler);
+
+    if ( handler )
+    {
+        m_refData = new wxBitmapRefData;
+
+        return handler->LoadFile(this, filename, type, -1, -1);
+    }
+#if wxUSE_IMAGE
+    else // no bitmap handler found
+    {
+        wxImage image;
+        if ( image.LoadFile( filename, type ) && image.Ok() )
+        {
+            *this = wxBitmap(image);
+
+            return true;
+        }
+    }
+#endif // wxUSE_IMAGE
+
+    return false;
+}
+
 bool wxBitmap::LoadFile(
   int                               nId
 , long                              lType
@@ -1181,9 +1205,7 @@ void wxBitmap::SetMask(
     GetBitmapData()->m_pBitmapMask = pMask;
 } // end of wxBitmap::SetMask
 
-wxBitmap wxBitmap::GetBitmapForDC(
-  wxDC&                             rDc
-) const
+wxBitmap wxBitmap::GetBitmapForDC(wxDC& WXUNUSED(rDc)) const
 {
     return(*this);
 } // end of wxBitmap::GetBitmapForDC
@@ -1429,18 +1451,16 @@ bool wxMask::Create(
 // wxBitmapHandler
 // ----------------------------------------------------------------------------
 
-bool wxBitmapHandler::Create(
-  wxGDIImage*                       pImage
-, void*                             pData
-, long                              lFlags
-, int                               nWidth
-, int                               nHeight
-, int                               nDepth
-)
+bool wxBitmapHandler::Create( wxGDIImage* pImage,
+                              void*       pData,
+                              long        WXUNUSED(lFlags),
+                              int         nWidth,
+                              int         nHeight,
+                              int         nDepth)
 {
-    wxBitmap*                       pBitmap = wxDynamicCast( pImage
-                                                            ,wxBitmap
-                                                           );
+    wxBitmap* pBitmap = wxDynamicCast( pImage
+                                      ,wxBitmap
+                                       );
 
     return(pBitmap ? Create( pBitmap
                             ,pData
@@ -1509,6 +1529,17 @@ bool wxBitmapHandler::LoadFile(
     return false;
 }
 
+bool wxBitmapHandler::LoadFile(
+  wxBitmap*                         WXUNUSED(pBitmap)
+, const wxString&                   WXUNUSED(rName)
+, long                              WXUNUSED(lType)
+, int                               WXUNUSED(nDesiredWidth)
+, int                               WXUNUSED(nDesiredHeight)
+)
+{
+    return false;
+}
+
 bool wxBitmapHandler::SaveFile(
   wxBitmap*                         WXUNUSED(pBitmap)
 , const wxString&                   WXUNUSED(rName)
@@ -1589,4 +1620,3 @@ HBITMAP wxInvertMask(
 
     return hBmpInvMask;
 } // end of WxWinGdi_InvertMask
-