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 public class Wheel : global::System.IDisposable
29 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
33 protected bool swigCMemOwn;
35 internal Wheel(global::System.IntPtr cPtr, bool cMemoryOwn)
37 swigCMemOwn = cMemoryOwn;
38 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
41 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Wheel obj)
43 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
46 //A Flag to check who called Dispose(). (By User or DisposeQueue)
47 private bool isDisposeQueued = false;
50 /// A Flat to check if it is already disposed.
52 protected bool disposed = false;
57 /// <since_tizen> 3 </since_tizen>
62 isDisposeQueued = true;
63 DisposeQueue.Instance.Add(this);
70 /// <since_tizen> 3 </since_tizen>
73 //Throw excpetion if Dispose() is called in separate thread.
74 if (!Window.IsInstalled())
76 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
81 Dispose(DisposeTypes.Implicit);
85 Dispose(DisposeTypes.Explicit);
86 System.GC.SuppressFinalize(this);
93 /// <param name="type">The type dispose, it could be from user, or called by DisposeQueue.</param>
94 /// <since_tizen> 3 </since_tizen>
95 protected virtual void Dispose(DisposeTypes type)
102 if(type == DisposeTypes.Explicit)
105 //Release your own managed resources here.
106 //You should release all of your own disposable objects here.
109 //Release your own unmanaged resources here.
110 //You should not access any managed member here except static instance.
111 //because the execution order of Finalizes is non-deterministic.
113 if (swigCPtr.Handle != global::System.IntPtr.Zero)
118 NDalicPINVOKE.delete_Wheel(swigCPtr);
120 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
126 internal static Wheel GetWheelFromPtr(global::System.IntPtr cPtr)
128 Wheel ret = new Wheel(cPtr, false);
129 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
134 /// The type of the wheel event.
136 /// <since_tizen> 3 </since_tizen>
137 public Wheel.WheelType Type
146 /// The direction of wheel rolling (0 = default vertical wheel, 1 = horizontal wheel).
148 /// <since_tizen> 3 </since_tizen>
158 /// Modifier keys pressed during the event (such as Shift, Alt, and Ctrl).
160 /// <since_tizen> 3 </since_tizen>
161 public uint Modifiers
170 /// The coordinates of the cursor relative to the top-left of the screen.
172 /// <since_tizen> 3 </since_tizen>
182 /// The offset of rolling (positive value means roll down or clockwise, and negative value means roll up or counter-clockwise).
184 /// <since_tizen> 3 </since_tizen>
194 /// The time the wheel is being rolled.
196 /// <since_tizen> 3 </since_tizen>
197 public uint TimeStamp
206 /// The default constructor.
208 /// <since_tizen> 3 </since_tizen>
209 public Wheel() : this(NDalicPINVOKE.new_Wheel__SWIG_0(), true)
211 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
217 /// <param name="type">The type of the wheel event.</param>
218 /// <param name="direction">The direction of wheel rolling (0 = default vertical wheel, 1 = horizontal wheel).</param>
219 /// <param name="modifiers">Modifier keys pressed during the event (such as Shift, Alt, and Ctrl).</param>
220 /// <param name="point">The coordinates of the cursor relative to the top-left of the screen.</param>
221 /// <param name="z">The offset of rolling (positive value means roll down or clockwise, and negative value means roll up or counter-clockwise).</param>
222 /// <param name="timeStamp">The time the wheel is being rolled.</param>
223 /// <since_tizen> 3 </since_tizen>
224 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)
226 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
230 /// Checks to see if the Shift key modifier has been supplied.
232 /// <returns>True if Shift modifier.</returns>
233 /// <since_tizen> 3 </since_tizen>
234 public bool IsShiftModifier()
236 bool ret = NDalicPINVOKE.Wheel_IsShiftModifier(swigCPtr);
237 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
242 /// Checks to see if Ctrl (control) key modifier has been supplied.
244 /// <returns>True if Ctrl modifier.</returns>
245 /// <since_tizen> 3 </since_tizen>
246 public bool IsCtrlModifier()
248 bool ret = NDalicPINVOKE.Wheel_IsCtrlModifier(swigCPtr);
249 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254 /// Checks to see if Alt key modifier has been supplied.
256 /// <returns>True if Alt modifier.</returns>
257 /// <since_tizen> 3 </since_tizen>
258 public bool IsAltModifier()
260 bool ret = NDalicPINVOKE.Wheel_IsAltModifier(swigCPtr);
261 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
265 private Wheel.WheelType type
269 NDalicPINVOKE.Wheel_type_set(swigCPtr, (int)value);
270 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
274 Wheel.WheelType ret = (Wheel.WheelType)NDalicPINVOKE.Wheel_type_get(swigCPtr);
275 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
280 private int direction
284 NDalicPINVOKE.Wheel_direction_set(swigCPtr, value);
285 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
289 int ret = NDalicPINVOKE.Wheel_direction_get(swigCPtr);
290 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
295 private uint modifiers
299 NDalicPINVOKE.Wheel_modifiers_set(swigCPtr, value);
300 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
304 uint ret = NDalicPINVOKE.Wheel_modifiers_get(swigCPtr);
305 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
310 private Vector2 point
314 NDalicPINVOKE.Wheel_point_set(swigCPtr, Vector2.getCPtr(value));
315 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
319 global::System.IntPtr cPtr = NDalicPINVOKE.Wheel_point_get(swigCPtr);
320 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
321 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
330 NDalicPINVOKE.Wheel_z_set(swigCPtr, value);
331 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
335 int ret = NDalicPINVOKE.Wheel_z_get(swigCPtr);
336 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
341 private uint timeStamp
345 NDalicPINVOKE.Wheel_timeStamp_set(swigCPtr, value);
346 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
350 uint ret = NDalicPINVOKE.Wheel_timeStamp_get(swigCPtr);
351 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
357 /// The type of the wheel event.
359 /// <since_tizen> 3 </since_tizen>
360 public enum WheelType
363 /// Mouse wheel event.
365 /// <since_tizen> 3 </since_tizen>
369 /// Custom wheel event.
371 /// <since_tizen> 3 </since_tizen>