return _pEditPresenter;
}
-Dimension
-_Edit::GetContentSizeInternal(void) const
+FloatDimension
+_Edit::GetContentSizeInternalF(void) const
{
- Dimension dimension(0,0);
- int leftMargin = 0;
- int rightMargin = 0;
- int textTopMargin = 0;
- int textBottomMargin = 0;
-
- _ControlOrientation orientation = GetOrientation();
- GET_SHAPE_CONFIG(EDIT::AREA_LEFT_MARGIN, orientation, leftMargin);
- GET_SHAPE_CONFIG(EDIT::AREA_RIGHT_MARGIN, orientation, rightMargin);
- GET_SHAPE_CONFIG(EDIT::AREA_TEXT_TOP_MARGIN, orientation, textTopMargin);
- GET_SHAPE_CONFIG(EDIT::AREA_TEXT_BOTTOM_MARGIN, orientation, textBottomMargin);
-
- TextObject* pTextObject = _pEditPresenter->GetTextObject();
-
- if (!pTextObject)
- {
- return dimension;
- }
-
- // store
- TextObjectActionType previousActionType = pTextObject->GetAction();
- TextObjectWrapType previousWrapType = pTextObject->GetWrap();
- Rectangle previousRect = pTextObject->GetBounds();
- Rectangle newRect = previousRect;
-
- if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
+ if (!GetTextLength())
{
- newRect.width = _ControlManager::GetInstance()->GetScreenSize().width;
+ return FloatDimension(GetBoundsF().width, GetBoundsF().height);
}
- else
- {
- newRect.width = _ControlManager::GetInstance()->GetScreenSize().height;
- }
-
-
- pTextObject->SetBounds(newRect);
- pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE);
- pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
- pTextObject->Compose();
-
- dimension = pTextObject->GetTextExtent(0, pTextObject->GetTextLength());
- if (dimension.width > newRect.width)
- {
- dimension.width = newRect.width;
- }
-
- dimension.height = pTextObject->GetTotalHeight();
-
- // restore
- pTextObject->SetBounds(previousRect);
- pTextObject->SetAction(previousActionType);
- pTextObject->SetWrap(previousWrapType);
- pTextObject->Compose();
- dimension.width += leftMargin + rightMargin;
- dimension.height += textTopMargin + textBottomMargin;
-
- return dimension;
-}
-
-FloatDimension
-_Edit::GetContentSizeInternalF(void) const
-{
FloatDimension dimension(0.0f,0.0f);
float leftMargin = 0.0f;
float rightMargin = 0.0f;
+ float textLeftMargin = 0.0f;
+ float textRightMargin = 0.0f;
float textTopMargin = 0.0f;
float textBottomMargin = 0.0f;
_ControlOrientation orientation = GetOrientation();
GET_SHAPE_CONFIG(EDIT::AREA_LEFT_MARGIN, orientation, leftMargin);
GET_SHAPE_CONFIG(EDIT::AREA_RIGHT_MARGIN, orientation, rightMargin);
+ GET_SHAPE_CONFIG(EDIT::AREA_TEXT_LEFT_MARGIN, orientation, textLeftMargin);
+ GET_SHAPE_CONFIG(EDIT::AREA_TEXT_RIGHT_MARGIN, orientation, textRightMargin);
GET_SHAPE_CONFIG(EDIT::AREA_TEXT_TOP_MARGIN, orientation, textTopMargin);
GET_SHAPE_CONFIG(EDIT::AREA_TEXT_BOTTOM_MARGIN, orientation, textBottomMargin);
if (!pTextObject)
{
- return dimension;
+ return FloatDimension(GetBoundsF().width, GetBoundsF().height);
}
// store
FloatRectangle previousRect = pTextObject->GetBoundsF();
FloatRectangle newRect = previousRect;
- if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
+ bool fitToHorizontal = false;
+ bool fitToVertical = true;
+
+ if (fitToHorizontal)
{
- newRect.width = _ControlManager::GetInstance()->GetScreenSizeF().width;
+ if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
+ {
+ newRect.width = _ControlManager::GetInstance()->GetScreenSizeF().width;
+ }
+ else
+ {
+ newRect.width = _ControlManager::GetInstance()->GetScreenSizeF().height;
+ }
+ newRect.width -= (GetBoundsF().x + leftMargin + rightMargin);
}
- else
+ if (fitToVertical)
{
- newRect.width = _ControlManager::GetInstance()->GetScreenSizeF().height;
+ if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
+ {
+ newRect.height = _ControlManager::GetInstance()->GetScreenSizeF().height;
+ }
+ else
+ {
+ 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();
- dimension = pTextObject->GetTextExtentF(0, pTextObject->GetTextLength());
- if (dimension.width > newRect.width)
+ if (fitToHorizontal && fitToVertical)
{
+ 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;
+ }
+ else if (fitToVertical)
+ {
+ float height = pTextObject->GetTotalHeightF();
+ if (height < newRect.height)
+ {
+ dimension.height = height;
+ }
+ else
+ {
+ dimension.height = newRect.height;
+ }
dimension.width = newRect.width;
}
- dimension.height = pTextObject->GetTotalHeightF();
-
// restore
pTextObject->SetBounds(previousRect);
pTextObject->SetAction(previousActionType);
pTextObject->SetWrap(previousWrapType);
pTextObject->Compose();
- dimension.width += leftMargin + rightMargin;
- dimension.height += textTopMargin + textBottomMargin;
+ if (fitToHorizontal)
+ {
+ dimension.width += leftMargin + rightMargin + textLeftMargin + textRightMargin;
+ }
+ if (fitToVertical)
+ {
+ dimension.height += textTopMargin + textBottomMargin;
+ }
return dimension;
}