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 INCLUDED_SLIDESHOW_VIEWLAYER_HXX
25 #define INCLUDED_SLIDESHOW_VIEWLAYER_HXX
26 
27 #include <sal/config.h>
28 #include <boost/shared_ptr.hpp>
29 
30 namespace basegfx
31 {
32     class B1DRange;
33     class B2DRange;
34     class B2DVector;
35     class B2DHomMatrix;
36     class B2DPolyPolygon;
37 }
38 namespace cppcanvas
39 {
40     class Canvas;
41     class CustomSprite;
42 }
43 
44 
45 /* Definition of ViewLayer interface */
46 
47 namespace slideshow
48 {
49     namespace internal
50     {
51         class View;
52 
53         class ViewLayer
54         {
55         public:
~ViewLayer()56             virtual ~ViewLayer() {}
57 
58             /** Query whether layer displays on given view.
59 
60                 @return true, if this layer displays on the given
61                 view.
62             */
63             virtual bool isOnView(boost::shared_ptr<View> const& rView) const = 0;
64 
65             /** Get the associated canvas of this layer.
66 
67 	        	The canvas returned by this method must not change, as
68                 long as this object is alive.
69             */
70             virtual boost::shared_ptr< cppcanvas::Canvas > getCanvas() const = 0;
71 
72             /** Clear the clipped view layer area
73 
74                 This method clears the area inside the clip polygon,
75                 if none is set, the transformed unit rectangle of the
76                 view.
77              */
78             virtual void clear() const = 0;
79 
80             /** Clear the complete view
81 
82                 This method clears the full view area (not only the
83                 transformed unit rectangle, or within the clip). If
84                 this ViewLayer represents the background layer, the
85                 whole XSlideShowView is cleared. If this ViewLayer is
86                 implemented using sprites (i.e. one of the upper
87                 layers), the sprite is cleared to fully transparent.
88              */
89             virtual void clearAll() const = 0;
90 
91             /** Create a sprite for this layer
92 
93 	        	@param rSpriteSizePixel
94                 Sprite size in device pixel
95 
96                 @param nPriority
97                 Sprite priority. This value determines the priority of
98                 this sprite, relative to all other sprites of this
99                 ViewLayer. The higher the priority, the closer to the
100                 foreground the sprite will be.
101 
102                 @return the sprite, or NULL on failure (or if this
103                 canvas does not support sprites).
104             */
105             virtual boost::shared_ptr< cppcanvas::CustomSprite >
106             createSprite( const basegfx::B2DVector& rSpriteSizePixel,
107                           double                    nPriority ) const = 0;
108 
109             /** Set the layer priority range
110 
111 	        	This method influences the relative priority of this
112 	        	layer, i.e. the z position in relation to other layers
113 	        	on the parent view. The higher the priority range, the
114 	        	further in front the layer resides.
115 
116                 @param rRange
117                 Priority range, must be in the range [0,1]
118             */
119             virtual void setPriority( const basegfx::B1DRange& rRange ) = 0;
120 
121             /** Get the overall view transformation.
122 
123 	        	This method should <em>not</em> simply return the
124 	        	underlying canvas' transformation, but rather provide
125 	        	a layer above that. This enables clients of the
126 	        	slideshow to set their own user space transformation
127 	        	at the canvas, whilst the slideshow adds their
128 	        	transformation on top of that. Concretely, this method
129 	        	returns the user transform (implicitely calculated
130 	        	from the setViewSize() method), combined with the view
131 	        	transformation.
132             */
133             virtual basegfx::B2DHomMatrix getTransformation() const = 0;
134 
135             /** Get the overall view transformation.
136 
137 	        	Same transformation as with getTransformation(), only
138 	        	that you can safely use this one to position sprites
139 	        	on screen (no ViewLayer offsets included whatsoever).
140             */
141             virtual basegfx::B2DHomMatrix getSpriteTransformation() const = 0;
142 
143             /** Set clipping on this view layer.
144 
145             	@param rClip
146                 Clip poly-polygon to set. The polygon is interpreted
147                 in the user coordinate system, i.e. the view layer has
148                 the size as given by setViewSize() on its
149                 corresponding View.
150              */
151             virtual void setClip( const basegfx::B2DPolyPolygon& rClip ) = 0;
152 
153             /** Resize this view layer.
154 
155             	@param rArea
156                 New area to cover. The area is interpreted in the user
157                 coordinate system, i.e. relative to the size as given
158                 by setViewSize() on the corresponding View.
159 
160                 @return true, if layer was actually resized (which
161                 invalidates its content)
162              */
163             virtual bool resize( const basegfx::B2DRange& rArea ) = 0;
164 
165         };
166 
167         typedef boost::shared_ptr< ViewLayer > ViewLayerSharedPtr;
168     }
169 }
170 
171 #endif /* INCLUDED_SLIDESHOW_VIEWLAYER_HXX */
172