tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / canvas / inc / base / sprite.hxx
blob8a89c945429d11ac43e993ac79b0917ebc965d05
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/lang/XComponent.hpp>
24 #include <basegfx/point/b2dpoint.hxx>
26 namespace basegfx
28 class B2DVector;
29 class B2DRange;
32 namespace canvas
34 /* Definition of Sprite interface (as we mix with UNO here, has to
35 be XInterface - reference holders to a Sprite must be able to
36 control lifetime of reference target)
39 /** Helper interface to connect SpriteCanvas with various
40 sprite implementations.
42 This interface should be implemented from every sprite class,
43 as it provides essential repaint and update area facilitates.
45 @derive typically, each canvas implementation will derive
46 another interface from this one, that adds rendering
47 functionality (which, of course, is impossible here in a
48 generic way)
50 class Sprite : public css::lang::XComponent
52 public:
53 typedef ::rtl::Reference< Sprite > Reference;
55 /** Query whether sprite update will fully cover the given area.
57 Use this method to determine whether any background
58 content (regardless of static or sprite) needs an update
59 before rendering this sprite.
61 @return true, if sprite redraw will fully overwrite given
62 area (and thus, the background need not be redrawn
63 beforehand).
65 virtual bool isAreaUpdateOpaque( const ::basegfx::B2DRange& rUpdateArea ) const = 0;
67 /** Query whether content has changed
69 virtual bool isContentChanged() const = 0;
71 /** Query position of the left, top pixel of the sprite
73 virtual ::basegfx::B2DPoint getPosPixel() const = 0;
75 /** Query size of the sprite in pixel.
77 virtual ::basegfx::B2DVector getSizePixel() const = 0;
79 /** Get area that is currently covered by the sprite
81 This area is already adapted to clipping, alpha and
82 transformation state of this sprite.
84 virtual ::basegfx::B2DRange getUpdateArea() const = 0;
86 /** Query sprite priority
88 virtual double getPriority() const = 0;
90 protected:
91 ~Sprite() {}
94 /** Functor providing a StrictWeakOrdering for sprite references
96 struct SpriteWeakOrder
98 bool operator()( const Sprite::Reference& rLHS,
99 const Sprite::Reference& rRHS )
101 const double nPrioL( rLHS->getPriority() );
102 const double nPrioR( rRHS->getPriority() );
104 // if prios are equal, tie-break on ptr value
105 return nPrioL == nPrioR ? rLHS.get() < rRHS.get() : nPrioL < nPrioR;
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */