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
109f62ea84SAndrew Rist *
119f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
129f62ea84SAndrew Rist *
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.
199f62ea84SAndrew Rist *
209f62ea84SAndrew Rist *************************************************************/
219f62ea84SAndrew Rist
229f62ea84SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #include <string.h>
25cdf0e10cSrcweir #include <svpm.h>
26cdf0e10cSrcweir
27cdf0e10cSrcweir #define _SV_SALGDI2_CXX
28fc9fd3f1SPedro Giffuni #include <os2/salbmp.h>
29fc9fd3f1SPedro Giffuni #include <os2/saldata.hxx>
30cdf0e10cSrcweir #ifndef _SV_SALIDS_HRC
31fc9fd3f1SPedro Giffuni #include <os2/salids.hrc>
32cdf0e10cSrcweir #endif
33fc9fd3f1SPedro Giffuni #include <os2/salgdi.h>
34fc9fd3f1SPedro Giffuni #include <os2/salvd.h>
35cdf0e10cSrcweir #include <vcl/salbtype.hxx>
36cdf0e10cSrcweir
37cdf0e10cSrcweir #ifndef __H_FT2LIB
38fc9fd3f1SPedro Giffuni #include <os2/wingdi.h>
39cdf0e10cSrcweir #include <ft2lib.h>
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir
42fc9fd3f1SPedro Giffuni PM_BOOL bFastTransparent = FALSE;
43cdf0e10cSrcweir
44cdf0e10cSrcweir // ---------------
45cdf0e10cSrcweir // - SalGraphics -
46cdf0e10cSrcweir // ---------------
47cdf0e10cSrcweir
supportsOperation(OutDevSupportType) const48cdf0e10cSrcweir bool Os2SalGraphics::supportsOperation( OutDevSupportType ) const
49cdf0e10cSrcweir {
50cdf0e10cSrcweir return false;
51cdf0e10cSrcweir }
52cdf0e10cSrcweir
53cdf0e10cSrcweir
copyBits(const SalTwoRect & rPosAry,SalGraphics * pSrcGraphics)545f27b83cSArmin Le Grand void Os2SalGraphics::copyBits( const SalTwoRect& rPosAry, 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
745f27b83cSArmin Le Grand thePoints[0].x = rPosAry.mnDestX;
755f27b83cSArmin Le Grand thePoints[0].y = TY( rPosAry.mnDestY + rPosAry.mnDestHeight - 1 );
76cdf0e10cSrcweir
77cdf0e10cSrcweir // upper-right corner of target
785f27b83cSArmin Le Grand thePoints[1].x = rPosAry.mnDestX + rPosAry.mnDestWidth;
795f27b83cSArmin Le Grand thePoints[1].y = TY( rPosAry.mnDestY - 1 );
80cdf0e10cSrcweir
81cdf0e10cSrcweir // lower-left corner of source
825f27b83cSArmin Le Grand thePoints[2].x = rPosAry.mnSrcX;
835f27b83cSArmin Le Grand thePoints[2].y = nSrcHeight - ( rPosAry.mnSrcY + rPosAry.mnSrcHeight );
84cdf0e10cSrcweir
855f27b83cSArmin Le Grand if ( ( rPosAry.mnDestWidth != rPosAry.mnSrcWidth ) || ( rPosAry.mnDestHeight != rPosAry.mnSrcHeight ) )
86cdf0e10cSrcweir {
87cdf0e10cSrcweir // upper-right corner of Source
885f27b83cSArmin Le Grand thePoints[3].x = rPosAry.mnSrcX + rPosAry.mnSrcWidth;
895f27b83cSArmin Le Grand thePoints[3].y = nSrcHeight - rPosAry.mnSrcY + rPosAry.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
copyArea(long nDestX,long nDestY,long nSrcX,long nSrcY,long nSrcWidth,long nSrcHeight,USHORT nFlags)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
ImplDrawBitmap(HPS hPS,long nScreenHeight,const SalTwoRect & rPosAry,const Os2SalBitmap & rSalBitmap,PM_BOOL bPrinter,int nDrawMode)277cdf0e10cSrcweir void ImplDrawBitmap( HPS hPS, long nScreenHeight,
2785f27b83cSArmin Le Grand const SalTwoRect& rPosAry, const Os2SalBitmap& rSalBitmap,
279fc9fd3f1SPedro Giffuni PM_BOOL bPrinter, int nDrawMode )
280cdf0e10cSrcweir {
281cdf0e10cSrcweir if( hPS )
282cdf0e10cSrcweir {
283cdf0e10cSrcweir HANDLE hDrawDIB;
284cdf0e10cSrcweir HBITMAP hDrawDDB = rSalBitmap.ImplGethDDB();
285cdf0e10cSrcweir Os2SalBitmap* pTmpSalBmp = NULL;
286fc9fd3f1SPedro Giffuni PM_BOOL bPrintDDB = ( bPrinter && hDrawDDB );
287fc9fd3f1SPedro 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 );
306fc9fd3f1SPedro Giffuni PM_BYTE* pBits = (PM_BYTE*) pBI + nInfoSize;
307cdf0e10cSrcweir
3085f27b83cSArmin Le Grand pts[0].x = rPosAry.mnDestX;
3095f27b83cSArmin Le Grand pts[0].y = nScreenHeight - rPosAry.mnDestY - rPosAry.mnDestHeight;
3105f27b83cSArmin Le Grand pts[1].x = rPosAry.mnDestX + rPosAry.mnDestWidth - 1;
3115f27b83cSArmin Le Grand pts[1].y = nScreenHeight - rPosAry.mnDestY - 1;
312cdf0e10cSrcweir
3135f27b83cSArmin Le Grand pts[2].x = rPosAry.mnSrcX;
3145f27b83cSArmin Le Grand pts[2].y = nHeight - ( rPosAry.mnSrcY + rPosAry.mnSrcHeight );
3155f27b83cSArmin Le Grand pts[3].x = rPosAry.mnSrcX + rPosAry.mnSrcWidth;
3165f27b83cSArmin Le Grand pts[3].y = nHeight - rPosAry.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 );
334fc9fd3f1SPedro Giffuni pBits = (PM_BYTE*) pBI + nInfoSize;
335cdf0e10cSrcweir }
336cdf0e10cSrcweir
337cdf0e10cSrcweir if( bPrinter )
338cdf0e10cSrcweir {
339fc9fd3f1SPedro 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
352fc9fd3f1SPedro 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
364fc9fd3f1SPedro Giffuni PM_BYTE* pBitsSrc = (PM_BYTE*) pBIH + nInfoSize;
365fc9fd3f1SPedro Giffuni PM_BYTE* pBitsDst = pDummy + sizeof( BITMAPINFO2 );
366cdf0e10cSrcweir
367cdf0e10cSrcweir for( long nY = 0UL; nY < nHeight; nY++ )
368cdf0e10cSrcweir {
369fc9fd3f1SPedro Giffuni PM_BYTE* pSrcLine = pBitsSrc + nY * nWidthAl8;
370fc9fd3f1SPedro 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
389fc9fd3f1SPedro 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
4035f27b83cSArmin Le Grand pts[0].x = rPosAry.mnDestX;
4045f27b83cSArmin Le Grand pts[0].y = nScreenHeight - rPosAry.mnDestY - rPosAry.mnDestHeight;
4055f27b83cSArmin Le Grand pts[1].x = rPosAry.mnDestX + rPosAry.mnDestWidth - 1;
4065f27b83cSArmin Le Grand pts[1].y = nScreenHeight - rPosAry.mnDestY - 1;
407cdf0e10cSrcweir
4085f27b83cSArmin Le Grand pts[2].x = rPosAry.mnSrcX;
4095f27b83cSArmin Le Grand pts[2].y = rSalBitmap.GetSize().Height() - ( rPosAry.mnSrcY + rPosAry.mnSrcHeight );
4105f27b83cSArmin Le Grand pts[3].x = rPosAry.mnSrcX + rPosAry.mnSrcWidth;
4115f27b83cSArmin Le Grand pts[3].y = rSalBitmap.GetSize().Height() - rPosAry.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
drawBitmap(const SalTwoRect & rPosAry,const SalBitmap & rSalBitmap)4285f27b83cSArmin Le Grand void Os2SalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap )
429cdf0e10cSrcweir {
430cdf0e10cSrcweir ImplDrawBitmap( mhPS, mnHeight,
4315f27b83cSArmin Le Grand rPosAry, static_cast<const Os2SalBitmap&>(rSalBitmap),
432cdf0e10cSrcweir mbPrinter,
433cdf0e10cSrcweir mbXORMode ? ROP_SRCINVERT : ROP_SRCCOPY );
434cdf0e10cSrcweir }
435cdf0e10cSrcweir
436cdf0e10cSrcweir // -----------------------------------------------------------------------
437cdf0e10cSrcweir
drawBitmap(const SalTwoRect & rPosAry,const SalBitmap & rSalBitmap,SalColor nTransparentColor)4385f27b83cSArmin Le Grand void Os2SalGraphics::drawBitmap( const SalTwoRect& rPosAry,
439cdf0e10cSrcweir const SalBitmap& rSalBitmap,
440cdf0e10cSrcweir SalColor nTransparentColor )
441cdf0e10cSrcweir {
442cdf0e10cSrcweir DBG_ASSERT( !mbPrinter, "No transparency print possible!" );
443cdf0e10cSrcweir //const Os2SalBitmap& rSalBitmap = static_cast<const Os2SalBitmap&>(rSSalBitmap);
444cdf0e10cSrcweir // an FM: kann erst einmal unberuecksichtigt bleiben
4455f27b83cSArmin Le Grand drawBitmap( rPosAry, rSalBitmap );
446cdf0e10cSrcweir }
447cdf0e10cSrcweir
448cdf0e10cSrcweir // -----------------------------------------------------------------------
449cdf0e10cSrcweir
drawBitmap(const SalTwoRect & rPosAry,const SalBitmap & rSSalBitmap,const SalBitmap & rSTransparentBitmap)4505f27b83cSArmin Le Grand void Os2SalGraphics::drawBitmap( const SalTwoRect& rPosAry,
451cdf0e10cSrcweir const SalBitmap& rSSalBitmap,
452cdf0e10cSrcweir const SalBitmap& rSTransparentBitmap )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir DBG_ASSERT( !mbPrinter, "No transparency print possible!" );
455cdf0e10cSrcweir
456cdf0e10cSrcweir const Os2SalBitmap& rSalBitmap = static_cast<const Os2SalBitmap&>(rSSalBitmap);
457cdf0e10cSrcweir const Os2SalBitmap& rTransparentBitmap = static_cast<const Os2SalBitmap&>(rSTransparentBitmap);
458cdf0e10cSrcweir
459cdf0e10cSrcweir if( bFastTransparent )
460cdf0e10cSrcweir {
4615f27b83cSArmin Le Grand ImplDrawBitmap( mhPS, mnHeight, rPosAry, rTransparentBitmap, FALSE, ROP_SRCAND );
4625f27b83cSArmin Le Grand ImplDrawBitmap( mhPS, mnHeight, rPosAry, rSalBitmap, FALSE, ROP_SRCPAINT );
463cdf0e10cSrcweir }
464cdf0e10cSrcweir else
465cdf0e10cSrcweir {
4665f27b83cSArmin Le Grand SalTwoRect aPosAry = rPosAry;
467cdf0e10cSrcweir int nDstX = (int) aPosAry.mnDestX;
468cdf0e10cSrcweir int nDstY = (int) aPosAry.mnDestY;
469cdf0e10cSrcweir int nDstWidth = (int) aPosAry.mnDestWidth;
470cdf0e10cSrcweir int nDstHeight = (int) aPosAry.mnDestHeight;
471cdf0e10cSrcweir HAB hAB = GetSalData()->mhAB;
472cdf0e10cSrcweir HPS hPS = mhPS;
473cdf0e10cSrcweir DEVOPENSTRUC aDevOpenStruc = { NULL, (PSZ)"DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL };
474cdf0e10cSrcweir SIZEL aSizeL = { nDstWidth, nDstHeight };
475cdf0e10cSrcweir POINTL aPtL[ 3 ];
476cdf0e10cSrcweir
477cdf0e10cSrcweir HDC hMemDC = DevOpenDC( hAB, OD_MEMORY, (PSZ)"*", 5L, (PDEVOPENDATA)&aDevOpenStruc, 0 );
478cdf0e10cSrcweir HPS hMemPS = Ft2CreatePS( hAB, hMemDC, &aSizeL, GPIT_MICRO | GPIA_ASSOC | PU_PELS );
479cdf0e10cSrcweir HBITMAP hMemBitmap = ImplCreateVirDevBitmap( hMemDC, hMemPS, nDstWidth, nDstHeight, 0 );
480cdf0e10cSrcweir HBITMAP hMemOld = (HBITMAP) Ft2SetBitmap( hMemPS, hMemBitmap );
481cdf0e10cSrcweir HDC hMaskDC = DevOpenDC( hAB, OD_MEMORY, (PSZ)"*", 5L, (PDEVOPENDATA)&aDevOpenStruc, 0 );
482cdf0e10cSrcweir HPS hMaskPS = Ft2CreatePS( hAB, hMaskDC, &aSizeL, GPIT_MICRO | GPIA_ASSOC | PU_PELS );
483cdf0e10cSrcweir HBITMAP hMaskBitmap = ImplCreateVirDevBitmap( hMaskDC, hMaskPS, nDstWidth, nDstHeight, 0 );
484cdf0e10cSrcweir HBITMAP hMaskOld = (HBITMAP) Ft2SetBitmap( hMaskPS, hMaskBitmap );
485cdf0e10cSrcweir /*
486cdf0e10cSrcweir HPS hMemPS = ImplGetCachedPS( CACHED_HPS_1, 0 );
487cdf0e10cSrcweir HPS hMaskPS = ImplGetCachedPS( CACHED_HPS_2, 0 );
488cdf0e10cSrcweir */
489cdf0e10cSrcweir aPosAry.mnDestX = aPosAry.mnDestY = 0L;
490cdf0e10cSrcweir
491cdf0e10cSrcweir aPtL[ 0 ].x = 0;
492cdf0e10cSrcweir aPtL[ 0 ].y = 0;
493cdf0e10cSrcweir aPtL[ 1 ].x = nDstWidth;
494cdf0e10cSrcweir aPtL[ 1 ].y = nDstHeight;
495cdf0e10cSrcweir aPtL[ 2 ].x = nDstX;
496cdf0e10cSrcweir aPtL[ 2 ].y = TY( nDstY + nDstHeight - 1 );
497cdf0e10cSrcweir
498cdf0e10cSrcweir GpiBitBlt( hMemPS, hPS, 3, aPtL, ROP_SRCCOPY, BBO_IGNORE );
4995f27b83cSArmin Le Grand ImplDrawBitmap( hMaskPS, nDstHeight, aPosAry, rTransparentBitmap, FALSE, ROP_SRCCOPY );
500cdf0e10cSrcweir
501cdf0e10cSrcweir aPtL[ 2 ].x = 0;
502cdf0e10cSrcweir aPtL[ 2 ].y = 0;
503cdf0e10cSrcweir
504cdf0e10cSrcweir GpiBitBlt( hMemPS, hMaskPS, 3, aPtL, ROP_SRCAND, BBO_IGNORE );
5055f27b83cSArmin Le Grand ImplDrawBitmap( hMaskPS, nDstHeight, aPosAry, rSalBitmap, FALSE, ROP_SRCERASE );
506cdf0e10cSrcweir GpiBitBlt( hMemPS, hMaskPS, 3, aPtL, ROP_SRCPAINT, BBO_IGNORE );
507cdf0e10cSrcweir
508cdf0e10cSrcweir aPtL[ 0 ].x = nDstX;
509cdf0e10cSrcweir aPtL[ 0 ].y = TY( nDstY + nDstHeight - 1 );
510cdf0e10cSrcweir aPtL[ 1 ].x = nDstX + nDstWidth;
511cdf0e10cSrcweir aPtL[ 1 ].y = TY( nDstY - 1 );
512cdf0e10cSrcweir
513cdf0e10cSrcweir GpiBitBlt( hPS, hMemPS, 3, aPtL, ROP_SRCCOPY, BBO_IGNORE );
514cdf0e10cSrcweir
515cdf0e10cSrcweir Ft2SetBitmap( hMaskPS, hMaskOld );
516cdf0e10cSrcweir Ft2DestroyPS( hMaskPS );
517cdf0e10cSrcweir DevCloseDC( hMaskDC );
518cdf0e10cSrcweir GpiDeleteBitmap( hMaskBitmap );
519cdf0e10cSrcweir
520cdf0e10cSrcweir Ft2SetBitmap( hMemPS, hMemOld );
521cdf0e10cSrcweir Ft2DestroyPS( hMemPS );
522cdf0e10cSrcweir DevCloseDC( hMemDC );
523cdf0e10cSrcweir GpiDeleteBitmap( hMemBitmap );
524cdf0e10cSrcweir
525cdf0e10cSrcweir /*
526cdf0e10cSrcweir ImplReleaseCachedPS( CACHED_HPS_1 );
527cdf0e10cSrcweir ImplReleaseCachedPS( CACHED_HPS_2 );
528cdf0e10cSrcweir */
529cdf0e10cSrcweir }
530cdf0e10cSrcweir }
531cdf0e10cSrcweir
532cdf0e10cSrcweir // -----------------------------------------------------------------------
533cdf0e10cSrcweir
drawAlphaBitmap(const SalTwoRect & rTR,const SalBitmap & rSrcBitmap,const SalBitmap & rAlphaBmp)534cdf0e10cSrcweir bool Os2SalGraphics::drawAlphaBitmap( const SalTwoRect& rTR,
535cdf0e10cSrcweir const SalBitmap& rSrcBitmap,
536cdf0e10cSrcweir const SalBitmap& rAlphaBmp )
537cdf0e10cSrcweir {
538cdf0e10cSrcweir // TODO(P3) implement alpha blending
539cdf0e10cSrcweir return false;
540cdf0e10cSrcweir }
541cdf0e10cSrcweir
542cdf0e10cSrcweir // -----------------------------------------------------------------------
543cdf0e10cSrcweir
drawTransformedBitmap(const basegfx::B2DPoint & rNull,const basegfx::B2DPoint & rX,const basegfx::B2DPoint & rY,const SalBitmap & rSourceBitmap,const SalBitmap * pAlphaBitmap)5445f27b83cSArmin Le Grand bool Os2SalGraphics::drawTransformedBitmap(
5455f27b83cSArmin Le Grand const basegfx::B2DPoint& rNull,
5465f27b83cSArmin Le Grand const basegfx::B2DPoint& rX,
5475f27b83cSArmin Le Grand const basegfx::B2DPoint& rY,
5485f27b83cSArmin Le Grand const SalBitmap& rSourceBitmap,
5495f27b83cSArmin Le Grand const SalBitmap* pAlphaBitmap)
5505f27b83cSArmin Le Grand {
5515f27b83cSArmin Le Grand // here direct support for transformed bitmaps can be impemented
5525f27b83cSArmin Le Grand (void)rNull; (void)rX; (void)rY; (void)rSourceBitmap; (void)pAlphaBitmap;
5535f27b83cSArmin Le Grand return false;
5545f27b83cSArmin Le Grand }
5555f27b83cSArmin Le Grand
5565f27b83cSArmin Le Grand // -----------------------------------------------------------------------
5575f27b83cSArmin Le Grand
drawAlphaRect(long nX,long nY,long nWidth,long nHeight,sal_uInt8 nTransparency)558cdf0e10cSrcweir bool Os2SalGraphics::drawAlphaRect( long nX, long nY, long nWidth,
559cdf0e10cSrcweir long nHeight, sal_uInt8 nTransparency )
560cdf0e10cSrcweir {
561cdf0e10cSrcweir // TODO(P3) implement alpha blending
562cdf0e10cSrcweir return false;
563cdf0e10cSrcweir }
564cdf0e10cSrcweir
565cdf0e10cSrcweir // -----------------------------------------------------------------------
566cdf0e10cSrcweir
drawMask(const SalTwoRect & rPosAry,const SalBitmap & rSSalBitmap,SalColor nMaskColor)5675f27b83cSArmin Le Grand void Os2SalGraphics::drawMask( const SalTwoRect& rPosAry,
568cdf0e10cSrcweir const SalBitmap& rSSalBitmap,
569cdf0e10cSrcweir SalColor nMaskColor )
570cdf0e10cSrcweir {
571cdf0e10cSrcweir DBG_ASSERT( !mbPrinter, "No transparency print possible!" );
572cdf0e10cSrcweir
573cdf0e10cSrcweir const Os2SalBitmap& rSalBitmap = static_cast<const Os2SalBitmap&>(rSSalBitmap);
574cdf0e10cSrcweir
5755f27b83cSArmin Le Grand SalTwoRect aPosAry = rPosAry;
576cdf0e10cSrcweir HPS hPS = mhPS;
577cdf0e10cSrcweir IMAGEBUNDLE aBundle, aOldBundle;
578cdf0e10cSrcweir AREABUNDLE aAreaBundle, aOldAreaBundle;
579a34dc4d9SYuri Dario const ULONG nColor = MAKE_SALCOLOR( SALCOLOR_RED( nMaskColor ),
580cdf0e10cSrcweir SALCOLOR_GREEN( nMaskColor ),
581cdf0e10cSrcweir SALCOLOR_BLUE( nMaskColor ) );
582cdf0e10cSrcweir
583cdf0e10cSrcweir GpiQueryAttrs( hPS, PRIM_IMAGE, IBB_COLOR | IBB_BACK_COLOR, &aOldBundle );
584a34dc4d9SYuri Dario aBundle.lColor = MAKE_SALCOLOR( 0, 0, 0 );
585a34dc4d9SYuri Dario aBundle.lBackColor = MAKE_SALCOLOR( 0xFF, 0xFF, 0xFF );
586cdf0e10cSrcweir Ft2SetAttrs( hPS, PRIM_IMAGE, IBB_COLOR | IBB_BACK_COLOR, 0, &aBundle );
587cdf0e10cSrcweir
588cdf0e10cSrcweir GpiQueryAttrs( hPS, PRIM_AREA, ABB_COLOR | ABB_BACK_COLOR | ABB_SYMBOL |
589cdf0e10cSrcweir ABB_MIX_MODE | ABB_BACK_MIX_MODE, &aOldAreaBundle );
590cdf0e10cSrcweir aAreaBundle.lColor = nColor;
591cdf0e10cSrcweir aAreaBundle.lBackColor = nColor;
592cdf0e10cSrcweir aAreaBundle.usSymbol = PATSYM_SOLID;
593cdf0e10cSrcweir aAreaBundle.usMixMode = FM_OVERPAINT;
594cdf0e10cSrcweir aAreaBundle.usBackMixMode = BM_OVERPAINT;
595cdf0e10cSrcweir Ft2SetAttrs( hPS, PRIM_AREA, ABB_COLOR | ABB_BACK_COLOR | ABB_SYMBOL |
596cdf0e10cSrcweir ABB_MIX_MODE | ABB_BACK_MIX_MODE, 0, &aAreaBundle );
597cdf0e10cSrcweir
5985f27b83cSArmin Le Grand ImplDrawBitmap( hPS, mnHeight, aPosAry, rSalBitmap, FALSE, 0x00B8L );
599cdf0e10cSrcweir
600cdf0e10cSrcweir Ft2SetAttrs( hPS, PRIM_IMAGE, IBB_COLOR | IBB_BACK_COLOR, 0, &aOldBundle );
601cdf0e10cSrcweir Ft2SetAttrs( hPS, PRIM_AREA, ABB_COLOR | ABB_BACK_COLOR | ABB_SYMBOL |
602cdf0e10cSrcweir ABB_MIX_MODE | ABB_BACK_MIX_MODE, 0, &aOldAreaBundle );
603cdf0e10cSrcweir }
604cdf0e10cSrcweir
605cdf0e10cSrcweir // -----------------------------------------------------------------------
606cdf0e10cSrcweir
getBitmap(long nX,long nY,long nDX,long nDY)607cdf0e10cSrcweir SalBitmap* Os2SalGraphics::getBitmap( long nX, long nY, long nDX, long nDY )
608cdf0e10cSrcweir {
609cdf0e10cSrcweir HAB hAB = GetSalData()->mhAB;
610cdf0e10cSrcweir SIZEL size = { nDX, nDY };
611cdf0e10cSrcweir Os2SalBitmap* pSalBitmap = NULL;
612cdf0e10cSrcweir
613cdf0e10cSrcweir // create device context (at this time allways display compatible)
614cdf0e10cSrcweir DEVOPENSTRUC aDevOpenStruc = { NULL, (PSZ)"DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL };
615cdf0e10cSrcweir HDC hMemDC = DevOpenDC( hAB, OD_MEMORY, (PSZ)"*", 5L, (PDEVOPENDATA)&aDevOpenStruc, 0 );
616cdf0e10cSrcweir HPS hMemPS = Ft2CreatePS( hAB, hMemDC, &size, GPIT_MICRO | GPIA_ASSOC | PU_PELS );
617cdf0e10cSrcweir HBITMAP hMemBmp = ImplCreateVirDevBitmap( hMemDC, hMemPS, nDX, nDY, 0 );
618cdf0e10cSrcweir HBITMAP hMemOld = Ft2SetBitmap( hMemPS, hMemBmp );
619cdf0e10cSrcweir
620*86e1cf34SPedro Giffuni // creation successful?
621cdf0e10cSrcweir if( hMemDC && hMemPS && hMemBmp )
622cdf0e10cSrcweir {
623cdf0e10cSrcweir POINTL thePoints[ 3 ];
624cdf0e10cSrcweir
625cdf0e10cSrcweir // lower-left corner of target
626cdf0e10cSrcweir thePoints[ 0 ].x = 0;
627cdf0e10cSrcweir thePoints[ 0 ].y = 0;
628cdf0e10cSrcweir
629cdf0e10cSrcweir // upper-right corner of target
630cdf0e10cSrcweir thePoints[ 1 ].x = nDX;
631cdf0e10cSrcweir thePoints[ 1 ].y = nDY;
632cdf0e10cSrcweir
633cdf0e10cSrcweir // lower-left corner of source
634cdf0e10cSrcweir thePoints[ 2 ].x = nX;
635cdf0e10cSrcweir thePoints[ 2 ].y = TY( nY + nDY - 1 );
636cdf0e10cSrcweir
637cdf0e10cSrcweir long lHits = GpiBitBlt( hMemPS, mhPS, 3, thePoints,
638cdf0e10cSrcweir mbXORMode ? ROP_SRCINVERT : ROP_SRCCOPY, BBO_IGNORE );
639cdf0e10cSrcweir
640cdf0e10cSrcweir if( hMemPS )
641cdf0e10cSrcweir {
642cdf0e10cSrcweir Ft2SetBitmap( hMemPS, hMemOld );
643cdf0e10cSrcweir Ft2DestroyPS( hMemPS );
644cdf0e10cSrcweir }
645cdf0e10cSrcweir
646cdf0e10cSrcweir if( hMemDC )
647cdf0e10cSrcweir DevCloseDC( hMemDC );
648cdf0e10cSrcweir
649cdf0e10cSrcweir if( lHits == GPI_OK )
650cdf0e10cSrcweir {
651cdf0e10cSrcweir pSalBitmap = new Os2SalBitmap;
652cdf0e10cSrcweir
653cdf0e10cSrcweir if( !pSalBitmap->Create( hMemBmp, FALSE, FALSE ) )
654cdf0e10cSrcweir {
655cdf0e10cSrcweir delete pSalBitmap;
656cdf0e10cSrcweir pSalBitmap = NULL;
657cdf0e10cSrcweir }
658cdf0e10cSrcweir }
659cdf0e10cSrcweir }
660cdf0e10cSrcweir
661cdf0e10cSrcweir if( !pSalBitmap )
662cdf0e10cSrcweir GpiDeleteBitmap( hMemBmp );
663cdf0e10cSrcweir
664cdf0e10cSrcweir // return pointer to SAL-Bitmap
665cdf0e10cSrcweir return pSalBitmap;
666cdf0e10cSrcweir }
667cdf0e10cSrcweir
668cdf0e10cSrcweir // -----------------------------------------------------------------------
669cdf0e10cSrcweir
getPixel(long nX,long nY)670cdf0e10cSrcweir SalColor Os2SalGraphics::getPixel( long nX, long nY )
671cdf0e10cSrcweir {
672cdf0e10cSrcweir POINTL aPt = { nX, TY( nY ) };
673cdf0e10cSrcweir LONG nColor = Ft2QueryPel( mhPS, &aPt );
674cdf0e10cSrcweir
675fc9fd3f1SPedro Giffuni return MAKE_SALCOLOR( (PM_BYTE) ( nColor >> 16 ), (PM_BYTE) ( nColor >> 8 ), (PM_BYTE) nColor );
676cdf0e10cSrcweir }
677cdf0e10cSrcweir
678cdf0e10cSrcweir // -----------------------------------------------------------------------
679cdf0e10cSrcweir
invert(long nX,long nY,long nWidth,long nHeight,SalInvert nFlags)680cdf0e10cSrcweir void Os2SalGraphics::invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags )
681cdf0e10cSrcweir {
682cdf0e10cSrcweir if( nFlags & SAL_INVERT_TRACKFRAME )
683cdf0e10cSrcweir {
684cdf0e10cSrcweir // save old vylues
685cdf0e10cSrcweir LINEBUNDLE oldLb;
686cdf0e10cSrcweir LINEBUNDLE lb;
687cdf0e10cSrcweir GpiQueryAttrs( mhPS, PRIM_LINE, LBB_MIX_MODE | LBB_TYPE | LBB_COLOR, &oldLb );
688cdf0e10cSrcweir
689cdf0e10cSrcweir // set linetype to short dash
690a34dc4d9SYuri Dario lb.lColor = MAKE_SALCOLOR( 255, 255, 255 );
691cdf0e10cSrcweir lb.usMixMode = FM_XOR;
692cdf0e10cSrcweir lb.usType = LINETYPE_ALTERNATE;
693cdf0e10cSrcweir Ft2SetAttrs( mhPS, PRIM_LINE, LBB_MIX_MODE | LBB_TYPE | LBB_COLOR, 0, &lb );
694cdf0e10cSrcweir
695cdf0e10cSrcweir // draw inverted box
696cdf0e10cSrcweir POINTL aPt;
697cdf0e10cSrcweir
698cdf0e10cSrcweir aPt.x = nX;
699cdf0e10cSrcweir aPt.y = TY( nY );
700cdf0e10cSrcweir
701cdf0e10cSrcweir Ft2Move( mhPS, &aPt );
702cdf0e10cSrcweir
703cdf0e10cSrcweir aPt.x = nX + nWidth - 1;
704cdf0e10cSrcweir aPt.y = TY( nY + nHeight - 1 );
705cdf0e10cSrcweir
706cdf0e10cSrcweir Ft2Box( mhPS, DRO_OUTLINE, &aPt, 0, 0 );
707cdf0e10cSrcweir
708cdf0e10cSrcweir // restore old values
709cdf0e10cSrcweir Ft2SetAttrs( mhPS, PRIM_LINE, LBB_MIX_MODE | LBB_TYPE | LBB_COLOR, 0, &oldLb );
710cdf0e10cSrcweir
711cdf0e10cSrcweir }
712cdf0e10cSrcweir else
713cdf0e10cSrcweir {
714cdf0e10cSrcweir // save old values
715cdf0e10cSrcweir AREABUNDLE oldAb;
716cdf0e10cSrcweir AREABUNDLE ab;
717cdf0e10cSrcweir
718cdf0e10cSrcweir GpiQueryAttrs( mhPS, PRIM_AREA, ABB_COLOR | ABB_MIX_MODE | ABB_SYMBOL, &oldAb );
719cdf0e10cSrcweir
720cdf0e10cSrcweir // set fill color to black
721a34dc4d9SYuri Dario ab.lColor = MAKE_SALCOLOR( 255, 255, 255 );
722cdf0e10cSrcweir ab.usMixMode = FM_XOR;
723cdf0e10cSrcweir ab.usSymbol = (nFlags & SAL_INVERT_50) ? PATSYM_DENSE5 : PATSYM_SOLID;
724cdf0e10cSrcweir Ft2SetAttrs( mhPS, PRIM_AREA, ABB_COLOR | ABB_MIX_MODE | ABB_SYMBOL, 0, &ab );
725cdf0e10cSrcweir
726cdf0e10cSrcweir // draw inverted box
727cdf0e10cSrcweir POINTL aPt;
728cdf0e10cSrcweir
729cdf0e10cSrcweir aPt.x = nX;
730cdf0e10cSrcweir aPt.y = TY( nY );
731cdf0e10cSrcweir
732cdf0e10cSrcweir Ft2Move( mhPS, &aPt );
733cdf0e10cSrcweir
734cdf0e10cSrcweir aPt.x = nX + nWidth - 1;
735cdf0e10cSrcweir aPt.y = TY( nY + nHeight - 1 );
736cdf0e10cSrcweir
737cdf0e10cSrcweir Ft2Box( mhPS, DRO_FILL, &aPt, 0, 0 );
738cdf0e10cSrcweir
739cdf0e10cSrcweir // restore old values
740cdf0e10cSrcweir Ft2SetAttrs( mhPS, PRIM_AREA, ABB_COLOR | ABB_MIX_MODE | ABB_SYMBOL, 0, &oldAb );
741cdf0e10cSrcweir }
742cdf0e10cSrcweir }
743cdf0e10cSrcweir
744cdf0e10cSrcweir // -----------------------------------------------------------------------
745cdf0e10cSrcweir
invert(sal_uInt32 nPoints,const SalPoint * pPtAry,SalInvert nFlags)74654ae6a37SHerbert Dürr void Os2SalGraphics::invert( sal_uInt32 nPoints, const SalPoint* pPtAry, SalInvert nFlags )
747cdf0e10cSrcweir {
748cdf0e10cSrcweir if( nFlags & SAL_INVERT_TRACKFRAME )
749cdf0e10cSrcweir {
750cdf0e10cSrcweir // save old vylues
751cdf0e10cSrcweir LINEBUNDLE oldLb;
752cdf0e10cSrcweir LINEBUNDLE lb;
753cdf0e10cSrcweir GpiQueryAttrs( mhPS, PRIM_LINE, LBB_MIX_MODE | LBB_TYPE | LBB_COLOR, &oldLb );
754cdf0e10cSrcweir
755cdf0e10cSrcweir // set linetype to short dash
756a34dc4d9SYuri Dario lb.lColor = MAKE_SALCOLOR( 255, 255, 255 );
757cdf0e10cSrcweir lb.usMixMode = FM_XOR;
758cdf0e10cSrcweir lb.usType = LINETYPE_ALTERNATE;
759cdf0e10cSrcweir Ft2SetAttrs( mhPS, PRIM_LINE, LBB_MIX_MODE | LBB_TYPE | LBB_COLOR, 0, &lb );
760cdf0e10cSrcweir
761cdf0e10cSrcweir // Draw Polyline
762cdf0e10cSrcweir drawPolyLine( nPoints, pPtAry );
763cdf0e10cSrcweir
764cdf0e10cSrcweir // restore old values
765cdf0e10cSrcweir Ft2SetAttrs( mhPS, PRIM_LINE, LBB_MIX_MODE | LBB_TYPE | LBB_COLOR, 0, &oldLb );
766cdf0e10cSrcweir }
767cdf0e10cSrcweir else
768cdf0e10cSrcweir {
769cdf0e10cSrcweir // save old values
770cdf0e10cSrcweir AREABUNDLE oldAb;
771cdf0e10cSrcweir AREABUNDLE ab;
772cdf0e10cSrcweir
773cdf0e10cSrcweir GpiQueryAttrs( mhPS, PRIM_AREA, ABB_COLOR | ABB_MIX_MODE | ABB_SYMBOL, &oldAb );
774cdf0e10cSrcweir
775cdf0e10cSrcweir // set fill color to black
776a34dc4d9SYuri Dario ab.lColor = MAKE_SALCOLOR( 255, 255, 255 );
777cdf0e10cSrcweir ab.usMixMode = FM_XOR;
778cdf0e10cSrcweir ab.usSymbol = (nFlags & SAL_INVERT_50) ? PATSYM_DENSE5 : PATSYM_SOLID;
779cdf0e10cSrcweir Ft2SetAttrs( mhPS, PRIM_AREA, ABB_COLOR | ABB_MIX_MODE | ABB_SYMBOL, 0, &ab );
780cdf0e10cSrcweir
781cdf0e10cSrcweir // Draw Polyline
782cdf0e10cSrcweir drawPolygon( nPoints, pPtAry );
783cdf0e10cSrcweir
784cdf0e10cSrcweir // restore old values
785cdf0e10cSrcweir Ft2SetAttrs( mhPS, PRIM_AREA, ABB_COLOR | ABB_MIX_MODE | ABB_SYMBOL, 0, &oldAb );
786cdf0e10cSrcweir }
787cdf0e10cSrcweir }
788cdf0e10cSrcweir
789