dc1eff73f1f350fe6ea92cfe8d4bc036c5c94605
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / View.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
17 namespace Tizen.NUI
18 {
19
20     using System;
21     using System.Runtime.InteropServices;
22
23     /// <summary>
24     /// View is the base class for all views.
25     /// </summary>
26     public class View : CustomActor
27     {
28         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29
30         internal View(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.View_SWIGUpcast(cPtr), cMemoryOwn)
31         {
32             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
33
34             // Register this instance of view in the view registry.
35             ViewRegistry.RegisterView(this);
36
37             // By default, we do not want the position to use the anchor point
38             //this.PositionUsesAnchorPoint = false;
39             this.PositionUsesAnchorPoint = !(InternalSetting.DefaultParentOriginAsTopLeft);
40         }
41
42         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj)
43         {
44             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
45         }
46
47         ~View()
48         {
49             DisposeQueue.Instance.Add(this);
50
51             // Unregister this instance of view from the view registry.
52             ViewRegistry.UnregisterView(this);
53         }
54
55         public override void Dispose()
56         {
57             if (!Stage.IsInstalled())
58             {
59                 DisposeQueue.Instance.Add(this);
60                 return;
61             }
62
63             lock (this)
64             {
65                 if (swigCPtr.Handle != global::System.IntPtr.Zero)
66                 {
67                     if (swigCMemOwn)
68                     {
69                         swigCMemOwn = false;
70                         NDalicPINVOKE.delete_View(swigCPtr);
71                     }
72                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
73                 }
74                 global::System.GC.SuppressFinalize(this);
75                 base.Dispose();
76             }
77         }
78
79
80
81         private EventHandler _keyInputFocusGainedEventHandler;
82         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
83         private delegate void KeyInputFocusGainedCallbackType(IntPtr control);
84         private KeyInputFocusGainedCallbackType _keyInputFocusGainedCallback;
85
86         /// <summary>
87         /// Event for KeyInputFocusGained signal which can be used to subscribe/unsubscribe the event handler provided by the user.<br>
88         /// KeyInputFocusGained signal is emitted when the control gets Key Input Focus.<br>
89         /// </summary>
90         public event EventHandler FocusGained
91         {
92             add
93             {
94                 if (_keyInputFocusGainedEventHandler == null)
95                 {
96                     _keyInputFocusGainedCallback = OnKeyInputFocusGained;
97                     this.KeyInputFocusGainedSignal().Connect(_keyInputFocusGainedCallback);
98                 }
99
100                 _keyInputFocusGainedEventHandler += value;
101             }
102
103             remove
104             {
105                 _keyInputFocusGainedEventHandler -= value;
106
107                 if (_keyInputFocusGainedEventHandler == null && KeyInputFocusGainedSignal().Empty() == false)
108                 {
109                     this.KeyInputFocusGainedSignal().Disconnect(_keyInputFocusGainedCallback);
110                 }
111             }
112         }
113
114         private void OnKeyInputFocusGained(IntPtr view)
115         {
116             if (_keyInputFocusGainedEventHandler != null)
117             {
118                 _keyInputFocusGainedEventHandler(this, null);
119             }
120         }
121
122
123         private EventHandler _keyInputFocusLostEventHandler;
124         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
125         private delegate void KeyInputFocusLostCallbackType(IntPtr control);
126         private KeyInputFocusLostCallbackType _keyInputFocusLostCallback;
127
128         /// <summary>
129         /// Event for KeyInputFocusLost signal which can be used to subscribe/unsubscribe the event handler provided by the user.<br>
130         /// KeyInputFocusLost signal is emitted when the control loses Key Input Focus.<br>
131         /// </summary>
132         public event EventHandler FocusLost
133         {
134             add
135             {
136                 if (_keyInputFocusLostEventHandler == null)
137                 {
138                     _keyInputFocusLostCallback = OnKeyInputFocusLost;
139                     this.KeyInputFocusLostSignal().Connect(_keyInputFocusLostCallback);
140                 }
141
142                 _keyInputFocusLostEventHandler += value;
143             }
144
145             remove
146             {
147                 _keyInputFocusLostEventHandler -= value;
148
149                 if (_keyInputFocusLostEventHandler == null && KeyInputFocusLostSignal().Empty() == false)
150                 {
151                     this.KeyInputFocusLostSignal().Disconnect(_keyInputFocusLostCallback);
152                 }
153             }
154         }
155
156         private void OnKeyInputFocusLost(IntPtr view)
157         {
158             if (_keyInputFocusLostEventHandler != null)
159             {
160                 _keyInputFocusLostEventHandler(this, null);
161             }
162         }
163
164         /// <summary>
165         /// Event arguments that passed via KeyEvent signal.
166         /// </summary>
167         public class KeyEventArgs : EventArgs
168         {
169             private Key _key;
170
171             /// <summary>
172             /// Key - is the key sent to the View.
173             /// </summary>
174             public Key Key
175             {
176                 get
177                 {
178                     return _key;
179                 }
180                 set
181                 {
182                     _key = value;
183                 }
184             }
185         }
186
187         private EventHandlerWithReturnType<object, KeyEventArgs, bool> _keyEventHandler;
188         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
189         private delegate bool KeyCallbackType(IntPtr control, IntPtr keyEvent);
190         private KeyCallbackType _keyCallback;
191
192         /// <summary>
193         /// Event for KeyPressed signal which can be used to subscribe/unsubscribe the event handler provided by the user.<br>
194         /// KeyPressed signal is emitted when key event is received.<br>
195         /// </summary>
196         public event EventHandlerWithReturnType<object, KeyEventArgs, bool> KeyEvent
197         {
198             add
199             {
200                 if (_keyEventHandler == null)
201                 {
202                     _keyCallback = OnKeyEvent;
203                     this.KeyEventSignal().Connect(_keyCallback);
204                 }
205
206                 _keyEventHandler += value;
207             }
208
209             remove
210             {
211                 _keyEventHandler -= value;
212
213                 if (_keyEventHandler == null && KeyEventSignal().Empty() == false)
214                 {
215                     this.KeyEventSignal().Disconnect(_keyCallback);
216                 }
217             }
218         }
219
220         private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
221         {
222             KeyEventArgs e = new KeyEventArgs();
223
224             e.Key = Tizen.NUI.Key.GetKeyFromPtr(keyEvent);
225
226             if (_keyEventHandler != null)
227             {
228                 return _keyEventHandler(this, e);
229             }
230             return false;
231         }
232
233
234         private EventHandler _onRelayoutEventHandler;
235         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
236         private delegate void OnRelayoutEventCallbackType(IntPtr control);
237         private OnRelayoutEventCallbackType _onRelayoutEventCallback;
238
239         /// <summary>
240         /// Event for OnRelayout signal which can be used to subscribe/unsubscribe the event handler.<br>
241         /// OnRelayout signal is emitted after the size has been set on the view during relayout.<br>
242         /// </summary>
243         public event EventHandler OnRelayoutEvent
244         {
245             add
246             {
247                 if (_onRelayoutEventHandler == null)
248                 {
249                     _onRelayoutEventCallback = OnRelayout;
250                     this.OnRelayoutSignal().Connect(_onRelayoutEventCallback);
251                 }
252
253                 _onRelayoutEventHandler += value;
254             }
255
256             remove
257             {
258                 _onRelayoutEventHandler -= value;
259
260                 if (_onRelayoutEventHandler == null && OnRelayoutSignal().Empty() == false)
261                 {
262                     this.OnRelayoutSignal().Disconnect(_onRelayoutEventCallback);
263                 }
264
265             }
266         }
267
268         // Callback for View OnRelayout signal
269         private void OnRelayout(IntPtr data)
270         {
271             if (_onRelayoutEventHandler != null)
272             {
273                 _onRelayoutEventHandler(this, null);
274             }
275         }
276
277         /// <summary>
278         /// Event arguments that passed via Touch signal.
279         /// </summary>
280         public class TouchEventArgs : EventArgs
281         {
282             private Touch _touch;
283
284             /// <summary>
285             /// Touch - contains the information of touch points
286             /// </summary>
287             public Touch Touch
288             {
289                 get
290                 {
291                     return _touch;
292                 }
293                 set
294                 {
295                     _touch = value;
296                 }
297             }
298         }
299
300         private EventHandlerWithReturnType<object, TouchEventArgs, bool> _touchDataEventHandler;
301         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
302         private delegate bool TouchDataCallbackType(IntPtr view, IntPtr touchData);
303         private TouchDataCallbackType _touchDataCallback;
304
305         /// <summary>
306         /// Event for Touched signal which can be used to subscribe/unsubscribe the event handler provided by the user.<br>
307         /// Touched signal is emitted when touch input is received.<br>
308         /// </summary>
309         public event EventHandlerWithReturnType<object, TouchEventArgs, bool> Touched
310         {
311             add
312             {
313                 if (_touchDataEventHandler == null)
314                 {
315                     _touchDataCallback = OnTouch;
316                     this.TouchSignal().Connect(_touchDataCallback);
317                 }
318
319                 _touchDataEventHandler += value;
320             }
321
322             remove
323             {
324                 _touchDataEventHandler -= value;
325
326                 if (_touchDataEventHandler == null && TouchSignal().Empty() == false)
327                 {
328                     this.TouchSignal().Disconnect(_touchDataCallback);
329                 }
330
331             }
332         }
333
334         // Callback for View TouchSignal
335         private bool OnTouch(IntPtr view, IntPtr touchData)
336         {
337             TouchEventArgs e = new TouchEventArgs();
338
339             e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
340
341             if (_touchDataEventHandler != null)
342             {
343                 return _touchDataEventHandler(this, e);
344             }
345             return false;
346         }
347
348
349         /// <summary>
350         /// Event arguments that passed via Hover signal.
351         /// </summary>
352         public class HoverEventArgs : EventArgs
353         {
354             private Hover _hover;
355
356             /// <summary>
357             /// Hover - contains touch points that represent the points that are currently being hovered or the points where a hover has stopped.
358             /// </summary>
359             public Hover Hover
360             {
361                 get
362                 {
363                     return _hover;
364                 }
365                 set
366                 {
367                     _hover = value;
368                 }
369             }
370         }
371
372         private EventHandlerWithReturnType<object, HoverEventArgs, bool> _hoverEventHandler;
373         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
374         private delegate bool HoverEventCallbackType(IntPtr view, IntPtr hoverEvent);
375         private HoverEventCallbackType _hoverEventCallback;
376
377         /// <summary>
378         /// Event for Hovered signal which can be used to subscribe/unsubscribe the event handler provided by the user.<br>
379         /// Hovered signal is emitted when hover input is received.<br>
380         /// </summary>
381         public event EventHandlerWithReturnType<object, HoverEventArgs, bool> Hovered
382         {
383             add
384             {
385                 if (_hoverEventHandler == null)
386                 {
387                     _hoverEventCallback = OnHoverEvent;
388                     this.HoveredSignal().Connect(_hoverEventCallback);
389                 }
390
391                 _hoverEventHandler += value;
392             }
393
394             remove
395             {
396                 _hoverEventHandler -= value;
397
398                 if (_hoverEventHandler == null && HoveredSignal().Empty() == false)
399                 {
400                     this.HoveredSignal().Disconnect(_hoverEventCallback);
401                 }
402
403             }
404         }
405
406         // Callback for View Hover signal
407         private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
408         {
409             HoverEventArgs e = new HoverEventArgs();
410
411             e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent);
412
413             if (_hoverEventHandler != null)
414             {
415                 return _hoverEventHandler(this, e);
416             }
417             return false;
418         }
419
420
421         /// <summary>
422         /// Event arguments that passed via Wheel signal.
423         /// </summary>
424         public class WheelEventArgs : EventArgs
425         {
426             private Wheel _wheel;
427
428             /// <summary>
429             /// WheelEvent - store a wheel rolling type : MOUSE_WHEEL or CUSTOM_WHEEL
430             /// </summary>
431             public Wheel Wheel
432             {
433                 get
434                 {
435                     return _wheel;
436                 }
437                 set
438                 {
439                     _wheel = value;
440                 }
441             }
442         }
443
444         private EventHandlerWithReturnType<object, WheelEventArgs, bool> _wheelEventHandler;
445         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
446         private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent);
447         private WheelEventCallbackType _wheelEventCallback;
448
449         /// <summary>
450         /// Event for WheelMoved signal which can be used to subscribe/unsubscribe the event handler provided by the user.<br>
451         /// WheelMoved signal is emitted when wheel event is received.<br>
452         /// </summary>
453         public event EventHandlerWithReturnType<object, WheelEventArgs, bool> WheelMoved
454         {
455             add
456             {
457                 if (_wheelEventHandler == null)
458                 {
459                     _wheelEventCallback = OnWheelEvent;
460                     this.WheelEventSignal().Connect(_wheelEventCallback);
461                 }
462
463                 _wheelEventHandler += value;
464             }
465
466             remove
467             {
468                 _wheelEventHandler -= value;
469
470                 if (_wheelEventHandler == null && WheelEventSignal().Empty() == false)
471                 {
472                     this.WheelEventSignal().Disconnect(_wheelEventCallback);
473                 }
474
475             }
476         }
477
478         // Callback for View Wheel signal
479         private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent)
480         {
481             WheelEventArgs e = new WheelEventArgs();
482
483             e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
484
485             if (_wheelEventHandler != null)
486             {
487                 return _wheelEventHandler(this, e);
488             }
489             return false;
490         }
491
492
493         private EventHandler _onStageEventHandler;
494         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
495         private delegate void OnStageEventCallbackType(IntPtr control);
496         private OnStageEventCallbackType _onStageEventCallback;
497
498         /// <summary>
499         /// Event for OnStage signal which can be used to subscribe/unsubscribe the event handler.<br>
500         /// OnStage signal is emitted after the view has been connected to the stage.<br>
501         /// </summary>
502         public event EventHandler OnStageEvent
503         {
504             add
505             {
506                 if (_onStageEventHandler == null)
507                 {
508                     _onStageEventCallback = OnStage;
509                     this.OnStageSignal().Connect(_onStageEventCallback);
510                 }
511
512                 _onStageEventHandler += value;
513             }
514
515             remove
516             {
517                 _onStageEventHandler -= value;
518
519                 if (_onStageEventHandler == null && OnStageSignal().Empty() == false)
520                 {
521                     this.OnStageSignal().Disconnect(_onStageEventCallback);
522                 }
523             }
524         }
525
526         // Callback for View OnStage signal
527         private void OnStage(IntPtr data)
528         {
529             if (_onStageEventHandler != null)
530             {
531                 _onStageEventHandler(this, null);
532             }
533         }
534
535
536         private EventHandler _offStageEventHandler;
537         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
538         private delegate void OffStageEventCallbackType(IntPtr control);
539         private OffStageEventCallbackType _offStageEventCallback;
540
541         /// <summary>
542         /// Event for OffStage signal which can be used to subscribe/unsubscribe the event handler.<br>
543         /// OffStage signal is emitted after the view has been disconnected from the stage.<br>
544         /// </summary>
545         public event EventHandler OffStageEvent
546         {
547             add
548             {
549                 if (_offStageEventHandler == null)
550                 {
551                     _offStageEventCallback = OffStage;
552                     this.OffStageSignal().Connect(_offStageEventCallback);
553                 }
554
555                 _offStageEventHandler += value;
556             }
557
558             remove
559             {
560                 _offStageEventHandler -= value;
561
562                 if (_offStageEventHandler == null && OffStageSignal().Empty() == false)
563                 {
564                     this.OffStageSignal().Disconnect(_offStageEventCallback);
565                 }
566             }
567         }
568
569         // Callback for View OffStage signal
570         private void OffStage(IntPtr data)
571         {
572             if (_offStageEventHandler != null)
573             {
574                 _offStageEventHandler(this, null);
575             }
576         }
577
578
579
580
581
582
583         internal static View GetViewFromPtr(global::System.IntPtr cPtr)
584         {
585             View ret = new View(cPtr, false);
586             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
587             return ret;
588         }
589
590         internal class Property : global::System.IDisposable
591         {
592             private global::System.Runtime.InteropServices.HandleRef swigCPtr;
593             protected bool swigCMemOwn;
594
595             internal Property(global::System.IntPtr cPtr, bool cMemoryOwn)
596             {
597                 swigCMemOwn = cMemoryOwn;
598                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
599             }
600
601             internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Property obj)
602             {
603                 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
604             }
605
606             ~Property()
607             {
608                 Dispose();
609             }
610
611             public virtual void Dispose()
612             {
613                 lock (this)
614                 {
615                     if (swigCPtr.Handle != global::System.IntPtr.Zero)
616                     {
617                         if (swigCMemOwn)
618                         {
619                             swigCMemOwn = false;
620                             NDalicPINVOKE.delete_View_Property(swigCPtr);
621                         }
622                         swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
623                     }
624                     global::System.GC.SuppressFinalize(this);
625                 }
626             }
627
628             internal static readonly int TOOLTIP = NDalicManualPINVOKE.View_Property_TOOLTIP_get();
629             internal static readonly int STATE = NDalicManualPINVOKE.View_Property_STATE_get();
630             internal static readonly int SUB_STATE = NDalicManualPINVOKE.View_Property_SUB_STATE_get();
631             internal static readonly int LEFT_FOCUSABLE_ACTOR_ID = NDalicManualPINVOKE.View_Property_LEFT_FOCUSABLE_ACTOR_ID_get();
632             internal static readonly int RIGHT_FOCUSABLE_ACTOR_ID = NDalicManualPINVOKE.View_Property_RIGHT_FOCUSABLE_ACTOR_ID_get();
633             internal static readonly int UP_FOCUSABLE_ACTOR_ID = NDalicManualPINVOKE.View_Property_UP_FOCUSABLE_ACTOR_ID_get();
634             internal static readonly int DOWN_FOCUSABLE_ACTOR_ID = NDalicManualPINVOKE.View_Property_DOWN_FOCUSABLE_ACTOR_ID_get();
635
636             internal Property() : this(NDalicPINVOKE.new_View_Property(), true)
637             {
638                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
639             }
640
641             internal static readonly int STYLE_NAME = NDalicPINVOKE.View_Property_STYLE_NAME_get();
642             internal static readonly int BACKGROUND_COLOR = NDalicPINVOKE.View_Property_BACKGROUND_COLOR_get();
643             internal static readonly int BACKGROUND_IMAGE = NDalicPINVOKE.View_Property_BACKGROUND_IMAGE_get();
644             internal static readonly int KEY_INPUT_FOCUS = NDalicPINVOKE.View_Property_KEY_INPUT_FOCUS_get();
645             internal static readonly int BACKGROUND = NDalicPINVOKE.View_Property_BACKGROUND_get();
646
647         }
648
649
650         /// <summary>
651         /// Describes the direction to move the focus towards.
652         /// </summary>
653         public enum FocusDirection
654         {
655             Left,
656             Right,
657             Up,
658             Down,
659             PageUp,
660             PageDown
661         }
662
663         /// <summary>
664         /// Creates a new instance of a View.
665         /// </summary>
666         public View() : this(NDalicPINVOKE.View_New(), true)
667         {
668             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
669
670         }
671         internal View(View uiControl) : this(NDalicPINVOKE.new_View__SWIG_1(View.getCPtr(uiControl)), true)
672         {
673             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
674         }
675
676         internal View Assign(View handle)
677         {
678             View ret = new View(NDalicPINVOKE.View_Assign(swigCPtr, View.getCPtr(handle)), false);
679             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
680             return ret;
681         }
682
683         /// <summary>
684         /// Downcasts a handle to View handle.<br>
685         /// If handle points to a View, the downcast produces valid handle.<br>
686         /// If not, the returned handle is left uninitialized.<br>
687         /// </summary>
688         /// <param name="handle">Handle to an object</param>
689         /// <returns>A handle to a View or an uninitialized handle</returns>
690         public new static View DownCast(BaseHandle handle)
691         {
692             View ret = new View(NDalicPINVOKE.View_DownCast(BaseHandle.getCPtr(handle)), true);
693             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
694             return ret;
695         }
696
697         /// <summary>
698         /// Downcasts a handle to class which inherit View handle.
699         /// </summary>
700         /// <typeparam name="T">Class which inherit View</typeparam>
701         /// <param name="actor">Actor to an object</param>
702         /// <returns>A object which inherit View</returns>
703         public static T DownCast<T>(Actor actor) where T : View
704         {
705             return (T)(ViewRegistry.GetViewFromActor(actor));
706         }
707
708         private View ConvertIdToView(uint id)
709         {
710             Actor actor = null;
711
712             if (Parent)
713             {
714                 actor = Parent.FindChildById(id);
715             }
716
717             if (!actor)
718             {
719                 actor = Stage.Instance.GetRootLayer().FindChildById(id);
720             }
721
722             return View.DownCast<View>(actor);
723         }
724
725         internal void SetKeyInputFocus()
726         {
727             NDalicPINVOKE.View_SetKeyInputFocus(swigCPtr);
728             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
729         }
730
731         /// <summary>
732         /// Quries whether the view has focus.
733         /// </summary>
734         /// <returns>true if this view has focus</returns>
735         public bool HasFocus()
736         {
737             bool ret = NDalicPINVOKE.View_HasKeyInputFocus(swigCPtr);
738             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
739             return ret;
740         }
741
742         internal void ClearKeyInputFocus()
743         {
744             NDalicPINVOKE.View_ClearKeyInputFocus(swigCPtr);
745             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
746         }
747
748         internal PinchGestureDetector GetPinchGestureDetector()
749         {
750             PinchGestureDetector ret = new PinchGestureDetector(NDalicPINVOKE.View_GetPinchGestureDetector(swigCPtr), true);
751             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
752             return ret;
753         }
754
755         internal PanGestureDetector GetPanGestureDetector()
756         {
757             PanGestureDetector ret = new PanGestureDetector(NDalicPINVOKE.View_GetPanGestureDetector(swigCPtr), true);
758             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
759             return ret;
760         }
761
762         internal TapGestureDetector GetTapGestureDetector()
763         {
764             TapGestureDetector ret = new TapGestureDetector(NDalicPINVOKE.View_GetTapGestureDetector(swigCPtr), true);
765             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
766             return ret;
767         }
768
769         internal LongPressGestureDetector GetLongPressGestureDetector()
770         {
771             LongPressGestureDetector ret = new LongPressGestureDetector(NDalicPINVOKE.View_GetLongPressGestureDetector(swigCPtr), true);
772             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
773             return ret;
774         }
775
776         /// <summary>
777         /// Sets the name of the style to be applied to the view.
778         /// </summary>
779         /// <param name="styleName">A string matching a style described in a stylesheet</param>
780         public void SetStyleName(string styleName)
781         {
782             NDalicPINVOKE.View_SetStyleName(swigCPtr, styleName);
783             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
784         }
785
786         /// <summary>
787         /// Retrieves the name of the style to be applied to the view (if any).
788         /// </summary>
789         /// <returns>A string matching a style, or an empty string</returns>
790         public string GetStyleName()
791         {
792             string ret = NDalicPINVOKE.View_GetStyleName(swigCPtr);
793             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
794             return ret;
795         }
796
797         internal void SetBackgroundColor(Vector4 color)
798         {
799             NDalicPINVOKE.View_SetBackgroundColor(swigCPtr, Vector4.getCPtr(color));
800             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
801         }
802
803         internal Vector4 GetBackgroundColor()
804         {
805             Vector4 ret = new Vector4(NDalicPINVOKE.View_GetBackgroundColor(swigCPtr), true);
806             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
807             return ret;
808         }
809
810         internal void SetBackgroundImage(Image image)
811         {
812             NDalicPINVOKE.View_SetBackgroundImage(swigCPtr, Image.getCPtr(image));
813             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
814         }
815
816         /// <summary>
817         /// Clears the background.
818         /// </summary>
819         public void ClearBackground()
820         {
821             NDalicPINVOKE.View_ClearBackground(swigCPtr);
822             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
823         }
824
825         internal ControlKeySignal KeyEventSignal()
826         {
827             ControlKeySignal ret = new ControlKeySignal(NDalicPINVOKE.View_KeyEventSignal(swigCPtr), false);
828             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
829             return ret;
830         }
831
832         internal KeyInputFocusSignal KeyInputFocusGainedSignal()
833         {
834             KeyInputFocusSignal ret = new KeyInputFocusSignal(NDalicPINVOKE.View_KeyInputFocusGainedSignal(swigCPtr), false);
835             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
836             return ret;
837         }
838
839         internal KeyInputFocusSignal KeyInputFocusLostSignal()
840         {
841             KeyInputFocusSignal ret = new KeyInputFocusSignal(NDalicPINVOKE.View_KeyInputFocusLostSignal(swigCPtr), false);
842             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
843             return ret;
844         }
845
846         internal View(ViewImpl implementation) : this(NDalicPINVOKE.new_View__SWIG_2(ViewImpl.getCPtr(implementation)), true)
847         {
848             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
849         }
850
851         internal enum PropertyRange
852         {
853             PROPERTY_START_INDEX = PropertyRanges.PROPERTY_REGISTRATION_START_INDEX,
854             CONTROL_PROPERTY_START_INDEX = PROPERTY_START_INDEX,
855             CONTROL_PROPERTY_END_INDEX = CONTROL_PROPERTY_START_INDEX + 1000
856         }
857
858         /// <summary>
859         /// styleName, type string.
860         /// </summary>
861         public string StyleName
862         {
863             get
864             {
865                 string temp;
866                 GetProperty(View.Property.STYLE_NAME).Get(out temp);
867                 return temp;
868             }
869             set
870             {
871                 SetProperty(View.Property.STYLE_NAME, new Tizen.NUI.PropertyValue(value));
872             }
873         }
874
875         /// <summary>
876         /// mutually exclusive with BACKGROUND_IMAGE & BACKGROUND,  type Vector4.
877         /// </summary>
878         public Color BackgroundColor
879         {
880             get
881             {
882                 Color backgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.0f);
883
884                 Tizen.NUI.PropertyMap background = Background;
885                 int visualType = 0;
886                 background.Find(Visual.Property.Type).Get(ref visualType);
887                 if (visualType == (int)Visual.Type.Color)
888                 {
889                     background.Find(ColorVisualProperty.MixColor).Get(backgroundColor);
890                 }
891
892                 return backgroundColor;
893             }
894             set
895             {
896                 SetProperty(View.Property.BACKGROUND, new Tizen.NUI.PropertyValue(value));
897             }
898         }
899
900         /// <summary>
901         /// mutually exclusive with BACKGROUND_COLOR & BACKGROUND,  type Map.
902         /// </summary>
903         public string BackgroundImage
904         {
905             get
906             {
907                 string backgroundImage = "";
908
909                 Tizen.NUI.PropertyMap background = Background;
910                 int visualType = 0;
911                 background.Find(Visual.Property.Type).Get(ref visualType);
912                 if (visualType == (int)Visual.Type.Image)
913                 {
914                     background.Find(ImageVisualProperty.URL).Get(out backgroundImage);
915                 }
916
917                 return backgroundImage;
918             }
919             set
920             {
921                 SetProperty(View.Property.BACKGROUND, new Tizen.NUI.PropertyValue(value));
922             }
923         }
924
925         internal bool KeyInputFocus
926         {
927             get
928             {
929                 bool temp = false;
930                 GetProperty(View.Property.KEY_INPUT_FOCUS).Get(ref temp);
931                 return temp;
932             }
933             set
934             {
935                 SetProperty(View.Property.KEY_INPUT_FOCUS, new Tizen.NUI.PropertyValue(value));
936             }
937         }
938
939         /// <summary>
940         /// mutually exclusive with BACKGROUND_COLOR & BACKGROUND_IMAGE, type Map or string for URL.
941         /// </summary>
942         public Tizen.NUI.PropertyMap Background
943         {
944             get
945             {
946                 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
947                 GetProperty(View.Property.BACKGROUND).Get(temp);
948                 return temp;
949             }
950             set
951             {
952                 SetProperty(View.Property.BACKGROUND, new Tizen.NUI.PropertyValue(value));
953             }
954         }
955
956         /// <summary>
957         /// The current state of the view.
958         /// </summary>
959         public States State
960         {
961             get
962             {
963                 int temp = 0;
964                 if (GetProperty(View.Property.STATE).Get(ref temp) == false)
965                 {
966                     //Tizen.Log.Error("NUI", "State get error!");
967                 }
968                 switch (temp)
969                 {
970                     case 0:
971                     {
972                         return States.Normal;
973                     }
974                     case 1:
975                     {
976                         return States.Focused;
977                     }
978                     case 2:
979                     {
980                         return States.Disabled;
981                     }
982                     default:
983                     {
984                         return States.Normal;
985                     }
986                 }
987             }
988             set
989             {
990                 SetProperty(View.Property.STATE, new Tizen.NUI.PropertyValue((int)value));
991             }
992         }
993
994         /// <summary>
995         /// The current sub state of the view.
996         /// </summary>
997         public States SubState
998         {
999             get
1000             {
1001                 string temp;
1002                 if (GetProperty(View.Property.SUB_STATE).Get(out temp) == false)
1003                 {
1004                     //Tizen.Log.Error("NUI", "subState get error!");
1005                 }
1006                 switch (temp)
1007                 {
1008                     case "NORMAL":
1009                         return States.Normal;
1010                     case "FOCUSED":
1011                         return States.Focused;
1012                     case "DISABLED":
1013                         return States.Disabled;
1014                     default:
1015                         return States.Normal;
1016                 }
1017             }
1018             set
1019             {
1020                 string valueToString = "";
1021                 switch (value)
1022                 {
1023                     case States.Normal:
1024                     {
1025                         valueToString = "NORMAL";
1026                         break;
1027                     }
1028                     case States.Focused:
1029                     {
1030                         valueToString = "FOCUSED";
1031                         break;
1032                     }
1033                     case States.Disabled:
1034                     {
1035                         valueToString = "DISABLED";
1036                         break;
1037                     }
1038                     default:
1039                     {
1040                         valueToString = "NORMAL";
1041                         break;
1042                     }
1043                 }
1044                 SetProperty(View.Property.SUB_STATE, new Tizen.NUI.PropertyValue(valueToString));
1045             }
1046         }
1047
1048         /// <summary>
1049         /// Displays a tooltip
1050         /// </summary>
1051         public Tizen.NUI.PropertyMap Tooltip
1052         {
1053             get
1054             {
1055                 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
1056                 GetProperty(View.Property.TOOLTIP).Get(temp);
1057                 return temp;
1058             }
1059             set
1060             {
1061                 SetProperty(View.Property.TOOLTIP, new Tizen.NUI.PropertyValue(value));
1062             }
1063         }
1064
1065         /// <summary>
1066         /// Displays a tooltip as Text
1067         /// </summary>
1068         public string TooltipText
1069         {
1070             set
1071             {
1072                 SetProperty(View.Property.TOOLTIP, new Tizen.NUI.PropertyValue(value));
1073             }
1074         }
1075
1076         private int LeftFocusableActorId
1077         {
1078             get
1079             {
1080                 int temp = 0;
1081                 GetProperty(View.Property.LEFT_FOCUSABLE_ACTOR_ID).Get(ref temp);
1082                 return temp;
1083             }
1084             set
1085             {
1086                 SetProperty(View.Property.LEFT_FOCUSABLE_ACTOR_ID, new Tizen.NUI.PropertyValue(value));
1087             }
1088         }
1089
1090         private int RightFocusableActorId
1091         {
1092             get
1093             {
1094                 int temp = 0;
1095                 GetProperty(View.Property.RIGHT_FOCUSABLE_ACTOR_ID).Get(ref temp);
1096                 return temp;
1097             }
1098             set
1099             {
1100                 SetProperty(View.Property.RIGHT_FOCUSABLE_ACTOR_ID, new Tizen.NUI.PropertyValue(value));
1101             }
1102         }
1103
1104         private int UpFocusableActorId
1105         {
1106             get
1107             {
1108                 int temp = 0;
1109                 GetProperty(View.Property.UP_FOCUSABLE_ACTOR_ID).Get(ref temp);
1110                 return temp;
1111             }
1112             set
1113             {
1114                 SetProperty(View.Property.UP_FOCUSABLE_ACTOR_ID, new Tizen.NUI.PropertyValue(value));
1115             }
1116         }
1117
1118         private int DownFocusableActorId
1119         {
1120             get
1121             {
1122                 int temp = 0;
1123                 GetProperty(View.Property.DOWN_FOCUSABLE_ACTOR_ID).Get(ref temp);
1124                 return temp;
1125             }
1126             set
1127             {
1128                 SetProperty(View.Property.DOWN_FOCUSABLE_ACTOR_ID, new Tizen.NUI.PropertyValue(value));
1129             }
1130         }
1131
1132         /// <summary>
1133         /// Child Property of FlexContainer.<br>
1134         /// The proportion of the free space in the container the flex item will receive.<br>
1135         /// If all items in the container set this property, their sizes will be proportional to the specified flex factor.<br>
1136         /// </summary> 
1137         public float Flex
1138         {
1139             get
1140             {
1141                 float temp = 0.0f;
1142                 GetProperty(FlexContainer.ChildProperty.FLEX).Get(ref temp);
1143                 return temp;
1144             }
1145             set
1146             {
1147                 SetProperty(FlexContainer.ChildProperty.FLEX, new Tizen.NUI.PropertyValue(value));
1148             }
1149         }
1150
1151         /// <summary>
1152         /// Child Property of FlexContainer.<br>
1153         /// The alignment of the flex item along the cross axis, which, if set, overides the default alignment for all items in the container.<br>
1154         /// </summary> 
1155         public int AlignSelf
1156         {
1157             get
1158             {
1159                 int temp = 0;
1160                 GetProperty(FlexContainer.ChildProperty.ALIGN_SELF).Get(ref temp);
1161                 return temp;
1162             }
1163             set
1164             {
1165                 SetProperty(FlexContainer.ChildProperty.ALIGN_SELF, new Tizen.NUI.PropertyValue(value));
1166             }
1167         }
1168
1169         /// <summary>
1170         /// Child Property of FlexContainer.<br>
1171         /// The space around the flex item.<br>
1172         /// </summary> 
1173         public Vector4 FlexMargin
1174         {
1175             get
1176             {
1177                 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
1178                 GetProperty(FlexContainer.ChildProperty.FLEX_MARGIN).Get(temp);
1179                 return temp;
1180             }
1181             set
1182             {
1183                 SetProperty(FlexContainer.ChildProperty.FLEX_MARGIN, new Tizen.NUI.PropertyValue(value));
1184             }
1185         }
1186
1187         /// <summary>
1188         /// The top-left cell this child occupies, if not set, the first available cell is used
1189         /// </summary>
1190         public Vector2 CellIndex
1191         {
1192             get
1193             {
1194                 Vector2 temp = new Vector2(0.0f, 0.0f);
1195                 GetProperty(TableView.ChildProperty.CELL_INDEX).Get(temp);
1196                 return temp;
1197             }
1198             set
1199             {
1200                 SetProperty(TableView.ChildProperty.CELL_INDEX, new Tizen.NUI.PropertyValue(value));
1201             }
1202         }
1203
1204         /// <summary>
1205         /// The number of rows this child occupies, if not set, default value is 1
1206         /// </summary>
1207         public float RowSpan
1208         {
1209             get
1210             {
1211                 float temp = 0.0f;
1212                 GetProperty(TableView.ChildProperty.ROW_SPAN).Get(ref temp);
1213                 return temp;
1214             }
1215             set
1216             {
1217                 SetProperty(TableView.ChildProperty.ROW_SPAN, new Tizen.NUI.PropertyValue(value));
1218             }
1219         }
1220
1221         /// <summary>
1222         /// The number of columns this child occupies, if not set, default value is 1
1223         /// </summary>
1224         public float ColumnSpan
1225         {
1226             get
1227             {
1228                 float temp = 0.0f;
1229                 GetProperty(TableView.ChildProperty.COLUMN_SPAN).Get(ref temp);
1230                 return temp;
1231             }
1232             set
1233             {
1234                 SetProperty(TableView.ChildProperty.COLUMN_SPAN, new Tizen.NUI.PropertyValue(value));
1235             }
1236         }
1237
1238         /// <summary>
1239         /// The horizontal alignment of this child inside the cells, if not set, default value is 'left'
1240         /// </summary>
1241         public Tizen.NUI.HorizontalAlignmentType CellHorizontalAlignment
1242         {
1243             get
1244             {
1245                 string temp;
1246                 if (GetProperty(TableView.ChildProperty.CELL_HORIZONTAL_ALIGNMENT).Get(out temp) == false)
1247                 {
1248                     //Tizen.Log.Error("NUI", "CellHorizontalAlignment get error!");
1249                 }
1250
1251                 switch (temp)
1252                 {
1253                     case "left":
1254                         return Tizen.NUI.HorizontalAlignmentType.Left;
1255                     case "center":
1256                         return Tizen.NUI.HorizontalAlignmentType.Center;
1257                     case "right":
1258                         return Tizen.NUI.HorizontalAlignmentType.Right;
1259                     default:
1260                         return Tizen.NUI.HorizontalAlignmentType.Left;
1261                 }
1262             }
1263             set
1264             {
1265                 string valueToString = "";
1266                 switch (value)
1267                 {
1268                     case Tizen.NUI.HorizontalAlignmentType.Left:
1269                     {
1270                         valueToString = "left";
1271                         break;
1272                     }
1273                     case Tizen.NUI.HorizontalAlignmentType.Center:
1274                     {
1275                         valueToString = "center";
1276                         break;
1277                     }
1278                     case Tizen.NUI.HorizontalAlignmentType.Right:
1279                     {
1280                         valueToString = "right";
1281                         break;
1282                     }
1283                     default:
1284                     {
1285                         valueToString = "left";
1286                         break;
1287                     }
1288                 }
1289                 SetProperty(TableView.ChildProperty.CELL_HORIZONTAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
1290             }
1291         }
1292
1293         /// <summary>
1294         /// The vertical alignment of this child inside the cells, if not set, default value is 'top'
1295         /// </summary>
1296         public Tizen.NUI.VerticalAlignmentType CellVerticalAlignment
1297         {
1298             get
1299             {
1300                 string temp;
1301                 GetProperty(TableView.ChildProperty.CELL_VERTICAL_ALIGNMENT).Get(out temp);
1302                 {
1303                     //Tizen.Log.Error("NUI", "CellVerticalAlignment get error!");
1304                 }
1305
1306                 switch (temp)
1307                 {
1308                     case "top":
1309                         return Tizen.NUI.VerticalAlignmentType.Top;
1310                     case "center":
1311                         return Tizen.NUI.VerticalAlignmentType.Center;
1312                     case "bottom":
1313                         return Tizen.NUI.VerticalAlignmentType.Bottom;
1314                     default:
1315                         return Tizen.NUI.VerticalAlignmentType.Top;
1316                 }
1317             }
1318             set
1319             {
1320                 string valueToString = "";
1321                 switch (value)
1322                 {
1323                     case Tizen.NUI.VerticalAlignmentType.Top:
1324                     {
1325                         valueToString = "top";
1326                         break;
1327                     }
1328                     case Tizen.NUI.VerticalAlignmentType.Center:
1329                     {
1330                         valueToString = "center";
1331                         break;
1332                     }
1333                     case Tizen.NUI.VerticalAlignmentType.Bottom:
1334                     {
1335                         valueToString = "bottom";
1336                         break;
1337                     }
1338                     default:
1339                     {
1340                         valueToString = "top";
1341                         break;
1342                     }
1343                 }
1344                 SetProperty(TableView.ChildProperty.CELL_VERTICAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
1345             }
1346         }
1347
1348         /// <summary>
1349         /// The left focusable view.<br>
1350         /// This will return NULL if not set.<br>
1351         /// This will also return NULL if the specified left focusable view is not on stage.<br>
1352         /// </summary>
1353         public View LeftFocusableView
1354         {
1355             // As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
1356             get
1357             {
1358                 if (LeftFocusableActorId >= 0)
1359                 {
1360                     return ConvertIdToView((uint)LeftFocusableActorId);
1361                 }
1362                 return null;
1363             }
1364             set
1365             {
1366                 LeftFocusableActorId = (int)value.GetId();
1367             }
1368         }
1369
1370         /// <summary>
1371         /// The right focusable view.<br>
1372         /// This will return NULL if not set.<br>
1373         /// This will also return NULL if the specified right focusable view is not on stage.<br>
1374         /// </summary>
1375         public View RightFocusableView
1376         {
1377             // As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
1378             get
1379             {
1380                 if (RightFocusableActorId >= 0)
1381                 {
1382                     return ConvertIdToView((uint)RightFocusableActorId);
1383                 }
1384                 return null;
1385             }
1386             set
1387             {
1388                 RightFocusableActorId = (int)value.GetId();
1389             }
1390         }
1391
1392         /// <summary>
1393         /// The up focusable view.<br>
1394         /// This will return NULL if not set.<br>
1395         /// This will also return NULL if the specified up focusable view is not on stage.<br>
1396         /// </summary>
1397         public View UpFocusableView
1398         {
1399             // As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
1400             get
1401             {
1402                 if (UpFocusableActorId >= 0)
1403                 {
1404                     return ConvertIdToView((uint)UpFocusableActorId);
1405                 }
1406                 return null;
1407             }
1408             set
1409             {
1410                 UpFocusableActorId = (int)value.GetId();
1411             }
1412         }
1413
1414         /// <summary>
1415         /// The down focusable view.<br>
1416         /// This will return NULL if not set.<br>
1417         /// This will also return NULL if the specified down focusable view is not on stage.<br>
1418         /// </summary>
1419         public View DownFocusableView
1420         {
1421             // As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
1422             get
1423             {
1424                 if (DownFocusableActorId >= 0)
1425                 {
1426                     return ConvertIdToView((uint)DownFocusableActorId);
1427                 }
1428                 return null;
1429             }
1430             set
1431             {
1432                 DownFocusableActorId = (int)value.GetId();
1433             }
1434         }
1435
1436         /// <summary>
1437         /// whether the view should be focusable by keyboard navigation.
1438         /// </summary>
1439         public bool Focusable
1440         {
1441             set
1442             {
1443                 SetKeyboardFocusable(value);
1444             }
1445             get
1446             {
1447                 return IsKeyboardFocusable();
1448             }
1449         }
1450
1451         /// <summary>
1452         /// Enumeration for describing the states of view.
1453         /// </summary>
1454         public enum States
1455         {
1456             /// <summary>
1457             /// Normal state
1458             /// </summary>
1459             Normal,
1460             /// <summary>
1461             /// Focused state
1462             /// </summary>
1463             Focused,
1464             /// <summary>
1465             /// Disabled state
1466             /// </summary>
1467             Disabled
1468         }
1469     }
1470
1471 }