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