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_REHEARSETIMINGSACTIVITY_HXX 29 #define INCLUDED_SLIDESHOW_REHEARSETIMINGSACTIVITY_HXX 30 31 #include "activity.hxx" 32 33 #include <basegfx/range/b2drange.hxx> 34 #include <boost/shared_ptr.hpp> 35 #include <boost/enable_shared_from_this.hpp> 36 #include <boost/noncopyable.hpp> 37 38 #include <vector> 39 #include <utility> 40 41 class Font; 42 namespace canvas{ namespace tools{ class ElapsedTime; }} 43 namespace cppcanvas{ class CustomSprite; } 44 namespace basegfx 45 { 46 class B2IVector; 47 class B2DRange; 48 } 49 50 namespace slideshow { 51 namespace internal { 52 53 struct SlideShowContext; 54 class EventMultiplexer; 55 class ScreenUpdater; 56 class RehearseTimingsActivity : public Activity, 57 public ViewEventHandler, 58 public boost::enable_shared_from_this<RehearseTimingsActivity>, 59 private ::boost::noncopyable 60 { 61 public: 62 /** Creates the activity. 63 */ 64 static boost::shared_ptr<RehearseTimingsActivity> create( 65 const SlideShowContext& rContext ); 66 67 virtual ~RehearseTimingsActivity(); 68 69 /** Starts and shows the timer; adds to activity queue. 70 */ 71 void start(); 72 73 /** Stops and hides the timer. 74 @return elapsed time 75 */ 76 double stop(); 77 78 /** Determines whether the timer button has been clicked. 79 */ 80 bool hasBeenClicked() const; 81 82 // ViewEventHandler interface 83 virtual void viewAdded( const UnoViewSharedPtr& rView ); 84 virtual void viewRemoved( const UnoViewSharedPtr& rView ); 85 virtual void viewChanged( const UnoViewSharedPtr& rView ); 86 virtual void viewsChanged(); 87 88 // Disposable: 89 virtual void dispose(); 90 // Activity: 91 virtual double calcTimeLag() const; 92 virtual bool perform(); 93 virtual bool isActive() const; 94 virtual void dequeued(); 95 virtual void end(); 96 97 private: 98 class WakeupEvent; 99 100 explicit RehearseTimingsActivity( const SlideShowContext& rContext ); 101 102 void paint( ::cppcanvas::CanvasSharedPtr const & canvas ) const; 103 void paintAllSprites() const; 104 105 class MouseHandler; 106 friend class MouseHandler; 107 108 typedef ::std::vector< 109 ::std::pair<UnoViewSharedPtr, 110 boost::shared_ptr<cppcanvas::CustomSprite> > > ViewsVecT; 111 112 template <typename func_type> 113 void for_each_sprite( func_type const & func ) const 114 { 115 ViewsVecT::const_iterator iPos( maViews.begin() ); 116 const ViewsVecT::const_iterator iEnd( maViews.end() ); 117 for ( ; iPos != iEnd; ++iPos ) 118 func( iPos->second ); 119 } 120 121 ::basegfx::B2DRange calcSpriteRectangle( 122 UnoViewSharedPtr const & rView ) const; 123 124 EventQueue& mrEventQueue; 125 ScreenUpdater& mrScreenUpdater; 126 EventMultiplexer& mrEventMultiplexer; 127 ActivitiesQueue& mrActivitiesQueue; 128 canvas::tools::ElapsedTime maElapsedTime; 129 130 ViewsVecT maViews; 131 132 /// screen rect of sprite (in view coordinates!) 133 ::basegfx::B2DRange maSpriteRectangle; 134 135 Font maFont; 136 boost::shared_ptr<WakeupEvent> mpWakeUpEvent; 137 boost::shared_ptr<MouseHandler> mpMouseHandler; 138 ::basegfx::B2IVector maSpriteSizePixel; 139 sal_Int32 mnYOffset; 140 bool mbActive; 141 bool mbDrawPressed; 142 }; 143 144 } // namespace internal 145 } // namespace presentation 146 147 #endif /* INCLUDED_SLIDESHOW_REHEARSETIMINGSACTIVITY_HXX */ 148