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 <FUiAccessibilityTypes.h>
20 #include <FUiIAccessibilityListener.h>
21 #include <FBaseSysLog.h>
22 #include "FUi_AccessibilityContainer.h"
23 #include "FUi_AccessibilityElementImpl.h"
24 #include "FUi_AccessibilityElement.h"
25 #include "FUi_AccessibilityManager.h"
26 #include "FUi_Control.h"
28 using namespace Tizen::Base;
29 using namespace Tizen::Graphics;
31 namespace Tizen { namespace Ui {
33 const wchar_t* _traitString[] =
35 L"",//ACCESSIBILITY_TRAITS_NONE,
36 L"TITLE",//ACCESSIBILITY_TRAITS_TITLE,
37 L"OPTION HEADER",//ACCESSIBILITY_TRAITS_OPTION_HEADER,
38 L"PICTURE",//ACCESSIBILITY_TRAITS_PICTURE,
39 L"STATUS BAR",//ACCESSIBILITY_TRAITS_STATUS_BAR,
40 L"TEXT FIELD",//ACCESSIBILITY_TRAITS_TEXT_FIELD,
41 L"RATING",//ACCESSIBILITY_TRAITS_RATING,
42 L"ACTION BAR",//ACCESSIBILITY_TRAITS_ACTION_BAR,
43 L"ACTION BAR MENU",//ACCESSIBILITY_TRAITS_ACTION_BAR_MENU,
44 L"BACK BUTTON",//ACCESSIBILITY_TRAITS_BUTTON,
45 L"BUTTON",//ACCESSIBILITY_TRAITS_BUTTON,
46 L"LABEL",//ACCESSIBILITY_TRAITS_LABEL,
47 L"LIST",//ACCESSIBILITY_TRAITS_LIST,
48 L"SELECTOR",//ACCESSIBILITY_TRAITS_DATA_SELECTOR,
49 L"SCROLL",//ACCESSIBILITY_TRAITS_DRAG_SCROLL,
50 L"EXPAND BUTTON",//ACCESSIBILITY_TRAITS_EXPAND_BUTTON,
51 L"FUNCTION PANEL",//ACCESSIBILITY_TRAITS_FUNCTION_PANEL,
52 L"IN DEPTH BUTTON",//ACCESSIBILITY_TRAITS_IN_DEPTH_BUTTON,
53 L"INDEX SCROLL",//ACCESSIBILITY_TRAITS_INDEX_SCROLL,
54 L"IMAGE",//ACCESSIBILITY_TRAITS_IMAGE
55 L"INDICATOR",//ACCESSIBILITY_TRAITS_INDICATOR,
56 L"NOTIFICATION",//ACCESSIBILITY_TRAITS_NOTIFICATION,
57 L"RADIO BUTTON",//ACCESSIBILITY_TRAITS_RADIO_BUTTON,
58 L"SCROLL BAR",//ACCESSIBILITY_TRAITS_SCROLL_BAR,
59 L"SEARCH FIELD",//ACCESSIBILITY_TRAITS_SEARCH_FIELD,
60 L"SEGMENT",//ACCESSIBILITY_TRAITS_SEGMENT,
61 L"SLIDER",//ACCESSIBILITY_TRAITS_SLIDER,
62 L"SOFT KEY",//ACCESSIBILITY_TRAITS_SOFT_KEY,
63 L"SUB MENU TITLE",//ACCESSIBILITY_TRAITS_SUB_MENU_TITLE,
64 L"TAB",//ACCESSIBILITY_TRAITS_TAB,
65 L"TICK BOX",//ACCESSIBILITY_TRAITS_TICKBOX,
66 L"TIME SELECTOR",//ACCESSIBILITY_TRAITS_TIME_SELECTOR,
67 L"VOLUME SLIDER",//ACCESSIBILITY_TRAITS_VOLUME_SLIDER,
68 L"HOUR",//ACCESSIBILITY_TRAITS_HOUR,
69 L"MINUTE",//ACCESSIBILITY_TRAITS_MINUTE,
70 L"SECOND",//ACCESSIBILITY_TRAITS_SECOND,
71 L"YEAR",//ACCESSIBILITY_TRAITS_YEAR,
72 L"MONTH",//ACCESSIBILITY_TRAITS_MONTH,
73 L"DAY",//ACCESSIBILITY_TRAITS_DAY,
74 L"END",//ACCESSIBILITY_TRAITS_END = 0xff
78 _AccessibilityElement::_AccessibilityElement(bool systemElement)
81 , __absBounds(0,0,0,0)
86 , __trait(ACCESSIBILITY_TRAITS_NONE)
90 , __systemElement(systemElement)
92 , __supportOperatingGesture(true)
93 , __setHintByUser(false)
94 , __disabledHint(false)
95 , __updateContents(false)
98 _AccessibilityElement::~_AccessibilityElement(void)
102 static_cast<_AccessibilityElementImpl*>(__pUserData)->SetCore(null);
107 _AccessibilityElement::Construct(const String& name, const FloatRectangle& bounds)
110 __bounds.SetBounds(bounds.x,bounds.y,bounds.width,bounds.height);
114 _AccessibilityElement::Construct(const String& name, const Rectangle& bounds)
117 __bounds.SetBounds(bounds.x,bounds.y,bounds.width,bounds.height);
121 _AccessibilityElement::SetName(const String& name)
126 _AccessibilityElement::SetLabel(const String& label)
129 __updateContents = true;
132 _AccessibilityElement::SetHint(const String& hint, bool setHintByUser)
134 if(__setHintByUser && !setHintByUser)
139 __setHintByUser = setHintByUser;
140 __updateContents = true;
143 _AccessibilityElement::SetStatus(const String& status)
146 __updateContents = true;
149 _AccessibilityElement::SetTrait(AccessibilityTraits trait)
152 __traitString = (_traitString[__trait]);
153 __updateContents = true;
156 _AccessibilityElement::SetTrait(const Tizen::Base::String& trait)
158 __traitString = trait;
159 __updateContents = true;
162 _AccessibilityElement::SetParent(const _AccessibilityContainer& parent)
164 __pParent = &const_cast<_AccessibilityContainer&>(parent);
167 _AccessibilityElement::SetValue(const String& value)
170 __updateContents = true;
172 _AccessibilityContainer*
173 _AccessibilityElement::GetParent(void) const
178 _AccessibilityElement::GetName(void) const
183 _AccessibilityElement::GetBounds(void) const
188 _AccessibilityElement::GetLabel(void) const
193 _AccessibilityElement::GetHint(void) const
198 _AccessibilityElement::GetStatus(void) const
203 _AccessibilityElement::GetTrait(void) const
208 _AccessibilityElement::GetTraitString(void) const
210 return __traitString;
213 _AccessibilityElement::GetValue(void) const
218 _AccessibilityElement::SetHintDisabled(bool enable)
220 __disabledHint = enable;
223 _AccessibilityElement::Activate(bool enable)
225 __activated = enable;
228 // __pParent->RemoveElement(*this);
233 _AccessibilityElement::IsActivated(void) const
238 _AccessibilityElement::GetReadingContents(void) const
241 if(__label.GetLength() > 0)
246 if(__traitString.GetLength() > 0)
249 out += __traitString;
252 if(__value.GetLength() > 0)
257 if(__status.GetLength() > 0)
262 if(__hint.GetLength() > 0 && !__disabledHint && __pParent->GetEnableState())
267 if(__pParent->GetEnableState() == false)
272 const_cast<_AccessibilityElement*>(this)->__updateContents = false;
276 _AccessibilityElement::SetBounds(const FloatRectangle& bounds)
278 __bounds.SetBounds(bounds.x,bounds.y,bounds.width,bounds.height);
279 if(__pParent && this == __pParent->GetCurrentFocusedElement())
281 _AccessibilityManager::GetInstance()->RequestToDrawFocusUi();
286 _AccessibilityElement::SetBounds(const Tizen::Graphics::Rectangle& bounds)
288 __bounds.SetBounds(bounds.x,bounds.y,bounds.width,bounds.height);
289 if(__pParent && this == __pParent->GetCurrentFocusedElement())
291 _AccessibilityManager::GetInstance()->RequestToDrawFocusUi();
296 _AccessibilityElement::GetAbsoluteBounds(void) const
298 FloatRectangle controlAbsBounds = GetParent()->GetOwner().GetAbsoluteBoundsF();
299 FloatRectangle rect(controlAbsBounds.x+__bounds.x, controlAbsBounds.y+__bounds.y, __bounds.width, __bounds.height);
300 const_cast<FloatRectangle&>(__absBounds).SetBounds(controlAbsBounds.x+__bounds.x, controlAbsBounds.y+__bounds.y, __bounds.width, __bounds.height);
304 _AccessibilityElement::SetSupportOperatingGesture(bool set)
306 __supportOperatingGesture = set;
309 _AccessibilityElement::GetSupportOperatingGesture(void)
311 return __supportOperatingGesture;
314 _AccessibilityElement::GetUserData(void) const
320 _AccessibilityElement::SetUserData(void* pUserData)
322 __pUserData = pUserData;
325 _AccessibilityElement::IsSystemElement(void)
327 return __systemElement;
330 _AccessibilityElement::IsUpdated(void)
332 return __updateContents;