1 #ifndef __DALI_WIDGET_APPLICATION_H__
2 #define __DALI_WIDGET_APPLICATION_H__
5 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/object/base-handle.h>
23 #include <dali/public-api/signals/dali-signal.h>
24 #include <dali/public-api/signals/callback.h>
28 #ifdef DALI_ADAPTOR_COMPILATION // full path doesn't exist until adaptor is installed so we have to use relative
29 #include <device-status.h>
31 #include <dali/public-api/adaptor-framework/device-status.h>
39 namespace Internal DALI_INTERNAL
43 class WidgetApplication;
50 * @brief An WidgetApplication class object should be created by every widget application
51 * that wishes to use Dali.
53 * It provides a means for initializing the
54 * resources required by the Dali::Core.
56 * The WidgetApplication class emits several signals which the user can
57 * connect to. The user should not create any Dali objects in the main
58 * function and instead should connect to the Init signal of the
59 * WidgetApplication and create the Dali Widget object in the connected callback.
61 * WidgetApplications should follow the example below:
64 * class ExampleController: public ConnectionTracker
67 * ExampleController( WidgetApplication& widgetApplication )
68 * : mWidgetApplication( widgetApplication )
70 * mWidgetApplication.InitSignal().Connect( this, &ExampleController::Create );
73 * void Create( WidgetApplication& widgetApplication )
75 * Widget widget = Widget::New( WIDGET_ID );
76 * widget.CreateSignal( this, &ExampleController::WidgetCreate );
79 * void WidgetCreate( const std::string& id, bundle* content, Window window )
81 * // Do Dali components...
85 * WidgetApplication& mWidgetApplication;
88 * int main (int argc, char **argv)
90 * WidgetApplication app = WidgetApplication::New(&argc, &argv);
91 * ExampleController example( app );
96 * If required, you can also connect class member functions to a signal:
99 * MyWidgetApplication app;
100 * app.ResumeSignal().Connect(&app, &MyWidgetApplication::Resume);
105 class DALI_IMPORT_API WidgetApplication : public BaseHandle
109 typedef Signal< void (WidgetApplication&) > AppSignalType; ///< Widget application lifecycle signal and system signal callback type
110 typedef Signal< void (DeviceStatus::Battery::Status) > LowBatterySignalType; ///< Widget application device signal type
111 typedef Signal< void (DeviceStatus::Memory::Status) > LowMemorySignalType; ///< Widget application device signal type
116 * @brief This is the constructor for WidgetApplications with a name.
118 * @param[in,out] argc A pointer to the number of arguments
119 * @param[in,out] argv A pointer to the argument list
120 * @param[in] stylesheet The path to user defined theme file
121 * @return A handle to the WidgetApplication
122 * @note If the stylesheet is not specified, then the library's default stylesheet will not be overridden.
124 static WidgetApplication New( int* argc, char **argv[], const std::string& stylesheet );
127 * @brief The default constructor.
133 * @brief Copy Constructor.
134 * @param[in] WidgetApplication Handle to an object
136 WidgetApplication( const WidgetApplication& widgetApplication );
139 * @brief Assignment operator.
140 * @param[in] WidgetApplication Handle to an object
141 * @return A reference to this
143 WidgetApplication& operator=( const WidgetApplication& widgetApplication );
149 ~WidgetApplication();
152 * @brief This starts the application.
157 * @brief This quits the application. Tizen applications should use Lower to improve re-start performance unless they need to Quit completely.
162 * @brief Get path application resources are stored at
163 * @return the full path of the resources
165 static std::string GetResourcePath();
168 * @brief this is used to get region information from device.
170 * @return region information
172 std::string GetRegion();
175 * @brief this is used to get language information from device.
177 * @return language information
179 std::string GetLanguage();
184 * @brief The user should connect to this signal to determine when they should initialize
186 * @return The signal to connect to
188 AppSignalType& InitSignal();
191 * @brief The user should connect to this signal to determine when they should terminate
193 * @return The signal to connect to
195 AppSignalType& TerminateSignal();
198 * @brief This signal is emitted when the language is changed on the device.
199 * @return The signal to connect to
201 AppSignalType& LanguageChangedSignal();
204 * @brief This signal is emitted when the region of the device is changed.
205 * @return The signal to connect to
207 AppSignalType& RegionChangedSignal();
210 * @brief This signal is emitted when the battery level of the device is low.
211 * @return The signal to connect to
213 LowBatterySignalType& LowBatterySignal();
216 * @brief This signal is emitted when the memory level of the device is low.
217 * @return The signal to connect to
219 LowMemorySignalType& LowMemorySignal();
221 public: // Not intended for application developers
224 * @brief Internal constructor.
226 explicit DALI_INTERNAL WidgetApplication(Internal::Adaptor::WidgetApplication* widgetApplication);
232 #endif // ___DALI_WIDGET_APPLICATION_H__