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 #if ! defined(WAITSYMBOL_HXX_INCLUDED)
25 #define WAITSYMBOL_HXX_INCLUDED
26 
27 #include <com/sun/star/rendering/XBitmap.hpp>
28 #include <cppcanvas/customsprite.hxx>
29 
30 #include "vieweventhandler.hxx"
31 #include "screenupdater.hxx"
32 #include "eventmultiplexer.hxx"
33 #include "unoview.hxx"
34 
35 #include <boost/shared_ptr.hpp>
36 #include <boost/bind.hpp>
37 #include <boost/utility.hpp> // for noncopyable
38 #include <vector>
39 
40 namespace slideshow {
41 namespace internal {
42 
43 class EventMultiplexer;
44 typedef boost::shared_ptr<class WaitSymbol> WaitSymbolSharedPtr;
45 
46 class WaitSymbol : public ViewEventHandler,
47                    private ::boost::noncopyable
48 {
49 public:
50     static WaitSymbolSharedPtr create( const ::com::sun::star::uno::Reference<
51                                              ::com::sun::star::rendering::XBitmap>& xBitmap,
52                                        ScreenUpdater&                               rScreenUpdater,
53                                        EventMultiplexer&                            rEventMultiplexer,
54                                        const UnoViewContainer&                      rViewContainer );
55 
56     /** Shows the wait symbol.
57      */
show()58     void show() { setVisible(true); }
59 
60     /** Hides the wait symbol.
61      */
hide()62     void hide() { setVisible(false); }
63 
64 private:
65     WaitSymbol( const ::com::sun::star::uno::Reference<
66                       ::com::sun::star::rendering::XBitmap>& xBitmap,
67                 ScreenUpdater&                               rScreenUpdater,
68                 const UnoViewContainer&                      rViewContainer );
69 
70     // ViewEventHandler
71     virtual void viewAdded( const UnoViewSharedPtr& rView );
72     virtual void viewRemoved( const UnoViewSharedPtr& rView );
73     virtual void viewChanged( const UnoViewSharedPtr& rView );
74     virtual void viewsChanged();
75 
76     void setVisible( const bool bVisible );
77     ::basegfx::B2DPoint calcSpritePos( UnoViewSharedPtr const & rView ) const;
78 
79     template <typename func_type>
for_each_sprite(func_type const & func) const80     void for_each_sprite( func_type const & func ) const
81     {
82         ViewsVecT::const_iterator iPos( maViews.begin() );
83         const ViewsVecT::const_iterator iEnd( maViews.end() );
84         for ( ; iPos != iEnd; ++iPos )
85             if( iPos->second )
86                 func( iPos->second );
87     }
88 
89     typedef ::std::vector<
90         ::std::pair<UnoViewSharedPtr,
91                     cppcanvas::CustomSpriteSharedPtr> > ViewsVecT;
92 
93     ::com::sun::star::uno::Reference<
94         ::com::sun::star::rendering::XBitmap>  mxBitmap;
95 
96     ViewsVecT                                  maViews;
97     ScreenUpdater&                             mrScreenUpdater;
98     bool                                       mbVisible;
99 };
100 
101 } // namespace internal
102 } // namespace presentation
103 
104 #endif
105