[NUI] Revert "Sync with dalihub & API5 branch (#631)" (#635)
[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
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 default constructor with stylesheet.
43         /// </summary>
44         /// <remarks>Widget ID will be replaced as the application ID.</remarks>
45         /// <param name="widgetType">Derived widget class type.</param>
46         /// <param name="styleSheet">The styleSheet url.</param>
47         /// <since_tizen> 4 </since_tizen>
48         public NUIWidgetApplication(System.Type widgetType, string styleSheet) : base(new NUIWidgetCoreBackend(styleSheet))
49         {
50             NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
51             core?.RegisterWidgetInfo(new Dictionary<System.Type, string> { { widgetType, ApplicationInfo.ApplicationId } });
52         }
53
54         /// <summary>
55         /// Overrides this method if want to handle OnLocaleChanged behavior.
56         /// </summary>
57         /// <since_tizen> 4 </since_tizen>
58         protected override void OnLocaleChanged(LocaleChangedEventArgs e)
59         {
60             Log.Fatal("NUI", "OnLocaleChanged() is called!");
61             base.OnLocaleChanged(e);
62         }
63
64         /// <summary>
65         /// Overrides this method if want to handle OnLowBattery behavior.
66         /// </summary>
67         /// <since_tizen> 4 </since_tizen>
68         protected override void OnLowBattery(LowBatteryEventArgs e)
69         {
70             Log.Fatal("NUI", "OnLowBattery() is called!");
71             base.OnLowBattery(e);
72         }
73
74         /// <summary>
75         /// Overrides this method if want to handle OnLowMemory behavior.
76         /// </summary>
77         /// <since_tizen> 4 </since_tizen>
78         protected override void OnLowMemory(LowMemoryEventArgs e)
79         {
80             Log.Fatal("NUI", "OnLowMemory() is called!");
81             base.OnLowMemory(e);
82         }
83
84         /// <summary>
85         /// Overrides this method if want to handle OnRegionFormatChanged behavior.
86         /// </summary>
87         /// <since_tizen> 4 </since_tizen>
88         protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
89         {
90             Log.Fatal("NUI", "OnRegionFormatChanged() is called!");
91             base.OnRegionFormatChanged(e);
92         }
93
94         /// <summary>
95         /// Overrides this method if want to handle OnTerminate behavior.
96         /// </summary>
97         /// <since_tizen> 4 </since_tizen>
98         protected override void OnTerminate()
99         {
100             Log.Fatal("NUI", "OnTerminate() is called!");
101             base.OnTerminate();
102         }
103
104         /// <summary>
105         /// Overrides this method if want to handle OnPreCreate behavior.
106         /// </summary>
107         /// <since_tizen> 4 </since_tizen>
108         protected virtual void OnPreCreate()
109         {
110             Log.Fatal("NUI", "OnPreCreate() is called!");
111         }
112
113         /// <summary>
114         /// Overrides this method if want to handle OnCreate behavior.
115         /// </summary>
116         /// <since_tizen> 4 </since_tizen>
117         protected override void OnCreate()
118         {
119             // This is also required to create DisposeQueue on main thread.
120             DisposeQueue disposeQ = DisposeQueue.Instance;
121             disposeQ.Initialize();
122             Log.Fatal("NUI","OnCreate() is called!");
123             base.OnCreate();
124         }
125
126         /// <summary>
127         /// Run NUIWidgetApplication.
128         /// </summary>
129         /// <param name="args">Arguments from commandline.</param>
130         /// <since_tizen> 4 </since_tizen>
131         public override void Run(string[] args)
132         {
133             Backend.AddEventHandler(EventType.PreCreated, OnPreCreate);
134             base.Run(args);
135         }
136
137         /// <summary>
138         /// Exit NUIWidgetApplication.
139         /// </summary>
140         /// <since_tizen> 4 </since_tizen>
141         public override void Exit()
142         {
143             Tizen.Log.Fatal("NUI", "### NUIWidgetApplication Exit called");
144             base.Exit();
145         }
146
147         internal WidgetApplication ApplicationHandle
148         {
149             get
150             {
151                 return ((NUIWidgetCoreBackend)this.Backend).WidgetApplicationHandle;
152             }
153         }
154     }
155 }