1 #ifndef DALI_WIDGET_APPLICATION_H
2 #define DALI_WIDGET_APPLICATION_H
5 * Copyright (c) 2018 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/adaptor-framework/application.h>
27 * @addtogroup dali_adaptor_framework
31 namespace Internal DALI_INTERNAL
36 class WidgetApplication;
44 * @brief An WidgetApplication class object should be created by every widget application
45 * that wishes to use Dali.
47 * It provides a means for initializing the
48 * resources required by the Dali::Core.
50 * The WidgetApplication class emits several signals which the user can
51 * connect to. The user should not create any Dali objects in the main
52 * function and instead should connect to the Init signal of the
53 * WidgetApplication and create the Dali Widget object in the connected callback.
55 * WidgetApplications should follow the example below:
59 * //Widget header which
60 * #include <my-widget.h>
62 * class ExampleController: public ConnectionTracker
65 * ExampleController( Application& application )
66 * : mWidgetApplication( application )
68 * mApplication.InitSignal().Connect( this, &ExampleController::Create );
71 * static Widget CreateWidgetFunction(const std::string& widgetName)
73 * MyWidget widget = MyWidget::New();
77 * void Create( Application& application )
79 * mApplication.RegisterWidgetCreatingFunction( "myWidget", &ExampleController::CreateWidgetFunction );
83 * WidgetApplication& mWidgetApplication;
86 * int main (int argc, char **argv)
88 * WidgetApplication app = WidgetApplication::New(&argc, &argv);
89 * ExampleController example( app );
94 * If required, you can also connect class member functions to a signal:
97 * MyWidgetApplication app;
98 * app.ResumeSignal().Connect(&app, &MyWidgetApplication::Resume);
103 class DALI_ADAPTOR_API WidgetApplication : public Application
108 * @brief This is the typedef for Widget creator.
111 typedef Widget(*CreateWidgetFunction)(const std::string&);
116 * @brief This is the constructor for WidgetApplications with a name.
119 * @param[in,out] argc A pointer to the number of arguments
120 * @param[in,out] argv A pointer to the argument list
121 * @param[in] stylesheet The path to user defined theme file
122 * @return A handle to the WidgetApplication
123 * @note If the stylesheet is not specified, then the library's default stylesheet will not be overridden.
125 static WidgetApplication New( int* argc, char **argv[], const std::string& stylesheet );
128 * @brief The default constructor.
134 * @brief Copy Constructor.
137 * @param[in] widgetApplication Handle to an object
139 WidgetApplication( const WidgetApplication& widgetApplication );
142 * @brief Assignment operator.
145 * @param[in] widgetApplication Handle to an object
146 * @return A reference to this
148 WidgetApplication& operator=( const WidgetApplication& widgetApplication );
154 ~WidgetApplication();
157 * @brief Register create function for widget.
160 * @param[in] widgetName Name of widget
161 * @param[in] createFunction Function pointer for widget creation.
163 void RegisterWidgetCreatingFunction( const std::string& widgetName, CreateWidgetFunction createFunction );
165 public: // Not intended for application developers
168 * @brief Internal constructor.
170 explicit DALI_INTERNAL WidgetApplication(Internal::Adaptor::WidgetApplication* widgetApplication);
179 #endif // DALI_WIDGET_APPLICATION_H