2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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.
18 #include <FBaseString.h>
19 #include <FGrpRectangle.h>
20 #include <FUiAccessibilityTypes.h>
21 #include <FUiIAccessibilityListener.h>
22 #include <FBaseSysLog.h>
23 #include "FUi_AccessibilityContainer.h"
24 #include "FUi_AccessibilityElementImpl.h"
25 #include "FUi_AccessibilityElement.h"
26 #include "FUi_AccessibilityManager.h"
27 #include "FUi_Control.h"
29 using namespace Tizen::Base;
30 using namespace Tizen::Graphics;
32 namespace Tizen { namespace Ui {
34 const wchar_t* _traitString[] =
36 L"",//ACCESSIBILITY_TRAITS_NONE,
37 L"TITLE",//ACCESSIBILITY_TRAITS_TITLE,
38 L"OPTION HEADER",//ACCESSIBILITY_TRAITS_OPTION_HEADER,
39 L"PICTURE",//ACCESSIBILITY_TRAITS_PICTURE,
40 L"STATUS BAR",//ACCESSIBILITY_TRAITS_STATUS_BAR,
41 L"TEXT FIELD",//ACCESSIBILITY_TRAITS_TEXT_FIELD,
42 L"RATING",//ACCESSIBILITY_TRAITS_RATING,
43 L"ACTION BAR",//ACCESSIBILITY_TRAITS_ACTION_BAR,
44 L"ACTION BAR MENU",//ACCESSIBILITY_TRAITS_ACTION_BAR_MENU,
45 L"BACK BUTTON",//ACCESSIBILITY_TRAITS_BUTTON,
46 L"BUTTON",//ACCESSIBILITY_TRAITS_BUTTON,
47 L"LABEL",//ACCESSIBILITY_TRAITS_LABEL,
48 L"LIST",//ACCESSIBILITY_TRAITS_LIST,
49 L"SELECTOR",//ACCESSIBILITY_TRAITS_DATA_SELECTOR,
50 L"SCROLL",//ACCESSIBILITY_TRAITS_DRAG_SCROLL,
51 L"EXPAND BUTTON",//ACCESSIBILITY_TRAITS_EXPAND_BUTTON,
52 L"FUNCTION PANEL",//ACCESSIBILITY_TRAITS_FUNCTION_PANEL,
53 L"IN DEPTH BUTTON",//ACCESSIBILITY_TRAITS_IN_DEPTH_BUTTON,
54 L"INDEX SCROLL",//ACCESSIBILITY_TRAITS_INDEX_SCROLL,
55 L"IMAGE",//ACCESSIBILITY_TRAITS_IMAGE
56 L"INDICATOR",//ACCESSIBILITY_TRAITS_INDICATOR,
57 L"NOTIFICATION",//ACCESSIBILITY_TRAITS_NOTIFICATION,
58 L"RADIO BUTTON",//ACCESSIBILITY_TRAITS_RADIO_BUTTON,
59 L"SCROLL BAR",//ACCESSIBILITY_TRAITS_SCROLL_BAR,
60 L"SEARCH FIELD",//ACCESSIBILITY_TRAITS_SEARCH_FIELD,
61 L"SEGMENT",//ACCESSIBILITY_TRAITS_SEGMENT,
62 L"SLIDER",//ACCESSIBILITY_TRAITS_SLIDER,
63 L"SOFT KEY",//ACCESSIBILITY_TRAITS_SOFT_KEY,
64 L"SUB MENU TITLE",//ACCESSIBILITY_TRAITS_SUB_MENU_TITLE,
65 L"TAB",//ACCESSIBILITY_TRAITS_TAB,
66 L"TICK BOX",//ACCESSIBILITY_TRAITS_TICKBOX,
67 L"TIME SELECTOR",//ACCESSIBILITY_TRAITS_TIME_SELECTOR,
68 L"VOLUME SLIDER",//ACCESSIBILITY_TRAITS_VOLUME_SLIDER,
69 L"HOUR",//ACCESSIBILITY_TRAITS_HOUR,
70 L"MINUTE",//ACCESSIBILITY_TRAITS_MINUTE,
71 L"SECOND",//ACCESSIBILITY_TRAITS_SECOND,
72 L"YEAR",//ACCESSIBILITY_TRAITS_YEAR,
73 L"MONTH",//ACCESSIBILITY_TRAITS_MONTH,
74 L"DAY",//ACCESSIBILITY_TRAITS_DAY,
75 L"END",//ACCESSIBILITY_TRAITS_END = 0xff
79 _AccessibilityElement::_AccessibilityElement(bool systemElement)
82 , __absBounds(0,0,0,0)
87 , __trait(ACCESSIBILITY_TRAITS_NONE)
91 , __systemElement(systemElement)
93 , __supportOperatingGesture(true)
96 _AccessibilityElement::~_AccessibilityElement(void)
100 static_cast<_AccessibilityElementImpl*>(__pUserData)->SetCore(null);
105 _AccessibilityElement::Construct(const String& name, const Rectangle& bounds)
108 __bounds.SetBounds(bounds.x,bounds.y,bounds.width,bounds.height);
112 _AccessibilityElement::SetName(const String& name)
117 _AccessibilityElement::SetLabel(const String& label)
122 _AccessibilityElement::SetHint(const String& hint)
127 _AccessibilityElement::SetStatus(const String& status)
132 _AccessibilityElement::SetTrait(AccessibilityTraits trait)
135 __traitString = (_traitString[__trait]);
138 _AccessibilityElement::SetTrait(const Tizen::Base::String& trait)
140 __traitString = trait;
143 _AccessibilityElement::SetParent(const _AccessibilityContainer& parent)
145 __pParent = &const_cast<_AccessibilityContainer&>(parent);
148 _AccessibilityElement::SetValue(const String& value)
152 _AccessibilityContainer*
153 _AccessibilityElement::GetParent(void) const
158 _AccessibilityElement::GetName(void) const
163 _AccessibilityElement::GetBounds(void) const
168 _AccessibilityElement::GetLabel(void) const
173 _AccessibilityElement::GetHint(void) const
178 _AccessibilityElement::GetStatus(void) const
183 _AccessibilityElement::GetTrait(void) const
188 _AccessibilityElement::GetTraitString(void) const
190 return __traitString;
193 _AccessibilityElement::GetValue(void) const
198 _AccessibilityElement::Activate(bool enable)
200 __activated = enable;
203 //__pParent->RemoveElement(*this);
208 _AccessibilityElement::IsActivated(void) const
213 _AccessibilityElement::GetReadingContents(void) const
216 if(__label.GetLength() > 0)
221 if(__traitString.GetLength() > 0)
224 out += __traitString;
227 if(__value.GetLength() > 0)
232 if(__status.GetLength() > 0)
237 if(__hint.GetLength() > 0)
242 if( __pParent->GetEnableState() == false)
245 out += L"unavailable";
251 _AccessibilityElement::SetBounds(const Rectangle& bounds)
253 __bounds.SetBounds(bounds.x,bounds.y,bounds.width,bounds.height);
254 if(__pParent && this == __pParent->GetCurrentFocusedElement())
256 _AccessibilityManager::GetInstance()->RequestToDrawFocusUi();
260 _AccessibilityElement::GetAbsoluteBounds(void) const
262 Rectangle controlAbsBounds = GetParent()->GetOwner().GetAbsoluteBounds();
263 Rectangle rect(controlAbsBounds.x+__bounds.x, controlAbsBounds.y+__bounds.y, __bounds.width, __bounds.height);
264 const_cast<Rectangle&>(__absBounds).SetBounds(controlAbsBounds.x+__bounds.x, controlAbsBounds.y+__bounds.y, __bounds.width, __bounds.height);
268 _AccessibilityElement::SetSupportOperatingGesture(bool set)
270 __supportOperatingGesture = set;
273 _AccessibilityElement::GetSupportOperatingGesture(void)
275 return __supportOperatingGesture;
278 _AccessibilityElement::GetUserData(void) const
284 _AccessibilityElement::SetUserData(void* pUserData)
286 __pUserData = pUserData;
289 _AccessibilityElement::IsSystemElement(void)
291 return __systemElement;