2 * Copyright(c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 /// The wheel event structure is used to store a wheel rolling, it facilitates processing of the wheel rolling and passing to other libraries like Toolkit.<br />
23 /// There is a key modifier which relates to keys like Alt, Shift, and Ctrl functions are supplied to check if they have been pressed when the wheel is being rolled.<br />
24 /// We support a mouse device and there may be another custom device that support the wheel event. The device type is specified as \e type.<br />
25 /// The mouse wheel event can be sent to the specific actor but the custom wheel event will be sent to the window.<br />
27 /// <since_tizen> 3 </since_tizen>
28 public class Wheel : global::System.IDisposable
30 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
34 /// <since_tizen> 3 </since_tizen>
35 protected bool swigCMemOwn;
37 internal Wheel(global::System.IntPtr cPtr, bool cMemoryOwn)
39 swigCMemOwn = cMemoryOwn;
40 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
43 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Wheel obj)
45 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
48 //A Flag to check who called Dispose(). (By User or DisposeQueue)
49 private bool isDisposeQueued = false;
52 /// A Flat to check if it is already disposed.
54 /// <since_tizen> 3 </since_tizen>
55 protected bool disposed = false;
60 /// <since_tizen> 3 </since_tizen>
65 isDisposeQueued = true;
66 DisposeQueue.Instance.Add(this);
73 /// <since_tizen> 3 </since_tizen>
76 //Throw excpetion if Dispose() is called in separate thread.
77 if (!Window.IsInstalled())
79 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
84 Dispose(DisposeTypes.Implicit);
88 Dispose(DisposeTypes.Explicit);
89 System.GC.SuppressFinalize(this);
96 /// <param name="type">The type dispose, it could be from user, or called by DisposeQueue.</param>
97 /// <since_tizen> 3 </since_tizen>
98 protected virtual void Dispose(DisposeTypes type)
105 if(type == DisposeTypes.Explicit)
108 //Release your own managed resources here.
109 //You should release all of your own disposable objects here.
112 //Release your own unmanaged resources here.
113 //You should not access any managed member here except static instance.
114 //because the execution order of Finalizes is non-deterministic.
116 if (swigCPtr.Handle != global::System.IntPtr.Zero)
121 NDalicPINVOKE.delete_Wheel(swigCPtr);
123 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
129 internal static Wheel GetWheelFromPtr(global::System.IntPtr cPtr)
131 Wheel ret = new Wheel(cPtr, false);
132 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
137 /// The type of the wheel event.
139 /// <since_tizen> 3 </since_tizen>
140 public Wheel.WheelType Type
149 /// The direction of wheel rolling (0 = default vertical wheel, 1 = horizontal wheel).
151 /// <since_tizen> 3 </since_tizen>
161 /// Modifier keys pressed during the event (such as Shift, Alt, and Ctrl).
163 /// <since_tizen> 3 </since_tizen>
164 public uint Modifiers
173 /// The coordinates of the cursor relative to the top-left of the screen.
175 /// <since_tizen> 3 </since_tizen>
185 /// The offset of rolling (positive value means roll down or clockwise, and negative value means roll up or counter-clockwise).
187 /// <since_tizen> 3 </since_tizen>
197 /// The time the wheel is being rolled.
199 /// <since_tizen> 3 </since_tizen>
200 public uint TimeStamp
209 /// The default constructor.
211 /// <since_tizen> 3 </since_tizen>
212 public Wheel() : this(NDalicPINVOKE.new_Wheel__SWIG_0(), true)
214 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
220 /// <param name="type">The type of the wheel event.</param>
221 /// <param name="direction">The direction of wheel rolling (0 = default vertical wheel, 1 = horizontal wheel).</param>
222 /// <param name="modifiers">Modifier keys pressed during the event (such as Shift, Alt, and Ctrl).</param>
223 /// <param name="point">The coordinates of the cursor relative to the top-left of the screen.</param>
224 /// <param name="z">The offset of rolling (positive value means roll down or clockwise, and negative value means roll up or counter-clockwise).</param>
225 /// <param name="timeStamp">The time the wheel is being rolled.</param>
226 /// <since_tizen> 3 </since_tizen>
227 public Wheel(Wheel.WheelType type, int direction, uint modifiers, Vector2 point, int z, uint timeStamp) : this(NDalicPINVOKE.new_Wheel__SWIG_1((int)type, direction, modifiers, Vector2.getCPtr(point), z, timeStamp), true)
229 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
233 /// Checks to see if the Shift key modifier has been supplied.
235 /// <returns>True if Shift modifier.</returns>
236 /// <since_tizen> 3 </since_tizen>
237 public bool IsShiftModifier()
239 bool ret = NDalicPINVOKE.Wheel_IsShiftModifier(swigCPtr);
240 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
245 /// Checks to see if Ctrl (control) key modifier has been supplied.
247 /// <returns>True if Ctrl modifier.</returns>
248 /// <since_tizen> 3 </since_tizen>
249 public bool IsCtrlModifier()
251 bool ret = NDalicPINVOKE.Wheel_IsCtrlModifier(swigCPtr);
252 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
257 /// Checks to see if Alt key modifier has been supplied.
259 /// <returns>True if Alt modifier.</returns>
260 /// <since_tizen> 3 </since_tizen>
261 public bool IsAltModifier()
263 bool ret = NDalicPINVOKE.Wheel_IsAltModifier(swigCPtr);
264 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
268 private Wheel.WheelType type
272 NDalicPINVOKE.Wheel_type_set(swigCPtr, (int)value);
273 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
277 Wheel.WheelType ret = (Wheel.WheelType)NDalicPINVOKE.Wheel_type_get(swigCPtr);
278 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
283 private int direction
287 NDalicPINVOKE.Wheel_direction_set(swigCPtr, value);
288 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
292 int ret = NDalicPINVOKE.Wheel_direction_get(swigCPtr);
293 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
298 private uint modifiers
302 NDalicPINVOKE.Wheel_modifiers_set(swigCPtr, value);
303 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
307 uint ret = NDalicPINVOKE.Wheel_modifiers_get(swigCPtr);
308 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
313 private Vector2 point
317 NDalicPINVOKE.Wheel_point_set(swigCPtr, Vector2.getCPtr(value));
318 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
322 global::System.IntPtr cPtr = NDalicPINVOKE.Wheel_point_get(swigCPtr);
323 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
324 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
333 NDalicPINVOKE.Wheel_z_set(swigCPtr, value);
334 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
338 int ret = NDalicPINVOKE.Wheel_z_get(swigCPtr);
339 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
344 private uint timeStamp
348 NDalicPINVOKE.Wheel_timeStamp_set(swigCPtr, value);
349 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
353 uint ret = NDalicPINVOKE.Wheel_timeStamp_get(swigCPtr);
354 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
360 /// The type of the wheel event.
362 /// <since_tizen> 3 </since_tizen>
363 public enum WheelType
366 /// Mouse wheel event.
368 /// <since_tizen> 3 </since_tizen>
372 /// Custom wheel event.
374 /// <since_tizen> 3 </since_tizen>