Merge "[AT-SPI] Add ScreenReaderEnabled, Disabled" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / tizen-wayland / widget-application-impl-tizen.h
1 #ifndef DALI_INTERNAL_WIDGET_APPLICATION_TIZEN_H
2 #define DALI_INTERNAL_WIDGET_APPLICATION_TIZEN_H
3
4 /*
5  * Copyright (c) 2021 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 #include <screen_connector_provider.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/devel-api/adaptor-framework/window-devel.h>
27 #include <dali/internal/adaptor/common/application-impl.h>
28 #include <dali/internal/system/common/widget-application-impl.h>
29
30 namespace Dali
31 {
32 class Widget;
33
34 namespace Internal
35 {
36 namespace Adaptor
37 {
38 class WidgetApplication;
39 typedef IntrusivePtr<WidgetApplication> WidgetApplicationPtr;
40
41 /**
42  * Implementation of the WidgetApplication class.
43  */
44 class WidgetApplicationTizen : public WidgetApplication, public ConnectionTracker
45 {
46 public:
47   typedef std::pair<const std::string, Dali::WidgetApplication::CreateWidgetFunction> CreateWidgetFunctionPair;
48   typedef std::vector<CreateWidgetFunctionPair>                                       CreateWidgetFunctionContainer;
49
50   /**
51    * Create a new widget application
52    * @param[in]  argc         A pointer to the number of arguments
53    * @param[in]  argv         A pointer to the argument list
54    * @param[in]  stylesheet   The path to user defined theme file
55    */
56   static WidgetApplicationPtr New(int* argc, char** argv[], const std::string& stylesheet);
57
58 public:
59   /**
60    * @copydoc Dali::Internal::Adaptor::Application::OnInit()
61    */
62   void OnInit() override;
63
64   /**
65    * @copydoc Dali::WidgetApplication::RegisterWidgetCreator()
66    */
67   void RegisterWidgetCreatingFunction(const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction) override;
68
69   /**
70    * Add widget name - CreateWidgetFunction pair to container.
71    */
72   void AddWidgetCreatingFunctionPair(CreateWidgetFunctionPair pair);
73
74   /**
75    * Find and get CreateWidgetFunctionPair in container by widget name.
76    */
77   CreateWidgetFunctionPair GetWidgetCreatingFunctionPair(const std::string& widgetName);
78
79   /**
80    * Add widget_base_instance_h - Widget instance pair to container.
81    */
82   void AddWidget(widget_base_instance_h widgetBaseInstance, Dali::Widget widget, Dali::Window window, const std::string& widgetId);
83
84   /**
85    * Find and get Widget instance in container by widget_base_instance_h.
86    */
87   Dali::Widget GetWidget(widget_base_instance_h widgetBaseInstance) const;
88
89   /**
90    * Delete widget_base_instance_h - Widget instance pair in container.
91    */
92   void DeleteWidget(widget_base_instance_h widgetBaseInstance);
93
94   /**
95    * Find and get Window instance in container by widget_base_instance_h.
96    */
97   Dali::Window GetWindowFromWidget(Dali::Widget widget) const;
98
99   /**
100    * Find and get widget_base_instance in container by widget id.
101    */
102   widget_base_instance_h GetWidgetInstanceFromWidgetId(std::string& widgetId) const;
103   /**
104    * Get the number of created widget.
105    */
106   int32_t GetWidgetCount();
107
108   /**
109    * @brief connect the keyEvent for window
110    *
111    * @param[in] window window for connecting keyEvent
112    */
113   void ConnectKeyEvent(Dali::Window window);
114
115   /**
116    * @brief Callback for widget window
117    *
118    * If Widget Application consume key event, this api is not called.
119    *
120    * @param[in] event The key event.
121    */
122   void OnWindowKeyEvent(const Dali::KeyEvent& event);
123
124   /**
125    * @brief Feed keyEvent to Widget.
126    *
127    * @param[in] instanceHandle the handle of widget instance
128    * @param[in] keyEvent The key event for widget
129    * @return True if widget consume keyEvent, false otherwise.
130    */
131   bool FeedKeyEvent(widget_base_instance_h instanceHandle, const Dali::KeyEvent& keyEvent);
132
133 protected:
134   /**
135    * Private Constructor
136    * @param[in]  argc         A pointer to the number of arguments
137    * @param[in]  argv         A pointer to the argument list
138    * @param[in]  stylesheet   The path to user defined theme file
139    */
140   WidgetApplicationTizen(int* argc, char** argv[], const std::string& stylesheet);
141
142   /**
143    * Destructor
144    */
145   virtual ~WidgetApplicationTizen();
146
147   WidgetApplicationTizen(const Application&) = delete;
148   WidgetApplicationTizen& operator=(Application&) = delete;
149
150 private:
151   typedef std::pair<widget_base_instance_h, Dali::Widget> WidgetInstancePair;
152   typedef std::vector<WidgetInstancePair>                 WidgetInstanceContainer;
153
154   CreateWidgetFunctionContainer mCreateWidgetFunctionContainer;
155   WidgetInstanceContainer       mWidgetInstanceContainer;
156
157   bool mConnectedKeyEvent; // Check if keyEvent is connected
158   bool mReceivedKeyEvent;  // Check if application receive keyEvent
159 };
160
161 } // namespace Adaptor
162
163 } // namespace Internal
164
165 } // namespace Dali
166
167 #endif // DALI_INTERNAL_WIDGET_APPLICATION_TIZEN_H