1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 /// 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>
22 /// 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>
23 /// 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>
24 /// The mouse wheel event can be sent to the specific actor but the custom wheel event will be sent to the window.<br>
26 public class Wheel : global::System.IDisposable
28 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29 protected bool swigCMemOwn;
31 internal Wheel(global::System.IntPtr cPtr, bool cMemoryOwn)
33 swigCMemOwn = cMemoryOwn;
34 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
37 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Wheel obj)
39 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
42 //A Flag to check who called Dispose(). (By User or DisposeQueue)
43 private bool isDisposeQueued = false;
44 //A Flat to check if it is already disposed.
45 protected bool disposed = false;
51 isDisposeQueued = true;
52 DisposeQueue.Instance.Add(this);
58 //Throw excpetion if Dispose() is called in separate thread.
59 if (!Window.IsInstalled())
61 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
66 Dispose(DisposeTypes.Implicit);
70 Dispose(DisposeTypes.Explicit);
71 System.GC.SuppressFinalize(this);
75 protected virtual void Dispose(DisposeTypes type)
82 if(type == DisposeTypes.Explicit)
85 //Release your own managed resources here.
86 //You should release all of your own disposable objects here.
89 //Release your own unmanaged resources here.
90 //You should not access any managed member here except static instance.
91 //because the execution order of Finalizes is non-deterministic.
93 if (swigCPtr.Handle != global::System.IntPtr.Zero)
98 NDalicPINVOKE.delete_Wheel(swigCPtr);
100 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
106 internal static Wheel GetWheelFromPtr(global::System.IntPtr cPtr)
108 Wheel ret = new Wheel(cPtr, false);
109 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
114 /// The type of the wheel event.
116 public Wheel.WheelType Type
125 /// The direction of wheel rolling (0 = default vertical wheel, 1 = horizontal wheel).
136 /// Modifier keys pressed during the event (such as Shift, Alt, and Ctrl).
138 public uint Modifiers
147 /// The coordinates of the cursor relative to the top-left of the screen.
158 /// The offset of rolling (positive value means roll down or clockwise, and negative value means roll up or counter-clockwise).
169 /// The time the wheel is being rolled.
171 public uint TimeStamp
180 /// The default constructor.
182 public Wheel() : this(NDalicPINVOKE.new_Wheel__SWIG_0(), true)
184 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190 /// <param name="type">The type of the wheel event.</param>
191 /// <param name="direction">The direction of wheel rolling (0 = default vertical wheel, 1 = horizontal wheel).</param>
192 /// <param name="modifiers">Modifier keys pressed during the event (such as Shift, Alt, and Ctrl).</param>
193 /// <param name="point">The coordinates of the cursor relative to the top-left of the screen.</param>
194 /// <param name="z">The offset of rolling (positive value means roll down or clockwise, and negative value means roll up or counter-clockwise).</param>
195 /// <param name="timeStamp">The time the wheel is being rolled.</param>
196 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)
198 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
202 /// Checks to see if the Shift key modifier has been supplied.
204 /// <returns>True if Shift modifier.</returns>
205 public bool IsShiftModifier()
207 bool ret = NDalicPINVOKE.Wheel_IsShiftModifier(swigCPtr);
208 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
213 /// Checks to see if Ctrl (control) key modifier has been supplied.
215 /// <returns>True if Ctrl modifier.</returns>
216 public bool IsCtrlModifier()
218 bool ret = NDalicPINVOKE.Wheel_IsCtrlModifier(swigCPtr);
219 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
224 /// Checks to see if Alt key modifier has been supplied.
226 /// <returns>True if Alt modifier.</returns>
227 public bool IsAltModifier()
229 bool ret = NDalicPINVOKE.Wheel_IsAltModifier(swigCPtr);
230 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
234 private Wheel.WheelType type
238 NDalicPINVOKE.Wheel_type_set(swigCPtr, (int)value);
239 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
243 Wheel.WheelType ret = (Wheel.WheelType)NDalicPINVOKE.Wheel_type_get(swigCPtr);
244 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
249 private int direction
253 NDalicPINVOKE.Wheel_direction_set(swigCPtr, value);
254 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
258 int ret = NDalicPINVOKE.Wheel_direction_get(swigCPtr);
259 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
264 private uint modifiers
268 NDalicPINVOKE.Wheel_modifiers_set(swigCPtr, value);
269 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
273 uint ret = NDalicPINVOKE.Wheel_modifiers_get(swigCPtr);
274 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
279 private Vector2 point
283 NDalicPINVOKE.Wheel_point_set(swigCPtr, Vector2.getCPtr(value));
284 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
288 global::System.IntPtr cPtr = NDalicPINVOKE.Wheel_point_get(swigCPtr);
289 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
290 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
299 NDalicPINVOKE.Wheel_z_set(swigCPtr, value);
300 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
304 int ret = NDalicPINVOKE.Wheel_z_get(swigCPtr);
305 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
310 private uint timeStamp
314 NDalicPINVOKE.Wheel_timeStamp_set(swigCPtr, value);
315 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
319 uint ret = NDalicPINVOKE.Wheel_timeStamp_get(swigCPtr);
320 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
326 /// The type of the wheel event.
328 public enum WheelType