Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef INCLUDED_CANVAS_SPRITE_HXX
30 : : #define INCLUDED_CANVAS_SPRITE_HXX
31 : :
32 : : #include <rtl/ref.hxx>
33 : : #include <com/sun/star/lang/XComponent.hpp>
34 : : #include <com/sun/star/rendering/XCanvas.hpp>
35 : : #include <basegfx/point/b2dpoint.hxx>
36 : : #include <basegfx/vector/b2dsize.hxx>
37 : :
38 : : namespace basegfx
39 : : {
40 : : class B2DPoint;
41 : : class B2DVector;
42 : : class B2DRange;
43 : : }
44 : :
45 : : namespace canvas
46 : : {
47 : : /* Definition of Sprite interface (as we mix with UNO here, has to
48 : : be XInterface - reference holders to a Sprite must be able to
49 : : control lifetime of reference target)
50 : : */
51 : :
52 : : /** Helper interface to connect SpriteCanvas with various
53 : : sprite implementations.
54 : :
55 : : This interface should be implemented from every sprite class,
56 : : as it provides essential repaint and update area facilitates.
57 : :
58 : : @derive typically, each canvas implementation will derive
59 : : another interface from this one, that adds rendering
60 : : functionality (which, of course, is impossible here in a
61 : : generic way)
62 : : */
63 : 0 : class Sprite : public ::com::sun::star::lang::XComponent
64 : : {
65 : : public:
66 : : typedef ::rtl::Reference< Sprite > Reference;
67 : :
68 : : /** Query whether sprite update will fully cover the given area.
69 : :
70 : : Use this method to determine whether any background
71 : : content (regardless of static or sprite) needs an update
72 : : before rendering this sprite.
73 : :
74 : : @return true, if sprite redraw will fully overwrite given
75 : : area (and thus, the background need not be redrawn
76 : : beforehand).
77 : : */
78 : : virtual bool isAreaUpdateOpaque( const ::basegfx::B2DRange& rUpdateArea ) const = 0;
79 : :
80 : : /** Query whether content has changed
81 : : */
82 : : virtual bool isContentChanged() const = 0;
83 : :
84 : : /** Query position of the left, top pixel of the sprite
85 : : */
86 : : virtual ::basegfx::B2DPoint getPosPixel() const = 0;
87 : :
88 : : /** Query size of the sprite in pixel.
89 : : */
90 : : virtual ::basegfx::B2DVector getSizePixel() const = 0;
91 : :
92 : : /** Get area that is currently covered by the sprite
93 : :
94 : : This area is already adapted to clipping, alpha and
95 : : transformation state of this sprite.
96 : : */
97 : : virtual ::basegfx::B2DRange getUpdateArea() const = 0;
98 : :
99 : : /** Query sprite priority
100 : : */
101 : : virtual double getPriority() const = 0;
102 : :
103 : : protected:
104 : 0 : ~Sprite() {}
105 : : };
106 : :
107 : : /** Functor providing a StrictWeakOrdering for sprite references
108 : : */
109 : : struct SpriteWeakOrder
110 : : {
111 : 0 : bool operator()( const Sprite::Reference& rLHS,
112 : : const Sprite::Reference& rRHS )
113 : : {
114 : 0 : const double nPrioL( rLHS->getPriority() );
115 : 0 : const double nPrioR( rRHS->getPriority() );
116 : :
117 : : // if prios are equal, tie-break on ptr value
118 [ # # ]: 0 : return nPrioL == nPrioR ? rLHS.get() < rRHS.get() : nPrioL < nPrioR;
119 : : }
120 : : };
121 : : }
122 : :
123 : : #endif /* INCLUDED_CANVAS_SPRITE_HXX */
124 : :
125 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|