// Open Service Platform
// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
//
-// Licensed under the Flora License, Version 1.0 (the License);
+// Licensed under the Apache License, Version 2.0 (the License);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
-// http://floralicense.org/license/
+// 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.
, __pTimeChangeEvent(null)
, __pDateTimeBar(null)
, __absoluteBounds(FloatRectangle())
+ , __previousSize(0.0f, 0.0f)
, __title()
, __pAccessibilityEditTimeElement(null)
, __pAccessibilityHourElement(null)
, __pAccessibilityMinuteElement(null)
, __pAccessibilityAmPmElement(null)
+ , __isCalledBoundsChanged(false)
+ , __isXmlBoundsExist(false)
{
}
}
pEditTime->AcquireHandle();
+ pEditTime->SetTouchPressThreshold(_TOUCH_PRESS_THRESHOLD_INSENSITIVE);
return pEditTime;
r = SettingInfo::AddSettingEventListener(*this);
SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ GET_SHAPE_CONFIG(EDITTIME::WIDTH, GetOrientation(), __previousSize.width);
+ GET_SHAPE_CONFIG(EDITTIME::HEIGHT, GetOrientation(), __previousSize.height);
+
return r;
CATCH:
void
_EditTime::OnDraw(void)
{
- if (GetDateTimeBar() != null && GetDateTimeBar()->IsActivated())
+ if (GetDateTimeBar() != null)
{
- CalculateDateTimeBarPosition();
+ FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
+
+ if (absoluteBounds.y != __absoluteBounds.y || absoluteBounds.height != __absoluteBounds.height)
+ {
+ CalculateDateTimeBarPosition();
+ }
}
__pEditTimePresenter->Draw();
- UpdateAccessibilityElement();
+ if (unlikely((_AccessibilityManager::IsActivated())))
+ {
+ UpdateAccessibilityElement();
+ }
+
return;
}
if (__pAccessibilityEditTimeElement == null)
{
__pAccessibilityEditTimeElement = new _AccessibilityElement(true);
- __pAccessibilityEditTimeElement->SetBounds(GetClientBounds());
+ __pAccessibilityEditTimeElement->SetBounds(GetClientBoundsF());
__pAccessibilityEditTimeElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
__pAccessibilityEditTimeElement->SetName(L"EditTimeText");
pContainer->AddElement(*__pAccessibilityEditTimeElement);
__pAccessibilityAmPmElement->SetBounds(ampmBounds);
__pAccessibilityAmPmElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON);
pContainer->AddElement(*__pAccessibilityAmPmElement);
+
+ __pAccessibilityHourElement->SetBounds(FloatRectangle(hourBounds.x, ampmBounds.y, hourBounds.width, ampmBounds.height));
+ __pAccessibilityMinuteElement->SetBounds(FloatRectangle(minuteBounds.x, ampmBounds.y, minuteBounds.width, ampmBounds.height));
}
}
}
void
_EditTime::OnBoundsChanged(void)
{
- __pEditTimePresenter->Initialize();
+ FloatDimension newSize = GetSizeF();
- if (__pAccessibilityEditTimeElement)
- {
- __pAccessibilityEditTimeElement->SetBounds(__pEditTimePresenter->GetTitleBounds());
- }
- if (__pAccessibilityHourElement)
+ if (newSize.width != __previousSize.width || newSize.height != __previousSize.height)
{
- __pAccessibilityHourElement->SetBounds(__pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR));
- }
- if (__pAccessibilityMinuteElement)
- {
- __pAccessibilityMinuteElement->SetBounds(__pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE));
+ __isCalledBoundsChanged = true;
}
+
+ __pEditTimePresenter->Initialize();
+
+ SysTryReturnVoidResult(NID_UI_CTRL, (__pAccessibilityEditTimeElement != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. EditTime accessibility element must not be null.");
+ SysTryReturnVoidResult(NID_UI_CTRL, (__pAccessibilityHourElement != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Hour accessibility element must not be null.");
+ SysTryReturnVoidResult(NID_UI_CTRL, (__pAccessibilityMinuteElement != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Minute accessibility element must not be null.");
+
+ __pAccessibilityEditTimeElement->SetBounds(GetClientBoundsF());
+
+ FloatRectangle hourBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
+ FloatRectangle minuteBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
+ FloatRectangle ampmBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
+
+ __pAccessibilityHourElement->SetBounds(hourBounds);
+ __pAccessibilityMinuteElement->SetBounds(minuteBounds);
+
if (__pAccessibilityAmPmElement)
{
- __pAccessibilityAmPmElement->SetBounds(__pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM));
+ __pAccessibilityHourElement->SetBounds(FloatRectangle(hourBounds.x, ampmBounds.y, hourBounds.width, ampmBounds.height));
+ __pAccessibilityMinuteElement->SetBounds(FloatRectangle(minuteBounds.x, ampmBounds.y, minuteBounds.width, ampmBounds.height));
+ __pAccessibilityAmPmElement->SetBounds(ampmBounds);
}
return;
void
_EditTime::OnChangeLayout(_ControlOrientation orientation)
{
- FloatDimension dim;
+ if (!__isCalledBoundsChanged && !__isXmlBoundsExist)
+ {
+ FloatRectangle bounds = GetBoundsF();
- GET_SHAPE_CONFIG(EDITTIME::WIDTH, GetOrientation(), dim.width);
- GET_SHAPE_CONFIG(EDITTIME::HEIGHT, GetOrientation(), dim.height);
+ GET_SHAPE_CONFIG(EDITTIME::WIDTH, GetOrientation(), bounds.width);
+ GET_SHAPE_CONFIG(EDITTIME::HEIGHT, GetOrientation(), bounds.height);
- SetSize(dim);
+ SetBounds(bounds, false);
+ }
__pEditTimePresenter->Initialize();
__pEditTimePresenter->SetLastSelectedId(DATETIME_ID_NONE);
bool
_EditTime::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
{
- SetFocused(true);
+ FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
+ if (absoluteBounds.y != __absoluteBounds.y || absoluteBounds.height != __absoluteBounds.height)
+ {
+ CalculateDateTimeBarPosition();
+ }
return __pEditTimePresenter->OnTouchPressed(source, touchinfo);
}
bool
_EditTime::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
{
- FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
-
- if (absoluteBounds.y != __absoluteBounds.y || absoluteBounds.height != __absoluteBounds.height)
- {
- CalculateDateTimeBarPosition();
- }
-
return __pEditTimePresenter->OnTouchReleased(source, touchinfo);
}
if (key.Equals(L"http://tizen.org/setting/locale.time.format.24hour", false))
{
__pEditTimePresenter->UpdateTimeFormat();
+ __pEditTimePresenter->SetLastSelectedId(DATETIME_ID_NONE);
+
+ if (GetDateTimeBar() != null)
+ {
+ GetDateTimeBar()->SetVisibleState(false);
+ GetDateTimeBar()->Close();
+ }
+
Invalidate();
}
return;
}
+void
+_EditTime::OnDrawFocus(void)
+{
+ __pEditTimePresenter->SetFocusState(true);
+ __pEditTimePresenter->SetFocusedElement();
+ __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);
+}
+
+void
+_EditTime::OnFocusModeStateChanged(void)
+{
+ __pEditTimePresenter->OnFocusModeStateChanged();
+ return;
+}
+
FloatRectangle
_EditTime::GetParentWindowBounds(void) const
{
}
void
+_EditTime::SetXmlBoundsExist(bool isXmlBoundsExist)
+{
+ __isXmlBoundsExist = isXmlBoundsExist;
+}
+
+void
_EditTime::UpdateAccessibilityElement(void)
{
- String string;
- if (likely(!(_AccessibilityManager::IsActivated())))
- {
- return;
- }
+ String string;
- if (__pAccessibilityEditTimeElement == null && __pAccessibilityHourElement == null
- && __pAccessibilityMinuteElement == null && __pAccessibilityAmPmElement == null)
- {
- return;
- }
+ SysTryReturnVoidResult(NID_UI_CTRL, (__pAccessibilityEditTimeElement != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. EditTime accessibility element must not be null.");
+ SysTryReturnVoidResult(NID_UI_CTRL, (__pAccessibilityHourElement != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Hour accessibility element must not be null.");
+ SysTryReturnVoidResult(NID_UI_CTRL, (__pAccessibilityMinuteElement != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Minute accessibility element must not be null.");
if (__title.IsEmpty() == false)
{
string.Append(GetMinute());
string.Append(L" ");
+ FloatRectangle hourBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR);
+ FloatRectangle minuteBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE);
+ FloatRectangle ampmBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM);
+
if (Is24HourNotationEnabled() == false)
{
- String hintAmPmText(L"Double tap to change to ");
+ _AccessibilityContainer* pContainer = GetAccessibilityContainer();
+ SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+ if (__pAccessibilityAmPmElement == null)
+ {
+ __pAccessibilityAmPmElement = new (std::nothrow) _AccessibilityElement(true);
+ SysTryReturnVoidResult(NID_UI_CTRL, (__pAccessibilityAmPmElement != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+ __pAccessibilityAmPmElement->SetBounds(ampmBounds);
+ __pAccessibilityAmPmElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON);
+ pContainer->AddElement(*__pAccessibilityAmPmElement);
+
+ __pAccessibilityHourElement->SetBounds(FloatRectangle(hourBounds.x, ampmBounds.y, hourBounds.width, ampmBounds.height));
+ __pAccessibilityMinuteElement->SetBounds(FloatRectangle(minuteBounds.x, ampmBounds.y, minuteBounds.width, ampmBounds.height));
+ }
+ else
+ {
+ __pAccessibilityAmPmElement->Activate(true);
+ }
+
+ String hintAmPmText(L"Double tap to edit");
String amString;
String pmString;
if (__pEditTimePresenter->GetAmEnabled() == true)
{
__pAccessibilityAmPmElement->SetLabel(amString);
- hintAmPmText.Append(pmString.GetPointer());
string.Append(amString.GetPointer());
}
else
{
__pAccessibilityAmPmElement->SetLabel(pmString);
- hintAmPmText.Append(amString.GetPointer());
string.Append(pmString.GetPointer());
}
__pAccessibilityAmPmElement->SetHint(hintAmPmText);
}
+ else if (__pAccessibilityAmPmElement != null)
+ {
+ __pAccessibilityAmPmElement->Activate(false);
+ }
__pAccessibilityEditTimeElement->SetLabel(string);
}
bool
-_EditTime::OnAccessibilityReadedElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
+_EditTime::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
{
return false;
}