FloatRectangle previousRect = pTextObject->GetBoundsF();
FloatRectangle newRect = previousRect;
- bool fitToHorizontal = false;
- bool fitToVertical = true;
-
- if (fitToHorizontal)
+ if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
{
- if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
- {
- newRect.width = _ControlManager::GetInstance()->GetScreenSizeF().width;
- }
- else
- {
- newRect.width = _ControlManager::GetInstance()->GetScreenSizeF().height;
- }
- newRect.width -= (GetBoundsF().x + leftMargin + rightMargin);
+ newRect.height = _ControlManager::GetInstance()->GetScreenSizeF().height;
}
- if (fitToVertical)
+ else
{
- if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
- {
- newRect.height = _ControlManager::GetInstance()->GetScreenSizeF().height;
- }
- else
- {
- newRect.height = _ControlManager::GetInstance()->GetScreenSizeF().width;
- }
- newRect.height -= (GetBoundsF().y + textTopMargin + textBottomMargin);
+ newRect.height = _ControlManager::GetInstance()->GetScreenSizeF().width;
}
+ newRect.height -= (GetBoundsF().y + textTopMargin + textBottomMargin);
pTextObject->SetBounds(newRect);
pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE);
pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
pTextObject->Compose();
- if (fitToHorizontal && fitToVertical)
+ float height = pTextObject->GetTotalHeightF();
+ if (height < newRect.height)
{
- dimension = pTextObject->GetTextExtentF(0, pTextObject->GetTextLength());
- float height = pTextObject->GetTotalHeightF();
- if (height < newRect.height)
- {
- dimension.height = height;
- }
- else
- {
- dimension.height = newRect.height;
- }
- }
- else if (fitToHorizontal)
- {
- dimension = pTextObject->GetTextExtentF(0, pTextObject->GetTextLength());
- dimension.height = GetBoundsF().height;
+ dimension.height = height;
}
- else if (fitToVertical)
+ else
{
- float height = pTextObject->GetTotalHeightF();
- if (height < newRect.height)
- {
- dimension.height = height;
- }
- else
- {
- dimension.height = newRect.height;
- }
- dimension.width = newRect.width;
+ dimension.height = newRect.height;
}
+ dimension.width = newRect.width;
// restore
pTextObject->SetBounds(previousRect);
pTextObject->SetWrap(previousWrapType);
pTextObject->Compose();
- if (fitToHorizontal)
- {
- dimension.width += leftMargin + rightMargin + textLeftMargin + textRightMargin;
- }
- if (fitToVertical)
- {
- dimension.height += textTopMargin + textBottomMargin;
- }
+ dimension.height += textTopMargin + textBottomMargin;
return dimension;
}