// http://www.apache.org/licenses/LICENSE-2.0/
//
// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an ”AS IS” BASIS,
+// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
, __timeFontSize(0.0f)
, __isAnimating(false)
, __isEditTimeInitialized(false)
+ , __focusStatus(FOCUS_NONE)
+ , __isEnterKeyPressed(false)
+ , __isFocused(false)
{
}
_EditTimePresenter::SetTitleBounds(void)
{
GET_SHAPE_CONFIG(EDITTIME::TITLE_TEXT_LEFT_MARGIN, __pEditTime->GetOrientation(), __titleBounds.x);
- GET_SHAPE_CONFIG(EDITTIME::WIDTH, __pEditTime->GetOrientation(), __titleBounds.width);
GET_SHAPE_CONFIG(EDITTIME::TITLE_HEIGHT, __pEditTime->GetOrientation(), __titleBounds.height);
- __titleBounds.width = __titleBounds.width - __titleBounds.x;
+ __titleBounds.width = __pEditTime->GetBoundsF().width - __titleBounds.x;
return;
}
__titleObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
__titleObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
__titleObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
+ __titleObject.SetTextObjectEllipsisType(TEXT_OBJECT_ELLIPSIS_TYPE_TAIL);
return r;
}
SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
}
+ if (__pEditTime->IsFocused())
+ {
+ DrawFocus();
+ }
+
CATCH:
delete pCanvas;
+ return r;
+}
+result
+_EditTimePresenter::DrawFocus(void)
+{
+ FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
+
+ Canvas* pCanvas = __pEditTime->GetCanvasN();
+ SysTryReturnResult(NID_UI_CTRL, (pCanvas != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create canvas.");
+
+ if (__focusStatus == FOCUS_HOUR)
+ {
+ bounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
+ }
+ else if (__focusStatus == FOCUS_MINUTE)
+ {
+ bounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
+ }
+ else if (__focusStatus == FOCUS_AMPM)
+ {
+ bounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
+ }
+ result r = E_SUCCESS;
+
+ bounds.y = bounds.y - (__adjustFocusHeight / 2.0f);
+ bounds.height = bounds.height + __adjustFocusHeight;
+
+ if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pContentBgHighlightedColorReplacementBitmap))
+ {
+ r = pCanvas->DrawNinePatchedBitmap(bounds, *__pContentBgHighlightedColorReplacementBitmap);
+ SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+ else
+ {
+ r = pCanvas->DrawBitmap(bounds, *__pContentBgHighlightedColorReplacementBitmap);
+ SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+
+ delete pCanvas;
+ return r;
+
+CATCH:
+ delete pCanvas;
return r;
}
}
else if (__selectedId != boxId)
{
- isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::CONTENT_BG_NORMAL);
- pReplacementBitmap = __pContentBgNormalColorReplacementBitmap;
- pEffectBitmap = __pContentBgEffectNormalBitmap;
+ if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated() &&
+ (GetLastSelectedId() == boxId))
+ {
+ isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::CONTENT_BG_PRESSED);
+ pReplacementBitmap = __pContentBgPressedColorReplacementBitmap;
+ pEffectBitmap = __pContentBgEffectPressedBitmap;
+ }
+ else
+ {
+ isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::CONTENT_BG_NORMAL);
+ pReplacementBitmap = __pContentBgNormalColorReplacementBitmap;
+ pEffectBitmap = __pContentBgEffectNormalBitmap;
+ }
}
else
{
result r = E_SUCCESS;
Color textColor;
+ (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_PLAIN);
if (!__pEditTime->IsEnabled())
{
(GetLastSelectedId() == boxId))
{
GET_COLOR_CONFIG(EDITTIME::TEXT_PRESSED, textColor);
+ (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_BOLD);
}
if (boxId == DATETIME_ID_AMPM)
else
{
GET_COLOR_CONFIG(EDITTIME::TEXT_PRESSED, textColor);
+ (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_BOLD);
}
}
}
__textObject.RemoveAll();
(_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize);
- (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_PLAIN);
-
__textObject.AppendElement(*pSimpleText);
- if (boxId == __selectedId && boxId != DATETIME_ID_AMPM)
- {
- (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_BOLD);
- }
-
if (boxId == DATETIME_ID_AMPM)
{
(_FontImpl::GetInstance(*__pFont))->SetSize(textSize);
return __lastSelectedId;
}
+void
+_EditTimePresenter::SetFocusedElement()
+{
+ if (__focusStatus == FOCUS_NONE || __focusStatus == FOCUS_AMPM)
+ {
+ __focusStatus = FOCUS_HOUR;
+ }
+
+ return;
+}
+
+void
+_EditTimePresenter::SetFocusState(bool isFocused)
+{
+ __isFocused = isFocused;
+ return;
+}
+
+bool
+_EditTimePresenter::OnFocusLost(const _Control &source)
+{
+ if (!__isEnterKeyPressed || __focusStatus == FOCUS_AMPM)
+ {
+ __focusStatus = FOCUS_NONE;
+ }
+ else
+ {
+ __isEnterKeyPressed = false;
+ }
+ __pEditTime->Invalidate();
+ return true;
+}
+
+bool
+_EditTimePresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
+{
+ if (!__isFocused)
+ {
+ return false;
+ }
+ _KeyCode keyCode = keyInfo.GetKeyCode();
+
+ int minValue = -1;
+ int maxValue = -1;
+ int displayValue = -1;
+
+ _DateTimeId boxId = DATETIME_ID_HOUR;
+
+ switch (keyCode)
+ {
+ case _KEY_RIGHT:
+ {
+ __isEnterKeyPressed = false;
+ if (__focusStatus == FOCUS_HOUR)
+ {
+ __focusStatus = FOCUS_MINUTE;
+ }
+ else if (__focusStatus == FOCUS_MINUTE)
+ {
+ if (!Is24HourNotationEnabled())
+ {
+ __focusStatus = FOCUS_AMPM;
+ }
+ }
+
+ __pEditTime->Invalidate();
+ break;
+ }
+
+ case _KEY_LEFT:
+ {
+ __isEnterKeyPressed = false;
+ if (__focusStatus == FOCUS_MINUTE)
+ {
+ __focusStatus = FOCUS_HOUR;
+ }
+ else if (__focusStatus == FOCUS_AMPM)
+ {
+ __focusStatus = FOCUS_MINUTE;
+ }
+ __pEditTime->Invalidate();
+ break;
+ }
+
+ case _KEY_ENTER:
+ {
+ __isEnterKeyPressed = true;
+ if (__focusStatus == FOCUS_HOUR)
+ {
+ boxId = DATETIME_ID_HOUR;
+ if (__pEditTime->GetDateTimeBar() != null)
+ {
+ if (!Is24HourNotationEnabled())
+ {
+ if (GetHour() == 0)
+ {
+ minValue = DATETIME_HOUR_MIN + 1;
+ maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
+ displayValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
+ }
+ else if (GetHour() > DATETIME_HOUR_MAX_FOR_24NOTATION)
+ {
+ minValue = DATETIME_HOUR_MIN + 1;
+ maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
+ displayValue = __pEditTime->GetHour() - DATETIME_HOUR_MAX_FOR_24NOTATION;
+ }
+ else
+ {
+ minValue = DATETIME_HOUR_MIN + 1;
+ maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
+ displayValue = __pEditTime->GetHour();
+ }
+ }
+ else
+ {
+ minValue = DATETIME_HOUR_MIN;
+ maxValue = DATETIME_HOUR_MAX;
+ displayValue = __pEditTime->GetHour();
+ }
+
+ if (__pEditTime->GetDateTimeBar()->GetItemCount() > 0)
+ {
+ __pEditTime->GetDateTimeBar()->RemoveAllItems();
+ }
+ }
+ }
+ else if (__focusStatus == FOCUS_MINUTE)
+ {
+ if (__pEditTime->GetDateTimeBar() != null)
+ {
+ minValue = DATETIME_MINUTE_MIN;
+ maxValue = DATETIME_MINUTE_MAX;
+ displayValue = __pEditTime->GetMinute();
+
+ if (__pEditTime->GetDateTimeBar()->GetItemCount() > 0)
+ {
+ __pEditTime->GetDateTimeBar()->RemoveAllItems();
+ }
+ }
+ boxId = DATETIME_ID_MINUTE;
+ }
+ else if (__focusStatus == FOCUS_AMPM)
+ {
+ SetAmEnabled(!GetAmEnabled());
+ __pEditTime->FireTimeChangeEvent(TIME_INTERNAL_CHANGE_SAVED);
+ boxId = DATETIME_ID_AMPM;
+
+ DrawFocus();
+ }
+
+ if ((__pEditTime->GetDateTimeBar() != null) && (boxId != DATETIME_ID_AMPM))
+ {
+ FloatRectangle absoluteBounds = __pEditTime->GetAbsoluteBoundsF();
+
+ FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
+ bounds = GetDisplayAreaBoundsFromHoursStyle(boxId);
+ bounds.x += absoluteBounds.x;
+
+ __pEditTime->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId);
+ __pEditTime->GetDateTimeBar()->CalculateArrowBounds(bounds);
+ __pEditTime->GetDateTimeBar()->SetVisibleState(true);
+ __pEditTime->GetDateTimeBar()->Open();
+ UpdateLastSelectedValue(boxId, false);
+ }
+ break;
+ }
+
+ default:
+ {
+ return false;
+ }
+ }
+ return true;
+}
+
bool
_EditTimePresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
{
return true;
}
+ UpdateLastSelectedValue(__selectedId, true);
+ if (GetLastSelectedId() == DATETIME_ID_AMPM)
+ {
+ return true;
+ }
+
+ Draw();
+
+ if ((__pEditTime->GetDateTimeBar() != null) && (boxId != DATETIME_ID_AMPM) && (GetLastSelectedId() != DATETIME_ID_NONE))
+ {
+ FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
+ bounds = GetDisplayAreaBoundsFromHoursStyle(GetLastSelectedId());
+ FloatRectangle absoluteBounds(0.0f, 0.0f, 0.0f, 0.0f);
+ absoluteBounds = __pEditTime->GetAbsoluteBoundsF();
+ bounds.x += absoluteBounds.x;
+
+ __pEditTime->GetDateTimeBar()->CalculateArrowBounds(bounds);
+
+ if (__pEditTime->GetDateTimeBar()->IsActivated())
+ {
+ __pEditTime->GetDateTimeBar()->RefreshItems();
+ }
+ else
+ {
+ __pEditTime->GetDateTimeBar()->SetVisibleState(true);
+ __pEditTime->GetDateTimeBar()->Open();
+ }
+ }
+
+ __selectedId = DATETIME_ID_NONE;
+ return true;
+}
- SetLastSelectedId(__selectedId);
+void
+_EditTimePresenter::UpdateLastSelectedValue(_DateTimeId boxId, bool isTouchPressed)
+{
+ __selectedId = boxId;
+ SetLastSelectedId(boxId);
__lastSelectedValue = "";
- _DateTimeUtils dateTimeUtils;
if (GetLastSelectedId() == DATETIME_ID_HOUR)
{
if (hours == DATETIME_HOUR_MIN)
{
- hours = hours + DATETIME_HOUR_MAX_FOR_24NOTATION;
+ hours = hours + DATETIME_HOUR_MAX_FOR_24NOTATION;
}
}
__lastSelectedValue.Format(10, L"%02d", hours);
- PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
+ if (isTouchPressed)
+ {
+ PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
+ }
}
else if (GetLastSelectedId() == DATETIME_ID_MINUTE)
{
__lastSelectedValue.Format(10, L"%02d", GetMinute());
- PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
+ if (isTouchPressed)
+ {
+ PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
+ }
}
else if (GetLastSelectedId() == DATETIME_ID_AMPM)
{
SetAmEnabled(!GetAmEnabled());
__pEditTime->FireTimeChangeEvent(TIME_INTERNAL_CHANGE_SAVED);
- __pEditTime->UpdateAccessibilityElement();
- PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
-
+ if (isTouchPressed)
+ {
+ __pEditTime->UpdateAccessibilityElement();
+ PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
+ }
__selectedId = DATETIME_ID_NONE;
if (__pEditTime->GetDateTimeBar() != null && __pEditTime->GetDateTimeBar()->IsActivated())
__pEditTime->GetDateTimeBar()->SetVisibleState(false);
__pEditTime->GetDateTimeBar()->Close();
}
-
- Draw();
-
- return true;
- }
-
- Draw();
-
- if ((__pEditTime->GetDateTimeBar() != null) && (boxId != DATETIME_ID_AMPM) && (GetLastSelectedId() != DATETIME_ID_NONE))
- {
- FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
- bounds = GetDisplayAreaBoundsFromHoursStyle(GetLastSelectedId());
- FloatRectangle absoluteBounds(0.0f, 0.0f, 0.0f, 0.0f);
- absoluteBounds = __pEditTime->GetAbsoluteBoundsF();
- bounds.x += absoluteBounds.x;
-
- __pEditTime->GetDateTimeBar()->CalculateArrowBounds(bounds);
-
- if (__pEditTime->GetDateTimeBar()->IsActivated())
- {
- __pEditTime->GetDateTimeBar()->RefreshItems();
- }
- else
- {
- __pEditTime->GetDateTimeBar()->SetVisibleState(true);
- __pEditTime->GetDateTimeBar()->Open();
- }
}
__selectedId = DATETIME_ID_NONE;
- return true;
+ __pEditTime->Invalidate();
+ return;
}
bool