1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _CPPCANVAS_VCLFACTORY_HXX 29 #define _CPPCANVAS_VCLFACTORY_HXX 30 31 #include <cppcanvas/canvas.hxx> 32 #include <cppcanvas/bitmapcanvas.hxx> 33 #include <cppcanvas/spritecanvas.hxx> 34 #include <cppcanvas/polypolygon.hxx> 35 #include <cppcanvas/bitmap.hxx> 36 #include <cppcanvas/renderer.hxx> 37 #include <cppcanvas/text.hxx> 38 #include <cppcanvas/sprite.hxx> 39 40 41 class Window; 42 class Bitmap; 43 class BitmapEx; 44 class Polygon; 45 class PolyPolygon; 46 class Size; 47 class Graphic; 48 class GDIMetaFile; 49 class Animation; 50 51 namespace rtl 52 { 53 class OUString; 54 } 55 namespace com { namespace sun { namespace star { namespace rendering 56 { 57 class XBitmapCanvas; 58 class XSpriteCanvas; 59 } } } } 60 61 /* Definition of VCLFactory class */ 62 63 namespace cppcanvas 64 { 65 /** The VCLFactory creates Canvas objects for various VCL 66 OutputDevice primitives, such as windows, polygons, bitmaps 67 and metafiles. 68 69 Please note that the objects created for a specific Canvas can 70 only be drawn on exactly that canvas. You have to regenerate 71 them for different canvases. 72 */ 73 class VCLFactory 74 { 75 public: 76 static VCLFactory& getInstance(); 77 78 BitmapCanvasSharedPtr createCanvas( const ::Window& rVCLWindow ); 79 BitmapCanvasSharedPtr createCanvas( const ::com::sun::star::uno::Reference< 80 ::com::sun::star::rendering::XBitmapCanvas >& xCanvas ); 81 82 SpriteCanvasSharedPtr createSpriteCanvas( const ::Window& rVCLWindow ) const; 83 SpriteCanvasSharedPtr createSpriteCanvas( const ::com::sun::star::uno::Reference< 84 ::com::sun::star::rendering::XSpriteCanvas >& xCanvas ) const; 85 SpriteCanvasSharedPtr createFullscreenSpriteCanvas( const ::Window& rVCLWindow, const Size& rFullscreenSize ) const; 86 87 /** Create a polygon from a tools::Polygon 88 89 The created polygon initially has the same size in user 90 coordinate space as the source polygon 91 */ 92 PolyPolygonSharedPtr createPolyPolygon( const CanvasSharedPtr&, const ::Polygon& rPoly ) const; 93 PolyPolygonSharedPtr createPolyPolygon( const CanvasSharedPtr&, const ::PolyPolygon& rPoly ) const; 94 95 /** Create an uninitialized bitmap with the given size 96 */ 97 BitmapSharedPtr createBitmap( const CanvasSharedPtr&, const ::Size& rSize ) const; 98 99 /** Create an uninitialized alpha bitmap with the given size 100 */ 101 BitmapSharedPtr createAlphaBitmap( const CanvasSharedPtr&, const ::Size& rSize ) const; 102 103 /** Create a bitmap from a VCL Bitmap 104 */ 105 BitmapSharedPtr createBitmap( const CanvasSharedPtr&, const ::Bitmap& rBitmap ) const; 106 BitmapSharedPtr createBitmap( const CanvasSharedPtr&, const ::BitmapEx& rBmpEx ) const; 107 108 /** Create a renderer object from a Graphic 109 110 The created renderer initially draws the graphic 111 one-by-one units large, in user coordinate space 112 */ 113 RendererSharedPtr createRenderer( const CanvasSharedPtr& rCanvas, 114 const ::Graphic& rGraphic, 115 const Renderer::Parameters& rParms ) const; 116 /** Create a renderer object from a Metafile 117 118 The created renderer initially draws the metafile 119 one-by-one units large, in user coordinate space 120 */ 121 RendererSharedPtr createRenderer( const CanvasSharedPtr& rCanvas, 122 const ::GDIMetaFile& rMtf, 123 const Renderer::Parameters& rParms ) const; 124 125 /** Create an animated sprite from a VCL animation 126 */ 127 SpriteSharedPtr createAnimatedSprite( const SpriteCanvasSharedPtr&, const ::Animation& rAnim ) const; 128 129 /** Create a text portion with the given content string 130 */ 131 TextSharedPtr createText( const CanvasSharedPtr&, const ::rtl::OUString& ) const; 132 133 private: 134 friend struct InitInstance; 135 136 // singleton 137 VCLFactory(); 138 ~VCLFactory(); 139 140 // default: disabled copy/assignment 141 VCLFactory(const VCLFactory&); 142 VCLFactory& operator=( const VCLFactory& ); 143 }; 144 145 } 146 147 #endif /* _CPPCANVAS_VCLFACTORY_HXX */ 148