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