apply doxygen review
[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 Flora License, Version 1.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://floralicense.org/license/
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 accessibility element.
54 * @since                2.0
55 *
56 *
57 * @final                This class is not intended for extension.
58 * This class represents a container for accessibility element.
59  * The following example demonstrates how to use the %AccessibilityContainer class.
60 .*
61  * @code
62 // Sample code for AccessibilitySample.h
63 #include <FGraphics.h>
64 #include <FUi.h>
65
66 class AccessibilitySample 
67         : public Tizen::Ui::Controls::Form
68 {
69 public:
70         AccessibilitySample(void);
71         virtual ~AccessibilitySample(void);
72
73         result Initialize(void);
74
75         virtual result OnInitializing(void);
76
77
78 private:
79         static const int ID_FOOTER_ITEM1 = 101;
80         static const int ID_FOOTER_ITEM2 = 102;
81
82         Tizen::Graphics::Bitmap *__pTizenBitmap;
83 };
84
85  *      @endcode
86  *
87  *      @code
88
89 // Sample code for AccessibilitySample.cpp
90 #include "FApp.h"
91 #include "FMedia.h"
92 #include "AccessibilitySample.h"
93
94 using namespace Tizen::App;
95 using namespace Tizen::Base;
96 using namespace Tizen::Graphics;
97 using namespace Tizen::Media;
98 using namespace Tizen::Ui;
99 using namespace Tizen::Ui::Controls;
100
101 AccessibilitySample::AccessibilitySample(void)
102         : __pTizenBitmap(null)
103 {
104 }
105
106 AccessibilitySample::~AccessibilitySample(void)
107 {
108         delete __pTizenBitmap;
109         __pTizenBitmap = null;
110 }
111
112 result
113 AccessibilitySample::Initialize(void)
114 {
115         Image image;
116         result r = Form::Construct(FORM_STYLE_NORMAL| FORM_STYLE_INDICATOR| FORM_STYLE_HEADER| FORM_STYLE_FOOTER);
117         r = image.Construct();
118         String filepath = App::GetInstance()->GetAppResourcePath() + L"screen-density-xhigh/tizen.png";
119
120         __pTizenBitmap = image.DecodeN(filepath, BITMAP_PIXEL_FORMAT_ARGB8888);
121         return r;
122 }
123
124 result
125 AccessibilitySample::OnInitializing(void)
126 {
127         result r = E_SUCCESS;
128
129         Header * pHeader = GetHeader();
130         if (pHeader != null)
131         {
132                 pHeader->SetStyle(HEADER_STYLE_TITLE);
133                 pHeader->SetTitleText(L"Accessibility Sample");
134         }
135
136         //Draw Image
137         Canvas* pCanvas = GetCanvasN();
138         Rectangle rt = pCanvas->GetBounds();
139         int width = rt.width;
140         int height = rt.width * __pTizenBitmap->GetHeight() / __pTizenBitmap->GetWidth();
141         r = pCanvas->DrawBitmap(Rectangle(rt.x, (rt.y + ( (rt.height - height) / 2)), width, height), *__pTizenBitmap);
142
143         //Make accessibility element for drawn image.
144         AccessibilityElement* pAccessibilityElement = new AccessibilityElement();
145         r = pAccessibilityElement->Construct(GetBounds(), L"Tizen Image");
146         pAccessibilityElement->SetLabel(L"Tizen Image");
147         pAccessibilityElement->SetTrait(L"Image");
148         pAccessibilityElement->SetHint(L"This image rotates automatically.");
149         GetAccessibilityContainer()->AddElement(*pAccessibilityElement);
150         pAccessibilityElement->SetBounds(Rectangle(rt.x, (rt.y + ( (rt.height - height) / 2)), width, height));
151
152         Footer* pFooter = GetFooter();
153         if (pFooter != null)
154         {
155                 pFooter->SetStyle(FOOTER_STYLE_TAB);
156
157                 FooterItem footerItem1;
158                 footerItem1.Construct(ID_FOOTER_ITEM1);
159                 footerItem1.SetText(L"Item1");
160                 pFooter->AddItem(footerItem1);
161
162                 FooterItem footerItem2;
163                 footerItem2.Construct(ID_FOOTER_ITEM2);
164                 footerItem2.SetText(L"Item2");
165                 pFooter->AddItem(footerItem2);
166
167                 //Set information to system accessibility element.
168                 AccessibilityContainer* pContainer = pFooter->GetAccessibilityContainer();
169                 AccessibilityElement* pElement = pContainer->GetElement(L"Tab2Text");
170                 pElement->SetHint(L"Test accessibility");
171         }
172         delete pCanvas;
173         Invalidate(true);
174         return r;
175 }
176  * @endcode
177  *
178  */
179
180 class _OSP_EXPORT_ AccessibilityContainer
181         : public Tizen::Base::Object
182 {
183 public:
184         /**
185         * Gets the owner of the accessibility container
186         *
187         * @since                2.0
188         * @return       The control which owns this %AccessibilityContainer
189         * @see          Control::GetAccessibilityContainer()
190         */
191         const Control* GetOwner(void) const;
192
193         /**
194         * Gets the owner of the accessibility container
195         *
196         * @since                2.0
197         * @return       The control which owns this %AccessibilityContainer
198         * @see          Control::GetAccessibilityContainer()
199         */
200         Control* GetOwner(void);
201
202         /**
203         * Adds the IAccessibilityListener instance to the %AccessibilityContainer. @n
204         * The added listener gets notified when the accessibility status is changed.
205         *
206         * @since                2.0
207         * @return An error code
208         * @param[in] listener   The event listener to add
209         * @exception E_SUCCESS  The method is successful.
210         * @exception E_OBJ_ALREADY_EXIST        The instance of IAccessibilityListener is already registered.
211         * @see          RemoveAccessibilityListener()
212         */
213         result AddAccessibilityListener(IAccessibilityListener& listener);
214
215         /**
216         * Removes the IAccessibilityListener listener instance. @n
217         * The removed listener is not notified even when the accessibility status is changed.
218         *
219         *
220         * @since                2.0
221         * @return An error code
222         * @param[in] listener   The listener to remove
223         * @exception E_SUCCESS  The method is successful.
224         * @exception E_OBJ_NOT_FOUND    The instance of listener is not found.
225         * @see          AddAccessibilityListener()
226         */
227         result RemoveAccessibilityListener(IAccessibilityListener& listener);
228
229         /**
230         * Adds the accessibility element to the %AccessibilityContainer.
231         *
232         * @since                2.0
233         * @return An error code
234         * @param[in] element    The instance of AccessibilityElement
235         * @exception E_SUCCESS  The method is successful.
236         * @exception E_OBJ_ALREADY_EXIST        The instance of AccessibilityElement is already registered.
237         * @see          RemoveElement()
238         * @see          RemoveAllElements()
239         *
240         */
241         result AddElement(AccessibilityElement& element);
242
243         /**
244         * Removes the accessibility element in the %AccessibilityContainer.
245         *
246         * @since                2.0
247         *
248         * @return An error code
249         *
250         * @param[in] element    The instance of AccessibilityElement
251         *
252         * @exception E_SUCCESS  The method is successful.
253         * @exception E_OBJ_NOT_FOUND    The instance of AccessibilityElement is already registered.
254         * @see          AddElement()
255         *
256         */
257         result RemoveElement(AccessibilityElement& element);
258
259         /**
260         * Removes all of the accessibility elements in the %AccessibilityContainer.
261         *
262         * @since                2.0
263         *
264         * @see          AddElement()
265         *
266         */
267         void RemoveAllElements(void);
268
269         /**
270         * Gets the instance of accessibility element which is the child of the %AccessibilityContainer by the name.
271         *
272         * @since                2.0
273         *
274         * @return       The instance of child element, if there exists an element which has the given name @n
275         *                       else @c null
276         *
277         * @param[in] name The name of AccessibilityElement
278         *
279         */
280         AccessibilityElement* GetElement(const Tizen::Base::String& name) const;
281
282         /**
283         * Gets the list of accessibility elements that are the child of the %AccessibilityContainer.
284         *
285         * @since                2.0
286         *
287         * @return       The list of child element, if there exists some elements in the container. @n
288         *                       else @c null.
289         *
290         */
291         Tizen::Base::Collection::IList* GetElementsN(void) const;
292
293 private:
294         //
295         // This default constructor is intentionally declared as private so that only the platform can create an instance
296         //
297         AccessibilityContainer(void);
298
299         //
300         // This destructor is intentionally declared as private so that only the platform can delete an instance.
301         //
302         virtual ~AccessibilityContainer(void);
303
304         //
305         // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
306         //
307         AccessibilityContainer(const AccessibilityContainer& rhs);
308
309         //
310         // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
311         //
312         AccessibilityContainer& operator =(const AccessibilityContainer& rhs);
313
314 private:
315         _AccessibilityContainerImpl* __pAccessibilityContainerImpl;
316         friend class _AccessibilityContainerImpl;
317 }; // AccessibilityContainer
318
319 }} // Tizen::Ui
320 #endif //_FUI_ACCESSIBILITY_CONTAINER_H_