eb32e60ee10da20a7877f7cbc393f38e7f14b68b
[framework/osp/uifw.git] / src / ui / FUi_AccessibilityManager.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
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.
16 //
17 #include <sys/utsname.h>
18 #include <FBaseInteger.h>
19 #include <pthread.h>
20 #include <FAppUiApp.h>
21 #include <FAppIAppFrame.h>
22 #include <FBaseRtTimer.h>
23 #include <FLclLocale.h>
24 #include <FUiAnimVisualElement.h>
25 #include <FUiCtrlFrame.h>
26 #include <FUiCtrlForm.h>
27 #include <FGrpCanvas.h>
28 #include <FGrpColor.h>
29 #include <FGrpFloatDimension.h>
30 #include <FGrpEnrichedText.h>
31 #include <FGrpBitmap.h>
32 #include <FBase_StringConverter.h>
33 #include <FGrp_BitmapImpl.h>
34 #include <FSys_SystemTimeImpl.h>
35 #include "FUi_AccessibilityGesture.h"
36 #include "FUi_AccessibilitySystemSettingLoader.h"
37 #include "FUi_AccessibilityTtsPlayer.h"
38 #include "FUi_AccessibilityManager.h"
39 #include "FUi_AccessibilityElement.h"
40 #include "FUi_AccessibilityContainer.h"
41 #include "FUi_IAccessibilityListener.h"
42 #include "FUi_ControlManager.h"
43 #include "FUi_TouchManager.h"
44 #include "FUi_UiEventManager.h"
45 #include "FUiAnim_VisualElementImpl.h"
46 #include "FUiCtrl_FrameImpl.h"
47 #include "FUiCtrl_ScrollPanel.h"
48 #include "FUiCtrl_IconListView.h"
49 #include "FUi_ResourceManager.h"
50
51 using namespace Tizen::App;
52 using namespace Tizen::Base;
53 using namespace Tizen::Base::Collection;
54 using namespace Tizen::Base::Runtime;
55 using namespace Tizen::Graphics;
56 using namespace Tizen::Ui::Animations;
57 using namespace Tizen::Ui::Controls;
58 using namespace Tizen::System;
59 namespace
60 {
61 class GuidePopupTimer
62         : public ITimerEventListener
63 {
64 public:
65         GuidePopupTimer(void)
66                 : __pElement(null)
67         {
68                 timer.Construct(*this);
69         }
70         virtual ~GuidePopupTimer(void) {}
71         void SetElement(VisualElement* pElement)
72         {
73                 if (__pElement != null)
74                 {
75                         timer.Cancel();
76                 }
77                 __pElement = pElement;
78                 timer.Start(3000);
79
80         }
81         void Stop(void)
82         {
83                 timer.Cancel();
84         }
85         virtual void OnTimerExpired(Timer& timer)
86         {
87                 if (__pElement)
88                 {
89                         __pElement->SetShowState(false);
90                 }
91                 __pElement = null;
92         }
93         VisualElement* __pElement;
94         Timer timer;
95 };
96
97 class AutoReadingTimer
98         : public ITimerEventListener
99 {
100 public:
101         AutoReadingTimer(Tizen::Ui::_AccessibilityManager* pManager)
102                 : __pAccessibilityManager(pManager)
103                 , __mode(Tizen::Ui::_ACCESSIBILITY_AUTO_READING_MODE_FIRST_ITEM)
104                 , __start(false)
105         {
106
107                 timer.Construct(*this);
108         }
109         virtual ~AutoReadingTimer(void) {}
110         void Start(Tizen::Ui::_AccessibilityAutoReadingMode mode)
111         {
112                 if((Tizen::App::_AppInfo::GetAppType() & _APP_TYPE_SERVICE_APP) || (Tizen::App::_AppInfo::GetAppType() & _APP_TYPE_IME_APP))
113                 {
114                         return;
115                 }
116                 if (__start)
117                 {
118                         return;
119                 }
120                 __start = true;
121                 __mode = mode;
122                 timer.Start(700);
123         }
124         void Stop(void)
125         {
126                 timer.Cancel();
127                 __start = false;
128         }
129         virtual void OnTimerExpired(Timer& timer)
130         {
131                 if (!(__pAccessibilityManager->IsScreenReaderActivated()) || UiApp::GetInstance()->GetAppUiState() == APP_UI_STATE_BACKGROUND)
132                 {
133                         return Stop();
134                 }
135                 SysLog(NID_UI, "mode %d", __mode);
136                 if (__pAccessibilityManager->GetTtsStatus() != Tizen::Ui::ACCESSIBILITY_SCREEN_READER_STATUS_READY
137                         && __pAccessibilityManager->GetTtsStatus() != Tizen::Ui::ACCESSIBILITY_SCREEN_READER_STATUS_PLAYING)
138                 {
139                         __start = false;
140                         Start(__mode);
141                         SysLog(NID_UI, "AccessibilityManager::AutoReadingTimer is started again because tts is not initialized.");
142                         return;
143                 }
144                 __start = false;
145                 __pAccessibilityManager->ReadElement(__mode);
146         }
147         Tizen::Ui::_AccessibilityManager* __pAccessibilityManager;
148         Timer timer;
149         Tizen::Ui::_AccessibilityAutoReadingMode __mode;
150         bool __start;
151 };
152
153 GuidePopupTimer* pGuidePopupTimer;
154 AutoReadingTimer* pAutoReadingTimer;
155 }
156 namespace Tizen { namespace Ui {
157
158 template <class T>
159 class _AccessibilityItemComparer
160         : public Tizen::Base::Collection::IComparerT <T>
161 {
162 public:
163         _AccessibilityItemComparer(void)
164         {
165         }
166         virtual ~_AccessibilityItemComparer(void)
167         {
168         }
169         virtual result Compare(const T& obj1, const T& obj2, int& cmp) const
170         {
171                 Tizen::Graphics::Rectangle rect1= obj1->GetAbsoluteBounds();
172                 Tizen::Graphics::Rectangle rect2= obj2->GetAbsoluteBounds();
173
174                 if (rect1.y > rect2.y)
175                 {
176                         cmp = 1;
177                         return E_SUCCESS;
178                 }
179                 else if (rect1.y < rect2.y)
180                 {
181                         cmp = -1;
182                         return E_SUCCESS;
183                 }
184                 else
185                 {
186                         if (rect1.x > rect2.x)
187                         {
188                                 cmp = 1;
189                                 return E_SUCCESS;
190                         }
191                         else if (rect1.x < rect2.x)
192                         {
193                                 cmp = -1;
194                                 return E_SUCCESS;
195                         }
196                         else
197                         {
198                                 cmp = 0;
199                                 return E_SUCCESS;
200                         }
201                 }
202         }
203 }; //class _AccessibilityComparer
204
205 template <class T>
206 class _ElementComparer
207         : public Tizen::Base::Collection::IComparerT <T>
208 {
209 public:
210         _ElementComparer(void)
211         {
212         }
213         virtual ~_ElementComparer(void)
214         {
215         }
216         virtual result Compare(const T& obj1, const T& obj2, int& cmp) const
217         {
218                 if (obj1->GetParent()->GetPriority() > obj2->GetParent()->GetPriority())
219                 {
220                         cmp = -1;
221                         return E_SUCCESS;
222                 }
223                 else if (obj1->GetParent()->GetPriority() < obj2->GetParent()->GetPriority())
224                 {
225                         cmp = 1;
226                         return E_SUCCESS;
227                 }
228                 else
229                 {
230                         Tizen::Graphics::FloatRectangle rect1= obj1->GetAbsoluteBounds();
231                         Tizen::Graphics::FloatRectangle rect2= obj2->GetAbsoluteBounds();
232
233                         if (rect1.y > rect2.y)
234                         {
235                                 cmp = 1;
236                                 return E_SUCCESS;
237                         }
238                         else if (rect1.y < rect2.y)
239                         {
240                                 cmp = -1;
241                                 return E_SUCCESS;
242                         }
243                         else
244                         {
245                                 if (rect1.x > rect2.x)
246                                 {
247                                         cmp = 1;
248                                         return E_SUCCESS;
249                                 }
250                                 else if (rect1.x < rect2.x)
251                                 {
252                                         cmp = -1;
253                                         return E_SUCCESS;
254                                 }
255                                 else
256                                 {
257                                         cmp = 0;
258                                         return E_SUCCESS;
259                                 }
260                         }
261                 }
262         }
263 };
264
265 static _AccessibilityManager* pAccManager = null;
266 bool _AccessibilityManager::__screenReaderIsEnabled = false;
267 _AccessibilityManager::_AccessibilityManager(void)
268         : __pAccGesture(null)
269         , __pTtsPlayer(null)
270         , __pSettingLoader(null)
271         , __pTargetContainer(null)
272         , __pTargetElement(null)
273         , __pTitleElement(null)
274         , __containerList()
275         , __candidateList()
276         , __mode(MODE_NONE)
277         , __pReadingVe(null)
278         , __pFocusVe(null)
279         , __pPanningControl(null)
280         , __needRefreshItem(false)
281 {
282         Initialize();
283 }
284 _AccessibilityManager::~_AccessibilityManager(void)
285 {
286         delete __pAccGesture;
287         __pAccGesture = null;
288         delete __pTtsPlayer;
289         __pTtsPlayer = null;
290         delete __pSettingLoader;
291         __pSettingLoader = null;
292         delete pGuidePopupTimer;
293         pGuidePopupTimer = null;
294         delete pAutoReadingTimer;
295         pAutoReadingTimer = null;
296 }
297
298 _AccessibilityManager*
299 _AccessibilityManager::GetInstance(void)
300 {
301         return pAccManager;
302 }
303
304 void
305 _AccessibilityManager::CreateInstance(void)
306 {
307         static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
308
309         if (pAccManager == null)
310         {
311                 pthread_once(&onceBlock, InitializeInstance);
312         }
313 }
314
315 void
316 _AccessibilityManager::InitializeInstance(void)
317 {
318         pAccManager = new (std::nothrow) _AccessibilityManager;
319 }
320 void
321 _AccessibilityManager::ReleaseInstance(void)
322 {
323         delete pAccManager;
324         pAccManager = null;
325 }
326 void
327 _AccessibilityManager::Initialize(void)
328 {
329         __pAccGesture = new (std::nothrow) _AccessibilityGesture(*this);
330         SysTryReturn(NID_UI, __pAccGesture, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
331         __pTtsPlayer = new (std::nothrow) _AccessibilityTtsPlayer(*this);
332         SysTryCatch(NID_UI, __pTtsPlayer, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
333         __pTtsPlayer->Construct();
334         __pSettingLoader = new (std::nothrow) _AccessibilitySystemSettingLoader(*this);
335         SysTryCatch(NID_UI, __pSettingLoader, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
336
337         if (IsScreenReaderActivated())
338         {
339                 __pTtsPlayer->SetLocale(__pSettingLoader->GetLocale());
340                 __pTtsPlayer->Activate();
341         }
342         pGuidePopupTimer = new (std::nothrow) GuidePopupTimer;
343         SysTryCatch(NID_UI, pGuidePopupTimer, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
344         pAutoReadingTimer = new (std::nothrow) AutoReadingTimer(this);
345         SysTryCatch(NID_UI, pAutoReadingTimer, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
346         return;
347
348 CATCH:
349         delete __pAccGesture;
350         __pAccGesture = null;
351         delete __pTtsPlayer;
352         __pTtsPlayer = null;
353         delete __pSettingLoader;
354         __pSettingLoader = null;
355         delete pGuidePopupTimer;
356         pGuidePopupTimer = null;
357         delete pAutoReadingTimer;
358         pAutoReadingTimer = null;
359 }
360 AccessibilityScreenReaderStatus
361 _AccessibilityManager::GetTtsStatus(void)
362 {
363         if (__pTtsPlayer)
364         {
365                 return __pTtsPlayer->GetStatus();
366         }
367         return ACCESSIBILITY_SCREEN_READER_STATUS_ERROR;
368 }
369 result
370 _AccessibilityManager::ReadContent(const Tizen::Base::String& content)
371 {
372         if (__pTtsPlayer)
373         {
374                 //ShowPopup(content);
375                 __pTtsPlayer->ReadGrammar(content);
376         }
377         return E_SUCCESS;
378 }
379 void
380 _AccessibilityManager::ReadElement(_AccessibilityAutoReadingMode mode)
381 {
382         MakeList();
383         int count = __candidateList.GetCount();
384         if (count < 1)
385         {
386                 return;
387         }
388         _AccessibilityElement* pElement = null;
389         result r = E_SYSTEM;
390
391         if (mode == _ACCESSIBILITY_AUTO_READING_MODE_FIRST_ITEM)
392         {
393                 r = __candidateList.GetAt(0, pElement);
394         }
395         else if (mode == _ACCESSIBILITY_AUTO_READING_MODE_FIRST_ITEM_OF_CONTENTS)
396         {
397                 for (int i = 0 ; i < count ; i++)
398                 {
399                         r = __candidateList.GetAt(i, pElement);
400                         if (r == E_SUCCESS && pElement)
401                         {
402                                 if (pElement->GetParent()->GetPriority() < ACCESSIBILITY_PRIORITY_TOP)
403                                 {
404                                         break;
405                                 }
406                         }
407                 }
408         }
409         else //_ACCESSIBILITY_AUTO_READING_MODE_CURRENT_FOCUS
410         {
411                 if (IsContainerValid(__pTargetContainer))
412                 {
413                         pElement = __pTargetElement;
414                         r = E_SUCCESS;
415                 }
416         }
417         if (r != E_SUCCESS || pElement == null)
418         {
419                 SysLog(NID_UI, "cause 1");
420                 return;
421         }
422         if (mode == _ACCESSIBILITY_AUTO_READING_MODE_FIRST_ITEM && __pTitleElement == pElement && !(__pTitleElement->IsUpdated()))
423         {
424                 SysLog(NID_UI, "cause 2");
425                 return;
426         }
427         __pTitleElement = pElement;
428         DrawFocusUi(*pElement);
429         __pTargetContainer = pElement->GetParent();
430         __pTargetElement = pElement;
431         __targetControlHandle = __pTargetContainer->GetOwner().GetHandle();
432         ReadElement(*pElement);
433 }
434
435 result
436 _AccessibilityManager::ReadElement(const _AccessibilityElement& element)
437 {
438         if (__pTtsPlayer)
439         {
440                 LinkedListT<_IAccessibilityListener*>* pList = static_cast<LinkedListT<_IAccessibilityListener*>*>(__pTargetContainer->GetListenerListN());
441                 if (pList != null)
442                 {
443                         for (int i = 0;i<pList->GetCount();i++)
444                         {
445                                 _IAccessibilityListener* pListener = null;
446                                 if (pList->GetAt(i, pListener) == E_SUCCESS)
447                                 {
448                                         pListener->OnAccessibilityReadingElement(*__pTargetContainer, element);
449                                 }
450                         }
451                         delete pList;
452                         pList = null;
453                 }
454                 //ShowPopup();
455                 __pTtsPlayer->ReadGrammar(element.GetReadingContents());
456         }
457         return E_SUCCESS;
458 }
459 result
460 _AccessibilityManager::ReadingStop(void)
461 {
462         return E_SUCCESS;
463 }
464 result
465 _AccessibilityManager::ReadingPause(void)
466 {
467         return E_SUCCESS;
468 }
469 result
470 _AccessibilityManager::ReadingResume(void)
471 {
472         return E_SUCCESS;
473 }
474
475 void
476 _AccessibilityManager::OnStartReading(const Tizen::Base::String& grammar)
477 {
478 }
479 void
480 _AccessibilityManager::HidePopup(void)
481 {
482         if (__readingPopupParentHandle.IsValid())
483         {
484                 if (__pReadingVe)
485                 {
486                         __pReadingVe->Destroy();
487                         __pReadingVe = null;
488                 }
489         }
490         else
491         {
492                 __pReadingVe = null;
493         }
494         pGuidePopupTimer->Stop();
495 }
496 void
497 _AccessibilityManager::ShowPopup(const String& content)
498 {
499         if (content.IsEmpty())
500         {
501                 return;
502         }
503         utsname sysInfo;
504         uname(&sysInfo);
505         if (String("i686_emulated") != sysInfo.machine)
506         {
507                 return;
508         }
509         Canvas* pCanvas = null;
510         Bitmap* pBgBitmap = null;
511         EnrichedText* pEnrichedTitleText = null;
512         EnrichedText* pText = null;
513         Frame* pFrame = null;
514
515         if (__readingPopupParentHandle.IsValid())
516         {
517                 if (__pReadingVe)
518                 {
519                         __pReadingVe->Destroy();
520                         __pReadingVe = null;
521                 }
522         }
523         else
524         {
525                 __pReadingVe = null;
526         }
527
528         pFrame = UiApp::GetInstance()->GetAppFrame()->GetFrame();
529
530         if (pFrame != null)
531         {
532                 int accesibilityVisualElementLevel = 3000;
533                 result r = E_SUCCESS;
534                 _Window* pWindow = _ControlManager::GetInstance()->GetTopVisibleWindow();
535                 VisualElement* pRootVe = pWindow->GetVisualElement();
536
537                 __pReadingVe = new (std::nothrow) VisualElement();
538                 SysTryCatch(NID_UI, __pReadingVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
539
540                 r = __pReadingVe->Construct();
541                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error");
542                 __pReadingVe->SetName("Accessibility reading popup");
543                 __pReadingVe->SetImplicitAnimationEnabled(false);
544                 _VisualElementImpl::GetInstance(*__pReadingVe)->SetZOrderGroup(accesibilityVisualElementLevel);
545                 pRootVe->AttachChild(*__pReadingVe);
546                 __readingPopupParentHandle = pWindow->GetHandle();
547         }
548
549         if (__pReadingVe)
550         {
551                 result r = E_SUCCESS;
552
553                 float titleFontSize = 0;
554                 float textFontSize = 0;
555                 float popupWidth = 0;
556                 float topMargin = 0;
557                 float bottomMargin = 0;
558                 float sideMargin = 0;
559                 float titleHeight = 0;
560                 float textTopMargin = 0;
561                 float textHeight = 0;
562
563                 Color titleTextColor;
564                 Color pointTextColor;
565                 Color textColor;
566                 TextElement* pElement = null;
567
568                 r = GET_SHAPE_CONFIG(ACCESSIBILITY::TITLE_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, titleFontSize);
569                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
570                 r = GET_SHAPE_CONFIG(ACCESSIBILITY::TEXT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, textFontSize);
571                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
572                 r = GET_SHAPE_CONFIG(ACCESSIBILITY::POPUP_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, popupWidth);
573                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
574                 r = GET_SHAPE_CONFIG(ACCESSIBILITY::TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, topMargin);
575                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
576                 r = GET_SHAPE_CONFIG(ACCESSIBILITY::BOTTON_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, bottomMargin);
577                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
578                 r = GET_SHAPE_CONFIG(ACCESSIBILITY::SIDE_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, sideMargin);
579                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
580                 r = GET_SHAPE_CONFIG(ACCESSIBILITY::TITLE_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, titleHeight);
581                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
582                 r = GET_SHAPE_CONFIG(ACCESSIBILITY::TEXT_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, textTopMargin);
583                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
584                 r = GET_SHAPE_CONFIG(ACCESSIBILITY::TEXT_HEGIHT, _CONTROL_ORIENTATION_PORTRAIT, textHeight);
585                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
586                 r = GET_COLOR_CONFIG(ACCESSIBILITY::TITLE_TEXT, titleTextColor);
587                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
588                 r = GET_COLOR_CONFIG(ACCESSIBILITY::POINT_TEXT, pointTextColor);
589                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
590                 r = GET_COLOR_CONFIG(ACCESSIBILITY::TEXT, textColor);
591                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
592                 r = GET_BITMAP_CONFIG_N(ACCESSIBILITY::POPUP_BG, BITMAP_PIXEL_FORMAT_ARGB8888, pBgBitmap);
593                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
594
595                 Font titleFont;
596                 r = titleFont.Construct(FONT_STYLE_PLAIN, titleFontSize);
597                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
598                 Font textFont;
599                 r = textFont.Construct(FONT_STYLE_PLAIN, textFontSize);
600                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
601
602                 pEnrichedTitleText = new (std::nothrow) EnrichedText;
603                 SysTryCatch(NID_UI, pEnrichedTitleText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
604                 pEnrichedTitleText->Construct(FloatDimension(popupWidth-sideMargin*2, titleHeight));
605
606                 pText = new (std::nothrow) EnrichedText;
607                 SysTryCatch(NID_UI, pText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
608                 pText->Construct(FloatDimension(popupWidth-sideMargin*2, textHeight));
609
610                 pElement = new (std::nothrow) TextElement;
611                 SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
612                 r = pElement->Construct(L"Screen reading...");
613                 if (r != E_SUCCESS)
614                 {
615                         delete pElement;
616                         goto CATCH;
617                 }
618                 pElement->SetTextColor(titleTextColor);
619                 pElement->SetFont(titleFont);
620                 r = pEnrichedTitleText->Add(*pElement);
621                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
622                 pEnrichedTitleText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
623                 pEnrichedTitleText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP);
624                 pEnrichedTitleText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP);
625                 pEnrichedTitleText->SetTextAbbreviationEnabled(true);
626
627                 pElement = new (std::nothrow) TextElement;
628                 SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
629                 r = pElement->Construct(content);
630                 if (r != E_SUCCESS)
631                 {
632                         delete pElement;
633                         goto CATCH;
634                 }
635                 pElement->SetTextColor(textColor);
636                 pElement->SetFont(textFont);
637                 r = pText->Add(*pElement);
638                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
639                 pText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
640                 pText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP);
641                 pText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP);
642                 pText->SetTextAbbreviationEnabled(true);
643
644                 float x = 40;
645                 float y = 200;
646                 float popupHeight = topMargin + bottomMargin + titleHeight + textTopMargin + textHeight;
647
648                 FloatDimension screen = Tizen::Ui::_ControlManager::GetInstance()->GetScreenSizeF();
649                 __pReadingVe->SetBounds(FloatRectangle(x, y, popupWidth, popupHeight));
650                 pCanvas = __pReadingVe->GetCanvasN();
651                 SysTryCatch(NID_UI, pCanvas != null, , E_SYSTEM, "System error for accessibility popup");
652                 pCanvas->DrawNinePatchedBitmap(FloatRectangle(0, 0, popupWidth, popupHeight), *pBgBitmap);
653                 float drawingTextY = topMargin;
654                 pCanvas->DrawText(FloatPoint(sideMargin, drawingTextY), *pEnrichedTitleText);
655                 drawingTextY += textTopMargin + titleHeight;
656                 pCanvas->DrawText(FloatPoint(sideMargin, drawingTextY), *pText);
657                 __pReadingVe->SetShowState(true);
658                 __pReadingVe->SetFlushNeeded();
659                 pGuidePopupTimer->SetElement(__pReadingVe);
660
661         }
662 CATCH:
663         delete pCanvas;
664         pCanvas = null;
665         delete pBgBitmap;
666         pBgBitmap = null;
667         if (pEnrichedTitleText)
668         {
669                 pEnrichedTitleText->RemoveAll(true);
670                 delete pEnrichedTitleText;
671         }
672         if (pText)
673         {
674                 pText->RemoveAll(true);
675                 delete pText;
676         }
677
678         return;
679
680 }
681 void
682 _AccessibilityManager::ShowPopup()
683 {
684         if (__pTargetElement == null)
685         {
686                 return;
687         }
688         utsname sysInfo;
689         uname(&sysInfo);
690         Frame* pFrame = null;
691         Canvas* pCanvas = null;
692         Bitmap* pBgBitmap = null;
693         EnrichedText* pEnrichedTitleText = null;
694         EnrichedText* pEnrichedNameText = null;
695         EnrichedText* pEnrichedLableText = null;
696         EnrichedText* pEnrichedTraitText = null;
697         EnrichedText* pEnrichedStatusText = null;
698         EnrichedText* pEnrichedHintText = null;
699         EnrichedText* pEnrichedValueText = null;
700         EnrichedText* pEnrichedBoundsText = null;
701         EnrichedText* pEnrichedAbsBoundsText = null;
702         TextElement* pElement = null;
703         FloatDimension screen;
704
705         if (String("i686_emulated") != sysInfo.machine)
706         {
707                 return;
708         }
709
710         if (__readingPopupParentHandle.IsValid())
711         {
712                 if (__pReadingVe)
713                 {
714                         __pReadingVe->Destroy();
715                         __pReadingVe = null;
716                 }
717         }
718         else
719         {
720                 __pReadingVe = null;
721         }
722
723         pFrame = UiApp::GetInstance()->GetAppFrame()->GetFrame();
724
725         if (pFrame != null)
726         {
727                 int accesibilityVisualElementLevel = 3000;
728                 result r = E_SUCCESS;
729                 _Window* pWindow = _ControlManager::GetInstance()->GetTopVisibleWindow();
730                 VisualElement* pRootVe = pWindow->GetVisualElement();
731                 __readingPopupParentHandle = pWindow->GetHandle();
732                 __pReadingVe = new (std::nothrow) VisualElement();
733                 SysTryCatch(NID_UI, __pReadingVe, , E_SYSTEM, "[E_SYSTEM] System error");
734
735                 r = __pReadingVe->Construct();
736                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error");
737                 __pReadingVe->SetName("Accessibility reading popup");
738                 __pReadingVe->SetImplicitAnimationEnabled(false);
739                 _VisualElementImpl::GetInstance(*__pReadingVe)->SetZOrderGroup(accesibilityVisualElementLevel);
740                 pRootVe->AttachChild(*__pReadingVe);
741         }
742
743         screen = _ControlManager::GetInstance()->GetScreenSizeF();
744         if (__pReadingVe)
745         {
746                 result r = E_SUCCESS;
747
748                 float titleFontSize = 0;
749                 float textFontSize = 0;
750                 float popupWidth = 0;
751                 float topMargin = 0;
752                 float bottomMargin = 0;
753                 float sideMargin = 0;
754                 float titleHeight = 0;
755                 float textTopMargin = 0;
756                 float textHeight = 0;
757
758                 Color titleTextColor;
759                 Color pointTextColor;
760                 Color textColor;
761
762                 r = GET_SHAPE_CONFIG(ACCESSIBILITY::TITLE_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, titleFontSize);
763                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
764                 r = GET_SHAPE_CONFIG(ACCESSIBILITY::TEXT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, textFontSize);
765                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
766                 r = GET_SHAPE_CONFIG(ACCESSIBILITY::POPUP_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, popupWidth);
767                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
768                 r = GET_SHAPE_CONFIG(ACCESSIBILITY::TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, topMargin);
769                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
770                 r = GET_SHAPE_CONFIG(ACCESSIBILITY::BOTTON_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, bottomMargin);
771                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
772                 r = GET_SHAPE_CONFIG(ACCESSIBILITY::SIDE_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, sideMargin);
773                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
774                 r = GET_SHAPE_CONFIG(ACCESSIBILITY::TITLE_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, titleHeight);
775                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
776                 r = GET_SHAPE_CONFIG(ACCESSIBILITY::TEXT_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, textTopMargin);
777                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
778                 r = GET_SHAPE_CONFIG(ACCESSIBILITY::TEXT_HEGIHT, _CONTROL_ORIENTATION_PORTRAIT, textHeight);
779                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
780                 r = GET_COLOR_CONFIG(ACCESSIBILITY::TITLE_TEXT, titleTextColor);
781                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
782                 r = GET_COLOR_CONFIG(ACCESSIBILITY::POINT_TEXT, pointTextColor);
783                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
784                 r = GET_COLOR_CONFIG(ACCESSIBILITY::TEXT, textColor);
785                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
786                 r = GET_BITMAP_CONFIG_N(ACCESSIBILITY::POPUP_BG, BITMAP_PIXEL_FORMAT_ARGB8888, pBgBitmap);
787                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
788
789                 Font titleFont;
790                 r = titleFont.Construct(FONT_STYLE_PLAIN, titleFontSize);
791                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
792
793                 Font textFont;
794                 r = textFont.Construct(FONT_STYLE_PLAIN, textFontSize);
795                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
796
797                 pEnrichedTitleText = new (std::nothrow) EnrichedText;
798                 SysTryCatch(NID_UI, pEnrichedTitleText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
799                 pEnrichedTitleText->Construct(FloatDimension(popupWidth-sideMargin*2, titleHeight));
800
801                 pEnrichedNameText = new (std::nothrow) EnrichedText;
802                 SysTryCatch(NID_UI, pEnrichedNameText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
803                 pEnrichedNameText->Construct(FloatDimension(popupWidth-sideMargin*2, textHeight));
804
805                 pEnrichedLableText = new (std::nothrow) EnrichedText;
806                 SysTryCatch(NID_UI, pEnrichedLableText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
807                 pEnrichedLableText->Construct(FloatDimension(popupWidth-sideMargin*2, textHeight));
808
809                 pEnrichedTraitText = new (std::nothrow) EnrichedText;
810                 SysTryCatch(NID_UI, pEnrichedTraitText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
811                 pEnrichedTraitText->Construct(FloatDimension(popupWidth-sideMargin*2, textHeight));
812
813                 pEnrichedStatusText = new (std::nothrow) EnrichedText;
814                 SysTryCatch(NID_UI, pEnrichedStatusText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
815                 pEnrichedStatusText->Construct(FloatDimension(popupWidth-sideMargin*2, textHeight));
816
817                 pEnrichedHintText = new (std::nothrow) EnrichedText;
818                 SysTryCatch(NID_UI, pEnrichedHintText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
819                 pEnrichedHintText->Construct(FloatDimension(popupWidth-sideMargin*2, textHeight));
820
821                 pEnrichedValueText = new (std::nothrow) EnrichedText;
822                 SysTryCatch(NID_UI, pEnrichedValueText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
823                 pEnrichedValueText->Construct(FloatDimension(popupWidth-sideMargin*2, textHeight));
824
825                 pEnrichedBoundsText = new (std::nothrow) EnrichedText;
826                 SysTryCatch(NID_UI, pEnrichedBoundsText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
827                 pEnrichedBoundsText->Construct(FloatDimension(popupWidth-sideMargin*2, textHeight));
828
829                 pEnrichedAbsBoundsText = new (std::nothrow) EnrichedText;
830                 SysTryCatch(NID_UI, pEnrichedAbsBoundsText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
831                 pEnrichedAbsBoundsText->Construct(FloatDimension(popupWidth-sideMargin*2, textHeight));
832
833                 pElement = new (std::nothrow) TextElement;
834                 r = pElement->Construct(L"Screen reading...");
835                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
836                 pElement->SetTextColor(titleTextColor);
837                 pElement->SetFont(titleFont);
838                 r = pEnrichedTitleText->Add(*pElement);
839
840                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
841                 pEnrichedTitleText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
842                 pEnrichedTitleText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP);
843                 pEnrichedTitleText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP);
844                 pEnrichedTitleText->SetTextAbbreviationEnabled(true);
845
846                 pElement  = new (std::nothrow) TextElement;
847                 r = pElement->Construct(L"Name: ");
848                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
849
850                 pElement->SetTextColor(pointTextColor);
851                 pElement->SetFont(textFont);
852                 r = pEnrichedNameText->Add(*pElement);
853                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
854
855                 if (!(__pTargetElement->GetName().IsEmpty()))
856                 {
857                         pElement  = new (std::nothrow) TextElement;
858                         r = pElement->Construct(__pTargetElement->GetName());
859                         SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
860
861                         pElement->SetTextColor(textColor);
862                         pElement->SetFont(textFont);
863                         r = pEnrichedNameText->Add(*pElement);
864                         SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
865                         SysLog(NID_UI, " Name :::::: %s", _StringConverter::CopyToCharArrayN(__pTargetElement->GetName()));
866                 }
867                 pEnrichedNameText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
868                 pEnrichedNameText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP);
869                 pEnrichedNameText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP);
870                 pEnrichedNameText->SetTextAbbreviationEnabled(true);
871
872                 pElement  = new (std::nothrow) TextElement;
873                 SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
874                 r = pElement->Construct(L"Label: ");
875                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
876
877                 pElement->SetTextColor(pointTextColor);
878                 pElement->SetFont(textFont);
879                 r = pEnrichedLableText->Add(*pElement);
880                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
881
882                 if (!(__pTargetElement->GetLabel().IsEmpty()))
883                 {
884                         pElement  = new (std::nothrow) TextElement;
885                         SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
886                         r = pElement->Construct(__pTargetElement->GetLabel());
887                         SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
888
889                         pElement->SetTextColor(textColor);
890                         pElement->SetFont(textFont);
891                         r = pEnrichedLableText->Add(*pElement);
892                         SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
893                         SysLog(NID_UI, " Label :::::: %s", _StringConverter::CopyToCharArrayN(__pTargetElement->GetLabel()));
894                 }
895                 pEnrichedLableText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
896                 pEnrichedLableText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP);
897                 pEnrichedLableText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP);
898                 pEnrichedLableText->SetTextAbbreviationEnabled(true);
899
900                 pElement  = new (std::nothrow) TextElement;
901                 SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
902                 r = pElement->Construct(L"Trait: ");
903                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
904
905                 pElement->SetTextColor(pointTextColor);
906                 pElement->SetFont(textFont);
907                 r = pEnrichedTraitText->Add(*pElement);
908                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
909                 if (!(__pTargetElement->GetTraitString().IsEmpty()))
910                 {
911                         pElement  = new (std::nothrow) TextElement;
912                         SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
913                         r = pElement->Construct(__pTargetElement->GetTraitString());
914                         SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
915
916                         pElement->SetTextColor(textColor);
917                         pElement->SetFont(textFont);
918                         r = pEnrichedTraitText->Add(*pElement);
919                         SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
920                 }
921                 pEnrichedTraitText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
922                 pEnrichedTraitText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP);
923                 pEnrichedTraitText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP);
924                 pEnrichedTraitText->SetTextAbbreviationEnabled(true);
925
926                 pElement  = new (std::nothrow) TextElement;
927                 SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
928                 r = pElement->Construct(L"Status: ");
929                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
930
931                 pElement->SetTextColor(pointTextColor);
932                 pElement->SetFont(textFont);
933                 r = pEnrichedStatusText->Add(*pElement);
934                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
935                 if (!(__pTargetElement->GetStatus().IsEmpty()))
936                 {
937                         pElement  = new (std::nothrow) TextElement;
938                         SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
939                         r = pElement->Construct(__pTargetElement->GetStatus());
940                         SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
941
942                         pElement->SetTextColor(textColor);
943                         pElement->SetFont(textFont);
944                         r = pEnrichedStatusText->Add(*pElement);
945                         SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
946                 }
947                 pEnrichedStatusText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
948                 pEnrichedStatusText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP);
949                 pEnrichedStatusText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP);
950                 pEnrichedStatusText->SetTextAbbreviationEnabled(true);
951
952                 pElement  = new (std::nothrow) TextElement;
953                 SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
954                 r = pElement->Construct(L"Hint: ");
955                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
956
957                 pElement->SetTextColor(pointTextColor);
958                 pElement->SetFont(textFont);
959                 r = pEnrichedHintText->Add(*pElement);
960                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
961                 if (!(__pTargetElement->GetHint().IsEmpty()))
962                 {
963                         pElement  = new (std::nothrow) TextElement;
964                         SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
965                         r = pElement->Construct(__pTargetElement->GetHint());
966                         SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
967
968                         pElement->SetTextColor(textColor);
969                         pElement->SetFont(textFont);
970                         r = pEnrichedHintText->Add(*pElement);
971                         SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
972                 }
973                 pEnrichedHintText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
974                 pEnrichedHintText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP);
975                 pEnrichedHintText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP);
976                 pEnrichedHintText->SetTextAbbreviationEnabled(true);
977
978                 pElement  = new (std::nothrow) TextElement;
979                 SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
980                 r = pElement->Construct(L"Value: ");
981                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
982
983                 pElement->SetTextColor(pointTextColor);
984                 pElement->SetFont(textFont);
985                 r = pEnrichedValueText->Add(*pElement);
986                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
987                 if (!(__pTargetElement->GetValue().IsEmpty()))
988                 {
989                         pElement  = new (std::nothrow) TextElement;
990                         SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
991                         r = pElement->Construct(__pTargetElement->GetValue());
992                         SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
993
994                         pElement->SetTextColor(textColor);
995                         pElement->SetFont(textFont);
996                         r = pEnrichedValueText->Add(*pElement);
997                         SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
998                 }
999                 pEnrichedValueText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
1000                 pEnrichedValueText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP);
1001                 pEnrichedValueText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP);
1002                 pEnrichedValueText->SetTextAbbreviationEnabled(true);
1003
1004                 pElement  = new (std::nothrow) TextElement;
1005                 SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
1006                 r = pElement->Construct(L"Bound: ");
1007                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
1008
1009                 pElement->SetTextColor(pointTextColor);
1010                 pElement->SetFont(textFont);
1011                 r = pEnrichedBoundsText->Add(*pElement);
1012                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
1013
1014                 pElement  = new (std::nothrow) TextElement;
1015                 SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
1016                 FloatRectangle rect = __pTargetElement->GetBounds();
1017                 String rectString;
1018                 rectString.Format(40, L"x:%.1f, y:%.1f, w:%.1f, h:%.1f", rect.x, rect.y, rect.width, rect.height);
1019                 r = pElement->Construct(rectString);
1020                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
1021
1022                 pElement->SetTextColor(textColor);
1023                 pElement->SetFont(textFont);
1024                 r = pEnrichedBoundsText->Add(*pElement);
1025                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
1026                 pEnrichedBoundsText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
1027                 pEnrichedBoundsText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP);
1028                 pEnrichedBoundsText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP);
1029                 pEnrichedBoundsText->SetTextAbbreviationEnabled(true);
1030
1031                 pElement  = new (std::nothrow) TextElement;
1032                 SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
1033                 r = pElement->Construct(L"AbsBound: ");
1034                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
1035
1036                 pElement->SetTextColor(pointTextColor);
1037                 pElement->SetFont(textFont);
1038                 r = pEnrichedAbsBoundsText->Add(*pElement);
1039                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
1040
1041                 pElement  = new (std::nothrow) TextElement;
1042                 SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
1043                 rect = __pTargetElement->GetAbsoluteBounds();
1044                 rectString.Clear();
1045                 rectString.Format(40, L"x:%.1f, y:%.1f, w:%.1f, h:%.1f", rect.x, rect.y, rect.width, rect.height);
1046                 r = pElement->Construct(rectString);
1047                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
1048
1049                 pElement->SetTextColor(textColor);
1050                 pElement->SetFont(textFont);
1051                 r = pEnrichedAbsBoundsText->Add(*pElement);
1052                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup");
1053                 pEnrichedAbsBoundsText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT);
1054                 pEnrichedAbsBoundsText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP);
1055                 pEnrichedAbsBoundsText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP);
1056                 pEnrichedAbsBoundsText->SetTextAbbreviationEnabled(true);
1057
1058                 float x = 0;
1059                 float y = 0;
1060                 float popupHeight = topMargin + bottomMargin + titleHeight + textTopMargin + textHeight * 8;
1061                 Frame* pFrame = UiApp::GetInstance()->GetAppFrame()->GetFrame();
1062                 Form* pForm = pFrame->GetCurrentForm();
1063                 FloatDimension screen = Tizen::Ui::_ControlManager::GetInstance()->GetScreenSizeF();
1064
1065                 if (pForm->GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT
1066                         || pForm->GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1067                 {
1068                         x = (screen.width-popupWidth) / 2;
1069                         if (rect.y < screen.height/2)
1070                         {
1071                                 y = (screen.height/2 - popupHeight) /2 + screen.height/2;
1072                         }
1073                         else
1074                         {
1075                                 y = (screen.height/2 - popupHeight) /2;
1076                         }
1077                 }
1078                 else
1079                 {
1080                         y = (screen.width-popupHeight) / 2;
1081                         if (rect.x < screen.height/2)
1082                         {
1083                                 x = (screen.height/2 - popupWidth) /2 + screen.height/2;
1084                         }
1085                         else
1086                         {
1087                                 x = (screen.height/2 - popupWidth) /2;
1088                         }
1089                 }
1090
1091                 __pReadingVe->SetBounds(FloatRectangle(x, y, popupWidth, popupHeight));
1092                 pCanvas = __pReadingVe->GetCanvasN();
1093                 SysTryCatch(NID_UI, pCanvas != null, , E_SYSTEM, "System error for accessibility popup");
1094                 pCanvas->DrawNinePatchedBitmap(FloatRectangle(0, 0, popupWidth, popupHeight), *pBgBitmap);
1095                 float drawingTextY = topMargin;
1096                 pCanvas->DrawText(FloatPoint(sideMargin, drawingTextY), *pEnrichedTitleText);
1097                 drawingTextY += textTopMargin + titleHeight;
1098                 pCanvas->DrawText(FloatPoint(sideMargin, drawingTextY), *pEnrichedNameText);
1099                 drawingTextY += textHeight;
1100                 pCanvas->DrawText(FloatPoint(sideMargin, drawingTextY), *pEnrichedLableText);
1101                 drawingTextY += textHeight;
1102                 pCanvas->DrawText(FloatPoint(sideMargin, drawingTextY), *pEnrichedTraitText);
1103                 drawingTextY += textHeight;
1104                 pCanvas->DrawText(FloatPoint(sideMargin, drawingTextY), *pEnrichedStatusText);
1105                 drawingTextY += textHeight;
1106                 pCanvas->DrawText(FloatPoint(sideMargin, drawingTextY), *pEnrichedHintText);
1107                 drawingTextY += textHeight;
1108                 pCanvas->DrawText(FloatPoint(sideMargin, drawingTextY), *pEnrichedValueText);
1109                 drawingTextY += textHeight;
1110                 pCanvas->DrawText(FloatPoint(sideMargin, drawingTextY), *pEnrichedBoundsText);
1111                 drawingTextY += textHeight;
1112                 pCanvas->DrawText(FloatPoint(sideMargin, drawingTextY), *pEnrichedAbsBoundsText);
1113                 __pReadingVe->SetShowState(true);
1114                 __pReadingVe->SetFlushNeeded();
1115                 pGuidePopupTimer->SetElement(__pReadingVe);
1116
1117         }
1118         //go through
1119 CATCH:
1120         delete pCanvas;
1121         pCanvas = null;
1122         delete pBgBitmap;
1123         pBgBitmap = null;
1124         if (pEnrichedTitleText)
1125         {
1126                 pEnrichedTitleText->RemoveAll(true);
1127                 delete pEnrichedTitleText;
1128         }
1129         if (pEnrichedNameText)
1130         {
1131                 pEnrichedNameText->RemoveAll(true);
1132                 delete pEnrichedNameText;
1133         }
1134         if (pEnrichedLableText)
1135         {
1136                 pEnrichedLableText->RemoveAll(true);
1137                 delete pEnrichedLableText;
1138         }
1139         if (pEnrichedTraitText)
1140         {
1141                 pEnrichedTraitText->RemoveAll(true);
1142                 delete pEnrichedTraitText;
1143         }
1144         if (pEnrichedStatusText)
1145         {
1146                 pEnrichedStatusText->RemoveAll(true);
1147                 delete pEnrichedStatusText;
1148         }
1149         if (pEnrichedHintText)
1150         {
1151                 pEnrichedHintText->RemoveAll(true);
1152                 delete pEnrichedHintText;
1153         }
1154         if (pEnrichedValueText)
1155         {
1156                 pEnrichedValueText->RemoveAll(true);
1157                 delete pEnrichedValueText;
1158         }
1159         if (pEnrichedBoundsText)
1160         {
1161                 pEnrichedBoundsText->RemoveAll(true);
1162                 delete pEnrichedBoundsText;
1163         }
1164         if (pEnrichedAbsBoundsText)
1165         {
1166                 pEnrichedAbsBoundsText->RemoveAll(true);
1167                 delete pEnrichedAbsBoundsText;
1168         }
1169
1170         return;
1171 }
1172
1173 void
1174 _AccessibilityManager::OnFinishReading(const Tizen::Base::String& grammar)
1175 {
1176 //      HidePopup();
1177         if (!IsContainerValid(__pTargetContainer))
1178         {
1179                 return;
1180         }
1181         LinkedListT<_IAccessibilityListener*>* pList = static_cast<LinkedListT<_IAccessibilityListener*>*>(__pTargetContainer->GetListenerListN());
1182         if (pList != null)
1183         {
1184                 for (int i = 0;i<pList->GetCount();i++)
1185                 {
1186                         _IAccessibilityListener* pListener = null;
1187                         if (pList->GetAt(i, pListener) == E_SUCCESS)
1188                         {
1189                                 if (__pTargetElement)
1190                                 {
1191                                         pListener->OnAccessibilityReadElement(*__pTargetContainer, *__pTargetElement);
1192                                 }
1193                         }
1194                 }
1195                 delete pList;
1196                 pList = null;
1197         }
1198         return;
1199 }
1200
1201 String
1202 _AccessibilityManager::GetCurrentGrammar(void)
1203 {
1204         return L"";
1205 }
1206 void
1207 _AccessibilityManager::AddContainer(const _AccessibilityContainer& container)
1208 {
1209         __containerList.Add(&const_cast<_AccessibilityContainer&>(container));
1210         if(__mode == MODE_FOCUS_MOVE)
1211         {
1212                 SetGestureMode(MODE_TAP);
1213         }
1214         return;
1215 }
1216 void
1217 _AccessibilityManager::RemoveContainer(const _AccessibilityContainer& container)
1218 {
1219         __containerList.Remove(&const_cast<_AccessibilityContainer&>(container));
1220         if(__mode == MODE_FOCUS_MOVE)
1221         {
1222                 SetGestureMode(MODE_TAP);
1223         }
1224         if (__pTargetContainer == &container)
1225         {
1226                 __pTargetContainer = null;
1227                 __pTargetElement = null;
1228         }
1229         return;
1230 }
1231
1232 void
1233 _AccessibilityManager::MakeList(void)
1234 {
1235         struct DownVisitor
1236         {
1237                 DownVisitor(_Control& control, LinkedListT<_Control*>& list)
1238                 {
1239                         LinkedListT<_Control*> _list;
1240                         int count = control.GetChildCount();
1241                         _Control* pControl = null;
1242                         for (int i = 0; i < count ; i++)
1243                         {
1244                                 pControl = control.GetChild(i);
1245                                 if (pControl)
1246                                 {
1247                                         _list.Add(pControl);
1248                                 }
1249                         }
1250                         _AccessibilityItemComparer<_Control*> comparer;
1251                         _list.Sort(comparer);
1252                         int index = 0;
1253                         list.IndexOf(&control, index);
1254                         list.InsertItemsFrom(_list,index+1);
1255                         for (int i = 0; i < count ; i++)
1256                         {
1257                                 pControl = control.GetChild(i);
1258                                 DownVisitor(*pControl, list);
1259                         }
1260                 }
1261         };
1262         if ( !__needRefreshItem && GetGestureMode() == MODE_FOCUS_MOVE)
1263         {
1264                 __needRefreshItem = false;
1265                 return;
1266         }
1267         __needRefreshItem = false;
1268         result r = E_SUCCESS;
1269         int count = 0;
1270         _Control* pControl = null;
1271         _AccessibilityContainer* pContainer = null;
1272         _TouchManager* pTouchManager = _TouchManager::GetInstance();
1273         LinkedListT<_Control*> controlList;
1274         LinkedListT<_AccessibilityElement*> elementPositionList;
1275         LinkedListT<_AccessibilityElement*> elementPositionByControlList;
1276         __candidateList.RemoveAll();
1277
1278         if (pTouchManager)
1279         {
1280                 pControl = pTouchManager->GetCapturedControl();
1281                 if (pControl)
1282                 {
1283                         controlList.Add(pControl);
1284                 }
1285         }
1286
1287         if (pControl == null)
1288         {
1289                 pControl = static_cast<_Control*>(_ControlManager::GetInstance()->GetWindow(_ControlManager::GetInstance()->GetWindowCount() - 1));
1290                 controlList.Add(pControl);
1291         }
1292         DownVisitor(*pControl, controlList);
1293         count = controlList.GetCount();
1294         Dimension screen = _ResourceManager::GetInstance()->GetLogicalScreenSizen();
1295         int margin = _ControlManager::GetInstance()->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT ? screen.width : screen.height;
1296
1297         for(int i = 0 ; i < count ; i++)
1298         {
1299                 if (controlList.GetAt(i, pControl) == E_SUCCESS)
1300                 {
1301                         FloatRectangle rect = pControl->GetAbsoluteBoundsF();
1302                         if (rect.x + rect.width <= 0.0f || (rect.x) >= margin)
1303                         {
1304                                 bool inside = false;
1305                                 _Control* _pControl = pControl;
1306                                 while(_pControl)
1307                                 {
1308                                         if(dynamic_cast<_IScrollableContainer*>(_pControl))
1309                                         {
1310                                                 if (rect.x + rect.width > 0.0f && (rect.x) < margin)
1311                                                 {
1312                                                         inside = true;
1313                                                         break;
1314                                                 }
1315                                         }
1316                                         _pControl = _pControl->GetParent();
1317                                 }
1318                                 if(!inside)
1319                                 {
1320                                         _AccessibilityContainer* pContainer = pControl->GetAccessibilityContainer()->GetRootParent();
1321                                         if(pContainer != null)
1322                                         {
1323                                                 rect = pContainer->GetAbsoluteBounds();
1324                                                 if (rect.x + rect.width > 0.0f && (rect.x) < margin)
1325                                                 {
1326                                                         inside = true;
1327                                                 }
1328                                         }
1329                                 }
1330                                 if(!inside)
1331                                 {
1332                                         controlList.Remove(pControl);
1333                                         i--;
1334                                         count--;
1335                                 }
1336                         }
1337                 }
1338         }
1339         for (int i = 0; i < controlList.GetCount() ; i++)
1340         {
1341                 if (controlList.GetAt(i, pControl) == E_SUCCESS)
1342                 {
1343                         pContainer = pControl->GetAccessibilityContainer();
1344                         if (pContainer == null)
1345                         {
1346                                 continue;
1347                         }
1348                         if (IsContainerValid(pContainer))
1349                         {
1350                                 pContainer->SortElements();
1351                                 pContainer->GetElements(elementPositionList);
1352                                 pContainer->GetElements(elementPositionByControlList);
1353                         }
1354                 }
1355         }
1356         bool done = false;
1357         _ElementComparer<_AccessibilityElement*> comparer;
1358         elementPositionList.Sort(comparer);
1359         count = elementPositionList.GetCount();
1360         int index = 0;
1361         _AccessibilityElement* pPositionListElement = null;
1362         _AccessibilityElement* pPositionByControlListElement = null;
1363         while (!done && index < count && index < count)
1364         {
1365                 Rectangle rect;
1366                 r = elementPositionList.GetAt(index, pPositionListElement);
1367                 if (r != E_SUCCESS)
1368                 {
1369                         index++;
1370                         continue;
1371                 }
1372
1373                 r = elementPositionByControlList.GetAt(index, pPositionByControlListElement);
1374                 if (r != E_SUCCESS)
1375                 {
1376                         index++;
1377                         continue;
1378                 }
1379
1380                 if (pPositionListElement == pPositionByControlListElement)
1381                 {
1382                         __candidateList.Add(pPositionByControlListElement);
1383                         index++;
1384                         continue;
1385                 }
1386
1387                 if (pPositionListElement->GetParent()->GetPriority() > pPositionByControlListElement->GetParent()->GetPriority())
1388                 {
1389                         elementPositionByControlList.Remove(pPositionListElement);
1390                         elementPositionByControlList.InsertAt(pPositionListElement, index);
1391                         __candidateList.Add(pPositionListElement);
1392                         index++;
1393                         continue;
1394                 }
1395                 else if (pPositionListElement->GetParent()->GetPriority() < pPositionByControlListElement->GetParent()->GetPriority())
1396                 {
1397                         elementPositionList.Remove(pPositionByControlListElement);
1398                         elementPositionList.InsertAt(pPositionByControlListElement, index);
1399                         __candidateList.Add(pPositionByControlListElement);
1400                         index++;
1401                         continue;
1402                 }
1403
1404                 if (pPositionListElement->GetAbsoluteBounds().y > pPositionByControlListElement->GetAbsoluteBounds().y)
1405                 {
1406                         elementPositionList.Remove(pPositionByControlListElement);
1407                         elementPositionList.InsertAt(pPositionByControlListElement, index);
1408                         __candidateList.Add(pPositionByControlListElement);
1409                         index++;
1410                         continue;
1411                 }
1412                 else if (pPositionListElement->GetAbsoluteBounds().y < pPositionByControlListElement->GetAbsoluteBounds().y)
1413                 {
1414                         pControl = &(pPositionByControlListElement->GetParent()->GetOwner());
1415                         while (pControl)
1416                         {
1417                                 rect = pControl->GetAbsoluteBounds();
1418                                 if (rect.y >0)
1419                                 {
1420                                         break;
1421                                 }
1422                                 else
1423                                 {
1424                                         if(pControl->GetParent())
1425                                         {
1426                                                 pControl = pControl->GetParent();
1427                                         }
1428                                         else
1429                                         {
1430                                                 break;
1431                                         }
1432                                 }
1433                         }
1434                         if (pControl)
1435                         {
1436                                 controlList.RemoveAll();
1437                                 controlList.Add(pControl);
1438                                 DownVisitor(*pControl, controlList);
1439                                 int _count = controlList.GetCount();
1440                                 LinkedListT<_AccessibilityElement*> _elementPositionList;
1441                                 for (int i = 0; i < _count ; i++)
1442                                 {
1443                                         if (controlList.GetAt(i, pControl) == E_SUCCESS)
1444                                         {
1445                                                 pContainer = pControl->GetAccessibilityContainer();
1446                                                 if (pContainer == null)
1447                                                 {
1448                                                         continue;
1449                                                 }
1450                                                 if (IsContainerValid(pContainer))
1451                                                 {
1452                                                         pContainer->GetElements(_elementPositionList);
1453                                                 }
1454                                         }
1455                                 }
1456                                 _elementPositionList.Sort(comparer);
1457                                 _count = _elementPositionList.GetCount();
1458                                 _AccessibilityElement* pElement = null;
1459                                 for (int i = 0 ; i < _count ; i++)
1460                                 {
1461                                         r = _elementPositionList.GetAt(i, pElement);
1462                                         if (r != E_SUCCESS)
1463                                         {
1464                                                 continue;
1465                                         }
1466                                         if (__candidateList.Contains(pElement))
1467                                         {
1468                                                 continue;
1469                                         }
1470                                         __candidateList.Add(pElement);
1471                                         elementPositionByControlList.Remove(pElement);
1472                                         elementPositionByControlList.InsertAt(pElement, index);
1473                                         elementPositionList.Remove(pElement);
1474                                         elementPositionList.InsertAt(pElement, index);
1475                                         index++;
1476                                 }
1477                         }
1478                 }
1479                 else
1480                 {
1481                         elementPositionList.Remove(pPositionByControlListElement);
1482                         elementPositionList.InsertAt(pPositionByControlListElement, index);
1483                         __candidateList.Add(pPositionByControlListElement);
1484                         index++;
1485                         continue;
1486                 }
1487         }
1488
1489         count = __candidateList.GetCount();
1490         SysLog(NID_UI, "Accessibility element candidate count : %d", count);
1491         if (count < 1)
1492         {
1493                 return;
1494         }
1495
1496         _AccessibilityElement* pElement = null;
1497         for (int i = 0 ; i < count ; i++)
1498         {
1499                 r = __candidateList.GetAt(i, pElement);
1500                 if (r != E_SUCCESS)
1501                 {
1502                         continue;
1503                 }
1504                 if (pElement->GetName() == "HeaderTitleText")
1505                 {
1506                         __candidateList.Remove(pElement);
1507                         __candidateList.InsertAt(pElement, 0);
1508                 }
1509         }
1510         return;
1511 }
1512 void
1513 _AccessibilityManager::MakeList(_AccessibilityContainer* pContainer)
1514 {
1515         if (pContainer->GetOwner().IsVisible() && pContainer->IsActivated())
1516         {
1517                 pContainer->GetElements(__candidateList);
1518         }
1519         _Control* pControl = &(pContainer->GetOwner());
1520         int count = pControl->GetChildCount();
1521         for (int i = 0 ; i<count;i++)
1522         {
1523                 _Control* pChildControl = pControl->GetChild(i);
1524                 if (pChildControl)
1525                 {
1526                         MakeList(pChildControl->GetAccessibilityContainer());
1527                 }
1528         }
1529         return;
1530 }
1531 bool
1532 _AccessibilityManager::MoveFocus(_AccessibilityFocusDirection direction)
1533 {
1534         if (direction == _ACCESSIBILITY_FOCUS_DIRECTION_PREVIOUS
1535                 || direction == _ACCESSIBILITY_FOCUS_DIRECTION_NEXT)
1536         {
1537                 MakeList();
1538         }
1539         else
1540         {
1541                 return false;
1542         }
1543
1544         int count = __candidateList.GetCount();
1545         if (count <= 0)
1546         {
1547                 return false;
1548         }
1549         SysLog(NID_UI, "count ", count);
1550         result r = E_SUCCESS;
1551         int index = 0;
1552         _AccessibilityElement* pElement = null;
1553         _AccessibilityContainer* pContainer = null;
1554         bool focusManaged = false;
1555         if (IsContainerValid(__pTargetContainer))
1556         {
1557                 r = __candidateList.IndexOf(__pTargetElement, 0, index);
1558                 if (r != E_SUCCESS)
1559                 {
1560                         pElement = null;
1561                         __pTargetElement = null;
1562                         __pTargetContainer = null;
1563                 }
1564                 else
1565                 {
1566                         if ((__pTargetContainer->MoveFocus(direction)))
1567                         {
1568                                 pElement = __pTargetContainer->GetCurrentFocusedElement();
1569                                 focusManaged = true;
1570                         }
1571                         else
1572                         {
1573                                 index += direction;
1574                                 if (index < 0)
1575                                 {
1576                                         index = count - 1;
1577                                 }
1578                                 if (index > count - 1)
1579                                 {
1580                                         index = 0;
1581                                 }
1582                                  __candidateList.GetAt(index, pElement);
1583                                 if (pElement->GetParent()->IsFocusManaged())
1584                                 {
1585                                         if ((pElement->GetParent()->MoveFocus(direction)))
1586                                         {
1587                                                 focusManaged = true;
1588                                         }
1589                                 }
1590                         }
1591                 }
1592         }
1593         else
1594         {
1595                 SysTryReturn(NID_UI, __candidateList.GetAt(0, pElement) == E_SUCCESS, false, E_SUCCESS, "[E_SUCCESS] Candidates are not exist.");
1596         }
1597         if (pElement)
1598         {
1599                 pContainer = pElement->GetParent();
1600                 IListT<_IAccessibilityListener*>* pListenerList = pContainer->GetListenerListN();
1601                 if (pListenerList)
1602                 {
1603                         int listenerCount = pListenerList->GetCount();
1604                         if (listenerCount > 0)
1605                         {
1606                                 for (int i = 0;i<listenerCount;i++)
1607                                 {
1608                                         _IAccessibilityListener* pListener = null;
1609                                         if (pListenerList->GetAt(i, pListener) == E_SUCCESS)
1610                                         {
1611                                                 if (pListener->OnAccessibilityItemRefreshed(*pContainer, *pElement, direction) == true)
1612                                                 {
1613                                                         return MoveFocus(direction);
1614                                                 }
1615                                         }
1616                                 }
1617                         }
1618                         delete pListenerList;
1619                         pListenerList = null;
1620                 }
1621
1622                 if (__pTargetContainer)
1623                 {
1624                         pListenerList = __pTargetContainer->GetListenerListN();
1625                         if (pListenerList)
1626                         {
1627                                 int listenerCount = pListenerList->GetCount();
1628                                 if (listenerCount > 0)
1629                                 {
1630                                         for (int i = 0;i<listenerCount;i++)
1631                                         {
1632                                                 _IAccessibilityListener* pListener = null;
1633                                                 if (pListenerList->GetAt(i, pListener) == E_SUCCESS)
1634                                                 {
1635                                                         pListener->OnAccessibilityFocusOut(*__pTargetContainer, *__pTargetElement);
1636                                                 }
1637                                         }
1638                                 }
1639                                 delete pListenerList;
1640                                 pListenerList = null;
1641                         }
1642                 }
1643                 if(__pTargetContainer)
1644                 {
1645                         __pTargetContainer->SetCurrentFocusedElement(null);
1646                 }
1647                 if (focusManaged)
1648                 {
1649                         __pTargetElement = pElement;
1650                         __pTargetContainer = pContainer;
1651                         __targetControlHandle = pContainer->GetOwner().GetHandle();
1652                         EraseFocusUi();
1653                 }
1654                 else
1655                 {
1656
1657                         __pTargetElement = pElement;
1658                         __pTargetContainer = pContainer;
1659                         __targetControlHandle = pContainer->GetOwner().GetHandle();
1660                         pListenerList = __pTargetContainer->GetListenerListN();
1661                         if (pListenerList)
1662                         {
1663                                 int listenerCount = pListenerList->GetCount();
1664                                 if (listenerCount > 0)
1665                                 {
1666                                         for (int i = 0;i<listenerCount;i++)
1667                                         {
1668                                                 _IAccessibilityListener* pListener = null;
1669                                                 if (pListenerList->GetAt(i, pListener) == E_SUCCESS)
1670                                                 {
1671                                                         pListener->OnAccessibilityFocusIn(*__pTargetContainer, *__pTargetElement);
1672                                                         DrawFocusUi(*__pTargetElement);
1673                                                         if (direction == _ACCESSIBILITY_FOCUS_DIRECTION_PREVIOUS)
1674                                                         {
1675                                                                 pListener->OnAccessibilityFocusMovedPrevious(*__pTargetContainer, *__pTargetElement);
1676                                                         }
1677                                                         else if (direction == _ACCESSIBILITY_FOCUS_DIRECTION_NEXT)
1678                                                         {
1679                                                                 pListener->OnAccessibilityFocusMovedNext(*__pTargetContainer, *__pTargetElement);
1680                                                         }
1681                                                 }
1682                                         }
1683                                 }
1684                         }
1685                         else
1686                         {
1687                                 DrawFocusUi(*__pTargetElement);
1688                         }
1689                         delete pListenerList;
1690                         pListenerList = null;
1691                         ReadElement(*pElement);
1692                 }
1693                 return true;
1694         }
1695         return false;
1696 }
1697 void
1698 _AccessibilityManager::RequestToDrawFocusUi()
1699 {
1700         if (__pTargetContainer)
1701         {
1702                 //HidePopup();
1703                 DrawFocusUi(*__pTargetElement);
1704         }
1705 }
1706
1707 void
1708 _AccessibilityManager::RequestAutoReading(_AccessibilityAutoReadingMode mode)
1709 {
1710         if(__screenReaderIsEnabled)
1711         {
1712                 if (mode == _ACCESSIBILITY_AUTO_READING_MODE_RESET)
1713                 {
1714                         __pTitleElement = null;
1715                         return;
1716                 }
1717                 pAutoReadingTimer->Start(mode);
1718         }
1719 }
1720
1721 void
1722 _AccessibilityManager::SetTtsMode(_AccessibilityTtsMode mode)
1723 {
1724         if (__pTtsPlayer)
1725         {
1726                 //__pTtsPlayer->SetMode(mode);
1727         }
1728 }
1729
1730 void
1731 _AccessibilityManager::SetGlobalFocusedElement(_AccessibilityElement& element)
1732 {
1733         _AccessibilityElement* pElement = &element;
1734         if (!IsContainerValid(pElement->GetParent()))
1735         {
1736                 return;
1737         }
1738         __pTargetContainer = pElement->GetParent();
1739         __pTargetElement = pElement;
1740         RequestAutoReading(_ACCESSIBILITY_AUTO_READING_MODE_CURRENT_FOCUS);
1741 }
1742
1743 void
1744 _AccessibilityManager::EraseFocusUi(void)
1745 {
1746         if (__focusedControlHandle.IsValid())
1747         {
1748                 if (__pFocusVe)
1749                 {
1750                         __pFocusVe->Destroy();
1751                         __pFocusVe = null;
1752                 }
1753         }
1754         else
1755         {
1756                 __pFocusVe = null;
1757         }
1758 }
1759 void
1760 _AccessibilityManager::DrawFocusUi(const _AccessibilityElement& element)
1761 {
1762         FloatRectangle rectangle = element.GetBounds();
1763         Canvas* pCanvas = null;
1764
1765         _AccessibilityContainer* pContainer = element.GetParent();
1766
1767         if (__focusedControlHandle.IsValid())
1768         {
1769                 if (__pFocusVe)
1770                 {
1771                         __pFocusVe->Destroy();
1772                         __pFocusVe = null;
1773                 }
1774         }
1775         else
1776         {
1777                 __pFocusVe = null;
1778         }
1779
1780         result r = E_SUCCESS;
1781         _Control* pControl = &const_cast<_Control&>(pContainer->GetOwner());
1782         _VisualElement* pControlVe = pControl->GetVisualElement();
1783
1784         __pFocusVe = new (std::nothrow) VisualElement();
1785         SysTryCatch(NID_UI, __pFocusVe != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
1786         r = __pFocusVe->Construct();
1787         SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error");
1788
1789         __pFocusVe->SetName("Accessibility focus ui");
1790         __pFocusVe->SetImplicitAnimationEnabled(false);
1791         __focusedControlHandle = pControl->GetHandle();
1792         pControlVe->AttachChild(*__pFocusVe);
1793
1794         if (__pFocusVe)
1795         {
1796                 __pFocusVe->SetBounds(FloatRectangle(rectangle.x, rectangle.y, rectangle.width, rectangle.height));
1797                 pCanvas = __pFocusVe->GetCanvasN();
1798                 SysTryCatch(NID_UI, pCanvas, , E_SYSTEM, "[E_SYSTEM] System error");
1799                 pCanvas->SetBackgroundColor(0x00000000);
1800                 pCanvas->Clear();
1801                 Bitmap* pBitmap = null;
1802                 result r = GET_BITMAP_CONFIG_N(ACCESSIBILITY::FOCUS, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap);
1803                 if (r == E_SUCCESS)
1804                 {
1805                         if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap))
1806                         {
1807                                 r = pCanvas->DrawNinePatchedBitmap(Rectangle(0, 0, rectangle.width, rectangle.height), *pBitmap);
1808                                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error");
1809                         }
1810                         else
1811                         {
1812                                 r = pCanvas->DrawBitmap(Rectangle(0, 0, rectangle.width, rectangle.height), *pBitmap);
1813                                 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error");
1814                         }
1815                 }
1816                 
1817                 __pFocusVe->SetShowState(true);
1818                 delete pCanvas;
1819         }
1820         pContainer ->SetCurrentFocusedElement(const_cast<_AccessibilityElement*>(&element));
1821         return;
1822 CATCH:
1823         delete pCanvas;
1824         if (__focusedControlHandle.IsValid())
1825         {
1826                 if (__pFocusVe)
1827                 {
1828                         __pFocusVe->Destroy();
1829                         __pFocusVe = null;
1830                 }
1831         }
1832         else
1833         {
1834                 __pFocusVe = null;
1835         }
1836         return;
1837 }
1838 bool
1839 _AccessibilityManager::ProcessGesture(_AccessibilityGestureType type, const FloatPoint& point)
1840 {
1841         switch(type)
1842         {
1843                 case _ACCESSIBILITY_GESTURE_TYPE_FLICK_UP:
1844                 case _ACCESSIBILITY_GESTURE_TYPE_FLICK_LEFT:
1845                         if (MoveFocus(_ACCESSIBILITY_FOCUS_DIRECTION_PREVIOUS))
1846                         {
1847                                 SetGestureMode(MODE_FOCUS_MOVE);
1848                         }
1849                         break;
1850                 case _ACCESSIBILITY_GESTURE_TYPE_FLICK_DOWN:
1851                 case _ACCESSIBILITY_GESTURE_TYPE_FLICK_RIGHT:
1852                         if (MoveFocus(_ACCESSIBILITY_FOCUS_DIRECTION_NEXT))
1853                         {
1854                                 SetGestureMode(MODE_FOCUS_MOVE);
1855                         }
1856                         break;
1857                 case _ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_ONE_TAP:
1858                 {
1859                         if (GetGestureMode() == MODE_FOCUS_MOVE)
1860                         {
1861                                 SetGestureMode(MODE_TAP);
1862                                 __candidateList.RemoveAll();
1863                         }
1864                         _Control* pControl = null;
1865                         Point pt((int)point.x, (int)point.y);
1866                         _Window* pWindow = _ControlManager::GetInstance()->GetTopVisibleWindow();
1867                         if (!(pWindow->IsLayoutChangable()))
1868                         {
1869                                 Rectangle topWindowAbsBounds = pWindow->GetAbsoluteBounds();
1870                                 pt.x = pt.x + topWindowAbsBounds.x;
1871                                 pt.y = pt.y + topWindowAbsBounds.y;
1872                         }
1873                         pControl = _ControlManager::GetInstance()->GetTopmostTouchedControl(pt);
1874                         if (pControl == null || !(pControl->GetAbsoluteBounds().Contains(pt)))
1875                         {
1876                                 return false;
1877                         }
1878                         _AccessibilityContainer* pAccContainer = pControl->GetAccessibilityContainer();
1879                         while(!(pAccContainer->IsActivated()))
1880                         {
1881                                 _Control* _pControl = pAccContainer->GetOwner().GetParent();
1882                                 if (_pControl == null)
1883                                 {
1884                                         return false;
1885                                 }
1886                                 pAccContainer = _pControl->GetAccessibilityContainer();
1887                                 if (pAccContainer == null)
1888                                 {
1889                                         return false;
1890                                 }
1891                         }
1892                         _AccessibilityElement* pElement = pAccContainer->Hit(pt);
1893                         if (pElement == null)
1894                         {
1895                                 return false;
1896                         }
1897
1898                         if (__pTargetElement == pElement)
1899                         {
1900                                 if (__pTtsPlayer)
1901                                 {
1902                                         AccessibilityScreenReaderStatus status = __pTtsPlayer->GetStatus();
1903                                         if (status == ACCESSIBILITY_SCREEN_READER_STATUS_PLAYING)
1904                                         {
1905                                                 return true;
1906                                         }
1907                                 }
1908                         }
1909
1910                         if (!(pAccContainer->MoveFocus(pt)))
1911                         {
1912                                 return false;
1913                         }
1914                         LinkedListT<_IAccessibilityListener*>* pList = null;
1915                         if (IsContainerValid(__pTargetContainer))
1916                         {
1917                                 __pTargetContainer->ResetFocus();
1918                                 __pTargetContainer->GetOwner().Invalidate();
1919                                 pList = static_cast<LinkedListT<_IAccessibilityListener*>*>(__pTargetContainer->GetListenerListN());
1920                                 if (pList != null)
1921                                 {
1922                                         int count = pList->GetCount();
1923                                         for (int i = 0;i<count;i++)
1924                                         {
1925                                                 _IAccessibilityListener* pListener = null;
1926                                                 if (pList->GetAt(i, pListener) == E_SUCCESS)
1927                                                 {
1928                                                         pListener->OnAccessibilityFocusOut(*__pTargetContainer, *__pTargetElement);
1929                                                 }
1930                                         }
1931                                         delete pList;
1932                                 }
1933                         }
1934                         if(__pTargetContainer)
1935                         {
1936                                 __pTargetContainer->SetCurrentFocusedElement(null);
1937                         }
1938                         if (pAccContainer->IsFocusManaged())
1939                         {
1940                                 __pTargetContainer = pAccContainer;
1941                                 __targetControlHandle = pAccContainer->GetOwner().GetHandle();
1942                                 __pTargetElement = pElement;
1943                                 EraseFocusUi();
1944                         }
1945                         else
1946                         {
1947                                 __pTargetContainer = pAccContainer;
1948                                 __targetControlHandle = pAccContainer->GetOwner().GetHandle();
1949                                 __pTargetElement = pElement;
1950                                 pList = static_cast<LinkedListT<_IAccessibilityListener*>*>(__pTargetContainer->GetListenerListN());
1951                                 if (pList != null)
1952                                 {
1953                                         int count = pList->GetCount();
1954                                         for (int i = 0;i<count;i++)
1955                                         {
1956                                                 _IAccessibilityListener* pListener = null;
1957                                                 if (pList->GetAt(i, pListener) == E_SUCCESS)
1958                                                 {
1959                                                         pListener->OnAccessibilityFocusIn(*__pTargetContainer, *__pTargetElement);
1960                                                 }
1961                                         }
1962                                         delete pList;
1963                                 }
1964                                 DrawFocusUi(*pElement);
1965                                 ReadElement(*pElement);
1966                         }
1967                 }
1968                         break;
1969                 case _ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_DOUBLE_TAP:
1970                 {
1971                         if (GetGestureMode() == MODE_FOCUS_MOVE)
1972                         {
1973                                 SetGestureMode(MODE_TAP);
1974                                 __candidateList.RemoveAll();
1975                         }
1976                         if (__pTargetElement == null)
1977                         {
1978                                 return true;
1979                         }
1980                         _TouchManager* pTouchMgr = _TouchManager::GetInstance();
1981                         _Control* _pControl = null;
1982                         if (pTouchMgr == null)
1983                         {
1984                                 return false;
1985                         }
1986                         if (IsContainerValid(__pTargetContainer))
1987                         {
1988                                 _pControl = &(__pTargetContainer->GetOwner());
1989                         }
1990                         else
1991                         {
1992                                 return false;
1993                         }
1994                         if (_pControl == null)
1995                         {
1996                                 return false;
1997                         }
1998                         if (_pControl->GetEnableState() == false)
1999                         {
2000                                 ReadContent(L"Unavailable");
2001                                 return true;
2002                         }
2003                         if (__pTargetElement->GetSupportOperatingGesture())
2004                         {
2005                                 long long tick = 0;
2006                                 if (_SystemTimeImpl::GetTicks(tick) != E_SUCCESS)
2007                                 {
2008                                         tick = 0;
2009                                 }
2010                                 FloatRectangle rect = __pTargetElement->GetAbsoluteBounds();
2011                                 Point _point((int)(rect.x + rect.width/2), (int)(rect.y + rect.height/2));
2012                                 _UiTouchEvent pressedEvent(_pControl->GetHandle(), _TouchInfo(0, _TOUCH_PRESSED, _point, false, tick));
2013                                 _UiTouchEvent releasedEvent(_pControl->GetHandle(), _TouchInfo(0, _TOUCH_RELEASED, _point, false, tick+1));
2014                                 pressedEvent.SetAccessibilityEvent(true);
2015                                 releasedEvent.SetAccessibilityEvent(true);
2016
2017                                 unsigned int pointId = 0;
2018                                 pointId = pTouchMgr->GeneratePointId(0);
2019                                 SysLog(NID_UI, "Accessibility manager generated touch pressed event. id: %d", pointId);
2020                                 _UiEventManager::GetInstance()->SendEvent(pressedEvent);
2021                                 pointId = pTouchMgr->GetPointId(0);
2022                                 SysLog(NID_UI, "Accessibility manager generated touch released event. id: %d", pointId);
2023                                 _UiEventManager::GetInstance()->SendEvent(releasedEvent);
2024                                 if (!IsContainerValid(__pTargetContainer))
2025                                 {
2026                                         return false;
2027                                 }
2028                         }
2029                         LinkedListT<_IAccessibilityListener*>* pList = static_cast<LinkedListT<_IAccessibilityListener*>*>(__pTargetContainer->GetListenerListN());
2030                         if (pList != null)
2031                         {
2032                                 int count = pList->GetCount();
2033                                 SysLog(NID_UI, "Accessibility manager called listeners. count : %d", count);
2034                                 for (int i = 0;i<count;i++)
2035                                 {
2036                                         _IAccessibilityListener* pListener = null;
2037                                         if (pList->GetAt(i, pListener) == E_SUCCESS)
2038                                         {
2039                                                 pListener->OnAccessibilityActionPerformed(*__pTargetContainer, *__pTargetElement);
2040                                         }
2041                                 }
2042                                 delete pList;
2043                         }
2044                 }
2045                 break;
2046
2047                 case _ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_LONGPRESS:
2048                         break;
2049                 case _ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_PANNING_STARTED:
2050                 case _ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_PANNING_CHANGED:
2051                 case _ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_PANNING_FINISHED:
2052                         break;
2053                 case _ACCESSIBILITY_GESTURE_TYPE_VALUE_INCREASED:
2054                         {
2055                                 if (!IsContainerValid(__pTargetContainer))
2056                                 {
2057                                         return false;
2058                                 }
2059
2060                                 _Control* pControl = &(__pTargetContainer->GetOwner());
2061                                 if (pControl->GetEnableState() == false)
2062                                 {
2063                                         ReadContent(L"Unavailable");
2064                                         return true;
2065                                 }
2066
2067                                 LinkedListT<_IAccessibilityListener*>* pList = static_cast<LinkedListT<_IAccessibilityListener*>*>(__pTargetContainer->GetListenerListN());
2068                                 if (pList != null)
2069                                 {
2070                                         int count = pList->GetCount();
2071                                         for (int i = 0;i<count;i++)
2072                                         {
2073                                                 _IAccessibilityListener* pListener = null;
2074                                                 if (pList->GetAt(i, pListener) == E_SUCCESS)
2075                                                 {
2076                                                         pListener->OnAccessibilityValueIncreased(*__pTargetContainer, *__pTargetElement);
2077                                                 }
2078                                         }
2079                                         delete pList;
2080                                 }
2081                         }
2082                         break;
2083                 case _ACCESSIBILITY_GESTURE_TYPE_VALUE_DECREASED:
2084                         {
2085                                 if (!IsContainerValid(__pTargetContainer))
2086                                 {
2087                                         return false;
2088                                 }
2089
2090                                 _Control* pControl = &(__pTargetContainer->GetOwner());
2091                                 if (pControl->GetEnableState() == false)
2092                                 {
2093                                         ReadContent(L"Unavailable");
2094                                         return true;
2095                                 }
2096
2097                                 LinkedListT<_IAccessibilityListener*>* pList = static_cast<LinkedListT<_IAccessibilityListener*>*>(__pTargetContainer->GetListenerListN());
2098                                 if (pList != null)
2099                                 {
2100                                         int count = pList->GetCount();
2101                                         for (int i = 0;i<count;i++)
2102                                         {
2103                                                 _IAccessibilityListener* pListener = null;
2104                                                 if (pList->GetAt(i, pListener) == E_SUCCESS)
2105                                                 {
2106                                                         pListener->OnAccessibilityValueDecreased(*__pTargetContainer, *__pTargetElement);
2107                                                 }
2108                                         }
2109                                         delete pList;
2110                                 }
2111                         }
2112                         break;
2113                 case _ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_STARTED:
2114                 {
2115                         Point pt((int)point.x, (int)point.y);
2116                         _Control* pControl = _ControlManager::GetInstance()->GetTopmostTouchedControl(pt);
2117                         if (pControl == null)
2118                         {
2119                                 SysLog(NID_UI, "Two finger panning is started. but control is null");
2120                                 return false;
2121                         }
2122                         long long tick = 0;
2123                         if (_SystemTimeImpl::GetTicks(tick) != E_SUCCESS)
2124                         {
2125                                 tick = 0;
2126                         }
2127                         _UiTouchEvent pressedEvent(pControl->GetHandle(), _TouchInfo(0, _TOUCH_PRESSED, pt, false, tick));
2128                         unsigned int pointId = 0;
2129                         pointId = _TouchManager::GetInstance()->GeneratePointId(0);
2130                         _UiEventManager::GetInstance()->SendEvent(pressedEvent);
2131                         __pPanningControl = pControl;
2132                         SetGestureMode(MODE_PANNING);
2133                         SysLog(NID_UI, "Two finger panning is started. x:%d, y:%d", pt.x, pt.y);
2134                         }
2135                         break;
2136                 case _ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_CHANGED:
2137                 {
2138                         if (__pPanningControl == null || GetGestureMode() != MODE_PANNING)
2139                         {
2140                                 SetGestureMode(MODE_TAP);
2141                                 SysLog(NID_UI, "Two finger panning is started. but control is null");
2142                                 return false;
2143                         }
2144                         long long tick = 0;
2145                         if (_SystemTimeImpl::GetTicks(tick) != E_SUCCESS)
2146                         {
2147                                 tick = 0;
2148                         }
2149                         Point pt((int)point.x, (int)point.y);
2150                         _UiTouchEvent movedEvent(__pPanningControl->GetHandle(), _TouchInfo(0, _TOUCH_MOVED, pt, false, tick));
2151                         unsigned int pointId = 0;
2152                         pointId = _TouchManager::GetInstance()->GetPointId(0);
2153                         _UiEventManager::GetInstance()->SendEvent(movedEvent);
2154                         SysLog(NID_UI, "Two finger panning is moved. x:%d, y:%d", pt.x, pt.y);
2155                 }
2156                         break;
2157                 case _ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_FINISHED:
2158                 {
2159                         if (__pPanningControl == null || GetGestureMode() != MODE_PANNING)
2160                         {
2161                                 SetGestureMode(MODE_TAP);
2162                                 SysLog(NID_UI, "Two finger panning is started. but control is null");
2163                                 return false;
2164                         }
2165                         long long tick = 0;
2166                         if (_SystemTimeImpl::GetTicks(tick) != E_SUCCESS)
2167                         {
2168                                 tick = 0;
2169                         }
2170                         Point pt((int)point.x, (int)point.y);
2171                         _UiTouchEvent releasedEvent(__pPanningControl->GetHandle(), _TouchInfo(0, _TOUCH_RELEASED, pt, false, tick));
2172                         unsigned int pointId = 0;
2173                         pointId = _TouchManager::GetInstance()->GetPointId(0);
2174                         _UiEventManager::GetInstance()->SendEvent(releasedEvent);
2175                         __pPanningControl = null;
2176                         SetGestureMode(MODE_TAP);
2177                         SysLog(NID_UI, "Two finger panning is finished. x:%d, y:%d", pt.x, pt.y);
2178                 }
2179                         break;
2180                 default:
2181                         break;
2182         }
2183         return true;
2184 }
2185
2186 Tizen::Base::_HandleT<_AccessibilityContainer>
2187 _AccessibilityManager::Register(_AccessibilityContainer* pObject)
2188 {
2189         if (pObject == null)
2190         {
2191                 return Tizen::Base::_HandleT<_AccessibilityContainer>();
2192         }
2193
2194         return __objectManager.Register(*pObject);
2195 }
2196 void
2197 _AccessibilityManager::Unregister(Tizen::Base::_HandleT <_AccessibilityContainer> handle)
2198 {
2199         __objectManager.Unregister(handle);
2200         return;
2201 }
2202
2203 void
2204 _AccessibilityManager::OnChangedLocale(void)
2205 {
2206         if (__pTtsPlayer && __pSettingLoader)
2207         {
2208                 __pTtsPlayer->SetLocale(__pSettingLoader->GetLocale());
2209         }
2210 }
2211
2212 void
2213 _AccessibilityManager::OnAccessibilityScreenReaderIsActivated(bool set)
2214 {
2215         SysLog(NID_UI, "Screen reader status is changed. %d", set);
2216         if (__screenReaderIsEnabled == set)
2217         {
2218                 return;
2219         }
2220         else
2221         {
2222                 __screenReaderIsEnabled = set;
2223                 if (__screenReaderIsEnabled)
2224                 {
2225                         if (__pTtsPlayer)
2226                         {
2227                                 __pTtsPlayer->SetLocale(__pSettingLoader->GetLocale());
2228                                 __pTtsPlayer->Activate();
2229                                 RequestAutoReading(_ACCESSIBILITY_AUTO_READING_MODE_FIRST_ITEM);
2230                         }
2231                 }
2232                 else
2233                 {
2234                         __pTtsPlayer->Deactivate();
2235                         EraseFocusUi();
2236                         __pTargetContainer = null;
2237                         __pTargetElement = null;
2238                         __pTitleElement = null;
2239                         __candidateList.RemoveAll();
2240                         __mode = MODE_NONE;
2241                         __targetControlHandle = _ControlHandle();
2242                         __focusedControlHandle = _ControlHandle();
2243                         __readingPopupParentHandle = _ControlHandle();
2244                 }
2245         }
2246 }
2247 bool
2248 _AccessibilityManager::IsScreenReaderActivated(void)
2249 {
2250         __screenReaderIsEnabled = __pSettingLoader->IsScreenReaderActivated();
2251         return __screenReaderIsEnabled;
2252 }
2253 float
2254 _AccessibilityManager::GetLargeFontSize(void)
2255 {
2256         return __pSettingLoader->GetLargeFontSize();
2257 }
2258
2259 bool
2260 _AccessibilityManager::IsActivated()
2261 {
2262         return __screenReaderIsEnabled;
2263 }
2264
2265 bool
2266 _AccessibilityManager::IsContainerValid(_AccessibilityContainer* pContainer)
2267 {
2268         if (pContainer == null)
2269         {
2270                 return false;
2271         }
2272         if (!(pContainer->IsActivated()))
2273         {
2274                 return false;
2275         }
2276         if (!(pContainer->GetHandle().IsValid()))
2277         {
2278                 return false;
2279         }
2280         if (!(pContainer->GetOwner().GetHandle().IsValid()))
2281         {
2282                 return false;
2283         }
2284         if (!(pContainer->GetOwner().IsVisible()))
2285         {
2286                 return false;
2287         }
2288         if (!IsVisible(pContainer))
2289         {
2290                 return false;
2291         }
2292         return true;
2293 }
2294 bool
2295 _AccessibilityManager::IsTargetContainerValid(void)
2296 {
2297
2298         if (__pTargetContainer && __targetControlHandle.IsValid() && __pTargetContainer->GetOwner().IsVisible() && __pTargetContainer->GetOwner().GetRootWindow() && IsVisible(__pTargetContainer))
2299         {
2300                 return true;
2301         }
2302         return false;
2303 }
2304 bool
2305 _AccessibilityManager::IsFirstElementGainedFocus(void)
2306 {
2307         int count = __candidateList.GetCount();
2308         if(count == 0)
2309         {
2310                 return false;
2311         }
2312         if(__pTargetElement == null)
2313         {
2314                 return false;
2315         }
2316         _AccessibilityElement* pElement = null;
2317         if(__candidateList.GetAt(0, pElement) == E_SUCCESS)
2318         {
2319                 if(pElement == __pTargetElement)
2320                 {
2321                         return true;
2322                 }
2323         }
2324         return false;
2325 }
2326 bool
2327 _AccessibilityManager::IsLastElementGainedFocus(void)
2328 {
2329         int count = __candidateList.GetCount();
2330         if(count == 0)
2331         {
2332                 return false;
2333         }
2334         if(__pTargetElement == null)
2335         {
2336                 return false;
2337         }
2338         _AccessibilityElement* pElement = null;
2339         if(__candidateList.GetAt(count-1, pElement) == E_SUCCESS)
2340         {
2341                 if(pElement == __pTargetElement)
2342                 {
2343                         return true;
2344                 }
2345         }
2346         return false;
2347 }
2348 bool
2349 _AccessibilityManager::IsVisible(_AccessibilityElement* pElement)
2350 {
2351         return IsVisible(pElement->GetParent());
2352 }
2353 bool
2354 _AccessibilityManager::IsVisible(_AccessibilityContainer* pContainer)
2355 {
2356         _ControlManager* pControlManager = _ControlManager::GetInstance();
2357         int count = pControlManager->GetWindowCount();
2358         if (count < 1)
2359         {
2360                 return false;
2361         }
2362         _Window* pTopWindow = pControlManager->GetWindow(count - 1);
2363         if (pTopWindow != pContainer->GetOwner().GetRootWindow())
2364         {
2365                 return false;
2366         }
2367         return true;
2368 }
2369 void
2370 _AccessibilityManager::SetGestureMode(GestureMode mode)
2371 {
2372         __mode = mode;
2373 }
2374 _AccessibilityManager::GestureMode
2375 _AccessibilityManager::GetGestureMode(void)
2376 {
2377         return __mode;
2378 }
2379
2380 void
2381 _AccessibilityManager::NeedRefreshItem(void)
2382 {
2383         __needRefreshItem = true;
2384 }
2385
2386 }} //Tizen::Ui
2387