Add ScriptUI to support XAML file (#320)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Wheel.cs
1 /*
2  * Copyright(c) 2017 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 namespace Tizen.NUI
19 {
20
21     /// <summary>
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 />
26     /// </summary>
27     /// <since_tizen> 3 </since_tizen>
28     public class Wheel : global::System.IDisposable
29     {
30         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
31         /// <summary>
32         /// swigCMemOwn.
33         /// </summary>
34         /// <since_tizen> 3 </since_tizen>
35         protected bool swigCMemOwn;
36
37         internal Wheel(global::System.IntPtr cPtr, bool cMemoryOwn)
38         {
39             swigCMemOwn = cMemoryOwn;
40             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
41         }
42
43         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Wheel obj)
44         {
45             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
46         }
47
48         //A Flag to check who called Dispose(). (By User or DisposeQueue)
49         private bool isDisposeQueued = false;
50
51         /// <summary>
52         /// A Flat to check if it is already disposed.
53         /// </summary>
54         /// <since_tizen> 3 </since_tizen>
55         protected bool disposed = false;
56
57         /// <summary>
58         /// Destructor.
59         /// </summary>
60         /// <since_tizen> 3 </since_tizen>
61         ~Wheel()
62         {
63             if(!isDisposeQueued)
64             {
65                 isDisposeQueued = true;
66                 DisposeQueue.Instance.Add(this);
67             }
68         }
69
70         /// <summary>
71         /// Dispose.
72         /// </summary>
73         /// <since_tizen> 3 </since_tizen>
74         public void Dispose()
75         {
76             //Throw excpetion if Dispose() is called in separate thread.
77             if (!Window.IsInstalled())
78             {
79                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
80             }
81
82             if (isDisposeQueued)
83             {
84                 Dispose(DisposeTypes.Implicit);
85             }
86             else
87             {
88                 Dispose(DisposeTypes.Explicit);
89                 System.GC.SuppressFinalize(this);
90             }
91         }
92
93         /// <summary>
94         /// Dispose.
95         /// </summary>
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)
99         {
100             if (disposed)
101             {
102                 return;
103             }
104
105             if(type == DisposeTypes.Explicit)
106             {
107                 //Called by User
108                 //Release your own managed resources here.
109                 //You should release all of your own disposable objects here.
110             }
111
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.
115
116             if (swigCPtr.Handle != global::System.IntPtr.Zero)
117             {
118                 if (swigCMemOwn)
119                 {
120                     swigCMemOwn = false;
121                     NDalicPINVOKE.delete_Wheel(swigCPtr);
122                 }
123                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
124             }
125             disposed = true;
126         }
127
128
129         internal static Wheel GetWheelFromPtr(global::System.IntPtr cPtr)
130         {
131             Wheel ret = new Wheel(cPtr, false);
132             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
133             return ret;
134         }
135
136         /// <summary>
137         /// The type of the wheel event.
138         /// </summary>
139         /// <since_tizen> 3 </since_tizen>
140         public Wheel.WheelType Type
141         {
142             get
143             {
144                 return type;
145             }
146         }
147
148         /// <summary>
149         /// The direction of wheel rolling (0 = default vertical wheel, 1 = horizontal wheel).
150         /// </summary>
151         /// <since_tizen> 3 </since_tizen>
152         public int Direction
153         {
154             get
155             {
156                 return direction;
157             }
158         }
159
160         /// <summary>
161         /// Modifier keys pressed during the event (such as Shift, Alt, and Ctrl).
162         /// </summary>
163         /// <since_tizen> 3 </since_tizen>
164         public uint Modifiers
165         {
166             get
167             {
168                 return modifiers;
169             }
170         }
171
172         /// <summary>
173         /// The coordinates of the cursor relative to the top-left of the screen.
174         /// </summary>
175         /// <since_tizen> 3 </since_tizen>
176         public Vector2 Point
177         {
178             get
179             {
180                 return point;
181             }
182         }
183
184         /// <summary>
185         /// The offset of rolling (positive value means roll down or clockwise, and negative value means roll up or counter-clockwise).
186         /// </summary>
187         /// <since_tizen> 3 </since_tizen>
188         public int Z
189         {
190             get
191             {
192                 return z;
193             }
194         }
195
196         /// <summary>
197         /// The time the wheel is being rolled.
198         /// </summary>
199         /// <since_tizen> 3 </since_tizen>
200         public uint TimeStamp
201         {
202             get
203             {
204                 return timeStamp;
205             }
206         }
207
208         /// <summary>
209         /// The default constructor.
210         /// </summary>
211         /// <since_tizen> 3 </since_tizen>
212         public Wheel() : this(NDalicPINVOKE.new_Wheel__SWIG_0(), true)
213         {
214             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215         }
216
217         /// <summary>
218         /// The constructor.
219         /// </summary>
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)
228         {
229             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
230         }
231
232         /// <summary>
233         /// Checks to see if the Shift key modifier has been supplied.
234         /// </summary>
235         /// <returns>True if Shift modifier.</returns>
236         /// <since_tizen> 3 </since_tizen>
237         public bool IsShiftModifier()
238         {
239             bool ret = NDalicPINVOKE.Wheel_IsShiftModifier(swigCPtr);
240             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
241             return ret;
242         }
243
244         /// <summary>
245         /// Checks to see if Ctrl (control) key modifier has been supplied.
246         /// </summary>
247         /// <returns>True if Ctrl modifier.</returns>
248         /// <since_tizen> 3 </since_tizen>
249         public bool IsCtrlModifier()
250         {
251             bool ret = NDalicPINVOKE.Wheel_IsCtrlModifier(swigCPtr);
252             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
253             return ret;
254         }
255
256         /// <summary>
257         /// Checks to see if Alt key modifier has been supplied.
258         /// </summary>
259         /// <returns>True if Alt modifier.</returns>
260         /// <since_tizen> 3 </since_tizen>
261         public bool IsAltModifier()
262         {
263             bool ret = NDalicPINVOKE.Wheel_IsAltModifier(swigCPtr);
264             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
265             return ret;
266         }
267
268         private Wheel.WheelType type
269         {
270             set
271             {
272                 NDalicPINVOKE.Wheel_type_set(swigCPtr, (int)value);
273                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
274             }
275             get
276             {
277                 Wheel.WheelType ret = (Wheel.WheelType)NDalicPINVOKE.Wheel_type_get(swigCPtr);
278                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
279                 return ret;
280             }
281         }
282
283         private int direction
284         {
285             set
286             {
287                 NDalicPINVOKE.Wheel_direction_set(swigCPtr, value);
288                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
289             }
290             get
291             {
292                 int ret = NDalicPINVOKE.Wheel_direction_get(swigCPtr);
293                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
294                 return ret;
295             }
296         }
297
298         private uint modifiers
299         {
300             set
301             {
302                 NDalicPINVOKE.Wheel_modifiers_set(swigCPtr, value);
303                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
304             }
305             get
306             {
307                 uint ret = NDalicPINVOKE.Wheel_modifiers_get(swigCPtr);
308                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
309                 return ret;
310             }
311         }
312
313         private Vector2 point
314         {
315             set
316             {
317                 NDalicPINVOKE.Wheel_point_set(swigCPtr, Vector2.getCPtr(value));
318                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
319             }
320             get
321             {
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();
325                 return ret;
326             }
327         }
328
329         private int z
330         {
331             set
332             {
333                 NDalicPINVOKE.Wheel_z_set(swigCPtr, value);
334                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
335             }
336             get
337             {
338                 int ret = NDalicPINVOKE.Wheel_z_get(swigCPtr);
339                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
340                 return ret;
341             }
342         }
343
344         private uint timeStamp
345         {
346             set
347             {
348                 NDalicPINVOKE.Wheel_timeStamp_set(swigCPtr, value);
349                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
350             }
351             get
352             {
353                 uint ret = NDalicPINVOKE.Wheel_timeStamp_get(swigCPtr);
354                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
355                 return ret;
356             }
357         }
358
359         /// <summary>
360         /// The type of the wheel event.
361         /// </summary>
362         /// <since_tizen> 3 </since_tizen>
363         public enum WheelType
364         {
365             /// <summary>
366             /// Mouse wheel event.
367             /// </summary>
368             /// <since_tizen> 3 </since_tizen>
369             MouseWheel,
370
371             /// <summary>
372             /// Custom wheel event.
373             /// </summary>
374             /// <since_tizen> 3 </since_tizen>
375             CustomWheel
376         }
377
378     }
379
380 }