#include "FUi_CoordinateSystemUtils.h"
#include "FUiCtrl_ButtonImpl.h"
#include "FUiCtrl_Button.h"
+#include "FUiCtrl_Label.h"
#include "FUiCtrl_Scroll.h"
+#include "FUiCtrl_ScrollPanel.h"
#include "FUiCtrl_MessageBox.h"
#include "FUiCtrl_MessageBoxPresenter.h"
, __pBodyTextObject(null)
, __titleBounds(0.0f, 0.0f, 0.0f, 0.0f)
, __textBounds(0.0f, 0.0f, 0.0f, 0.0f)
+ , __pLabel(null)
, __pScroll(null)
+ , __pScrollPanel(null)
, __fontStyle(0)
, __fontSize(0.0f)
, __scrollPos(0.0f)
__pBodyTextObject = null;
}
+ if (__pLabel != null)
+ {
+ __pScrollPanel->DetachChild(*__pLabel);
+ delete __pLabel;
+ __pLabel = null;
+ }
+
+ if (__pScrollPanel != null)
+ {
+ __pMessageBox->DetachChild(*__pScrollPanel);
+ delete __pScrollPanel;
+ __pScrollPanel = null;
+ }
+
if (__pScroll != null)
{
__pMessageBox->DetachSystemChild(*__pScroll);
float maxHeight = 0.0f;
float textTopMargin = 0.0f;
- float textLeftMargin = 0.0f;
- float textRightMargin = 0.0f;
float titleTopMargin = 0.0f;
float titleLeftMargin = 0.0f;
float transTopMargin = 0.0f;
float transBottomMargin = 0.0f;
- float transLeftMargin = 0.0f;
- float transRightMargin = 0.0f;
+ float labelHeight = 0.0f;
GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, orientation, defaultWidth);
GET_SHAPE_CONFIG(MESSAGEBOX::BOTTOM_HEIGHT, orientation, bottomHeight);
GET_SHAPE_CONFIG(MESSAGEBOX::MAX_HEIGHT, orientation, maxHeight);
GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_TOP_MRAGIN, orientation, textTopMargin);
- GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_LEFT_MARGIN, orientation, textLeftMargin);
- GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_RIGHT_MARGIN, orientation, textRightMargin);
GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_TEXT_TOP_MARGIN, orientation, titleTopMargin);
GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_TEXT_LEFT_MARGIN, orientation, titleLeftMargin);
GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_TOP_MARGIN, orientation, transTopMargin);
GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_BOTTOM_MARGIN, orientation, transBottomMargin);
- GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_LEFT_MARGIN, orientation, transLeftMargin);
- GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_RIGHT_MARGIN, orientation, transRightMargin);
- __textBounds.width = defaultWidth - (textLeftMargin + textRightMargin + transLeftMargin + transRightMargin);
+ __textBounds.width = defaultWidth - GetLeftRightLabelMargin();
// TitleText
if (__pMessageBox->HasTitle() == true)
__pTitleTextObject->SetBounds(__titleBounds);
__pTitleTextObject->Compose();
-
- __titleBounds.height = __pTitleTextObject->GetTotalHeightF();
-
+ __titleBounds.height = titleHeight - titleTopMargin;
}
// Text
__pBodyTextObject->SetBounds(__textBounds);
+
__pBodyTextObject->Compose();
// Text bounds
- __pBodyTextObject->SetBounds(__textBounds);
+ __pScrollPanel->SetBounds(__textBounds);
- // Scroll in Text
- if (__pBodyTextObject->GetTotalHeightF() > __textObjHeight)
- {
- float maxH = __pBodyTextObject->GetTotalHeightF();
+ labelHeight = __pBodyTextObject->GetTotalHeightF();
- if (__pScroll == null)
- {
- __pScroll = _Scroll::CreateScrollN(*__pMessageBox,
- SCROLL_DIRECTION_VERTICAL,
- true,
- true,
- false,
- false,
- __textObjHeight,
- maxH,
- 0.0f);
-
- SysTryReturnResult(NID_UI_CTRL, __pScroll != null, E_OUT_OF_MEMORY, "[E_SYSTEM] Failed to create the scroll.");
-
- __pMessageBox->AttachSystemChild(*__pScroll);
- }
+ if (labelHeight < __textObjHeight)
+ {
+ __pLabel->SetBounds(FloatRectangle(0.0f, (__textObjHeight - labelHeight)/2.0f, __textBounds.width, labelHeight));
}
- else if (__pScroll != null)
+ else
{
- __pMessageBox->DetachSystemChild(*__pScroll);
- delete __pScroll;
- __pScroll = null;
+ __pLabel->SetBounds(FloatRectangle(0.0f, 0.0f, __textBounds.width, labelHeight));
}
for (int i = 0; i < __buttonNum; i++)
float textTopMargin = 0.0f;
float textTopMarginNoButton = 0.0f;
float textLeftMargin = 0.0f;
- float textRightMargin = 0.0f;
float titleTopMargin = 0.0f;
float titleLeftMargin = 0.0f;
float transLeftMargin = 0.0f;
float transRightMargin = 0.0f;
+ float labelHeight = 0.0f;
+
_ControlOrientation orientation;
__pMessageBox = &msgbox;
GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_TOP_MRAGIN, orientation, textTopMargin);
GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_TOP_MRAGIN_NO_BUTTON, orientation, textTopMarginNoButton);
GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_LEFT_MARGIN, orientation, textLeftMargin);
- GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_RIGHT_MARGIN, orientation, textRightMargin);
GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_TEXT_TOP_MARGIN, orientation, titleTopMargin);
GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_TEXT_LEFT_MARGIN, orientation, titleLeftMargin);
// TitleText
if (__pMessageBox->HasTitle() == true)
{
- r = SetFontInfo(FONT_STYLE_PLAIN, titleTextSize);
- SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to set font.", GetErrorMessage(r));
-
__pTitleTextObject = new (std::nothrow) TextObject();
SysTryReturn(NID_UI_CTRL, __pTitleTextObject != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create TitleTextObject.");
__pTitleTextObject->Construct();
- TextSimple* pSimpleTextForTitleText = new (std::nothrow) TextSimple(const_cast <wchar_t*>(__pMessageBox->GetTitleText().GetPointer()),
- __pMessageBox->GetTitleText().GetLength(),
- TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
- SysTryCatch(NID_UI_CTRL, pSimpleTextForTitleText != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
-
- __pTitleTextObject->AppendElement(*pSimpleTextForTitleText);
- __pTitleTextObject->SetForegroundColor(__pMessageBox->GetTitleTextColor(), 0, __pTitleTextObject->GetTextLength());
- __pTitleTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
- __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
- __pTitleTextObject->SetTextObjectEllipsisType(TEXT_OBJECT_ELLIPSIS_TYPE_TAIL);
-
- __pTitleTextObject->SetFont(_pFont, 0, __pTitleTextObject->GetTextLength());
- __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT);
- __pTitleTextObject->SetBounds(FloatRectangle(titleLeftMargin + transLeftMargin,
+ FloatRectangle bounds = FloatRectangle(titleLeftMargin + transLeftMargin,
titleTopMargin + transTopMargin,
defaultWidth - (titleLeftMargin + titleRightMargin + transLeftMargin + transRightMargin),
- titleHeight - titleTopMargin));
- __pTitleTextObject->Compose();
+ titleHeight - titleTopMargin);
+
+ labelHeight = GetLabelHeight(__pTitleTextObject, const_cast <wchar_t*>(__pMessageBox->GetTitleText().GetPointer()),
+ __pMessageBox->GetTitleText().GetLength(), bodyTextSize, bounds);
__titleBounds = FloatRectangle(titleLeftMargin + transLeftMargin,
titleTopMargin + transTopMargin,
defaultWidth - (titleLeftMargin + titleRightMargin + transLeftMargin + transRightMargin),
- __pTitleTextObject->GetTotalHeightF());
-
+ titleHeight - titleTopMargin);
}
else
{
titleHeight = 0;
}
- // Text
- r = SetFontInfo(FONT_STYLE_PLAIN, bodyTextSize);
- SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set font.", GetErrorMessage(r));
-
- __pBodyTextObject = new (std::nothrow) TextObject();
- SysTryCatch(NID_UI_CTRL, __pBodyTextObject != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
-
- __pBodyTextObject->Construct();
-
- pSimpleTextForBodyText = new (std::nothrow) TextSimple(const_cast <wchar_t*>(__pMessageBox->GetText().GetPointer()),
- __pMessageBox->GetText().GetLength(),
- TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
- SysTryCatch(NID_UI_CTRL, pSimpleTextForBodyText != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
-
- __pBodyTextObject->AppendElement(*pSimpleTextForBodyText);
- __pBodyTextObject->SetForegroundColor(__pMessageBox->GetTextColor(), 0, __pBodyTextObject->GetTextLength());
- __pBodyTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
- __pBodyTextObject->SetFont(_pFont, 0, __pBodyTextObject->GetTextLength());
- __pBodyTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT|TEXT_OBJECT_ALIGNMENT_MIDDLE);
- __pBodyTextObject->SetBounds(FloatRectangle(textLeftMargin + transLeftMargin,
- titleHeight + textTopMargin + transTopMargin,
- defaultWidth - (textLeftMargin + textRightMargin + transLeftMargin + transRightMargin),
- maxHeight - titleHeight));
- __pBodyTextObject->Compose();
-
// Text bounds
__textBounds.SetBounds(textLeftMargin + transLeftMargin,
titleHeight + textTopMargin + transTopMargin,
- defaultWidth - (textLeftMargin + textRightMargin + transLeftMargin + transRightMargin),
+ defaultWidth - GetLeftRightLabelMargin(),
__textObjHeight);
+
if ((__pMessageBox->HasTitle() == false) && (__pMessageBox->GetMsgBoxStyle() == MSGBOX_STYLE_NONE))
{
__textBounds.y = transTopMargin + textTopMarginNoButton;
}
- __pBodyTextObject->SetBounds(__textBounds);
- // Scroll in Text
- if (__pBodyTextObject->GetTotalHeightF() > __textObjHeight)
- {
- float maxH = __pBodyTextObject->GetTotalHeightF();
+ __pLabel = _Label::CreateLabelN();
+ SysTryCatch(NID_UI_CTRL, __pLabel != null, , E_OUT_OF_MEMORY, "[E_SYSTEM] Failed to create the scroll.");
- __pScroll = _Scroll::CreateScrollN(*__pMessageBox,
- SCROLL_DIRECTION_VERTICAL,
- true,
- true,
- false,
- false,
- __textObjHeight,
- maxH,
- 0.0f);
+ __pBodyTextObject = new (std::nothrow) TextObject();
+ SysTryCatch(NID_UI_CTRL, __pBodyTextObject != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ __pBodyTextObject->Construct();
+ labelHeight = GetLabelHeight(__pBodyTextObject, const_cast <wchar_t*>(__pMessageBox->GetText().GetPointer()),
+ __pMessageBox->GetText().GetLength(), bodyTextSize, __textBounds);
- SysTryCatch(NID_UI_CTRL, __pScroll != null, , E_OUT_OF_MEMORY, "[E_SYSTEM] Failed to create the scroll.");
+ if (__pMessageBox->GetText().GetLength() > 0)
+ {
+ __textObjHeight = __pBodyTextObject->GetLineHeightAtF(0) * 3.0;
+ __textBounds.height = __textObjHeight;
+ }
- __pMessageBox->AttachSystemChild(*__pScroll);
+ if (labelHeight < __textObjHeight)
+ {
+ __pLabel->SetBounds(FloatRectangle(0.0f, (__textObjHeight - labelHeight)/2.0f, __textBounds.width, labelHeight));
}
+ else
+ {
+ __pLabel->SetBounds(FloatRectangle(0.0f, 0.0f, __textBounds.width, labelHeight));
+ }
+
+
+ __pLabel->SetText(__pMessageBox->GetText());
+ __pLabel->SetTextConfig(bodyTextSize, LABEL_TEXT_STYLE_NORMAL);
+ __pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
+ __pLabel->SetMargin(0.0f, 0.0f, 0.0f, 0.0f);
+
+ __pScrollPanel = _ScrollPanel::CreateScrollPanelN(__textBounds, SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL, true);
+
+ SysTryCatch(NID_UI_CTRL, __pScrollPanel != null, , E_OUT_OF_MEMORY, "[E_SYSTEM] Failed to create the scroll.");
+ __pScrollPanel->SetBounds(__textBounds);
+ __pScrollPanel->AttachChild(*__pLabel);
+ __pMessageBox->AttachChild(*__pScrollPanel);
r = CreateButtons();
SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
return r;
}
+float
+_MessageBoxPresenter::GetLabelHeight(TextObject* textObject, wchar_t* text, int length, float bodyTextSize, FloatRectangle bounds)
+{
+ TextSimple* pSimpleTextForBodyText = null;
+
+ // Text
+ result r = SetFontInfo(FONT_STYLE_PLAIN, bodyTextSize);
+ SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set font.", GetErrorMessage(r));
+
+ textObject->Construct();
+
+ pSimpleTextForBodyText = new (std::nothrow) TextSimple(text, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
+ SysTryCatch(NID_UI_CTRL, pSimpleTextForBodyText != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ textObject->AppendElement(*pSimpleTextForBodyText);
+ textObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
+ textObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
+ textObject->SetFont(_pFont, 0, textObject->GetTextLength());
+ textObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT|TEXT_OBJECT_ALIGNMENT_MIDDLE);
+ textObject->SetBounds(bounds);
+ textObject->Compose();
+
+ return textObject->GetTotalHeightF();
+CATCH:
+ delete pSimpleTextForBodyText;
+ return 0.0f;
+}
+
+float
+_MessageBoxPresenter::GetLeftRightLabelMargin(void)
+{
+ float textLeftMargin = 0.0f;
+ float textRightMargin = 0.0f;
+ float transLeftMargin = 0.0f;
+ float transRightMargin = 0.0f;
+
+ _ControlOrientation orientation = __pMessageBox->GetOrientation();
+
+ GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_LEFT_MARGIN, orientation, textLeftMargin);
+ GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_RIGHT_MARGIN, orientation, textRightMargin);
+ GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_LEFT_MARGIN, orientation, transLeftMargin);
+ GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_RIGHT_MARGIN, orientation, transRightMargin);
+
+ return textLeftMargin + textRightMargin + transLeftMargin + transRightMargin;
+}
+
void
_MessageBoxPresenter::OnFontChanged(Font* pFont)
{
__pTitleTextObject->SetFont(_pFont, 0, __pTitleTextObject->GetTextLength());
__pTitleTextObject->SetForegroundColor(__pMessageBox->GetTitleTextColor(), 0, __pTitleTextObject->GetTextLength());
+ __pTitleTextObject->SetBounds(__titleBounds);
__pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
}
- // Draw Text
- if (__pBodyTextObject != null)
- {
- r = SetFontInfo(FONT_STYLE_PLAIN, textSize);
- SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
- __pBodyTextObject->SetFont(_pFont, 0, __pBodyTextObject->GetTextLength());
- __pBodyTextObject->SetForegroundColor(__pMessageBox->GetTextColor(), 0, __pBodyTextObject->GetTextLength());
-
- __pBodyTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
- }
-
+ __pLabel->SetTextColor(__pMessageBox->GetTextColor());
//fall thtrough
CATCH:
delete pCanvas;
#include "FUi_CoordinateSystemUtils.h"
#include "FUi_ResourceManager.h"
#include "FUi_UiTouchEvent.h"
+#include "FUiCtrl_Label.h"
+#include "FUiCtrl_ScrollPanel.h"
#include "FUiCtrl_ProgressPopupPresenter.h"
#include "FUiCtrl_ProgressPopup.h"
, __pBodyTextObject(null)
, __titleBounds(0.0f, 0.0f, 0.0f, 0.0f)
, __textBounds(0.0f, 0.0f, 0.0f, 0.0f)
+ , __pLabel(null)
+ , __pScrollPanel(null)
, __pAnimation(null)
, __pAnimationFrameList(null)
, __fontStyle(0)
__pBodyTextObject = null;
}
+ if (__pLabel != null)
+ {
+ __pScrollPanel->DetachChild(*__pLabel);
+ delete __pLabel;
+ __pLabel = null;
+ }
+
+ if (__pScrollPanel != null)
+ {
+ __pProgressPopup->DetachChild(*__pScrollPanel);
+ delete __pScrollPanel;
+ __pScrollPanel = null;
+ }
+
if (__pAnimationFrameList != null)
{
delete __pAnimationFrameList;
if (__pBodyTextObject == null) //add for landscape
{
+ __pLabel = _Label::CreateLabelN();
+ SysTryCatch(NID_UI_CTRL, __pLabel != null, , E_OUT_OF_MEMORY, "[E_SYSTEM] Failed to create the scroll.");
__pBodyTextObject = new (std::nothrow) TextObject();
SysTryReturnVoidResult(NID_UI_CTRL, __pBodyTextObject != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
GET_SHAPE_CONFIG(MESSAGEBOX::BOTTOM_HEIGHT, orientation, bottomHeight);
}
- __pBodyTextObject->SetBounds(FloatRectangle(textLeftMargin + transLeftMargin,
- titleHeight + textTopMargin + transTopMargin + animationWidth + noTitleHeight,
- defaultWidth - (textLeftMargin + textRightMargin + transLeftMargin + transRightMargin),
- maxHeight - titleHeight - bottomHeight - animationWidth));
- __pBodyTextObject->Compose();
-
// Calculate Text bounds
__textBounds.SetBounds(textLeftMargin + transLeftMargin,
titleHeight + textTopMargin + transTopMargin + animationWidth + noTitleHeight,
defaultWidth - (textLeftMargin + textRightMargin + transLeftMargin + transRightMargin),
- __textObjectHeight);
+ maxHeight - titleHeight - bottomHeight - animationWidth);
__pBodyTextObject->SetBounds(__textBounds);
+
+ if (__pProgressPopup->GetText().GetLength() > 0)
+ {
+ __pBodyTextObject->Compose();
+ __textObjectHeight = __pBodyTextObject->GetLineHeightAtF(0) * 3.0;
+ __textBounds.height = __textObjectHeight;
+ }
+
+ if (__pBodyTextObject->GetTotalHeightF() < __textObjectHeight)
+ {
+ __pLabel->SetBounds(FloatRectangle(0.0f, (__textObjectHeight - __pBodyTextObject->GetTotalHeightF())/2.0f, __textBounds.width, __pBodyTextObject->GetTotalHeightF()));
+ }
+ else
+ {
+ __pLabel->SetBounds(FloatRectangle(0.0f, 0.0f, __textBounds.width, __pBodyTextObject->GetTotalHeightF()));
+ }
+
+
+ __pLabel->SetText(__pProgressPopup->GetText());
+ __pLabel->SetTextConfig(bodyTextSize, LABEL_TEXT_STYLE_NORMAL);
+ __pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
+ __pLabel->SetMargin(0.0f, 0.0f, 0.0f, 0.0f);
+
+ if (__pScrollPanel == null)
+ {
+ __pScrollPanel = _ScrollPanel::CreateScrollPanelN(__textBounds, SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL, true);
+ SysTryCatch(NID_UI_CTRL, __pScrollPanel != null, , E_OUT_OF_MEMORY, "[E_SYSTEM] Failed to create the scroll.");
+
+ __pScrollPanel->SetBounds(__textBounds);
+ __pScrollPanel->AttachChild(*__pLabel);
+ __pProgressPopup->AttachChild(*__pScrollPanel);
+ }
+ else
+ {
+ __pScrollPanel->SetBounds(__textBounds);
+ }
}
return;
delete __pBodyTextObject;
__pBodyTextObject = null;
+ delete __pLabel;
+ __pLabel = null;
+
+ delete __pScrollPanel;
+ __pScrollPanel = null;
+
return;
}
__pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
}
- // Draw Body text
- if (__pBodyTextObject != null)
- {
- r = SetFontInfo(FONT_STYLE_PLAIN, bodyTextSize);
- SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
- __pBodyTextObject->SetFont(_pFont, 0, __pBodyTextObject->GetTextLength());
-
- __pBodyTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
- }
-
- //fall thtrough
-CATCH:
- delete pCanvas;
+ __pLabel->SetTextColor(__pProgressPopup->GetTextColor());
return;
}