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 37 class Window; 38 class Bitmap; 39 class BitmapEx; 40 class Polygon; 41 class PolyPolygon; 42 class Size; 43 class Graphic; 44 class GDIMetaFile; 45 class Animation; 46 47 namespace rtl 48 { 49 class OUString; 50 } 51 namespace com { namespace sun { namespace star { namespace rendering 52 { 53 class XBitmapCanvas; 54 class XSpriteCanvas; 55 } } } } 56 57 /* Definition of VCLFactory class */ 58 59 namespace cppcanvas 60 { 61 /** The VCLFactory creates Canvas objects for various VCL 62 OutputDevice primitives, such as windows, polygons, bitmaps 63 and metafiles. 64 65 Please note that the objects created for a specific Canvas can 66 only be drawn on exactly that canvas. You have to regenerate 67 them for different canvases. 68 */ 69 class VCLFactory 70 { 71 public: 72 static VCLFactory& getInstance(); 73 74 BitmapCanvasSharedPtr createCanvas( const ::Window& rVCLWindow ); 75 BitmapCanvasSharedPtr createCanvas( const ::com::sun::star::uno::Reference< 76 ::com::sun::star::rendering::XBitmapCanvas >& xCanvas ); 77 78 SpriteCanvasSharedPtr createSpriteCanvas( const ::Window& rVCLWindow ) const; 79 SpriteCanvasSharedPtr createSpriteCanvas( const ::com::sun::star::uno::Reference< 80 ::com::sun::star::rendering::XSpriteCanvas >& xCanvas ) const; 81 SpriteCanvasSharedPtr createFullscreenSpriteCanvas( const ::Window& rVCLWindow, const Size& rFullscreenSize ) const; 82 83 /** Create a polygon from a tools::Polygon 84 85 The created polygon initially has the same size in user 86 coordinate space as the source polygon 87 */ 88 PolyPolygonSharedPtr createPolyPolygon( const CanvasSharedPtr&, const ::Polygon& rPoly ) const; 89 PolyPolygonSharedPtr createPolyPolygon( const CanvasSharedPtr&, const ::PolyPolygon& rPoly ) const; 90 91 /** Create an uninitialized bitmap with the given size 92 */ 93 BitmapSharedPtr createBitmap( const CanvasSharedPtr&, const ::Size& rSize ) const; 94 95 /** Create an uninitialized alpha bitmap with the given size 96 */ 97 BitmapSharedPtr createAlphaBitmap( const CanvasSharedPtr&, const ::Size& rSize ) const; 98 99 /** Create a bitmap from a VCL Bitmap 100 */ 101 BitmapSharedPtr createBitmap( const CanvasSharedPtr&, const ::Bitmap& rBitmap ) const; 102 BitmapSharedPtr createBitmap( const CanvasSharedPtr&, const ::BitmapEx& rBmpEx ) const; 103 104 /** Create a renderer object from a Graphic 105 106 The created renderer initially draws the graphic 107 one-by-one units large, in user coordinate space 108 */ 109 RendererSharedPtr createRenderer( const CanvasSharedPtr& rCanvas, 110 const ::Graphic& rGraphic, 111 const Renderer::Parameters& rParms ) const; 112 /** Create a renderer object from a Metafile 113 114 The created renderer initially draws the metafile 115 one-by-one units large, in user coordinate space 116 */ 117 RendererSharedPtr createRenderer( const CanvasSharedPtr& rCanvas, 118 const ::GDIMetaFile& rMtf, 119 const Renderer::Parameters& rParms ) const; 120 121 /** Create an animated sprite from a VCL animation 122 */ 123 SpriteSharedPtr createAnimatedSprite( const SpriteCanvasSharedPtr&, const ::Animation& rAnim ) const; 124 125 /** Create a text portion with the given content string 126 */ 127 TextSharedPtr createText( const CanvasSharedPtr&, const ::rtl::OUString& ) const; 128 129 private: 130 friend struct InitInstance; 131 132 // singleton 133 VCLFactory(); 134 ~VCLFactory(); 135 136 // default: disabled copy/assignment 137 VCLFactory(const VCLFactory&); 138 VCLFactory& operator=( const VCLFactory& ); 139 }; 140 141 } 142 143 #endif /* _CPPCANVAS_VCLFACTORY_HXX */ 144