From 59fb774d924754f60063924a01b73989908dc45e Mon Sep 17 00:00:00 2001 From: Stefan Neis Date: Tue, 3 Jan 2006 16:52:50 +0000 Subject: [PATCH] Applied patch #1396039 (Notebook tab bitmaps) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36665 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/os2/private.h | 1 + src/os2/bitmap.cpp | 77 ++++++++++++++++++++++++++++++++++++++++ src/os2/notebook.cpp | 2 +- 3 files changed, 79 insertions(+), 1 deletion(-) diff --git a/include/wx/os2/private.h b/include/wx/os2/private.h index d571467d30..a4e579fdf9 100644 --- a/include/wx/os2/private.h +++ b/include/wx/os2/private.h @@ -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 diff --git a/src/os2/bitmap.cpp b/src/os2/bitmap.cpp index 4f96446eef..9139803c49 100644 --- a/src/os2/bitmap.cpp +++ b/src/os2/bitmap.cpp @@ -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 diff --git a/src/os2/notebook.cpp b/src/os2/notebook.cpp index 35513ca1e9..ee9b6810eb 100644 --- a/src/os2/notebook.cpp +++ b/src/os2/notebook.cpp @@ -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 -- 2.45.2