xref: /aoo41x/main/slideshow/source/inc/viewlayer.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef INCLUDED_SLIDESHOW_VIEWLAYER_HXX
29 #define INCLUDED_SLIDESHOW_VIEWLAYER_HXX
30 
31 #include <sal/config.h>
32 #include <boost/shared_ptr.hpp>
33 
34 namespace basegfx
35 {
36     class B1DRange;
37     class B2DRange;
38     class B2DVector;
39     class B2DHomMatrix;
40     class B2DPolyPolygon;
41 }
42 namespace cppcanvas
43 {
44     class Canvas;
45     class CustomSprite;
46 }
47 
48 
49 /* Definition of ViewLayer interface */
50 
51 namespace slideshow
52 {
53     namespace internal
54     {
55         class View;
56 
57         class ViewLayer
58         {
59         public:
60             virtual ~ViewLayer() {}
61 
62             /** Query whether layer displays on given view.
63 
64                 @return true, if this layer displays on the given
65                 view.
66             */
67             virtual bool isOnView(boost::shared_ptr<View> const& rView) const = 0;
68 
69             /** Get the associated canvas of this layer.
70 
71 	        	The canvas returned by this method must not change, as
72                 long as this object is alive.
73             */
74             virtual boost::shared_ptr< cppcanvas::Canvas > getCanvas() const = 0;
75 
76             /** Clear the clipped view layer area
77 
78                 This method clears the area inside the clip polygon,
79                 if none is set, the transformed unit rectangle of the
80                 view.
81              */
82             virtual void clear() const = 0;
83 
84             /** Clear the complete view
85 
86                 This method clears the full view area (not only the
87                 transformed unit rectangle, or within the clip). If
88                 this ViewLayer represents the background layer, the
89                 whole XSlideShowView is cleared. If this ViewLayer is
90                 implemented using sprites (i.e. one of the upper
91                 layers), the sprite is cleared to fully transparent.
92              */
93             virtual void clearAll() const = 0;
94 
95             /** Create a sprite for this layer
96 
97 	        	@param rSpriteSizePixel
98                 Sprite size in device pixel
99 
100                 @param nPriority
101                 Sprite priority. This value determines the priority of
102                 this sprite, relative to all other sprites of this
103                 ViewLayer. The higher the priority, the closer to the
104                 foreground the sprite will be.
105 
106                 @return the sprite, or NULL on failure (or if this
107                 canvas does not support sprites).
108             */
109             virtual boost::shared_ptr< cppcanvas::CustomSprite >
110             createSprite( const basegfx::B2DVector& rSpriteSizePixel,
111                           double                    nPriority ) const = 0;
112 
113             /** Set the layer priority range
114 
115 	        	This method influences the relative priority of this
116 	        	layer, i.e. the z position in relation to other layers
117 	        	on the parent view. The higher the priority range, the
118 	        	further in front the layer resides.
119 
120                 @param rRange
121                 Priority range, must be in the range [0,1]
122             */
123             virtual void setPriority( const basegfx::B1DRange& rRange ) = 0;
124 
125             /** Get the overall view transformation.
126 
127 	        	This method should <em>not</em> simply return the
128 	        	underlying canvas' transformation, but rather provide
129 	        	a layer above that. This enables clients of the
130 	        	slideshow to set their own user space transformation
131 	        	at the canvas, whilst the slideshow adds their
132 	        	transformation on top of that. Concretely, this method
133 	        	returns the user transform (implicitely calculated
134 	        	from the setViewSize() method), combined with the view
135 	        	transformation.
136             */
137             virtual basegfx::B2DHomMatrix getTransformation() const = 0;
138 
139             /** Get the overall view transformation.
140 
141 	        	Same transformation as with getTransformation(), only
142 	        	that you can safely use this one to position sprites
143 	        	on screen (no ViewLayer offsets included whatsoever).
144             */
145             virtual basegfx::B2DHomMatrix getSpriteTransformation() const = 0;
146 
147             /** Set clipping on this view layer.
148 
149             	@param rClip
150                 Clip poly-polygon to set. The polygon is interpreted
151                 in the user coordinate system, i.e. the view layer has
152                 the size as given by setViewSize() on its
153                 corresponding View.
154              */
155             virtual void setClip( const basegfx::B2DPolyPolygon& rClip ) = 0;
156 
157             /** Resize this view layer.
158 
159             	@param rArea
160                 New area to cover. The area is interpreted in the user
161                 coordinate system, i.e. relative to the size as given
162                 by setViewSize() on the corresponding View.
163 
164                 @return true, if layer was actually resized (which
165                 invalidates its content)
166              */
167             virtual bool resize( const basegfx::B2DRange& rArea ) = 0;
168 
169         };
170 
171         typedef boost::shared_ptr< ViewLayer > ViewLayerSharedPtr;
172     }
173 }
174 
175 #endif /* INCLUDED_SLIDESHOW_VIEWLAYER_HXX */
176