[NUI] Clean NUI codes from Adaptor.cs to Window.cs (#652)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / NUIWidgetApplication.cs
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 using Tizen.Applications;
18 using Tizen.Applications.CoreBackend;
19 using System.Collections.Generic;
20
21 namespace Tizen.NUI
22 {
23     /// <summary>
24     /// Represents an application that have UI screen. The NUIWidgetApplication class has a default stage.
25     /// </summary>
26     /// <since_tizen> 4 </since_tizen>
27     public class NUIWidgetApplication : CoreApplication
28     {
29         /// <summary>
30         /// The default constructor.
31         /// </summary>
32         /// <remarks>Widget ID will be replaced as the application ID.</remarks>
33         /// <param name="widgetType">Derived widget class type.</param>
34         public NUIWidgetApplication( System.Type widgetType ) : base(new NUIWidgetCoreBackend())
35         {
36             NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
37             core?.RegisterWidgetInfo(new Dictionary<System.Type, string> { { widgetType, ApplicationInfo.ApplicationId } });
38         }
39
40         /// <summary>
41         /// The default constructor with stylesheet.
42         /// </summary>
43         /// <remarks>Widget ID will be replaced as the application ID.</remarks>
44         /// <param name="widgetType">Derived widget class type.</param>
45         /// <param name="styleSheet">The styleSheet url.</param>
46         /// <since_tizen> 4 </since_tizen>
47         public NUIWidgetApplication(System.Type widgetType, string styleSheet) : base(new NUIWidgetCoreBackend(styleSheet))
48         {
49             NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
50             core?.RegisterWidgetInfo(new Dictionary<System.Type, string> { { widgetType, ApplicationInfo.ApplicationId } });
51         }
52
53         internal WidgetApplication ApplicationHandle
54         {
55             get
56             {
57                 return ((NUIWidgetCoreBackend)this.Backend).WidgetApplicationHandle;
58             }
59         }
60
61         /// <summary>
62         /// Run NUIWidgetApplication.
63         /// </summary>
64         /// <param name="args">Arguments from commandline.</param>
65         /// <since_tizen> 4 </since_tizen>
66         public override void Run(string[] args)
67         {
68             Backend.AddEventHandler(EventType.PreCreated, OnPreCreate);
69             base.Run(args);
70         }
71
72         /// <summary>
73         /// Exit NUIWidgetApplication.
74         /// </summary>
75         /// <since_tizen> 4 </since_tizen>
76         public override void Exit()
77         {
78             Tizen.Log.Fatal("NUI", "### NUIWidgetApplication Exit called");
79             base.Exit();
80         }
81
82         /// <summary>
83         /// Overrides this method if want to handle OnLocaleChanged behavior.
84         /// </summary>
85         /// <since_tizen> 4 </since_tizen>
86         protected override void OnLocaleChanged(LocaleChangedEventArgs e)
87         {
88             Log.Fatal("NUI", "OnLocaleChanged() is called!");
89             base.OnLocaleChanged(e);
90         }
91
92         /// <summary>
93         /// Overrides this method if want to handle OnLowBattery behavior.
94         /// </summary>
95         /// <since_tizen> 4 </since_tizen>
96         protected override void OnLowBattery(LowBatteryEventArgs e)
97         {
98             Log.Fatal("NUI", "OnLowBattery() is called!");
99             base.OnLowBattery(e);
100         }
101
102         /// <summary>
103         /// Overrides this method if want to handle OnLowMemory behavior.
104         /// </summary>
105         /// <since_tizen> 4 </since_tizen>
106         protected override void OnLowMemory(LowMemoryEventArgs e)
107         {
108             Log.Fatal("NUI", "OnLowMemory() is called!");
109             base.OnLowMemory(e);
110         }
111
112         /// <summary>
113         /// Overrides this method if want to handle OnRegionFormatChanged behavior.
114         /// </summary>
115         /// <since_tizen> 4 </since_tizen>
116         protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
117         {
118             Log.Fatal("NUI", "OnRegionFormatChanged() is called!");
119             base.OnRegionFormatChanged(e);
120         }
121
122         /// <summary>
123         /// Overrides this method if want to handle OnTerminate behavior.
124         /// </summary>
125         /// <since_tizen> 4 </since_tizen>
126         protected override void OnTerminate()
127         {
128             Log.Fatal("NUI", "OnTerminate() is called!");
129             base.OnTerminate();
130         }
131
132         /// <summary>
133         /// Overrides this method if want to handle OnPreCreate behavior.
134         /// </summary>
135         /// <since_tizen> 4 </since_tizen>
136         protected virtual void OnPreCreate()
137         {
138             Log.Fatal("NUI", "OnPreCreate() is called!");
139         }
140
141         /// <summary>
142         /// Overrides this method if want to handle OnCreate behavior.
143         /// </summary>
144         /// <since_tizen> 4 </since_tizen>
145         protected override void OnCreate()
146         {
147             // This is also required to create DisposeQueue on main thread.
148             DisposeQueue disposeQ = DisposeQueue.Instance;
149             disposeQ.Initialize();
150             Log.Fatal("NUI","OnCreate() is called!");
151             base.OnCreate();
152         }
153     }
154 }