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