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