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 _SDR_ANIMATION_SCHEDULER_HXX 29*cdf0e10cSrcweir #define _SDR_ANIMATION_SCHEDULER_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <sal/types.h> 32*cdf0e10cSrcweir #include <vcl/timer.hxx> 33*cdf0e10cSrcweir #include <svx/svxdllapi.h> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 36*cdf0e10cSrcweir // event class 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir namespace sdr 39*cdf0e10cSrcweir { 40*cdf0e10cSrcweir namespace animation 41*cdf0e10cSrcweir { 42*cdf0e10cSrcweir class Event 43*cdf0e10cSrcweir { 44*cdf0e10cSrcweir // time of event in ms 45*cdf0e10cSrcweir sal_uInt32 mnTime; 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir // pointer for simply linked list 48*cdf0e10cSrcweir Event* mpNext; 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir public: 51*cdf0e10cSrcweir // constructor/destructor 52*cdf0e10cSrcweir Event(sal_uInt32 nTime); 53*cdf0e10cSrcweir SVX_DLLPUBLIC virtual ~Event(); 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir // access to mpNext 56*cdf0e10cSrcweir Event* GetNext() const; 57*cdf0e10cSrcweir void SetNext(Event* pNew); 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir // get/set time 60*cdf0e10cSrcweir sal_uInt32 GetTime() const; 61*cdf0e10cSrcweir void SetTime(sal_uInt32 nNew); 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir // execute event 64*cdf0e10cSrcweir virtual void Trigger(sal_uInt32 nTime) = 0; 65*cdf0e10cSrcweir }; 66*cdf0e10cSrcweir } // end of namespace animation 67*cdf0e10cSrcweir } // end of namespace sdr 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 70*cdf0e10cSrcweir // eventlist class 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir namespace sdr 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir namespace animation 75*cdf0e10cSrcweir { 76*cdf0e10cSrcweir class EventList 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir // pointer to first entry 79*cdf0e10cSrcweir Event* mpHead; 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir public: 82*cdf0e10cSrcweir // constructor/destructor 83*cdf0e10cSrcweir EventList(); 84*cdf0e10cSrcweir SVX_DLLPUBLIC virtual ~EventList(); 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir // insert/remove time dependent 87*cdf0e10cSrcweir void Insert(Event* pNew); 88*cdf0e10cSrcweir void Remove(Event* pOld); 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir // clear list 91*cdf0e10cSrcweir void Clear(); 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir // get first 94*cdf0e10cSrcweir Event* GetFirst(); 95*cdf0e10cSrcweir }; 96*cdf0e10cSrcweir } // end of namespace animation 97*cdf0e10cSrcweir } // end of namespace sdr 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 100*cdf0e10cSrcweir // scheduler class 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir namespace sdr 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir namespace animation 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir class Scheduler : public Timer 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir // time in ms 109*cdf0e10cSrcweir sal_uInt32 mnTime; 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir // next delta time 112*cdf0e10cSrcweir sal_uInt32 mnDeltaTime; 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir // list of events 115*cdf0e10cSrcweir EventList maList; 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir // Flag which remembers if this timer is paused. Default 118*cdf0e10cSrcweir // is false. 119*cdf0e10cSrcweir bool mbIsPaused; 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir public: 122*cdf0e10cSrcweir // constructor/destructor 123*cdf0e10cSrcweir Scheduler(); 124*cdf0e10cSrcweir SVX_DLLPUBLIC virtual ~Scheduler(); 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir // From baseclass Timer, the timeout call 127*cdf0e10cSrcweir SVX_DLLPUBLIC virtual void Timeout(); 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir // get time 130*cdf0e10cSrcweir sal_uInt32 GetTime(); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir // #i38135# 133*cdf0e10cSrcweir void SetTime(sal_uInt32 nTime); 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir // reset 136*cdf0e10cSrcweir void Reset(sal_uInt32 nTime); 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir // execute all ripe events, removes executed ones from the scheduler 139*cdf0e10cSrcweir void triggerEvents(); 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir // re-start or stop timer according to event list 142*cdf0e10cSrcweir void checkTimeout(); 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir // insert/remove events, wrapper to EventList methods 145*cdf0e10cSrcweir void InsertEvent(Event* pNew); 146*cdf0e10cSrcweir void RemoveEvent(Event* pOld); 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir // get/set pause 149*cdf0e10cSrcweir bool IsPaused() const { return mbIsPaused; } 150*cdf0e10cSrcweir void SetPaused(bool bNew); 151*cdf0e10cSrcweir }; 152*cdf0e10cSrcweir } // end of namespace animation 153*cdf0e10cSrcweir } // end of namespace sdr 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir #endif //_SDR_ANIMATION_SCHEDULER_HXX 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir // eof 160