1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #include <string.h> 29*cdf0e10cSrcweir #include <svpm.h> 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #define _SV_SALGDI2_CXX 32*cdf0e10cSrcweir #include <salbmp.h> 33*cdf0e10cSrcweir #include <saldata.hxx> 34*cdf0e10cSrcweir #ifndef _SV_SALIDS_HRC 35*cdf0e10cSrcweir #include <salids.hrc> 36*cdf0e10cSrcweir #endif 37*cdf0e10cSrcweir #include <salgdi.h> 38*cdf0e10cSrcweir #include <salvd.h> 39*cdf0e10cSrcweir #include <vcl/salbtype.hxx> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #ifndef __H_FT2LIB 42*cdf0e10cSrcweir #include <wingdi.h> 43*cdf0e10cSrcweir #include <ft2lib.h> 44*cdf0e10cSrcweir #endif 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir BOOL bFastTransparent = FALSE; 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir // ----------- 49*cdf0e10cSrcweir // - Defines - 50*cdf0e10cSrcweir // ----------- 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir #define RGBCOLOR( r, g, b ) ((ULONG)(((BYTE)(b)|((USHORT)(g)<<8))|(((ULONG)(BYTE)(r))<<16))) 53*cdf0e10cSrcweir #define TY( y ) (mnHeight-(y)-1) 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir // --------------- 56*cdf0e10cSrcweir // - SalGraphics - 57*cdf0e10cSrcweir // --------------- 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir bool Os2SalGraphics::supportsOperation( OutDevSupportType ) const 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir return false; 62*cdf0e10cSrcweir } 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir void Os2SalGraphics::copyBits( const SalTwoRect* pPosAry, SalGraphics* pSrcGraphics ) 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir HPS hSrcPS; 68*cdf0e10cSrcweir POINTL thePoints[4]; 69*cdf0e10cSrcweir long nSrcHeight; 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir if ( pSrcGraphics ) 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir //hSrcPS = pSrcGraphics->mhPS; 74*cdf0e10cSrcweir //nSrcHeight = pSrcGraphics->mnHeight; 75*cdf0e10cSrcweir hSrcPS = static_cast<Os2SalGraphics*>(pSrcGraphics)->mhPS; 76*cdf0e10cSrcweir nSrcHeight = static_cast<Os2SalGraphics*>(pSrcGraphics)->mnHeight; 77*cdf0e10cSrcweir } 78*cdf0e10cSrcweir else 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir hSrcPS = mhPS; 81*cdf0e10cSrcweir nSrcHeight = mnHeight; 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir // lower-left corner of target 85*cdf0e10cSrcweir thePoints[0].x = pPosAry->mnDestX; 86*cdf0e10cSrcweir thePoints[0].y = TY( pPosAry->mnDestY + pPosAry->mnDestHeight - 1 ); 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir // upper-right corner of target 89*cdf0e10cSrcweir thePoints[1].x = pPosAry->mnDestX + pPosAry->mnDestWidth; 90*cdf0e10cSrcweir thePoints[1].y = TY( pPosAry->mnDestY - 1 ); 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir // lower-left corner of source 93*cdf0e10cSrcweir thePoints[2].x = pPosAry->mnSrcX; 94*cdf0e10cSrcweir thePoints[2].y = nSrcHeight - ( pPosAry->mnSrcY + pPosAry->mnSrcHeight ); 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir if ( ( pPosAry->mnDestWidth != pPosAry->mnSrcWidth ) || ( pPosAry->mnDestHeight != pPosAry->mnSrcHeight ) ) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir // upper-right corner of Source 99*cdf0e10cSrcweir thePoints[3].x = pPosAry->mnSrcX + pPosAry->mnSrcWidth; 100*cdf0e10cSrcweir thePoints[3].y = nSrcHeight - pPosAry->mnSrcY + pPosAry->mnSrcHeight; 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir GpiBitBlt( mhPS, hSrcPS, 4, thePoints, 103*cdf0e10cSrcweir mbXORMode ? ROP_SRCINVERT : ROP_SRCCOPY, BBO_IGNORE ); 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir else 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir GpiBitBlt( mhPS, hSrcPS, 3, thePoints, 108*cdf0e10cSrcweir mbXORMode ? ROP_SRCINVERT : ROP_SRCCOPY, BBO_IGNORE ); 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir // ----------------------------------------------------------------------- 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir void Os2SalGraphics::copyArea( long nDestX, long nDestY, 115*cdf0e10cSrcweir long nSrcX, long nSrcY, 116*cdf0e10cSrcweir long nSrcWidth, long nSrcHeight, 117*cdf0e10cSrcweir USHORT nFlags ) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir POINTL thePoints[3]; 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir // lower-left corner of target 122*cdf0e10cSrcweir thePoints[0].x = nDestX; 123*cdf0e10cSrcweir thePoints[0].y = TY( nDestY + nSrcHeight - 1 ); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir // upper-right corner of target 126*cdf0e10cSrcweir thePoints[1].x = nDestX + nSrcWidth; 127*cdf0e10cSrcweir thePoints[1].y = TY( nDestY - 1 ); 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir // lower-left corner of source 130*cdf0e10cSrcweir thePoints[2].x = nSrcX; 131*cdf0e10cSrcweir thePoints[2].y = TY( nSrcY + nSrcHeight - 1); 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir if ( (nFlags & SAL_COPYAREA_WINDOWINVALIDATE) && mbWindow ) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir // Overlap-Bereich berechnen und invalidieren 136*cdf0e10cSrcweir Point aVCLSrcPos( nSrcX, nSrcY ); 137*cdf0e10cSrcweir Size aVCLSrcSize( nSrcWidth, nSrcHeight ); 138*cdf0e10cSrcweir Rectangle aVCLSrcRect( aVCLSrcPos, aVCLSrcSize ); 139*cdf0e10cSrcweir Rectangle aVCLClipRect; 140*cdf0e10cSrcweir SWP aSWP; 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir WinQueryWindowPos( mhWnd, &aSWP ); 143*cdf0e10cSrcweir aVCLClipRect.Right() = aSWP.cx-1; 144*cdf0e10cSrcweir aVCLClipRect.Bottom() = aSWP.cy-1; 145*cdf0e10cSrcweir if ( !aVCLSrcRect.Intersection( aVCLClipRect ).IsEmpty() ) 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir RECTL aSrcRect; 148*cdf0e10cSrcweir RECTL aTempRect; 149*cdf0e10cSrcweir HRGN hInvalidateRgn; 150*cdf0e10cSrcweir HRGN hTempRgn; 151*cdf0e10cSrcweir HWND hWnd; 152*cdf0e10cSrcweir long nRgnType; 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir long nVCLScrHeight = aVCLSrcRect.GetHeight(); 155*cdf0e10cSrcweir aSrcRect.xLeft = aVCLSrcRect.Left(); 156*cdf0e10cSrcweir aSrcRect.yBottom = TY( aVCLSrcRect.Top()+nVCLScrHeight-1 ); 157*cdf0e10cSrcweir aSrcRect.xRight = aSrcRect.xLeft+aVCLSrcRect.GetWidth(); 158*cdf0e10cSrcweir aSrcRect.yTop = aSrcRect.yBottom+nVCLScrHeight; 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir // Rechteck in Screen-Koordinaaten umrechnen 161*cdf0e10cSrcweir POINTL aPt; 162*cdf0e10cSrcweir long nScreenDX = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ); 163*cdf0e10cSrcweir long nScreenDY = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ); 164*cdf0e10cSrcweir aPt.x = 0; 165*cdf0e10cSrcweir aPt.y = 0; 166*cdf0e10cSrcweir WinMapWindowPoints( mhWnd, HWND_DESKTOP, &aPt, 1 ); 167*cdf0e10cSrcweir aSrcRect.xLeft += aPt.x; 168*cdf0e10cSrcweir aSrcRect.yTop += aPt.y; 169*cdf0e10cSrcweir aSrcRect.xRight += aPt.x; 170*cdf0e10cSrcweir aSrcRect.yBottom += aPt.y; 171*cdf0e10cSrcweir hInvalidateRgn = 0; 172*cdf0e10cSrcweir // Bereiche ausserhalb des sichtbaren Bereiches berechnen 173*cdf0e10cSrcweir if ( aSrcRect.xLeft < 0 ) 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir if ( !hInvalidateRgn ) 176*cdf0e10cSrcweir hInvalidateRgn = GpiCreateRegion( mhPS, 1, &aSrcRect ); 177*cdf0e10cSrcweir aTempRect.xLeft = -31999; 178*cdf0e10cSrcweir aTempRect.yBottom = 0; 179*cdf0e10cSrcweir aTempRect.xRight = 0; 180*cdf0e10cSrcweir aTempRect.yTop = 31999; 181*cdf0e10cSrcweir hTempRgn = GpiCreateRegion( mhPS, 1, &aTempRect ); 182*cdf0e10cSrcweir GpiCombineRegion( mhPS, hInvalidateRgn, hInvalidateRgn, hTempRgn, CRGN_DIFF ); 183*cdf0e10cSrcweir GpiDestroyRegion( mhPS, hTempRgn ); 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir if ( aSrcRect.yBottom < 0 ) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir if ( !hInvalidateRgn ) 188*cdf0e10cSrcweir hInvalidateRgn = GpiCreateRegion( mhPS, 1, &aSrcRect ); 189*cdf0e10cSrcweir aTempRect.xLeft = 0; 190*cdf0e10cSrcweir aTempRect.yBottom = -31999; 191*cdf0e10cSrcweir aTempRect.xRight = 31999; 192*cdf0e10cSrcweir aTempRect.yTop = 0; 193*cdf0e10cSrcweir hTempRgn = GpiCreateRegion( mhPS, 1, &aTempRect ); 194*cdf0e10cSrcweir GpiCombineRegion( mhPS, hInvalidateRgn, hInvalidateRgn, hTempRgn, CRGN_DIFF ); 195*cdf0e10cSrcweir GpiDestroyRegion( mhPS, hTempRgn ); 196*cdf0e10cSrcweir } 197*cdf0e10cSrcweir if ( aSrcRect.xRight > nScreenDX ) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir if ( !hInvalidateRgn ) 200*cdf0e10cSrcweir hInvalidateRgn = GpiCreateRegion( mhPS, 1, &aSrcRect ); 201*cdf0e10cSrcweir aTempRect.xLeft = nScreenDX; 202*cdf0e10cSrcweir aTempRect.yBottom = 0; 203*cdf0e10cSrcweir aTempRect.xRight = 31999; 204*cdf0e10cSrcweir aTempRect.yTop = 31999; 205*cdf0e10cSrcweir hTempRgn = GpiCreateRegion( mhPS, 1, &aTempRect ); 206*cdf0e10cSrcweir GpiCombineRegion( mhPS, hInvalidateRgn, hInvalidateRgn, hTempRgn, CRGN_DIFF ); 207*cdf0e10cSrcweir GpiDestroyRegion( mhPS, hTempRgn ); 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir if ( aSrcRect.yTop > nScreenDY ) 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir if ( !hInvalidateRgn ) 212*cdf0e10cSrcweir hInvalidateRgn = GpiCreateRegion( mhPS, 1, &aSrcRect ); 213*cdf0e10cSrcweir aTempRect.xLeft = 0; 214*cdf0e10cSrcweir aTempRect.yBottom = nScreenDY; 215*cdf0e10cSrcweir aTempRect.xRight = 31999; 216*cdf0e10cSrcweir aTempRect.yTop = 31999; 217*cdf0e10cSrcweir hTempRgn = GpiCreateRegion( mhPS, 1, &aTempRect ); 218*cdf0e10cSrcweir GpiCombineRegion( mhPS, hInvalidateRgn, hInvalidateRgn, hTempRgn, CRGN_DIFF ); 219*cdf0e10cSrcweir GpiDestroyRegion( mhPS, hTempRgn ); 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir // Bereiche die von anderen Fenstern ueberlagert werden berechnen 223*cdf0e10cSrcweir // Calculate areas that are overlapped by other windows 224*cdf0e10cSrcweir HWND hWndParent = WinQueryWindow( mhWnd, QW_PARENT ); 225*cdf0e10cSrcweir hWnd = WinQueryWindow( HWND_DESKTOP, QW_TOP ); 226*cdf0e10cSrcweir aVCLSrcRect = Rectangle( aSrcRect.xLeft, aSrcRect.yBottom, aSrcRect.xRight, aSrcRect.yTop ); 227*cdf0e10cSrcweir while ( hWnd ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir if ( hWnd == hWndParent ) 230*cdf0e10cSrcweir break; 231*cdf0e10cSrcweir if ( WinIsWindowVisible( hWnd ) ) 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir WinQueryWindowPos( hWnd, &aSWP ); 234*cdf0e10cSrcweir if ( !(aSWP.fl & SWP_MINIMIZE) ) 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir aVCLClipRect = Rectangle( Point( aSWP.x, aSWP.y ), Size( aSWP.cx, aSWP.cy ) ); 237*cdf0e10cSrcweir if ( aVCLSrcRect.IsOver( aVCLClipRect ) ) 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir if ( !hInvalidateRgn ) 240*cdf0e10cSrcweir hInvalidateRgn = GpiCreateRegion( mhPS, 1, &aSrcRect ); 241*cdf0e10cSrcweir aTempRect.xLeft = aSWP.x; 242*cdf0e10cSrcweir aTempRect.yBottom = aSWP.y; 243*cdf0e10cSrcweir aTempRect.xRight = aTempRect.xLeft+aSWP.cx; 244*cdf0e10cSrcweir aTempRect.yTop = aTempRect.yBottom+aSWP.cy; 245*cdf0e10cSrcweir hTempRgn = GpiCreateRegion( mhPS, 1, &aTempRect ); 246*cdf0e10cSrcweir GpiCombineRegion( mhPS, hInvalidateRgn, hInvalidateRgn, hTempRgn, CRGN_DIFF ); 247*cdf0e10cSrcweir GpiDestroyRegion( mhPS, hTempRgn ); 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir hWnd = WinQueryWindow( hWnd, QW_NEXT ); 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir if ( hInvalidateRgn ) 255*cdf0e10cSrcweir { 256*cdf0e10cSrcweir hTempRgn = GpiCreateRegion( mhPS, 1, &aSrcRect ); 257*cdf0e10cSrcweir nRgnType = GpiCombineRegion( mhPS, hInvalidateRgn, hTempRgn, hInvalidateRgn, CRGN_DIFF ); 258*cdf0e10cSrcweir GpiDestroyRegion( mhPS, hTempRgn ); 259*cdf0e10cSrcweir if ( (nRgnType != RGN_ERROR) && (nRgnType != RGN_NULL) ) 260*cdf0e10cSrcweir { 261*cdf0e10cSrcweir long nOffX = (nDestX-nSrcX); 262*cdf0e10cSrcweir long nOffY = (nSrcY-nDestY); 263*cdf0e10cSrcweir aPt.x = nOffX-aPt.x; 264*cdf0e10cSrcweir aPt.y = nOffY-aPt.y; 265*cdf0e10cSrcweir GpiOffsetRegion( mhPS, hInvalidateRgn, &aPt ); 266*cdf0e10cSrcweir WinInvalidateRegion( mhWnd, hInvalidateRgn, TRUE ); 267*cdf0e10cSrcweir // Hier loesen wir nur ein Update aus, wenn es der 268*cdf0e10cSrcweir // MainThread ist, damit es beim Bearbeiten der 269*cdf0e10cSrcweir // Paint-Message keinen Deadlock gibt, da der 270*cdf0e10cSrcweir // SolarMutex durch diesen Thread schon gelockt ist 271*cdf0e10cSrcweir SalData* pSalData = GetSalData(); 272*cdf0e10cSrcweir ULONG nCurThreadId = GetCurrentThreadId(); 273*cdf0e10cSrcweir if ( pSalData->mnAppThreadId == nCurThreadId ) 274*cdf0e10cSrcweir WinUpdateWindow( mhWnd ); 275*cdf0e10cSrcweir } 276*cdf0e10cSrcweir GpiDestroyRegion( mhPS, hInvalidateRgn ); 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir GpiBitBlt( mhPS, mhPS, 3, thePoints, 282*cdf0e10cSrcweir ROP_SRCCOPY, BBO_IGNORE ); 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir // ----------------------------------------------------------------------- 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir void ImplDrawBitmap( HPS hPS, long nScreenHeight, 289*cdf0e10cSrcweir const SalTwoRect* pPosAry, const Os2SalBitmap& rSalBitmap, 290*cdf0e10cSrcweir BOOL bPrinter, int nDrawMode ) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir if( hPS ) 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir HANDLE hDrawDIB; 295*cdf0e10cSrcweir HBITMAP hDrawDDB = rSalBitmap.ImplGethDDB(); 296*cdf0e10cSrcweir Os2SalBitmap* pTmpSalBmp = NULL; 297*cdf0e10cSrcweir BOOL bPrintDDB = ( bPrinter && hDrawDDB ); 298*cdf0e10cSrcweir BOOL bDrawDDB1 = ( ( rSalBitmap.GetBitCount() == 1 ) && hDrawDDB ); 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir if( bPrintDDB || bDrawDDB1 ) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir pTmpSalBmp = new Os2SalBitmap; 303*cdf0e10cSrcweir pTmpSalBmp->Create( rSalBitmap, rSalBitmap.GetBitCount() ); 304*cdf0e10cSrcweir hDrawDIB = pTmpSalBmp->ImplGethDIB(); 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir else 307*cdf0e10cSrcweir hDrawDIB = rSalBitmap.ImplGethDIB(); 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir if( hDrawDIB ) 310*cdf0e10cSrcweir { 311*cdf0e10cSrcweir HANDLE hSubst = rSalBitmap.ImplGethDIB1Subst(); 312*cdf0e10cSrcweir POINTL pts[ 4 ]; 313*cdf0e10cSrcweir BITMAPINFO2* pBI = (BITMAPINFO2*) hDrawDIB; 314*cdf0e10cSrcweir BITMAPINFOHEADER2* pBIH = (BITMAPINFOHEADER2*) pBI; 315*cdf0e10cSrcweir const long nHeight = pBIH->cy; 316*cdf0e10cSrcweir long nInfoSize = *(ULONG*) pBI + rSalBitmap.ImplGetDIBColorCount( hDrawDIB ) * sizeof( RGB2 ); 317*cdf0e10cSrcweir BYTE* pBits = (BYTE*) pBI + nInfoSize; 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir pts[0].x = pPosAry->mnDestX; 320*cdf0e10cSrcweir pts[0].y = nScreenHeight - pPosAry->mnDestY - pPosAry->mnDestHeight; 321*cdf0e10cSrcweir pts[1].x = pPosAry->mnDestX + pPosAry->mnDestWidth - 1; 322*cdf0e10cSrcweir pts[1].y = nScreenHeight - pPosAry->mnDestY - 1; 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir pts[2].x = pPosAry->mnSrcX; 325*cdf0e10cSrcweir pts[2].y = nHeight - ( pPosAry->mnSrcY + pPosAry->mnSrcHeight ); 326*cdf0e10cSrcweir pts[3].x = pPosAry->mnSrcX + pPosAry->mnSrcWidth; 327*cdf0e10cSrcweir pts[3].y = nHeight - pPosAry->mnSrcY; 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir // if we've got a 1Bit DIB, we create a 4Bit substitute 330*cdf0e10cSrcweir if( ( pBIH->cBitCount == 1 ) && !hSubst ) 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir // create 4Bit substitute 333*cdf0e10cSrcweir hSubst = Os2SalBitmap::ImplCreateDIB4FromDIB1( hDrawDIB ); 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir // replace substitute only, if it is no temporary SalBitmap 336*cdf0e10cSrcweir if( !( bPrintDDB || bDrawDDB1 ) ) 337*cdf0e10cSrcweir ( (Os2SalBitmap&) rSalBitmap ).ImplReplacehDIB1Subst( hSubst ); 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir if( hSubst ) 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir pBI = (BITMAPINFO2*) hSubst; 343*cdf0e10cSrcweir pBIH = (BITMAPINFOHEADER2*) pBI; 344*cdf0e10cSrcweir nInfoSize = *(ULONG*) pBI + rSalBitmap.ImplGetDIBColorCount( hSubst ) * sizeof( RGB2 ); 345*cdf0e10cSrcweir pBits = (BYTE*) pBI + nInfoSize; 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir if( bPrinter ) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir BYTE* pDummy; 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir // expand 8Bit-DIB's to 24Bit-DIB's, because some printer drivers 353*cdf0e10cSrcweir // have problems to print these DIB's (strange) 354*cdf0e10cSrcweir if( pBIH->cBitCount == 8 && pBIH->ulCompression == BCA_UNCOMP ) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir const long nWidth = pBIH->cx; 357*cdf0e10cSrcweir const long nHeight = pBIH->cy; 358*cdf0e10cSrcweir const long nWidthAl8 = AlignedWidth4Bytes( nWidth * 8 ); 359*cdf0e10cSrcweir const long nWidthAl24 = AlignedWidth4Bytes( nWidth * 24 ); 360*cdf0e10cSrcweir const long nNewImageSize = nHeight * nWidthAl24; 361*cdf0e10cSrcweir BITMAPINFOHEADER2* pNewInfo; 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir pDummy = new BYTE[ sizeof( BITMAPINFO2 ) + nNewImageSize ]; 364*cdf0e10cSrcweir memset( pDummy, 0, sizeof( BITMAPINFO2 ) ); 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir pNewInfo = (BITMAPINFOHEADER2*) pDummy; 367*cdf0e10cSrcweir pNewInfo->cbFix = sizeof( BITMAPINFOHEADER2 ); 368*cdf0e10cSrcweir pNewInfo->cx = nWidth; 369*cdf0e10cSrcweir pNewInfo->cy = nHeight; 370*cdf0e10cSrcweir pNewInfo->cPlanes = 1; 371*cdf0e10cSrcweir pNewInfo->cBitCount = 24; 372*cdf0e10cSrcweir pNewInfo->ulCompression = BCA_UNCOMP; 373*cdf0e10cSrcweir pNewInfo->cbImage = nNewImageSize; 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir BYTE* pBitsSrc = (BYTE*) pBIH + nInfoSize; 376*cdf0e10cSrcweir BYTE* pBitsDst = pDummy + sizeof( BITMAPINFO2 ); 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir for( long nY = 0UL; nY < nHeight; nY++ ) 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir BYTE* pSrcLine = pBitsSrc + nY * nWidthAl8; 381*cdf0e10cSrcweir BYTE* pDstLine = pBitsDst + nY * nWidthAl24; 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir for( long nX = 0UL; nX < nWidth; nX++ ) 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir const RGB2& rQuad = pBI->argbColor[ *pSrcLine++ ]; 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir *pDstLine++ = rQuad.bBlue; 388*cdf0e10cSrcweir *pDstLine++ = rQuad.bGreen; 389*cdf0e10cSrcweir *pDstLine++ = rQuad.bRed; 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir } 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir nInfoSize = sizeof( BITMAPINFO2 ); 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir else 396*cdf0e10cSrcweir { 397*cdf0e10cSrcweir const long nImageSize = ( pBIH->cbImage ? pBIH->cbImage : ( pBIH->cy * AlignedWidth4Bytes( pBIH->cx * pBIH->cBitCount ) ) ); 398*cdf0e10cSrcweir const long nTotalSize = nInfoSize + nImageSize; 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir pDummy = new BYTE[ nTotalSize ]; 401*cdf0e10cSrcweir memcpy( pDummy, pBI, nTotalSize ); 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir GpiDrawBits( hPS, pDummy + nInfoSize, (BITMAPINFO2*) pDummy, 4L, pts, nDrawMode, BBO_IGNORE ); 405*cdf0e10cSrcweir delete[] pDummy; 406*cdf0e10cSrcweir } 407*cdf0e10cSrcweir else 408*cdf0e10cSrcweir GpiDrawBits( hPS, pBits, pBI, 4L, pts, nDrawMode, BBO_IGNORE ); 409*cdf0e10cSrcweir } 410*cdf0e10cSrcweir else if( hDrawDDB && !bPrintDDB ) 411*cdf0e10cSrcweir { 412*cdf0e10cSrcweir POINTL pts[ 4 ]; 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir pts[0].x = pPosAry->mnDestX; 415*cdf0e10cSrcweir pts[0].y = nScreenHeight - pPosAry->mnDestY - pPosAry->mnDestHeight; 416*cdf0e10cSrcweir pts[1].x = pPosAry->mnDestX + pPosAry->mnDestWidth - 1; 417*cdf0e10cSrcweir pts[1].y = nScreenHeight - pPosAry->mnDestY - 1; 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir pts[2].x = pPosAry->mnSrcX; 420*cdf0e10cSrcweir pts[2].y = rSalBitmap.GetSize().Height() - ( pPosAry->mnSrcY + pPosAry->mnSrcHeight ); 421*cdf0e10cSrcweir pts[3].x = pPosAry->mnSrcX + pPosAry->mnSrcWidth; 422*cdf0e10cSrcweir pts[3].y = rSalBitmap.GetSize().Height() - pPosAry->mnSrcY; 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir GpiWCBitBlt( hPS, hDrawDDB, 4L, pts, nDrawMode, BBO_IGNORE ); 425*cdf0e10cSrcweir /* 426*cdf0e10cSrcweir HPS hDrawPS = ImplGetCachedPS( CACHED_HPS_DRAW, hDrawDDB ); 427*cdf0e10cSrcweir Ft2BitBlt( hPS, hDrawPS, 4, pts, nDrawMode, BBO_IGNORE ); 428*cdf0e10cSrcweir ImplReleaseCachedPS( CACHED_HPS_DRAW ); 429*cdf0e10cSrcweir */ 430*cdf0e10cSrcweir } 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir if( bPrintDDB || bDrawDDB1 ) 433*cdf0e10cSrcweir delete pTmpSalBmp; 434*cdf0e10cSrcweir } 435*cdf0e10cSrcweir } 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir // ----------------------------------------------------------------------- 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir void Os2SalGraphics::drawBitmap( const SalTwoRect* pPosAry, 440*cdf0e10cSrcweir const SalBitmap& rSalBitmap ) 441*cdf0e10cSrcweir { 442*cdf0e10cSrcweir ImplDrawBitmap( mhPS, mnHeight, 443*cdf0e10cSrcweir pPosAry, static_cast<const Os2SalBitmap&>(rSalBitmap), 444*cdf0e10cSrcweir mbPrinter, 445*cdf0e10cSrcweir mbXORMode ? ROP_SRCINVERT : ROP_SRCCOPY ); 446*cdf0e10cSrcweir } 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir // ----------------------------------------------------------------------- 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir void Os2SalGraphics::drawBitmap( const SalTwoRect* pPosAry, 451*cdf0e10cSrcweir const SalBitmap& rSalBitmap, 452*cdf0e10cSrcweir SalColor nTransparentColor ) 453*cdf0e10cSrcweir { 454*cdf0e10cSrcweir DBG_ASSERT( !mbPrinter, "No transparency print possible!" ); 455*cdf0e10cSrcweir //const Os2SalBitmap& rSalBitmap = static_cast<const Os2SalBitmap&>(rSSalBitmap); 456*cdf0e10cSrcweir // an FM: kann erst einmal unberuecksichtigt bleiben 457*cdf0e10cSrcweir drawBitmap( pPosAry, rSalBitmap ); 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir // ----------------------------------------------------------------------- 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir void Os2SalGraphics::drawBitmap( const SalTwoRect* pPosAry, 463*cdf0e10cSrcweir const SalBitmap& rSSalBitmap, 464*cdf0e10cSrcweir const SalBitmap& rSTransparentBitmap ) 465*cdf0e10cSrcweir { 466*cdf0e10cSrcweir DBG_ASSERT( !mbPrinter, "No transparency print possible!" ); 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir const Os2SalBitmap& rSalBitmap = static_cast<const Os2SalBitmap&>(rSSalBitmap); 469*cdf0e10cSrcweir const Os2SalBitmap& rTransparentBitmap = static_cast<const Os2SalBitmap&>(rSTransparentBitmap); 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir if( bFastTransparent ) 472*cdf0e10cSrcweir { 473*cdf0e10cSrcweir ImplDrawBitmap( mhPS, mnHeight, pPosAry, rTransparentBitmap, FALSE, ROP_SRCAND ); 474*cdf0e10cSrcweir ImplDrawBitmap( mhPS, mnHeight, pPosAry, rSalBitmap, FALSE, ROP_SRCPAINT ); 475*cdf0e10cSrcweir } 476*cdf0e10cSrcweir else 477*cdf0e10cSrcweir { 478*cdf0e10cSrcweir SalTwoRect aPosAry = *pPosAry; 479*cdf0e10cSrcweir int nDstX = (int) aPosAry.mnDestX; 480*cdf0e10cSrcweir int nDstY = (int) aPosAry.mnDestY; 481*cdf0e10cSrcweir int nDstWidth = (int) aPosAry.mnDestWidth; 482*cdf0e10cSrcweir int nDstHeight = (int) aPosAry.mnDestHeight; 483*cdf0e10cSrcweir HAB hAB = GetSalData()->mhAB; 484*cdf0e10cSrcweir HPS hPS = mhPS; 485*cdf0e10cSrcweir DEVOPENSTRUC aDevOpenStruc = { NULL, (PSZ)"DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL }; 486*cdf0e10cSrcweir SIZEL aSizeL = { nDstWidth, nDstHeight }; 487*cdf0e10cSrcweir POINTL aPtL[ 3 ]; 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir HDC hMemDC = DevOpenDC( hAB, OD_MEMORY, (PSZ)"*", 5L, (PDEVOPENDATA)&aDevOpenStruc, 0 ); 490*cdf0e10cSrcweir HPS hMemPS = Ft2CreatePS( hAB, hMemDC, &aSizeL, GPIT_MICRO | GPIA_ASSOC | PU_PELS ); 491*cdf0e10cSrcweir HBITMAP hMemBitmap = ImplCreateVirDevBitmap( hMemDC, hMemPS, nDstWidth, nDstHeight, 0 ); 492*cdf0e10cSrcweir HBITMAP hMemOld = (HBITMAP) Ft2SetBitmap( hMemPS, hMemBitmap ); 493*cdf0e10cSrcweir HDC hMaskDC = DevOpenDC( hAB, OD_MEMORY, (PSZ)"*", 5L, (PDEVOPENDATA)&aDevOpenStruc, 0 ); 494*cdf0e10cSrcweir HPS hMaskPS = Ft2CreatePS( hAB, hMaskDC, &aSizeL, GPIT_MICRO | GPIA_ASSOC | PU_PELS ); 495*cdf0e10cSrcweir HBITMAP hMaskBitmap = ImplCreateVirDevBitmap( hMaskDC, hMaskPS, nDstWidth, nDstHeight, 0 ); 496*cdf0e10cSrcweir HBITMAP hMaskOld = (HBITMAP) Ft2SetBitmap( hMaskPS, hMaskBitmap ); 497*cdf0e10cSrcweir /* 498*cdf0e10cSrcweir HPS hMemPS = ImplGetCachedPS( CACHED_HPS_1, 0 ); 499*cdf0e10cSrcweir HPS hMaskPS = ImplGetCachedPS( CACHED_HPS_2, 0 ); 500*cdf0e10cSrcweir */ 501*cdf0e10cSrcweir aPosAry.mnDestX = aPosAry.mnDestY = 0L; 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir aPtL[ 0 ].x = 0; 504*cdf0e10cSrcweir aPtL[ 0 ].y = 0; 505*cdf0e10cSrcweir aPtL[ 1 ].x = nDstWidth; 506*cdf0e10cSrcweir aPtL[ 1 ].y = nDstHeight; 507*cdf0e10cSrcweir aPtL[ 2 ].x = nDstX; 508*cdf0e10cSrcweir aPtL[ 2 ].y = TY( nDstY + nDstHeight - 1 ); 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir GpiBitBlt( hMemPS, hPS, 3, aPtL, ROP_SRCCOPY, BBO_IGNORE ); 511*cdf0e10cSrcweir ImplDrawBitmap( hMaskPS, nDstHeight, &aPosAry, rTransparentBitmap, FALSE, ROP_SRCCOPY ); 512*cdf0e10cSrcweir 513*cdf0e10cSrcweir aPtL[ 2 ].x = 0; 514*cdf0e10cSrcweir aPtL[ 2 ].y = 0; 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir GpiBitBlt( hMemPS, hMaskPS, 3, aPtL, ROP_SRCAND, BBO_IGNORE ); 517*cdf0e10cSrcweir ImplDrawBitmap( hMaskPS, nDstHeight, &aPosAry, rSalBitmap, FALSE, ROP_SRCERASE ); 518*cdf0e10cSrcweir GpiBitBlt( hMemPS, hMaskPS, 3, aPtL, ROP_SRCPAINT, BBO_IGNORE ); 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir aPtL[ 0 ].x = nDstX; 521*cdf0e10cSrcweir aPtL[ 0 ].y = TY( nDstY + nDstHeight - 1 ); 522*cdf0e10cSrcweir aPtL[ 1 ].x = nDstX + nDstWidth; 523*cdf0e10cSrcweir aPtL[ 1 ].y = TY( nDstY - 1 ); 524*cdf0e10cSrcweir 525*cdf0e10cSrcweir GpiBitBlt( hPS, hMemPS, 3, aPtL, ROP_SRCCOPY, BBO_IGNORE ); 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir Ft2SetBitmap( hMaskPS, hMaskOld ); 528*cdf0e10cSrcweir Ft2DestroyPS( hMaskPS ); 529*cdf0e10cSrcweir DevCloseDC( hMaskDC ); 530*cdf0e10cSrcweir GpiDeleteBitmap( hMaskBitmap ); 531*cdf0e10cSrcweir 532*cdf0e10cSrcweir Ft2SetBitmap( hMemPS, hMemOld ); 533*cdf0e10cSrcweir Ft2DestroyPS( hMemPS ); 534*cdf0e10cSrcweir DevCloseDC( hMemDC ); 535*cdf0e10cSrcweir GpiDeleteBitmap( hMemBitmap ); 536*cdf0e10cSrcweir 537*cdf0e10cSrcweir /* 538*cdf0e10cSrcweir ImplReleaseCachedPS( CACHED_HPS_1 ); 539*cdf0e10cSrcweir ImplReleaseCachedPS( CACHED_HPS_2 ); 540*cdf0e10cSrcweir */ 541*cdf0e10cSrcweir } 542*cdf0e10cSrcweir } 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir // ----------------------------------------------------------------------- 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir bool Os2SalGraphics::drawAlphaBitmap( const SalTwoRect& rTR, 547*cdf0e10cSrcweir const SalBitmap& rSrcBitmap, 548*cdf0e10cSrcweir const SalBitmap& rAlphaBmp ) 549*cdf0e10cSrcweir { 550*cdf0e10cSrcweir // TODO(P3) implement alpha blending 551*cdf0e10cSrcweir return false; 552*cdf0e10cSrcweir } 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir // ----------------------------------------------------------------------- 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir bool Os2SalGraphics::drawAlphaRect( long nX, long nY, long nWidth, 557*cdf0e10cSrcweir long nHeight, sal_uInt8 nTransparency ) 558*cdf0e10cSrcweir { 559*cdf0e10cSrcweir // TODO(P3) implement alpha blending 560*cdf0e10cSrcweir return false; 561*cdf0e10cSrcweir } 562*cdf0e10cSrcweir 563*cdf0e10cSrcweir // ----------------------------------------------------------------------- 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir void Os2SalGraphics::drawMask( const SalTwoRect* pPosAry, 566*cdf0e10cSrcweir const SalBitmap& rSSalBitmap, 567*cdf0e10cSrcweir SalColor nMaskColor ) 568*cdf0e10cSrcweir { 569*cdf0e10cSrcweir DBG_ASSERT( !mbPrinter, "No transparency print possible!" ); 570*cdf0e10cSrcweir 571*cdf0e10cSrcweir const Os2SalBitmap& rSalBitmap = static_cast<const Os2SalBitmap&>(rSSalBitmap); 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir SalTwoRect aPosAry = *pPosAry; 574*cdf0e10cSrcweir HPS hPS = mhPS; 575*cdf0e10cSrcweir IMAGEBUNDLE aBundle, aOldBundle; 576*cdf0e10cSrcweir AREABUNDLE aAreaBundle, aOldAreaBundle; 577*cdf0e10cSrcweir const ULONG nColor = RGBCOLOR( SALCOLOR_RED( nMaskColor ), 578*cdf0e10cSrcweir SALCOLOR_GREEN( nMaskColor ), 579*cdf0e10cSrcweir SALCOLOR_BLUE( nMaskColor ) ); 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir GpiQueryAttrs( hPS, PRIM_IMAGE, IBB_COLOR | IBB_BACK_COLOR, &aOldBundle ); 582*cdf0e10cSrcweir aBundle.lColor = RGBCOLOR( 0, 0, 0 ); 583*cdf0e10cSrcweir aBundle.lBackColor = RGBCOLOR( 0xFF, 0xFF, 0xFF ); 584*cdf0e10cSrcweir Ft2SetAttrs( hPS, PRIM_IMAGE, IBB_COLOR | IBB_BACK_COLOR, 0, &aBundle ); 585*cdf0e10cSrcweir 586*cdf0e10cSrcweir GpiQueryAttrs( hPS, PRIM_AREA, ABB_COLOR | ABB_BACK_COLOR | ABB_SYMBOL | 587*cdf0e10cSrcweir ABB_MIX_MODE | ABB_BACK_MIX_MODE, &aOldAreaBundle ); 588*cdf0e10cSrcweir aAreaBundle.lColor = nColor; 589*cdf0e10cSrcweir aAreaBundle.lBackColor = nColor; 590*cdf0e10cSrcweir aAreaBundle.usSymbol = PATSYM_SOLID; 591*cdf0e10cSrcweir aAreaBundle.usMixMode = FM_OVERPAINT; 592*cdf0e10cSrcweir aAreaBundle.usBackMixMode = BM_OVERPAINT; 593*cdf0e10cSrcweir Ft2SetAttrs( hPS, PRIM_AREA, ABB_COLOR | ABB_BACK_COLOR | ABB_SYMBOL | 594*cdf0e10cSrcweir ABB_MIX_MODE | ABB_BACK_MIX_MODE, 0, &aAreaBundle ); 595*cdf0e10cSrcweir 596*cdf0e10cSrcweir ImplDrawBitmap( hPS, mnHeight, &aPosAry, rSalBitmap, FALSE, 0x00B8L ); 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir Ft2SetAttrs( hPS, PRIM_IMAGE, IBB_COLOR | IBB_BACK_COLOR, 0, &aOldBundle ); 599*cdf0e10cSrcweir Ft2SetAttrs( hPS, PRIM_AREA, ABB_COLOR | ABB_BACK_COLOR | ABB_SYMBOL | 600*cdf0e10cSrcweir ABB_MIX_MODE | ABB_BACK_MIX_MODE, 0, &aOldAreaBundle ); 601*cdf0e10cSrcweir } 602*cdf0e10cSrcweir 603*cdf0e10cSrcweir // ----------------------------------------------------------------------- 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir SalBitmap* Os2SalGraphics::getBitmap( long nX, long nY, long nDX, long nDY ) 606*cdf0e10cSrcweir { 607*cdf0e10cSrcweir HAB hAB = GetSalData()->mhAB; 608*cdf0e10cSrcweir SIZEL size = { nDX, nDY }; 609*cdf0e10cSrcweir Os2SalBitmap* pSalBitmap = NULL; 610*cdf0e10cSrcweir 611*cdf0e10cSrcweir // create device context (at this time allways display compatible) 612*cdf0e10cSrcweir DEVOPENSTRUC aDevOpenStruc = { NULL, (PSZ)"DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL }; 613*cdf0e10cSrcweir HDC hMemDC = DevOpenDC( hAB, OD_MEMORY, (PSZ)"*", 5L, (PDEVOPENDATA)&aDevOpenStruc, 0 ); 614*cdf0e10cSrcweir HPS hMemPS = Ft2CreatePS( hAB, hMemDC, &size, GPIT_MICRO | GPIA_ASSOC | PU_PELS ); 615*cdf0e10cSrcweir HBITMAP hMemBmp = ImplCreateVirDevBitmap( hMemDC, hMemPS, nDX, nDY, 0 ); 616*cdf0e10cSrcweir HBITMAP hMemOld = Ft2SetBitmap( hMemPS, hMemBmp ); 617*cdf0e10cSrcweir 618*cdf0e10cSrcweir // creation successfull? 619*cdf0e10cSrcweir if( hMemDC && hMemPS && hMemBmp ) 620*cdf0e10cSrcweir { 621*cdf0e10cSrcweir POINTL thePoints[ 3 ]; 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir // lower-left corner of target 624*cdf0e10cSrcweir thePoints[ 0 ].x = 0; 625*cdf0e10cSrcweir thePoints[ 0 ].y = 0; 626*cdf0e10cSrcweir 627*cdf0e10cSrcweir // upper-right corner of target 628*cdf0e10cSrcweir thePoints[ 1 ].x = nDX; 629*cdf0e10cSrcweir thePoints[ 1 ].y = nDY; 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir // lower-left corner of source 632*cdf0e10cSrcweir thePoints[ 2 ].x = nX; 633*cdf0e10cSrcweir thePoints[ 2 ].y = TY( nY + nDY - 1 ); 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir long lHits = GpiBitBlt( hMemPS, mhPS, 3, thePoints, 636*cdf0e10cSrcweir mbXORMode ? ROP_SRCINVERT : ROP_SRCCOPY, BBO_IGNORE ); 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir if( hMemPS ) 639*cdf0e10cSrcweir { 640*cdf0e10cSrcweir Ft2SetBitmap( hMemPS, hMemOld ); 641*cdf0e10cSrcweir Ft2DestroyPS( hMemPS ); 642*cdf0e10cSrcweir } 643*cdf0e10cSrcweir 644*cdf0e10cSrcweir if( hMemDC ) 645*cdf0e10cSrcweir DevCloseDC( hMemDC ); 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir if( lHits == GPI_OK ) 648*cdf0e10cSrcweir { 649*cdf0e10cSrcweir pSalBitmap = new Os2SalBitmap; 650*cdf0e10cSrcweir 651*cdf0e10cSrcweir if( !pSalBitmap->Create( hMemBmp, FALSE, FALSE ) ) 652*cdf0e10cSrcweir { 653*cdf0e10cSrcweir delete pSalBitmap; 654*cdf0e10cSrcweir pSalBitmap = NULL; 655*cdf0e10cSrcweir } 656*cdf0e10cSrcweir } 657*cdf0e10cSrcweir } 658*cdf0e10cSrcweir 659*cdf0e10cSrcweir if( !pSalBitmap ) 660*cdf0e10cSrcweir GpiDeleteBitmap( hMemBmp ); 661*cdf0e10cSrcweir 662*cdf0e10cSrcweir // return pointer to SAL-Bitmap 663*cdf0e10cSrcweir return pSalBitmap; 664*cdf0e10cSrcweir } 665*cdf0e10cSrcweir 666*cdf0e10cSrcweir // ----------------------------------------------------------------------- 667*cdf0e10cSrcweir 668*cdf0e10cSrcweir SalColor Os2SalGraphics::getPixel( long nX, long nY ) 669*cdf0e10cSrcweir { 670*cdf0e10cSrcweir POINTL aPt = { nX, TY( nY ) }; 671*cdf0e10cSrcweir LONG nColor = Ft2QueryPel( mhPS, &aPt ); 672*cdf0e10cSrcweir 673*cdf0e10cSrcweir return MAKE_SALCOLOR( (BYTE) ( nColor >> 16 ), (BYTE) ( nColor >> 8 ), (BYTE) nColor ); 674*cdf0e10cSrcweir } 675*cdf0e10cSrcweir 676*cdf0e10cSrcweir // ----------------------------------------------------------------------- 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir void Os2SalGraphics::invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags ) 679*cdf0e10cSrcweir { 680*cdf0e10cSrcweir if( nFlags & SAL_INVERT_TRACKFRAME ) 681*cdf0e10cSrcweir { 682*cdf0e10cSrcweir // save old vylues 683*cdf0e10cSrcweir LINEBUNDLE oldLb; 684*cdf0e10cSrcweir LINEBUNDLE lb; 685*cdf0e10cSrcweir GpiQueryAttrs( mhPS, PRIM_LINE, LBB_MIX_MODE | LBB_TYPE | LBB_COLOR, &oldLb ); 686*cdf0e10cSrcweir 687*cdf0e10cSrcweir // set linetype to short dash 688*cdf0e10cSrcweir lb.lColor = RGBCOLOR( 255, 255, 255 ); 689*cdf0e10cSrcweir lb.usMixMode = FM_XOR; 690*cdf0e10cSrcweir lb.usType = LINETYPE_ALTERNATE; 691*cdf0e10cSrcweir Ft2SetAttrs( mhPS, PRIM_LINE, LBB_MIX_MODE | LBB_TYPE | LBB_COLOR, 0, &lb ); 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir // draw inverted box 694*cdf0e10cSrcweir POINTL aPt; 695*cdf0e10cSrcweir 696*cdf0e10cSrcweir aPt.x = nX; 697*cdf0e10cSrcweir aPt.y = TY( nY ); 698*cdf0e10cSrcweir 699*cdf0e10cSrcweir Ft2Move( mhPS, &aPt ); 700*cdf0e10cSrcweir 701*cdf0e10cSrcweir aPt.x = nX + nWidth - 1; 702*cdf0e10cSrcweir aPt.y = TY( nY + nHeight - 1 ); 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir Ft2Box( mhPS, DRO_OUTLINE, &aPt, 0, 0 ); 705*cdf0e10cSrcweir 706*cdf0e10cSrcweir // restore old values 707*cdf0e10cSrcweir Ft2SetAttrs( mhPS, PRIM_LINE, LBB_MIX_MODE | LBB_TYPE | LBB_COLOR, 0, &oldLb ); 708*cdf0e10cSrcweir 709*cdf0e10cSrcweir } 710*cdf0e10cSrcweir else 711*cdf0e10cSrcweir { 712*cdf0e10cSrcweir // save old values 713*cdf0e10cSrcweir AREABUNDLE oldAb; 714*cdf0e10cSrcweir AREABUNDLE ab; 715*cdf0e10cSrcweir 716*cdf0e10cSrcweir GpiQueryAttrs( mhPS, PRIM_AREA, ABB_COLOR | ABB_MIX_MODE | ABB_SYMBOL, &oldAb ); 717*cdf0e10cSrcweir 718*cdf0e10cSrcweir // set fill color to black 719*cdf0e10cSrcweir ab.lColor = RGBCOLOR( 255, 255, 255 ); 720*cdf0e10cSrcweir ab.usMixMode = FM_XOR; 721*cdf0e10cSrcweir ab.usSymbol = (nFlags & SAL_INVERT_50) ? PATSYM_DENSE5 : PATSYM_SOLID; 722*cdf0e10cSrcweir Ft2SetAttrs( mhPS, PRIM_AREA, ABB_COLOR | ABB_MIX_MODE | ABB_SYMBOL, 0, &ab ); 723*cdf0e10cSrcweir 724*cdf0e10cSrcweir // draw inverted box 725*cdf0e10cSrcweir POINTL aPt; 726*cdf0e10cSrcweir 727*cdf0e10cSrcweir aPt.x = nX; 728*cdf0e10cSrcweir aPt.y = TY( nY ); 729*cdf0e10cSrcweir 730*cdf0e10cSrcweir Ft2Move( mhPS, &aPt ); 731*cdf0e10cSrcweir 732*cdf0e10cSrcweir aPt.x = nX + nWidth - 1; 733*cdf0e10cSrcweir aPt.y = TY( nY + nHeight - 1 ); 734*cdf0e10cSrcweir 735*cdf0e10cSrcweir Ft2Box( mhPS, DRO_FILL, &aPt, 0, 0 ); 736*cdf0e10cSrcweir 737*cdf0e10cSrcweir // restore old values 738*cdf0e10cSrcweir Ft2SetAttrs( mhPS, PRIM_AREA, ABB_COLOR | ABB_MIX_MODE | ABB_SYMBOL, 0, &oldAb ); 739*cdf0e10cSrcweir } 740*cdf0e10cSrcweir } 741*cdf0e10cSrcweir 742*cdf0e10cSrcweir // ----------------------------------------------------------------------- 743*cdf0e10cSrcweir 744*cdf0e10cSrcweir void Os2SalGraphics::invert( ULONG nPoints, const SalPoint* pPtAry, SalInvert nFlags ) 745*cdf0e10cSrcweir { 746*cdf0e10cSrcweir if( nFlags & SAL_INVERT_TRACKFRAME ) 747*cdf0e10cSrcweir { 748*cdf0e10cSrcweir // save old vylues 749*cdf0e10cSrcweir LINEBUNDLE oldLb; 750*cdf0e10cSrcweir LINEBUNDLE lb; 751*cdf0e10cSrcweir GpiQueryAttrs( mhPS, PRIM_LINE, LBB_MIX_MODE | LBB_TYPE | LBB_COLOR, &oldLb ); 752*cdf0e10cSrcweir 753*cdf0e10cSrcweir // set linetype to short dash 754*cdf0e10cSrcweir lb.lColor = RGBCOLOR( 255, 255, 255 ); 755*cdf0e10cSrcweir lb.usMixMode = FM_XOR; 756*cdf0e10cSrcweir lb.usType = LINETYPE_ALTERNATE; 757*cdf0e10cSrcweir Ft2SetAttrs( mhPS, PRIM_LINE, LBB_MIX_MODE | LBB_TYPE | LBB_COLOR, 0, &lb ); 758*cdf0e10cSrcweir 759*cdf0e10cSrcweir // Draw Polyline 760*cdf0e10cSrcweir drawPolyLine( nPoints, pPtAry ); 761*cdf0e10cSrcweir 762*cdf0e10cSrcweir // restore old values 763*cdf0e10cSrcweir Ft2SetAttrs( mhPS, PRIM_LINE, LBB_MIX_MODE | LBB_TYPE | LBB_COLOR, 0, &oldLb ); 764*cdf0e10cSrcweir } 765*cdf0e10cSrcweir else 766*cdf0e10cSrcweir { 767*cdf0e10cSrcweir // save old values 768*cdf0e10cSrcweir AREABUNDLE oldAb; 769*cdf0e10cSrcweir AREABUNDLE ab; 770*cdf0e10cSrcweir 771*cdf0e10cSrcweir GpiQueryAttrs( mhPS, PRIM_AREA, ABB_COLOR | ABB_MIX_MODE | ABB_SYMBOL, &oldAb ); 772*cdf0e10cSrcweir 773*cdf0e10cSrcweir // set fill color to black 774*cdf0e10cSrcweir ab.lColor = RGBCOLOR( 255, 255, 255 ); 775*cdf0e10cSrcweir ab.usMixMode = FM_XOR; 776*cdf0e10cSrcweir ab.usSymbol = (nFlags & SAL_INVERT_50) ? PATSYM_DENSE5 : PATSYM_SOLID; 777*cdf0e10cSrcweir Ft2SetAttrs( mhPS, PRIM_AREA, ABB_COLOR | ABB_MIX_MODE | ABB_SYMBOL, 0, &ab ); 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir // Draw Polyline 780*cdf0e10cSrcweir drawPolygon( nPoints, pPtAry ); 781*cdf0e10cSrcweir 782*cdf0e10cSrcweir // restore old values 783*cdf0e10cSrcweir Ft2SetAttrs( mhPS, PRIM_AREA, ABB_COLOR | ABB_MIX_MODE | ABB_SYMBOL, 0, &oldAb ); 784*cdf0e10cSrcweir } 785*cdf0e10cSrcweir } 786*cdf0e10cSrcweir 787