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 _AccessibilityElement::_AccessibilityElement(bool systemElement)
37 , __absBounds(0,0,0,0)
42 , __trait(ACCESSIBILITY_TRAITS_NONE)
51 , __systemElement(systemElement)
53 , __supportOperatingGesture(true)
54 , __setHintByUser(false)
55 , __disabledHint(false)
56 , __updateContents(false)
57 , __publicLabelUpdated(false)
60 _AccessibilityElement::~_AccessibilityElement(void)
64 static_cast<_AccessibilityElementImpl*>(__pUserData)->SetCore(null);
73 delete [] __pStatusId;
77 if (__pParent && this == __pParent->GetCurrentFocusedElement())
79 _AccessibilityManager::GetInstance()->RequestAutoReading(_ACCESSIBILITY_AUTO_READING_MODE_FIRST_ITEM);
83 _AccessibilityElement::Construct(const String& name, const FloatRectangle& bounds)
86 __bounds.SetBounds(bounds.x,bounds.y,bounds.width,bounds.height);
90 _AccessibilityElement::Construct(const String& name, const Rectangle& bounds)
93 __bounds.SetBounds(bounds.x,bounds.y,bounds.width,bounds.height);
97 _AccessibilityElement::SetName(const String& name)
102 _AccessibilityElement::SetLabel(const String& label)
105 __updateContents = true;
108 delete [] __pLabelId;
113 _AccessibilityElement::SetHint(const String& hint, bool setHintByUser)
115 if(__setHintByUser && !setHintByUser)
120 __setHintByUser = setHintByUser;
121 __updateContents = true;
129 _AccessibilityElement::SetStatus(const String& status)
132 __updateContents = true;
135 delete [] __pStatusId;
140 _AccessibilityElement::SetTrait(const Tizen::Base::String& trait)
142 __traitString = trait;
143 __updateContents = true;
146 delete [] __pTraitId;
151 _AccessibilityElement::SetParent(const _AccessibilityContainer& parent)
153 __pParent = &const_cast<_AccessibilityContainer&>(parent);
156 _AccessibilityElement::SetValue(const String& value)
159 __updateContents = true;
162 delete [] __pValueId;
166 _AccessibilityContainer*
167 _AccessibilityElement::GetParent(void) const
172 _AccessibilityElement::GetName(void) const
177 _AccessibilityElement::GetBounds(void) const
182 _AccessibilityElement::GetLabel(void) const
187 Tizen::Ui::_ResourceManager::GetInstance()->GetString(__pLabelId, out);
194 _AccessibilityElement::GetHint(void) const
199 Tizen::Ui::_ResourceManager::GetInstance()->GetString(__pHintId, out);
205 _AccessibilityElement::GetStatus(void) const
210 Tizen::Ui::_ResourceManager::GetInstance()->GetString(__pStatusId, out);
216 _AccessibilityElement::GetTraitString(void) const
221 Tizen::Ui::_ResourceManager::GetInstance()->GetString(__pTraitId, out);
224 return __traitString;
227 _AccessibilityElement::GetValue(void) const
232 Tizen::Ui::_ResourceManager::GetInstance()->GetString(__pValueId, out);
238 _AccessibilityElement::SetHintDisabled(bool enable)
240 __disabledHint = enable;
243 _AccessibilityElement::Activate(bool enable)
245 __activated = enable;
246 _AccessibilityManager::GetInstance()->NeedRefreshItem();
249 _AccessibilityElement::IsActivated(void) const
254 _AccessibilityElement::GetReadingContents(void) const
257 if (__pLabelId != null)
260 Tizen::Ui::_ResourceManager::GetInstance()->GetString(__pLabelId, string);
263 else if(__label.GetLength() > 0)
268 if (__pTraitId != null)
271 Tizen::Ui::_ResourceManager::GetInstance()->GetString(__pTraitId, string);
275 else if(__traitString.GetLength() > 0)
278 out += __traitString;
281 if (__pValueId != null)
284 Tizen::Ui::_ResourceManager::GetInstance()->GetString(__pValueId, string);
288 else if(__value.GetLength() > 0)
294 if (__pStatusId != null)
297 Tizen::Ui::_ResourceManager::GetInstance()->GetString(__pStatusId, string);
301 else if(__status.GetLength() > 0)
306 if(__pParent->GetEnableState() == false)
309 out += L"disable"; //ScrLocalization
311 if (!__disabledHint && __pParent->GetEnableState())
313 if (__pHintId != null)
316 Tizen::Ui::_ResourceManager::GetInstance()->GetString(__pHintId, string);
320 else if(__hint.GetLength() > 0)
326 const_cast<_AccessibilityElement*>(this)->__updateContents = false;
330 _AccessibilityElement::SetBounds(const FloatRectangle& bounds)
332 __bounds.SetBounds(bounds.x,bounds.y,bounds.width,bounds.height);
333 if(__pParent && this == __pParent->GetCurrentFocusedElement())
335 _AccessibilityManager::GetInstance()->RequestToDrawFocusUi();
337 _AccessibilityManager::GetInstance()->NeedRefreshItem();
341 _AccessibilityElement::SetBounds(const Tizen::Graphics::Rectangle& bounds)
343 __bounds.SetBounds(bounds.x,bounds.y,bounds.width,bounds.height);
344 if(__pParent && this == __pParent->GetCurrentFocusedElement())
346 _AccessibilityManager::GetInstance()->RequestToDrawFocusUi();
348 _AccessibilityManager::GetInstance()->NeedRefreshItem();
352 _AccessibilityElement::GetAbsoluteBounds(void) const
354 FloatRectangle controlAbsBounds = GetParent()->GetOwner().GetAbsoluteBoundsF(true);
355 FloatRectangle rect(controlAbsBounds.x+__bounds.x, controlAbsBounds.y+__bounds.y, __bounds.width, __bounds.height);
356 const_cast<FloatRectangle&>(__absBounds).SetBounds(controlAbsBounds.x+__bounds.x, controlAbsBounds.y+__bounds.y, __bounds.width, __bounds.height);
360 _AccessibilityElement::SetSupportOperatingGesture(bool set)
362 __supportOperatingGesture = set;
365 _AccessibilityElement::GetSupportOperatingGesture(void)
367 return __supportOperatingGesture;
370 _AccessibilityElement::GetUserData(void) const
376 _AccessibilityElement::SetUserData(void* pUserData)
378 __pUserData = pUserData;
381 _AccessibilityElement::IsSystemElement(void)
383 return __systemElement;
386 _AccessibilityElement::IsUpdated(void)
388 return __updateContents;
392 _AccessibilityElement::SetLabelWithStringId(const char* id)
396 delete [] __pLabelId;
399 int length = strlen(id);
404 __pLabelId = new char[length+1];
405 strcpy(__pLabelId, id);
406 __pLabelId[length] = '\0';
409 _AccessibilityElement::SetTraitWithStringId(const char* id)
413 delete [] __pTraitId;
416 int length = strlen(id);
421 __pTraitId = new char[length+1];
422 strcpy(__pTraitId, id);
423 __pTraitId[length] = '\0';
426 _AccessibilityElement::SetHintWithStringId(const char* id)
434 int length = strlen(id);
439 __pHintId = new char[length+1];
440 strcpy(__pHintId, id);
441 __pHintId[length] = '\0';
444 _AccessibilityElement::SetStatusWithStringId(const char* id)
448 delete [] __pStatusId;
451 int length = strlen(id);
456 __pStatusId = new char[length+1];
457 strcpy(__pStatusId, id);
458 __pStatusId[length] = '\0';
461 _AccessibilityElement::SetValueWithStringId(const char* id)
465 delete [] __pValueId;
468 int length = strlen(id);
473 __pValueId = new char[length+1];
474 strcpy(__pValueId, id);
475 __pValueId[length] = '\0';
479 _AccessibilityElement::SetPublicLabelUpdate(bool isPublicLabelUpdated)
481 __publicLabelUpdated = isPublicLabelUpdated;
485 _AccessibilityElement::IsPublicLabelUpdated(void)
487 return __publicLabelUpdated;