2b64c8f41629ed9f2b2188b7fef824020dd2a691
[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 string State
960         {
961             get
962             {
963                 int temp = 0;
964                 GetProperty(View.Property.STATE).Get(ref temp);
965                 switch (temp)
966                 {
967                     case 0:
968                     {
969                         return "NORMAL";
970                     }
971                     case 1:
972                     {
973                         return "FOCUSED";
974                     }
975                     case 2:
976                     {
977                         return "DISABLED";
978                     }
979                     default:
980                     {
981                         return "";
982                     }
983                 }
984             }
985             set
986             {
987                 SetProperty(View.Property.STATE, new Tizen.NUI.PropertyValue(value));
988             }
989         }
990
991         /// <summary>
992         /// The current sub state of the view.
993         /// </summary>
994         public string SubState
995         {
996             get
997             {
998                 string temp;
999                 GetProperty(View.Property.SUB_STATE).Get(out temp);
1000                 return temp;
1001             }
1002             set
1003             {
1004                 SetProperty(View.Property.SUB_STATE, new Tizen.NUI.PropertyValue(value));
1005             }
1006         }
1007
1008         /// <summary>
1009         /// Displays a tooltip
1010         /// </summary>
1011         public Tizen.NUI.PropertyMap Tooltip
1012         {
1013             get
1014             {
1015                 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
1016                 GetProperty(View.Property.TOOLTIP).Get(temp);
1017                 return temp;
1018             }
1019             set
1020             {
1021                 SetProperty(View.Property.TOOLTIP, new Tizen.NUI.PropertyValue(value));
1022             }
1023         }
1024
1025         /// <summary>
1026         /// Displays a tooltip as Text
1027         /// </summary>
1028         public string TooltipText
1029         {
1030             set
1031             {
1032                 SetProperty(View.Property.TOOLTIP, new Tizen.NUI.PropertyValue(value));
1033             }
1034         }
1035
1036         private int LeftFocusableActorId
1037         {
1038             get
1039             {
1040                 int temp = 0;
1041                 GetProperty(View.Property.LEFT_FOCUSABLE_ACTOR_ID).Get(ref temp);
1042                 return temp;
1043             }
1044             set
1045             {
1046                 SetProperty(View.Property.LEFT_FOCUSABLE_ACTOR_ID, new Tizen.NUI.PropertyValue(value));
1047             }
1048         }
1049
1050         private int RightFocusableActorId
1051         {
1052             get
1053             {
1054                 int temp = 0;
1055                 GetProperty(View.Property.RIGHT_FOCUSABLE_ACTOR_ID).Get(ref temp);
1056                 return temp;
1057             }
1058             set
1059             {
1060                 SetProperty(View.Property.RIGHT_FOCUSABLE_ACTOR_ID, new Tizen.NUI.PropertyValue(value));
1061             }
1062         }
1063
1064         private int UpFocusableActorId
1065         {
1066             get
1067             {
1068                 int temp = 0;
1069                 GetProperty(View.Property.UP_FOCUSABLE_ACTOR_ID).Get(ref temp);
1070                 return temp;
1071             }
1072             set
1073             {
1074                 SetProperty(View.Property.UP_FOCUSABLE_ACTOR_ID, new Tizen.NUI.PropertyValue(value));
1075             }
1076         }
1077
1078         private int DownFocusableActorId
1079         {
1080             get
1081             {
1082                 int temp = 0;
1083                 GetProperty(View.Property.DOWN_FOCUSABLE_ACTOR_ID).Get(ref temp);
1084                 return temp;
1085             }
1086             set
1087             {
1088                 SetProperty(View.Property.DOWN_FOCUSABLE_ACTOR_ID, new Tizen.NUI.PropertyValue(value));
1089             }
1090         }
1091
1092         /// <summary>
1093         /// Child Property of FlexContainer.<br>
1094         /// The proportion of the free space in the container the flex item will receive.<br>
1095         /// If all items in the container set this property, their sizes will be proportional to the specified flex factor.<br>
1096         /// </summary> 
1097         public float Flex
1098         {
1099             get
1100             {
1101                 float temp = 0.0f;
1102                 GetProperty(FlexContainer.ChildProperty.FLEX).Get(ref temp);
1103                 return temp;
1104             }
1105             set
1106             {
1107                 SetProperty(FlexContainer.ChildProperty.FLEX, new Tizen.NUI.PropertyValue(value));
1108             }
1109         }
1110
1111         /// <summary>
1112         /// Child Property of FlexContainer.<br>
1113         /// The alignment of the flex item along the cross axis, which, if set, overides the default alignment for all items in the container.<br>
1114         /// </summary> 
1115         public int AlignSelf
1116         {
1117             get
1118             {
1119                 int temp = 0;
1120                 GetProperty(FlexContainer.ChildProperty.ALIGN_SELF).Get(ref temp);
1121                 return temp;
1122             }
1123             set
1124             {
1125                 SetProperty(FlexContainer.ChildProperty.ALIGN_SELF, new Tizen.NUI.PropertyValue(value));
1126             }
1127         }
1128
1129         /// <summary>
1130         /// Child Property of FlexContainer.<br>
1131         /// The space around the flex item.<br>
1132         /// </summary> 
1133         public Vector4 FlexMargin
1134         {
1135             get
1136             {
1137                 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
1138                 GetProperty(FlexContainer.ChildProperty.FLEX_MARGIN).Get(temp);
1139                 return temp;
1140             }
1141             set
1142             {
1143                 SetProperty(FlexContainer.ChildProperty.FLEX_MARGIN, new Tizen.NUI.PropertyValue(value));
1144             }
1145         }
1146
1147         /// <summary>
1148         /// The top-left cell this child occupies, if not set, the first available cell is used
1149         /// </summary>
1150         public Vector2 CellIndex
1151         {
1152             get
1153             {
1154                 Vector2 temp = new Vector2(0.0f, 0.0f);
1155                 GetProperty(TableView.ChildProperty.CELL_INDEX).Get(temp);
1156                 return temp;
1157             }
1158             set
1159             {
1160                 SetProperty(TableView.ChildProperty.CELL_INDEX, new Tizen.NUI.PropertyValue(value));
1161             }
1162         }
1163
1164         /// <summary>
1165         /// The number of rows this child occupies, if not set, default value is 1
1166         /// </summary>
1167         public float RowSpan
1168         {
1169             get
1170             {
1171                 float temp = 0.0f;
1172                 GetProperty(TableView.ChildProperty.ROW_SPAN).Get(ref temp);
1173                 return temp;
1174             }
1175             set
1176             {
1177                 SetProperty(TableView.ChildProperty.ROW_SPAN, new Tizen.NUI.PropertyValue(value));
1178             }
1179         }
1180
1181         /// <summary>
1182         /// The number of columns this child occupies, if not set, default value is 1
1183         /// </summary>
1184         public float ColumnSpan
1185         {
1186             get
1187             {
1188                 float temp = 0.0f;
1189                 GetProperty(TableView.ChildProperty.COLUMN_SPAN).Get(ref temp);
1190                 return temp;
1191             }
1192             set
1193             {
1194                 SetProperty(TableView.ChildProperty.COLUMN_SPAN, new Tizen.NUI.PropertyValue(value));
1195             }
1196         }
1197
1198         /// <summary>
1199         /// The horizontal alignment of this child inside the cells, if not set, default value is 'left'
1200         /// </summary>
1201         public string CellHorizontalAlignment
1202         {
1203             get
1204             {
1205                 string temp;
1206                 GetProperty(TableView.ChildProperty.CELL_HORIZONTAL_ALIGNMENT).Get(out temp);
1207                 return temp;
1208             }
1209             set
1210             {
1211                 SetProperty(TableView.ChildProperty.CELL_HORIZONTAL_ALIGNMENT, new Tizen.NUI.PropertyValue(value));
1212             }
1213         }
1214
1215         /// <summary>
1216         /// The vertical alignment of this child inside the cells, if not set, default value is 'top'
1217         /// </summary>
1218         public string CellVerticalAlignment
1219         {
1220             get
1221             {
1222                 string temp;
1223                 GetProperty(TableView.ChildProperty.CELL_VERTICAL_ALIGNMENT).Get(out temp);
1224                 return temp;
1225             }
1226             set
1227             {
1228                 SetProperty(TableView.ChildProperty.CELL_VERTICAL_ALIGNMENT, new Tizen.NUI.PropertyValue(value));
1229             }
1230         }
1231
1232         /// <summary>
1233         /// The left focusable view.<br>
1234         /// This will return NULL if not set.<br>
1235         /// This will also return NULL if the specified left focusable view is not on stage.<br>
1236         /// </summary>
1237         public View LeftFocusableView
1238         {
1239             // As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
1240             get
1241             {
1242                 if (LeftFocusableActorId >= 0)
1243                 {
1244                     return ConvertIdToView((uint)LeftFocusableActorId);
1245                 }
1246                 return null;
1247             }
1248             set
1249             {
1250                 LeftFocusableActorId = (int)value.GetId();
1251             }
1252         }
1253
1254         /// <summary>
1255         /// The right focusable view.<br>
1256         /// This will return NULL if not set.<br>
1257         /// This will also return NULL if the specified right focusable view is not on stage.<br>
1258         /// </summary>
1259         public View RightFocusableView
1260         {
1261             // As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
1262             get
1263             {
1264                 if (RightFocusableActorId >= 0)
1265                 {
1266                     return ConvertIdToView((uint)RightFocusableActorId);
1267                 }
1268                 return null;
1269             }
1270             set
1271             {
1272                 RightFocusableActorId = (int)value.GetId();
1273             }
1274         }
1275
1276         /// <summary>
1277         /// The up focusable view.<br>
1278         /// This will return NULL if not set.<br>
1279         /// This will also return NULL if the specified up focusable view is not on stage.<br>
1280         /// </summary>
1281         public View UpFocusableView
1282         {
1283             // As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
1284             get
1285             {
1286                 if (UpFocusableActorId >= 0)
1287                 {
1288                     return ConvertIdToView((uint)UpFocusableActorId);
1289                 }
1290                 return null;
1291             }
1292             set
1293             {
1294                 UpFocusableActorId = (int)value.GetId();
1295             }
1296         }
1297
1298         /// <summary>
1299         /// The down focusable view.<br>
1300         /// This will return NULL if not set.<br>
1301         /// This will also return NULL if the specified down focusable view is not on stage.<br>
1302         /// </summary>
1303         public View DownFocusableView
1304         {
1305             // As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
1306             get
1307             {
1308                 if (DownFocusableActorId >= 0)
1309                 {
1310                     return ConvertIdToView((uint)DownFocusableActorId);
1311                 }
1312                 return null;
1313             }
1314             set
1315             {
1316                 DownFocusableActorId = (int)value.GetId();
1317             }
1318         }
1319
1320         /// <summary>
1321         /// whether the view should be focusable by keyboard navigation.
1322         /// </summary>
1323         public bool Focusable
1324         {
1325             set
1326             {
1327                 SetKeyboardFocusable(value);
1328             }
1329             get
1330             {
1331                 return IsKeyboardFocusable();
1332             }
1333         }
1334
1335     }
1336
1337 }