Merge "Set proper locale to harfbuzz" into devel/master
[platform/core/uifw/dali-adaptor.git] / adaptors / tizen / widget-application-impl.h
1 #ifndef DALI_INTERNAL_WIDGET_APPLICATION_H
2 #define DALI_INTERNAL_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 // EXTERNAL INCLUDES
22 #ifdef WIDGET_SUPPOERTED
23 #include <widget_base.h>
24 #endif
25
26 // INTERNAL INCLUDES
27 #include <application-impl.h>
28 #include <widget-application.h>
29
30 namespace Dali
31 {
32 class Widget;
33
34 namespace Internal
35 {
36
37 namespace Adaptor
38 {
39
40 class WidgetApplication;
41 typedef IntrusivePtr<WidgetApplication> WidgetApplicationPtr;
42
43 /**
44  * Implementation of the WidgetApplication class.
45  */
46 class WidgetApplication : public Application
47 {
48 public:
49
50 #ifndef WIDGET_SUPPOERTED
51   typedef void* widget_base_instance_h;
52 #endif
53   typedef std::pair<const std::string, Dali::WidgetApplication::CreateWidgetFunction >  CreateWidgetFunctionPair;
54   typedef std::vector< CreateWidgetFunctionPair >   CreateWidgetFunctionContainer;
55
56   /**
57    * Create a new widget application
58    * @param[in]  argc         A pointer to the number of arguments
59    * @param[in]  argv         A pointer to the argument list
60    * @param[in]  stylesheet   The path to user defined theme file
61    */
62   static WidgetApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet );
63
64 public:
65
66   /**
67    * @copydoc Dali::WidgetApplication::RegisterWidgetCreator()
68    */
69   void RegisterWidgetCreatingFunction( const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction );
70
71   /**
72    * Add widget name - CreateWidgetFunction pair to container.
73    */
74   void AddWidgetCreatingFunctionPair( CreateWidgetFunctionPair pair );
75
76   /**
77    * Find and get CreateWidgetFunctionPair in container by widget name.
78    */
79   CreateWidgetFunctionPair GetWidgetCreatingFunctionPair( const std::string& widgetName );
80
81   /**
82    * Add widget_base_instance_h - Widget instance pair to container.
83    */
84   void AddWidget( widget_base_instance_h widgetBaseInstance, Dali::Widget widget );
85
86   /**
87    * Find and get Widget instance in container by widget_base_instance_h.
88    */
89   Dali::Widget GetWidget( widget_base_instance_h widgetBaseInstance );
90
91   /**
92    * Delete widget_base_instance_h - Widget instance pair in container.
93    */
94   void DeleteWidget( widget_base_instance_h widgetBaseInstance );
95
96 protected:
97
98   /**
99    * Private Constructor
100    * @param[in]  argc         A pointer to the number of arguments
101    * @param[in]  argv         A pointer to the argument list
102    * @param[in]  stylesheet   The path to user defined theme file
103    */
104   WidgetApplication( int* argc, char **argv[], const std::string& stylesheet );
105
106   /**
107    * Destructor
108    */
109   virtual ~WidgetApplication();
110
111   // Undefined
112   WidgetApplication(const Application&);
113   WidgetApplication& operator=(Application&);
114
115 private:
116
117   typedef std::pair< widget_base_instance_h, Dali::Widget > WidgetInstancePair;
118   typedef std::vector< WidgetInstancePair >                 WidgetInstanceContainer;
119
120   CreateWidgetFunctionContainer  mCreateWidgetFunctionContainer;
121   WidgetInstanceContainer        mWidgetInstanceContainer;
122
123 };
124
125 inline WidgetApplication& GetImplementation(Dali::WidgetApplication& widgetApplication)
126 {
127   DALI_ASSERT_ALWAYS(widgetApplication && "widget application handle is empty");
128
129   BaseObject& handle = widgetApplication.GetBaseObject();
130
131   return static_cast<Internal::Adaptor::WidgetApplication&>(handle);
132 }
133
134 inline const WidgetApplication& GetImplementation(const Dali::WidgetApplication& widgetApplication)
135 {
136   DALI_ASSERT_ALWAYS(widgetApplication && "widget application handle is empty");
137
138   const BaseObject& handle = widgetApplication.GetBaseObject();
139
140   return static_cast<const Internal::Adaptor::WidgetApplication&>(handle);
141 }
142
143 } // namespace Adaptor
144
145 } // namespace Internal
146
147 } // namespace Dali
148
149 #endif // DALI_INTERNAL_WIDGET_APPLICATION_H