2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0/
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.
19 * @file FUiAccessibilityContainer.h
20 * @brief This is the header file for the AccessibilityContainer class.
22 * This header file contains the declarations of the AccessibilityContainer class.
25 #ifndef _FUI_ACCESSIBILITY_CONTAINER_H_
26 #define _FUI_ACCESSIBILITY_CONTAINER_H_
28 #include <FOspConfig.h>
29 #include <FBaseObject.h>
30 #include <FUiAccessibilityTypes.h>
32 namespace Tizen { namespace Base
37 namespace Tizen { namespace Base { namespace Collection
40 }}} //Tizen::Base::Collection
43 namespace Tizen { namespace Ui
47 class AccessibilityElement;
48 class IAccessibilityListener;
49 class _AccessibilityContainerImpl;
52 * @class AccessibilityContainer
53 * @brief This class represents a container for an accessibility element.
57 * @final This class is not intended for extension.
59 * This class represents a container for an accessibility element. @n
60 * The following example demonstrates how to use the %AccessibilityContainer class.
63 // Sample code for AccessibilitySample.h
64 #include <FGraphics.h>
67 class AccessibilitySample
68 : public Tizen::Ui::Controls::Form
71 AccessibilitySample(void);
72 virtual ~AccessibilitySample(void);
74 result Initialize(void);
76 virtual result OnInitializing(void);
80 static const int ID_FOOTER_ITEM1 = 101;
81 static const int ID_FOOTER_ITEM2 = 102;
83 Tizen::Graphics::Bitmap *__pTizenBitmap;
86 // Sample code for AccessibilitySample.cpp
89 #include "AccessibilitySample.h"
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;
98 AccessibilitySample::AccessibilitySample(void)
99 : __pTizenBitmap(null)
103 AccessibilitySample::~AccessibilitySample(void)
105 delete __pTizenBitmap;
106 __pTizenBitmap = null;
110 AccessibilitySample::Initialize(void)
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";
117 __pTizenBitmap = image.DecodeN(filepath, BITMAP_PIXEL_FORMAT_ARGB8888);
122 AccessibilitySample::OnInitializing(void)
124 result r = E_SUCCESS;
126 Header * pHeader = GetHeader();
129 pHeader->SetStyle(HEADER_STYLE_TITLE);
130 pHeader->SetTitleText(L"Accessibility Sample");
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);
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));
149 Footer* pFooter = GetFooter();
152 pFooter->SetStyle(FOOTER_STYLE_TAB);
154 FooterItem footerItem1;
155 footerItem1.Construct(ID_FOOTER_ITEM1);
156 footerItem1.SetText(L"Item1");
157 pFooter->AddItem(footerItem1);
159 FooterItem footerItem2;
160 footerItem2.Construct(ID_FOOTER_ITEM2);
161 footerItem2.SetText(L"Item2");
162 pFooter->AddItem(footerItem2);
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");
177 class _OSP_EXPORT_ AccessibilityContainer
178 : public Tizen::Base::Object
182 * Gets the owner of the accessibility container
185 * @return A pointer to the control which owns this %AccessibilityContainer @n
186 * It cannot be @c null.
187 * @see Control::GetAccessibilityContainer()
189 const Control* GetOwner(void) const;
192 * Gets the owner of the accessibility container
195 * @return A pointer to the control which owns this %AccessibilityContainer @n
196 * It cannot be @c null.
197 * @see Control::GetAccessibilityContainer()
199 Control* GetOwner(void);
202 * Adds the IAccessibilityListener instance to the %AccessibilityContainer. @n
203 * The added listener gets notified when the accessibility status has been changed.
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()
212 result AddAccessibilityListener(IAccessibilityListener& listener);
215 * Removes the IAccessibilityListener listener instance. @n
216 * The removed listener is not notified even when the accessibility status has been changed.
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()
225 result RemoveAccessibilityListener(IAccessibilityListener& listener);
228 * Adds the accessibility element to the %AccessibilityContainer.
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()
239 result AddElement(AccessibilityElement& element);
242 * Removes the accessibility element in the %AccessibilityContainer.
246 * @return An error code
248 * @param[in] element The instance of AccessibilityElement
250 * @exception E_SUCCESS The method is successful.
251 * @exception E_OBJ_NOT_FOUND The instance of AccessibilityElement is not found.
255 result RemoveElement(AccessibilityElement& element);
258 * Removes all of the accessibility elements in the %AccessibilityContainer.
265 void RemoveAllElements(void);
268 * Gets the instance of the accessibility element which is the child of the %AccessibilityContainer by the name.
272 * @return The instance to the child element, if there exists an element which has the given name, @n
275 * @param[in] name The name of AccessibilityElement
278 AccessibilityElement* GetElement(const Tizen::Base::String& name) const;
281 * Gets the list of accessibility elements that are the child of the %AccessibilityContainer.
285 * @return A pointer to the list of the child element, if there exists some elements in the container, @n
288 Tizen::Base::Collection::IList* GetElementsN(void) const;
292 // This default constructor is intentionally declared as private so that only the platform can create an instance
294 AccessibilityContainer(void);
297 // This destructor is intentionally declared as private so that only the platform can delete an instance.
299 virtual ~AccessibilityContainer(void);
302 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
304 AccessibilityContainer(const AccessibilityContainer& rhs);
307 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
309 AccessibilityContainer& operator =(const AccessibilityContainer& rhs);
312 _AccessibilityContainerImpl* __pAccessibilityContainerImpl;
313 friend class _AccessibilityContainerImpl;
314 }; // AccessibilityContainer
317 #endif //_FUI_ACCESSIBILITY_CONTAINER_H_