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 #ifdef DALI_ADAPTOR_COMPILATION // full path doesn't exist until adaptor is installed so we have to use relative
23 #include <application.h>
25 #include <dali/public-api/adaptor-framework/application.h>
30 namespace Internal DALI_INTERNAL
35 class WidgetApplication;
43 * @brief An WidgetApplication class object should be created by every widget application
44 * that wishes to use Dali.
46 * It provides a means for initializing the
47 * resources required by the Dali::Core.
49 * The WidgetApplication class emits several signals which the user can
50 * connect to. The user should not create any Dali objects in the main
51 * function and instead should connect to the Init signal of the
52 * WidgetApplication and create the Dali Widget object in the connected callback.
54 * WidgetApplications should follow the example below:
58 * //Widget header which
59 * #include <my-widget.h>
61 * class ExampleController: public ConnectionTracker
64 * ExampleController( Application& application )
65 * : mWidgetApplication( application )
67 * mApplication.InitSignal().Connect( this, &ExampleController::Create );
70 * static Widget CreateWidgetFunction(const std::string& widgetName)
72 * MyWidget widget = MyWidget::New();
76 * void Create( Application& application )
78 * mApplication.RegisterWidgetCreatingFunction( "myWidget", &ExampleController::CreateWidgetFunction );
82 * WidgetApplication& mWidgetApplication;
85 * int main (int argc, char **argv)
87 * WidgetApplication app = WidgetApplication::New(&argc, &argv);
88 * ExampleController example( app );
93 * If required, you can also connect class member functions to a signal:
96 * MyWidgetApplication app;
97 * app.ResumeSignal().Connect(&app, &MyWidgetApplication::Resume);
102 class DALI_IMPORT_API WidgetApplication : public Application
107 * @brief This is the typedef for Widget creator.
110 typedef Widget(*CreateWidgetFunction)(const std::string&);
115 * @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.
136 * @param[in] widgetApplication Handle to an object
138 WidgetApplication( const WidgetApplication& widgetApplication );
141 * @brief Assignment operator.
144 * @param[in] widgetApplication Handle to an object
145 * @return A reference to this
147 WidgetApplication& operator=( const WidgetApplication& widgetApplication );
153 ~WidgetApplication();
156 * @brief Register create function for widget.
159 * @param[in] widgetName Name of widget
160 * @param[in] createFunction Function pointer for widget creation.
162 void RegisterWidgetCreatingFunction( const std::string& widgetName, CreateWidgetFunction createFunction );
164 public: // Not intended for application developers
167 * @brief Internal constructor.
169 explicit DALI_INTERNAL WidgetApplication(Internal::Adaptor::WidgetApplication* widgetApplication);
175 #endif // DALI_WIDGET_APPLICATION_H