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