Merge "DALi Version 1.2.40" into devel/master
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / SWIG / events / application-event.i
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 %define APPLICATION_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19   %typemap(csimports) NameSpace::ClassName %{
20     using System;
21     using System.Runtime.InteropServices;
22
23     /**
24       * @brief Event arguments that passed via NUIApplicationInit signal
25       *
26       */
27     public class NUIApplicationInitEventArgs : EventArgs
28     {
29     private Application _application;
30
31       /**
32         * @brief Application - is the application that is being initialized
33         *
34         */
35     public Application Application
36       {
37         get
38         {
39           return _application;
40         }
41         set
42         {
43           _application = value;
44         }
45       }
46     }
47
48     /**
49       * @brief Event arguments that passed via NUIApplicationTerminate signal
50       *
51       */
52     public class NUIApplicationTerminateEventArgs : EventArgs
53     {
54     private Application _application;
55       /**
56         * @brief Application - is the application that is being Terminated
57         *
58         */
59     public Application Application
60       {
61         get
62         {
63           return _application;
64         }
65         set
66         {
67           _application = value;
68         }
69       }
70     }
71
72     /**
73       * @brief Event arguments that passed via NUIApplicationPause signal
74       *
75       */
76     public class NUIApplicationPauseEventArgs : EventArgs
77     {
78     private Application _application;
79       /**
80         * @brief Application - is the application that is being Paused
81         *
82         */
83     public Application Application
84       {
85         get
86         {
87           return _application;
88         }
89         set
90         {
91           _application = value;
92         }
93       }
94     }
95
96     /**
97       * @brief Event arguments that passed via NUIApplicationResume signal
98       *
99       */
100     public class NUIApplicationResumeEventArgs : EventArgs
101     {
102     private Application _application;
103       /**
104         * @brief Application - is the application that is being Resumed
105         *
106         */
107     public Application Application
108       {
109         get
110         {
111           return _application;
112         }
113         set
114         {
115           _application = value;
116         }
117       }
118     }
119
120     /**
121       * @brief Event arguments that passed via NUIApplicationReset signal
122       *
123       */
124     public class NUIApplicationResetEventArgs : EventArgs
125     {
126     private Application _application;
127       /**
128         * @brief Application - is the application that is being Reset
129         *
130         */
131     public Application Application
132       {
133         get
134         {
135           return _application;
136         }
137         set
138         {
139           _application = value;
140         }
141       }
142     }
143
144     /**
145       * @brief Event arguments that passed via NUIApplicationResize signal
146       *
147       */
148     public class NUIApplicationResizeEventArgs : EventArgs
149     {
150     private Application _application;
151       /**
152         * @brief Application - is the application that is being Resized
153         *
154         */
155     public Application Application
156       {
157         get
158         {
159           return _application;
160         }
161         set
162         {
163           _application = value;
164         }
165       }
166     }
167
168     /**
169       * @brief Event arguments that passed via NUIApplicationLanguageChanged signal
170       *
171       */
172     public class NUIApplicationLanguageChangedEventArgs : EventArgs
173     {
174     private Application _application;
175       /**
176         * @brief Application - is the application that is being affected with Device's language change
177         *
178         */
179     public Application Application
180       {
181         get
182         {
183           return _application;
184         }
185         set
186         {
187           _application = value;
188         }
189       }
190     }
191
192     /**
193       * @brief Event arguments that passed via NUIApplicationRegionChanged signal
194       *
195       */
196     public class NUIApplicationRegionChangedEventArgs : EventArgs
197     {
198     private Application _application;
199       /**
200         * @brief Application - is the application that is being affected with Device's region change
201         *
202         */
203     public Application Application
204       {
205         get
206         {
207           return _application;
208         }
209         set
210         {
211           _application = value;
212         }
213       }
214     }
215
216     /**
217       * @brief Event arguments that passed via NUIApplicationBatteryLow signal
218       *
219       */
220     public class NUIApplicationBatteryLowEventArgs : EventArgs
221     {
222     private Application _application;
223       /**
224         * @brief Application - is the application that is being affected when the battery level of the device is low
225         *
226         */
227     public Application Application
228       {
229         get
230         {
231           return _application;
232         }
233         set
234         {
235           _application = value;
236         }
237       }
238     }
239
240     /**
241       * @brief Event arguments that passed via NUIApplicationMemoryLow signal
242       *
243       */
244     public class NUIApplicationMemoryLowEventArgs : EventArgs
245     {
246     private Application _application;
247       /**
248         * @brief Application - is the application that is being affected when the memory level of the device is low
249         *
250         */
251     public Application Application
252       {
253         get
254         {
255           return _application;
256         }
257         set
258         {
259           _application = value;
260         }
261       }
262     }
263
264     /**
265       * @brief Event arguments that passed via NUIApplicationAppControl  signal
266       *
267       */
268     public class NUIApplicationAppControlEventArgs : EventArgs
269     {
270     private Application _application;
271     private IntPtr _voidp;
272       /**
273         * @brief Application - is the application that is receiving the launch request from another application
274         *
275         */
276     public Application Application
277       {
278         get
279         {
280           return _application;
281         }
282         set
283         {
284           _application = value;
285         }
286       }
287       /**
288         * @brief VoidP - contains the information about why the application is launched
289         *
290         */
291     public IntPtr VoidP
292       {
293         get
294         {
295           return _voidp;
296         }
297         set
298         {
299           _voidp = value;
300         }
301       }
302     }
303 %}
304
305 %enddef
306
307
308 %define APPLICATION_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
309   %typemap(cscode) NameSpace::ClassName %{
310     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
311     private delegate void NUIApplicationInitEventCallbackDelegate(IntPtr application);
312     private DaliEventHandler<object,NUIApplicationInitEventArgs> _applicationInitEventHandler;
313     private NUIApplicationInitEventCallbackDelegate _applicationInitEventCallbackDelegate;
314
315
316     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
317     private delegate void NUIApplicationTerminateEventCallbackDelegate(IntPtr application);
318     private DaliEventHandler<object,NUIApplicationTerminateEventArgs> _applicationTerminateEventHandler;
319     private NUIApplicationTerminateEventCallbackDelegate _applicationTerminateEventCallbackDelegate;
320
321
322     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
323     private delegate void NUIApplicationPauseEventCallbackDelegate(IntPtr application);
324     private DaliEventHandler<object,NUIApplicationPauseEventArgs> _applicationPauseEventHandler;
325     private NUIApplicationPauseEventCallbackDelegate _applicationPauseEventCallbackDelegate;
326
327     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
328     private delegate void NUIApplicationResumeEventCallbackDelegate(IntPtr application);
329     private DaliEventHandler<object,NUIApplicationResumeEventArgs> _applicationResumeEventHandler;
330     private NUIApplicationResumeEventCallbackDelegate _applicationResumeEventCallbackDelegate;
331
332     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
333     private delegate void NUIApplicationResetEventCallbackDelegate(IntPtr application);
334     private DaliEventHandler<object,NUIApplicationResetEventArgs> _applicationResetEventHandler;
335     private NUIApplicationResetEventCallbackDelegate _applicationResetEventCallbackDelegate;
336
337     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
338     private delegate void NUIApplicationResizeEventCallbackDelegate(IntPtr application);
339     private DaliEventHandler<object,NUIApplicationResizeEventArgs> _applicationResizeEventHandler;
340     private NUIApplicationResizeEventCallbackDelegate _applicationResizeEventCallbackDelegate;
341
342     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
343     private delegate void NUIApplicationLanguageChangedEventCallbackDelegate(IntPtr application);
344     private DaliEventHandler<object,NUIApplicationLanguageChangedEventArgs> _applicationLanguageChangedEventHandler;
345     private NUIApplicationLanguageChangedEventCallbackDelegate _applicationLanguageChangedEventCallbackDelegate;
346
347
348     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
349     private delegate void NUIApplicationRegionChangedEventCallbackDelegate(IntPtr application);
350     private DaliEventHandler<object,NUIApplicationRegionChangedEventArgs> _applicationRegionChangedEventHandler;
351     private NUIApplicationRegionChangedEventCallbackDelegate _applicationRegionChangedEventCallbackDelegate;
352
353     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
354     private delegate void NUIApplicationBatteryLowEventCallbackDelegate(IntPtr application);
355     private DaliEventHandler<object,NUIApplicationBatteryLowEventArgs> _applicationBatteryLowEventHandler;
356     private NUIApplicationBatteryLowEventCallbackDelegate _applicationBatteryLowEventCallbackDelegate;
357
358     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
359     private delegate void NUIApplicationMemoryLowEventCallbackDelegate(IntPtr application);
360     private DaliEventHandler<object,NUIApplicationMemoryLowEventArgs> _applicationMemoryLowEventHandler;
361     private NUIApplicationMemoryLowEventCallbackDelegate _applicationMemoryLowEventCallbackDelegate;
362
363     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
364     private delegate void NUIApplicationAppControlEventCallbackDelegate(IntPtr application, IntPtr voidp);
365     private DaliEventHandler<object,NUIApplicationAppControlEventArgs> _applicationAppControlEventHandler;
366     private NUIApplicationAppControlEventCallbackDelegate _applicationAppControlEventCallbackDelegate;
367
368     /**
369       * @brief Event for Initialized signal which can be used to subscribe/unsubscribe the event handler
370       * (in the type of NUIApplicationInitEventHandler - DaliEventHandler<object,NUIApplicationInitEventArgs>)
371       *  provided by the user. Initialized signal is emitted when application is initialised
372       */
373     public event DaliEventHandler<object,NUIApplicationInitEventArgs> Initialized
374     {
375       add
376       {
377         lock(this)
378         {
379           // Restricted to only one listener
380           if (_applicationInitEventHandler == null)
381           {
382             _applicationInitEventHandler += value;
383
384             _applicationInitEventCallbackDelegate = new NUIApplicationInitEventCallbackDelegate(OnApplicationInit);
385             this.InitSignal().Connect(_applicationInitEventCallbackDelegate);
386           }
387         }
388       }
389
390       remove
391       {
392         lock(this)
393         {
394           if (_applicationInitEventHandler != null)
395           {
396             this.InitSignal().Disconnect(_applicationInitEventCallbackDelegate);
397           }
398
399           _applicationInitEventHandler -= value;
400         }
401       }
402     }
403
404     // Callback for Application InitSignal
405     private void OnApplicationInit(IntPtr data)
406     {
407       // Initialize DisposeQueue Singleton class. This is also required to create DisposeQueue on main thread.
408       DisposeQueue.Instance.Initialize();
409
410       NUIApplicationInitEventArgs e = new NUIApplicationInitEventArgs();
411
412       // Populate all members of "e" (NUIApplicationInitEventArgs) with real data
413       e.Application = Application.GetApplicationFromPtr(data);
414
415       if (_applicationInitEventHandler != null)
416       {
417         //here we send all data to user event handlers
418         _applicationInitEventHandler(this, e);
419       }
420     }
421
422     /**
423       * @brief Event for Terminated signal which can be used to subscribe/unsubscribe the event handler
424       * (in the type of NUIApplicationTerminateEventHandler-DaliEventHandler<object,NUIApplicationTerminateEventArgs>)
425       *  provided by the user. Terminated signal is emitted when application is terminated
426       */
427     public event DaliEventHandler<object,NUIApplicationTerminateEventArgs> Terminated
428     {
429       add
430       {
431         lock(this)
432         {
433           // Restricted to only one listener
434           if (_applicationTerminateEventHandler == null)
435           {
436             _applicationTerminateEventHandler += value;
437
438             _applicationTerminateEventCallbackDelegate = new NUIApplicationTerminateEventCallbackDelegate(OnNUIApplicationTerminate);
439             this.TerminateSignal().Connect(_applicationTerminateEventCallbackDelegate);
440           }
441         }
442       }
443
444       remove
445       {
446         lock(this)
447         {
448           if (_applicationTerminateEventHandler != null)
449           {
450             this.TerminateSignal().Disconnect(_applicationTerminateEventCallbackDelegate);
451           }
452
453           _applicationTerminateEventHandler -= value;
454         }
455       }
456     }
457
458     // Callback for Application TerminateSignal
459     private void OnNUIApplicationTerminate(IntPtr data)
460     {
461       NUIApplicationTerminateEventArgs e = new NUIApplicationTerminateEventArgs();
462
463       // Populate all members of "e" (NUIApplicationTerminateEventArgs) with real data
464       e.Application = Application.GetApplicationFromPtr(data);
465
466       if (_applicationTerminateEventHandler != null)
467       {
468         //here we send all data to user event handlers
469         _applicationTerminateEventHandler(this, e);
470       }
471     }
472
473     /**
474       * @brief Event for Paused signal which can be used to subscribe/unsubscribe the event handler
475       * (in the type of NUIApplicationPauseEventHandler-DaliEventHandler<object,NUIApplicationPauseEventArgs>)
476       * provided by the user. Paused signal is emitted when application is paused
477       */
478     public event DaliEventHandler<object,NUIApplicationPauseEventArgs> Paused
479     {
480       add
481       {
482         lock(this)
483         {
484           // Restricted to only one listener
485           if (_applicationPauseEventHandler == null)
486           {
487             _applicationPauseEventHandler += value;
488
489             _applicationPauseEventCallbackDelegate = new NUIApplicationPauseEventCallbackDelegate(OnNUIApplicationPause);
490             this.PauseSignal().Connect(_applicationPauseEventCallbackDelegate);
491           }
492         }
493       }
494
495       remove
496       {
497         lock(this)
498         {
499           if (_applicationPauseEventHandler != null)
500           {
501             this.PauseSignal().Disconnect(_applicationPauseEventCallbackDelegate);
502           }
503
504           _applicationPauseEventHandler -= value;
505         }
506       }
507     }
508
509     // Callback for Application PauseSignal
510     private void OnNUIApplicationPause(IntPtr data)
511     {
512       NUIApplicationPauseEventArgs e = new NUIApplicationPauseEventArgs();
513
514       // Populate all members of "e" (NUIApplicationPauseEventArgs) with real data
515       e.Application = Application.GetApplicationFromPtr(data);
516
517       if (_applicationPauseEventHandler != null)
518       {
519         //here we send all data to user event handlers
520         _applicationPauseEventHandler(this, e);
521       }
522     }
523
524     /**
525       * @brief Event for Resumed signal which can be used to subscribe/unsubscribe the event handler
526       * (in the type of NUIApplicationResumeEventHandler-DaliEventHandler<object,NUIApplicationResumeEventArgs>)
527       *  provided by the user. Resumed signal is emitted when application is resumed
528       */
529     public event DaliEventHandler<object,NUIApplicationResumeEventArgs> Resumed
530     {
531       add
532       {
533         lock(this)
534         {
535           // Restricted to only one listener
536           if (_applicationResumeEventHandler == null)
537           {
538             _applicationResumeEventHandler += value;
539
540             _applicationResumeEventCallbackDelegate = new NUIApplicationResumeEventCallbackDelegate(OnNUIApplicationResume);
541             this.ResumeSignal().Connect(_applicationResumeEventCallbackDelegate);
542           }
543         }
544       }
545
546       remove
547       {
548         lock(this)
549         {
550           if (_applicationResumeEventHandler != null)
551           {
552             this.ResumeSignal().Disconnect(_applicationResumeEventCallbackDelegate);
553           }
554
555           _applicationResumeEventHandler -= value;
556         }
557       }
558     }
559
560     // Callback for Application ResumeSignal
561     private void OnNUIApplicationResume(IntPtr data)
562     {
563       NUIApplicationResumeEventArgs e = new NUIApplicationResumeEventArgs();
564
565       // Populate all members of "e" (NUIApplicationResumeEventArgs) with real data
566       e.Application = Application.GetApplicationFromPtr(data);
567
568       if (_applicationResumeEventHandler != null)
569       {
570         //here we send all data to user event handlers
571         _applicationResumeEventHandler(this, e);
572       }
573     }
574
575     /**
576       * @brief Event for Reset signal which can be used to subscribe/unsubscribe the event handler
577       * (in the type of NUIApplicationResetEventHandler-DaliEventHandler<object,NUIApplicationResetEventArgs>)
578       *  provided by the user. Reset signal is emitted when application is reset
579       */
580     public event DaliEventHandler<object,NUIApplicationResetEventArgs> Reset
581     {
582       add
583       {
584         lock(this)
585         {
586           // Restricted to only one listener
587           if (_applicationResetEventHandler == null)
588           {
589             _applicationResetEventHandler += value;
590
591             _applicationResetEventCallbackDelegate = new NUIApplicationResetEventCallbackDelegate(OnNUIApplicationReset);
592             this.ResetSignal().Connect(_applicationResetEventCallbackDelegate);
593           }
594         }
595       }
596
597       remove
598       {
599         lock(this)
600         {
601           if (_applicationResetEventHandler != null)
602           {
603             this.ResetSignal().Disconnect(_applicationResetEventCallbackDelegate);
604           }
605
606           _applicationResetEventHandler -= value;
607         }
608       }
609     }
610
611     // Callback for Application ResetSignal
612     private void OnNUIApplicationReset(IntPtr data)
613     {
614       NUIApplicationResetEventArgs e = new NUIApplicationResetEventArgs();
615
616       // Populate all members of "e" (NUIApplicationResetEventArgs) with real data
617       e.Application = Application.GetApplicationFromPtr(data);
618
619       if (_applicationResetEventHandler != null)
620       {
621         //here we send all data to user event handlers
622         _applicationResetEventHandler(this, e);
623       }
624     }
625
626     /**
627       * @brief Event for Resized signal which can be used to subscribe/unsubscribe the event handler
628       * (in the type of NUIApplicationResizeEventHandler-DaliEventHandler<object,NUIApplicationResizeEventArgs>)
629       *  provided by the user. Resized signal is emitted when application is resized
630       */
631     public event DaliEventHandler<object,NUIApplicationResizeEventArgs> Resized
632     {
633       add
634       {
635         lock(this)
636         {
637           // Restricted to only one listener
638           if (_applicationResizeEventHandler == null)
639           {
640             _applicationResizeEventHandler += value;
641
642             _applicationResizeEventCallbackDelegate = new NUIApplicationResizeEventCallbackDelegate(OnNUIApplicationResize);
643             this.ResizeSignal().Connect(_applicationResizeEventCallbackDelegate);
644           }
645         }
646       }
647
648       remove
649       {
650         lock(this)
651         {
652           if (_applicationResizeEventHandler != null)
653           {
654             this.ResizeSignal().Disconnect(_applicationResizeEventCallbackDelegate);
655           }
656
657           _applicationResizeEventHandler -= value;
658         }
659       }
660     }
661
662     // Callback for Application ResizeSignal
663     private void OnNUIApplicationResize(IntPtr data)
664     {
665       NUIApplicationResizeEventArgs e = new NUIApplicationResizeEventArgs();
666
667       // Populate all members of "e" (NUIApplicationResizeEventArgs) with real data
668       e.Application = Application.GetApplicationFromPtr(data);
669
670       if (_applicationResizeEventHandler != null)
671       {
672         //here we send all data to user event handlers
673         _applicationResizeEventHandler(this, e);
674       }
675     }
676
677     /**
678       * @brief Event for LanguageChanged signal which can be used to subscribe/unsubscribe the event handler
679       * (in the type of NUIApplicationLanguageChangedEventHandler-DaliEventHandler<object,NUIApplicationLanguageChangedEventArgs>)
680       *  provided by the user. LanguageChanged signal is emitted when the region of the device is changed.
681       */
682     public event DaliEventHandler<object,NUIApplicationLanguageChangedEventArgs> LanguageChanged
683     {
684       add
685       {
686         lock(this)
687         {
688           // Restricted to only one listener
689           if (_applicationLanguageChangedEventHandler == null)
690           {
691             _applicationLanguageChangedEventHandler += value;
692
693             _applicationLanguageChangedEventCallbackDelegate = new NUIApplicationLanguageChangedEventCallbackDelegate(OnNUIApplicationLanguageChanged);
694             this.LanguageChangedSignal().Connect(_applicationLanguageChangedEventCallbackDelegate);
695           }
696         }
697       }
698
699       remove
700       {
701         lock(this)
702         {
703           if (_applicationLanguageChangedEventHandler != null)
704           {
705             this.LanguageChangedSignal().Disconnect(_applicationLanguageChangedEventCallbackDelegate);
706           }
707
708           _applicationLanguageChangedEventHandler -= value;
709         }
710       }
711     }
712
713     // Callback for Application LanguageChangedSignal
714     private void OnNUIApplicationLanguageChanged(IntPtr data)
715     {
716       NUIApplicationLanguageChangedEventArgs e = new NUIApplicationLanguageChangedEventArgs();
717
718       // Populate all members of "e" (NUIApplicationLanguageChangedEventArgs) with real data
719       e.Application = Application.GetApplicationFromPtr(data);
720
721       if (_applicationLanguageChangedEventHandler != null)
722       {
723         //here we send all data to user event handlers
724         _applicationLanguageChangedEventHandler(this, e);
725       }
726     }
727
728     /**
729       * @brief Event for RegionChanged signal which can be used to subscribe/unsubscribe the event handler
730       * (in the type of NUIApplicationRegionChangedEventHandler-DaliEventHandler<object,NUIApplicationRegionChangedEventArgs>)
731       *  provided by the user. RegionChanged signal is emitted when the region of the device is changed.
732       */
733     public event DaliEventHandler<object,NUIApplicationRegionChangedEventArgs> RegionChanged
734     {
735       add
736       {
737         lock(this)
738         {
739           // Restricted to only one listener
740           if (_applicationRegionChangedEventHandler == null)
741           {
742             _applicationRegionChangedEventHandler += value;
743
744             _applicationRegionChangedEventCallbackDelegate = new NUIApplicationRegionChangedEventCallbackDelegate(OnNUIApplicationRegionChanged);
745             this.RegionChangedSignal().Connect(_applicationRegionChangedEventCallbackDelegate);
746           }
747         }
748       }
749
750       remove
751       {
752         lock(this)
753         {
754           if (_applicationRegionChangedEventHandler != null)
755           {
756             this.RegionChangedSignal().Disconnect(_applicationRegionChangedEventCallbackDelegate);
757           }
758
759           _applicationRegionChangedEventHandler -= value;
760         }
761       }
762     }
763
764     // Callback for Application RegionChangedSignal
765     private void OnNUIApplicationRegionChanged(IntPtr data)
766     {
767       NUIApplicationRegionChangedEventArgs e = new NUIApplicationRegionChangedEventArgs();
768
769       // Populate all members of "e" (NUIApplicationRegionChangedEventArgs) with real data
770       e.Application = Application.GetApplicationFromPtr(data);
771
772       if (_applicationRegionChangedEventHandler != null)
773       {
774         //here we send all data to user event handlers
775         _applicationRegionChangedEventHandler(this, e);
776       }
777     }
778
779     /**
780       * @brief Event for BatteryLow signal which can be used to subscribe/unsubscribe the event handler
781       * (in the type of NUIApplicationBatteryLowEventHandler-DaliEventHandler<object,NUIApplicationBatteryLowEventArgs>) 
782       * provided by the user. BatteryLow signal is emitted when the battery level of the device is low.
783       */
784     public event DaliEventHandler<object,NUIApplicationBatteryLowEventArgs> BatteryLow
785     {
786       add
787       {
788         lock(this)
789         {
790           // Restricted to only one listener
791           if (_applicationBatteryLowEventHandler == null)
792           {
793             _applicationBatteryLowEventHandler += value;
794
795             _applicationBatteryLowEventCallbackDelegate = new NUIApplicationBatteryLowEventCallbackDelegate(OnNUIApplicationBatteryLow);
796             this.BatteryLowSignal().Connect(_applicationBatteryLowEventCallbackDelegate);
797           }
798         }
799       }
800
801       remove
802       {
803         lock(this)
804         {
805           if (_applicationBatteryLowEventHandler != null)
806           {
807             this.BatteryLowSignal().Disconnect(_applicationBatteryLowEventCallbackDelegate);
808           }
809
810           _applicationBatteryLowEventHandler -= value;
811         }
812       }
813     }
814
815     // Callback for Application BatteryLowSignal
816     private void OnNUIApplicationBatteryLow(IntPtr data)
817     {
818       NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs();
819
820       // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data
821       e.Application = Application.GetApplicationFromPtr(data);
822
823       if (_applicationBatteryLowEventHandler != null)
824       {
825         //here we send all data to user event handlers
826         _applicationBatteryLowEventHandler(this, e);
827       }
828     }
829
830     /**
831       * @brief Event for MemoryLow signal which can be used to subscribe/unsubscribe the event handler
832       * (in the type of NUIApplicationMemoryLowEventHandler-DaliEventHandler<object,NUIApplicationMemoryLowEventArgs>)
833       *  provided by the user. MemoryLow signal is emitted when the memory level of the device is low.
834       */
835     public event DaliEventHandler<object,NUIApplicationMemoryLowEventArgs> MemoryLow
836     {
837       add
838       {
839         lock(this)
840         {
841           // Restricted to only one listener
842           if (_applicationMemoryLowEventHandler == null)
843           {
844             _applicationMemoryLowEventHandler += value;
845
846             _applicationMemoryLowEventCallbackDelegate = new NUIApplicationMemoryLowEventCallbackDelegate(OnNUIApplicationMemoryLow);
847             this.MemoryLowSignal().Connect(_applicationMemoryLowEventCallbackDelegate);
848           }
849         }
850       }
851
852       remove
853       {
854         lock(this)
855         {
856           if (_applicationMemoryLowEventHandler != null)
857           {
858             this.MemoryLowSignal().Disconnect(_applicationMemoryLowEventCallbackDelegate);
859           }
860
861           _applicationMemoryLowEventHandler -= value;
862         }
863       }
864     }
865
866     // Callback for Application MemoryLowSignal
867     private void OnNUIApplicationMemoryLow(IntPtr data)
868     {
869       NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs();
870
871       // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data
872       e.Application = Application.GetApplicationFromPtr(data);
873
874       if (_applicationMemoryLowEventHandler != null)
875       {
876         //here we send all data to user event handlers
877         _applicationMemoryLowEventHandler(this, e);
878       }
879     }
880
881     /**
882       * @brief Event for AppControl signal which can be used to subscribe/unsubscribe the event handler
883       * (in the type of NUIApplicationAppControlEventHandler-DaliEventHandler<object,NUIApplicationAppControlEventArgs>)
884       *  provided by the user. AppControl signal is emitted when another application sends a launch request to the application.
885       */
886     public event DaliEventHandler<object,NUIApplicationAppControlEventArgs> AppControl
887     {
888       add
889       {
890         lock(this)
891         {
892           // Restricted to only one listener
893           if (_applicationAppControlEventHandler == null)
894           {
895             _applicationAppControlEventHandler += value;
896
897             _applicationAppControlEventCallbackDelegate = new NUIApplicationAppControlEventCallbackDelegate(OnNUIApplicationAppControl);
898             this.AppControlSignal().Connect(_applicationAppControlEventCallbackDelegate);
899           }
900         }
901       }
902
903       remove
904       {
905         lock(this)
906         {
907           if (_applicationAppControlEventHandler != null)
908           {
909             this.AppControlSignal().Disconnect(_applicationAppControlEventCallbackDelegate);
910           }
911
912           _applicationAppControlEventHandler -= value;
913         }
914       }
915     }
916
917     // Callback for Application AppControlSignal
918     private void OnNUIApplicationAppControl(IntPtr application, IntPtr voidp)
919     {
920       NUIApplicationAppControlEventArgs e = new NUIApplicationAppControlEventArgs();
921
922       // Populate all members of "e" (NUIApplicationAppControlEventArgs) with real data
923       e.Application = Application.GetApplicationFromPtr(application);
924       e.VoidP = voidp;
925
926       if (_applicationAppControlEventHandler != null)
927       {
928         //here we send all data to user event handlers
929         _applicationAppControlEventHandler(this, e);
930       }
931     }
932
933     private static Application _instance; // singleton
934
935     public delegate void InitDelegate();
936
937     public delegate void TerminateDelegate();
938
939     public delegate void PauseDelegate();
940
941     public delegate void ResumeDelegate();
942
943     public delegate void ResizeDelegate();
944
945     public delegate void AppControlDelegate();
946
947     public delegate void LanguageChangedDelegate();
948
949     public delegate void RegionChangedDelegate();
950
951     public delegate void BatteryLowDelegate();
952
953     public delegate void MemoryLowDelegate();
954
955     [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
956     internal delegate void InitDelegateInternal();
957
958     [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
959     internal delegate void TerminateDelegateInternal();
960
961     [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
962     internal delegate void PauseDelegateInternal();
963
964     [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
965     internal delegate void ResumeDelegateInternal();
966
967     [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
968     internal delegate void ResizeDelegateInternal();
969
970     [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
971     internal delegate void AppControlDelegateInternal();
972
973     [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
974     internal delegate void LanguageChangedDelegateInternal();
975
976     [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
977     internal delegate void RegionChangedDelegateInternal();
978
979     [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
980     internal delegate void BatteryLowDelegateInternal();
981
982     [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
983     internal delegate void MemoryLowDelegateInternal();
984
985     static void Initialize()
986     {
987       //        instance.InitDelegate();
988     }
989
990     public static Application Instance
991     {
992        get
993        {
994             return _instance;
995        }
996     }
997
998     public static Application GetApplicationFromPtr(global::System.IntPtr cPtr) {
999       Application ret = new Application(cPtr, false);
1000       if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1001       return ret;
1002     }
1003
1004     internal void SetupDelegates() {
1005       InitDelegateInternal initializeCallback = new InitDelegateInternal( Initialize );
1006       System.Console.WriteLine( "InitSignal connection count");
1007
1008       this.InitSignal().Connect( initializeCallback );
1009       //Console.WriteLine( "InitSignal connection count = " + app.InitSignal().GetConnectionCount() );
1010     }
1011
1012     public static Application NewApplication() {
1013      _instance = NewApplication("", Application.WINDOW_MODE.OPAQUE);
1014      return _instance;
1015     }
1016
1017     public static Application NewApplication(string stylesheet) {
1018       _instance = NewApplication(stylesheet, Application.WINDOW_MODE.OPAQUE);
1019       return _instance;
1020     }
1021
1022     public static Application NewApplication(string stylesheet, Application.WINDOW_MODE windowMode) {
1023
1024       // register all Views with the type registry, so that can be created / styled via JSON
1025       ViewRegistryHelper.Initialize();
1026
1027       Application ret = New(1, stylesheet, windowMode);
1028       if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1029
1030       // we've got an application now connect the signals
1031       ret.SetupDelegates();
1032       // set the singleton
1033       _instance = ret;
1034       return ret;
1035     }
1036
1037     %}
1038     %enddef
1039
1040 %define DALI_APPLICATION_EVENTHANDLER_PARAM( NameSpace, ClassName)
1041   APPLICATION_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
1042   APPLICATION_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
1043   %enddef
1044
1045   namespace Dali
1046 {
1047   DALI_APPLICATION_EVENTHANDLER_PARAM( Dali, Application);
1048 }
1049
1050