1*3334a7e6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*3334a7e6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*3334a7e6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*3334a7e6SAndrew Rist * distributed with this work for additional information 6*3334a7e6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*3334a7e6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*3334a7e6SAndrew Rist * "License"); you may not use this file except in compliance 9*3334a7e6SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*3334a7e6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*3334a7e6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*3334a7e6SAndrew Rist * software distributed under the License is distributed on an 15*3334a7e6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*3334a7e6SAndrew Rist * KIND, either express or implied. See the License for the 17*3334a7e6SAndrew Rist * specific language governing permissions and limitations 18*3334a7e6SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*3334a7e6SAndrew Rist *************************************************************/ 21*3334a7e6SAndrew Rist 22*3334a7e6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _SDR_ANIMATION_SCHEDULER_HXX 25cdf0e10cSrcweir #define _SDR_ANIMATION_SCHEDULER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <sal/types.h> 28cdf0e10cSrcweir #include <vcl/timer.hxx> 29cdf0e10cSrcweir #include <svx/svxdllapi.h> 30cdf0e10cSrcweir 31cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 32cdf0e10cSrcweir // event class 33cdf0e10cSrcweir 34cdf0e10cSrcweir namespace sdr 35cdf0e10cSrcweir { 36cdf0e10cSrcweir namespace animation 37cdf0e10cSrcweir { 38cdf0e10cSrcweir class Event 39cdf0e10cSrcweir { 40cdf0e10cSrcweir // time of event in ms 41cdf0e10cSrcweir sal_uInt32 mnTime; 42cdf0e10cSrcweir 43cdf0e10cSrcweir // pointer for simply linked list 44cdf0e10cSrcweir Event* mpNext; 45cdf0e10cSrcweir 46cdf0e10cSrcweir public: 47cdf0e10cSrcweir // constructor/destructor 48cdf0e10cSrcweir Event(sal_uInt32 nTime); 49cdf0e10cSrcweir SVX_DLLPUBLIC virtual ~Event(); 50cdf0e10cSrcweir 51cdf0e10cSrcweir // access to mpNext 52cdf0e10cSrcweir Event* GetNext() const; 53cdf0e10cSrcweir void SetNext(Event* pNew); 54cdf0e10cSrcweir 55cdf0e10cSrcweir // get/set time 56cdf0e10cSrcweir sal_uInt32 GetTime() const; 57cdf0e10cSrcweir void SetTime(sal_uInt32 nNew); 58cdf0e10cSrcweir 59cdf0e10cSrcweir // execute event 60cdf0e10cSrcweir virtual void Trigger(sal_uInt32 nTime) = 0; 61cdf0e10cSrcweir }; 62cdf0e10cSrcweir } // end of namespace animation 63cdf0e10cSrcweir } // end of namespace sdr 64cdf0e10cSrcweir 65cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 66cdf0e10cSrcweir // eventlist class 67cdf0e10cSrcweir 68cdf0e10cSrcweir namespace sdr 69cdf0e10cSrcweir { 70cdf0e10cSrcweir namespace animation 71cdf0e10cSrcweir { 72cdf0e10cSrcweir class EventList 73cdf0e10cSrcweir { 74cdf0e10cSrcweir // pointer to first entry 75cdf0e10cSrcweir Event* mpHead; 76cdf0e10cSrcweir 77cdf0e10cSrcweir public: 78cdf0e10cSrcweir // constructor/destructor 79cdf0e10cSrcweir EventList(); 80cdf0e10cSrcweir SVX_DLLPUBLIC virtual ~EventList(); 81cdf0e10cSrcweir 82cdf0e10cSrcweir // insert/remove time dependent 83cdf0e10cSrcweir void Insert(Event* pNew); 84cdf0e10cSrcweir void Remove(Event* pOld); 85cdf0e10cSrcweir 86cdf0e10cSrcweir // clear list 87cdf0e10cSrcweir void Clear(); 88cdf0e10cSrcweir 89cdf0e10cSrcweir // get first 90cdf0e10cSrcweir Event* GetFirst(); 91cdf0e10cSrcweir }; 92cdf0e10cSrcweir } // end of namespace animation 93cdf0e10cSrcweir } // end of namespace sdr 94cdf0e10cSrcweir 95cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 96cdf0e10cSrcweir // scheduler class 97cdf0e10cSrcweir 98cdf0e10cSrcweir namespace sdr 99cdf0e10cSrcweir { 100cdf0e10cSrcweir namespace animation 101cdf0e10cSrcweir { 102cdf0e10cSrcweir class Scheduler : public Timer 103cdf0e10cSrcweir { 104cdf0e10cSrcweir // time in ms 105cdf0e10cSrcweir sal_uInt32 mnTime; 106cdf0e10cSrcweir 107cdf0e10cSrcweir // next delta time 108cdf0e10cSrcweir sal_uInt32 mnDeltaTime; 109cdf0e10cSrcweir 110cdf0e10cSrcweir // list of events 111cdf0e10cSrcweir EventList maList; 112cdf0e10cSrcweir 113cdf0e10cSrcweir // Flag which remembers if this timer is paused. Default 114cdf0e10cSrcweir // is false. 115cdf0e10cSrcweir bool mbIsPaused; 116cdf0e10cSrcweir 117cdf0e10cSrcweir public: 118cdf0e10cSrcweir // constructor/destructor 119cdf0e10cSrcweir Scheduler(); 120cdf0e10cSrcweir SVX_DLLPUBLIC virtual ~Scheduler(); 121cdf0e10cSrcweir 122cdf0e10cSrcweir // From baseclass Timer, the timeout call 123cdf0e10cSrcweir SVX_DLLPUBLIC virtual void Timeout(); 124cdf0e10cSrcweir 125cdf0e10cSrcweir // get time 126cdf0e10cSrcweir sal_uInt32 GetTime(); 127cdf0e10cSrcweir 128cdf0e10cSrcweir // #i38135# 129cdf0e10cSrcweir void SetTime(sal_uInt32 nTime); 130cdf0e10cSrcweir 131cdf0e10cSrcweir // reset 132cdf0e10cSrcweir void Reset(sal_uInt32 nTime); 133cdf0e10cSrcweir 134cdf0e10cSrcweir // execute all ripe events, removes executed ones from the scheduler 135cdf0e10cSrcweir void triggerEvents(); 136cdf0e10cSrcweir 137cdf0e10cSrcweir // re-start or stop timer according to event list 138cdf0e10cSrcweir void checkTimeout(); 139cdf0e10cSrcweir 140cdf0e10cSrcweir // insert/remove events, wrapper to EventList methods 141cdf0e10cSrcweir void InsertEvent(Event* pNew); 142cdf0e10cSrcweir void RemoveEvent(Event* pOld); 143cdf0e10cSrcweir 144cdf0e10cSrcweir // get/set pause IsPaused() const145cdf0e10cSrcweir bool IsPaused() const { return mbIsPaused; } 146cdf0e10cSrcweir void SetPaused(bool bNew); 147cdf0e10cSrcweir }; 148cdf0e10cSrcweir } // end of namespace animation 149cdf0e10cSrcweir } // end of namespace sdr 150cdf0e10cSrcweir 151cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 152cdf0e10cSrcweir 153cdf0e10cSrcweir #endif //_SDR_ANIMATION_SCHEDULER_HXX 154cdf0e10cSrcweir 155cdf0e10cSrcweir // eof 156