Update ooo320-m1
[ooovba.git] / slideshow / source / engine / rehearsetimingsactivity.hxx
blob72f6e3f2fd99516e8c18811d527f9d1347c5add0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: rehearsetimingsactivity.hxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef INCLUDED_SLIDESHOW_REHEARSETIMINGSACTIVITY_HXX
32 #define INCLUDED_SLIDESHOW_REHEARSETIMINGSACTIVITY_HXX
34 #include "activity.hxx"
36 #include <basegfx/range/b2drange.hxx>
37 #include <boost/shared_ptr.hpp>
38 #include <boost/enable_shared_from_this.hpp>
39 #include <boost/noncopyable.hpp>
41 #include <vector>
42 #include <utility>
44 class Font;
45 namespace canvas{ namespace tools{ class ElapsedTime; }}
46 namespace cppcanvas{ class CustomSprite; }
47 namespace basegfx
49 class B2IVector;
50 class B2DRange;
53 namespace slideshow {
54 namespace internal {
56 struct SlideShowContext;
57 class EventMultiplexer;
58 class ScreenUpdater;
59 class RehearseTimingsActivity : public Activity,
60 public ViewEventHandler,
61 public boost::enable_shared_from_this<RehearseTimingsActivity>,
62 private ::boost::noncopyable
64 public:
65 /** Creates the activity.
67 static boost::shared_ptr<RehearseTimingsActivity> create(
68 const SlideShowContext& rContext );
70 virtual ~RehearseTimingsActivity();
72 /** Starts and shows the timer; adds to activity queue.
74 void start();
76 /** Stops and hides the timer.
77 @return elapsed time
79 double stop();
81 /** Determines whether the timer button has been clicked.
83 bool hasBeenClicked() const;
85 // ViewEventHandler interface
86 virtual void viewAdded( const UnoViewSharedPtr& rView );
87 virtual void viewRemoved( const UnoViewSharedPtr& rView );
88 virtual void viewChanged( const UnoViewSharedPtr& rView );
89 virtual void viewsChanged();
91 // Disposable:
92 virtual void dispose();
93 // Activity:
94 virtual double calcTimeLag() const;
95 virtual bool perform();
96 virtual bool isActive() const;
97 virtual void dequeued();
98 virtual void end();
100 private:
101 class WakeupEvent;
103 explicit RehearseTimingsActivity( const SlideShowContext& rContext );
105 void paint( ::cppcanvas::CanvasSharedPtr const & canvas ) const;
106 void paintAllSprites() const;
108 class MouseHandler;
109 friend class MouseHandler;
111 typedef ::std::vector<
112 ::std::pair<UnoViewSharedPtr,
113 boost::shared_ptr<cppcanvas::CustomSprite> > > ViewsVecT;
115 template <typename func_type>
116 void for_each_sprite( func_type const & func ) const
118 ViewsVecT::const_iterator iPos( maViews.begin() );
119 const ViewsVecT::const_iterator iEnd( maViews.end() );
120 for ( ; iPos != iEnd; ++iPos )
121 func( iPos->second );
124 ::basegfx::B2DRange calcSpriteRectangle(
125 UnoViewSharedPtr const & rView ) const;
127 EventQueue& mrEventQueue;
128 ScreenUpdater& mrScreenUpdater;
129 EventMultiplexer& mrEventMultiplexer;
130 ActivitiesQueue& mrActivitiesQueue;
131 canvas::tools::ElapsedTime maElapsedTime;
133 ViewsVecT maViews;
135 /// screen rect of sprite (in view coordinates!)
136 ::basegfx::B2DRange maSpriteRectangle;
138 Font maFont;
139 boost::shared_ptr<WakeupEvent> mpWakeUpEvent;
140 boost::shared_ptr<MouseHandler> mpMouseHandler;
141 ::basegfx::B2IVector maSpriteSizePixel;
142 sal_Int32 mnYOffset;
143 bool mbActive;
144 bool mbDrawPressed;
147 } // namespace internal
148 } // namespace presentation
150 #endif /* INCLUDED_SLIDESHOW_REHEARSETIMINGSACTIVITY_HXX */