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 namespace Internal DALI_INTERNAL
32 class WidgetApplication;
40 * @brief An WidgetApplication class object should be created by every widget application
41 * that wishes to use Dali.
43 * It provides a means for initializing the
44 * resources required by the Dali::Core.
46 * The WidgetApplication class emits several signals which the user can
47 * connect to. The user should not create any Dali objects in the main
48 * function and instead should connect to the Init signal of the
49 * WidgetApplication and create the Dali Widget object in the connected callback.
51 * WidgetApplications should follow the example below:
55 * //Widget header which
56 * #include <my-widget.h>
58 * class ExampleController: public ConnectionTracker
61 * ExampleController( Application& application )
62 * : mWidgetApplication( application )
64 * mApplication.InitSignal().Connect( this, &ExampleController::Create );
67 * static Widget CreateWidgetFunction(const std::string& widgetName)
69 * MyWidget widget = MyWidget::New();
73 * void Create( Application& application )
75 * mApplication.RegisterWidgetCreatingFunction( "myWidget", &ExampleController::CreateWidgetFunction );
79 * WidgetApplication& mWidgetApplication;
82 * int main (int argc, char **argv)
84 * WidgetApplication app = WidgetApplication::New(&argc, &argv);
85 * ExampleController example( app );
90 * If required, you can also connect class member functions to a signal:
93 * MyWidgetApplication app;
94 * app.ResumeSignal().Connect(&app, &MyWidgetApplication::Resume);
99 class DALI_ADAPTOR_API WidgetApplication : public Application
104 * @brief This is the typedef for Widget creator.
107 typedef Widget(*CreateWidgetFunction)(const std::string&);
112 * @brief This is the constructor for WidgetApplications with a name.
115 * @param[in,out] argc A pointer to the number of arguments
116 * @param[in,out] argv A pointer to the argument list
117 * @param[in] stylesheet The path to user defined theme file
118 * @return A handle to the WidgetApplication
119 * @note If the stylesheet is not specified, then the library's default stylesheet will not be overridden.
121 static WidgetApplication New( int* argc, char **argv[], const std::string& stylesheet );
124 * @brief The default constructor.
130 * @brief Copy Constructor.
133 * @param[in] widgetApplication Handle to an object
135 WidgetApplication( const WidgetApplication& widgetApplication );
138 * @brief Assignment operator.
141 * @param[in] widgetApplication Handle to an object
142 * @return A reference to this
144 WidgetApplication& operator=( const WidgetApplication& widgetApplication );
150 ~WidgetApplication();
153 * @brief Register create function for widget.
156 * @param[in] widgetName Name of widget
157 * @param[in] createFunction Function pointer for widget creation.
159 void RegisterWidgetCreatingFunction( const std::string& widgetName, CreateWidgetFunction createFunction );
161 public: // Not intended for application developers
164 * @brief Internal constructor.
166 explicit DALI_INTERNAL WidgetApplication(Internal::Adaptor::WidgetApplication* widgetApplication);
172 #endif // DALI_WIDGET_APPLICATION_H