Merge "Resource ready signal for Controls (for ImageLoading)" into devel/master
[platform/core/uifw/dali-toolkit.git] / plugins / dali-sharp / sharp / internal / Timer.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16 // This File has been auto-generated by SWIG and then modified using DALi Ruby Scripts
17 //------------------------------------------------------------------------------
18 // <auto-generated />
19 //
20 // This file was automatically generated by SWIG (http://www.swig.org).
21 // Version 3.0.10
22 //
23 // Do not make changes to this file unless you know what you are doing--modify
24 // the SWIG interface file instead.
25 //------------------------------------------------------------------------------
26
27 namespace Dali {
28
29 using System;
30 using System.Runtime.InteropServices;
31
32
33 public class Timer : BaseHandle {
34   private global::System.Runtime.InteropServices.HandleRef swigCPtr;
35
36   internal Timer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Timer_SWIGUpcast(cPtr), cMemoryOwn) {
37     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
38   }
39
40   internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Timer obj) {
41     return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
42   }
43
44   ~Timer() {
45     DisposeQueue.Instance.Add(this);
46   }
47
48   public override void Dispose() {
49     if (!Stage.IsInstalled()) {
50       DisposeQueue.Instance.Add(this);
51       return;
52     }
53
54     lock(this) {
55       if (swigCPtr.Handle != global::System.IntPtr.Zero) {
56         if (swigCMemOwn) {
57           swigCMemOwn = false;
58           NDalicPINVOKE.delete_Timer(swigCPtr);
59         }
60         swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
61       }
62       global::System.GC.SuppressFinalize(this);
63       base.Dispose();
64     }
65   }
66
67
68
69   /**
70     * @brief Event arguments that passed via Tick signal
71     *
72     */
73   public class TickEventArgs : EventArgs
74   {
75   }
76
77   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
78   private delegate bool TickCallbackDelegate(IntPtr data);
79   private DaliEventHandlerWithReturnType<object,TickEventArgs,bool> _timerTickEventHandler;
80   private TickCallbackDelegate _timerTickCallbackDelegate;
81
82   /**
83     * @brief Event for Ticked signal which can be used to subscribe/unsubscribe the event handler
84     * (in the type of TickEventHandler-DaliEventHandlerWithReturnType<object,TickEventArgs,bool>) 
85     * provided by the user. Ticked signal is emitted after specified time interval.
86     */
87   public event DaliEventHandlerWithReturnType<object,TickEventArgs,bool> Tick
88   {
89      add
90      {
91         lock(this)
92         {
93            // Restricted to only one listener
94            if (_timerTickEventHandler == null)
95            {
96               _timerTickEventHandler += value;
97
98               _timerTickCallbackDelegate = new TickCallbackDelegate(OnTick);
99               this.TickSignal().Connect(_timerTickCallbackDelegate);
100            }
101         }
102      }
103
104      remove
105      {
106         lock(this)
107         {
108            if (_timerTickEventHandler != null)
109            {
110               this.TickSignal().Disconnect(_timerTickCallbackDelegate);
111            }
112
113            _timerTickEventHandler -= value;
114         }
115      }
116   }
117
118   // Callback for Timer Tick signal
119   private bool OnTick(IntPtr data)
120   {
121      TickEventArgs e = new TickEventArgs();
122
123      if (_timerTickEventHandler != null)
124      {
125         //here we send all data to user event handlers
126         return _timerTickEventHandler(this, e);
127      }
128      return false;
129   }
130
131
132   public Timer (uint milliSec) : this (NDalicPINVOKE.Timer_New(milliSec), true) {
133       if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
134
135   }
136   public Timer(Timer timer) : this(NDalicPINVOKE.new_Timer__SWIG_1(Timer.getCPtr(timer)), true) {
137     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
138   }
139
140   public Timer Assign(Timer timer) {
141     Timer ret = new Timer(NDalicPINVOKE.Timer_Assign(swigCPtr, Timer.getCPtr(timer)), false);
142     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
143     return ret;
144   }
145
146   public static Timer DownCast(BaseHandle handle) {
147     Timer ret = new Timer(NDalicPINVOKE.Timer_DownCast(BaseHandle.getCPtr(handle)), true);
148     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
149     return ret;
150   }
151
152   public void Start() {
153     NDalicPINVOKE.Timer_Start(swigCPtr);
154     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
155   }
156
157   public void Stop() {
158     NDalicPINVOKE.Timer_Stop(swigCPtr);
159     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
160   }
161
162   public void SetInterval(uint milliSec) {
163     NDalicPINVOKE.Timer_SetInterval(swigCPtr, milliSec);
164     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
165   }
166
167   public uint GetInterval() {
168     uint ret = NDalicPINVOKE.Timer_GetInterval(swigCPtr);
169     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
170     return ret;
171   }
172
173   public bool IsRunning() {
174     bool ret = NDalicPINVOKE.Timer_IsRunning(swigCPtr);
175     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
176     return ret;
177   }
178
179   public TimerSignalType TickSignal() {
180     TimerSignalType ret = new TimerSignalType(NDalicPINVOKE.Timer_TickSignal(swigCPtr), false);
181     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
182     return ret;
183   }
184
185 }
186
187 }