tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / canvas / inc / base / spritecanvasbase.hxx
blob0a0d952a295577e2aaa2a791baf0f5e61ccaf8ee
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <rtl/ref.hxx>
23 #include <com/sun/star/rendering/InterpolationMode.hpp>
24 #include <base/integerbitmapbase.hxx>
25 #include <base/bitmapcanvasbase.hxx>
26 #include <spriteredrawmanager.hxx>
28 namespace com::sun::star::rendering { class XAnimation; }
29 namespace com::sun::star::rendering { class XAnimatedSprite; }
30 namespace com::sun::star::rendering { class XCustomSprite; }
31 namespace com::sun::star::rendering { class XSprite; }
34 namespace canvas
36 /** Helper template to handle XIntegerBitmap method forwarding to
37 BitmapCanvasHelper
39 Use this helper to handle the XIntegerBitmap part of your
40 implementation.
42 @tpl Base
43 Base class to use, most probably one of the
44 WeakComponentImplHelperN templates with the appropriate
45 interfaces. At least XSpriteCanvas and SpriteSurface should be
46 among them (why else would you use this template, then?). Base
47 class must have a Base( const Mutex& ) constructor (like the
48 WeakComponentImplHelperN templates have).
50 @tpl CanvasHelper
51 Canvas helper implementation for the backend in question
53 @tpl Mutex
54 Lock strategy to use. Defaults to using the
55 BaseMutex-provided lock. Every time one of the methods is
56 entered, an object of type Mutex is created with m_aMutex as
57 the sole parameter, and destroyed again when the method scope
58 is left.
60 @tpl UnambiguousBase
61 Optional unambiguous base class for XInterface of Base. It's
62 sometimes necessary to specify this parameter, e.g. if Base
63 derives from multiple UNO interface (were each provides its
64 own version of XInterface, making the conversion ambiguous)
66 @see CanvasBase for further contractual requirements towards
67 the CanvasHelper type, and some examples.
69 template< class Base,
70 class CanvasHelper,
71 class Mutex=::osl::MutexGuard,
72 class UnambiguousBase = css::uno::XInterface > class SpriteCanvasBase :
73 public IntegerBitmapBase< BitmapCanvasBase<Base, CanvasHelper, Mutex, UnambiguousBase> >
75 public:
76 typedef IntegerBitmapBase< BitmapCanvasBase<Base, CanvasHelper, Mutex, UnambiguousBase> > BaseType;
77 typedef ::rtl::Reference< SpriteCanvasBase > Reference;
79 SpriteCanvasBase() :
80 maRedrawManager()
84 virtual void disposeThis() override
86 typename BaseType::MutexType aGuard( BaseType::m_aMutex );
88 maRedrawManager.disposing();
90 // pass on to base class
91 BaseType::disposeThis();
94 // XSpriteCanvas
95 virtual css::uno::Reference< css::rendering::XAnimatedSprite > SAL_CALL createSpriteFromAnimation( const css::uno::Reference< css::rendering::XAnimation >& animation ) override
97 tools::verifyArgs(animation,
98 __func__,
99 static_cast< typename BaseType::UnambiguousBaseType* >(this));
101 typename BaseType::MutexType aGuard( BaseType::m_aMutex );
103 return BaseType::maCanvasHelper.createSpriteFromAnimation(animation);
106 virtual css::uno::Reference< css::rendering::XAnimatedSprite > SAL_CALL createSpriteFromBitmaps( const css::uno::Sequence< css::uno::Reference< css::rendering::XBitmap > >& animationBitmaps,
107 sal_Int8 interpolationMode ) override
109 tools::verifyArgs(animationBitmaps,
110 __func__,
111 static_cast< typename BaseType::UnambiguousBaseType* >(this));
112 tools::verifyRange( interpolationMode,
113 css::rendering::InterpolationMode::NEAREST_NEIGHBOR,
114 css::rendering::InterpolationMode::BEZIERSPLINE4 );
116 typename BaseType::MutexType aGuard( BaseType::m_aMutex );
118 return BaseType::maCanvasHelper.createSpriteFromBitmaps(animationBitmaps, interpolationMode);
121 virtual css::uno::Reference< css::rendering::XCustomSprite > SAL_CALL createCustomSprite( const css::geometry::RealSize2D& spriteSize ) override
123 tools::verifySpriteSize(spriteSize,
124 __func__,
125 static_cast< typename BaseType::UnambiguousBaseType* >(this));
127 typename BaseType::MutexType aGuard( BaseType::m_aMutex );
129 return BaseType::maCanvasHelper.createCustomSprite(spriteSize);
132 virtual css::uno::Reference< css::rendering::XSprite > SAL_CALL createClonedSprite( const css::uno::Reference< css::rendering::XSprite >& original ) override
134 tools::verifyArgs(original,
135 __func__,
136 static_cast< typename BaseType::UnambiguousBaseType* >(this));
138 typename BaseType::MutexType aGuard( BaseType::m_aMutex );
140 return BaseType::maCanvasHelper.createClonedSprite(original);
143 // SpriteSurface
144 virtual void showSprite( const Sprite::Reference& rSprite ) override
146 OSL_ASSERT( rSprite.is() );
148 typename BaseType::MutexType aGuard( BaseType::m_aMutex );
150 maRedrawManager.showSprite( rSprite );
153 virtual void hideSprite( const Sprite::Reference& rSprite ) override
155 OSL_ASSERT( rSprite.is() );
157 typename BaseType::MutexType aGuard( BaseType::m_aMutex );
159 maRedrawManager.hideSprite( rSprite );
162 virtual void moveSprite( const Sprite::Reference& rSprite,
163 const ::basegfx::B2DPoint& rOldPos,
164 const ::basegfx::B2DPoint& rNewPos,
165 const ::basegfx::B2DVector& rSpriteSize ) override
167 OSL_ASSERT( rSprite.is() );
169 typename BaseType::MutexType aGuard( BaseType::m_aMutex );
171 maRedrawManager.moveSprite( rSprite, rOldPos, rNewPos, rSpriteSize );
174 virtual void updateSprite( const Sprite::Reference& rSprite,
175 const ::basegfx::B2DPoint& rPos,
176 const ::basegfx::B2DRange& rUpdateArea ) override
178 OSL_ASSERT( rSprite.is() );
180 typename BaseType::MutexType aGuard( BaseType::m_aMutex );
182 maRedrawManager.updateSprite( rSprite, rPos, rUpdateArea );
185 protected:
186 SpriteRedrawManager maRedrawManager;
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */