update dev300-m58
[ooovba.git] / canvas / source / cairo / cairo_xlib_cairo.hxx
blobb7165ccd7c49da8520aa5234fa1e20ad9d3c8be6
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: cairo_xlib_cairo.hxx,v $
10 * $Revision: 1.2 $
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 _CAIROCANVAS_XLIB_CAIRO_HXX
32 #define _CAIROCANVAS_XLIB_CAIRO_HXX
34 #include "cairo_cairo.hxx"
36 struct SystemEnvData;
37 struct SystemGraphicsData;
39 namespace cairo {
41 /// Holds all X11-output relevant data
42 struct X11SysData
44 X11SysData();
45 explicit X11SysData( const SystemGraphicsData& );
46 explicit X11SysData( const SystemEnvData& );
48 void* pDisplay; // the relevant display connection
49 long hDrawable; // a drawable
50 void* pVisual; // the visual in use
51 int nScreen; // the current screen of the drawable
52 int nDepth; // depth of said visual
53 long aColormap; // the colormap being used
54 void* pRenderFormat; // render format for drawable
57 /// RAII wrapper for a pixmap
58 struct X11Pixmap
60 void* mpDisplay; // the relevant display connection
61 long mhDrawable; // a drawable
63 X11Pixmap( long hDrawable, void* pDisplay ) :
64 mpDisplay(pDisplay),
65 mhDrawable(hDrawable)
68 ~X11Pixmap();
70 void clear() { mpDisplay=NULL; mhDrawable=0; }
73 typedef boost::shared_ptr<X11Pixmap> X11PixmapSharedPtr;
75 class X11Surface : public Surface
77 const X11SysData maSysData;
78 X11PixmapSharedPtr mpPixmap;
79 CairoSurfaceSharedPtr mpSurface;
81 X11Surface( const X11SysData& rSysData, const X11PixmapSharedPtr& rPixmap, const CairoSurfaceSharedPtr& pSurface );
83 public:
84 /// takes over ownership of passed cairo_surface
85 explicit X11Surface( const CairoSurfaceSharedPtr& pSurface );
86 /// create surface on subarea of given drawable
87 X11Surface( const X11SysData& rSysData, int x, int y, int width, int height );
88 /// create surface for given bitmap data
89 X11Surface( const X11SysData& rSysData, const BitmapSystemData& rBmpData );
91 // Surface interface
92 virtual CairoSharedPtr getCairo() const;
93 virtual CairoSurfaceSharedPtr getCairoSurface() const { return mpSurface; }
94 virtual SurfaceSharedPtr getSimilar( Content aContent, int width, int height ) const;
96 virtual boost::shared_ptr<VirtualDevice> createVirtualDevice() const;
98 virtual void Resize( int width, int height );
100 virtual void flush() const;
102 int getDepth() const;
103 X11PixmapSharedPtr getPixmap() const { return mpPixmap; }
104 void* getRenderFormat() const { return maSysData.pRenderFormat; }
105 long getDrawable() const { return mpPixmap ? mpPixmap->mhDrawable : maSysData.hDrawable; }
109 #endif