1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: salvd.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
36 #include <saldata.hxx>
46 // =======================================================================
48 HBITMAP
ImplCreateVirDevBitmap( HDC hDC
, HPS hPS
, long nDX
, long nDY
,
54 DevQueryCaps( hDC
, CAPS_COLOR_BITCOUNT
, 1, &nDevBitCount
);
55 nBitCount
= nDevBitCount
;
59 DevQueryCaps( hDC
, CAPS_COLOR_PLANES
, 1, &nPlanes
);
61 // entsprechende Bitmap zum OutputDevice erzeugen
63 BITMAPINFOHEADER2 aBitmapInfo
;
64 memset( &aBitmapInfo
, 0, sizeof( BITMAPINFOHEADER2
) );
65 aBitmapInfo
.cbFix
= sizeof( BITMAPINFOHEADER2
);
68 aBitmapInfo
.cPlanes
= nPlanes
;
69 aBitmapInfo
.cBitCount
= (nBitCount
< 4) ? 4 : nBitCount
;
70 hBitmap
= GpiCreateBitmap( hPS
, &aBitmapInfo
, 0, NULL
, NULL
);
74 // -----------------------------------------------------------------------
76 SalVirtualDevice
* Os2SalInstance::CreateVirtualDevice( SalGraphics
* pSGraphics
,
79 const SystemGraphicsData
* pData
)
81 Os2SalGraphics
* pGraphics
= static_cast<Os2SalGraphics
*>(pSGraphics
);
82 HAB hAB
= GetSalData()->mhAB
;
85 // create device context (at this time allways display compatible)
86 DEVOPENSTRUC aDevOpenStruc
= { NULL
, "DISPLAY", NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
};
87 HDC hDC
= DevOpenDC( hAB
, OD_MEMORY
, (PSZ
)"*", 5, (PDEVOPENDATA
)&aDevOpenStruc
, 0 );
91 // create presentation space
94 HPS hPS
= Ft2CreatePS( hAB
, hDC
, &size
, GPIT_MICRO
| GPIA_ASSOC
| PU_PELS
);
101 // create bitmap for the virtual device
102 HBITMAP hBmp
= ImplCreateVirDevBitmap( hDC
, hPS
, nDX
, nDY
, nBitCount
);
111 Os2SalVirtualDevice
* pVDev
= new Os2SalVirtualDevice
;
112 Os2SalGraphics
* pVirGraphics
= new Os2SalGraphics
;
114 pVirGraphics
->mhDC
= hDC
;
115 pVirGraphics
->mhPS
= hPS
;
116 pVirGraphics
->mhWnd
= 0;
117 pVirGraphics
->mnHeight
= nDY
;
118 pVirGraphics
->mbPrinter
= FALSE
;
119 pVirGraphics
->mbVirDev
= TRUE
;
120 pVirGraphics
->mbWindow
= FALSE
;
121 pVirGraphics
->mbScreen
= pGraphics
->mbScreen
;
122 ImplSalInitGraphics( pVirGraphics
);
127 pVDev
->mhDefBmp
= Ft2SetBitmap( hPS
, hBmp
);
128 pVDev
->mpGraphics
= pVirGraphics
;
129 pVDev
->mnBitCount
= nBitCount
;
130 pVDev
->mbGraphics
= FALSE
;
134 // -----------------------------------------------------------------------
136 void Os2SalInstance::DestroyVirtualDevice( SalVirtualDevice
* pDevice
)
141 // =======================================================================
143 Os2SalVirtualDevice::Os2SalVirtualDevice()
147 // -----------------------------------------------------------------------
149 Os2SalVirtualDevice::~Os2SalVirtualDevice()
151 ImplSalDeInitGraphics( mpGraphics
);
153 Ft2SetBitmap( mpGraphics
->mhPS
, mhDefBmp
);
154 GpiDeleteBitmap( mhBmp
);
155 Ft2DestroyPS( mpGraphics
->mhPS
);
156 DevCloseDC( mpGraphics
->mhDC
);
160 // -----------------------------------------------------------------------
162 SalGraphics
* Os2SalVirtualDevice::GetGraphics()
173 // -----------------------------------------------------------------------
175 void Os2SalVirtualDevice::ReleaseGraphics( SalGraphics
* )
180 // -----------------------------------------------------------------------
182 BOOL
Os2SalVirtualDevice::SetSize( long nDX
, long nDY
)
184 HBITMAP hNewBmp
= ImplCreateVirDevBitmap( mhDC
,
189 Ft2SetBitmap( mhPS
, hNewBmp
);
190 GpiDeleteBitmap( mhBmp
);
192 mpGraphics
->mnHeight
= nDY
;
199 void Os2SalVirtualDevice::GetSize( long& rWidth
, long& rHeight
)
201 DevQueryCaps( mpGraphics
->mhDC
, CAPS_WIDTH
, CAPS_WIDTH
, (LONG
*)rWidth
);
202 DevQueryCaps( mpGraphics
->mhDC
, CAPS_HEIGHT
, CAPS_HEIGHT
, (LONG
*)rHeight
);