1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef INCLUDED_SLIDESHOW_USEREVENTQUEUE_HXX 29*cdf0e10cSrcweir #define INCLUDED_SLIDESHOW_USEREVENTQUEUE_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <com/sun/star/animations/XAnimationNode.hpp> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include "eventmultiplexer.hxx" 34*cdf0e10cSrcweir #include "eventqueue.hxx" 35*cdf0e10cSrcweir #include "shape.hxx" 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <boost/noncopyable.hpp> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir /* Definition of UserEventQueue class */ 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir namespace slideshow { 42*cdf0e10cSrcweir namespace internal { 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir class PlainEventHandler; 45*cdf0e10cSrcweir class AllAnimationEventHandler; 46*cdf0e10cSrcweir class ShapeClickEventHandler; 47*cdf0e10cSrcweir class ClickEventHandler; 48*cdf0e10cSrcweir class CursorManager; 49*cdf0e10cSrcweir class SkipEffectEventHandler; 50*cdf0e10cSrcweir class RewindEffectEventHandler; 51*cdf0e10cSrcweir class MouseEnterHandler; 52*cdf0e10cSrcweir class MouseLeaveHandler; 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir /** This class schedules user-activated events. 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir This class registeres at the EventMultiplexer and fires 57*cdf0e10cSrcweir events registered for certain user actions. Note that all 58*cdf0e10cSrcweir events will not be fired immediately after the user action 59*cdf0e10cSrcweir occured, but always added to the EventQueue (and fired the 60*cdf0e10cSrcweir next time that queue is processed). Which is actually a 61*cdf0e10cSrcweir feature. 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir Conceptually, an event is an object that typically is 64*cdf0e10cSrcweir fired only once. After that, the event is exhausted, and 65*cdf0e10cSrcweir should be discarded. Therefore, all events registered on 66*cdf0e10cSrcweir this object are fired and then all references to them are 67*cdf0e10cSrcweir removed. 68*cdf0e10cSrcweir */ 69*cdf0e10cSrcweir class UserEventQueue : private ::boost::noncopyable 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir public: 72*cdf0e10cSrcweir /** Create a user event queue 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir @param rEventMultiplexer 75*cdf0e10cSrcweir The slideshow-global event source, where this class 76*cdf0e10cSrcweir registeres its event handlers. 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir @param rEventQueue 79*cdf0e10cSrcweir Reference to the main event queue. Since we hold this 80*cdf0e10cSrcweir object by plain reference, it must live longer than we 81*cdf0e10cSrcweir do. On the other hand, that queue must not fire events 82*cdf0e10cSrcweir after this object is destroyed, since we might 83*cdf0e10cSrcweir schedule events there which itself contain plain 84*cdf0e10cSrcweir references to this object. Basically, EventQueue and 85*cdf0e10cSrcweir UserEventQueue should have the same lifetime, and since 86*cdf0e10cSrcweir this is not possible, both must be destructed in a 87*cdf0e10cSrcweir phased mode: first clear both of any remaining events, 88*cdf0e10cSrcweir then destruct them. 89*cdf0e10cSrcweir */ 90*cdf0e10cSrcweir UserEventQueue( EventMultiplexer& rMultiplexer, 91*cdf0e10cSrcweir EventQueue& rEventQueue, 92*cdf0e10cSrcweir CursorManager& rCursorManager ); 93*cdf0e10cSrcweir ~UserEventQueue(); 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir /** Query whether there are any events still pending. 96*cdf0e10cSrcweir */ 97*cdf0e10cSrcweir bool isEmpty() const; 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir /** Clear all registered events. 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir This method clears all registered, but 102*cdf0e10cSrcweir not-yet-executed events. This comes in handy when 103*cdf0e10cSrcweir force-ending a slide, to avoid interference with the 104*cdf0e10cSrcweir next slide's event registration. 105*cdf0e10cSrcweir */ 106*cdf0e10cSrcweir void clear(); 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir /** Set advance on click behaviour. 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir @param bAdvanceOnClick 111*cdf0e10cSrcweir When true, a click somewhere on the slide will also 112*cdf0e10cSrcweir generate next effect event. In this case, it is 113*cdf0e10cSrcweir irrelevant where on the slide the mouse is clicked, 114*cdf0e10cSrcweir i.e. the shape need not be hit by the mouse. 115*cdf0e10cSrcweir */ 116*cdf0e10cSrcweir void setAdvanceOnClick( bool bAdvanceOnClick ); 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir /** Register an event that will be fired when the slide is 119*cdf0e10cSrcweir just shown. 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir Note that <em>all</em> registered events will be fired 122*cdf0e10cSrcweir when the slide start occurs. This is in contrast to 123*cdf0e10cSrcweir the mouse events below. 124*cdf0e10cSrcweir */ 125*cdf0e10cSrcweir void registerSlideStartEvent( const EventSharedPtr& rEvent ); 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir /** Register an event that will be fired when the slide is 128*cdf0e10cSrcweir about to vanish. 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir Note that <em>all</em> registered events will be fired 131*cdf0e10cSrcweir when the slide end occurs. This is in contrast to 132*cdf0e10cSrcweir the mouse events below. 133*cdf0e10cSrcweir */ 134*cdf0e10cSrcweir void registerSlideEndEvent( const EventSharedPtr& rEvent ); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir /** Register an event that will be fired when the given 137*cdf0e10cSrcweir animation node starts. 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir Note that <em>all</em> registered events will be fired 140*cdf0e10cSrcweir when the animation start occurs. This is in contrast to 141*cdf0e10cSrcweir the mouse events below. 142*cdf0e10cSrcweir */ 143*cdf0e10cSrcweir void registerAnimationStartEvent( 144*cdf0e10cSrcweir const EventSharedPtr& rEvent, 145*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 146*cdf0e10cSrcweir ::com::sun::star::animations::XAnimationNode>& xNode ); 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir /** Register an event that will be fired when the given 149*cdf0e10cSrcweir animation node ends its active duration. 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir Note that <em>all</em> registered events will be fired 152*cdf0e10cSrcweir when the animation end occurs. This is in contrast to 153*cdf0e10cSrcweir the mouse events below. 154*cdf0e10cSrcweir */ 155*cdf0e10cSrcweir void registerAnimationEndEvent( 156*cdf0e10cSrcweir const EventSharedPtr& rEvent, 157*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 158*cdf0e10cSrcweir ::com::sun::star::animations::XAnimationNode>& xNode ); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir /** Register an event that will be fired when audio output 161*cdf0e10cSrcweir stopped for the given animation node. 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir Note that <em>all</em> registered events will be fired 164*cdf0e10cSrcweir when the audio stopping occurs. This is in contrast to 165*cdf0e10cSrcweir the mouse events below. 166*cdf0e10cSrcweir */ 167*cdf0e10cSrcweir void registerAudioStoppedEvent( 168*cdf0e10cSrcweir const EventSharedPtr& rEvent, 169*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 170*cdf0e10cSrcweir ::com::sun::star::animations::XAnimationNode>& xNode ); 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir /** Register an event that is fired when a shape is clicked 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir For every mouse click, only one of the events 175*cdf0e10cSrcweir registered here is fired. The order of fired events is 176*cdf0e10cSrcweir the order of registration, i.e. the first event 177*cdf0e10cSrcweir registered will be the one fired for the first mouse 178*cdf0e10cSrcweir click on the given shape. 179*cdf0e10cSrcweir */ 180*cdf0e10cSrcweir void registerShapeClickEvent( const EventSharedPtr& rEvent, 181*cdf0e10cSrcweir const ShapeSharedPtr& rShape ); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir /** Registes an event that is fired when the current effects(s) 184*cdf0e10cSrcweir are skipped, .e.g. when the left mouse button is pressed. 185*cdf0e10cSrcweir Then, all registered events are fired and removed from this 186*cdf0e10cSrcweir queue. After firing, a next effect event is issued to this 187*cdf0e10cSrcweir queue to start the next effect. 188*cdf0e10cSrcweir @param pEvent 189*cdf0e10cSrcweir The event to execute when skipping the current effect. 190*cdf0e10cSrcweir @param bSkipTriggersNextEffect 191*cdf0e10cSrcweir When <TRUE/> then after skipping the current effect the next 192*cdf0e10cSrcweir effect is triggered. When <FALSE/> then the next effect is not 193*cdf0e10cSrcweir triggered. 194*cdf0e10cSrcweir */ 195*cdf0e10cSrcweir void registerSkipEffectEvent( 196*cdf0e10cSrcweir EventSharedPtr const& pEvent, 197*cdf0e10cSrcweir const bool bSkipTriggersNextEffect); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir /** Registes an event that is fired when the current effects(s) 200*cdf0e10cSrcweir are rewound, .e.g. when the right mouse button is pressed. 201*cdf0e10cSrcweir Then, all registered events are fired and removed from this 202*cdf0e10cSrcweir queue. 203*cdf0e10cSrcweir */ 204*cdf0e10cSrcweir void registerRewindEffectEvent( EventSharedPtr const& rEvent ); 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir /** Register an event that is fired to show the next event 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir For every next effect event, only one of the events 209*cdf0e10cSrcweir registered here is fired. The order of fired events is 210*cdf0e10cSrcweir the order of registration, i.e. the first event 211*cdf0e10cSrcweir registered will be the one fired for the first mouse 212*cdf0e10cSrcweir click. When advance-on-click (see method 213*cdf0e10cSrcweir setAdvanceOnClick()) is enabled, a mouse click 214*cdf0e10cSrcweir somewhere on the slide will also generate a next 215*cdf0e10cSrcweir effect event. In this case, it is irrelevant where on 216*cdf0e10cSrcweir the slide the mouse is clicked, i.e. the shape need 217*cdf0e10cSrcweir not be hit by the mouse. 218*cdf0e10cSrcweir */ 219*cdf0e10cSrcweir void registerNextEffectEvent( const EventSharedPtr& rEvent ); 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir /** Register an event that is fired on a double mouse 222*cdf0e10cSrcweir click on a shape 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir For every mouse double click, only one of the events 225*cdf0e10cSrcweir registered here is fired. The order of fired events is 226*cdf0e10cSrcweir the order of registration, i.e. the first event 227*cdf0e10cSrcweir registered will be the one fired for the first mouse 228*cdf0e10cSrcweir double click. It is irrelevant where on the slide the 229*cdf0e10cSrcweir mouse is clicked, i.e. the shape need not be hit by 230*cdf0e10cSrcweir the mouse. 231*cdf0e10cSrcweir */ 232*cdf0e10cSrcweir void registerShapeDoubleClickEvent( const EventSharedPtr& rEvent, 233*cdf0e10cSrcweir const ShapeSharedPtr& rShape ); 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir /** Register an event that is fired on a double mouse click 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir For every mouse double click, only one of the events 238*cdf0e10cSrcweir registered here is fired. The order of fired events is 239*cdf0e10cSrcweir the order of registration, i.e. the first event 240*cdf0e10cSrcweir registered will be the one fired for the first mouse 241*cdf0e10cSrcweir double click. It is irrelevant where on the slide the 242*cdf0e10cSrcweir mouse is clicked, i.e. the shape need not be hit by 243*cdf0e10cSrcweir the mouse. 244*cdf0e10cSrcweir */ 245*cdf0e10cSrcweir void registerDoubleClickEvent( const EventSharedPtr& rEvent ); 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir /** Register an event that is fired when the mouse enters 248*cdf0e10cSrcweir the area of the given shape 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir For every enter, only one of the events registered 251*cdf0e10cSrcweir here is fired. The order of fired events is the order 252*cdf0e10cSrcweir of registration, i.e. the first event registered will 253*cdf0e10cSrcweir be the one fired for the first time the mouse enters 254*cdf0e10cSrcweir the given shape. 255*cdf0e10cSrcweir */ 256*cdf0e10cSrcweir void registerMouseEnterEvent( const EventSharedPtr& rEvent, 257*cdf0e10cSrcweir const ShapeSharedPtr& rShape ); 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir /** Register an event that is fired when the mouse leaves 260*cdf0e10cSrcweir the area of the given shape 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir For every leave, only one of the events registered 263*cdf0e10cSrcweir here is fired. The order of fired events is the order 264*cdf0e10cSrcweir of registration, i.e. the first event registered will 265*cdf0e10cSrcweir be the one fired for the first time the mouse leaves 266*cdf0e10cSrcweir the given shape area. 267*cdf0e10cSrcweir */ 268*cdf0e10cSrcweir void registerMouseLeaveEvent( const EventSharedPtr& rEvent, 269*cdf0e10cSrcweir const ShapeSharedPtr& rShape ); 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir /** Typically skipping the current effect is triggered by mouse clicks 272*cdf0e10cSrcweir or key presses that trigger the next effect. This method allows the 273*cdf0e10cSrcweir skipping of effects to be triggered programatically. 274*cdf0e10cSrcweir */ 275*cdf0e10cSrcweir void callSkipEffectEventHandler (void); 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir private: 278*cdf0e10cSrcweir /** Generically register an event on one of the handlers. 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir If the handler is not yet created, do that and 281*cdf0e10cSrcweir register it via the Functor 282*cdf0e10cSrcweir */ 283*cdf0e10cSrcweir template< typename Handler, typename Functor > 284*cdf0e10cSrcweir void registerEvent( ::boost::shared_ptr< Handler >& rHandler, 285*cdf0e10cSrcweir const EventSharedPtr& rEvent, 286*cdf0e10cSrcweir const Functor& rRegistrationFunctor ); 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir /** Generically register an event on one of the handlers. 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir If the handler is not yet created, do that and 291*cdf0e10cSrcweir register it via the Functor. This version of the 292*cdf0e10cSrcweir registerEvent method takes an additional parameter 293*cdf0e10cSrcweir rArg, which is passed as the second argument to 294*cdf0e10cSrcweir rHandler's addEvent() method. 295*cdf0e10cSrcweir */ 296*cdf0e10cSrcweir template< typename Handler, typename Arg, typename Functor > 297*cdf0e10cSrcweir void registerEvent( ::boost::shared_ptr< Handler >& rHandler, 298*cdf0e10cSrcweir const EventSharedPtr& rEvent, 299*cdf0e10cSrcweir const Arg& rArg, 300*cdf0e10cSrcweir const Functor& rRegistrationFunctor ); 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir EventMultiplexer& mrMultiplexer; 303*cdf0e10cSrcweir EventQueue& mrEventQueue; 304*cdf0e10cSrcweir CursorManager& mrCursorManager; 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir ::boost::shared_ptr<PlainEventHandler> mpStartEventHandler; 307*cdf0e10cSrcweir ::boost::shared_ptr<PlainEventHandler> mpEndEventHandler; 308*cdf0e10cSrcweir ::boost::shared_ptr<AllAnimationEventHandler> mpAnimationStartEventHandler; 309*cdf0e10cSrcweir ::boost::shared_ptr<AllAnimationEventHandler> mpAnimationEndEventHandler; 310*cdf0e10cSrcweir ::boost::shared_ptr<AllAnimationEventHandler> mpAudioStoppedEventHandler; 311*cdf0e10cSrcweir ::boost::shared_ptr<ShapeClickEventHandler> mpShapeClickEventHandler; 312*cdf0e10cSrcweir ::boost::shared_ptr<ClickEventHandler> mpClickEventHandler; 313*cdf0e10cSrcweir ::boost::shared_ptr<SkipEffectEventHandler> mpSkipEffectEventHandler; 314*cdf0e10cSrcweir ::boost::shared_ptr<RewindEffectEventHandler> mpRewindEffectEventHandler; 315*cdf0e10cSrcweir ::boost::shared_ptr<ShapeClickEventHandler> mpShapeDoubleClickEventHandler; 316*cdf0e10cSrcweir ::boost::shared_ptr<ClickEventHandler> mpDoubleClickEventHandler; 317*cdf0e10cSrcweir ::boost::shared_ptr<MouseEnterHandler> mpMouseEnterHandler; 318*cdf0e10cSrcweir ::boost::shared_ptr<MouseLeaveHandler> mpMouseLeaveHandler; 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir bool mbAdvanceOnClick; 321*cdf0e10cSrcweir }; 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir } // namespace internal 324*cdf0e10cSrcweir } // namespace presentation 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir #endif /* INCLUDED_SLIDESHOW_USEREVENTQUEUE_HXX */ 327*cdf0e10cSrcweir 328