[NUI] Constructor of NUIWidgetApplication is opened public in API level7 (#1241)
[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 using System.ComponentModel;
21
22 namespace Tizen.NUI
23 {
24     /// <summary>
25     /// Represents an application that have UI screen. The NUIWidgetApplication class has a default stage.
26     /// </summary>
27     /// <since_tizen> 4 </since_tizen>
28     public class NUIWidgetApplication : CoreApplication
29     {
30         /// <summary>
31         /// The default constructor.
32         /// </summary>
33         /// <remarks>Widget ID will be replaced as the application ID.</remarks>
34         /// <param name="widgetType">Derived widget class type.</param>
35         public NUIWidgetApplication( System.Type widgetType ) : base(new NUIWidgetCoreBackend())
36         {
37             NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
38             core?.RegisterWidgetInfo(new Dictionary<System.Type, string> { { widgetType, ApplicationInfo.ApplicationId } });
39         }
40
41         /// <summary>
42         /// The constructor for multi widget class and instance.
43         /// </summary>
44         /// <param name="widgetTypes">List of derived widget class type.</param>
45         public NUIWidgetApplication(Dictionary<System.Type, string> widgetTypes) : base(new NUIWidgetCoreBackend())
46         {
47             NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
48             core?.RegisterWidgetInfo(widgetTypes);
49         }
50
51         /// <summary>
52         /// The default constructor with stylesheet.
53         /// </summary>
54         /// <remarks>Widget ID will be replaced as the application ID.</remarks>
55         /// <param name="widgetType">Derived widget class type.</param>
56         /// <param name="styleSheet">The styleSheet url.</param>
57         /// <since_tizen> 4 </since_tizen>
58         public NUIWidgetApplication(System.Type widgetType, string styleSheet) : base(new NUIWidgetCoreBackend(styleSheet))
59         {
60             NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
61             core?.RegisterWidgetInfo(new Dictionary<System.Type, string> { { widgetType, ApplicationInfo.ApplicationId } });
62         }
63
64         /// <summary>
65         /// Add WidgetInfo in runtime
66         /// </summary>
67         /// <param name="widgetType">Derived widget class type.</param>
68         [EditorBrowsable(EditorBrowsableState.Never)]
69         public void AddWidgetType( System.Type widgetType )
70         {
71             NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
72             core?.AddWidgetInfo(new Dictionary<System.Type, string> { { widgetType, ApplicationInfo.ApplicationId } });
73         }
74
75         /// <summary>
76         /// Add WidgetInfo in runtime
77         /// </summary>
78         /// <param name="widgetTypes">Derived widget class type.</param>
79         [EditorBrowsable(EditorBrowsableState.Never)]
80         public void AddWidgetType( Dictionary<System.Type, string> widgetTypes )
81         {
82             NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
83             core?.AddWidgetInfo(widgetTypes);
84         }
85
86         internal WidgetApplication ApplicationHandle
87         {
88             get
89             {
90                 return ((NUIWidgetCoreBackend)this.Backend).WidgetApplicationHandle;
91             }
92         }
93
94         /// <summary>
95         /// Run NUIWidgetApplication.
96         /// </summary>
97         /// <param name="args">Arguments from commandline.</param>
98         /// <since_tizen> 4 </since_tizen>
99         public override void Run(string[] args)
100         {
101             Backend.AddEventHandler(EventType.PreCreated, OnPreCreate);
102             base.Run(args);
103         }
104
105         /// <summary>
106         /// Exit NUIWidgetApplication.
107         /// </summary>
108         /// <since_tizen> 4 </since_tizen>
109         public override void Exit()
110         {
111             Tizen.Log.Fatal("NUI", "### NUIWidgetApplication Exit called");
112             base.Exit();
113         }
114
115         /// <summary>
116         /// Overrides this method if want to handle OnLocaleChanged behavior.
117         /// </summary>
118         /// <since_tizen> 4 </since_tizen>
119         protected override void OnLocaleChanged(LocaleChangedEventArgs e)
120         {
121             Log.Fatal("NUI", "OnLocaleChanged() is called!");
122             base.OnLocaleChanged(e);
123         }
124
125         /// <summary>
126         /// Overrides this method if want to handle OnLowBattery behavior.
127         /// </summary>
128         /// <since_tizen> 4 </since_tizen>
129         protected override void OnLowBattery(LowBatteryEventArgs e)
130         {
131             Log.Fatal("NUI", "OnLowBattery() is called!");
132             base.OnLowBattery(e);
133         }
134
135         /// <summary>
136         /// Overrides this method if want to handle OnLowMemory behavior.
137         /// </summary>
138         /// <since_tizen> 4 </since_tizen>
139         protected override void OnLowMemory(LowMemoryEventArgs e)
140         {
141             Log.Fatal("NUI", "OnLowMemory() is called!");
142             base.OnLowMemory(e);
143         }
144
145         /// <summary>
146         /// Overrides this method if want to handle OnRegionFormatChanged behavior.
147         /// </summary>
148         /// <since_tizen> 4 </since_tizen>
149         protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
150         {
151             Log.Fatal("NUI", "OnRegionFormatChanged() is called!");
152             base.OnRegionFormatChanged(e);
153         }
154
155         /// <summary>
156         /// Overrides this method if want to handle OnTerminate behavior.
157         /// </summary>
158         /// <since_tizen> 4 </since_tizen>
159         protected override void OnTerminate()
160         {
161             Log.Fatal("NUI", "OnTerminate() is called!");
162             base.OnTerminate();
163         }
164
165         /// <summary>
166         /// Overrides this method if want to handle OnPreCreate behavior.
167         /// </summary>
168         /// <since_tizen> 4 </since_tizen>
169         protected virtual void OnPreCreate()
170         {
171             Log.Fatal("NUI", "OnPreCreate() is called!");
172         }
173
174         /// <summary>
175         /// Overrides this method if want to handle OnCreate behavior.
176         /// </summary>
177         /// <since_tizen> 4 </since_tizen>
178         protected override void OnCreate()
179         {
180             // This is also required to create DisposeQueue on main thread.
181             DisposeQueue disposeQ = DisposeQueue.Instance;
182             disposeQ.Initialize();
183             Log.Fatal("NUI","OnCreate() is called!");
184             base.OnCreate();
185         }
186     }
187 }