8c8d892a431fc058dafeb9165db57ba9b57eb78b
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_Popup.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
18 /**
19  * @file                FUiCtrl_Popup.cpp
20  * @brief       This is the implementation file for the _Popup class.
21  */
22
23 #include <FBaseSysLog.h>
24 #include <FBaseErrorDefine.h>
25 #include <FGrp_BitmapImpl.h>
26 #include <FUiCtrlForm.h>
27 #include "FUi_AccessibilityContainer.h"
28 #include "FUi_AccessibilityElement.h"
29 #include "FUi_ControlManager.h"
30 #include "FUi_CoordinateSystemUtils.h"
31 #include "FUi_EcoreEvas.h"
32 #include "FUi_EcoreEvasMgr.h"
33 #include "FUi_ModalLoopManager.h"
34 #include "FUi_ResourceManager.h"
35 #include "FUi_DataBindingContext.h"
36 #include "FUiCtrl_Popup.h"
37 #include "FUiCtrl_PopupPresenter.h"
38 #include "FUiCtrl_Form.h"
39 #include "FUiCtrl_Frame.h"
40 #include "FUiCtrl_Indicator.h"
41
42
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Ui::Animations;
45 using namespace Tizen::Ui;
46 using namespace Tizen::Base;
47
48
49 namespace Tizen { namespace Ui { namespace Controls
50 {
51
52
53 _Popup::_Popup(void)
54         : _titleState(false)
55         , _titleText(L"")
56         , _bgColor(Color(0xFFFFFFFF))
57         , _titleTextColor(Color(0xFFFFFFFF))
58         , _pBgBitmap(null)
59         , _pComposedBgBitmap(null)
60         , _pOutlineBitmap(null)
61         , _pComposedTitleBitmap(null)
62         , _pTitleEffectBitmap(null)
63         , _pTitleTextAccessibilityElement(null)
64         , __pPopupPresenter(null)
65         , __bounds(0.0f, 0.0f, 0.0f, 0.0f)
66         , __popupResult(POPUP_RESULT_NONE)
67         , __pIndicator(null)
68 {
69         __pIndicator = _Indicator::CreateIndicator();
70         SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
71 }
72
73 _Popup::~_Popup(void)
74 {
75         delete __pPopupPresenter;
76         __pPopupPresenter = null;
77
78         delete _pBgBitmap;
79         _pBgBitmap = null;
80
81         delete _pComposedBgBitmap;
82         _pComposedBgBitmap = null;
83
84         delete _pOutlineBitmap;
85         _pOutlineBitmap = null;
86
87         delete _pComposedTitleBitmap;
88         _pComposedTitleBitmap = null;
89
90         delete _pTitleEffectBitmap;
91         _pTitleEffectBitmap = null;
92
93         if (_pTitleTextAccessibilityElement)
94         {
95                 _pTitleTextAccessibilityElement->Activate(false);
96                 _pTitleTextAccessibilityElement = null;
97         }
98
99         if (__pIndicator)
100         {
101                 __pIndicator->Destroy();
102                 __pIndicator = null;
103         }
104 }
105
106 _Popup*
107 _Popup::CreatePopupN(void)
108 {
109         _Popup* pPopup = new (std::nothrow) _Popup();
110         SysTryReturn(NID_UI_CTRL, pPopup != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
111
112         result r = pPopup->CreateRootVisualElement(_WINDOW_TYPE_SUB);
113         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
114
115         // for taking touch event
116         pPopup->AcquireHandle();
117
118         return pPopup;
119
120 CATCH:
121         delete pPopup;
122         return null;
123 }
124
125 result
126 _Popup::Initialize(bool hasTitle, const Tizen::Graphics::FloatRectangle& bounds)
127 {
128         result r = E_SUCCESS;
129
130         _AccessibilityContainer* pContainer = null;
131         _DataBindingContext* pContext = null;
132         Bitmap* titleBgBitmap = null;
133         Color titleBgColor(0x00000000);
134
135         _titleState = hasTitle;
136         __bounds = bounds;
137         SetClientBounds(GetPopupClientArea());
138
139         _PopupPresenter* pPresenter = new (std::nothrow) _PopupPresenter();
140         SysTryReturn(NID_UI_CTRL, pPresenter != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
141
142         SetPresenter(*pPresenter);
143         pPresenter->Initialize(*this);
144
145         SetDimmingEnabled(true);
146
147         GET_COLOR_CONFIG(POPUP::BG_NORMAL, _bgColor);
148         GET_COLOR_CONFIG(POPUP::TITLE_TEXT_NORMAL, _titleTextColor);
149
150         if (_titleState)
151         {
152                 GET_COLOR_CONFIG(POPUP::TITLE_BG_NORMAL, titleBgColor);
153
154                 // Popup-TitleBitmap
155                 GET_BITMAP_CONFIG_N(POPUP::BG_TITLE_AREA, BITMAP_PIXEL_FORMAT_ARGB8888, titleBgBitmap);
156                 r = GetLastResult();
157                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
158
159                 _pComposedTitleBitmap = _BitmapImpl::GetColorReplacedBitmapN(*titleBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), titleBgColor);
160                  r = GetLastResult();
161                  SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
162
163                 // Popup-TitleEffectBitmap
164                 GET_BITMAP_CONFIG_N(POPUP::BG_TITLE_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, _pTitleEffectBitmap);
165                 r = GetLastResult();
166                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
167         }
168
169         // Popup-Outline
170         GET_BITMAP_CONFIG_N(POPUP::BG_OUTLINE_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, _pOutlineBitmap);
171         r = GetLastResult();
172         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
173
174         // Popup BG
175         GET_BITMAP_CONFIG_N(POPUP::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, _pBgBitmap);
176         r = GetLastResult();
177         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
178
179         _pComposedBgBitmap = _BitmapImpl::GetColorReplacedBitmapN(*_pBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), _bgColor);
180         r = GetLastResult();
181         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
182
183         // for clearing canvas
184         r = GetVisualElement()->SetSurfaceOpaque(false);
185         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
186
187         GetVisualElement()->SetClipChildrenEnabled(true);
188
189         //create data binding context
190         pContext = new (std::nothrow) _DataBindingContext(*this);
191         SysTryCatch(NID_UI_CTRL, pContext != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
192         r = GetLastResult();
193         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
194
195         SetDataBindingContext(pContext);
196
197         pContainer = GetAccessibilityContainer();
198         if(pContainer != null)
199         {
200                 pContainer->Activate(true);
201         }
202
203         if (titleBgBitmap != null)
204         {
205                 delete titleBgBitmap;
206                 titleBgBitmap = null;
207         }
208
209         return r;
210
211 CATCH:
212         delete pContext;
213
214         if (titleBgBitmap != null)
215         {
216                 delete titleBgBitmap;
217                 titleBgBitmap = null;
218         }
219
220         if (_pComposedTitleBitmap != null)
221         {
222                 delete _pComposedTitleBitmap;
223                 _pComposedTitleBitmap = null;
224         }
225
226         if (_pTitleEffectBitmap != null)
227         {
228                 delete _pTitleEffectBitmap;
229                 _pTitleEffectBitmap = null;
230         }
231
232         delete _pOutlineBitmap;
233         _pOutlineBitmap = null;
234
235         delete _pBgBitmap;
236         _pBgBitmap = null;
237
238         delete _pComposedBgBitmap;
239         _pComposedBgBitmap = null;
240
241         return r;
242 }
243
244 result
245 _Popup::SetPresenter(const _PopupPresenter& popupPresenter)
246 {
247         __pPopupPresenter = const_cast <_PopupPresenter*>(&popupPresenter);
248
249         return E_SUCCESS;
250 }
251
252 _PopupPresenter*
253 _Popup::GetPresenter(void)
254 {
255         return __pPopupPresenter;
256 }
257
258 result
259 _Popup::DoModal(int& modalResult)
260 {
261         SysTryReturn(NID_UI_CTRL, __pPopupPresenter != null, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not allocated.");
262
263         __pPopupPresenter->DoModal(modalResult);
264
265         result r = GetLastResult();
266         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
267
268         return r;
269 }
270
271 result
272 _Popup::EndModal(int modalResult)
273 {
274         _ModalLoopManager::GetInstance()->EndMainLoop(POPUP_RESULT_END_MODAL, false);
275
276         SetReturnValue(static_cast <PopupModalResult>(modalResult));
277
278         return E_SUCCESS;
279 }
280
281 void
282 _Popup::SetReturnValue(PopupModalResult rtn)
283 {
284         __popupResult = rtn;
285 }
286
287 int
288 _Popup::GetPopupReturnValue(void) const
289 {
290         return (int) __popupResult;
291 }
292
293 bool
294 _Popup::HasTitle(void) const
295 {
296         return _titleState;
297 }
298
299 FloatPoint
300 _Popup::TranslateFromClientAreaPosition(const FloatPoint& clientPosition) const
301 {
302         FloatRectangle leftTop = GetClientBoundsF();
303         result r = GetLastResult();
304         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, FloatPoint(-1.0f, -1.0f), r, "[%s] Propagating.", GetErrorMessage(r));
305
306         return FloatPoint(clientPosition.x + leftTop.x, clientPosition.y + leftTop.y);
307 }
308
309 FloatPoint
310 _Popup::TranslateToClientAreaPosition(const FloatPoint& position) const
311 {
312         FloatRectangle leftTop = GetClientBoundsF();
313         result r = GetLastResult();
314         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, FloatPoint(-1.0f, -1.0f), r, "[%s] Propagating.", GetErrorMessage(r));
315
316         return FloatPoint(position.x - leftTop.x, position.y - leftTop.y);
317 }
318
319 Canvas*
320 _Popup::GetClientAreaCanvasN(void) const
321 {
322         Canvas* pCanvas = GetCanvasN(GetClientBoundsF());
323         if ((pCanvas == null) || (GetLastResult() != E_SUCCESS))
324         {
325                 SysLog(NID_UI_CTRL, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
326                 delete pCanvas;
327                 return null;
328         }
329
330         return pCanvas;
331 }
332
333 void
334 _Popup::SetColor(const Color& color)
335 {
336         if (_pComposedBgBitmap != null)
337         {
338                 delete _pComposedBgBitmap;
339                 _pComposedBgBitmap = null;
340         }
341
342         _pComposedBgBitmap = _BitmapImpl::GetColorReplacedBitmapN(*_pBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), color);
343
344         _bgColor = color;
345 }
346
347 Color
348 _Popup::GetColor() const
349 {
350         return _bgColor;
351 }
352
353 void
354 _Popup::SetTitleTextColor(const Color& color)
355 {
356         _titleTextColor = color;
357 }
358
359 Color
360 _Popup::GetTitleTextColor() const
361 {
362         return _titleTextColor;
363 }
364
365 result
366 _Popup::SetTitleText(const String& title)
367 {
368         if (HasTitle() == true)
369         {
370                 if (__pPopupPresenter != null)
371                 {
372                         _titleText = title;
373
374                         result r = __pPopupPresenter->SetTitleTextObject(_titleText);
375                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
376
377                         if (_pTitleTextAccessibilityElement != null)
378                         {
379                                 _pTitleTextAccessibilityElement->SetLabel(title);
380                         }
381                 }
382                 return E_SUCCESS;
383         }
384         else
385         {
386                 return E_SYSTEM;
387         }
388
389 }
390
391 String
392 _Popup::GetTitleText(void) const
393 {
394         return _titleText;
395 }
396
397 const Bitmap*
398 _Popup::GetBackgroundBitmap(void) const
399 {
400         return _pComposedBgBitmap;
401 }
402
403 const Bitmap*
404 _Popup::GetOutlineBitmap(void) const
405 {
406         return _pOutlineBitmap;
407 }
408
409 Bitmap*
410 _Popup::GetTitleBackgroundBitmap(void)
411 {
412     return _pComposedTitleBitmap;
413 }
414
415 Bitmap*
416 _Popup::GetTitleBackgroundEffectBitmap(void)
417 {
418     return _pTitleEffectBitmap;
419 }
420
421
422 FloatRectangle
423 _Popup::GetPopupClientArea(void) const
424 {
425         float x = 0.0f;
426         float y = 0.0f;
427         float width = 0.0f;
428         float height = 0.0f;
429
430         float titleHeight = 0.0f;
431
432         if (HasTitle())
433         {
434                 GET_SHAPE_CONFIG(POPUP::TITLE_HEIGHT, GetOrientation(), titleHeight);
435                 y = titleHeight;
436         }
437
438         width = GetBoundsF().width;
439         height = GetBoundsF().height - y;
440
441         return FloatRectangle(x, y, width, height);
442 }
443
444 _AccessibilityElement*
445 _Popup::GetTitleTextAccessibilityElement(void)
446 {
447         return _pTitleTextAccessibilityElement;
448 }
449
450 _Indicator*
451 _Popup::GetIndicator(void) const
452 {
453         return __pIndicator;
454 }
455
456 void
457 _Popup::OnDraw(void)
458 {
459         __pPopupPresenter->OnDraw();
460         result r = GetLastResult();
461         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
462         if(unlikely((_AccessibilityManager::IsActivated())))
463         {
464                 _AccessibilityManager::GetInstance()->RequestAutoReading(_ACCESSIBILITY_AUTO_READING_MODE_FIRST_ITEM);
465         }
466         return;
467 }
468
469 void
470 _Popup::OnFontChanged(Font * pFont)
471 {
472         if (__pPopupPresenter != null)
473         {
474                 __pPopupPresenter->OnFontChanged(pFont);
475         }
476 }
477
478 void
479 _Popup::OnFontInfoRequested(unsigned long& style, float& size)
480 {
481         if (__pPopupPresenter != null)
482         {
483                 __pPopupPresenter->OnFontInfoRequested(style, size);
484         }
485 }
486
487 void
488 _Popup::OnActivated(void)
489 {
490         if (__pPopupPresenter != null)
491         {
492                 __pPopupPresenter->OnActivated();
493         }
494
495         if (GetVisibleState())
496         {
497                 SetTouchCapture(false, false);
498         }
499
500         bool showstate = false;
501         bool opacity = false;
502         unsigned long formstyle = 0x00000000;
503
504         _Control* pOwner = GetOwner();
505         if (pOwner == null)
506         {
507                 _Frame* pFrame = dynamic_cast<_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
508                 SysTryReturnVoidResult(NID_UI_CTRL, pFrame != null, E_SYSTEM, "[E_SYSTEM] This instance is not constructed.");
509
510                 _Form* pForm = pFrame->GetCurrentForm();
511                 if (pForm != null)
512                 {
513                         SetOwner(pForm);
514
515                         showstate = pForm->IsIndicatorVisible();
516                         opacity = pForm->IsIndicatorTranslucent();
517                         formstyle = pForm->GetFormStyle();
518                 }
519                 else
520                 {
521                         SetOwner(pFrame);
522                 }
523         }
524         else
525         {
526                 _Form* pForm = dynamic_cast<_Form*>(pOwner);
527                 if (pForm != null)
528                 {
529                         showstate = pForm->IsIndicatorVisible();
530                         opacity = pForm->IsIndicatorTranslucent();
531                         formstyle = pForm->GetFormStyle();
532                 }
533
534                 pOwner->LockInputEvent();
535         }
536
537         if (__pIndicator)
538         {
539                 __pIndicator->AddIndicatorObject(this, GetRootWindow());
540
541
542                 float indicatorwidth = 0.0f;
543                 float indicatorheight = 0.0f;
544
545                 if (GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
546                 {
547                         indicatorwidth = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF().width;
548                         GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorheight);
549                 }
550                 else
551                 {
552                         indicatorwidth = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF().height;
553                         GET_SHAPE_CONFIG(FORM::INDICATOR_MINIMIZE_HEIGHT, GetOrientation(), indicatorheight);
554                 }
555                 __pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, indicatorwidth, indicatorheight));
556                 __pIndicator->SetIndicatorShowState(showstate);
557                 if (opacity)
558                 {
559                         __pIndicator->SetIndicatorOpacity(_INDICATOR_OPACITY_TRANSLUCENT);
560                 }
561                 else
562                 {
563                         __pIndicator->SetIndicatorOpacity(_INDICATOR_OPACITY_OPAQUE);
564                 }
565
566                 if (formstyle & FORM_STYLE_PORTRAIT_INDICATOR)
567                 {
568                         if (formstyle & FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE)
569                         {
570                                 __pIndicator->SetIndicatorAutoHide(false, true);
571                         }
572                         else
573                         {
574                                 __pIndicator->SetIndicatorAutoHide(false, false);
575                         }
576                 }
577                 else if (formstyle & FORM_STYLE_INDICATOR_AUTO_HIDE)
578                 {
579                         if (formstyle & FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE)
580                         {
581                                 __pIndicator->SetIndicatorAutoHide(true, true);
582                         }
583                         else
584                         {
585                                 __pIndicator->SetIndicatorAutoHide(true, false);
586                         }
587                 }
588                 else
589                 {
590                         if (formstyle & FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE)
591                         {
592                                 __pIndicator->SetIndicatorAutoHide(false, true);
593                         }
594                         else
595                         {
596                                 __pIndicator->SetIndicatorAutoHide(false, false);
597                         }
598                 }
599         }
600
601         _Window::OnActivated();
602 }
603
604 void
605 _Popup::OnDeactivated(void)
606 {
607         _Control* pOwner = GetOwner();
608         if (pOwner != null)
609         {
610                 pOwner->UnlockInputEvent();
611         }
612
613         ReleaseTouchCapture();
614
615         _Window::OnDeactivated();
616 }
617
618 void
619 _Popup::OnVisibleStateChanged(void)
620 {
621         _Window::OnVisibleStateChanged();
622 }
623
624 result
625 _Popup::OnAttachingToMainTree(const _Control* pParent)
626 {
627         return _Window::OnAttachingToMainTree(pParent);
628 }
629
630 result
631 _Popup::OnAttachedToMainTree(void)
632 {
633         SysTryReturn(NID_UI_CTRL, GetVisibleState() != false, E_INVALID_OPERATION,
634                                 E_INVALID_OPERATION, "[E_INVALID_OPERATION] This control is not 'displayable'");
635
636         _Control* pOwner = GetOwner();
637         if (pOwner != null)
638         {
639                 GetEcoreEvasMgr()->GetEcoreEvas()->SetOwner(*this, *pOwner);
640         }
641
642         if (__pIndicator)
643         {
644                 __pIndicator->OnAttachedToMainTree();
645         }
646
647         InitializeAccessibilityElement();
648
649         return E_SUCCESS;
650 }
651
652 void
653 _Popup::InitializeAccessibilityElement(void)
654 {
655         _AccessibilityContainer* pContainer = GetAccessibilityContainer();
656         if (pContainer != null)
657         {
658                 pContainer->RemoveAllElement();
659                 _pTitleTextAccessibilityElement = null;
660                 if (HasTitle() == true)
661                 {
662                         _pTitleTextAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
663                         SysTryReturnVoidResult(NID_UI_CTRL, _pTitleTextAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
664
665                         _PopupPresenter* pPresenter = GetPresenter();
666                         SysTryReturnVoidResult(NID_UI_CTRL, pPresenter != null, E_SYSTEM, "[E_SYSTEM] This instance is not constructed.");
667                         _pTitleTextAccessibilityElement->Construct(L"PopupTitleText", pPresenter->GetTitleTextBounds());
668                         _pTitleTextAccessibilityElement->SetLabel(GetTitleText());
669                         _pTitleTextAccessibilityElement->SetTrait(L"Popup Title");
670
671                         pContainer->AddElement(*_pTitleTextAccessibilityElement);
672                 }
673         }
674
675         return;
676 }
677
678 result
679 _Popup::OnDetachingFromMainTree(void)
680 {
681         if (__pIndicator)
682         {
683                 __pIndicator->DeleteIndicatorObject();
684         }
685         return _Window::OnDetachingFromMainTree();
686 }
687
688 result
689 _Popup::OnBoundsChanging(const FloatRectangle& bounds)
690 {
691         return E_SUCCESS;
692 }
693
694 void
695 _Popup::OnBoundsChanged(void)
696 {
697         SetClientBounds(GetPopupClientArea());
698
699         if (__pPopupPresenter != null)
700         {
701                 __pPopupPresenter->OnBoundsChanged();
702
703                 if ((_pTitleTextAccessibilityElement != null) && (HasTitle() == true))
704                 {
705                         _pTitleTextAccessibilityElement->SetBounds(__pPopupPresenter->GetTitleTextBounds());
706                 }
707         }
708
709 }
710
711 bool
712 _Popup::IsLayoutChangable(void) const
713 {
714         return true;
715 }
716
717 bool
718 _Popup::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
719 {
720         if (&source != this)
721         {
722                 return false;
723         }
724
725         return __pPopupPresenter->OnTouchPressed(source, touchinfo);
726 }
727
728 bool
729 _Popup::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
730 {
731         if (&source != this)
732         {
733                 return false;
734         }
735
736         return __pPopupPresenter->OnTouchReleased(source, touchinfo);
737 }
738
739 void
740 _Popup::OnOwnerChanged(_Control* pOldOwner)
741 {
742         if (IsActivated() == false)
743         {
744                 return;
745         }
746
747         _Control* pOwner = GetOwner();
748
749         if (pOldOwner != null)
750         {
751                 pOldOwner->UnlockInputEvent();
752         }
753
754         if (pOwner != null)
755         {
756                 pOwner->LockInputEvent();
757         }
758 }
759
760 void
761 _Popup::UpdateClientBounds(const FloatDimension& size, FloatRectangle& clientBounds)
762 {
763         float titleHeight = 0.0f;
764
765         if (HasTitle())
766         {
767                 GET_SHAPE_CONFIG(POPUP::TITLE_HEIGHT, GetOrientation(), titleHeight);
768                 clientBounds.y = titleHeight;
769         }
770
771         clientBounds.width = size.width;
772         clientBounds.height = size.height - clientBounds.y;
773 }
774
775 bool
776 _Popup::IsRotationSynchronized(void) const
777 {
778         return true;
779 }
780
781 void
782 _Popup::OnChangeLayout(_ControlOrientation orientation)
783 {
784         _Window::OnChangeLayout(orientation);
785
786         float indicatorheight = 0.0f;
787
788         const FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
789         const FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
790
791         GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorheight);
792
793         _Form* pForm = dynamic_cast<_Form*>(GetOwner());
794         if (pForm)
795         {
796                 if (__pIndicator)
797                 {
798                         if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
799                         {
800                                 __pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, portraitSize.width, indicatorheight));
801                                 if ((FORM_STYLE_INDICATOR & pForm->GetFormStyle()) || (FORM_STYLE_INDICATOR_AUTO_HIDE & pForm->GetFormStyle()))
802                                 {
803                                         __pIndicator->SetIndicatorShowState(true);
804                                 }
805                                 else
806                                 {
807                                         __pIndicator->SetIndicatorShowState(false);
808                                 }
809                         }
810                         else
811                         {
812                                 if (FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE & pForm->GetFormStyle())
813                                 {
814                                         __pIndicator->SetIndicatorShowState(true);
815                                 }
816                                 else
817                                 {
818                                         __pIndicator->SetIndicatorShowState(false);
819                                 }
820                         }
821                         __pIndicator->OnChangeLayout(orientation);
822                 }
823         }
824 }
825
826 }}} // Tizen::Ui::Controls
827