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