]> git.saurik.com Git - wxWidgets.git/commitdiff
Applied patch #1396039 (Notebook tab bitmaps)
authorStefan Neis <Stefan.Neis@t-online.de>
Tue, 3 Jan 2006 16:52:50 +0000 (16:52 +0000)
committerStefan Neis <Stefan.Neis@t-online.de>
Tue, 3 Jan 2006 16:52:50 +0000 (16:52 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36665 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/os2/private.h
src/os2/bitmap.cpp
src/os2/notebook.cpp

index d571467d30a99a598b9956fd41ec6851c4dab742..a4e579fdf96f7f4388f735f68d5193612bcb237a 100644 (file)
@@ -293,6 +293,7 @@ extern LONG APIENTRY wxSubclassedGenericControlProc(WXHWND hWnd, WXDWORD message
 // OS/2 convention of the mask is opposed to the wxWidgets one, so we need
 // to invert the mask each time we pass one/get one to/from Windows
 extern HBITMAP wxInvertMask(HBITMAP hbmpMask, int w = 0, int h = 0);
+extern HBITMAP wxFlipBmp(HBITMAP hbmp, int w = 0, int h = 0);
 
 // ---------------------------------------------------------------------------
 // global data
index 4f96446eef380ed48071e31e430974b412d6ddb8..9139803c490adc1cc356d9e0fc308c86c0be9996 100644 (file)
@@ -1620,3 +1620,80 @@ HBITMAP wxInvertMask(
 
     return hBmpInvMask;
 } // end of WxWinGdi_InvertMask
+
+HBITMAP wxFlipBmp( HBITMAP hBmp, int nWidth, int nHeight )
+{
+    wxCHECK_MSG( hBmp, 0, _T("invalid bitmap in wxFlipBmp") );
+
+    //
+    // Get width/height from the bitmap if not given
+    //
+    if (!nWidth || !nHeight)
+    {
+        BITMAPINFOHEADER2 vBmhdr;
+
+        vBmhdr.cbFix  = 16;
+        ::GpiQueryBitmapInfoHeader( hBmp,
+                                    &vBmhdr );
+        nWidth        = (int)vBmhdr.cx;
+        nHeight       = (int)vBmhdr.cy;
+    }
+
+    BITMAPINFOHEADER2 vBmih;
+    SIZEL             vSize     = {0, 0};
+    DEVOPENSTRUC      vDop      = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
+    HDC               hDCSrc    = ::DevOpenDC(  vHabmain,
+                                                OD_MEMORY,
+                                                "*",
+                                                5L,
+                                                (PDEVOPENDATA)&vDop,
+                                                NULLHANDLE  );
+    HDC               hDCDst    = ::DevOpenDC(  vHabmain,
+                                                OD_MEMORY,
+                                                "*",
+                                                5L,
+                                                (PDEVOPENDATA)&vDop,
+                                                NULLHANDLE  );
+    HPS               hPSSrc    = ::GpiCreatePS(  vHabmain,
+                                                  hDCSrc,
+                                                  &vSize,
+                                                  PU_PELS | GPIA_ASSOC  );
+    HPS               hPSDst    = ::GpiCreatePS(  vHabmain,
+                                                  hDCDst,
+                                                  &vSize,
+                                                  PU_PELS | GPIA_ASSOC  );
+    POINTL            vPoint[4] = { {0,      nHeight},
+                                    {nWidth, 0},
+                                    {0,      0},
+                                    {nWidth, nHeight} };
+
+    memset(&vBmih, '\0', 16);
+    vBmih.cbFix     = 16;
+    vBmih.cx        = nWidth;
+    vBmih.cy        = nHeight;
+    vBmih.cPlanes   = 1;
+    vBmih.cBitCount = 24;
+
+    HBITMAP hInvBmp = ::GpiCreateBitmap(  hPSDst,
+                                          &vBmih,
+                                          0L,
+                                          NULL,
+                                          NULL  );
+
+    ::GpiSetBitmap(hPSSrc, (HBITMAP) hBmp);
+    ::GpiSetBitmap(hPSDst, (HBITMAP) hInvBmp);
+
+    ::GpiBitBlt(  hPSDst,
+                  hPSSrc,
+                  4L,
+                  vPoint,
+                  ROP_SRCCOPY,
+                  BBO_IGNORE  );
+
+    ::GpiDestroyPS(hPSSrc);
+    ::GpiDestroyPS(hPSDst);
+    ::DevCloseDC(hDCSrc);
+    ::DevCloseDC(hDCDst);
+
+    return hInvBmp;
+} // end of wxFlipBmp
index 35513ca1e97dd1c29deb68ee79e271fee34da029..ee9b6810ebfe2c74e1188fe15f5c18c184a6ffdf 100644 (file)
@@ -318,7 +318,7 @@ bool wxNotebook::SetPageImage (
     return (bool)::WinSendMsg( GetHWND()
                               ,BKM_SETTABBITMAP
                               ,MPFROMLONG((ULONG)m_alPageId[nPage])
-                              ,(MPARAM)vBitmap.GetHBITMAP()
+                              ,(MPARAM)wxFlipBmp(vBitmap.GetHBITMAP())
                              );
 } // end of wxNotebook::SetPageImage