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