AnimationBetween() parameter changed and more
[platform/core/csapi/nui.git] / Tizen.NUI / src / public / NUIApplication.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
18 using System;
19 using Tizen.Applications;
20 using Tizen.NUI;
21
22 namespace Tizen.NUI
23 {
24
25     /// <summary>
26     /// Represents an application that have UI screen. The NUIApplication class has a default stage.
27     /// </summary>
28     public class NUIApplication : CoreUIApplication
29     {
30         private void LOG(string _str)
31         {
32             //Tizen.Log.Debug("NUI", _str);
33             //Console.WriteLine("[NUI]" + _str);
34         }
35
36         /// <summary>
37         /// The instance of the Application.
38         /// </summary>
39         /// <remarks>
40         /// This application is created before OnCreate() or created event. And the NUIApplication will be terminated when this application is closed.
41         /// </remarks>
42         private Application _application;
43
44         /// <summary>
45         /// The instance of the Dali Application extension.
46         /// </summary>
47         private ApplicationExtensions _applicationExt;
48
49         /// <summary>
50         /// Store the stylesheet value.
51         /// </summary>
52         private string _stylesheet;
53
54         /// <summary>
55         /// Store the window mode value.
56         /// </summary>
57         private Application.WindowMode _windowMode;
58
59         /// <summary>
60         /// Store the app mode value.
61         /// </summary>
62         private AppMode _appMode;
63
64         /// <summary>
65         /// The instance of the Dali Stage.
66         /// </summary>
67         private Stage _stage;
68
69         /// <summary>
70         /// The default constructor.
71         /// </summary>
72         public NUIApplication() : base()
73         {
74             _appMode = AppMode.Default;
75         }
76
77         /// <summary>
78         /// The constructor with stylesheet.
79         /// </summary>
80         public NUIApplication(string stylesheet) : base()
81         {
82             //handle the stylesheet
83             _appMode = AppMode.StyleSheetOnly;
84             _stylesheet = stylesheet;
85         }
86
87         /// <summary>
88         /// The constructor with stylesheet and window mode.
89         /// </summary>
90         public NUIApplication(string stylesheet, WindowMode windowMode) : base()
91         {
92             //handle the stylesheet and windowMode
93             _appMode = AppMode.StyleSheetWithWindowMode;
94             _stylesheet = stylesheet;
95             _windowMode = (Application.WindowMode)windowMode;
96         }
97
98         /// <summary>
99         /// Overrides this method if want to handle behavior.
100         /// </summary>
101         protected override void OnPause()
102         {
103             base.OnPause();
104             _applicationExt.Pause();
105             LOG("OnPause() is called!");
106         }
107
108         /// <summary>
109         /// Overrides this method if want to handle behavior before calling OnCreate().
110         /// stage property is initialized in this overrided method.
111         /// </summary>
112         protected override void OnPreCreate()
113         {
114             switch (_appMode)
115             {
116                 case AppMode.Default:
117                     _application = Tizen.NUI.Application.NewApplication();
118                     break;
119                 case AppMode.StyleSheetOnly:
120                     _application = Tizen.NUI.Application.NewApplication(_stylesheet);
121                     break;
122                 case AppMode.StyleSheetWithWindowMode:
123                     _application = Tizen.NUI.Application.NewApplication(_stylesheet, _windowMode);
124                     break;
125                 default:
126                     break;
127             }
128             _applicationExt = new ApplicationExtensions(_application);
129             _applicationExt.Init();
130
131             _stage = Stage.Instance;
132             _stage.SetBackgroundColor(Color.White);
133             LOG("OnPreCreate() is called!");
134         }
135
136         /// <summary>
137         /// Overrides this method if want to handle behavior.
138         /// </summary>
139         protected override void OnResume()
140         {
141             base.OnResume();
142             _applicationExt.Resume();
143             LOG("OnResume() is called!");
144         }
145
146         /// <summary>
147         /// Overrides this method if want to handle behavior.
148         /// </summary>
149         protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
150         {
151             base.OnAppControlReceived(e);
152             LOG("OnAppControlReceived() is called!");
153             if (e != null)
154             {
155                 LOG("OnAppControlReceived() is called! ApplicationId=" + e.ReceivedAppControl.ApplicationId);
156                 LOG("CallerApplicationId=" + e.ReceivedAppControl.CallerApplicationId + "   IsReplyRequest=" + e.ReceivedAppControl.IsReplyRequest);
157             }
158         }
159
160         /// <summary>
161         /// Overrides this method if want to handle behavior.
162         /// </summary>
163         protected override void OnCreate()
164         {
165             base.OnCreate();
166             LOG("OnCreate() is called!");
167         }
168
169         /// <summary>
170         /// Overrides this method if want to handle behavior.
171         /// </summary>
172         protected override void OnLocaleChanged(LocaleChangedEventArgs e)
173         {
174             base.OnLocaleChanged(e);
175             _applicationExt.LanguageChange();
176             LOG("OnLocaleChanged() is called!");
177         }
178
179         /// <summary>
180         /// Overrides this method if want to handle behavior.
181         /// </summary>
182         protected override void OnLowBattery(LowBatteryEventArgs e)
183         {
184             base.OnLowBattery(e);
185             LOG("OnLowBattery() is called!");
186         }
187
188         /// <summary>
189         /// Overrides this method if want to handle behavior.
190         /// </summary>
191         protected override void OnLowMemory(LowMemoryEventArgs e)
192         {
193             base.OnLowMemory(e);
194             LOG("OnLowMemory() is called!");
195         }
196
197         /// <summary>
198         /// Overrides this method if want to handle behavior.
199         /// </summary>
200         protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
201         {
202             base.OnRegionFormatChanged(e);
203             LOG("OnRegionFormatChanged() is called!");
204         }
205
206         /// <summary>
207         /// Overrides this method if want to handle behavior.
208         /// </summary>
209         protected override void OnTerminate()
210         {
211             base.OnTerminate();
212             _applicationExt.Terminate();
213             LOG("OnTerminate() is called!");
214         }
215
216         /// <summary>
217         /// The mode of creating NUI application.
218         /// </summary>
219         private enum AppMode
220         {
221             Default = 0,
222             StyleSheetOnly = 1,
223             StyleSheetWithWindowMode = 2
224         }
225
226         /// <summary>
227         /// Enumeration for deciding whether a NUI application window is opaque or transparent.
228         /// </summary>
229         public enum WindowMode
230         {
231             Opaque = 0,
232             Transparent = 1
233         }
234
235     }
236 }