Merge "DALi Version 1.2.40" into devel/master
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / manual / csharp / Tizen.Applications / DaliApplication.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 Dali;
20
21 //------------------------------------------------------------------------------
22 // This file can only run on Tizen target. You should compile it with hello-test.cs, and
23 // add tizen c# application related library as reference.
24 //------------------------------------------------------------------------------
25 namespace Tizen.Applications
26 {
27     /// <summary>
28     /// Represents an application that have UI screen. The DaliApplication class has a default stage.
29     /// </summary>
30     public class DaliApplication : CoreUIApplication
31     {
32         /// <summary>
33         /// The instance of the Dali Application.
34         /// </summary>
35         /// <remarks>
36         /// This application is created before OnCreate() or created event. And the DaliApplication will be terminated when this application is closed.
37         /// </remarks>
38         protected Dali.Application application;
39
40         /// <summary>
41         /// The instance of the Dali Application extension.
42         /// </summary>
43         protected Dali.ApplicationExtensions applicationExt;
44
45         /// <summary>
46         /// Store the stylesheet value.
47         /// </summary>
48         protected string m_stylesheet;
49
50         /// <summary>
51         /// Store the window mode value.
52         /// </summary>
53         protected Dali.Application.WINDOW_MODE m_windowMode;
54
55         /// <summary>
56         /// Store the app mode value.
57         /// </summary>
58         protected APP_MODE appMode;
59
60         /// <summary>
61         /// The instance of the Dali Stage.
62         /// </summary>
63         public Stage stage { get; private set; }
64
65         /// <summary>
66         /// The default constructor.
67         /// </summary>
68         public DaliApplication():base()
69         {
70             appMode = APP_MODE.DEFAULT;
71         }
72
73         /// <summary>
74         /// The constructor with stylesheet.
75         /// </summary>
76         public DaliApplication(string stylesheet):base()
77         {
78             //handle the stylesheet
79             appMode = APP_MODE.STYLESHEETONLY;
80             m_stylesheet = stylesheet;
81         }
82
83         /// <summary>
84         /// The constructor with stylesheet and window mode.
85         /// </summary>
86         public DaliApplication(string stylesheet, Dali.Application.WINDOW_MODE windowMode)
87             : base()
88         {
89             //handle the stylesheet and windowMode
90             appMode = APP_MODE.STYLESHEETWITHWINDOWMODE;
91             m_stylesheet = stylesheet;
92             m_windowMode = windowMode;
93         }
94
95         /// <summary>
96         /// Overrides this method if want to handle behavior before calling OnCreate().
97         /// stage property is initialized in this overrided method.
98         /// </summary>
99         protected override void OnPreCreate()
100         {
101             switch(appMode)
102             {
103                 case APP_MODE.DEFAULT:
104                     application = Dali.Application.NewApplication();
105                     break;
106                 case APP_MODE.STYLESHEETONLY:
107                     application = Dali.Application.NewApplication(m_stylesheet);
108                     break;
109                 case APP_MODE.STYLESHEETWITHWINDOWMODE:
110                     application = Dali.Application.NewApplication(m_stylesheet, m_windowMode);
111                     break;
112                 default:
113                     break;
114             }
115
116             applicationExt = new Dali.ApplicationExtensions(application);
117             applicationExt.Init();
118
119             stage = Stage.GetCurrent();
120             stage.SetBackgroundColor( NDalic.WHITE );
121         }
122
123         /// <summary>
124         /// Overrides this method if want to handle behavior.
125         /// </summary>
126         protected override void OnTerminate()
127         {
128             base.OnTerminate();
129             applicationExt.Terminate();
130         }
131
132         /// <summary>
133         /// Overrides this method if want to handle behavior.
134         /// </summary>
135         protected override void OnPause()
136         {
137             base.OnPause();
138             applicationExt.Pause();
139         }
140
141         /// <summary>
142         /// Overrides this method if want to handle behavior.
143         /// </summary>
144         protected override void OnResume()
145         {
146             base.OnResume();
147             applicationExt.Resume();
148         }
149
150         /// <summary>
151         /// Overrides this method if want to handle behavior.
152         /// </summary>
153         protected override void OnLocaleChanged(LocaleChangedEventArgs e)
154         {
155             base.OnLocaleChanged(e);
156             applicationExt.LanguageChange();
157         }
158
159         /// <summary>
160         /// The mode of creating Dali application.
161         /// </summary>
162         protected enum APP_MODE
163         {
164             DEFAULT = 0,
165             STYLESHEETONLY = 1,
166             STYLESHEETWITHWINDOWMODE = 2
167         }
168     }
169 }