, __pContentProvider(null)
, __isAnimating(false)
, __isEditDateInitialized(false)
+ , __elementWidth(0.0f)
{
}
GET_SHAPE_CONFIG(EDITDATE::TITLE_DATE_MARGIN, __pEditDate->GetOrientation(), titledateMargin);
GET_SHAPE_CONFIG(EDITDATE::DATE_HEIGHT, __pEditDate->GetOrientation(), dateHeight);
GET_SHAPE_CONFIG(EDITDATE::TITLE_HEIGHT, __pEditDate->GetOrientation(), __titleBounds.height);
+ GET_SHAPE_CONFIG(EDITDATE::TEXT_ELEMENT_WIDTH, __pEditDate->GetOrientation(), __elementWidth);
if (__pEditDate->GetBoundsF().height > editDateHeight)
{
__yearBounds.height = editDateHeight;
}
- float elementWidth = 0.0f;
- GET_SHAPE_CONFIG(EDITDATE::TEXT_ELEMENT_WIDTH, __pEditDate->GetOrientation(), elementWidth);
-
- __dayBounds.width = elementWidth;
- __monthBounds.width = elementWidth;
- __yearBounds.width = elementWidth;
+ __dayBounds.width = GetTextWidth(DATETIME_ID_DAY);
+ __monthBounds.width = GetTextWidth(DATETIME_ID_MONTH);
+ __yearBounds.width = GetTextWidth(DATETIME_ID_YEAR);
- __dayBounds.x = 0.0f;
- __monthBounds.x = 0.0f;
- __yearBounds.x = 0.0f;
+ __dayBounds.x = (__elementWidth - __dayBounds.width) / 2.0f;
+ __monthBounds.x = (__elementWidth - __monthBounds.width) / 2.0f;
+ __yearBounds.x = (__elementWidth - __yearBounds.width) / 2.0f;
__dayBounds.y = bounds.y;
__monthBounds.y = bounds.y;
return r;
}
+float
+_EditDatePresenter::GetTextWidth(_DateTimeId boxId) const
+{
+ result r = E_SUCCESS;
+ FloatDimension dim;
+ TextObject dateObject;
+
+ String monthString;
+ String yearString;
+ String dayString;
+
+ _DateTimeUtils dateTimeUtils;
+ monthString = dateTimeUtils.GetMonthString(GetMonth());
+ yearString.Format(10, L"%04d", GetYear());
+ dayString.Format(10, L"%02d", GetDay());
+
+ r = dateObject.Construct();
+ SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ TextSimple* pSimpleText = null;
+
+ if (boxId == DATETIME_ID_DAY)
+ {
+ pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(dayString.GetPointer())), dayString.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
+ }
+ else if (boxId == DATETIME_ID_MONTH)
+ {
+ pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(monthString.GetPointer())), monthString.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
+ }
+ else if (boxId == DATETIME_ID_YEAR)
+ {
+ pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(yearString.GetPointer())), yearString.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
+ }
+
+ SysTryReturn(NID_UI_CTRL, (pSimpleText != null), dim.width, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ dateObject.AppendElement(*pSimpleText);
+ dateObject.SetFont(__pFont, 0, dateObject.GetTextLength());
+ dim = dateObject.GetTextExtentF(0, dateObject.GetTextLength());
+
+ dateObject.RemoveAll();
+
+ return dim.width;
+}
+
int
_EditDatePresenter::GetLocaleDateFormat(void) const
{
if (GetLocaleDateFormat() == DATE_FORMAT_DDMMYYYY)
{
- __monthBounds.x = __dayBounds.x + __dayBounds.width + __dividerLineWidth;
- __yearBounds.x = __monthBounds.x + __monthBounds.width + __dividerLineWidth;
+ __monthBounds.x = __elementWidth + __dividerLineWidth + (__elementWidth - __monthBounds.width) / 2.0f;
+ __yearBounds.x = (2.0f * __elementWidth) + (2.0f * __dividerLineWidth) + (__elementWidth - __yearBounds.width) / 2.0f;
}
else if (GetLocaleDateFormat() == DATE_FORMAT_MMDDYYYY)
{
- __dayBounds.x = __monthBounds.x + __monthBounds.width + __dividerLineWidth;
- __yearBounds.x = __dayBounds.x + __dayBounds.width + __dividerLineWidth;
+ __dayBounds.x = __elementWidth + __dividerLineWidth + (__elementWidth - __dayBounds.width) / 2.0f;
+ __yearBounds.x = (2.0f * __elementWidth) + (2.0f * __dividerLineWidth) + (__elementWidth - __yearBounds.width) / 2.0f;
}
else if (GetLocaleDateFormat() == DATE_FORMAT_YYYYMMDD)
{
- __monthBounds.x = __yearBounds.x + __yearBounds.width + __dividerLineWidth;
- __dayBounds.x = __monthBounds.x + __monthBounds.width + __dividerLineWidth;
+ __monthBounds.x = __elementWidth + __dividerLineWidth + (__elementWidth - __monthBounds.width) / 2.0f;
+ __dayBounds.x = (2.0f * __elementWidth) + (2.0f * __dividerLineWidth) + (__elementWidth - __dayBounds.width) / 2.0f;
}
else if (GetLocaleDateFormat() == DATE_FORMAT_YYYYDDMM)
{
- __dayBounds.x = __yearBounds.x + __yearBounds.width + __dividerLineWidth;
- __monthBounds.x = __dayBounds.x + __dayBounds.width + __dividerLineWidth;
+ __dayBounds.x = __elementWidth + __dividerLineWidth + (__elementWidth - __dayBounds.width) / 2.0f;
+ __monthBounds.x = (2.0f * __elementWidth) + (2.0f * __dividerLineWidth) + (__elementWidth - __monthBounds.width) / 2.0f;
}
return r;
_DateTimeId boxId = DATETIME_ID_NONE;
boxId = GetBoxIdFromPosition(point);
- if (boxId != __selectedId || boxId == DATETIME_ID_NONE)
+ if (boxId == GetLastSelectedId() || boxId != __selectedId || boxId == DATETIME_ID_NONE)
{
if (__pEditDate->GetDateTimeBar() != null && __pEditDate->GetDateTimeBar()->IsActivated())
{
if (displayBoxId == DATETIME_ID_HOUR)
{
- bounds.width = timeElementWidth;
+ bounds.width = GetTextWidth(displayBoxId);
}
else if (displayBoxId == DATETIME_ID_MINUTE)
{
- bounds.x = bounds.x + timeElementWidth + colonWidth + 2.0f * colonMargin;
- bounds.width = timeElementWidth;
+ bounds.width = GetTextWidth(displayBoxId);
+ bounds.x = bounds.x + timeElementWidth + colonWidth + 2.0f * colonMargin + (timeElementWidth - bounds.width) / 2.0f;
+
}
else if (displayBoxId == DATETIME_ID_AMPM)
{
return bounds;
}
+float
+_EditTimePresenter::GetTextWidth(_DateTimeId boxId) const
+{
+ result r = E_SUCCESS;
+ FloatDimension dim;
+ TextObject dateObject;
+ String hourString;
+ String minuteString;
+
+ hourString.Format(10, L"%02d", GetHour());
+ minuteString.Format(10, L"%02d", GetMinute());
+
+ r = dateObject.Construct();
+ SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ TextSimple* pSimpleText = null;
+
+ if (boxId == DATETIME_ID_HOUR)
+ {
+ pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(hourString.GetPointer())), hourString.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
+ }
+ else if (boxId == DATETIME_ID_MINUTE)
+ {
+ pSimpleText = new (std::nothrow)TextSimple((const_cast <wchar_t*>(minuteString.GetPointer())), minuteString.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
+ }
+
+ SysTryReturn(NID_UI_CTRL, (pSimpleText != null), dim.width, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize);
+
+ dateObject.AppendElement(*pSimpleText);
+ dateObject.SetFont(__pFont, 0, dateObject.GetTextLength());
+ dim = dateObject.GetTextExtentF(0, dateObject.GetTextLength());
+
+ dateObject.RemoveAll();
+ return dim.width;
+}
+
void
_EditTimePresenter::SetTitleBounds(void)
{
FloatRectangle colonBounds(0.0f, 0.0f, 0.0f, 0.0f);
float colonMargin = 0.0f;
+ float hourMinuteWidth = 0.0f;
Dimension textArea;
GET_SHAPE_CONFIG(EDITTIME::COLON_WIDTH, __pEditTime->GetOrientation(), colonBounds.width);
GET_SHAPE_CONFIG(EDITTIME::COLON_MARGIN, __pEditTime->GetOrientation(), colonMargin);
GET_SHAPE_CONFIG(EDITTIME::AMPM_HEIGHT, __pEditTime->GetOrientation(), colonBounds.height);
+ GET_SHAPE_CONFIG(EDITTIME::HOUR_MINUTE_WIDTH, __pEditTime->GetOrientation(), hourMinuteWidth);
- colonBounds.x = hourBounds.x + hourBounds.width + colonMargin;
+ colonBounds.x = hourBounds.x + hourMinuteWidth + colonMargin;
colonBounds.y = hourBounds.y + (hourBounds.height - colonBounds.height) / 2.0f;
if (__title.IsEmpty() == false)
_DateTimeId boxId = GetBoxIdFromPosition(point);
- if (boxId != __selectedId || boxId == DATETIME_ID_NONE)
+ if (boxId == GetLastSelectedId() || boxId != __selectedId || boxId == DATETIME_ID_NONE)
{
if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated())
{