Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #ifndef INCLUDED_SLIDESHOW_REHEARSETIMINGSACTIVITY_HXX
21 : : #define INCLUDED_SLIDESHOW_REHEARSETIMINGSACTIVITY_HXX
22 : :
23 : : #include "activity.hxx"
24 : :
25 : : #include <basegfx/range/b2drange.hxx>
26 : : #include <boost/shared_ptr.hpp>
27 : : #include <boost/enable_shared_from_this.hpp>
28 : : #include <boost/noncopyable.hpp>
29 : :
30 : : #include <vector>
31 : : #include <utility>
32 : :
33 : : class Font;
34 : : namespace canvas{ namespace tools{ class ElapsedTime; }}
35 : : namespace cppcanvas{ class CustomSprite; }
36 : : namespace basegfx
37 : : {
38 : : class B2IVector;
39 : : class B2DRange;
40 : : }
41 : :
42 : : namespace slideshow {
43 : : namespace internal {
44 : :
45 : : struct SlideShowContext;
46 : : class EventMultiplexer;
47 : : class ScreenUpdater;
48 : : class RehearseTimingsActivity : public Activity,
49 : : public ViewEventHandler,
50 : : public boost::enable_shared_from_this<RehearseTimingsActivity>,
51 : : private ::boost::noncopyable
52 : : {
53 : : public:
54 : : /** Creates the activity.
55 : : */
56 : : static boost::shared_ptr<RehearseTimingsActivity> create(
57 : : const SlideShowContext& rContext );
58 : :
59 : : virtual ~RehearseTimingsActivity();
60 : :
61 : : /** Starts and shows the timer; adds to activity queue.
62 : : */
63 : : void start();
64 : :
65 : : /** Stops and hides the timer.
66 : : @return elapsed time
67 : : */
68 : : double stop();
69 : :
70 : : /** Determines whether the timer button has been clicked.
71 : : */
72 : : bool hasBeenClicked() const;
73 : :
74 : : // ViewEventHandler interface
75 : : virtual void viewAdded( const UnoViewSharedPtr& rView );
76 : : virtual void viewRemoved( const UnoViewSharedPtr& rView );
77 : : virtual void viewChanged( const UnoViewSharedPtr& rView );
78 : : virtual void viewsChanged();
79 : :
80 : : // Disposable:
81 : : virtual void dispose();
82 : : // Activity:
83 : : virtual double calcTimeLag() const;
84 : : virtual bool perform();
85 : : virtual bool isActive() const;
86 : : virtual void dequeued();
87 : : virtual void end();
88 : :
89 : : private:
90 : : class WakeupEvent;
91 : :
92 : : explicit RehearseTimingsActivity( const SlideShowContext& rContext );
93 : :
94 : : void paint( ::cppcanvas::CanvasSharedPtr const & canvas ) const;
95 : : void paintAllSprites() const;
96 : :
97 : : class MouseHandler;
98 : : friend class MouseHandler;
99 : :
100 : : typedef ::std::vector<
101 : : ::std::pair<UnoViewSharedPtr,
102 : : boost::shared_ptr<cppcanvas::CustomSprite> > > ViewsVecT;
103 : :
104 : : template <typename func_type>
105 : 0 : void for_each_sprite( func_type const & func ) const
106 : : {
107 : 0 : ViewsVecT::const_iterator iPos( maViews.begin() );
108 : 0 : const ViewsVecT::const_iterator iEnd( maViews.end() );
109 : 0 : for ( ; iPos != iEnd; ++iPos )
110 : 0 : func( iPos->second );
111 : 0 : }
112 : :
113 : : ::basegfx::B2DRange calcSpriteRectangle(
114 : : UnoViewSharedPtr const & rView ) const;
115 : :
116 : : EventQueue& mrEventQueue;
117 : : ScreenUpdater& mrScreenUpdater;
118 : : EventMultiplexer& mrEventMultiplexer;
119 : : ActivitiesQueue& mrActivitiesQueue;
120 : : canvas::tools::ElapsedTime maElapsedTime;
121 : :
122 : : ViewsVecT maViews;
123 : :
124 : : /// screen rect of sprite (in view coordinates!)
125 : : ::basegfx::B2DRange maSpriteRectangle;
126 : :
127 : : Font maFont;
128 : : boost::shared_ptr<WakeupEvent> mpWakeUpEvent;
129 : : boost::shared_ptr<MouseHandler> mpMouseHandler;
130 : : ::basegfx::B2IVector maSpriteSizePixel;
131 : : sal_Int32 mnYOffset;
132 : : bool mbActive;
133 : : bool mbDrawPressed;
134 : : };
135 : :
136 : : } // namespace internal
137 : : } // namespace presentation
138 : :
139 : : #endif /* INCLUDED_SLIDESHOW_REHEARSETIMINGSACTIVITY_HXX */
140 : :
141 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|