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.
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"
27 #include "FUi_ResourceManager.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)
96 , __systemElement(systemElement)
98 , __supportOperatingGesture(true)
99 , __setHintByUser(false)
100 , __disabledHint(false)
101 , __updateContents(false)
104 _AccessibilityElement::~_AccessibilityElement(void)
108 static_cast<_AccessibilityElementImpl*>(__pUserData)->SetCore(null);
111 delete [] __pLabelId;
113 delete [] __pTraitId;
117 delete [] __pStatusId;
119 delete [] __pValueId;
121 if (__pParent && this == __pParent->GetCurrentFocusedElement())
123 _AccessibilityManager::GetInstance()->RequestAutoReading(_ACCESSIBILITY_AUTO_READING_MODE_FIRST_ITEM);
127 _AccessibilityElement::Construct(const String& name, const FloatRectangle& bounds)
130 __bounds.SetBounds(bounds.x,bounds.y,bounds.width,bounds.height);
134 _AccessibilityElement::Construct(const String& name, const Rectangle& bounds)
137 __bounds.SetBounds(bounds.x,bounds.y,bounds.width,bounds.height);
141 _AccessibilityElement::SetName(const String& name)
146 _AccessibilityElement::SetLabel(const String& label)
149 __updateContents = true;
152 delete [] __pLabelId;
157 _AccessibilityElement::SetHint(const String& hint, bool setHintByUser)
159 if(__setHintByUser && !setHintByUser)
164 __setHintByUser = setHintByUser;
165 __updateContents = true;
173 _AccessibilityElement::SetStatus(const String& status)
176 __updateContents = true;
179 delete [] __pStatusId;
184 _AccessibilityElement::SetTrait(const Tizen::Base::String& trait)
186 __traitString = trait;
187 __updateContents = true;
190 delete [] __pTraitId;
195 _AccessibilityElement::SetParent(const _AccessibilityContainer& parent)
197 __pParent = &const_cast<_AccessibilityContainer&>(parent);
200 _AccessibilityElement::SetValue(const String& value)
203 __updateContents = true;
206 delete [] __pValueId;
210 _AccessibilityContainer*
211 _AccessibilityElement::GetParent(void) const
216 _AccessibilityElement::GetName(void) const
221 _AccessibilityElement::GetBounds(void) const
226 _AccessibilityElement::GetLabel(void) const
231 Tizen::Ui::_ResourceManager::GetInstance()->GetString(__pLabelId, out);
238 _AccessibilityElement::GetHint(void) const
243 Tizen::Ui::_ResourceManager::GetInstance()->GetString(__pHintId, out);
249 _AccessibilityElement::GetStatus(void) const
254 Tizen::Ui::_ResourceManager::GetInstance()->GetString(__pStatusId, out);
260 _AccessibilityElement::GetTraitString(void) const
265 Tizen::Ui::_ResourceManager::GetInstance()->GetString(__pTraitId, out);
268 return __traitString;
271 _AccessibilityElement::GetValue(void) const
276 Tizen::Ui::_ResourceManager::GetInstance()->GetString(__pValueId, out);
282 _AccessibilityElement::SetHintDisabled(bool enable)
284 __disabledHint = enable;
287 _AccessibilityElement::Activate(bool enable)
289 __activated = enable;
290 _AccessibilityManager::GetInstance()->NeedRefreshItem();
293 _AccessibilityElement::IsActivated(void) const
298 _AccessibilityElement::GetReadingContents(void) const
301 if (__pLabelId != null)
304 Tizen::Ui::_ResourceManager::GetInstance()->GetString(__pLabelId, string);
307 else if(__label.GetLength() > 0)
312 if (__pTraitId != null)
315 Tizen::Ui::_ResourceManager::GetInstance()->GetString(__pTraitId, string);
319 else if(__traitString.GetLength() > 0)
322 out += __traitString;
325 if (__pValueId != null)
328 Tizen::Ui::_ResourceManager::GetInstance()->GetString(__pValueId, string);
332 else if(__value.GetLength() > 0)
338 if (__pStatusId != null)
341 Tizen::Ui::_ResourceManager::GetInstance()->GetString(__pStatusId, string);
345 else if(__status.GetLength() > 0)
350 if(__pParent->GetEnableState() == false)
353 out += L"disable"; //ScrLocalization
355 if (!__disabledHint && __pParent->GetEnableState())
357 if (__pHintId != null)
360 Tizen::Ui::_ResourceManager::GetInstance()->GetString(__pHintId, string);
364 else if(__hint.GetLength() > 0)
370 const_cast<_AccessibilityElement*>(this)->__updateContents = false;
374 _AccessibilityElement::SetBounds(const FloatRectangle& bounds)
376 __bounds.SetBounds(bounds.x,bounds.y,bounds.width,bounds.height);
377 if(__pParent && this == __pParent->GetCurrentFocusedElement())
379 _AccessibilityManager::GetInstance()->RequestToDrawFocusUi();
381 _AccessibilityManager::GetInstance()->NeedRefreshItem();
385 _AccessibilityElement::SetBounds(const Tizen::Graphics::Rectangle& bounds)
387 __bounds.SetBounds(bounds.x,bounds.y,bounds.width,bounds.height);
388 if(__pParent && this == __pParent->GetCurrentFocusedElement())
390 _AccessibilityManager::GetInstance()->RequestToDrawFocusUi();
392 _AccessibilityManager::GetInstance()->NeedRefreshItem();
396 _AccessibilityElement::GetAbsoluteBounds(void) const
398 FloatRectangle controlAbsBounds = GetParent()->GetOwner().GetAbsoluteBoundsF();
399 FloatRectangle rect(controlAbsBounds.x+__bounds.x, controlAbsBounds.y+__bounds.y, __bounds.width, __bounds.height);
400 const_cast<FloatRectangle&>(__absBounds).SetBounds(controlAbsBounds.x+__bounds.x, controlAbsBounds.y+__bounds.y, __bounds.width, __bounds.height);
404 _AccessibilityElement::SetSupportOperatingGesture(bool set)
406 __supportOperatingGesture = set;
409 _AccessibilityElement::GetSupportOperatingGesture(void)
411 return __supportOperatingGesture;
414 _AccessibilityElement::GetUserData(void) const
420 _AccessibilityElement::SetUserData(void* pUserData)
422 __pUserData = pUserData;
425 _AccessibilityElement::IsSystemElement(void)
427 return __systemElement;
430 _AccessibilityElement::IsUpdated(void)
432 return __updateContents;
436 _AccessibilityElement::SetLabelWithStringId(const char* id)
440 delete [] __pLabelId;
443 int length = strlen(id);
448 __pLabelId = new char[length+1];
449 strcpy(__pLabelId, id);
450 __pLabelId[length] = '\0';
453 _AccessibilityElement::SetTraitWithStringId(const char* id)
457 delete [] __pTraitId;
460 int length = strlen(id);
465 __pTraitId = new char[length+1];
466 strcpy(__pTraitId, id);
467 __pTraitId[length] = '\0';
470 _AccessibilityElement::SetHintWithStringId(const char* id)
478 int length = strlen(id);
483 __pHintId = new char[length+1];
484 strcpy(__pHintId, id);
485 __pHintId[length] = '\0';
488 _AccessibilityElement::SetStatusWithStringId(const char* id)
492 delete [] __pStatusId;
495 int length = strlen(id);
500 __pStatusId = new char[length+1];
501 strcpy(__pStatusId, id);
502 __pStatusId[length] = '\0';
505 _AccessibilityElement::SetValueWithStringId(const char* id)
509 delete [] __pValueId;
512 int length = strlen(id);
517 __pValueId = new char[length+1];
518 strcpy(__pValueId, id);
519 __pValueId[length] = '\0';