1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _CPPCANVAS_VCLFACTORY_HXX 25 #define _CPPCANVAS_VCLFACTORY_HXX 26 27 #include <cppcanvas/canvas.hxx> 28 #include <cppcanvas/bitmapcanvas.hxx> 29 #include <cppcanvas/spritecanvas.hxx> 30 #include <cppcanvas/polypolygon.hxx> 31 #include <cppcanvas/bitmap.hxx> 32 #include <cppcanvas/renderer.hxx> 33 #include <cppcanvas/text.hxx> 34 #include <cppcanvas/sprite.hxx> 35 36 #include <cppcanvas/cppcanvasdllapi.h> 37 38 class Window; 39 class Bitmap; 40 class BitmapEx; 41 class Polygon; 42 class PolyPolygon; 43 class Size; 44 class Graphic; 45 class GDIMetaFile; 46 class Animation; 47 48 namespace rtl 49 { 50 class OUString; 51 } 52 namespace com { namespace sun { namespace star { namespace rendering 53 { 54 class XBitmapCanvas; 55 class XSpriteCanvas; 56 } } } } 57 58 /* Definition of VCLFactory class */ 59 60 namespace cppcanvas 61 { 62 /** The VCLFactory creates Canvas objects for various VCL 63 OutputDevice primitives, such as windows, polygons, bitmaps 64 and metafiles. 65 66 Please note that the objects created for a specific Canvas can 67 only be drawn on exactly that canvas. You have to regenerate 68 them for different canvases. 69 */ 70 class CPPCANVAS_DLLPUBLIC VCLFactory 71 { 72 public: 73 static VCLFactory& getInstance(); 74 75 BitmapCanvasSharedPtr createCanvas( const ::Window& rVCLWindow ); 76 BitmapCanvasSharedPtr createCanvas( const ::com::sun::star::uno::Reference< 77 ::com::sun::star::rendering::XBitmapCanvas >& xCanvas ); 78 79 SpriteCanvasSharedPtr createSpriteCanvas( const ::Window& rVCLWindow ) const; 80 SpriteCanvasSharedPtr createSpriteCanvas( const ::com::sun::star::uno::Reference< 81 ::com::sun::star::rendering::XSpriteCanvas >& xCanvas ) const; 82 SpriteCanvasSharedPtr createFullscreenSpriteCanvas( const ::Window& rVCLWindow, const Size& rFullscreenSize ) const; 83 84 /** Create a polygon from a tools::Polygon 85 86 The created polygon initially has the same size in user 87 coordinate space as the source polygon 88 */ 89 PolyPolygonSharedPtr createPolyPolygon( const CanvasSharedPtr&, const ::Polygon& rPoly ) const; 90 PolyPolygonSharedPtr createPolyPolygon( const CanvasSharedPtr&, const ::PolyPolygon& rPoly ) const; 91 92 /** Create an uninitialized bitmap with the given size 93 */ 94 BitmapSharedPtr createBitmap( const CanvasSharedPtr&, const ::Size& rSize ) const; 95 96 /** Create an uninitialized alpha bitmap with the given size 97 */ 98 BitmapSharedPtr createAlphaBitmap( const CanvasSharedPtr&, const ::Size& rSize ) const; 99 100 /** Create a bitmap from a VCL Bitmap 101 */ 102 BitmapSharedPtr createBitmap( const CanvasSharedPtr&, const ::Bitmap& rBitmap ) const; 103 BitmapSharedPtr createBitmap( const CanvasSharedPtr&, const ::BitmapEx& rBmpEx ) const; 104 105 /** Create a renderer object from a Graphic 106 107 The created renderer initially draws the graphic 108 one-by-one units large, in user coordinate space 109 */ 110 RendererSharedPtr createRenderer( const CanvasSharedPtr& rCanvas, 111 const ::Graphic& rGraphic, 112 const Renderer::Parameters& rParms ) const; 113 /** Create a renderer object from a Metafile 114 115 The created renderer initially draws the metafile 116 one-by-one units large, in user coordinate space 117 */ 118 RendererSharedPtr createRenderer( const CanvasSharedPtr& rCanvas, 119 const ::GDIMetaFile& rMtf, 120 const Renderer::Parameters& rParms ) const; 121 122 /** Create an animated sprite from a VCL animation 123 */ 124 SpriteSharedPtr createAnimatedSprite( const SpriteCanvasSharedPtr&, const ::Animation& rAnim ) const; 125 126 /** Create a text portion with the given content string 127 */ 128 TextSharedPtr createText( const CanvasSharedPtr&, const ::rtl::OUString& ) const; 129 130 private: 131 friend struct InitInstance; 132 133 // singleton 134 VCLFactory(); 135 ~VCLFactory(); 136 137 // default: disabled copy/assignment 138 VCLFactory(const VCLFactory&); 139 VCLFactory& operator=( const VCLFactory& ); 140 }; 141 142 } 143 144 #endif /* _CPPCANVAS_VCLFACTORY_HXX */ 145