}
bool
+_DateTimeBar::OnFocusGained(const _Control& control)
+{
+ return true;
+}
+
+bool
+_DateTimeBar::OnFocusLost(const _Control& control)
+{
+ __pDateTimeBarPresenter->SetItemFocused(false);
+ return true;
+}
+
+void
+_DateTimeBar::OnDrawFocus(void)
+{
+ __pDateTimeBarPresenter->SetItemFocused(true);
+ __pDateTimeBarPresenter->DrawFocus();
+ return;
+}
+
+bool
+_DateTimeBar::OnKeyPressed(const _Control &source, const _KeyInfo &keyInfo)
+{
+ return __pDateTimeBarPresenter->OnKeyPressed(source,keyInfo);
+}
+
+bool
_DateTimeBar::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element)
{
return __pDateTimeBarPresenter->OnAccessibilityFocusMovedNext(control, element);
}
else if (__accessibilityFocusOutIndex > focusInIndex)
{
- if(pFocusInAccessibilityElement != null && pFocusInAccessibilityElement->GetBounds().x < 0)
+ if (pFocusInAccessibilityElement != null && pFocusInAccessibilityElement->GetBounds().x < 0)
{
__pDateTimeBarPresenter->MovePrevious();
}
using namespace Tizen::Base::Runtime;
using namespace Tizen::Graphics::_Text;
-const int UPDATE_ITEM_COUNT = 3;
-
namespace Tizen { namespace Ui { namespace Controls
{
, __arrowAreaBounds(FloatRectangle())
, __windowAreaBounds(FloatRectangle())
, __pBgColorReplacementBitmap(null)
+ , __pFocusBitmap(null)
, __pArrowColorReplacementBitmap(null)
, __isInitialAnimation(false)
, __initialAnimationValue(0.0f)
, __pFont(null)
+ , __isFocused(false)
+ , __focusedIndex(-1)
+ , __focusBounds(FloatRectangle())
{
}
delete __pBgColorReplacementBitmap;
__pBgColorReplacementBitmap = null;
+ delete __pFocusBitmap;
+ __pFocusBitmap = null;
+
delete __pArrowColorReplacementBitmap;
__pArrowColorReplacementBitmap = null;
SysTryCatch(NID_UI_CTRL, __pBgColorReplacementBitmap != null, r = GetLastResult(), GetLastResult(), "[%s] Propagating.",
GetErrorMessage(GetLastResult()));
+ r = GET_BITMAP_CONFIG_N(FOCUSUI::FOCUS, BITMAP_PIXEL_FORMAT_ARGB8888, __pFocusBitmap);
+ SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
+
r = LoadArrowBitmap();
SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to load resources.", GetErrorMessage(r));
delete __pBgColorReplacementBitmap;
__pBgColorReplacementBitmap = null;
+ delete __pFocusBitmap;
+ __pFocusBitmap = null;
+
return r;
}
r = DrawArrow(*pCanvas);
SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ if (__isFocused)
+ {
+ DrawFocus();
+ }
+
+CATCH:
delete pCanvas;
return r;
+}
+result
+_DateTimeBarPresenter::DrawFocus()
+{
+ Canvas* pCanvas = __pDateTimeBar->GetCanvasN();
+ SysTryReturnResult(NID_UI_CTRL, (pCanvas != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create canvas.");
+
+ result r = E_SUCCESS;
+
+ if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pFocusBitmap))
+ {
+ r = pCanvas->DrawNinePatchedBitmap(__focusBounds, *__pFocusBitmap);
+ SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+ else
+ {
+ r = pCanvas->DrawBitmap(__focusBounds, *__pFocusBitmap);
+ SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ }
CATCH:
+
delete pCanvas;
return r;
}
+void
+_DateTimeBarPresenter::SetItemFocused(bool isFocused)
+{
+ if (!__isFocused)
+ {
+ __focusedIndex = (GetSelectedItemIndex() - 1);
+ _DateTimeBarItem* pItem = null;
+ pItem = GetItemAt(__focusedIndex);
+
+ __focusBounds = pItem->GetBounds();
+ }
+ __isFocused = isFocused;
+ return;
+}
+
result
_DateTimeBarPresenter::DrawItem(Canvas& canvas)
{
}
bool
+_DateTimeBarPresenter::OnKeyPressed(const _Control &source, const _KeyInfo &keyInfo)
+{
+ if (!__isFocused)
+ {
+ return false;
+ }
+
+ _KeyCode keyCode = keyInfo.GetKeyCode();
+
+ switch (keyCode)
+ {
+ case KEY_RIGHT:
+ {
+ if ((__focusBounds.x + __focusBounds.width) > (GetWindowBounds().width - __focusBounds.width))
+ {
+ MoveNext();
+ }
+ else
+ {
+ __focusBounds.x = __focusBounds.x + __focusBounds.width + GetItemMargin();
+ __pDateTimeBar->Invalidate();
+
+ }
+ __focusedIndex = GetItemIndexFromPosition(FloatPoint(__focusBounds.x, __focusBounds.y));
+
+ break;
+ }
+
+ case KEY_LEFT:
+ {
+ if ((__focusBounds.x - __focusBounds.width) < 0)
+ {
+ MovePrevious();
+ }
+ else
+ {
+ __focusBounds.x = __focusBounds.x - __focusBounds.width - GetItemMargin();
+ __pDateTimeBar->Invalidate();
+ }
+ __focusedIndex = GetItemIndexFromPosition(FloatPoint(__focusBounds.x, __focusBounds.y));
+
+ break;
+ }
+
+ case KEY_ENTER:
+ {
+ _DateTimeBarItem* pItem = null;
+
+ SetItemSelected(__focusedIndex);
+ __pDateTimeBarModel->SetFirstDrawnItemIndex((__focusedIndex));
+
+ if (__focusedIndex >= 0)
+ {
+ pItem = GetItemAt(__focusedIndex);
+ }
+
+ if (pItem != null)
+ {
+ __pDateTimeBar->SetVisibleState(false);
+ __pDateTimeBar->Close();
+
+ __pDateTimeBar->FireActionEvent(pItem->GetActionId());
+
+ if (__pDateTimeBar->GetSelectedBoxId() >= DATETIME_ID_YEAR && __pDateTimeBar->GetSelectedBoxId() <= DATETIME_ID_DAY)
+ {
+ __pDateTimeBar->FireDateTimeChangeEvent(DATE_INTERNAL_CHANGE_SAVED);
+ }
+ else if (__pDateTimeBar->GetSelectedBoxId() >= DATETIME_ID_HOUR && __pDateTimeBar->GetSelectedBoxId() <= DATETIME_ID_MINUTE)
+ {
+ __pDateTimeBar->FireDateTimeChangeEvent(TIME_INTERNAL_CHANGE_SAVED);
+ }
+ }
+ __isFocused = false;
+ break;
+ }
+
+ default:
+ {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool
_DateTimeBarPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
{
if (&source != __pDateTimeBar)
GET_COLOR_CONFIG(DATETIMEPICKER::TEXT_NORMAL, __textColor[DATETIME_STATUS_NORMAL]);
GET_COLOR_CONFIG(DATETIMEPICKER::TEXT_HIGHLIGHTED, __textColor[DATETIME_STATUS_HIGHLIGHTED]);
- GET_COLOR_CONFIG(DATETIMEPICKER::TEXT_PRESSED, __textColor[DATETIME_STATUS_PRESSED]);
+ GET_COLOR_CONFIG(DATETIMEPICKER::TEXT_PRESSED, __textColor[DATETIME_STATUS_SELECTED]);
GET_COLOR_CONFIG(DATETIMEPICKER::TEXT_DISABLED, __textColor[DATETIME_STATUS_DISABLED]);
}
if (__boxId == DATETIME_ID_AMPM)
{
isCustomBitmap[DATETIME_STATUS_NORMAL] = IS_CUSTOM_BITMAP(DATETIMEPICKER::AMPM_BG_NORMAL);
- isCustomBitmap[DATETIME_STATUS_PRESSED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::AMPM_BG_PRESSED);
+ isCustomBitmap[DATETIME_STATUS_SELECTED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::AMPM_BG_PRESSED);
isCustomBitmap[DATETIME_STATUS_HIGHLIGHTED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::AMPM_BG_HIGHLIGHTED);
isCustomBitmap[DATETIME_STATUS_DISABLED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::AMPM_BG_DISABLED);
}
else
{
isCustomBitmap[DATETIME_STATUS_NORMAL] = IS_CUSTOM_BITMAP(DATETIMEPICKER::CONTENT_BG_NORMAL);
- isCustomBitmap[DATETIME_STATUS_PRESSED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::CONTENT_BG_PRESSED);
+ isCustomBitmap[DATETIME_STATUS_SELECTED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::CONTENT_BG_PRESSED);
isCustomBitmap[DATETIME_STATUS_HIGHLIGHTED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::CONTENT_BG_HIGHLIGHTED);
isCustomBitmap[DATETIME_STATUS_DISABLED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::CONTENT_BG_DISABLED);
}
_DateTimeDisplayBox::SetBackgroundBitmap(Bitmap **pBackgroundNormalBitmap, Bitmap **pBackgroundEffectBitmap)
{
GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_TEXT_NORMAL, __textColor[DATETIME_STATUS_NORMAL]);
- GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_TEXT_PRESSED, __textColor[DATETIME_STATUS_PRESSED]);
+ GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_TEXT_PRESSED, __textColor[DATETIME_STATUS_SELECTED]);
GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_TEXT_HIGHLIGHTED, __textColor[DATETIME_STATUS_HIGHLIGHTED]);
GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_TEXT_DISABLED, __textColor[DATETIME_STATUS_DISABLED]);
#include <FBaseColIEnumeratorT.h>
#include <FBaseSysLog.h>
#include <FGrp_BitmapImpl.h>
+#include <FSysSettingInfo.h>
#include "FUiCtrl_DateTimePicker.h"
#include "FUiAnim_VisualElement.h"
using namespace Tizen::Graphics;
using namespace Tizen::Ui;
using namespace Tizen::Ui::Animations;
+using namespace Tizen::System;
namespace Tizen { namespace Ui { namespace Controls
{
_DateTimePicker::~_DateTimePicker(void)
{
+ SettingInfo::RemoveSettingEventListener(*this);
+
if (__pDateTimeChangeEvent != null)
{
delete __pDateTimeChangeEvent;
pView->GetAccessibilityContainer()->Activate(true);
}
+ r = SettingInfo::AddSettingEventListener(*pView);
+ SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
return pView;
CATCH:
return;
}
+bool
+_DateTimePicker::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
+{
+ if (&source != this)
+ {
+ return false;
+ }
+
+ return __pPresenter->OnKeyPressed(source, keyInfo);
+}
+
+bool
+_DateTimePicker::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
+{
+ if (&source != this)
+ {
+ return false;
+ }
+
+ return __pPresenter->OnKeyReleased(source, keyInfo);
+}
+
+void
+_DateTimePicker::OnDrawFocus(void)
+{
+ __pPresenter->DrawFocus();
+ return;
+}
+
+bool
+_DateTimePicker::OnFocusGained(const _Control& source)
+{
+ return _Control::OnFocusGained(source);
+}
+
+bool
+_DateTimePicker::OnFocusLost(const _Control& source)
+{
+ result r = __pPresenter->ReleaseFocus();
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ _Control::OnFocusLost(source);
+ return true;
+}
+
+void
+_DateTimePicker::OnSettingChanged(Tizen::Base::String& key)
+{
+ if (key.Equals(L"http://tizen.org/setting/locale.date.format", false)
+ || key.Equals(L"http://tizen.org/setting/locale.time.format.24hour", false))
+ {
+ __pPresenter->UpdateLocaleDateTimeFormat();
+ Invalidate();
+ }
+
+ return;
+}
+
Font*
_DateTimePicker::GetDateTimeFont(void)
{
* @brief This is the implementation file for the _DateTimePresenter class.
*/
-#include <vconf.h>
+#include <FSysSettingInfo.h>
#include <FBaseErrorDefine.h>
#include <FBaseSysLog.h>
#include <FGrp_TextTextObject.h>
using namespace Tizen::Graphics;
using namespace Tizen::Graphics::_Text;
using namespace Tizen::Ui::Animations;
+using namespace Tizen::System;
namespace Tizen { namespace Ui { namespace Controls
{
_DateTimePresenter::_DateTimePresenter(int pickerStyle, const String& title)
: __pView(null)
, __pModel(null)
- , __selectedBoxIndex(-1)
+ , __selectedBoxIndex(0)
, __focusedBoxIndex(0)
, __pInputPad(null)
, __inputPadType(INPUTPAD_STYLE_NORMAL)
, __hour(0)
, __minute(0)
, __is24HourNotation(false)
+ , __dtp24HourSet(false)
, __isPm(false)
, __isPmButtonPressed(false)
, __isFocusBoxChanged(false)
, __pBgEffectBitmap(null)
, __pFont(null)
, __pPmBox(null)
+ , __keypadEnabled(false)
{
for (int i = 0; i < DATETIME_ID_MAX; i++)
{
SysTryReturnResult(NID_UI_CTRL, (__pModel != null), E_OUT_OF_MEMORY, "Memory allocation failed.");
// Load display data for sync with model data
+ UpdateTimeFormat();
LoadPickerData();
if (__inputPadEnabled == true)
__pInputPad->SetFont(__pFont);
- _DateTimeDisplayBox* pDisplayBox = __pDisplayBox[__focusedBoxIndex];
+ if (__pInputPad->IsFocusable() == true)
+ {
+ __pInputPad->SetFocusable(false);
+ }
+
+ _DateTimeDisplayBox* pDisplayBox = __pDisplayBox[__selectedBoxIndex];
SysTryCatch(NID_UI_CTRL, (pDisplayBox != null), , E_SYSTEM,
"[E_SYSTEM] A system error has occurred. Failed to get Display box.");
_DateTimePresenter::Set24HourNotationEnabled(bool enable)
{
__is24HourNotation = enable;
+ __dtp24HourSet = true;
UpdateDateTimeOutputConfig();
}
if (boxId == displayBoxId)
{
SetFocusBox(i);
- ChangeInputPadStyle(boxId);
return;
}
}
}
void
+_DateTimePresenter::UpdateLocaleDateTimeFormat(void)
+{
+ UpdateTimeFormat();
+
+ UpdateDateTimeOutputConfig();
+
+ LoadPickerData();
+
+ for (int i = 0; i < __outputBoxMaxCount; i++)
+ {
+ AdjustDisplayValue(i);
+ }
+
+ return;
+}
+
+void
+_DateTimePresenter::UpdateTimeFormat(void)
+{
+ if (!__dtp24HourSet)
+ {
+ String key(L"http://tizen.org/setting/locale.time.format.24hour");
+ SettingInfo::GetValue(key , __is24HourNotation);
+ }
+
+ return;
+}
+
+void
_DateTimePresenter::OnChangeLayout(_ControlOrientation orientation)
{
result r = E_SUCCESS;
int touchedAreaId = CalculateTouchArea(touchinfo.GetCurrentPosition().x, touchinfo.GetCurrentPosition().y);
+ if (touchedAreaId != DATETIME_AREA_INPUT)
+ {
+ __keypadEnabled = false;
+ }
+
if (touchedAreaId == DATETIME_AREA_OUTPUT_AMPM)
{
__isPmButtonPressed = true;
- __pView->Draw();
+ __pView->Invalidate(true);
return true;
}
- __selectedBoxIndex = CalculateTouchOutputArea(touchinfo.GetCurrentPosition().x, touchinfo.GetCurrentPosition().y);
-
return true;
}
int touchedAreaId = CalculateTouchArea(touchinfo.GetCurrentPosition().x, touchinfo.GetCurrentPosition().y);
+ if (touchedAreaId != DATETIME_AREA_INPUT)
+ {
+ __keypadEnabled = false;
+ }
+
if (__isPmButtonPressed == true)
{
if (touchedAreaId == DATETIME_AREA_OUTPUT_AMPM)
__inputComposing = DATETIME_INPUT_END;
__changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
__isPmButtonPressed = false;
- __pView->Draw();
+ __pView->Invalidate(true);
return true;
}
if ((touchedAreaId == DATETIME_AREA_NONE) || (touchedAreaId == DATETIME_AREA_INPUT) ||
(touchedAreaId == DATETIME_AREA_OUTPUT_AMPM))
{
- __selectedBoxIndex = -1;
__isPmButtonPressed = false;
- __pView->Draw();
+ __pView->Invalidate(true);
return true;
}
if (touchedAreaId == DATETIME_AREA_OUTPUT)
{
newOutputFocusedIndex = CalculateTouchOutputArea(touchinfo.GetCurrentPosition().x, touchinfo.GetCurrentPosition().y);
- if ((newOutputFocusedIndex == (-1)) || (newOutputFocusedIndex == __focusedBoxIndex))
- {
- __selectedBoxIndex = -1;
- __pView->Draw();
+ if (newOutputFocusedIndex == (-1))
+ {
return true;
}
{
AdjustDisplayValue(i);
}
-
- SetFocusBox(newOutputFocusedIndex);
+ }
+ else
+ {
+ __selectedBoxIndex = newOutputFocusedIndex;
}
_VisualElement* pVisualElement = null;
r = GetLastResult();
SysTryReturn(NID_UI_CTRL, (pCanvas != null), false, r, "[%s] Propagating.", GetErrorMessage(r));
- DrawDateTimeDisplayBox(*pCanvas, __focusedBoxIndex);
+ DrawDateTimeDisplayBox(*pCanvas, __selectedBoxIndex);
delete pCanvas;
- __selectedBoxIndex = -1;
__inputComposing = DATETIME_INPUT_END;
__changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
- int boxId = __pDisplayBox[__focusedBoxIndex]->GetDisplayBoxId();
+ int boxId = __pDisplayBox[__selectedBoxIndex]->GetDisplayBoxId();
ChangeInputPadStyle(boxId);
- __pView->Draw();
+ __pView->Invalidate(true);
return true;
}
return false;
}
- __selectedBoxIndex = -1;
__isPmButtonPressed = false;
__inputComposing = DATETIME_INPUT_END;
__changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
- __pView->Draw();
+ __pView->Invalidate(true);
return true;
}
void
_DateTimePresenter::OnInputPadValueChanged(const _Control& source, int inputPadReturnValue)
{
+ HandleInputPadValueChange(inputPadReturnValue);
+}
+
+void
+_DateTimePresenter::OnActionPerformed(const _Control& source, int actionId)
+{
+ HandleSaveCancelAction(actionId);
+}
+
+bool
+_DateTimePresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
+{
+ int boxId = 0;
+ __keypadEnabled = true;
+
+ _KeyCode keyCode = keyInfo.GetKeyCode();
+
+ if (__focusedBoxIndex < __outputBoxMaxCount)
+ {
+ boxId = __pDisplayBox[__focusedBoxIndex]->GetDisplayBoxId();
+
+ if ((keyCode != _KEY_RIGHT) && (keyCode != _KEY_LEFT) && (boxId == DATETIME_ID_MONTH))
+ {
+ //month can be changed only with touch on input pad
+ return true;
+ }
+ }
+
+ switch (keyCode)
+ {
+ case _KEY_RIGHT:
+ {
+ if (__pickerStyle != DATETIME_OUTPUT_STYLE_DATE && __focusedBoxIndex < __outputBoxMaxCount)
+ {
+ __focusedBoxIndex++;
+ SetFocusBox(__focusedBoxIndex);
+ }
+ else if (__pickerStyle == DATETIME_OUTPUT_STYLE_DATE && __focusedBoxIndex < __outputBoxMaxCount-1)
+ {
+ __focusedBoxIndex++;
+ SetFocusBox(__focusedBoxIndex);
+ }
+ else
+ {
+ return false;
+ }
+ }
+ break;
+ case _KEY_LEFT:
+ {
+ if (__focusedBoxIndex > 0)
+ {
+ __focusedBoxIndex--;
+ SetFocusBox(__focusedBoxIndex);
+ }
+ else
+ {
+ return false;
+ }
+ }
+ break;
+ case _KEY_ENTER:
+ {
+ if (__focusedBoxIndex == __outputBoxMaxCount)
+ {
+ __isPmButtonPressed = true;
+ }
+ }
+ break;
+ case _KEY_0:
+ case _KEY_NUMPAD_0:
+ HandleInputPadValueChange(0);
+ break;
+ case _KEY_1:
+ case _KEY_NUMPAD_1:
+ HandleInputPadValueChange(1);
+ break;
+ case _KEY_2:
+ case _KEY_NUMPAD_2:
+ HandleInputPadValueChange(2);
+ break;
+ case _KEY_3:
+ case _KEY_NUMPAD_3:
+ HandleInputPadValueChange(3);
+ break;
+ case _KEY_4:
+ case _KEY_NUMPAD_4:
+ HandleInputPadValueChange(4);
+ break;
+ case _KEY_5:
+ case _KEY_NUMPAD_5:
+ HandleInputPadValueChange(5);
+ break;
+ case _KEY_6:
+ case _KEY_NUMPAD_6:
+ HandleInputPadValueChange(6);
+ break;
+ case _KEY_7:
+ case _KEY_NUMPAD_7:
+ HandleInputPadValueChange(7);
+ break;
+ case _KEY_8:
+ case _KEY_NUMPAD_8:
+ HandleInputPadValueChange(8);
+ break;
+ case _KEY_9:
+ case _KEY_NUMPAD_9:
+ HandleInputPadValueChange(9);
+ break;
+ default:
+ return false;
+ }
+
+ __pView->Invalidate(true);
+ return true;
+}
+
+bool
+_DateTimePresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
+{
+ _KeyCode keyCode = keyInfo.GetKeyCode();
+ if (__isPmButtonPressed == true && keyCode == _KEY_ENTER)
+ {
+ __isPm = (!__isPm);
+ __isPmButtonPressed = false;
+ __pView->Invalidate(true);
+ }
+
+ return true;
+}
+
+result
+_DateTimePresenter::DrawFocus(void)
+{
+ result r = E_SUCCESS;
+ __keypadEnabled = true;
+ __focusedBoxIndex = __selectedBoxIndex;
+
+ __pView->Invalidate(true);
+ return r;
+}
+
+result
+_DateTimePresenter::ReleaseFocus(void)
+{
+ result r = E_SUCCESS;
+ __keypadEnabled = false;
+ __focusedBoxIndex = 0;
+ __selectedBoxIndex = 0;
+
+ __pView->Invalidate(true);
+ return r;
+}
+
+void
+_DateTimePresenter::HandleInputPadValueChange(int inputPadReturnValue)
+{
if ((__inputPadEnabled == false) || (inputPadReturnValue == -1))
{
return;
}
- int boxId = __pDisplayBox[__focusedBoxIndex]->GetDisplayBoxId();
+ if ((__keypadEnabled == true) && (__pickerStyle != DATETIME_OUTPUT_STYLE_DATE) && (__focusedBoxIndex == __outputBoxMaxCount))
+ {
+ //in case of Am/Pm if keypad enabled, inputpad values need not be handled though in focus
+ return;
+ }
+
+ int boxId = __pDisplayBox[__selectedBoxIndex]->GetDisplayBoxId();
int currentNumber = GetNumberInBox(boxId);
int newNumber = 0;
}
}
- __pView->Draw();
+ __pView->Invalidate(true);
}
void
-_DateTimePresenter::OnActionPerformed(const _Control& source, int actionId)
+_DateTimePresenter::HandleSaveCancelAction(int actionId)
{
result r = E_SUCCESS;
__inputComposing = DATETIME_INPUT_END;
__changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
__focusedBoxIndex = 0;
+ __selectedBoxIndex = 0;
- int boxId = __pDisplayBox[__focusedBoxIndex]->GetDisplayBoxId();
+ int boxId = __pDisplayBox[__selectedBoxIndex]->GetDisplayBoxId();
SetFocusBoxId(boxId);
__pView->Close();
float leftMargin = 0.0f;
GET_SHAPE_CONFIG(DATETIMEPICKER::DATETIME_OUTPUT_LEFT_MARGIN, orientation, leftMargin);
- switch (GetLocaleDateFormat())
+ _DateTimeUtils dateTimeUtils;
+ int localeDateFormat = dateTimeUtils.GetLocaleDateFormat();
+
+ switch (localeDateFormat)
{
case DATE_FORMAT_DDMMYYYY:
{
}
GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_BG_NORMAL, backgroundColor[DATETIME_STATUS_NORMAL]);
- GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_BG_PRESSED, backgroundColor[DATETIME_STATUS_PRESSED]);
+ GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_BG_PRESSED, backgroundColor[DATETIME_STATUS_SELECTED]);
GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_BG_HIGHLIGHTED, backgroundColor[DATETIME_STATUS_HIGHLIGHTED]);
GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_BG_DISABLED, backgroundColor[DATETIME_STATUS_DISABLED]);
r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pDisplayBoxNormalBitmap[DATETIME_STATUS_NORMAL]);
SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
- r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pDisplayBoxNormalBitmap[DATETIME_STATUS_PRESSED]);
+ r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pDisplayBoxNormalBitmap[DATETIME_STATUS_SELECTED]);
SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pDisplayBoxNormalBitmap[DATETIME_STATUS_HIGHLIGHTED]);
r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pAmPmNormalBitmap[DATETIME_STATUS_NORMAL]);
SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
- r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pAmPmNormalBitmap[DATETIME_STATUS_PRESSED]);
+ r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pAmPmNormalBitmap[DATETIME_STATUS_SELECTED]);
SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pAmPmNormalBitmap[DATETIME_STATUS_HIGHLIGHTED]);
SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
isDisplayBoxCustomBitmap[DATETIME_STATUS_NORMAL] = IS_CUSTOM_BITMAP(DATETIMEPICKER::CONTENT_BG_NORMAL);
- isDisplayBoxCustomBitmap[DATETIME_STATUS_PRESSED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::CONTENT_BG_PRESSED);
+ isDisplayBoxCustomBitmap[DATETIME_STATUS_SELECTED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::CONTENT_BG_PRESSED);
isDisplayBoxCustomBitmap[DATETIME_STATUS_HIGHLIGHTED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::CONTENT_BG_HIGHLIGHTED);
isDisplayBoxCustomBitmap[DATETIME_STATUS_DISABLED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::CONTENT_BG_DISABLED);
isAmPmCustomBitmap[DATETIME_STATUS_NORMAL] = IS_CUSTOM_BITMAP(DATETIMEPICKER::AMPM_BG_NORMAL);
- isAmPmCustomBitmap[DATETIME_STATUS_PRESSED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::AMPM_BG_PRESSED);
+ isAmPmCustomBitmap[DATETIME_STATUS_SELECTED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::AMPM_BG_PRESSED);
isAmPmCustomBitmap[DATETIME_STATUS_HIGHLIGHTED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::AMPM_BG_HIGHLIGHTED);
isAmPmCustomBitmap[DATETIME_STATUS_DISABLED] = IS_CUSTOM_BITMAP(DATETIMEPICKER::AMPM_BG_DISABLED);
SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
}
- if (!isDisplayBoxCustomBitmap[DATETIME_STATUS_PRESSED])
+ if (!isDisplayBoxCustomBitmap[DATETIME_STATUS_SELECTED])
{
- r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDisplayBoxEffectBitmap[DATETIME_STATUS_PRESSED]);
+ r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDisplayBoxEffectBitmap[DATETIME_STATUS_SELECTED]);
SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
}
if (!isDisplayBoxCustomBitmap[DATETIME_STATUS_HIGHLIGHTED])
{
- r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDisplayBoxEffectBitmap[DATETIME_STATUS_HIGHLIGHTED]);
+ r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::CONTENT_BG_EFFECT_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDisplayBoxEffectBitmap[DATETIME_STATUS_HIGHLIGHTED]);
SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
}
SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
}
- if (!isAmPmCustomBitmap[DATETIME_STATUS_PRESSED])
+ if (!isAmPmCustomBitmap[DATETIME_STATUS_SELECTED])
{
- r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmEffectBitmap[DATETIME_STATUS_PRESSED]);
+ r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmEffectBitmap[DATETIME_STATUS_SELECTED]);
SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
}
{
status = DATETIME_STATUS_DISABLED;
}
- else if (index == __selectedBoxIndex)
- {
- status = DATETIME_STATUS_PRESSED;
- }
- else if (index == __focusedBoxIndex)
+ else
{
- status = DATETIME_STATUS_HIGHLIGHTED;
+ if (__keypadEnabled)
+ {
+ if (index == __focusedBoxIndex)
+ {
+ status = DATETIME_STATUS_HIGHLIGHTED;
+ }
+ }
+ else
+ {
+ if (index == __selectedBoxIndex)
+ {
+ status = DATETIME_STATUS_SELECTED;
+ }
+ }
}
if (boxId == DATETIME_ID_YEAR)
{
- if ((__inputComposing == DATETIME_INPUT_BEGIN) && (status == DATETIME_STATUS_HIGHLIGHTED))
+ if ((__inputComposing == DATETIME_INPUT_BEGIN) && ((__keypadEnabled && status == DATETIME_STATUS_HIGHLIGHTED)
+ || (!__keypadEnabled && status == DATETIME_STATUS_SELECTED)))
{
String length = L"%0d";
}
else
{
- if ((__inputComposing == DATETIME_INPUT_BEGIN) && (status == DATETIME_STATUS_HIGHLIGHTED))
+ if ((__inputComposing == DATETIME_INPUT_BEGIN) && ((__keypadEnabled && status == DATETIME_STATUS_HIGHLIGHTED)
+ || (!__keypadEnabled && status == DATETIME_STATUS_SELECTED)))
{
r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, L"%d", number);
SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
_DateTimeUtils dateTimeUtils;
-
-
if (__isPm == false)
{
dateTimeUtils.GetAmPm(text, AM_TYPE);
}
else if (__isPmButtonPressed == true)
{
- __pPmBox->DrawDisplayBox(canvas, DATETIME_STATUS_PRESSED);
+ __pPmBox->DrawDisplayBox(canvas, DATETIME_STATUS_SELECTED);
}
else
{
- __pPmBox->DrawDisplayBox(canvas, DATETIME_STATUS_NORMAL);
+ if (__keypadEnabled && __focusedBoxIndex == __outputBoxMaxCount)
+ {
+ __pPmBox->DrawDisplayBox(canvas, DATETIME_STATUS_HIGHLIGHTED);
+ }
+ else
+ {
+ __pPmBox->DrawDisplayBox(canvas, DATETIME_STATUS_NORMAL);
+ }
}
}
void
_DateTimePresenter::SetFocusBox(int index)
{
- __focusedBoxIndex = index;
+ if (__keypadEnabled)
+ {
+ __focusedBoxIndex = index;
+
+ if (__focusedBoxIndex < __outputBoxMaxCount)
+ {
+ __selectedBoxIndex = __focusedBoxIndex;
+ }
+ }
+
__isFocusBoxChanged = true;
+ __inputComposing = DATETIME_INPUT_END;
+ __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
+
+ int boxId = __pDisplayBox[__selectedBoxIndex]->GetDisplayBoxId();
+
+ ChangeInputPadStyle(boxId);
}
void
_DateTimePresenter::LoadPickerData(void)
{
+ _DateTimeUtils dateTimeUtils;
+
__year = GetYear();
__month = GetMonth();
__day = GetDay();
__isPm = false;
}
}
+
__minute = GetMinute();
}
{
maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
- if(__hour == DATETIME_HOUR_MIN)
+ if (__hour == DATETIME_HOUR_MIN)
{
minValue = DATETIME_HOUR_MAX_FOR_24NOTATION;
}
void
_DateTimePresenter::ChangeFocusBox(void)
{
- if (__focusedBoxIndex < (__outputBoxMaxCount - 1))
+ if (__keypadEnabled)
{
- __focusedBoxIndex++;
- int boxId = __pDisplayBox[__focusedBoxIndex]->GetDisplayBoxId();
- ChangeInputPadStyle(boxId);
- __isFocusBoxChanged = true;
+ if (__focusedBoxIndex < __outputBoxMaxCount - 1)
+ {
+ __focusedBoxIndex++;
+ __selectedBoxIndex = __focusedBoxIndex;
+ int boxId = __pDisplayBox[__focusedBoxIndex]->GetDisplayBoxId();
+ ChangeInputPadStyle(boxId);
+ __isFocusBoxChanged = true;
+ }
+ }
+ else
+ {
+ if (__selectedBoxIndex < (__outputBoxMaxCount - 1))
+ {
+ __selectedBoxIndex++;
+ __focusedBoxIndex = __selectedBoxIndex;
+ int boxId = __pDisplayBox[__selectedBoxIndex]->GetDisplayBoxId();
+ ChangeInputPadStyle(boxId);
+ __isFocusBoxChanged = true;
+ }
}
for (int i = 0; i < __outputBoxMaxCount; i++)
__changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN;
}
-int
-_DateTimePresenter::GetLocaleDateFormat(void) const
-{
- int localeDateFormat = -1;
- int error = vconf_get_int(VCONFKEY_SETAPPL_DATE_FORMAT_INT, &localeDateFormat);
- if (error == -1)
- {
- localeDateFormat = SETTING_DATE_FORMAT_DD_MM_YYYY;
- }
-
- return localeDateFormat;
-}
-
void
_DateTimePresenter::SetAccessibilityElementText(void)
{
#include <FBaseDateTime.h>
#include <FLclDateTimeSymbols.h>
+#include <FLclLocaleManager.h>
+#include <FLclDateTimeFormatter.h>
+#include <FSysSettingInfo.h>
#include "FUiCtrl_DateTimeUtils.h"
+#include "FUiCtrl_DateTimeDefine.h"
#include "FUi_ResourceManager.h"
using namespace Tizen::Base;
using namespace Tizen::Locales;
using namespace Tizen::Base::Collection;
+using namespace Tizen::System;
namespace Tizen { namespace Ui { namespace Controls
{
dateSymbols.Construct(CALENDAR_GREGORIAN);
const IList* pListOfShortMonths = dateSymbols.GetShortMonths();
- SysTryReturn(NID_LCL, (pListOfShortMonths != null), text, E_SYSTEM, "[E_SYSTEM] A system error has occurred. pListOfShortMonths is null.");
+ SysTryReturn(NID_UI_CTRL, (pListOfShortMonths != null), text, E_SYSTEM, "[E_SYSTEM] A system error has occurred. pListOfShortMonths is null.");
String* pObj = null;
pObj = static_cast<String*>(const_cast<Object*>(pListOfShortMonths->GetAt(month - 1)));
dateSymbols.Construct(CALENDAR_GREGORIAN);
const IList* pListOfAmPm = dateSymbols.GetAmPm();
- SysTryReturnVoidResult(NID_LCL, (pListOfAmPm != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. pListOfAmPm is null.");
+ SysTryReturnVoidResult(NID_UI_CTRL, (pListOfAmPm != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. pListOfAmPm is null.");
String* pObj = null;
pObj = static_cast<String*>(const_cast<Object*>(pListOfAmPm->GetAt(amPmType)));
return text;
}
+
+int
+_DateTimeUtils::GetLocaleDateFormat(void) const
+{
+ result r = E_SUCCESS;
+
+ LocaleManager localeManager;
+ int localeDateFormat = 0;
+
+ r = localeManager.Construct();
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, localeDateFormat, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
+
+ Locale systemLocale = localeManager.GetSystemLocale();
+
+ DateTimeFormatter* pDateFormatter = DateTimeFormatter::CreateDateFormatterN(systemLocale, DATE_TIME_STYLE_LONG);
+ r = GetLastResult();
+ SysTryReturn(NID_UI_CTRL, pDateFormatter != null, localeDateFormat, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ String formatString = pDateFormatter->GetPattern();
+ formatString.ToLowerCase();
+
+ delete pDateFormatter;
+ pDateFormatter = null;
+
+ int stringLength = formatString.GetLength();
+ String parsedString = L"";
+
+ for (int i = 0; i < stringLength; i++)
+ {
+ wchar_t ch = '\0';
+ r = formatString.GetCharAt(i, ch);
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, localeDateFormat, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ if (ch == 'd' && !parsedString.Contains(L"DD"))
+ {
+ parsedString.Append(L"DD");
+ }
+ else if (ch == 'm' && !parsedString.Contains(L"MM"))
+ {
+ parsedString.Append(L"MM");
+ }
+ else if (ch == 'y' && !parsedString.Contains(L"YYYY"))
+ {
+ parsedString.Append(L"YYYY");
+ }
+
+ if (parsedString.GetLength() == LOCALE_DATE_FORMAT_STRING_LENGTH)
+ {
+ break;
+ }
+ }
+
+ if (parsedString.Equals(L"DDMMYYYY", false))
+ {
+ localeDateFormat = DATE_FORMAT_DDMMYYYY;
+ }
+ else if (parsedString.Equals(L"MMDDYYYY", false))
+ {
+ localeDateFormat = DATE_FORMAT_MMDDYYYY;
+ }
+ else if (parsedString.Equals(L"YYYYMMDD", false))
+ {
+ localeDateFormat = DATE_FORMAT_YYYYMMDD;
+ }
+ else if (parsedString.Equals(L"YYYYDDMM", false))
+ {
+ localeDateFormat = DATE_FORMAT_YYYYDDMM;
+ }
+
+ return localeDateFormat;
+}
+
}}} // Tizen::Ui::Controls
* @brief This is the implementation file for the _EditDate class.
*/
-#include <vconf.h>
#include <FSysSettingInfo.h>
#include "FUi_AccessibilityContainer.h"
#include "FUi_AccessibilityElement.h"
__pAccessibilityDayElement->SetTrait(ACCESSIBILITY_TRAITS_DAY);
__pAccessibilityDayElement->SetHint(hintText);
- switch (__pEditDatePresenter->GetLocaleDateFormat())
+ _DateTimeUtils dateTimeUtils;
+ int localeDateFormat = dateTimeUtils.GetLocaleDateFormat();
+
+ switch (localeDateFormat)
{
- case SETTING_DATE_FORMAT_DD_MM_YYYY:
+ case DATE_FORMAT_DDMMYYYY:
pContainer->AddElement(*__pAccessibilityDayElement);
pContainer->AddElement(*__pAccessibilityMonthElement);
pContainer->AddElement(*__pAccessibilityYearElement);
break;
- case SETTING_DATE_FORMAT_MM_DD_YYYY:
+ case DATE_FORMAT_MMDDYYYY:
pContainer->AddElement(*__pAccessibilityMonthElement);
pContainer->AddElement(*__pAccessibilityDayElement);
pContainer->AddElement(*__pAccessibilityYearElement);
break;
- case SETTING_DATE_FORMAT_YYYY_MM_DD:
+ case DATE_FORMAT_YYYYMMDD:
pContainer->AddElement(*__pAccessibilityYearElement);
pContainer->AddElement(*__pAccessibilityMonthElement);
pContainer->AddElement(*__pAccessibilityDayElement);
break;
- case SETTING_DATE_FORMAT_YYYY_DD_MM:
+ case DATE_FORMAT_YYYYDDMM:
pContainer->AddElement(*__pAccessibilityYearElement);
pContainer->AddElement(*__pAccessibilityDayElement);
pContainer->AddElement(*__pAccessibilityMonthElement);
bool
_EditDate::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
{
- SetFocused(true);
-
FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
if (absoluteBounds.y != __absoluteBounds.y || absoluteBounds.height != __absoluteBounds.height)
return;
}
+bool
+_EditDate::OnKeyPressed(const _Control &source, const _KeyInfo &keyInfo)
+{
+ _KeyCode keyCode = keyInfo.GetKeyCode();
+
+ switch (keyCode)
+ {
+ case _KEY_ENTER:
+ {
+
+ FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
+
+ if (absoluteBounds.y != __absoluteBounds.y || absoluteBounds.height != __absoluteBounds.height)
+ {
+ CalculateDateTimeBarPosition();
+ }
+ break;
+ }
+ default:
+ break;
+
+ }
+
+ return __pEditDatePresenter->OnKeyPressed(source, keyInfo);
+}
+
+bool
+_EditDate::OnFocusGained(const _Control &source)
+{
+ __pEditDatePresenter->SetFocusedElement();
+ return true;
+}
+
+bool
+_EditDate::OnFocusLost(const _Control &source)
+{
+ __pEditDatePresenter->OnFocusLost(source);
+ return true;
+}
+
+void
+_EditDate::OnDrawFocus(void)
+{
+ __pEditDatePresenter->SetFocusState(true);
+ __pEditDatePresenter->DrawFocus();
+ return;
+}
+
FloatRectangle
_EditDate::GetParentWindowBounds(void) const
{
dayString.Append(GetDay());
String monthString = GetDateTimeBar()->GetMonthValue(GetMonth()).GetPointer();
- switch (__pEditDatePresenter->GetLocaleDateFormat())
+ _DateTimeUtils dateTimeUtils;
+ int localeDateFormat = dateTimeUtils.GetLocaleDateFormat();
+
+ switch (localeDateFormat)
{
- case SETTING_DATE_FORMAT_DD_MM_YYYY:
+ case DATE_FORMAT_DDMMYYYY:
string.Append(dayString.GetPointer());
string.Append(space.GetPointer());
string.Append(monthString.GetPointer());
string.Append(space.GetPointer());
string.Append(yearString.GetPointer());
break;
- case SETTING_DATE_FORMAT_MM_DD_YYYY:
+ case DATE_FORMAT_MMDDYYYY:
string.Append(monthString.GetPointer());
string.Append(space.GetPointer());
string.Append(dayString.GetPointer());
string.Append(space.GetPointer());
string.Append(yearString.GetPointer());
break;
- case SETTING_DATE_FORMAT_YYYY_MM_DD:
+ case DATE_FORMAT_YYYYMMDD:
string.Append(yearString.GetPointer());
string.Append(space.GetPointer());
string.Append(monthString.GetPointer());
string.Append(space.GetPointer());
string.Append(dayString.GetPointer());
break;
- case SETTING_DATE_FORMAT_YYYY_DD_MM:
+ case DATE_FORMAT_YYYYDDMM:
string.Append(yearString.GetPointer());
string.Append(space.GetPointer());
string.Append(dayString.GetPointer());
, __isAnimating(false)
, __isEditDateInitialized(false)
, __elementWidth(0.0f)
+ , __focusStatus(FOCUS_NONE)
+ , __isEnterKeyPressed(false)
+ , __isFocused(false)
{
}
return r;
}
-int
-_EditDatePresenter::GetLocaleDateFormat(void) const
-{
- int localeDateFormat = -1;
- int error = vconf_get_int(VCONFKEY_SETAPPL_DATE_FORMAT_INT, &localeDateFormat);
- if (error == -1)
- {
- localeDateFormat = SETTING_DATE_FORMAT_DD_MM_YYYY;
- }
-
- return localeDateFormat;
-}
-
DateTime
_EditDatePresenter::GetDate(void) const
{
_EditDatePresenter::Draw(void)
{
result r = E_SUCCESS;
-
if (__isAnimating)
{
return E_SUCCESS;
r = DrawText(*pCanvas, GetDateAreaBounds(DATETIME_ID_YEAR), yearString, DATETIME_ID_YEAR);
SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ if (__pEditDate->IsFocused())
+ {
+ DrawFocus();
+ }
+
+CATCH:
delete pCanvas;
+ return r;
+}
+
+result
+_EditDatePresenter::DrawFocus(void)
+{
+ FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
+
+ Canvas* pCanvas = __pEditDate->GetCanvasN();
+ SysTryReturnResult(NID_UI_CTRL, (pCanvas != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create canvas.");
+
+ if (__focusStatus == FOCUS_DAY)
+ {
+ bounds = GetDateAreaBounds(DATETIME_ID_DAY);
+ }
+ else if (__focusStatus == FOCUS_MONTH)
+ {
+ bounds = GetDateAreaBounds(DATETIME_ID_MONTH);
+ }
+ else if (__focusStatus == FOCUS_YEAR)
+ {
+ bounds = GetDateAreaBounds(DATETIME_ID_YEAR);
+ }
+
+ bounds.y = bounds.y - (__adjustFocusHeight / 2.0f);
+ bounds.height = bounds.height + __adjustFocusHeight;
+
+ result r = E_SUCCESS;
+
+ 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:
+CATCH:
delete pCanvas;
return r;
}
+void
+_EditDatePresenter::UpdateLastSelectedValue(_DateTimeId id, bool isTouchPressed)
+{
+ __selectedId = id;
+ SetLastSelectedId(id);
+ __lastSelectedValue = "";
+ _DateTimeUtils dateTimeUtils;
+
+ if (GetLastSelectedId() == DATETIME_ID_YEAR)
+ {
+ __lastSelectedValue.Format(10, L"%04d", GetYear());
+ if (isTouchPressed)
+ {
+ PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
+ }
+ }
+ else if (GetLastSelectedId() == DATETIME_ID_MONTH)
+ {
+ __lastSelectedValue = dateTimeUtils.GetMonthString(GetMonth());
+ if (isTouchPressed)
+ {
+ PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
+ }
+ }
+ else if (GetLastSelectedId() == DATETIME_ID_DAY)
+ {
+ __lastSelectedValue.Format(10, L"%02d", GetDay());
+ if (isTouchPressed)
+ {
+ PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
+ }
+ }
+
+ __pEditDate->Invalidate();
+ return;
+}
+
result
_EditDatePresenter::CalculateAreaBounds(void)
{
result r = E_SUCCESS;
- if (GetLocaleDateFormat() == DATE_FORMAT_DDMMYYYY)
+ _DateTimeUtils dateTimeUtils;
+ int localeDateFormat = dateTimeUtils.GetLocaleDateFormat();
+
+ if (localeDateFormat == DATE_FORMAT_DDMMYYYY)
{
__monthBounds.x = __dayBounds.x + __dayBounds.width + __elementMargin;
__yearBounds.x = __monthBounds.x + __monthBounds.width + __elementMargin;
}
- else if (GetLocaleDateFormat() == DATE_FORMAT_MMDDYYYY)
+ else if (localeDateFormat == DATE_FORMAT_MMDDYYYY)
{
__dayBounds.x = __monthBounds.x + __monthBounds.width + __elementMargin;
__yearBounds.x = __dayBounds.x + __dayBounds.width + __elementMargin;
}
- else if (GetLocaleDateFormat() == DATE_FORMAT_YYYYMMDD)
+ else if (localeDateFormat == DATE_FORMAT_YYYYMMDD)
{
__monthBounds.x = __yearBounds.x + __yearBounds.width + __elementMargin;
__dayBounds.x = __monthBounds.x + __monthBounds.width + __elementMargin;
}
- else if (GetLocaleDateFormat() == DATE_FORMAT_YYYYDDMM)
+ else if (localeDateFormat == DATE_FORMAT_YYYYDDMM)
{
__dayBounds.x = __yearBounds.x + __yearBounds.width + __elementMargin;
__monthBounds.x = __dayBounds.x + __dayBounds.width + __elementMargin;
return;
}
+void
+_EditDatePresenter::SetFocusState(bool isFocused)
+{
+ __isFocused = isFocused;
+}
+
+void
+_EditDatePresenter::SetFocusedElement()
+{
+ _DateTimeUtils dateTimeUtils;
+ int localeDateFormat = dateTimeUtils.GetLocaleDateFormat();
+ if (__focusStatus == FOCUS_NONE)
+ {
+ if (localeDateFormat == DATE_FORMAT_DDMMYYYY)
+ {
+ __focusStatus = FOCUS_DAY;
+ }
+ else if (localeDateFormat == DATE_FORMAT_MMDDYYYY)
+ {
+ __focusStatus = FOCUS_MONTH;
+ }
+ else if (localeDateFormat == DATE_FORMAT_YYYYMMDD)
+ {
+ __focusStatus = FOCUS_YEAR;
+ }
+ else if (localeDateFormat == DATE_FORMAT_YYYYDDMM)
+ {
+ __focusStatus = FOCUS_YEAR;
+ }
+ }
+ return;
+}
+
+bool
+_EditDatePresenter::OnFocusLost(const _Control &source)
+{
+ if (!__isEnterKeyPressed)
+ {
+ __focusStatus = FOCUS_NONE;
+ }
+ else
+ {
+ __isEnterKeyPressed = false;
+ }
+ __pEditDate->Invalidate();
+ return true;
+}
+
+bool
+_EditDatePresenter::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_NONE;
+ _DateTimeUtils dateTimeUtils;
+ int localeDateFormat = dateTimeUtils.GetLocaleDateFormat();
+
+ switch (keyCode)
+ {
+ case _KEY_RIGHT:
+ {
+ if (__focusStatus == FOCUS_DAY)
+ {
+ if (localeDateFormat == DATE_FORMAT_DDMMYYYY || localeDateFormat == DATE_FORMAT_YYYYDDMM)
+ {
+ __focusStatus = FOCUS_MONTH;
+ }
+ else if (localeDateFormat == DATE_FORMAT_MMDDYYYY)
+ {
+ __focusStatus = FOCUS_YEAR;
+ }
+ }
+ else if (__focusStatus == FOCUS_MONTH)
+ {
+ if (localeDateFormat == DATE_FORMAT_DDMMYYYY)
+ {
+ __focusStatus = FOCUS_YEAR;
+ }
+ else if (localeDateFormat == DATE_FORMAT_MMDDYYYY || localeDateFormat == DATE_FORMAT_YYYYMMDD)
+ {
+ __focusStatus = FOCUS_DAY;
+ }
+ }
+ else if (__focusStatus == FOCUS_YEAR)
+ {
+ if (localeDateFormat == DATE_FORMAT_YYYYMMDD)
+ {
+ __focusStatus = FOCUS_MONTH;
+ }
+ else if (localeDateFormat == DATE_FORMAT_YYYYDDMM)
+ {
+ __focusStatus = FOCUS_DAY;
+ }
+ }
+ __pEditDate->Invalidate();
+ break;
+ }
+
+ case _KEY_LEFT:
+ {
+ if (__focusStatus == FOCUS_DAY)
+ {
+ if (localeDateFormat == DATE_FORMAT_YYYYDDMM)
+ {
+ __focusStatus = FOCUS_YEAR;
+ }
+ else if (localeDateFormat == DATE_FORMAT_MMDDYYYY || localeDateFormat == DATE_FORMAT_YYYYMMDD)
+ {
+ __focusStatus = FOCUS_MONTH;
+ }
+ }
+ else if (__focusStatus == FOCUS_MONTH)
+ {
+ if (localeDateFormat == DATE_FORMAT_YYYYMMDD)
+ {
+ __focusStatus = FOCUS_YEAR;
+ }
+ else if (localeDateFormat == DATE_FORMAT_DDMMYYYY || localeDateFormat == DATE_FORMAT_YYYYDDMM)
+ {
+ __focusStatus = FOCUS_DAY;
+ }
+ }
+ else if (__focusStatus == FOCUS_YEAR)
+ {
+ if (localeDateFormat == DATE_FORMAT_DDMMYYYY)
+ {
+ __focusStatus = FOCUS_MONTH;
+ }
+ else if (localeDateFormat == DATE_FORMAT_MMDDYYYY)
+ {
+ __focusStatus = FOCUS_DAY;
+ }
+ }
+ __pEditDate->Invalidate();
+ break;
+ }
+
+ case _KEY_ENTER:
+ {
+ __isEnterKeyPressed = true;
+ if (__focusStatus == FOCUS_DAY)
+ {
+ _DateTimeUtils dateTimeUtils;
+ maxValue = dateTimeUtils.CalculateMaxDay(GetYear(), GetMonth());
+ minValue = DATETIME_DAY_MIN;
+ displayValue = GetDay();
+ boxId = DATETIME_ID_DAY;
+
+ if (__pEditDate->GetDateTimeBar()->GetItemCount() > 0)
+ {
+ __pEditDate->GetDateTimeBar()->RemoveAllItems();
+ }
+ }
+
+ else if (__focusStatus == FOCUS_MONTH)
+ {
+ minValue = DATETIME_MONTH_MIN;
+ maxValue = DATETIME_MONTH_MAX;
+ displayValue = GetMonth();
+ boxId = DATETIME_ID_MONTH;
+
+ if (__pEditDate->GetDateTimeBar()->GetItemCount() > 0)
+ {
+ __pEditDate->GetDateTimeBar()->RemoveAllItems();
+ }
+ }
+ else if (__focusStatus == FOCUS_YEAR)
+ {
+ minValue = GetMinYear();
+ maxValue = GetMaxYear();
+ displayValue = GetYear();
+ boxId = DATETIME_ID_YEAR;
+
+ if (__pEditDate->GetDateTimeBar()->GetItemCount() > 0)
+ {
+ __pEditDate->GetDateTimeBar()->RemoveAllItems();
+ }
+ }
+ FloatRectangle absoluteBounds = __pEditDate->GetAbsoluteBoundsF();
+
+ FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
+ bounds = GetDateAreaBounds(boxId);
+ bounds.x += absoluteBounds.x;
+ __pEditDate->GetDateTimeBar()->CalculateArrowBounds(bounds);
+ __pEditDate->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId);
+ __pEditDate->GetDateTimeBar()->SetVisibleState(true);
+ __pEditDate->GetDateTimeBar()->Open();
+
+ UpdateLastSelectedValue(boxId, false);
+ break;
+ }
+ default:
+ {
+ return false;
+ }
+ }
+ return true;
+}
+
bool
_EditDatePresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
{
return true;
}
- SetLastSelectedId(__selectedId);
-
- __lastSelectedValue = "";
- _DateTimeUtils dateTimeUtils;
- if (GetLastSelectedId() == DATETIME_ID_YEAR)
- {
- __lastSelectedValue.Format(10, L"%04d", GetYear());
- PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
- }
- else if (GetLastSelectedId() == DATETIME_ID_MONTH)
- {
- __lastSelectedValue = dateTimeUtils.GetMonthString(GetMonth());
- PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
- }
- else if (GetLastSelectedId() == DATETIME_ID_DAY)
- {
- __lastSelectedValue.Format(10, L"%02d", GetDay());
- PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
- }
-
- Draw();
+ UpdateLastSelectedValue(__selectedId, true);
if ((__pEditDate->GetDateTimeBar() != null) && (GetLastSelectedId() != DATETIME_ID_NONE))
{
__pEditTimePresenter->Draw();
- if(unlikely((_AccessibilityManager::IsActivated())))
+ if (unlikely((_AccessibilityManager::IsActivated())))
{
UpdateAccessibilityElement();
}
bool
_EditTime::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
{
- SetFocused(true);
-
FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
if (absoluteBounds.y != __absoluteBounds.y || absoluteBounds.height != __absoluteBounds.height)
{
return;
}
+void
+_EditTime::OnDrawFocus(void)
+{
+ __pEditTimePresenter->SetFocusState(true);
+ __pEditTimePresenter->DrawFocus();
+ return;
+}
+
+bool
+_EditTime::OnKeyPressed(const _Control &source, const _KeyInfo &keyInfo)
+{
+ _KeyCode keyCode = keyInfo.GetKeyCode();
+
+ switch (keyCode)
+ {
+ case _KEY_ENTER:
+ {
+ FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
+
+ if (absoluteBounds.y != __absoluteBounds.y || absoluteBounds.height != __absoluteBounds.height)
+ {
+ CalculateDateTimeBarPosition();
+ }
+ break;
+ }
+ default:
+ break;
+
+ }
+
+ return __pEditTimePresenter->OnKeyPressed(source, keyInfo);
+}
+
+bool
+_EditTime::OnFocusGained(const _Control &source)
+{
+ __pEditTimePresenter->SetFocusedElement();
+ return true;
+}
+
+bool
+_EditTime::OnFocusLost(const _Control &source)
+{
+ return __pEditTimePresenter->OnFocusLost(source);
+}
+
FloatRectangle
_EditTime::GetParentWindowBounds(void) const
{
, __timeFontSize(0.0f)
, __isAnimating(false)
, __isEditTimeInitialized(false)
+ , __focusStatus(FOCUS_NONE)
+ , __isEnterKeyPressed(false)
+ , __isFocused(false)
{
}
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;
}
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
}
GET_COLOR_CONFIG(INPUTPAD::BUTTON_BG_NORMAL, buttonColor[DATETIME_STATUS_NORMAL]);
- GET_COLOR_CONFIG(INPUTPAD::BUTTON_BG_PRESSED, buttonColor[DATETIME_STATUS_PRESSED]);
+ GET_COLOR_CONFIG(INPUTPAD::BUTTON_BG_PRESSED, buttonColor[DATETIME_STATUS_SELECTED]);
GET_COLOR_CONFIG(INPUTPAD::BUTTON_BG_HIGHLIGHTED, buttonColor[DATETIME_STATUS_HIGHLIGHTED]);
GET_COLOR_CONFIG(INPUTPAD::BUTTON_BG_DISABLED, buttonColor[DATETIME_STATUS_DISABLED]);
r = GET_BITMAP_CONFIG_N(INPUTPAD::BUTTON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pButtonBgNormalBitmap[DATETIME_STATUS_NORMAL]);
SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
- r = GET_BITMAP_CONFIG_N(INPUTPAD::BUTTON_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pButtonBgNormalBitmap[DATETIME_STATUS_PRESSED]);
+ r = GET_BITMAP_CONFIG_N(INPUTPAD::BUTTON_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pButtonBgNormalBitmap[DATETIME_STATUS_SELECTED]);
SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
r = GET_BITMAP_CONFIG_N(INPUTPAD::BUTTON_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pButtonBgNormalBitmap[DATETIME_STATUS_HIGHLIGHTED]);
SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
isCustomBitmap[DATETIME_STATUS_NORMAL] = IS_CUSTOM_BITMAP(INPUTPAD::BUTTON_BG_NORMAL);
- isCustomBitmap[DATETIME_STATUS_PRESSED] = IS_CUSTOM_BITMAP(INPUTPAD::BUTTON_BG_PRESSED);
+ isCustomBitmap[DATETIME_STATUS_SELECTED] = IS_CUSTOM_BITMAP(INPUTPAD::BUTTON_BG_PRESSED);
isCustomBitmap[DATETIME_STATUS_HIGHLIGHTED] = IS_CUSTOM_BITMAP(INPUTPAD::BUTTON_BG_HIGHLIGHTED);
isCustomBitmap[DATETIME_STATUS_DISABLED] = IS_CUSTOM_BITMAP(INPUTPAD::BUTTON_BG_DISABLED);
SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
}
- if (!isCustomBitmap[DATETIME_STATUS_PRESSED])
+ if (!isCustomBitmap[DATETIME_STATUS_SELECTED])
{
- r = GET_BITMAP_CONFIG_N(INPUTPAD::BUTTON_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pKeypadButtonEffectBitmap[DATETIME_STATUS_PRESSED]);
+ r = GET_BITMAP_CONFIG_N(INPUTPAD::BUTTON_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pKeypadButtonEffectBitmap[DATETIME_STATUS_SELECTED]);
SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
}
}
else if (__pressedIndex == index)
{
- status = DATETIME_STATUS_PRESSED;
+ status = DATETIME_STATUS_SELECTED;
GET_COLOR_CONFIG(INPUTPAD::TEXT_PRESSED, textColor);
}
else
}
isCustomBitmap[DATETIME_STATUS_NORMAL] = IS_CUSTOM_BITMAP(INPUTPAD::BUTTON_BG_NORMAL);
- isCustomBitmap[DATETIME_STATUS_PRESSED] = IS_CUSTOM_BITMAP(INPUTPAD::BUTTON_BG_PRESSED);
+ isCustomBitmap[DATETIME_STATUS_SELECTED] = IS_CUSTOM_BITMAP(INPUTPAD::BUTTON_BG_PRESSED);
isCustomBitmap[DATETIME_STATUS_HIGHLIGHTED] = IS_CUSTOM_BITMAP(INPUTPAD::BUTTON_BG_HIGHLIGHTED);
isCustomBitmap[DATETIME_STATUS_DISABLED] = IS_CUSTOM_BITMAP(INPUTPAD::BUTTON_BG_DISABLED);
if (__pressedIndex >= 0)
{
RefreshButton(__pressedIndex);
- if (__pInputPadEventListener != null)
- {
- __pInputPadEventListener->OnInputPadValueChanged(source, GetReturnValue(__pressedIndex));
- }
-
return true;
}
return false;
}
- if (__pressedIndex >= 0)
+ SysTryReturn(NID_UI_CTRL, __pressedIndex >= 0, true, E_SUCCESS, "Touch pressed Index is invalid, ignoring touch release");
+
+ int refreshIndex = __pressedIndex;
+ int currentReleasedIndex = GetIndexFromTouchedPosition(touchinfo.GetCurrentPosition());
+
+ if (currentReleasedIndex >= 0)
{
- int refreshIndex = __pressedIndex;
- __pressedIndex = -1;
- RefreshButton(refreshIndex);
+ if (__pInputPadEventListener != null)
+ {
+ __pInputPadEventListener->OnInputPadValueChanged(source, GetReturnValue(currentReleasedIndex));
+ }
+ }
- return true;
+ __pressedIndex = -1;
+ if (refreshIndex >= 0)
+ {
+ RefreshButton(refreshIndex);
}
- return false;
+ return true;
}
bool
Tizen::Graphics::FloatRectangle GetParentWindowBounds() const;
void RefreshItems(void);
+ virtual bool OnFocusGained(const _Control &source);
+ virtual bool OnFocusLost(const _Control &source);
+ void OnDrawFocus(void);
+ bool OnKeyPressed(const _Control &source, const _KeyInfo &keyInfo);
+
// accessibility listener
virtual bool OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element);
virtual bool OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element);
int GetMaximumValue(void) const;
void SetMaximumValue(int maxValue);
+ result DrawFocus();
+ void SetItemFocused(bool isFocused);
+
float GetItemWidth(void) const;
float GetItemMargin(void) const;
float GetFontSize(void) const;
float GetLeftRightMargin(void) const;
+ bool OnKeyPressed(const _Control &source, const _KeyInfo &keyInfo);
virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
Tizen::Graphics::FloatRectangle __arrowAreaBounds;
Tizen::Graphics::FloatRectangle __windowAreaBounds;
Tizen::Graphics::Bitmap* __pBgColorReplacementBitmap;
+ Tizen::Graphics::Bitmap* __pFocusBitmap;
Tizen::Graphics::Bitmap* __pArrowColorReplacementBitmap;
bool __isInitialAnimation;
int __initialAnimationValue;
Tizen::Graphics::Font* __pFont;
+ bool __isFocused;
+ int __focusedIndex;
+ Tizen::Graphics::FloatRectangle __focusBounds;
+ static const int UPDATE_ITEM_COUNT = 3;
+
}; // _DateTimeBarPresenter
}}} // Tizen::Ui::Controls
enum DateTimePickerStatus
{
DATETIME_STATUS_NORMAL = 0,
- DATETIME_STATUS_PRESSED,
+ DATETIME_STATUS_SELECTED,
DATETIME_STATUS_HIGHLIGHTED,
DATETIME_STATUS_DISABLED,
DATETIME_STATUS_MAX
DATE_FORMAT_YYYYMMDD,
DATE_FORMAT_YYYYDDMM
};
+
+enum _TimeFormat
+{
+ TIME_FORMAT_12HOUR = 0,
+ TIME_FORMAT_24HOUR
+};
+
+enum _FocusType
+{
+ FOCUS_DAY = 0,
+ FOCUS_MONTH,
+ FOCUS_YEAR,
+ FOCUS_HOUR,
+ FOCUS_MINUTE,
+ FOCUS_AMPM,
+ FOCUS_NONE
+};
+
}}} // Tizen::Ui::Controls
#endif // _FUI_CTRL_INTERNAL_DATETIME_DEFINE_H_
#include <FBaseDateTime.h>
#include <FBaseString.h>
#include <FBaseColLinkedListT.h>
+#include <FSysISettingEventListener.h>
#include "FUi_Window.h"
#include "FUiCtrl_IActionEventListener.h"
, virtual public Tizen::Ui::_IUiEventListener
, virtual public Tizen::Ui::_IUiEventPreviewer
, virtual public Tizen::Ui::_IAccessibilityListener
+ , virtual public Tizen::System::ISettingEventListener
{
DECLARE_CLASS_BEGIN(_DateTimePicker, _Control);
DECLARE_PROPERTY("year", GetPropertyYear, SetPropertyYear);
virtual void OnFontChanged(Tizen::Graphics::Font* pFont);
virtual void OnFontInfoRequested(unsigned long& style, float& size);
+
+ virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
+ virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo);
+ virtual void OnDrawFocus(void);
+ bool OnFocusGained(const _Control& source);
+ bool OnFocusLost(const _Control& source);
+
+ virtual void OnSettingChanged(Tizen::Base::String& key);
+
Tizen::Graphics::Font* GetDateTimeFont(void);
result InitializeFont(void);
Tizen::Ui::Animations::_VisualElement* __pDisplayVisualElement;
Tizen::Base::Collection::LinkedListT<Tizen::Ui::_AccessibilityElement*> __accessibilityElements;
+
}; // _DateTimePicker
}}} // Tizen::Ui::Controls
result SetFont(Tizen::Graphics::Font* pFont);
+ void UpdateLocaleDateTimeFormat(void);
+
+ void UpdateTimeFormat(void);
+
virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation);
virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId);
+ virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
+ virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo);
+ result DrawFocus(void);
+ result ReleaseFocus(void);
+
private:
void UpdateDateTimeOutputConfig(void);
void ChangeFocusBox(void);
- int GetLocaleDateFormat(void) const;
-
void SetAccessibilityElementText(void);
+ void HandleInputPadValueChange(int inputPadReturnValue);
+
+ void HandleSaveCancelAction(int actionId);
+
private:
_DateTimePresenter(const _DateTimePresenter&);
bool __is24HourNotation;
+ bool __dtp24HourSet;
+
bool __isPm;
bool __isPmButtonPressed;
_DateTimeDisplayBox* __pDisplayBox[DATETIME_ID_MAX];
_DateTimeDisplayBox* __pPmBox;
+
+ bool __keypadEnabled;
}; // _DateTimePresenter
}}} // Tizen::Ui::Controls
int CalculateMaxDay(int displayYear, int month) const ;
bool IsLeapYear(int year) const;
void GetAmPm(Tizen::Base::String& timeFormat, _AmPmType amPmType) const;
+ int GetLocaleDateFormat(void) const;
private:
_DateTimeUtils(const _DateTimeUtils&);
_DateTimeUtils& operator =(const _DateTimeUtils&);
+ static const int LOCALE_DATE_FORMAT_STRING_LENGTH = 8;
+
};
}}} // Tizen::Ui::Controls
virtual void OnFontChanged(Tizen::Graphics::Font* pFont);
virtual void OnFontInfoRequested(unsigned long& style, float& size);
virtual void OnSettingChanged(Tizen::Base::String& key);
+
+ virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
+
+ virtual bool OnFocusGained(const _Control& source);
+ virtual bool OnFocusLost(const _Control& source);
+ virtual void OnDrawFocus(void);
+
Tizen::Graphics::FloatRectangle GetParentWindowBounds(void) const;
void SetXmlBoundsExist(bool isXmlBoundsExist);
result Initialize(void);
result Draw(void);
+ result DrawFocus(void);
+ void UpdateLastSelectedValue(_DateTimeId id, bool isTouchPressed);
_DateTimeId GetLastSelectedId(void) const;
void SetLastSelectedId(_DateTimeId boxId);
Tizen::Graphics::FloatRectangle GetDateAreaBounds(_DateTimeId id) const;
Tizen::Graphics::FloatRectangle GetTitleBounds(void) const;
- int GetLocaleDateFormat(void) const;
- void Animate(void);
+ void Animate(void);
virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
virtual void OnTouchMoveHandled(const Tizen::Ui::_Control& control);
void OnFontChanged(Tizen::Graphics::Font* pFont);
void OnFontInfoRequested(unsigned long& style, float& size);
+ void SetFocusState(bool isFocused);
+ void SetFocusedElement(void);
+ virtual bool OnFocusLost(const _Control& source);
+ virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
+
virtual void OnVisualElementAnimationFinished (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target, bool completedNormally);
virtual void OnVisualElementAnimationRepeated (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target, long currentRepeatCount){}
bool __isEditDateInitialized;
float __elementWidth;
static const int __dividerCount = 2;
+ static const float __adjustFocusHeight = 8.0f;
+ _FocusType __focusStatus;
+ bool __isEnterKeyPressed;
+ bool __isFocused;
}; // _EditDatePresenter
}}} // Tizen::Ui::Controls
void OnFontChanged(Tizen::Graphics::Font* pFont);
void OnFontInfoRequested(unsigned long& style, float& size);
virtual void OnSettingChanged(Tizen::Base::String& key);
+
+ virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
+ bool OnFocusGained(const _Control& source);
+ bool OnFocusLost(const _Control& source);
+ virtual void OnDrawFocus(void);
+
Tizen::Graphics::FloatRectangle GetParentWindowBounds(void) const;
void SetXmlBoundsExist(bool isXmlBoundsExist);
result Draw(void);
void Animate(void);
+ void SetFocusedElement(void);
+ void SetFocusState(bool isFocused);
+ bool OnFocusLost(const _Control& source);
+ bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
+
virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
void OnFontInfoRequested(unsigned long& style, float& size);
result Initialize(void);
void UpdateTimeFormat(void);
+ void UpdateLastSelectedValue(_DateTimeId boxId, bool __isTouchPressed);
virtual void OnVisualElementAnimationFinished (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target, bool completedNormally);
virtual void OnVisualElementAnimationRepeated (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target, long currentRepeatCount){}
virtual void OnVisualElementAnimationStarted (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target){}
+ result DrawFocus(void);
+
private:
_EditTimePresenter(const _EditTimePresenter&);
Tizen::Graphics::Bitmap* __pContentBgEffectNormalBitmap;
Tizen::Graphics::Bitmap* __pContentBgEffectPressedBitmap;
Tizen::Graphics::Bitmap* __pContentBgEffectDisabledBitmap;
+ Tizen::Graphics::Bitmap* __pfocusBitmap;
Tizen::Ui::Animations::VisualElement* __pContentProvider;
Tizen::Graphics::_Text::TextObject __textObject;
float __timeFontSize;
bool __isAnimating;
bool __isEditTimeInitialized;
+ _FocusType __focusStatus;
+ bool __isEnterKeyPressed;
+ bool __isFocused;
+ static const float __adjustFocusHeight = 8.0f;
}; // _EditTimePresenter
}}} // Tizen::Ui::Controls