N_SE-47263 : reset touch cancel when indicator touch released/N_SE-51832 : fix checki...
[platform/framework/native/uifw.git] / inc / FUiAccessibilityContainer.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file         FUiAccessibilityContainer.h
20  * @brief         This is the header file for the AccessibilityContainer class.
21  *
22  * This header file contains the declarations of the AccessibilityContainer class.
23  */
24
25 #ifndef _FUI_ACCESSIBILITY_CONTAINER_H_
26 #define _FUI_ACCESSIBILITY_CONTAINER_H_
27
28 #include <FOspConfig.h>
29 #include <FBaseObject.h>
30 #include <FUiAccessibilityTypes.h>
31
32 namespace Tizen { namespace Base
33 {
34 class String;
35 }} // Tizen::Base
36
37 namespace Tizen { namespace Base { namespace Collection
38 {
39 class IList;
40 }}} //Tizen::Base::Collection
41
42
43 namespace Tizen { namespace Ui
44 {
45
46 class Control;
47 class AccessibilityElement;
48 class IAccessibilityListener;
49 class _AccessibilityContainerImpl;
50
51 /**
52 * @class                AccessibilityContainer
53 * @brief                This class represents a container for an accessibility element.
54 * @since                2.0
55 *
56 *
57 * @final                This class is not intended for extension.
58 *
59 * This class represents a container for an accessibility element. @n
60 * The following example demonstrates how to use the %AccessibilityContainer class.
61 *
62 * @code
63 // Sample code for AccessibilitySample.h
64 #include <FGraphics.h>
65 #include <FUi.h>
66
67 class AccessibilitySample
68         : public Tizen::Ui::Controls::Form
69 {
70 public:
71         AccessibilitySample(void);
72         virtual ~AccessibilitySample(void);
73
74         result Initialize(void);
75
76         virtual result OnInitializing(void);
77
78
79 private:
80         static const int ID_FOOTER_ITEM1 = 101;
81         static const int ID_FOOTER_ITEM2 = 102;
82
83         Tizen::Graphics::Bitmap *__pTizenBitmap;
84 };
85
86 // Sample code for AccessibilitySample.cpp
87 #include "FApp.h"
88 #include "FMedia.h"
89 #include "AccessibilitySample.h"
90
91 using namespace Tizen::App;
92 using namespace Tizen::Base;
93 using namespace Tizen::Graphics;
94 using namespace Tizen::Media;
95 using namespace Tizen::Ui;
96 using namespace Tizen::Ui::Controls;
97
98 AccessibilitySample::AccessibilitySample(void)
99         : __pTizenBitmap(null)
100 {
101 }
102
103 AccessibilitySample::~AccessibilitySample(void)
104 {
105         delete __pTizenBitmap;
106         __pTizenBitmap = null;
107 }
108
109 result
110 AccessibilitySample::Initialize(void)
111 {
112         Image image;
113         result r = Form::Construct(FORM_STYLE_NORMAL| FORM_STYLE_PORTRAIT_INDICATOR| FORM_STYLE_HEADER| FORM_STYLE_FOOTER);
114         r = image.Construct();
115         String filepath = App::GetInstance()->GetAppResourcePath() + L"screen-density-xhigh/tizen.png";
116
117         __pTizenBitmap = image.DecodeN(filepath, BITMAP_PIXEL_FORMAT_ARGB8888);
118         return r;
119 }
120
121 result
122 AccessibilitySample::OnInitializing(void)
123 {
124         result r = E_SUCCESS;
125
126         Header * pHeader = GetHeader();
127         if (pHeader != null)
128         {
129                 pHeader->SetStyle(HEADER_STYLE_TITLE);
130                 pHeader->SetTitleText(L"Accessibility Sample");
131         }
132
133         //Draws an image
134         Canvas* pCanvas = GetCanvasN();
135         Rectangle rt = pCanvas->GetBounds();
136         int width = rt.width;
137         int height = rt.width * __pTizenBitmap->GetHeight() / __pTizenBitmap->GetWidth();
138         r = pCanvas->DrawBitmap(Rectangle(rt.x, (rt.y + ( (rt.height - height) / 2)), width, height), *__pTizenBitmap);
139
140         //Makes an accessibility element for the drawn image
141         AccessibilityElement* pAccessibilityElement = new AccessibilityElement();
142         r = pAccessibilityElement->Construct(GetBounds(), L"Tizen Image");
143         pAccessibilityElement->SetLabel(L"Tizen Image");
144         pAccessibilityElement->SetTrait(L"Image");
145         pAccessibilityElement->SetHint(L"This image rotates automatically.");
146         GetAccessibilityContainer()->AddElement(*pAccessibilityElement);
147         pAccessibilityElement->SetBounds(Rectangle(rt.x, (rt.y + ( (rt.height - height) / 2)), width, height));
148
149         Footer* pFooter = GetFooter();
150         if (pFooter != null)
151         {
152                 pFooter->SetStyle(FOOTER_STYLE_TAB);
153
154                 FooterItem footerItem1;
155                 footerItem1.Construct(ID_FOOTER_ITEM1);
156                 footerItem1.SetText(L"Item1");
157                 pFooter->AddItem(footerItem1);
158
159                 FooterItem footerItem2;
160                 footerItem2.Construct(ID_FOOTER_ITEM2);
161                 footerItem2.SetText(L"Item2");
162                 pFooter->AddItem(footerItem2);
163
164                 //Sets an information to the system accessibility element
165                 AccessibilityContainer* pContainer = pFooter->GetAccessibilityContainer();
166                 AccessibilityElement* pElement = pContainer->GetElement(L"Tab2Text");
167                 pElement->SetHint(L"Test accessibility");
168         }
169         delete pCanvas;
170         Invalidate(true);
171         return r;
172 }
173  * @endcode
174  *
175  */
176
177 class _OSP_EXPORT_ AccessibilityContainer
178         : public Tizen::Base::Object
179 {
180 public:
181         /**
182         * Gets the owner of the accessibility container
183         *
184         * @since                2.0
185         * @return       A pointer to the control which owns this %AccessibilityContainer @n
186         *                       It cannot be @c null.
187         * @see          Control::GetAccessibilityContainer()
188         */
189         const Control* GetOwner(void) const;
190
191         /**
192         * Gets the owner of the accessibility container
193         *
194         * @since                2.0
195         * @return       A pointer to the control which owns this %AccessibilityContainer @n
196         *                       It cannot be @c null.
197         * @see          Control::GetAccessibilityContainer()
198         */
199         Control* GetOwner(void);
200
201         /**
202         * Adds the IAccessibilityListener instance to the %AccessibilityContainer. @n
203         * The added listener gets notified when the accessibility status has been changed.
204         *
205         * @since                2.0
206         * @return An error code
207         * @param[in] listener   The event listener to add
208         * @exception E_SUCCESS  The method is successful.
209         * @exception E_OBJ_ALREADY_EXIST        The instance of IAccessibilityListener is already registered.
210         * @see          RemoveAccessibilityListener()
211         */
212         result AddAccessibilityListener(IAccessibilityListener& listener);
213
214         /**
215         * Removes the IAccessibilityListener listener instance. @n
216         * The removed listener is not notified even when the accessibility status has been changed.
217         *
218         * @since                2.0
219         * @return An error code
220         * @param[in] listener   The listener to remove
221         * @exception E_SUCCESS  The method is successful.
222         * @exception E_OBJ_NOT_FOUND    The instance of listener is not found.
223         * @see          AddAccessibilityListener()
224         */
225         result RemoveAccessibilityListener(IAccessibilityListener& listener);
226
227         /**
228         * Adds the accessibility element to the %AccessibilityContainer.
229         *
230         * @since                2.0
231         * @return An error code
232         * @param[in] element    The instance of AccessibilityElement
233         * @exception E_SUCCESS  The method is successful.
234         * @exception E_OBJ_ALREADY_EXIST        The instance of AccessibilityElement is already registered.
235         * @see          RemoveElement()
236         * @see          RemoveAllElements()
237         *
238         */
239         result AddElement(AccessibilityElement& element);
240
241         /**
242         * Removes the accessibility element in the %AccessibilityContainer.
243         *
244         * @since                2.0
245         *
246         * @return An error code
247         *
248         * @param[in] element    The instance of AccessibilityElement
249         *
250         * @exception E_SUCCESS  The method is successful.
251         * @exception E_OBJ_NOT_FOUND    The instance of AccessibilityElement is not found.
252         * @see          AddElement()
253         *
254         */
255         result RemoveElement(AccessibilityElement& element);
256
257         /**
258         * Removes all of the accessibility elements in the %AccessibilityContainer.
259         *
260         * @since                2.0
261         *
262         * @see          AddElement()
263         *
264         */
265         void RemoveAllElements(void);
266
267         /**
268         * Gets the instance of the accessibility element which is the child of the %AccessibilityContainer by the name.
269         *
270         * @since                2.0
271         *
272         * @return       The instance to the child element, if there exists an element which has the given name, @n
273         *                       else @c null
274         *
275         * @param[in] name The name of AccessibilityElement
276         *
277         */
278         AccessibilityElement* GetElement(const Tizen::Base::String& name) const;
279
280         /**
281         * Gets the list of accessibility elements that are the child of the %AccessibilityContainer.
282         *
283         * @since                2.0
284         *
285         * @return       A pointer to the list of the child element, if there exists some elements in the container, @n
286         *                       else @c null
287         */
288         Tizen::Base::Collection::IList* GetElementsN(void) const;
289
290 private:
291         //
292         // This default constructor is intentionally declared as private so that only the platform can create an instance
293         //
294         AccessibilityContainer(void);
295
296         //
297         // This destructor is intentionally declared as private so that only the platform can delete an instance.
298         //
299         virtual ~AccessibilityContainer(void);
300
301         //
302         // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
303         //
304         AccessibilityContainer(const AccessibilityContainer& rhs);
305
306         //
307         // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
308         //
309         AccessibilityContainer& operator =(const AccessibilityContainer& rhs);
310
311 private:
312         _AccessibilityContainerImpl* __pAccessibilityContainerImpl;
313         friend class _AccessibilityContainerImpl;
314 }; // AccessibilityContainer
315
316 }} // Tizen::Ui
317 #endif //_FUI_ACCESSIBILITY_CONTAINER_H_