merge the formfield patch from ooo-build
[ooovba.git] / vcl / unx / inc / salbmp.h
blob66f384f2531a15c24361d3513031dbb693f69c05
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: salbmp.h,v $
10 * $Revision: 1.12 $
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 ************************************************************************/
31 #ifndef _SV_SALBMP_H
32 #define _SV_SALBMP_H
34 #include <salstd.hxx>
35 #ifndef _SV_SALGTYPE
36 #include <vcl/salgtype.hxx>
37 #endif
38 #include <saldisp.hxx>
39 #include <vcl/salbmp.hxx>
40 #include <vcl/dllapi.h>
42 struct BitmapBuffer;
43 class BitmapPalette;
44 class SalGraphics;
45 class ImplSalDDB;
46 class ImplSalBitmapCache;
48 // -------------
49 // - SalBitmap -
50 // -------------
52 class VCL_DLLPUBLIC X11SalBitmap : public SalBitmap
54 private:
56 static BitmapBuffer* ImplCreateDIB( const Size& rSize,
57 USHORT nBitCount,
58 const BitmapPalette& rPal );
59 static BitmapBuffer* ImplCreateDIB( Drawable aDrawable,
60 int nScreen,
61 long nDrawableDepth,
62 long nX, long nY,
63 long nWidth, long nHeight,
64 bool bGrey );
66 public:
68 static ImplSalBitmapCache* mpCache;
69 static ULONG mnCacheInstCount;
71 static void ImplCreateCache();
72 static void ImplDestroyCache();
73 void ImplRemovedFromCache();
75 bool SnapShot (Display* pDisplay, XLIB_Window hWindow);
76 bool ImplCreateFromXImage( Display* pDisplay,
77 XLIB_Window hWindow,
78 int nScreen,
79 XImage* pImage);
80 private:
83 BitmapBuffer* mpDIB;
84 ImplSalDDB* mpDDB;
85 bool mbGrey;
87 public:
89 SAL_DLLPRIVATE bool ImplCreateFromDrawable( Drawable aDrawable,
90 int nScreen,
91 long nDrawableDepth,
92 long nX, long nY,
93 long nWidth, long nHeight );
95 SAL_DLLPRIVATE XImage* ImplCreateXImage( SalDisplay* pSalDisp,
96 int nScreen, long nDepth,
97 const SalTwoRect& rTwoRect ) const;
99 SAL_DLLPRIVATE ImplSalDDB* ImplGetDDB( Drawable, int nScreen, long nDrawableDepth,
100 const SalTwoRect& ) const;
101 void ImplDraw( Drawable aDrawable, int nScreen, long nDrawableDepth,
102 const SalTwoRect& rTwoRect, const GC& rGC ) const;
104 public:
106 X11SalBitmap();
107 virtual ~X11SalBitmap();
109 // overload pure virtual methods
110 virtual bool Create( const Size& rSize,
111 USHORT nBitCount,
112 const BitmapPalette& rPal );
113 virtual bool Create( const SalBitmap& rSalBmp );
114 virtual bool Create( const SalBitmap& rSalBmp,
115 SalGraphics* pGraphics );
116 virtual bool Create( const SalBitmap& rSalBmp,
117 USHORT nNewBitCount );
118 virtual bool Create( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas > xBitmapCanvas,
119 Size& rSize,
120 bool bMask = false );
122 virtual void Destroy();
124 virtual Size GetSize() const;
125 virtual USHORT GetBitCount() const;
127 virtual BitmapBuffer* AcquireBuffer( bool bReadOnly );
128 virtual void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly );
129 virtual bool GetSystemData( BitmapSystemData& rData );
132 // --------------
133 // - ImplSalDDB -
134 // --------------
136 class ImplSalDDB
138 private:
140 Pixmap maPixmap;
141 SalTwoRect maTwoRect;
142 long mnDepth;
143 int mnScreen;
145 ImplSalDDB() {}
147 static void ImplDraw( Drawable aSrcDrawable, long nSrcDrawableDepth,
148 Drawable aDstDrawable, long nDstDrawableDepth,
149 long nSrcX, long nSrcY,
150 long nDestWidth, long nDestHeight,
151 long nDestX, long nDestY, const GC& rGC );
153 public:
155 ImplSalDDB( XImage* pImage,
156 Drawable aDrawable, int nScreen,
157 const SalTwoRect& rTwoRect );
158 ImplSalDDB( Drawable aDrawable,
159 int nScreen,
160 long nDrawableDepth,
161 long nX, long nY, long nWidth, long nHeight );
162 ImplSalDDB( Display* pDisplay,
163 XLIB_Window hWindow,
164 int nScreen,
165 XImage* pImage);
166 ~ImplSalDDB();
168 Pixmap ImplGetPixmap() const { return maPixmap; }
169 long ImplGetWidth() const { return maTwoRect.mnDestWidth; }
170 long ImplGetHeight() const { return maTwoRect.mnDestHeight; }
171 long ImplGetDepth() const { return mnDepth; }
172 ULONG ImplGetMemSize() const { return( ( maTwoRect.mnDestWidth * maTwoRect.mnDestHeight * mnDepth ) >> 3 ); }
173 int ImplGetScreen() const { return mnScreen; }
175 bool ImplMatches( int nScreen, long nDepth, const SalTwoRect& rTwoRect ) const;
176 void ImplDraw( Drawable aDrawable, long nDrawableDepth,
177 const SalTwoRect& rTwoRect, const GC& rGC ) const;
180 // ----------------------
181 // - ImplSalBitmapCache -
182 // ----------------------
184 class ImplSalBitmapCache
186 private:
188 List maBmpList;
189 ULONG mnTotalSize;
191 public:
193 ImplSalBitmapCache();
194 ~ImplSalBitmapCache();
196 void ImplAdd( X11SalBitmap* pBmp, ULONG nMemSize = 0UL, ULONG nFlags = 0UL );
197 void ImplRemove( X11SalBitmap* pBmp );
198 void ImplClear();
201 #endif // _SV_SALBMP_HXX