2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrl_Keypad.cpp
20 * @brief This file contains implementation of _Keypad class
22 * This file contains implementation of _Keypad class.
25 #include <FBaseSysLog.h>
26 #include <FSysSystemInfo.h>
27 #include <FGrp_BitmapImpl.h>
28 #include <FSys_SettingInfoImpl.h>
29 #include "FUi_AccessibilityContainer.h"
30 #include "FUi_AccessibilityElement.h"
31 #include "FUi_EcoreEvas.h"
32 #include "FUi_EcoreEvasMgr.h"
33 #include "FUi_CoordinateSystemUtils.h"
34 #include "FUi_SystemUtilImpl.h"
35 #include "FUiAnim_ControlVisualElement.h"
36 #include "FUiAnim_VisualElement.h"
37 #include "FUiAnim_VisualElementImpl.h"
38 #include "FUiCtrlForm.h"
39 #include "FUiCtrl_Indicator.h"
40 #include "FUiCtrl_Edit.h"
41 #include "FUiCtrl_Frame.h"
42 #include "FUiCtrl_Form.h"
43 #include "FUiCtrl_Keypad.h"
44 #include "FUiCtrl_Toolbar.h"
46 using namespace Tizen::Graphics;
47 using namespace Tizen::Base;
48 using namespace Tizen::Base::Runtime;
49 using namespace Tizen::Ui;
50 using namespace Tizen::Ui::Animations;
51 using namespace Tizen::Ui::Controls;
52 using namespace Tizen::System;
54 namespace Tizen { namespace Ui { namespace Controls
56 const int COMMAND_DONE_BUTTON_ID = 100;
57 const int COMMAND_CANCEL_BUTTON_ID = 101;
58 const int FOOTER_BACK_BUTTON_ID = 102;
60 IMPLEMENT_PROPERTY(_Keypad);
62 _Keypad::_Keypad(void)
63 : __isInitialized(false)
64 , __isSingleLineEnabled(false)
71 , __isCommandButtonPressed(false)
72 , __isPredictionWindowOpendInUSBMode(false)
74 _AccessibilityContainer* pAccessibilityContainer = GetAccessibilityContainer();
75 if(pAccessibilityContainer)
77 pAccessibilityContainer->Activate(true);
80 _ControlManager::GetInstance()->SetClipboardOwner(this);
83 _Keypad::~_Keypad(void)
85 _ControlManager::GetInstance()->SetClipboardOwner(null);
91 _Keypad::CreateKeypadN(void)
95 Dimension screenSize = _ControlManager::GetInstance()->GetScreenSize();
97 Rectangle portBounds(0, 0, screenSize.width, screenSize.height);
98 Rectangle landBounds(0, 0, screenSize.width, screenSize.height);
99 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
101 _Keypad* pKeypad = new (std::nothrow) _Keypad;
102 result r = GetLastResult();
103 SysTryCatch(NID_UI_CTRL, pKeypad, , r, "[%s] Propagating.", GetErrorMessage(r));
104 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
106 r = pKeypad->CreateRootVisualElement(_WINDOW_TYPE_SUB);
108 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
110 pEcoreEvas->SetWindowRotationBounds(*pKeypad, 0, portBounds);
111 pEcoreEvas->SetWindowRotationBounds(*pKeypad, 180, portBounds);
112 pEcoreEvas->SetWindowRotationBounds(*pKeypad, 90, landBounds);
113 pEcoreEvas->SetWindowRotationBounds(*pKeypad, 270, landBounds);
115 pKeypad->AcquireHandle();
126 _Keypad::Initialize(int editStyle, _KeypadStyleInfo keypadStyleInfo, int limitLength, _Edit* pCallerEdit)
128 result r = E_SUCCESS;
129 bool UsbKeyboardConnected = false;
131 _ControlManager* pControlManager = _ControlManager::GetInstance();
132 SysTryReturnResult(NID_UI_CTRL, pControlManager, E_SYSTEM, "Failed to get root.");
134 if (GetOwner() == null)
136 _Frame* pFrame = dynamic_cast <_Frame*>(pControlManager->GetCurrentFrame());
137 SysTryReturn(NID_UI_CTRL, pFrame != null, E_SYSTEM,
138 E_SYSTEM, "[E_SYSTEM] This instance is not constructed.");
140 _Form* pForm = pFrame->GetCurrentForm();
152 __pFooter = CreateFooter();
156 SysTryReturnResult(NID_UI_CTRL, __pFooter, GetLastResult(), "Unable to create Footer");
161 __pCallerEdit = pCallerEdit;
165 __pCallerEdit = null;
168 if ( __pChildEdit == null)
170 __pChildEdit = _Edit::CreateEditN();
171 SysTryCatch(NID_UI_CTRL, __pChildEdit, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "Unable to create Edit");
175 _AccessibilityContainer* pAccessibilityContainer = null;
177 GET_STRING_CONFIG(IDS_COM_SK_DONE, doneText);
178 GET_STRING_CONFIG(IDS_COM_SK_CANCEL, cancelText);
180 __pChildEdit->SetFullScreenKeypadEdit(true);
182 r = __pChildEdit->Initialize(editStyle, INPUT_STYLE_OVERLAY, limitLength);
183 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
185 __pChildEdit->SetTextPredictionEnabled(keypadStyleInfo.textPredictionEnabled);
186 __pChildEdit->SetKeypadNormalNumberStyle(keypadStyleInfo.isNormalNumberStyle);
187 __pChildEdit->SetKeypadStyle(keypadStyleInfo.keypadStyle);
188 if (!keypadStyleInfo.enterActionEnabled)//EditField Style
190 __pChildEdit->SetKeypadActionEnabled(false);
193 __pChildEdit->SetLowerCaseModeEnabled(keypadStyleInfo.isLowerCaseModeEnabled);
195 r = __pChildEdit->SetKeypadCommandButtonVisible(false);
196 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
198 __pChildEdit->AddKeypadEventListener(*this);
200 r = AttachChild(*__pChildEdit);
201 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
203 pAccessibilityContainer = GetAccessibilityContainer();
204 if (pAccessibilityContainer)
206 _AccessibilityContainer* pAccessibilityEdit = __pChildEdit->GetAccessibilityContainer();
207 if (pAccessibilityEdit)
209 pAccessibilityContainer->AddChildContainer(*pAccessibilityEdit);
214 SetClipChildrenEnabled(false);
218 __pIndicator = _Indicator::CreateIndicator();
219 SysTryCatch(NID_UI_CTRL, __pIndicator, , GetLastResult(), "Unable to create Indicator");
221 _VisualElement* pKeypadVisualElement = GetVisualElement();
222 pKeypadVisualElement->AttachChild(*__pIndicator);
224 _VisualElementImpl* pImpl = _VisualElementImpl::GetInstance(*__pIndicator);
225 r = pImpl->SetZOrderGroup(_ControlVisualElement::Z_ORDER_GROUP_CONTROL + 4);
227 float indicatorwidth = 0.0f;
228 float indicatorheight = 0.0f;
230 if (GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
232 indicatorwidth = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF().width;
233 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorheight);
237 indicatorwidth = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF().height;
238 GET_SHAPE_CONFIG(FORM::INDICATOR_MINIMIZE_HEIGHT, GetOrientation(), indicatorheight);
241 __pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, indicatorwidth, indicatorheight));
242 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
245 UsbKeyboardConnected = __pChildEdit->IsUsbKeyboardConnected();
247 r = ChangeLayoutInternal(LAYOUT_CHANGE_NONE);
248 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
250 __pChildEdit->SetVisibleState(true);
252 __isInitialized = true;
254 r = _SettingInfoImpl::AddSettingEventListenerForInternal(*this);
255 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
265 _Keypad::Dispose(void)
267 result r = E_SUCCESS;
270 DetachChild(*__pFooter);
276 DetachChild(*__pChildEdit);
280 __pCallerEdit = null;
290 _VisualElement* pKeypadVisualElement = GetVisualElement();
291 pKeypadVisualElement->DetachChild(*__pIndicator);
296 _SettingInfoImpl::RemoveSettingEventListenerForInternal(*this);
302 _Keypad::CreateFooter(void)
304 result r = E_SUCCESS;
306 _Toolbar* pFooter = null;
310 _ControlManager* pControlManager = _ControlManager::GetInstance();
311 SysTryReturn(NID_UI_CTRL, pControlManager, null, E_SYSTEM, "Fail to get ControlManager instance");
313 _Frame* pFrame = dynamic_cast <_Frame*>(pControlManager->GetCurrentFrame());
314 SysTryReturn(NID_UI_CTRL, pFrame, null, E_SYSTEM, "This instance is not constructed.");
318 FloatRectangle bounds(0.0f,0.0f,0.0f,0.0f);
320 FloatDimension screenSize = pControlManager->GetScreenSizeF();
322 pFooter = _Toolbar::CreateToolbarN(false);
323 SysTryReturn(NID_UI_CTRL, pFooter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance.");
325 r = pFooter->Construct();
326 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
328 r = pFooter->SetStyle(TOOLBAR_TEXT);
329 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
331 pFooter->SetResizable(true);
332 pFooter->SetMovable(true);
334 _ControlOrientation orientation = GetOrientation();
336 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
338 bounds.width = screenSize.width;
342 bounds.width = screenSize.height;
346 GET_SHAPE_CONFIG(FOOTER::HEIGHT, orientation, height);
347 bounds.height = height;
349 r = pFooter->SetBounds(bounds);
350 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
352 pFooter->SetResizable(false);
353 pFooter->SetMovable(false);
355 GET_STRING_CONFIG(IDS_COM_SK_DONE, doneText);
357 r = pFooter->AddItem(CreateButtonItemN(COMMAND_DONE_BUTTON_ID, doneText));
358 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
360 pFooter->AddActionEventListener(*this);
362 bool isHWBackButtonExist = false;
364 Tizen::System::SystemInfo::GetValue(L"http://tizen.org/feature/input.keys.back", isHWBackButtonExist);
366 if(!isHWBackButtonExist)
368 pFooter->SetBackEventListener(*this, FOOTER_BACK_BUTTON_ID);
369 pFooter->SetButton(BACK_BUTTON, CreateFooterBackButton(pFooter));
372 r = AttachChild(*pFooter);
373 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
389 _Keypad::CreateFooterBackButton(_Toolbar* pFooter)
391 _Button* pButton = _Button::CreateButtonN();
393 float buttonHeight = 0.0f;
394 float buttonWidth = 0.0f;
395 float iconSize = 0.0f;
397 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_HEIGHT, pFooter->GetOrientation(), buttonHeight);
398 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_WIDTH, pFooter->GetOrientation(), buttonWidth);
399 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_ICON_SIZE, pFooter->GetOrientation(), iconSize);
401 pButton->SetSize(FloatDimension(buttonWidth, buttonHeight));
403 Bitmap* pBackgroundNormalBitmap = null;
404 Bitmap* pBackgroundPressedBitmap = null;
405 Bitmap* pColorReplacedBitmap = null;
406 Bitmap* pBackIconNormalBitmap = null;
407 Bitmap* pBackIconNormalEffectBitmap = null;
409 GET_BITMAP_CONFIG_N(FOOTER::BUTTON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pBackgroundNormalBitmap);
410 GET_BITMAP_CONFIG_N(FOOTER::BUTTON_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pBackgroundPressedBitmap);
411 GET_BITMAP_CONFIG_N(FOOTER::BACK_ICON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pBackIconNormalBitmap);
412 GET_BITMAP_CONFIG_N(FOOTER::BACK_ICON_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pBackIconNormalEffectBitmap);
414 bool themeBackNormalBitmap = IS_CUSTOM_BITMAP(FOOTER::BACK_ICON_NORMAL);
415 if (!themeBackNormalBitmap)
417 GET_BITMAP_CONFIG_N(FOOTER::BACK_ICON_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pBackIconNormalEffectBitmap);
420 if (pBackgroundNormalBitmap)
422 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundNormalBitmap, Color::GetColor(COLOR_ID_MAGENTA),
423 pFooter->GetButtonColor(_BUTTON_STATUS_NORMAL));
424 pButton->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *pColorReplacedBitmap);
425 delete pColorReplacedBitmap;
427 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundNormalBitmap, Color::GetColor(COLOR_ID_MAGENTA),
428 pFooter->GetButtonColor(_BUTTON_STATUS_HIGHLIGHTED));
429 pButton->SetBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pColorReplacedBitmap);
430 delete pColorReplacedBitmap;
432 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundNormalBitmap, Color::GetColor(COLOR_ID_MAGENTA),
433 pFooter->GetButtonColor(_BUTTON_STATUS_DISABLED));
434 pButton->SetBackgroundBitmap(_BUTTON_STATUS_DISABLED, *pColorReplacedBitmap);
435 delete pColorReplacedBitmap;
437 delete pBackgroundNormalBitmap;
440 if (pBackgroundPressedBitmap)
442 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundPressedBitmap, Color::GetColor(COLOR_ID_MAGENTA),
443 pFooter->GetButtonColor(_BUTTON_STATUS_PRESSED));
444 pButton->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *pColorReplacedBitmap);
445 delete pColorReplacedBitmap;
447 delete pBackgroundPressedBitmap;
450 if (pBackIconNormalBitmap)
456 GET_COLOR_CONFIG(FOOTER::BACK_ICON_NORMAL, normalColor);
457 GET_COLOR_CONFIG(FOOTER::BACK_ICON_PRESSED, pressedColor);
458 GET_COLOR_CONFIG(FOOTER::BACK_ICON_DISABLED, disabledColor);
460 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBackIconNormalBitmap, Color::GetColor(COLOR_ID_MAGENTA), normalColor);
461 if (pColorReplacedBitmap)
463 pColorReplacedBitmap->Scale(FloatDimension(iconSize, iconSize));
465 pButton->SetBitmap(_BUTTON_STATUS_NORMAL, FloatPoint(0.0f, 0.0f), *pColorReplacedBitmap);
467 delete pColorReplacedBitmap;
470 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBackIconNormalBitmap, Color::GetColor(COLOR_ID_MAGENTA), pressedColor);
471 if (pColorReplacedBitmap)
473 pColorReplacedBitmap->Scale(FloatDimension(iconSize, iconSize));
475 pButton->SetBitmap(_BUTTON_STATUS_PRESSED, FloatPoint(0.0f, 0.0f), *pColorReplacedBitmap);
476 delete pColorReplacedBitmap;
479 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBackIconNormalBitmap, Color::GetColor(COLOR_ID_MAGENTA), disabledColor);
480 if (pColorReplacedBitmap)
482 pColorReplacedBitmap->Scale(FloatDimension(iconSize, iconSize));
484 pButton->SetBitmap(_BUTTON_STATUS_DISABLED, FloatPoint(0.0f, 0.0f), *pColorReplacedBitmap);
485 delete pColorReplacedBitmap;
488 delete pBackIconNormalBitmap;
491 if (pBackIconNormalEffectBitmap)
493 pButton->SetEffectBitmap(_BUTTON_STATUS_NORMAL, FloatPoint(0.0f, 0.0f), *pBackIconNormalEffectBitmap);
494 pButton->SetEffectBitmap(_BUTTON_STATUS_PRESSED, FloatPoint(0.0f, 0.0f), *pBackIconNormalEffectBitmap);
495 pButton->SetEffectBitmap(_BUTTON_STATUS_SELECTED, FloatPoint(0.0f, 0.0f), *pBackIconNormalEffectBitmap);
496 pButton->SetEffectBitmap(_BUTTON_STATUS_HIGHLIGHTED, FloatPoint(0.0f, 0.0f), *pBackIconNormalEffectBitmap);
497 pButton->SetEffectBitmap(_BUTTON_STATUS_DISABLED, FloatPoint(0.0f, 0.0f), *pBackIconNormalEffectBitmap);
499 delete pBackIconNormalEffectBitmap;
506 _Keypad::CreateButtonItemN(int actionId, const String& text)
508 result r = E_SUCCESS;
509 _Button* pButton = _Button::CreateButtonN();
510 SysTryReturn(NID_UI_CTRL, pButton, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance.");
512 r = pButton->SetActionId(actionId);
513 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
515 r = pButton->SetText(text);
516 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
526 _Keypad::ChangeLayoutInternal(LayoutChangeState layoutChangeState)
528 result r = E_SUCCESS;
529 _ControlManager* pControlManager = _ControlManager::GetInstance();
530 SysTryReturnResult(NID_UI_CTRL, pControlManager, E_SYSTEM, "Failed to get root.");
531 FloatDimension screenSize = pControlManager->GetScreenSizeF();
532 _ControlOrientation orientation = GetOrientation();
534 _Frame* pFrame = dynamic_cast <_Frame*>(pControlManager->GetCurrentFrame());
535 SysTryReturn(NID_UI_CTRL, pFrame, null, E_SYSTEM, "This instance is not constructed.");
537 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
538 FloatRectangle keypadRect(0.0f, 0.0f, 0.0f, 0.0f);
539 float indicatorHeight = 0.0f;
540 float clipboardHeight = 0.0f;
541 bool isKeypadExist = false;
542 bool isClipboardExist = false;
544 if (__isInitialized == true)
546 isKeypadExist = __pChildEdit->CheckKeypadExist(orientation);
547 isClipboardExist = __pChildEdit->IsClipboardExist();
550 if ((isClipboardExist && layoutChangeState == LAYOUT_CHANGE_ROTATE))
555 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
557 bounds.width = screenSize.width;
558 bounds.height = screenSize.height;
562 bounds.width = screenSize.height;
563 bounds.height = screenSize.width;
566 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
568 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorHeight);
572 GET_SHAPE_CONFIG(FORM::INDICATOR_MINIMIZE_HEIGHT, GetOrientation(), indicatorHeight);
577 r = SetBounds(bounds);
578 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
582 FloatRectangle editRect = bounds;
584 editRect.y = indicatorHeight;
586 float footerHeight = 0.0f;
587 GET_SHAPE_CONFIG(FOOTER::HEIGHT, orientation, footerHeight);
589 editRect.height -= indicatorHeight;
590 editRect.height -= footerHeight;
592 if ( isKeypadExist || isClipboardExist)
596 r = __pChildEdit->GetKeypadBounds(keypadRect);
597 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
600 if (isClipboardExist)
602 clipboardHeight = __pChildEdit->GetClipboardHeight();
605 if (clipboardHeight > keypadRect.height)
607 editRect.height -= clipboardHeight;
611 editRect.height -= keypadRect.height;
614 if (!__isPredictionWindowOpendInUSBMode)
616 __pFooter->SetHideButton(true);
621 __pFooter->SetHideButton(false);
624 r = __pChildEdit->SetBounds(editRect);
625 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
627 FloatRectangle footerBounds(0.0f, 0.0f, 0.0f, 0.0f);
629 footerBounds.y = editRect.height + indicatorHeight;
630 footerBounds.width = editRect.width;
631 footerBounds.height = footerHeight;
633 __pFooter->SetResizable(true);
634 __pFooter->SetMovable(true);
636 __pFooter->SetBounds(footerBounds);
638 __pFooter->SetResizable(false);
639 __pFooter->SetMovable(false);
641 SysLog(NID_UI_CTRL, "[FULLEDIT] ChangeLayoutInternal Draw FullScreen window- Footer position(%f, %f, %f, %f)", footerBounds.x, footerBounds.y, footerBounds.width, footerBounds.height);
648 _Keypad::OnAttachedToMainTree(void)
650 result r = E_SUCCESS;
652 GetEcoreEvasMgr()->GetEcoreEvas()->SetOwner(*this, *GetOwner());//set owner to EcoreEvas for orientation set.
654 r = __pChildEdit->SetText(__text);
655 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
659 __pIndicator->OnAttachedToMainTree();
660 __pIndicator->AddIndicatorObject(this, GetRootWindow());
661 __pIndicator->SetIndicatorShowState(true);
670 _Keypad::OnDetachingFromMainTree(void)
674 __pIndicator->DeleteIndicatorObject();
677 if (__pCallerEdit && !__pCallerEdit->IsInputEventEnabled())
679 __pCallerEdit->UnlockInputEvent();
682 return _Window::OnDetachingFromMainTree();
686 _Keypad::OnNativeWindowActivated(void)
688 __pChildEdit->SetFocused();
694 _Keypad::IsRotationSynchronized(void) const
700 _Keypad::OnDraw(void)
702 Canvas* pCanvas = GetCanvasN();
703 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, E_SYSTEM, "[E_SYSTEM] System error occurred.");
705 Color backgroundColor;
706 GET_COLOR_CONFIG(EDIT::BG_NORMAL, backgroundColor);
708 pCanvas->SetBackgroundColor(backgroundColor);
716 _Keypad::SetSingleLineEnabled(bool enabled)
718 SetProperty("singleLineEnabled", Variant(enabled));
724 _Keypad::IsSingleLineEnabled(void) const
726 Variant enabled = GetProperty("singleLineEnabled");
728 return enabled.ToBool();
732 _Keypad::SetPropertySingleLineEnabled(const Variant& enabled)
734 __isSingleLineEnabled = enabled.ToBool();
740 _Keypad::GetPropertySingleLineEnabled(void) const
742 return Variant(__isSingleLineEnabled);
746 _Keypad::GetText(void) const
748 Variant text = GetProperty("text");
750 return text.ToString();
754 _Keypad::SetText(const String& text)
756 SetProperty("text", Variant(text));
762 _Keypad::SetPropertyText(const Variant& text)
764 __text = text.ToString();
770 _Keypad::GetPropertyText(void) const
772 return Variant(__text);
776 _Keypad::AddTextEventListener(const _ITextEventListener& listener)
778 if (__pTextEvent == null)
780 __pTextEvent = _TextEvent::CreateInstanceN(*this);
781 SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.\n");
784 return __pTextEvent->AddListener(listener);
788 _Keypad::RemoveTextEventListener(const _ITextEventListener& listener)
790 SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.");
791 __pTextEvent->RemoveListener(listener);
797 _Keypad::SetEditTextFilter(IEditTextFilter* pFilter)
801 __pChildEdit->SetEditTextFilter(pFilter);
808 _Keypad::SendOpaqueCommand (const Tizen::Base::String& command)
812 __pChildEdit->SendOpaqueCommand(command);
819 _Keypad::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
821 if (keyInfo.GetKeyCode() == _KEY_ESC || keyInfo.GetKeyCode() == _KEY_BACK)
823 OnActionPerformed(source, FOOTER_BACK_BUTTON_ID);
830 _Keypad::OnActionPerformed(const _Control& source, int actionId)
832 bool isReCreationLock = false;
833 if ((actionId != COMMAND_DONE_BUTTON_ID) && (actionId != FOOTER_BACK_BUTTON_ID))
838 if (actionId == FOOTER_BACK_BUTTON_ID)
840 if (__isPredictionWindowOpendInUSBMode == false)
842 if (__pChildEdit->IsKeypadExist() && __pChildEdit->IsClipboardExist())
844 _SystemUtilImpl::GenerateKeyEvent(KEY_EVENT_TYPE_PRESSED, _KEY_BACK);
845 _SystemUtilImpl::GenerateKeyEvent(KEY_EVENT_TYPE_RELEASED, _KEY_BACK);
846 _SystemUtilImpl::SendKeyStopMessage();
850 if (__pChildEdit->IsKeypadExist())
852 _SystemUtilImpl::GenerateKeyEvent(KEY_EVENT_TYPE_PRESSED, _KEY_BACK);
853 _SystemUtilImpl::GenerateKeyEvent(KEY_EVENT_TYPE_RELEASED, _KEY_BACK);
857 if (__pChildEdit->IsClipboardExist())
859 _SystemUtilImpl::SendKeyStopMessage();
865 __pChildEdit->HideKeypad();
869 __pCallerEdit->SetKeypadEnabled(false);
870 isReCreationLock = true;
873 if (isReCreationLock)
875 __pCallerEdit->SetKeypadEnabled(true);
878 CoreTextEventStatus textEventStatus = CORE_TEXT_EVENT_CHANGED;
879 if (actionId == COMMAND_DONE_BUTTON_ID)
881 __text = __pChildEdit->GetText();
882 textEventStatus = CORE_TEXT_EVENT_CHANGED;
886 textEventStatus = CORE_TEXT_EVENT_CANCELED;
889 __isCommandButtonPressed = true;
893 __pCallerEdit->SetText(__text);
894 _Control* pParent = __pCallerEdit->GetParent();
897 pParent->Invalidate(true);
900 __pCallerEdit->SendTextEvent(textEventStatus);
904 GetOwner()->Invalidate(true);
907 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(textEventStatus);
910 __pTextEvent->Fire(*pEventArg);
919 _Keypad::OnKeypadWillOpen(void)
921 SysLog(NID_UI_CTRL, "[FULLEDIT] OnKeypadWillOpen");
926 _Keypad::OnKeypadOpened(void)
928 if (__pChildEdit->IsUsbKeyboardConnected())
930 __isPredictionWindowOpendInUSBMode = true;
933 SysLog(NID_UI_CTRL, "[FULLEDIT] OnKeypadOpened");
935 ChangeLayoutInternal(LAYOUT_CHANGE_KEYPAD_SHOW);//usb off & bounded or usb on & prediction
941 _Keypad::OnKeypadClosed(void)
943 __isPredictionWindowOpendInUSBMode = false;
945 SysLog(NID_UI_CTRL, "[FULLEDIT] OnKeypadClosed");
947 ChangeLayoutInternal(LAYOUT_CHANGE_KEYPAD_HIDE);
953 _Keypad::OnKeypadBoundsChanged(void)
955 SysLog(NID_UI_CTRL, "[FULLEDIT] OnKeypadBoundsChanged");
957 ChangeLayoutInternal(LAYOUT_CHANGE_KEYPAD_BOUNDS_CHANGED);// predictive window show/hide
963 _Keypad::OnKeypadActionPerformed(CoreKeypadAction keypadAction)
969 _Keypad::OnChangeLayout(_ControlOrientation orientation)
971 float indicatorheight = 0.0f;
973 const FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
974 const FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
978 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
980 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorheight);
981 __pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, portraitSize.width, indicatorheight));
985 GET_SHAPE_CONFIG(FORM::INDICATOR_MINIMIZE_HEIGHT, GetOrientation(), indicatorheight);
986 __pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, landscapeSize.width, indicatorheight));
989 __pIndicator->OnChangeLayout(orientation);
994 ChangeLayoutInternal(LAYOUT_CHANGE_ROTATE);
1001 _Keypad::OnSettingChanged(String& key)
1003 const wchar_t* LOCALE_LANGUAGE = L"http://tizen.org/setting/locale.language";
1004 if (key == LOCALE_LANGUAGE)
1008 _Button* pButton = __pFooter->GetItem(0);
1012 GET_STRING_CONFIG(IDS_COM_SK_DONE, doneText);
1013 pButton->SetText(doneText);
1020 _Keypad::IsLayoutChangable(void) const
1025 } } } // Tizen::Ui::Controls