2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrl_MessageBoxPresenter.cpp
20 * @brief This is the implementation file for the _MessageBoxPresenter class.
22 #include <FUiCtrlMessageBox.h>
23 #include <FBaseSysLog.h>
24 #include <FBaseErrorDefine.h>
25 #include <FGrp_BitmapImpl.h>
26 #include <FGrp_CanvasImpl.h>
27 #include <FGrp_TextTextSimple.h>
28 #include "FUi_AccessibilityContainer.h"
29 #include "FUi_AccessibilityElement.h"
31 #include "FUi_ModalLoopManager.h"
32 #include "FUi_ResourceManager.h"
33 #include "FUi_TouchManager.h"
34 #include "FUi_CoordinateSystemUtils.h"
35 #include "FUiCtrl_ButtonImpl.h"
36 #include "FUiCtrl_Button.h"
37 #include "FUiCtrl_Label.h"
38 #include "FUiCtrl_Scroll.h"
39 #include "FUiCtrl_ScrollPanel.h"
40 #include "FUiCtrl_MessageBox.h"
41 #include "FUiCtrl_MessageBoxPresenter.h"
43 using namespace Tizen::Base;
44 using namespace Tizen::Base::Runtime;
45 using namespace Tizen::Graphics;
46 using namespace Tizen::Graphics::_Text;
47 using namespace Tizen::Ui;
48 using namespace Tizen::Ui::Animations;
51 namespace Tizen { namespace Ui { namespace Controls
55 _MessageBoxPresenter::_MessageBoxPresenter(void)
57 , __pButtonListener(null)
58 , __msgboxResult(MSGBOX_RESULT_CLOSE)
59 , __pBodyTextObject(null)
60 , __textBounds(0.0f, 0.0f, 0.0f, 0.0f)
61 , __titleBgBounds(0.0f, 0.0f, 0.0f, 0.0f)
62 , __buttonBgBounds(0.0f, 0.0f, 0.0f, 0.0f)
65 , __pScrollPanel(null)
68 , __prevPositionY(-1.0f)
69 , __textObjHeight(0.0f)
70 , __touchPressFlag(false)
71 , __scrollStart(false)
72 , __btnClickFlag(false)
73 , __bodyClickFlag(false)
74 , __touchOutBounds(false)
77 for (int i = 0; i < 3; i++)
83 _MessageBoxPresenter::~_MessageBoxPresenter(void)
85 for (int i = 0; i < __buttonNum; i++)
91 delete __pButtonListener;
92 __pButtonListener = null;
94 if (__pBodyTextObject != null)
96 __pBodyTextObject->RemoveAll();
97 delete __pBodyTextObject;
98 __pBodyTextObject = null;
101 if (__pLabel != null)
103 __pScrollPanel->DetachChild(*__pLabel);
108 if (__pScrollPanel != null)
110 __pMessageBox->DetachChild(*__pScrollPanel);
111 delete __pScrollPanel;
112 __pScrollPanel = null;
115 if (__pScroll != null)
117 __pMessageBox->DetachSystemChild(*__pScroll);
124 _MessageBoxPresenter::OnChangeLayout(_ControlOrientation orientation)
126 result r = E_SUCCESS;
128 float titleTextSize = 0.0f;
129 float minTitleTextSize = 0.0f;
130 float defaultWidth = 0.0f;
131 float titleHeight = 0.0f;
132 float bottomHeight = 0.0f;
133 float maxHeight = 0.0f;
135 float textTopMargin = 0.0f;
137 float titleTopMargin = 0.0f;
138 float titleLeftMargin = 0.0f;
139 float titleRightMargin = 0.0f;
141 float transTopMargin = 0.0f;
142 float transBottomMargin = 0.0f;
143 float labelHeight = 0.0f;
144 float transLeftMargin = 0.0f;
145 float transRightMargin = 0.0f;
147 GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_SIZE, orientation, titleTextSize);
148 GET_SHAPE_CONFIG(POPUP::MIN_TITLE_TEXT_SIZE, orientation, minTitleTextSize);
150 GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, orientation, defaultWidth);
151 GET_SHAPE_CONFIG(MESSAGEBOX::BOTTOM_HEIGHT, orientation, bottomHeight);
152 GET_SHAPE_CONFIG(MESSAGEBOX::MAX_HEIGHT, orientation, maxHeight);
154 GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_TOP_MRAGIN, orientation, textTopMargin);
156 GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_TEXT_TOP_MARGIN, orientation, titleTopMargin);
157 GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_TEXT_LEFT_MARGIN, orientation, titleLeftMargin);
158 GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_TEXT_RIGHT_MARGIN, orientation, titleRightMargin);
160 GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_TOP_MARGIN, orientation, transTopMargin);
161 GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_BOTTOM_MARGIN, orientation, transBottomMargin);
162 GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_LEFT_MARGIN, orientation, transLeftMargin);
163 GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_RIGHT_MARGIN, orientation, transRightMargin);
165 __textBounds.width = defaultWidth - GetLeftRightLabelMargin();
166 __titleBgBounds.width = defaultWidth - (transLeftMargin + transRightMargin);
169 if (__pMessageBox->HasTitle() == true)
171 GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_HEIGHT, orientation, titleHeight);
173 _titleBounds.width = __textBounds.width;
174 _pTitleTextObject->SetBounds(_titleBounds);
176 r = CalculateTitleTextSize(titleTextSize, minTitleTextSize);
177 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
179 _titleBounds.height = titleHeight - titleTopMargin;
183 __pBodyTextObject->SetBounds(__textBounds);
185 __pBodyTextObject->Compose();
188 __pScrollPanel->SetBounds(__textBounds);
190 labelHeight = __pBodyTextObject->GetTotalHeightF();
192 if (labelHeight < __textObjHeight)
194 __pLabel->SetBounds(FloatRectangle(0.0f, (__textObjHeight - labelHeight)/2.0f, __textBounds.width, labelHeight));
198 __pLabel->SetBounds(FloatRectangle(0.0f, 0.0f, __textBounds.width, labelHeight));
201 __buttonBgBounds = FloatRectangle(transLeftMargin, __pMessageBox->GetTotalHeight() - bottomHeight - transBottomMargin, defaultWidth- (transLeftMargin + transRightMargin), bottomHeight);
203 for (int i = 0; i < __buttonNum; i++)
205 r = __pButtons[i]->SetBounds(CalculateButtonPositionAndSize(i));
206 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
213 _MessageBoxPresenter::Initialize(_MessageBox& msgbox)
215 result r = E_SUCCESS;
217 float titleTextSize = 0.0f;
218 float bodyTextSize = 0.0f;
220 float defaultWidth = 0.0f;
221 float titleHeight = 0.0f;
222 float bottomHeight = 0.0f;
223 float maxHeight = 0.0f;
225 float textTopMargin = 0.0f;
226 float textTopMarginNoButton = 0.0f;
227 float textLeftMargin = 0.0f;
229 float titleTopMargin = 0.0f;
230 float titleLeftMargin = 0.0f;
231 float titleRightMargin = 0.0f;
233 float transTopMargin = 0.0f;
234 float transBottomMargin = 0.0f;
235 float transLeftMargin = 0.0f;
236 float transRightMargin = 0.0f;
237 float labelHeight = 0.0f;
239 _ControlOrientation orientation;
241 __pMessageBox = &msgbox;
243 orientation = __pMessageBox->GetOrientation();
245 GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_TEXT_SIZE, orientation, titleTextSize);
246 GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_SIZE, orientation, bodyTextSize);
247 GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_HEIGHT, orientation, __textObjHeight);
249 GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, orientation, defaultWidth);
250 GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_HEIGHT, orientation, titleHeight);
251 GET_SHAPE_CONFIG(MESSAGEBOX::BOTTOM_HEIGHT, orientation, bottomHeight);
252 GET_SHAPE_CONFIG(MESSAGEBOX::MAX_HEIGHT, orientation, maxHeight);
254 GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_TOP_MRAGIN, orientation, textTopMargin);
255 GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_TOP_MRAGIN_NO_BUTTON, orientation, textTopMarginNoButton);
256 GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_LEFT_MARGIN, orientation, textLeftMargin);
258 GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_TEXT_TOP_MARGIN, orientation, titleTopMargin);
259 GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_TEXT_LEFT_MARGIN, orientation, titleLeftMargin);
260 GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_TEXT_RIGHT_MARGIN, orientation, titleRightMargin);
262 GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_TOP_MARGIN, orientation, transTopMargin);
263 GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_BOTTOM_MARGIN, orientation, transBottomMargin);
264 GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_LEFT_MARGIN, orientation, transLeftMargin);
265 GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_RIGHT_MARGIN, orientation, transRightMargin);
267 __titleBgBounds= FloatRectangle(transLeftMargin, transTopMargin, _CoordinateSystemUtils::ConvertToFloat(defaultWidth) - (2 * transLeftMargin), titleHeight);
271 if (__pMessageBox->HasTitle() == true)
273 _pTitleTextObject = new (std::nothrow) TextObject();
274 SysTryReturn(NID_UI_CTRL, _pTitleTextObject != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create TitleTextObject.");
276 r = _pTitleTextObject->Construct();
277 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
279 FloatRectangle bounds = FloatRectangle(titleLeftMargin + transLeftMargin,
280 titleTopMargin + transTopMargin,
281 defaultWidth - (titleLeftMargin + titleRightMargin + transLeftMargin + transRightMargin),
282 titleHeight - titleTopMargin);
284 labelHeight = GetLabelHeight(_pTitleTextObject, const_cast <wchar_t*>(__pMessageBox->GetTitleText().GetPointer()),
285 __pMessageBox->GetTitleText().GetLength(), titleTextSize, bounds, true);
288 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
290 _titleBounds = FloatRectangle(titleLeftMargin + transLeftMargin,
291 __titleBgBounds.y + (__titleBgBounds.height - labelHeight) / 2,
292 defaultWidth - (titleLeftMargin + titleRightMargin + transLeftMargin + transRightMargin),
293 titleHeight - titleTopMargin);
301 __textBounds.SetBounds(textLeftMargin + transLeftMargin,
302 titleHeight + textTopMargin + transTopMargin,
303 defaultWidth - GetLeftRightLabelMargin(),
307 if ((__pMessageBox->HasTitle() == false) && (__pMessageBox->GetMsgBoxStyle() == MSGBOX_STYLE_NONE))
309 __textBounds.y = transTopMargin + textTopMarginNoButton;
312 __pLabel = _Label::CreateLabelN();
313 SysTryCatch(NID_UI_CTRL, __pLabel != null, , E_OUT_OF_MEMORY, "[E_SYSTEM] Failed to create the scroll.");
315 __pBodyTextObject = new (std::nothrow) TextObject();
316 SysTryCatch(NID_UI_CTRL, __pBodyTextObject != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
318 r = __pBodyTextObject->Construct();
319 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
321 labelHeight = GetLabelHeight(__pBodyTextObject, const_cast <wchar_t*>(__pMessageBox->GetText().GetPointer()),
322 __pMessageBox->GetText().GetLength(), bodyTextSize, __textBounds, false);
325 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
327 if (__pMessageBox->GetText().GetLength() > 0)
329 __textObjHeight = __pBodyTextObject->GetLineHeightAtF(0) * 3.0;
330 __textBounds.height = __textObjHeight;
333 if (labelHeight < __textObjHeight)
335 __pLabel->SetBounds(FloatRectangle(0.0f, (__textObjHeight - labelHeight)/2.0f, __textBounds.width, labelHeight));
339 __pLabel->SetBounds(FloatRectangle(0.0f, 0.0f, __textBounds.width, labelHeight));
343 __pLabel->SetText(__pMessageBox->GetText());
344 __pLabel->SetTextConfig(bodyTextSize, LABEL_TEXT_STYLE_NORMAL);
345 __pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
346 __pLabel->SetMargin(0.0f, 0.0f, 0.0f, 0.0f);
348 __pScrollPanel = _ScrollPanel::CreateScrollPanelN(__textBounds, SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL, true);
350 SysTryCatch(NID_UI_CTRL, __pScrollPanel != null, , E_OUT_OF_MEMORY, "[E_SYSTEM] Failed to create the scroll.");
351 __pScrollPanel->SetBounds(__textBounds);
352 __pScrollPanel->AttachChild(*__pLabel);
353 __pScrollPanel->SetFocusable(false);
354 __pMessageBox->AttachChild(*__pScrollPanel);
356 __buttonBgBounds = FloatRectangle(transLeftMargin, __pMessageBox->GetTotalHeight() - bottomHeight - transBottomMargin, _CoordinateSystemUtils::ConvertToFloat(defaultWidth)- (transLeftMargin + transRightMargin), bottomHeight);
359 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
364 delete _pTitleTextObject;
365 _pTitleTextObject = null;
367 delete __pBodyTextObject;
368 __pBodyTextObject = null;
375 _MessageBoxPresenter::GetLabelHeight(TextObject* textObject, wchar_t* text, int length, float bodyTextSize, FloatRectangle bounds, bool isTitle)
377 TextSimple* pSimpleTextForBodyText = null;
378 result r = E_SUCCESS;
381 pSimpleTextForBodyText = new (std::nothrow) TextSimple(text, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
382 SysTryCatch(NID_UI_CTRL, pSimpleTextForBodyText != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
384 textObject->AppendElement(*pSimpleTextForBodyText);
385 textObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
386 textObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
387 textObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT);
388 textObject->SetBounds(bounds);
392 float minTitleTextSize = 0.0f;
394 GET_SHAPE_CONFIG(MESSAGEBOX::MIN_TITLE_TEXT_SIZE, __pMessageBox->GetOrientation(), minTitleTextSize);
396 r = CalculateTitleTextSize(bodyTextSize, minTitleTextSize);
397 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
401 r = SetFontInfo(FONT_STYLE_PLAIN, bodyTextSize);
402 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set font.", GetErrorMessage(r));
404 textObject->SetFont(_pFont, 0, textObject->GetTextLength());
406 textObject->Compose();
411 return textObject->GetTotalHeightF();
418 _MessageBoxPresenter::GetLeftRightLabelMargin(void)
420 float textLeftMargin = 0.0f;
421 float textRightMargin = 0.0f;
422 float transLeftMargin = 0.0f;
423 float transRightMargin = 0.0f;
425 _ControlOrientation orientation = __pMessageBox->GetOrientation();
427 GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_LEFT_MARGIN, orientation, textLeftMargin);
428 GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_RIGHT_MARGIN, orientation, textRightMargin);
429 GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_LEFT_MARGIN, orientation, transLeftMargin);
430 GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_RIGHT_MARGIN, orientation, transRightMargin);
432 return textLeftMargin + textRightMargin + transLeftMargin + transRightMargin;
436 _MessageBoxPresenter::Draw(void)
438 result r = E_SUCCESS;
440 float defaultWidth = 0.0f;
441 float textSize = 0.0f;
443 bool isCustomBitmap = false;
445 _ControlOrientation orientation;
447 orientation = __pMessageBox->GetOrientation();
449 GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, orientation, defaultWidth);
450 GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_SIZE, orientation, textSize);
452 Canvas* pCanvas = __pMessageBox->GetCanvasN();
453 SysTryReturnVoidResult(NID_UI_CTRL, (pCanvas != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create canvas.");
455 pCanvas->SetBackgroundColor(Color(0x00000000));
458 float totalH = __pMessageBox->GetTotalHeight();
460 FloatRectangle bgBounds(0.0f, 0.0f, _CoordinateSystemUtils::ConvertToFloat(defaultWidth), totalH);
462 const Bitmap* pBackgroundBitmap = __pMessageBox->GetBackgroundBitmap();
463 const Bitmap* pOutlineBitmap = __pMessageBox->GetOutlineBitmap();
464 const Bitmap* pButtonBitmap = __pMessageBox->GetButtonBackgroundBitmap();
465 const Bitmap* pButtonEffectBitmap = __pMessageBox->GetButtonBackgroundEffectBitmap();
466 const Bitmap* pTitleBitmap = __pMessageBox->GetTitleBackgroundBitmap();
467 const Bitmap* pTitleEffectBitmap = __pMessageBox->GetTitleBackgroundEffectBitmap();
469 isCustomBitmap = IS_CUSTOM_BITMAP(MESSAGEBOX::BG_NORMAL);
471 if (pBackgroundBitmap != null)
473 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBackgroundBitmap))
475 pCanvas->DrawNinePatchedBitmap(bgBounds, *pBackgroundBitmap);
479 pCanvas->DrawBitmap(bgBounds, *pBackgroundBitmap);
484 if (!isCustomBitmap && pOutlineBitmap != null)
486 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pOutlineBitmap))
488 pCanvas->DrawNinePatchedBitmap(bgBounds, *pOutlineBitmap);
492 pCanvas->DrawBitmap(bgBounds, *pOutlineBitmap);
497 if(pButtonBitmap != null)
499 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pButtonBitmap))
501 pCanvas->DrawNinePatchedBitmap(__buttonBgBounds, *pButtonBitmap);
505 pCanvas->DrawBitmap(__buttonBgBounds, *pButtonBitmap);
508 //DrawEffectButtonBitmap
509 if (pButtonEffectBitmap != null)
511 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pButtonEffectBitmap))
513 pCanvas->DrawNinePatchedBitmap(__buttonBgBounds, *pButtonEffectBitmap);
517 pCanvas->DrawBitmap(__buttonBgBounds, *pButtonEffectBitmap);
522 if (_pTitleTextObject != null)
525 if(pTitleBitmap != null)
527 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pTitleBitmap))
529 pCanvas->DrawNinePatchedBitmap(__titleBgBounds, *pTitleBitmap);
533 pCanvas->DrawBitmap(__titleBgBounds, *pTitleBitmap);
536 //DrawEffectTitleBitmap
537 if (pTitleEffectBitmap != null)
539 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pTitleEffectBitmap))
541 pCanvas->DrawNinePatchedBitmap(__titleBgBounds, *pTitleEffectBitmap);
545 pCanvas->DrawBitmap(__titleBgBounds, *pTitleEffectBitmap);
548 r = SetFontInfo(FONT_STYLE_PLAIN, _titleTextSize);
549 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
551 _pTitleTextObject->SetFont(_pFont, 0, _pTitleTextObject->GetTextLength());
552 _pTitleTextObject->SetForegroundColor(__pMessageBox->GetTitleTextColor(), 0, _pTitleTextObject->GetTextLength());
553 _pTitleTextObject->SetBounds(_titleBounds);
554 _pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
557 __pLabel->SetTextColor(__pMessageBox->GetTextColor());
566 _MessageBoxPresenter::ShowAndWait(int& modalResult)
568 result r = E_SUCCESS;
570 r = __pMessageBox->Open();
572 __pMessageBox->SetTouchCapture(false, false);
576 __pMessageBox->ReleaseTouchCapture();
578 __pMessageBox->Close();
580 modalResult = GetReturnValue();
586 _MessageBoxPresenter::ProcessEvent(void)
588 _ControlHandle handle;
590 _TouchManager* pTouchManager = _TouchManager::GetInstance();
593 _Control* pControl = pTouchManager->GetTouchControlSource();
596 pControl->SetEventEnableState(false);
600 if (__pMessageBox->GetMsgBoxStyle() == MSGBOX_STYLE_NONE)
604 else if (__pButtonListener != null)
606 __pButtonListener->SetBeginModal(true);
609 _ModalLoopManager::GetInstance()->BeginMainLoop(__pMessageBox->GetTimeout(), MSGBOX_RESULT_CLOSE);
611 int exitCode = _ModalLoopManager::GetInstance()->GetLastExitCode();
614 case MSGBOX_BUTTON_CLICKED:
615 if (__pButtonListener != null && __pButtonListener->IsButtonClicked())
617 handle = __pButtonListener->GetClickedButtonHandle();
618 FindButtonAndResult(handle);
621 case MSGBOX_BUTTON_CLOSE:
622 SetReturnValue(MSGBOX_RESULT_CLOSE);
625 case MSGBOX_BUTTON_CANCEL:
626 SetReturnValue(MSGBOX_RESULT_CANCEL);
630 case _ModalLoopManager::MODAL_LOOP_EXIT_CODE_APP_TERMINATION:
631 case _ModalLoopManager::MODAL_LOOP_EXIT_CODE_CONTINUOUS_TERMINATION:
632 _ModalLoopManager::GetInstance()->EndMainLoop(exitCode, false);
633 __beginModal = false;
637 if (__pMessageBox->GetMsgBoxStyle() == MSGBOX_STYLE_NONE)
639 __beginModal = false;
641 else if (__pButtonListener != null)
643 __pButtonListener->SetBeginModal(false);
648 _MessageBoxPresenter::GetButtonString(void)
650 switch (__pMessageBox->GetMsgBoxStyle())
652 case MSGBOX_STYLE_NONE:
656 case MSGBOX_STYLE_OK:
658 GET_STRING_CONFIG(IDS_COM_SK_OK, __buttonText[0]);
661 case MSGBOX_STYLE_CANCEL:
663 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_CANCEL_ABB, __buttonText[0]);
666 case MSGBOX_STYLE_OKCANCEL:
668 GET_STRING_CONFIG(IDS_COM_SK_OK, __buttonText[1]);
669 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_CANCEL_ABB, __buttonText[0]);
672 case MSGBOX_STYLE_YESNO:
674 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_YES, __buttonText[1]);
675 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_NO, __buttonText[0]);
678 case MSGBOX_STYLE_YESNOCANCEL:
680 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_YES, __buttonText[2]);
681 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_NO, __buttonText[1]);
682 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_CANCEL_ABB, __buttonText[0]);
685 case MSGBOX_STYLE_ABORTRETRYIGNORE:
687 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_ABORT, __buttonText[0]);
688 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_RETRY, __buttonText[1]);
689 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_IGNORE, __buttonText[2]);
692 case MSGBOX_STYLE_CANCELTRYCONTINUE:
694 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_CANCEL_ABB, __buttonText[0]);
695 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_TRY, __buttonText[1]);
696 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_CONTINUE_ABB, __buttonText[2]);
699 case MSGBOX_STYLE_RETRYCANCEL:
701 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_RETRY, __buttonText[1]);
702 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_CANCEL_ABB, __buttonText[0]);
711 _MessageBoxPresenter::UpdateButtonString(void)
715 for (int i = 0; i < __buttonNum; i++)
717 __pButtons[i]->SetText(__buttonText[i]);
722 _MessageBoxPresenter::CreateButtons(void)
724 result r = E_SUCCESS;
727 Color buttonColorNormal(0x00000000);
728 Color buttonColorPressed(0x00000000);
729 Color buttonColorDisabled(0x00000000);
730 Color buttonColorHighlighted(0x00000000);
731 Color buttonTextNormal(0x00000000);
732 Color buttonTextPressed(0x00000000);
733 Color buttonTextDisabled(0x00000000);
734 Color buttonTextHighlighted(0x00000000);
735 bool isCustomBitmap = false;
738 Bitmap* pButtonBgNormal = null;
739 Bitmap* pButtonBgPressed = null;
740 Bitmap* pButtonBgDisabled = null;
741 Bitmap* pButtonBgHighlighted = null;
743 Bitmap* pComposedButtonBgNormal = null;
744 Bitmap* pComposedButtonBgPressed = null;
745 Bitmap* pComposedButtonBgDisabled = null;
746 Bitmap* pComposedButtonBgHighlighted = null;
748 Bitmap* pButtonNormalEffect = null;
749 Bitmap* pButtonPressedEffect = null;
750 Bitmap* pButtonDisabledEffect = null;
752 GET_COLOR_CONFIG(MESSAGEBOX::BOTTOM_BUTTON_BG_NORMAL, buttonColorNormal);
753 GET_COLOR_CONFIG(MESSAGEBOX::BOTTOM_BUTTON_BG_PRESSED, buttonColorPressed);
754 GET_COLOR_CONFIG(MESSAGEBOX::BOTTOM_BUTTON_BG_DISABLED, buttonColorDisabled);
755 GET_COLOR_CONFIG(MESSAGEBOX::BOTTOM_BUTTON_BG_HIGHLIGHTED, buttonColorHighlighted);
757 GET_COLOR_CONFIG(MESSAGEBOX::BOTTOM_BUTTON_TEXT_NORMAL, buttonTextNormal);
758 GET_COLOR_CONFIG(MESSAGEBOX::BOTTOM_BUTTON_TEXT_PRESSED, buttonTextPressed);
759 GET_COLOR_CONFIG(MESSAGEBOX::BOTTOM_BUTTON_TEXT_DISABLED, buttonTextDisabled);
760 GET_COLOR_CONFIG(MESSAGEBOX::BOTTOM_BUTTON_TEXT_HIGHLIGHTED, buttonTextHighlighted);
762 GET_BITMAP_CONFIG_N(MESSAGEBOX::BOTTOM_BUTTON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pButtonBgNormal);
764 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating. Failed to load Bottom button normal Image.", GetErrorMessage(r));
766 isCustomBitmap = IS_CUSTOM_BITMAP(MESSAGEBOX::BOTTOM_BUTTON_BG_NORMAL);
770 GET_BITMAP_CONFIG_N(MESSAGEBOX::BOTTOM_BUTTON_NORMAL_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pButtonNormalEffect);
772 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating. Failed to load Bottom button normal effect Image.", GetErrorMessage(r));
775 GET_BITMAP_CONFIG_N(MESSAGEBOX::BOTTOM_BUTTON_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pButtonBgPressed);
777 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating. Failed to load Bottom button pressed Image.", GetErrorMessage(r));
779 isCustomBitmap = IS_CUSTOM_BITMAP(MESSAGEBOX::BOTTOM_BUTTON_BG_PRESSED);
783 GET_BITMAP_CONFIG_N(MESSAGEBOX::BOTTOM_BUTTON_PRESSED_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pButtonPressedEffect);
785 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating. Failed to load Bottom button pressed effect Image.", GetErrorMessage(r));
788 GET_BITMAP_CONFIG_N(MESSAGEBOX::BOTTOM_BUTTON_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pButtonBgDisabled);
790 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating. Failed to load Bottom button disabled Image.", GetErrorMessage(r));
792 isCustomBitmap = IS_CUSTOM_BITMAP(MESSAGEBOX::BOTTOM_BUTTON_BG_DISABLED);
796 GET_BITMAP_CONFIG_N(MESSAGEBOX::BOTTOM_BUTTON_DISABLED_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pButtonDisabledEffect);
798 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating. Failed to load Bottom button disabled effect Image.", GetErrorMessage(r));
801 GET_BITMAP_CONFIG_N(MESSAGEBOX::BOTTOM_BUTTON_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pButtonBgHighlighted);
803 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating. Failed to load Bottom button highlighted Image.", GetErrorMessage(r));
805 pComposedButtonBgNormal = _BitmapImpl::GetColorReplacedBitmapN(*pButtonBgNormal, Color::GetColor(COLOR_ID_MAGENTA), buttonColorNormal);
807 SysTryCatch(NID_UI_CTRL, (pComposedButtonBgNormal != null), , r, "[%s] Propagating.", GetErrorMessage(r));
809 pComposedButtonBgPressed = _BitmapImpl::GetColorReplacedBitmapN(*pButtonBgPressed, Color::GetColor(COLOR_ID_MAGENTA), buttonColorPressed);
811 SysTryCatch(NID_UI_CTRL, (pComposedButtonBgPressed != null), , r, "[%s] Propagating.", GetErrorMessage(r));
813 pComposedButtonBgDisabled = _BitmapImpl::GetColorReplacedBitmapN(*pButtonBgDisabled, Color::GetColor(COLOR_ID_MAGENTA), buttonColorDisabled);
815 SysTryCatch(NID_UI_CTRL, (pComposedButtonBgDisabled != null), , r, "[%s] Propagating.", GetErrorMessage(r));
817 pComposedButtonBgHighlighted = _BitmapImpl::GetColorReplacedBitmapN(*pButtonBgHighlighted, Color::GetColor(COLOR_ID_MAGENTA), buttonColorHighlighted);
819 SysTryCatch(NID_UI_CTRL, (pComposedButtonBgHighlighted != null), , r, "[%s] Propagating.", GetErrorMessage(r));
821 __pButtonListener = new (std::nothrow) _MessageBoxButtonListener();
822 SysTryCatch(NID_UI_CTRL, __pButtonListener != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
824 for (int i = 0; i < __buttonNum; i++)
826 _ControlImpl* pImpl = null;
827 _Button* pButtonCore = null;
829 __pButtons[i] = new (std::nothrow) Button();
830 SysTryCatch(NID_UI_CTRL, __pButtons[i] != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
832 r = __pButtons[i]->Construct(CalculateButtonPositionAndSize(i));
833 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
835 __pButtons[i]->SetText(__buttonText[i]);
836 __pButtons[i]->AddTouchEventListener(*__pButtonListener);
837 __pButtons[i]->AddKeyEventListener(*__pButtonListener);
838 __pButtons[i]->SetNormalBackgroundBitmap(*pComposedButtonBgNormal);
839 __pButtons[i]->SetPressedBackgroundBitmap(*pComposedButtonBgPressed);
840 __pButtons[i]->SetDisabledBackgroundBitmap(*pComposedButtonBgDisabled);
841 __pButtons[i]->SetHighlightedBackgroundBitmap(*pComposedButtonBgHighlighted);
842 __pButtons[i]->SetTextColor(buttonTextNormal);
843 __pButtons[i]->SetPressedTextColor(buttonTextPressed);
844 __pButtons[i]->SetDisabledTextColor(buttonTextDisabled);
845 __pButtons[i]->SetHighlightedTextColor(buttonTextHighlighted);
847 pImpl = _ControlImpl::GetInstance(*__pButtons[i]);
848 pButtonCore = dynamic_cast<_Button*>(&pImpl->GetCore());
850 if (pButtonCore != null)
852 pButtonCore->SetTouchPressThreshold(0.16);
853 __pMessageBox->AttachChild(*pButtonCore);
855 if (pButtonNormalEffect != null)
857 pButtonCore->SetBackgroundEffectBitmap(_BUTTON_STATUS_NORMAL, *pButtonNormalEffect);
860 if (pButtonPressedEffect != null)
862 pButtonCore->SetBackgroundEffectBitmap(_BUTTON_STATUS_PRESSED, *pButtonPressedEffect);
865 if(pButtonDisabledEffect != null)
867 pButtonCore->SetBackgroundEffectBitmap(_BUTTON_STATUS_DISABLED, *pButtonDisabledEffect);
873 __pButtons[i-1]->SetNextFocus(__pButtons[i]);
874 __pButtons[i]->SetPreviousFocus(__pButtons[i-1]);
879 delete pButtonBgNormal;
880 pButtonBgNormal = null;
882 delete pButtonBgPressed;
883 pButtonBgPressed = null;
885 delete pButtonBgDisabled;
886 pButtonBgDisabled = null;
888 delete pButtonBgHighlighted;
889 pButtonBgHighlighted = null;
891 delete pComposedButtonBgNormal;
892 pComposedButtonBgNormal = null;
894 delete pComposedButtonBgPressed;
895 pComposedButtonBgPressed = null;
897 delete pComposedButtonBgDisabled;
898 pComposedButtonBgDisabled = null;
900 delete pComposedButtonBgHighlighted;
901 pComposedButtonBgHighlighted = null;
903 delete pButtonNormalEffect;
904 pButtonNormalEffect = null;
906 delete pButtonPressedEffect;
907 pButtonNormalEffect = null;
909 delete pButtonDisabledEffect;
910 pButtonNormalEffect = null;
916 delete pButtonBgNormal;
917 pButtonBgNormal = null;
919 delete pButtonBgPressed;
920 pButtonBgPressed = null;
922 delete pButtonBgDisabled;
923 pButtonBgDisabled = null;
925 delete pButtonBgHighlighted;
926 pButtonBgHighlighted = null;
928 delete pComposedButtonBgNormal;
929 pComposedButtonBgNormal = null;
931 delete pComposedButtonBgPressed;
932 pComposedButtonBgPressed = null;
934 delete pComposedButtonBgDisabled;
935 pComposedButtonBgDisabled = null;
937 delete pComposedButtonBgHighlighted;
938 pComposedButtonBgHighlighted = null;
940 delete pButtonNormalEffect;
941 pButtonNormalEffect = null;
943 delete pButtonPressedEffect;
944 pButtonNormalEffect = null;
946 delete pButtonDisabledEffect;
947 pButtonNormalEffect = null;
949 delete __pButtonListener;
950 __pButtonListener = null;
952 for (int i = 0; i < __buttonNum; i++)
954 delete __pButtons[i];
955 __pButtons[i] = null;
961 _MessageBoxPresenter::CalculateButtonPositionAndSize(int buttonIndex)
968 float defaultWidth = 0.0f;
969 float btnHeight = 0.0f;
971 float btnSideMargin1 = 0.0f;
972 float btnSideMargin2 = 0.0f;
973 float btnSideMargin3 = 0.0f;
974 float btnTopMargin = 0.0f;
977 float textTopMargin = 0.0f;
979 float titleHeight = 0.0f;
980 float transTopMargin = 0.0f;
982 _ControlOrientation orientation;
983 orientation = __pMessageBox->GetOrientation();
984 GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, orientation, defaultWidth);
985 GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_HEIGHT, orientation, btnHeight);
987 GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_SIDE_MARGIN_01, orientation, btnSideMargin1);
988 GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_SIDE_MARGIN_02, orientation, btnSideMargin2);
989 GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_SIDE_MARGIN_03, orientation, btnSideMargin3);
990 GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_TOP_MARGIN, orientation, btnTopMargin);
992 GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_INTERNAL_GAP, orientation, btnGap);
993 GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_TOP_MRAGIN, orientation, textTopMargin);
995 GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_HEIGHT, orientation, titleHeight);
996 GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_TOP_MARGIN, orientation, transTopMargin);
998 if (__pMessageBox->HasTitle() == false)
1003 switch (__buttonNum)
1006 w = defaultWidth - (btnSideMargin1 * 2.0f);
1012 w = (defaultWidth - (btnSideMargin2 * 2.0f) - btnGap) / 2.0f;
1014 x = btnSideMargin2 + (buttonIndex * (w + btnGap));
1019 switch (buttonIndex)
1026 w = (defaultWidth - ((btnSideMargin3 + btnGap) * 2.0f)) / 3.0f;
1028 x = btnSideMargin3 + (buttonIndex * (w + btnGap));
1036 y = __buttonBgBounds.y + (__buttonBgBounds.height - h) / 2;
1037 return FloatRectangle(x, y, w, h);
1041 _MessageBoxPresenter::FindButtonAndResult(const _ControlHandle handle)
1045 for (int i = 0; i < __buttonNum; i++)
1047 _ControlImpl* pImpl = _ControlImpl::GetInstance(*__pButtons[i]);
1048 if (pImpl->GetCore().GetHandle() == handle)
1055 switch (__pMessageBox->GetMsgBoxStyle())
1057 case MSGBOX_STYLE_NONE:
1058 SetReturnValue(MSGBOX_RESULT_CLOSE);
1061 case MSGBOX_STYLE_OK:
1062 SetReturnValue(MSGBOX_RESULT_OK);
1065 case MSGBOX_STYLE_CANCEL:
1066 SetReturnValue(MSGBOX_RESULT_CANCEL);
1069 case MSGBOX_STYLE_OKCANCEL:
1073 SetReturnValue(MSGBOX_RESULT_CANCEL);
1077 SetReturnValue(MSGBOX_RESULT_OK);
1082 case MSGBOX_STYLE_YESNO:
1086 SetReturnValue(MSGBOX_RESULT_NO);
1090 SetReturnValue(MSGBOX_RESULT_YES);
1095 case MSGBOX_STYLE_YESNOCANCEL:
1099 SetReturnValue(MSGBOX_RESULT_CANCEL);
1103 SetReturnValue(MSGBOX_RESULT_NO);
1107 SetReturnValue(MSGBOX_RESULT_YES);
1112 case MSGBOX_STYLE_ABORTRETRYIGNORE:
1116 SetReturnValue(MSGBOX_RESULT_ABORT);
1120 SetReturnValue(MSGBOX_RESULT_RETRY);
1124 SetReturnValue(MSGBOX_RESULT_IGNORE);
1129 case MSGBOX_STYLE_CANCELTRYCONTINUE:
1133 SetReturnValue(MSGBOX_RESULT_CANCEL);
1137 SetReturnValue(MSGBOX_RESULT_TRY);
1141 SetReturnValue(MSGBOX_RESULT_CONTINUE);
1146 case MSGBOX_STYLE_RETRYCANCEL:
1150 SetReturnValue(MSGBOX_RESULT_CANCEL);
1154 SetReturnValue(MSGBOX_RESULT_RETRY);
1165 _MessageBoxPresenter::CalculateButtonAreaHeight(void)
1167 float btnHeight = 0.0f;
1169 GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_HEIGHT, __pMessageBox->GetOrientation(), btnHeight);
1171 switch (__pMessageBox->GetMsgBoxStyle())
1173 case MSGBOX_STYLE_NONE:
1176 case MSGBOX_STYLE_OK:
1178 case MSGBOX_STYLE_CANCEL:
1180 case MSGBOX_STYLE_OKCANCEL:
1182 case MSGBOX_STYLE_YESNO:
1184 case MSGBOX_STYLE_RETRYCANCEL:
1186 case MSGBOX_STYLE_YESNOCANCEL:
1188 case MSGBOX_STYLE_ABORTRETRYIGNORE:
1190 case MSGBOX_STYLE_CANCELTRYCONTINUE:
1198 _MessageBoxPresenter::GetBodyTextObjHeight(void) const
1200 return (__pBodyTextObject == null) ? 0.0f : __textObjHeight;
1203 _MessageBoxPresenter::GetBodyTextHeight(void) const
1205 return (__pBodyTextObject == null) ? 0.0f : __pBodyTextObject->GetTotalHeightF();
1209 _MessageBoxPresenter::GetTextBounds(void) const
1211 return __textBounds;
1215 _MessageBoxPresenter::SetReturnValue(MessageBoxModalResult rtn)
1217 __msgboxResult = rtn;
1221 _MessageBoxPresenter::GetReturnValue(void) const
1223 return (int) __msgboxResult;
1227 _MessageBoxPresenter::InitializeAccessibilityElement(void)
1229 result r = E_SUCCESS;
1231 _AccessibilityContainer* pContainer = null;
1233 pContainer = __pMessageBox->GetAccessibilityContainer();
1235 if (pContainer == null)
1240 if (__pLabel != null)
1242 _AccessibilityContainer* pLabelContainer = __pLabel->GetAccessibilityContainer();
1243 if (pLabelContainer != null)
1245 _AccessibilityElement* pLabelElement = pLabelContainer->GetChildElement(L"LabelText");
1246 if (pLabelElement != null)
1248 pLabelElement->SetName(L"MessageBoxText");
1249 pLabelElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_TEXT_IN_BODY_OF_POP_UP_T_TALKBACK");
1253 pContainer->AddChildContainer(*pLabelContainer);
1257 if (__pMessageBox->GetMsgBoxStyle() != MSGBOX_STYLE_NONE)
1259 for (int i = 0; i < __buttonNum; i++)
1261 _ControlImpl* pImpl = null;
1262 _Button* pButtonCore = null;
1264 pImpl = _ControlImpl::GetInstance(*__pButtons[i]);
1266 pButtonCore = dynamic_cast<_Button*>(&pImpl->GetCore());
1267 r = GetLastResult();
1268 SysTryReturnVoidResult(NID_UI_CTRL, pButtonCore != null, r, "[%s] Propagating.", GetErrorMessage(r));
1270 _AccessibilityContainer* pButtonContainer = pButtonCore->GetAccessibilityContainer();
1271 if (pButtonContainer != null)
1273 _AccessibilityElement* pButtonElement = pButtonContainer->GetChildElement(L"ButtonText");
1274 if (pButtonElement != null)
1276 String numberString = null;
1277 numberString = Integer::ToString(i + 1);
1279 String buttonName = L"MessageBoxButton";
1280 buttonName.Append(numberString);
1282 pButtonElement->SetName(buttonName);
1286 pContainer->AddChildContainer(*pButtonContainer);
1292 _AccessibilityElement* pElementMessageBox = new (std::nothrow) _AccessibilityElement(true);
1293 SysTryReturnVoidResult(NID_UI_CTRL, pElementMessageBox != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
1295 pElementMessageBox->SetSupportOperatingGesture(false);
1296 pElementMessageBox->SetName(L"MessageBox");
1297 pElementMessageBox->SetHint(L"double tap to close");
1298 pElementMessageBox->SetBounds(FloatRectangle(0.0f, 0.0f, __pMessageBox->GetBoundsF().width, __pMessageBox->GetBoundsF().height));
1299 pContainer->AddElement(*pElementMessageBox);
1304 _MessageBoxPresenter::GetCore(void)
1306 return static_cast <_Popup*>(__pMessageBox);
1310 _MessageBoxPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1312 FloatPoint point = touchinfo.GetCurrentPosition();
1314 FloatRectangle rect(0.0f, 0.0f, __pMessageBox->GetBoundsF().width, __pMessageBox->GetBoundsF().height);
1316 // Touch-event's starting point is MessageBox's leftTop
1317 if (rect.Contains(point) == false)
1319 __touchOutBounds = true;
1323 __touchOutBounds = false;
1326 __touchPressFlag = true;
1328 if ((__pScroll != null) && (__textBounds.Contains(point) == true))
1330 __pScroll->SetScrollVisibility(true);
1332 __scrollStart = true;
1339 _MessageBoxPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1341 if (__touchOutBounds == true)
1343 if (__pMessageBox->GetMsgBoxStyle() == MSGBOX_STYLE_NONE)
1345 if (__beginModal == true)
1347 SetReturnValue(MSGBOX_RESULT_CLOSE);
1348 _ModalLoopManager::GetInstance()->EndMainLoop(MSGBOX_RESULT_CLOSE, false);
1349 __beginModal = false;
1354 if (__touchPressFlag == false)
1356 __prevPositionY = -1.0f;
1358 __scrollStart = false;
1361 if (__pScroll != null)
1363 __pScroll->SetScrollVisibility(false);
1371 _MessageBoxPresenter::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1373 if (__pMessageBox->GetMsgBoxStyle() == MSGBOX_STYLE_NONE)
1375 if (__beginModal == true)
1377 SetReturnValue(MSGBOX_RESULT_CLOSE);
1378 _ModalLoopManager::GetInstance()->EndMainLoop(MSGBOX_RESULT_CLOSE, false);
1379 __beginModal = false;
1387 _MessageBoxPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1389 __touchOutBounds = false;
1391 if ((__pScroll != null) && (__scrollStart == true))
1393 float scrollAmountView = 0.0f;
1394 float scrollAmountData = 0.0f;
1395 float currentPosition = touchinfo.GetCurrentPosition().y;
1398 if (_FloatCompare(__prevPositionY, -1.0f))
1400 __prevPositionY = currentPosition;
1403 float distance = __prevPositionY - currentPosition;
1405 float newFirstDspY = __pBodyTextObject->GetFirstDisplayPositionYF();
1406 newFirstDspY += distance;
1408 if (newFirstDspY < 0.0f)
1410 newFirstDspY = 0.0f;
1413 if (newFirstDspY > __textBounds.height)
1415 newFirstDspY = __textBounds.height;
1418 int moveLine = __pBodyTextObject->GetLineIndexAtPositionY(newFirstDspY);
1420 __pBodyTextObject->SetFirstDisplayLineIndex(moveLine);
1421 __pBodyTextObject->SetFirstDisplayPositionY(newFirstDspY);
1424 __pScroll->GetScrollRange(&scrollAmountView, &scrollAmountData);
1425 __scrollPos += distance;
1427 if (__scrollPos < 0.0f)
1431 else if (__scrollPos > scrollAmountView)
1433 __scrollPos = scrollAmountView;
1436 __pScroll->SetScrollPosition(__scrollPos);
1438 __prevPositionY = currentPosition;
1440 __touchPressFlag = false;
1443 __pMessageBox->Show();
1451 _MessageBoxPresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
1453 _KeyCode keyCode = keyInfo.GetKeyCode();
1455 if (keyCode == _KEY_ESC || keyCode == _KEY_BACK)
1457 MessageBoxStyle style = __pMessageBox->GetMsgBoxStyle();
1459 if ((__pButtonListener->GetBeginModal() == true) || (__beginModal == true))
1463 case MSGBOX_STYLE_CANCEL:
1465 case MSGBOX_STYLE_OKCANCEL:
1467 case MSGBOX_STYLE_YESNOCANCEL:
1469 case MSGBOX_STYLE_CANCELTRYCONTINUE:
1471 case MSGBOX_STYLE_RETRYCANCEL:
1472 _ModalLoopManager::GetInstance()->EndMainLoop(MSGBOX_BUTTON_CANCEL, false);
1473 __beginModal = false;
1484 ////////////////////////////////////////////////////////////////////////
1485 ///////////////////////////MsgBoxButtonListener/////////////////////////
1486 ////////////////////////////////////////////////////////////////////////
1488 _MessageBoxPresenter::_MessageBoxButtonListener::_MessageBoxButtonListener(void)
1490 , __buttonPressFlag(false)
1491 , __buttonReleaseState(false)
1492 , __beginModal(false)
1493 , __point(0.0f, 0.0f)
1498 _MessageBoxPresenter::_MessageBoxButtonListener::~_MessageBoxButtonListener(void)
1504 _MessageBoxPresenter::_MessageBoxButtonListener::GetClickedButtonHandle(void) const
1506 return __buttonHandle;
1510 _MessageBoxPresenter::_MessageBoxButtonListener::IsButtonClicked(void)
1512 return __buttonReleaseState;
1516 _MessageBoxPresenter::_MessageBoxButtonListener::OnTouchPressed(const Control& source, const Point& currentPosition,
1517 const TouchEventInfo& touchInfo)
1519 __buttonPressFlag = true;
1520 __buttonReleaseState = false;
1522 FloatPoint point = touchInfo.GetCurrentPositionF();
1527 _MessageBoxPresenter::_MessageBoxButtonListener::OnTouchMoved(const Control& source, const Point& currentPosition,
1528 const TouchEventInfo& touchInfo)
1530 //FloatPoint point = touchInfo.GetCurrentPositionF();
1532 __buttonPressFlag = false;
1536 _MessageBoxPresenter::_MessageBoxButtonListener::OnTouchReleased(const Control& source, const Point& currentPosition,
1537 const TouchEventInfo& touchInfo)
1539 if (__buttonPressFlag == true)
1541 __buttonHandle = _ControlImpl::GetInstance(source)->GetCore().GetHandle();
1542 SysTryReturnVoidResult(NID_UI_CTRL, __buttonHandle.IsValid() == true, E_SYSTEM, "[E_SYSTEM] Button's Handle is invalid");
1544 __buttonPressFlag = false;
1545 __buttonReleaseState = true;
1547 if (__beginModal == true)
1549 _ModalLoopManager::GetInstance()->EndMainLoop(MSGBOX_BUTTON_CLICKED, false);
1550 __beginModal = false;
1558 _MessageBoxPresenter::_MessageBoxButtonListener::OnKeyReleased(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
1560 const _ControlImpl* pImpl = null;
1561 const _Button* pControl = null;
1563 pImpl = _ControlImpl::GetInstance(source);
1564 pControl = dynamic_cast<const _Button*>(&pImpl->GetCore());
1566 if (pControl != null)
1568 if (keyCode == KEY_ENTER)
1570 __buttonHandle = _ControlImpl::GetInstance(source)->GetCore().GetHandle();
1571 SysTryReturnVoidResult(NID_UI_CTRL, __buttonHandle.IsValid() == true, E_SYSTEM, "[E_SYSTEM] Button's Handle is invalid");
1573 __buttonPressFlag = false;
1574 __buttonReleaseState = true;
1576 if (__beginModal == true)
1578 _ModalLoopManager::GetInstance()->EndMainLoop(MSGBOX_BUTTON_CLICKED, false);
1579 __beginModal = false;
1588 _MessageBoxPresenter::_MessageBoxButtonListener::OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
1590 const _ControlImpl* pImpl = null;
1591 const _Button* pControl = null;
1593 pImpl = _ControlImpl::GetInstance(source);
1594 pControl = dynamic_cast<const _Button*>(&pImpl->GetCore());
1596 if (pControl != null)
1598 _Button* pFocusControl = null;
1602 pFocusControl = dynamic_cast<_Button*>(pControl->GetNextFocus());
1606 pFocusControl = dynamic_cast<_Button*>(pControl->GetPreviousFocus());
1613 _Window* pTop = pControl->GetRootWindow();
1615 if (pFocusControl != null)
1617 pTop->SetFocusTraversalControl(pFocusControl, true);
1618 _Control* pParentControl = pFocusControl->GetParent();
1620 if (pParentControl != null)
1622 pParentControl->OnChildControlFocusMoved(*pFocusControl);
1625 pFocusControl->SetFocused();
1626 pFocusControl->DrawFocus();
1634 _MessageBoxPresenter::_MessageBoxButtonListener::SetBeginModal(bool beginModal)
1636 __beginModal = beginModal;
1640 _MessageBoxPresenter::_MessageBoxButtonListener::GetBeginModal(void)
1642 return __beginModal;
1645 }}} // Tizen::Ui::Controls