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