Merge "Dali C#: Common Interface Define related changes" 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       NUIApplicationInitEventArgs e = new NUIApplicationInitEventArgs();
408
409       // Populate all members of "e" (NUIApplicationInitEventArgs) with real data
410       e.Application = Application.GetApplicationFromPtr(data);
411
412       if (_applicationInitEventHandler != null)
413       {
414         //here we send all data to user event handlers
415         _applicationInitEventHandler(this, e);
416       }
417     }
418
419     /**
420       * @brief Event for Terminated signal which can be used to subscribe/unsubscribe the event handler
421       * (in the type of NUIApplicationTerminateEventHandler-DaliEventHandler<object,NUIApplicationTerminateEventArgs>)
422       *  provided by the user. Terminated signal is emitted when application is terminated
423       */
424     public event DaliEventHandler<object,NUIApplicationTerminateEventArgs> Terminated
425     {
426       add
427       {
428         lock(this)
429         {
430           // Restricted to only one listener
431           if (_applicationTerminateEventHandler == null)
432           {
433             _applicationTerminateEventHandler += value;
434
435             _applicationTerminateEventCallbackDelegate = new NUIApplicationTerminateEventCallbackDelegate(OnNUIApplicationTerminate);
436             this.TerminateSignal().Connect(_applicationTerminateEventCallbackDelegate);
437           }
438         }
439       }
440
441       remove
442       {
443         lock(this)
444         {
445           if (_applicationTerminateEventHandler != null)
446           {
447             this.TerminateSignal().Disconnect(_applicationTerminateEventCallbackDelegate);
448           }
449
450           _applicationTerminateEventHandler -= value;
451         }
452       }
453     }
454
455     // Callback for Application TerminateSignal
456     private void OnNUIApplicationTerminate(IntPtr data)
457     {
458       NUIApplicationTerminateEventArgs e = new NUIApplicationTerminateEventArgs();
459
460       // Populate all members of "e" (NUIApplicationTerminateEventArgs) with real data
461       e.Application = Application.GetApplicationFromPtr(data);
462
463       if (_applicationTerminateEventHandler != null)
464       {
465         //here we send all data to user event handlers
466         _applicationTerminateEventHandler(this, e);
467       }
468     }
469
470     /**
471       * @brief Event for Paused signal which can be used to subscribe/unsubscribe the event handler
472       * (in the type of NUIApplicationPauseEventHandler-DaliEventHandler<object,NUIApplicationPauseEventArgs>)
473       * provided by the user. Paused signal is emitted when application is paused
474       */
475     public event DaliEventHandler<object,NUIApplicationPauseEventArgs> Paused
476     {
477       add
478       {
479         lock(this)
480         {
481           // Restricted to only one listener
482           if (_applicationPauseEventHandler == null)
483           {
484             _applicationPauseEventHandler += value;
485
486             _applicationPauseEventCallbackDelegate = new NUIApplicationPauseEventCallbackDelegate(OnNUIApplicationPause);
487             this.PauseSignal().Connect(_applicationPauseEventCallbackDelegate);
488           }
489         }
490       }
491
492       remove
493       {
494         lock(this)
495         {
496           if (_applicationPauseEventHandler != null)
497           {
498             this.PauseSignal().Disconnect(_applicationPauseEventCallbackDelegate);
499           }
500
501           _applicationPauseEventHandler -= value;
502         }
503       }
504     }
505
506     // Callback for Application PauseSignal
507     private void OnNUIApplicationPause(IntPtr data)
508     {
509       NUIApplicationPauseEventArgs e = new NUIApplicationPauseEventArgs();
510
511       // Populate all members of "e" (NUIApplicationPauseEventArgs) with real data
512       e.Application = Application.GetApplicationFromPtr(data);
513
514       if (_applicationPauseEventHandler != null)
515       {
516         //here we send all data to user event handlers
517         _applicationPauseEventHandler(this, e);
518       }
519     }
520
521     /**
522       * @brief Event for Resumed signal which can be used to subscribe/unsubscribe the event handler
523       * (in the type of NUIApplicationResumeEventHandler-DaliEventHandler<object,NUIApplicationResumeEventArgs>)
524       *  provided by the user. Resumed signal is emitted when application is resumed
525       */
526     public event DaliEventHandler<object,NUIApplicationResumeEventArgs> Resumed
527     {
528       add
529       {
530         lock(this)
531         {
532           // Restricted to only one listener
533           if (_applicationResumeEventHandler == null)
534           {
535             _applicationResumeEventHandler += value;
536
537             _applicationResumeEventCallbackDelegate = new NUIApplicationResumeEventCallbackDelegate(OnNUIApplicationResume);
538             this.ResumeSignal().Connect(_applicationResumeEventCallbackDelegate);
539           }
540         }
541       }
542
543       remove
544       {
545         lock(this)
546         {
547           if (_applicationResumeEventHandler != null)
548           {
549             this.ResumeSignal().Disconnect(_applicationResumeEventCallbackDelegate);
550           }
551
552           _applicationResumeEventHandler -= value;
553         }
554       }
555     }
556
557     // Callback for Application ResumeSignal
558     private void OnNUIApplicationResume(IntPtr data)
559     {
560       NUIApplicationResumeEventArgs e = new NUIApplicationResumeEventArgs();
561
562       // Populate all members of "e" (NUIApplicationResumeEventArgs) with real data
563       e.Application = Application.GetApplicationFromPtr(data);
564
565       if (_applicationResumeEventHandler != null)
566       {
567         //here we send all data to user event handlers
568         _applicationResumeEventHandler(this, e);
569       }
570     }
571
572     /**
573       * @brief Event for Reset signal which can be used to subscribe/unsubscribe the event handler
574       * (in the type of NUIApplicationResetEventHandler-DaliEventHandler<object,NUIApplicationResetEventArgs>)
575       *  provided by the user. Reset signal is emitted when application is reset
576       */
577     public event DaliEventHandler<object,NUIApplicationResetEventArgs> Reset
578     {
579       add
580       {
581         lock(this)
582         {
583           // Restricted to only one listener
584           if (_applicationResetEventHandler == null)
585           {
586             _applicationResetEventHandler += value;
587
588             _applicationResetEventCallbackDelegate = new NUIApplicationResetEventCallbackDelegate(OnNUIApplicationReset);
589             this.ResetSignal().Connect(_applicationResetEventCallbackDelegate);
590           }
591         }
592       }
593
594       remove
595       {
596         lock(this)
597         {
598           if (_applicationResetEventHandler != null)
599           {
600             this.ResetSignal().Disconnect(_applicationResetEventCallbackDelegate);
601           }
602
603           _applicationResetEventHandler -= value;
604         }
605       }
606     }
607
608     // Callback for Application ResetSignal
609     private void OnNUIApplicationReset(IntPtr data)
610     {
611       NUIApplicationResetEventArgs e = new NUIApplicationResetEventArgs();
612
613       // Populate all members of "e" (NUIApplicationResetEventArgs) with real data
614       e.Application = Application.GetApplicationFromPtr(data);
615
616       if (_applicationResetEventHandler != null)
617       {
618         //here we send all data to user event handlers
619         _applicationResetEventHandler(this, e);
620       }
621     }
622
623     /**
624       * @brief Event for Resized signal which can be used to subscribe/unsubscribe the event handler
625       * (in the type of NUIApplicationResizeEventHandler-DaliEventHandler<object,NUIApplicationResizeEventArgs>)
626       *  provided by the user. Resized signal is emitted when application is resized
627       */
628     public event DaliEventHandler<object,NUIApplicationResizeEventArgs> Resized
629     {
630       add
631       {
632         lock(this)
633         {
634           // Restricted to only one listener
635           if (_applicationResizeEventHandler == null)
636           {
637             _applicationResizeEventHandler += value;
638
639             _applicationResizeEventCallbackDelegate = new NUIApplicationResizeEventCallbackDelegate(OnNUIApplicationResize);
640             this.ResizeSignal().Connect(_applicationResizeEventCallbackDelegate);
641           }
642         }
643       }
644
645       remove
646       {
647         lock(this)
648         {
649           if (_applicationResizeEventHandler != null)
650           {
651             this.ResizeSignal().Disconnect(_applicationResizeEventCallbackDelegate);
652           }
653
654           _applicationResizeEventHandler -= value;
655         }
656       }
657     }
658
659     // Callback for Application ResizeSignal
660     private void OnNUIApplicationResize(IntPtr data)
661     {
662       NUIApplicationResizeEventArgs e = new NUIApplicationResizeEventArgs();
663
664       // Populate all members of "e" (NUIApplicationResizeEventArgs) with real data
665       e.Application = Application.GetApplicationFromPtr(data);
666
667       if (_applicationResizeEventHandler != null)
668       {
669         //here we send all data to user event handlers
670         _applicationResizeEventHandler(this, e);
671       }
672     }
673
674     /**
675       * @brief Event for LanguageChanged signal which can be used to subscribe/unsubscribe the event handler
676       * (in the type of NUIApplicationLanguageChangedEventHandler-DaliEventHandler<object,NUIApplicationLanguageChangedEventArgs>)
677       *  provided by the user. LanguageChanged signal is emitted when the region of the device is changed.
678       */
679     public event DaliEventHandler<object,NUIApplicationLanguageChangedEventArgs> LanguageChanged
680     {
681       add
682       {
683         lock(this)
684         {
685           // Restricted to only one listener
686           if (_applicationLanguageChangedEventHandler == null)
687           {
688             _applicationLanguageChangedEventHandler += value;
689
690             _applicationLanguageChangedEventCallbackDelegate = new NUIApplicationLanguageChangedEventCallbackDelegate(OnNUIApplicationLanguageChanged);
691             this.LanguageChangedSignal().Connect(_applicationLanguageChangedEventCallbackDelegate);
692           }
693         }
694       }
695
696       remove
697       {
698         lock(this)
699         {
700           if (_applicationLanguageChangedEventHandler != null)
701           {
702             this.LanguageChangedSignal().Disconnect(_applicationLanguageChangedEventCallbackDelegate);
703           }
704
705           _applicationLanguageChangedEventHandler -= value;
706         }
707       }
708     }
709
710     // Callback for Application LanguageChangedSignal
711     private void OnNUIApplicationLanguageChanged(IntPtr data)
712     {
713       NUIApplicationLanguageChangedEventArgs e = new NUIApplicationLanguageChangedEventArgs();
714
715       // Populate all members of "e" (NUIApplicationLanguageChangedEventArgs) with real data
716       e.Application = Application.GetApplicationFromPtr(data);
717
718       if (_applicationLanguageChangedEventHandler != null)
719       {
720         //here we send all data to user event handlers
721         _applicationLanguageChangedEventHandler(this, e);
722       }
723     }
724
725     /**
726       * @brief Event for RegionChanged signal which can be used to subscribe/unsubscribe the event handler
727       * (in the type of NUIApplicationRegionChangedEventHandler-DaliEventHandler<object,NUIApplicationRegionChangedEventArgs>)
728       *  provided by the user. RegionChanged signal is emitted when the region of the device is changed.
729       */
730     public event DaliEventHandler<object,NUIApplicationRegionChangedEventArgs> RegionChanged
731     {
732       add
733       {
734         lock(this)
735         {
736           // Restricted to only one listener
737           if (_applicationRegionChangedEventHandler == null)
738           {
739             _applicationRegionChangedEventHandler += value;
740
741             _applicationRegionChangedEventCallbackDelegate = new NUIApplicationRegionChangedEventCallbackDelegate(OnNUIApplicationRegionChanged);
742             this.RegionChangedSignal().Connect(_applicationRegionChangedEventCallbackDelegate);
743           }
744         }
745       }
746
747       remove
748       {
749         lock(this)
750         {
751           if (_applicationRegionChangedEventHandler != null)
752           {
753             this.RegionChangedSignal().Disconnect(_applicationRegionChangedEventCallbackDelegate);
754           }
755
756           _applicationRegionChangedEventHandler -= value;
757         }
758       }
759     }
760
761     // Callback for Application RegionChangedSignal
762     private void OnNUIApplicationRegionChanged(IntPtr data)
763     {
764       NUIApplicationRegionChangedEventArgs e = new NUIApplicationRegionChangedEventArgs();
765
766       // Populate all members of "e" (NUIApplicationRegionChangedEventArgs) with real data
767       e.Application = Application.GetApplicationFromPtr(data);
768
769       if (_applicationRegionChangedEventHandler != null)
770       {
771         //here we send all data to user event handlers
772         _applicationRegionChangedEventHandler(this, e);
773       }
774     }
775
776     /**
777       * @brief Event for BatteryLow signal which can be used to subscribe/unsubscribe the event handler
778       * (in the type of NUIApplicationBatteryLowEventHandler-DaliEventHandler<object,NUIApplicationBatteryLowEventArgs>) 
779       * provided by the user. BatteryLow signal is emitted when the battery level of the device is low.
780       */
781     public event DaliEventHandler<object,NUIApplicationBatteryLowEventArgs> BatteryLow
782     {
783       add
784       {
785         lock(this)
786         {
787           // Restricted to only one listener
788           if (_applicationBatteryLowEventHandler == null)
789           {
790             _applicationBatteryLowEventHandler += value;
791
792             _applicationBatteryLowEventCallbackDelegate = new NUIApplicationBatteryLowEventCallbackDelegate(OnNUIApplicationBatteryLow);
793             this.BatteryLowSignal().Connect(_applicationBatteryLowEventCallbackDelegate);
794           }
795         }
796       }
797
798       remove
799       {
800         lock(this)
801         {
802           if (_applicationBatteryLowEventHandler != null)
803           {
804             this.BatteryLowSignal().Disconnect(_applicationBatteryLowEventCallbackDelegate);
805           }
806
807           _applicationBatteryLowEventHandler -= value;
808         }
809       }
810     }
811
812     // Callback for Application BatteryLowSignal
813     private void OnNUIApplicationBatteryLow(IntPtr data)
814     {
815       NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs();
816
817       // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data
818       e.Application = Application.GetApplicationFromPtr(data);
819
820       if (_applicationBatteryLowEventHandler != null)
821       {
822         //here we send all data to user event handlers
823         _applicationBatteryLowEventHandler(this, e);
824       }
825     }
826
827     /**
828       * @brief Event for MemoryLow signal which can be used to subscribe/unsubscribe the event handler
829       * (in the type of NUIApplicationMemoryLowEventHandler-DaliEventHandler<object,NUIApplicationMemoryLowEventArgs>)
830       *  provided by the user. MemoryLow signal is emitted when the memory level of the device is low.
831       */
832     public event DaliEventHandler<object,NUIApplicationMemoryLowEventArgs> MemoryLow
833     {
834       add
835       {
836         lock(this)
837         {
838           // Restricted to only one listener
839           if (_applicationMemoryLowEventHandler == null)
840           {
841             _applicationMemoryLowEventHandler += value;
842
843             _applicationMemoryLowEventCallbackDelegate = new NUIApplicationMemoryLowEventCallbackDelegate(OnNUIApplicationMemoryLow);
844             this.MemoryLowSignal().Connect(_applicationMemoryLowEventCallbackDelegate);
845           }
846         }
847       }
848
849       remove
850       {
851         lock(this)
852         {
853           if (_applicationMemoryLowEventHandler != null)
854           {
855             this.MemoryLowSignal().Disconnect(_applicationMemoryLowEventCallbackDelegate);
856           }
857
858           _applicationMemoryLowEventHandler -= value;
859         }
860       }
861     }
862
863     // Callback for Application MemoryLowSignal
864     private void OnNUIApplicationMemoryLow(IntPtr data)
865     {
866       NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs();
867
868       // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data
869       e.Application = Application.GetApplicationFromPtr(data);
870
871       if (_applicationMemoryLowEventHandler != null)
872       {
873         //here we send all data to user event handlers
874         _applicationMemoryLowEventHandler(this, e);
875       }
876     }
877
878     /**
879       * @brief Event for AppControl signal which can be used to subscribe/unsubscribe the event handler
880       * (in the type of NUIApplicationAppControlEventHandler-DaliEventHandler<object,NUIApplicationAppControlEventArgs>)
881       *  provided by the user. AppControl signal is emitted when another application sends a launch request to the application.
882       */
883     public event DaliEventHandler<object,NUIApplicationAppControlEventArgs> AppControl
884     {
885       add
886       {
887         lock(this)
888         {
889           // Restricted to only one listener
890           if (_applicationAppControlEventHandler == null)
891           {
892             _applicationAppControlEventHandler += value;
893
894             _applicationAppControlEventCallbackDelegate = new NUIApplicationAppControlEventCallbackDelegate(OnNUIApplicationAppControl);
895             this.AppControlSignal().Connect(_applicationAppControlEventCallbackDelegate);
896           }
897         }
898       }
899
900       remove
901       {
902         lock(this)
903         {
904           if (_applicationAppControlEventHandler != null)
905           {
906             this.AppControlSignal().Disconnect(_applicationAppControlEventCallbackDelegate);
907           }
908
909           _applicationAppControlEventHandler -= value;
910         }
911       }
912     }
913
914     // Callback for Application AppControlSignal
915     private void OnNUIApplicationAppControl(IntPtr application, IntPtr voidp)
916     {
917       NUIApplicationAppControlEventArgs e = new NUIApplicationAppControlEventArgs();
918
919       // Populate all members of "e" (NUIApplicationAppControlEventArgs) with real data
920       e.Application = Application.GetApplicationFromPtr(application);
921       e.VoidP = voidp;
922
923       if (_applicationAppControlEventHandler != null)
924       {
925         //here we send all data to user event handlers
926         _applicationAppControlEventHandler(this, e);
927       }
928     }
929
930     private static Application _instance; // singleton
931
932     public delegate void InitDelegate();
933
934     public delegate void TerminateDelegate();
935
936     public delegate void PauseDelegate();
937
938     public delegate void ResumeDelegate();
939
940     public delegate void ResizeDelegate();
941
942     public delegate void AppControlDelegate();
943
944     public delegate void LanguageChangedDelegate();
945
946     public delegate void RegionChangedDelegate();
947
948     public delegate void BatteryLowDelegate();
949
950     public delegate void MemoryLowDelegate();
951
952     [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
953     internal delegate void InitDelegateInternal();
954
955     [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
956     internal delegate void TerminateDelegateInternal();
957
958     [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
959     internal delegate void PauseDelegateInternal();
960
961     [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
962     internal delegate void ResumeDelegateInternal();
963
964     [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
965     internal delegate void ResizeDelegateInternal();
966
967     [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
968     internal delegate void AppControlDelegateInternal();
969
970     [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
971     internal delegate void LanguageChangedDelegateInternal();
972
973     [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
974     internal delegate void RegionChangedDelegateInternal();
975
976     [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
977     internal delegate void BatteryLowDelegateInternal();
978
979     [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
980     internal delegate void MemoryLowDelegateInternal();
981
982     static void Initialize()
983     {
984       //        instance.InitDelegate();
985     }
986
987     public static Application Instance
988     {
989        get
990        {
991             return _instance;
992        }
993     }
994
995     public static Application GetApplicationFromPtr(global::System.IntPtr cPtr) {
996       Application ret = new Application(cPtr, false);
997       if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
998       return ret;
999     }
1000
1001     internal void SetupDelegates() {
1002       InitDelegateInternal initializeCallback = new InitDelegateInternal( Initialize );
1003       System.Console.WriteLine( "InitSignal connection count");
1004
1005       this.InitSignal().Connect( initializeCallback );
1006       //Console.WriteLine( "InitSignal connection count = " + app.InitSignal().GetConnectionCount() );
1007     }
1008
1009     public static Application NewApplication() {
1010      _instance = NewApplication("", Application.WINDOW_MODE.OPAQUE);
1011      return _instance;
1012     }
1013
1014     public static Application NewApplication(string stylesheet) {
1015       _instance = NewApplication(stylesheet, Application.WINDOW_MODE.OPAQUE);
1016       return _instance;
1017     }
1018
1019     public static Application NewApplication(string stylesheet, Application.WINDOW_MODE windowMode) {
1020
1021       Application ret = New(1, stylesheet, windowMode);
1022       if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1023
1024       // we've got an application now connect the signals
1025       ret.SetupDelegates();
1026       // set the singleton
1027       _instance = ret;
1028       return ret;
1029     }
1030
1031     public bool AddIdle(System.Delegate func) {
1032       System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func);
1033       System.IntPtr ip2 = NDalicManualPINVOKE.MakeCallback(new System.Runtime.InteropServices.HandleRef(this, ip));
1034
1035       bool ret = NDalicPINVOKE.Application_AddIdle(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip2));
1036
1037       if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1038       return ret;
1039     }
1040
1041     %}
1042     %enddef
1043
1044 %define DALI_APPLICATION_EVENTHANDLER_PARAM( NameSpace, ClassName)
1045   APPLICATION_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
1046   APPLICATION_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
1047   %enddef
1048
1049   namespace Dali
1050 {
1051   DALI_APPLICATION_EVENTHANDLER_PARAM( Dali, Application);
1052 }
1053
1054