Merge "Set proper locale to harfbuzz" into devel/master
[platform/core/uifw/dali-adaptor.git] / adaptors / public-api / adaptor-framework / widget-application.h
1 #ifndef DALI_WIDGET_APPLICATION_H
2 #define DALI_WIDGET_APPLICATION_H
3
4 /*
5  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #ifdef DALI_ADAPTOR_COMPILATION  // full path doesn't exist until adaptor is installed so we have to use relative
23 #include <application.h>
24 #else
25 #include <dali/public-api/adaptor-framework/application.h>
26 #endif
27 namespace Dali
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32
33 namespace Adaptor
34 {
35 class WidgetApplication;
36 }
37
38 }
39
40 class Widget;
41
42 /**
43  * @brief An WidgetApplication class object should be created by every widget application
44  * that wishes to use Dali.
45  *
46  * It provides a means for initializing the
47  * resources required by the Dali::Core.
48  *
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.
53  *
54  * WidgetApplications should follow the example below:
55  *
56  * @code
57  *
58  * //Widget header which
59  * #include <my-widget.h>
60  *
61  * class ExampleController: public ConnectionTracker
62  * {
63  * public:
64  *   ExampleController( Application& application )
65  *   : mWidgetApplication( application )
66  *   {
67  *     mApplication.InitSignal().Connect( this, &ExampleController::Create );
68  *   }
69  *
70  *   static Widget CreateWidgetFunction(const std::string& widgetName)
71  *   {
72  *     MyWidget widget = MyWidget::New();
73  *     return widget;
74  *   }
75  *
76  *   void Create( Application& application )
77  *   {
78  *     mApplication.RegisterWidgetCreatingFunction( "myWidget", &ExampleController::CreateWidgetFunction );
79  *   }
80  *
81  * private:
82  *   WidgetApplication& mWidgetApplication;
83  * };
84  *
85  * int main (int argc, char **argv)
86  * {
87  *   WidgetApplication app = WidgetApplication::New(&argc, &argv);
88  *   ExampleController example( app );
89  *   app.MainLoop();
90  * }
91  * @endcode
92  *
93  * If required, you can also connect class member functions to a signal:
94  *
95  * @code
96  * MyWidgetApplication app;
97  * app.ResumeSignal().Connect(&app, &MyWidgetApplication::Resume);
98  * @endcode
99  *
100  * @SINCE_1_3_5
101  */
102 class DALI_IMPORT_API WidgetApplication : public Application
103 {
104 public:
105
106   /**
107    * @brief This is the typedef for Widget creator.
108    * @SINCE_1_3_5
109    */
110   typedef Widget(*CreateWidgetFunction)(const std::string&);
111
112 public:
113
114   /**
115    * @brief This is the constructor for WidgetApplications with a name.
116    *
117    * @SINCE_1_3_5
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.
123    */
124   static WidgetApplication New( int* argc, char **argv[], const std::string& stylesheet );
125
126   /**
127    * @brief The default constructor.
128    * @SINCE_1_3_5
129    */
130   WidgetApplication();
131
132   /**
133    * @brief Copy Constructor.
134    *
135    * @SINCE_1_3_5
136    * @param[in] widgetApplication Handle to an object
137    */
138   WidgetApplication( const WidgetApplication& widgetApplication );
139
140   /**
141    * @brief Assignment operator.
142    *
143    * @SINCE_1_3_5
144    * @param[in] widgetApplication Handle to an object
145    * @return A reference to this
146    */
147   WidgetApplication& operator=( const WidgetApplication& widgetApplication );
148
149  /**
150    * @brief Destructor
151    * @SINCE_1_3_5
152    */
153   ~WidgetApplication();
154
155   /**
156    * @brief Register create function for widget.
157    *
158    * @SINCE_1_3_5
159    * @param[in] widgetName  Name of widget
160    * @param[in] createFunction     Function pointer for widget creation.
161    */
162   void RegisterWidgetCreatingFunction( const std::string& widgetName, CreateWidgetFunction createFunction );
163
164 public: // Not intended for application developers
165   /// @cond internal
166   /**
167    * @brief Internal constructor.
168    */
169   explicit DALI_INTERNAL WidgetApplication(Internal::Adaptor::WidgetApplication* widgetApplication);
170   /// @endcond
171 };
172
173 } // namespace Dali
174
175 #endif // DALI_WIDGET_APPLICATION_H