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 SDEXT_PRESENTER_PRESENTER_SPRITE_HXX
25 #define SDEXT_PRESENTER_PRESENTER_SPRITE_HXX
26 
27 #include <com/sun/star/rendering/XCustomSprite.hpp>
28 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
29 #include <boost/noncopyable.hpp>
30 
31 namespace css = ::com::sun::star;
32 
33 namespace sdext { namespace presenter {
34 
35 /** A wrapper around a com::sun::star::rendering::XCustomSprite that allows
36     not only setting values like size, location, and transformation but also
37     provides read access to them.
38     It also handles the showing and hiding of a sprite.  This includes not
39     to show the sprite when its size is not yet defined (results in a crash)
40     and hiding a sprite before disposing it (results in zombie sprites.)
41 */
42 class PresenterSprite
43     : private ::boost::noncopyable
44 {
45 public:
46     PresenterSprite (void);
47     virtual ~PresenterSprite (void);
48 
49     /** The given sprite canvas is used as factory to create the sprite that
50         is wrapped by objects of this class.
51         It is also used to call updateScreen() at (wrapped by the Update() method).
52     */
53     void SetFactory (
54         const ::css::uno::Reference<css::rendering::XSpriteCanvas>& rxSpriteFactory);
55 
56     ::css::uno::Reference<css::rendering::XCanvas> GetCanvas (void);
57 
58     void Show (void);
59     void Hide (void);
60     bool IsVisible (void) const;
61 
62     void SetPriority (const double nPriority);
63     double GetPriority (void) const;
64 
65     void Resize (const css::geometry::RealSize2D& rSize);
66     css::geometry::RealSize2D GetSize (void) const;
67 
68     void MoveTo (const css::geometry::RealPoint2D& rLocation);
69     css::geometry::RealPoint2D GetLocation (void) const;
70 
71     void Transform (const css::geometry::AffineMatrix2D& rTransform);
72     css::geometry::AffineMatrix2D GetTransform (void) const;
73 
74     void SetAlpha (const double nAlpha);
75     double GetAlpha (void) const;
76 
77     void Update (void);
78 
79 private:
80     ::css::uno::Reference<css::rendering::XSpriteCanvas> mxSpriteFactory;
81     ::css::uno::Reference<css::rendering::XCustomSprite> mxSprite;
82     css::geometry::RealSize2D maSize;
83     css::geometry::RealPoint2D maLocation;
84     css::geometry::AffineMatrix2D maTransform;
85     bool mbIsVisible;
86     double mnPriority;
87     double mnAlpha;
88 
89     void ProvideSprite (void);
90     void DisposeSprite (void);
91 };
92 
93 } }
94 
95 #endif
96