Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_Keypad.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
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.
16 //
17
18 /**
19 * @file                 FUiCtrl_Keypad.cpp
20 * @brief                This file contains implementation of _Keypad class
21 *
22 * This file contains implementation of _Keypad class.
23 */
24
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"
45
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;
53
54 namespace Tizen { namespace Ui { namespace Controls
55 {
56 const int COMMAND_DONE_BUTTON_ID = 100;
57 const int COMMAND_CANCEL_BUTTON_ID = 101;
58 const int FOOTER_BACK_BUTTON_ID = 102;
59
60 IMPLEMENT_PROPERTY(_Keypad);
61
62 _Keypad::_Keypad(void)
63         : __isFirstCall(true)
64         , __isInitialized(false)
65         , __isSingleLineEnabled(false)
66         , __pIndicator(null)
67         , __pCallerEdit(null)
68         , __pChildEdit(null)
69         , __pFooter(null)
70         , __text()
71         , __pTextEvent(null)
72         , __isCommandButtonPressed(false)
73         , __isPredictionWindowOpendInUSBMode(false)
74 {
75         _AccessibilityContainer* pAccessibilityContainer = GetAccessibilityContainer();
76         if(pAccessibilityContainer)
77         {
78                 pAccessibilityContainer->Activate(true);
79         }
80
81         _ControlManager::GetInstance()->SetClipboardOwner(this);
82 }
83
84 _Keypad::~_Keypad(void)
85 {
86         _ControlManager::GetInstance()->SetClipboardOwner(null);
87
88         Dispose();
89 }
90
91 _Keypad*
92 _Keypad::CreateKeypadN(void)
93 {
94         ClearLastResult();
95
96         FloatDimension screenSize = _ControlManager::GetInstance()->GetScreenSizeF();
97
98         FloatRectangle portBounds(0.0f, 0.0f, screenSize.width, screenSize.height);
99         FloatRectangle landBounds(0.0f, 0.0f, screenSize.width, screenSize.height);
100         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
101
102         _Keypad* pKeypad = new (std::nothrow) _Keypad;
103         result r = GetLastResult();
104         SysTryCatch(NID_UI_CTRL, pKeypad, , r, "[%s] Propagating.", GetErrorMessage(r));
105         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
106
107         r = pKeypad->CreateRootVisualElement(_WINDOW_TYPE_SUB);
108
109         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
110
111         pEcoreEvas->SetWindowRotationBounds(*pKeypad, 0, portBounds);
112         pEcoreEvas->SetWindowRotationBounds(*pKeypad, 180, portBounds);
113         pEcoreEvas->SetWindowRotationBounds(*pKeypad, 90, landBounds);
114         pEcoreEvas->SetWindowRotationBounds(*pKeypad, 270, landBounds);
115
116         pKeypad->AcquireHandle();
117
118         return pKeypad;
119
120 CATCH:
121         delete pKeypad;
122
123         return null;
124 }
125
126 result
127 _Keypad::Initialize(int editStyle, _KeypadStyleInfo keypadStyleInfo, int limitLength, _Edit* pCallerEdit)
128 {
129         result r = E_SUCCESS;
130         bool UsbKeyboardConnected = false;
131
132         _ControlManager* pControlManager = _ControlManager::GetInstance();
133         SysTryReturnResult(NID_UI_CTRL, pControlManager, E_SYSTEM, "Failed to get root.");
134
135         if (GetOwner() == null)
136         {
137                 _Frame* pFrame = dynamic_cast <_Frame*>(pControlManager->GetCurrentFrame());
138                 SysTryReturn(NID_UI_CTRL, pFrame != null, E_SYSTEM,
139                                         E_SYSTEM, "[E_SYSTEM] This instance is not constructed.");
140
141                 _Form* pForm = pFrame->GetCurrentForm();
142
143                 if (pForm)
144                 {
145                         SetOwner(pForm);
146                 }
147                 else
148                 {
149                         SetOwner(pFrame);
150                 }
151         }
152
153         __pFooter = CreateFooter();
154
155         if (!__pFooter)
156         {
157                 SysTryReturnResult(NID_UI_CTRL, __pFooter, GetLastResult(), "Unable to create Footer");
158         }
159
160         if (pCallerEdit)
161         {
162                 __pCallerEdit = pCallerEdit;
163         }
164         else
165         {
166                 __pCallerEdit = null;
167         }
168
169         if ( __pChildEdit == null)
170         {
171                 __pChildEdit = _Edit::CreateEditN();
172                 SysTryCatch(NID_UI_CTRL, __pChildEdit, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "Unable to create Edit");
173
174                 String doneText;
175                 String cancelText;
176                 _AccessibilityContainer* pAccessibilityContainer = null;
177                 Variant variantKeypadStyle = (int)keypadStyleInfo.keypadStyle;
178
179                 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_DONE, doneText);
180                 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_CANCEL_ABB, cancelText);
181
182                 __pChildEdit->SetFullScreenKeypadEdit(true);
183
184                 r = __pChildEdit->Initialize(editStyle, INPUT_STYLE_OVERLAY, limitLength);
185                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
186
187                 __pChildEdit->SetTextPredictionEnabled(keypadStyleInfo.textPredictionEnabled);
188                 __pChildEdit->SetKeypadNormalNumberStyle(keypadStyleInfo.isNormalNumberStyle);
189                 __pChildEdit->SetPropertyKeypadStyle(variantKeypadStyle);
190
191                 if (!keypadStyleInfo.enterActionEnabled)//EditField Style
192                 {
193                         __pChildEdit->SetKeypadActionEnabled(false);
194                 }
195
196                 __pChildEdit->SetLowerCaseModeEnabled(keypadStyleInfo.isLowerCaseModeEnabled);
197
198                 r = __pChildEdit->SetKeypadCommandButtonVisible(false);
199                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
200
201                 __pChildEdit->AddKeypadEventListener(*this);
202
203                 r = AttachChild(*__pChildEdit);
204                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
205
206                 pAccessibilityContainer = GetAccessibilityContainer();
207                 if (pAccessibilityContainer)
208                 {
209                         _AccessibilityContainer* pAccessibilityEdit = __pChildEdit->GetAccessibilityContainer();
210                         if (pAccessibilityEdit)
211                         {
212                                 pAccessibilityContainer->AddChildContainer(*pAccessibilityEdit);
213                         }
214                 }
215
216                 if (__pCallerEdit)
217                 {
218                         if (editStyle & EDIT_STYLE_PASSWORD)
219                         {
220                                 __pChildEdit->SetPasswordVisible(__pCallerEdit->IsPasswordVisible());
221                         }
222                 }
223         }
224
225         SetClipChildrenEnabled(false);
226
227         if (!__pIndicator)
228         {
229                 __pIndicator = _Indicator::CreateIndicator();
230                 SysTryCatch(NID_UI_CTRL, __pIndicator, , GetLastResult(), "Unable to create Indicator");
231
232                 _VisualElement* pKeypadVisualElement = GetVisualElement();
233                 pKeypadVisualElement->AttachChild(*__pIndicator);
234
235                 _VisualElementImpl* pImpl = _VisualElementImpl::GetInstance(*__pIndicator);
236                 r = pImpl->SetZOrderGroup(_ControlVisualElement::Z_ORDER_GROUP_CONTROL + 4);
237
238                 float indicatorwidth = 0.0f;
239                 float indicatorheight = 0.0f;
240
241                 if (GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
242                 {
243                         indicatorwidth = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF().width;
244                         GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorheight);
245                 }
246                 else
247                 {
248                         indicatorwidth = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF().height;
249                         GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorheight);
250                 }
251
252                 __pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, indicatorwidth, indicatorheight));
253                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
254         }
255
256         UsbKeyboardConnected = __pChildEdit->IsUsbKeyboardConnected();
257
258         r = ChangeLayoutInternal(LAYOUT_CHANGE_NONE);
259         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
260
261         __pChildEdit->SetVisibleState(true);
262
263         __isInitialized = true;
264
265         r = _SettingInfoImpl::AddSettingEventListenerForInternal(*this);
266         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
267
268         return r;
269
270 CATCH:
271         Dispose();
272         return r;
273 }
274
275 result
276 _Keypad::Dispose(void)
277 {
278         result r = E_SUCCESS;
279         if (__pFooter)
280         {
281                 DetachChild(*__pFooter);
282                 delete __pFooter;
283                 __pFooter = null;
284         }
285         if (__pChildEdit)
286         {
287                 DetachChild(*__pChildEdit);
288                 delete __pChildEdit;
289                 __pChildEdit = null;
290         }
291         __pCallerEdit = null;
292
293         if (__pTextEvent)
294         {
295                 delete __pTextEvent;
296                 __pTextEvent = null;
297         }
298
299         if (__pIndicator)
300         {
301                 _VisualElement* pKeypadVisualElement = GetVisualElement();
302                 pKeypadVisualElement->DetachChild(*__pIndicator);
303                 delete __pIndicator;
304                 __pIndicator = null;
305         }
306
307         _SettingInfoImpl::RemoveSettingEventListenerForInternal(*this);
308
309         return r;
310 }
311
312 _Toolbar*
313 _Keypad::CreateFooter(void)
314 {
315         result r = E_SUCCESS;
316
317         _Toolbar* pFooter = null;
318
319         if (!__pFooter)
320         {
321                 _ControlManager* pControlManager = _ControlManager::GetInstance();
322                 SysTryReturn(NID_UI_CTRL, pControlManager, null, E_SYSTEM, "Fail to get ControlManager instance");
323
324                 _Frame* pFrame = dynamic_cast <_Frame*>(pControlManager->GetCurrentFrame());
325                 SysTryReturn(NID_UI_CTRL, pFrame, null, E_SYSTEM, "This instance is not constructed.");
326
327                 String doneText;
328
329                 FloatRectangle bounds(0.0f,0.0f,0.0f,0.0f);
330
331                 FloatDimension screenSize = pControlManager->GetScreenSizeF();
332
333                 pFooter = _Toolbar::CreateToolbarN(false);
334                 SysTryReturn(NID_UI_CTRL, pFooter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance.");
335
336                 r = pFooter->Construct();
337                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
338
339                 r = pFooter->SetStyle(TOOLBAR_TEXT);
340                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
341
342                 pFooter->SetResizable(true);
343                 pFooter->SetMovable(true);
344
345                 _ControlOrientation orientation = GetOrientation();
346
347                 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
348                 {
349                         bounds.width = screenSize.width;
350                 }
351                 else
352                 {
353                         bounds.width = screenSize.height;
354                 }
355
356                 float height = 0.0f;
357                 GET_SHAPE_CONFIG(FOOTER::HEIGHT, orientation, height);
358                 bounds.height = height;
359
360                 r = pFooter->SetBounds(bounds);
361                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
362
363                 pFooter->SetResizable(false);
364                 pFooter->SetMovable(false);
365
366                 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_DONE, doneText);
367
368                 r = pFooter->AddItem(CreateButtonItemN(COMMAND_DONE_BUTTON_ID, doneText));
369                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
370
371                 pFooter->AddActionEventListener(*this);
372
373                 r = AttachChild(*pFooter);
374                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
375
376                 return pFooter;
377
378         }
379         else
380         {
381                 return __pFooter;
382         }
383
384 CATCH:
385         delete pFooter;
386         return null;
387 }
388
389 _Button*
390 _Keypad::CreateButtonItemN(int actionId, const String& text)
391 {
392         result r = E_SUCCESS;
393         _Button* pButton = _Button::CreateButtonN();
394         SysTryReturn(NID_UI_CTRL, pButton, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance.");
395
396         r = pButton->SetActionId(actionId);
397         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
398
399         r = pButton->SetText(text);
400         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
401
402         return pButton;
403 CATCH:
404         delete pButton;
405
406         return null;
407 }
408
409 result
410 _Keypad::ChangeLayoutInternal(LayoutChangeState layoutChangeState)
411 {
412         result r = E_SUCCESS;
413         _ControlManager* pControlManager = _ControlManager::GetInstance();
414         SysTryReturnResult(NID_UI_CTRL, pControlManager, E_SYSTEM, "Failed to get root.");
415         FloatDimension screenSize = pControlManager->GetScreenSizeF();
416         _ControlOrientation orientation = GetOrientation();
417
418         _Frame* pFrame = dynamic_cast <_Frame*>(pControlManager->GetCurrentFrame());
419         SysTryReturn(NID_UI_CTRL, pFrame, null, E_SYSTEM, "This instance is not constructed.");
420
421         FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
422         FloatRectangle keypadRect(0.0f, 0.0f, 0.0f, 0.0f);
423         float indicatorHeight = 0.0f;
424         float clipboardHeight = 0.0f;
425         bool isKeypadExist = false;
426         bool isClipboardExist = false;
427
428         if (__isInitialized)
429         {
430                 isKeypadExist = __pChildEdit->CheckKeypadExist(orientation);
431                 isClipboardExist = __pChildEdit->IsClipboardExist();
432         }
433
434         if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
435         {
436                 bounds.width = screenSize.width;
437                 bounds.height = screenSize.height;
438         }
439         else
440         {
441                 bounds.width = screenSize.height;
442                 bounds.height = screenSize.width;
443         }
444
445         if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
446         {
447                 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorHeight);
448         }
449
450         SetResizable(true);
451         SetMovable(true);
452         r = SetBounds(bounds);
453         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
454         SetResizable(false);
455         SetMovable(false);
456
457         FloatRectangle editRect = bounds;
458
459         editRect.y = indicatorHeight;
460
461         float footerHeight = 0.0f;
462         GET_SHAPE_CONFIG(FOOTER::HEIGHT, orientation, footerHeight);
463
464         editRect.height -= indicatorHeight;
465         editRect.height -= footerHeight;
466
467         if ((isClipboardExist && layoutChangeState == LAYOUT_CHANGE_ROTATE))
468         {
469                 ;
470         }
471         else
472         {
473                 if ( isKeypadExist || isClipboardExist)
474                 {
475                         if (isKeypadExist)
476                         {
477                                 r = __pChildEdit->GetKeypadBounds(keypadRect);
478                                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
479                         }
480
481                         if (isClipboardExist)
482                         {
483                                 clipboardHeight = __pChildEdit->GetClipboardHeight();
484                         }
485
486                         if (clipboardHeight > keypadRect.height)
487                         {
488                                 editRect.height -= clipboardHeight;
489                         }
490                         else
491                         {
492                                 editRect.height -= keypadRect.height;
493                         }
494                 }
495         }
496
497         r = __pChildEdit->SetBounds(editRect);
498         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS,  r, r, "[%s] Propagating.", GetErrorMessage(r));
499
500         FloatRectangle footerBounds(0.0f, 0.0f, 0.0f, 0.0f);
501
502         footerBounds.y = editRect.height + indicatorHeight;
503         footerBounds.width = editRect.width;
504         footerBounds.height = footerHeight;
505
506         __pFooter->SetResizable(true);
507         __pFooter->SetMovable(true);
508
509         __pFooter->SetBounds(footerBounds);
510
511         __pFooter->SetResizable(false);
512         __pFooter->SetMovable(false);
513
514         SysLog(NID_UI_CTRL, "[FULLEDIT] ChangeLayoutInternal Draw FullScreen window- Footer position(%f, %f, %f, %f)", footerBounds.x, footerBounds.y, footerBounds.width, footerBounds.height);
515         Invalidate(true);
516
517         return r;
518 }
519
520 result
521 _Keypad::OnAttachedToMainTree(void)
522 {
523         result r = E_SUCCESS;
524
525         GetEcoreEvasMgr()->GetEcoreEvas()->SetOwner(*this, *GetOwner());//set owner to EcoreEvas for orientation set.
526
527         r = __pChildEdit->SetText(__text);
528         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
529
530         if (__pIndicator)
531         {
532                 __pIndicator->OnAttachedToMainTree();
533                 __pIndicator->AddIndicatorObject(this, GetRootWindow());
534                 __pIndicator->SetIndicatorShowState(true);
535                 __pIndicator->SetIndicatorAutoHide(false, true);
536         }
537
538         Invalidate(true);
539
540         return r;
541 }
542
543 result
544 _Keypad::OnDetachingFromMainTree(void)
545 {
546         if (__pIndicator)
547         {
548                 __pIndicator->DeleteIndicatorObject();
549         }
550
551         if (__pCallerEdit && !__pCallerEdit->IsInputEventEnabled())
552         {
553                 __pCallerEdit->UnlockInputEvent();
554         }
555
556         return _Window::OnDetachingFromMainTree();
557 }
558
559 void
560 _Keypad::OnNativeWindowActivated(void)
561 {
562         if (__isFirstCall && __pChildEdit)
563         {
564                 __pChildEdit->SetFocused();
565                 __isFirstCall = false;
566         }
567
568         return;
569 }
570
571 bool
572 _Keypad::IsRotationSynchronized(void) const
573 {
574         return true;
575 }
576
577 void
578 _Keypad::OnDraw(void)
579 {
580         Color backgroundColor;
581         GET_COLOR_CONFIG(EDIT::BG_NORMAL, backgroundColor);
582         SetBackgroundColor(backgroundColor);
583
584         return;
585 }
586
587 result
588 _Keypad::SetSingleLineEnabled(bool enabled)
589 {
590         SetProperty("singleLineEnabled", Variant(enabled));
591
592         return E_SUCCESS;
593 }
594
595 bool
596 _Keypad::IsSingleLineEnabled(void) const
597 {
598         Variant enabled = GetProperty("singleLineEnabled");
599
600         return enabled.ToBool();
601 }
602
603 result
604 _Keypad::SetPropertySingleLineEnabled(const Variant& enabled)
605 {
606         __isSingleLineEnabled = enabled.ToBool();
607
608         return E_SUCCESS;
609 }
610
611 Variant
612 _Keypad::GetPropertySingleLineEnabled(void) const
613 {
614         return Variant(__isSingleLineEnabled);
615 }
616
617 String
618 _Keypad::GetText(void) const
619 {
620         Variant text = GetProperty("text");
621
622         return text.ToString();
623 }
624
625 void
626 _Keypad::SetText(const String& text)
627 {
628         SetProperty("text", Variant(text));
629
630         return;
631 }
632
633 result
634 _Keypad::SetPropertyText(const Variant& text)
635 {
636         __text = text.ToString();
637
638         return E_SUCCESS;
639 }
640
641 Variant
642 _Keypad::GetPropertyText(void) const
643 {
644         return Variant(__text);
645 }
646
647 result
648 _Keypad::AddTextEventListener(const _ITextEventListener& listener)
649 {
650         if (__pTextEvent == null)
651         {
652                 __pTextEvent = _TextEvent::CreateInstanceN(*this);
653                 SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.\n");
654         }
655
656         return __pTextEvent->AddListener(listener);
657 }
658
659 result
660 _Keypad::RemoveTextEventListener(const _ITextEventListener& listener)
661 {
662         SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.");
663         __pTextEvent->RemoveListener(listener);
664
665         return E_SUCCESS;
666 }
667
668 void
669 _Keypad::SetEditTextFilter(IEditTextFilter* pFilter)
670 {
671         if (__pChildEdit)
672         {
673                 __pChildEdit->SetEditTextFilter(pFilter);
674         }
675
676         return;
677 }
678
679 void
680 _Keypad::SendOpaqueCommand (const Tizen::Base::String& command)
681 {
682         if (__pChildEdit)
683         {
684                 __pChildEdit->SendOpaqueCommand(command);
685         }
686
687         return;
688 }
689
690 bool
691 _Keypad::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
692 {
693         if (keyInfo.GetKeyCode() == _KEY_ESC || keyInfo.GetKeyCode() == _KEY_BACK)
694         {
695                 OnActionPerformed(source, FOOTER_BACK_BUTTON_ID);
696         }
697
698         return true;
699 }
700
701 void
702 _Keypad::OnActionPerformed(const _Control& source, int actionId)
703 {
704         bool isReCreationLock = false;
705         if ((actionId != COMMAND_DONE_BUTTON_ID) && (actionId != FOOTER_BACK_BUTTON_ID))
706         {
707                 return;
708         }
709
710         if (actionId == FOOTER_BACK_BUTTON_ID)
711         {
712                 if (__isPredictionWindowOpendInUSBMode == false)
713                 {
714                         if (__pChildEdit->IsKeypadExist() && __pChildEdit->IsClipboardExist())
715                         {
716                                 _SystemUtilImpl::GenerateKeyEvent(KEY_EVENT_TYPE_PRESSED, _KEY_BACK);
717                                 _SystemUtilImpl::GenerateKeyEvent(KEY_EVENT_TYPE_RELEASED, _KEY_BACK);
718                                 _SystemUtilImpl::SendKeyStopMessage();
719                                 return;
720                         }
721
722                         if (__pChildEdit->IsKeypadExist())
723                         {
724                                 _SystemUtilImpl::GenerateKeyEvent(KEY_EVENT_TYPE_PRESSED, _KEY_BACK);
725                                 _SystemUtilImpl::GenerateKeyEvent(KEY_EVENT_TYPE_RELEASED, _KEY_BACK);
726                                 return;
727                         }
728
729                         if (__pChildEdit->IsClipboardExist())
730                         {
731                                 _SystemUtilImpl::SendKeyStopMessage();
732                                 return;
733                         }
734                 }
735         }
736
737         __pChildEdit->HideKeypad();
738
739         if (__pCallerEdit)
740         {
741                 __pCallerEdit->SetKeypadEnabled(false);
742                 isReCreationLock = true;
743         }
744         Close();
745         if (isReCreationLock)
746         {
747                 __pCallerEdit->SetKeypadEnabled(true);
748         }
749
750         CoreTextEventStatus textEventStatus = CORE_TEXT_EVENT_CHANGED;
751         if (actionId == COMMAND_DONE_BUTTON_ID)
752         {
753                 __text = __pChildEdit->GetText();
754                 textEventStatus = CORE_TEXT_EVENT_CHANGED;
755         }
756         else
757         {
758                 textEventStatus = CORE_TEXT_EVENT_CANCELED;
759         }
760
761         __isCommandButtonPressed = true;
762
763         if (__pCallerEdit)
764         {
765                 __pCallerEdit->SetText(__text);
766                 _Control* pParent = __pCallerEdit->GetParent();
767                 if (pParent)
768                 {
769                         pParent->Invalidate(true);
770                 }
771
772                 __pCallerEdit->SendTextEvent(textEventStatus);
773         }
774         else
775         {
776                 GetOwner()->Invalidate(true);
777                 if (__pTextEvent)
778                 {
779                         IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(textEventStatus);
780                         if (pEventArg)
781                         {
782                                 __pTextEvent->Fire(*pEventArg);
783                         }
784                 }
785         }
786
787         return;
788 }
789
790 void
791 _Keypad::OnKeypadWillOpen(void)
792 {
793         SysLog(NID_UI_CTRL, "[FULLEDIT] OnKeypadWillOpen");
794         return;
795 }
796
797 void
798 _Keypad::OnKeypadOpened(void)
799 {
800         if (__pChildEdit->IsUsbKeyboardConnected())
801         {
802                 __isPredictionWindowOpendInUSBMode = true;
803         }
804
805         SysLog(NID_UI_CTRL, "[FULLEDIT] OnKeypadOpened");
806
807         ChangeLayoutInternal(LAYOUT_CHANGE_KEYPAD_SHOW);//usb off & bounded or usb on & prediction
808
809         return;
810 }
811
812 void
813 _Keypad::OnKeypadClosed(void)
814 {
815         __isPredictionWindowOpendInUSBMode = false;
816
817         SysLog(NID_UI_CTRL, "[FULLEDIT] OnKeypadClosed");
818
819         ChangeLayoutInternal(LAYOUT_CHANGE_KEYPAD_HIDE);
820
821         return;
822 }
823
824 void
825 _Keypad::OnKeypadBoundsChanged(void)
826 {
827         SysLog(NID_UI_CTRL, "[FULLEDIT] OnKeypadBoundsChanged");
828
829         ChangeLayoutInternal(LAYOUT_CHANGE_KEYPAD_BOUNDS_CHANGED);// predictive window show/hide
830
831         return;
832 }
833
834 void
835 _Keypad::OnKeypadActionPerformed(CoreKeypadAction keypadAction)
836 {
837         return;
838 }
839
840 void
841 _Keypad::OnChangeLayout(_ControlOrientation orientation)
842 {
843         float indicatorheight = 0.0f;
844
845         const FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
846         const FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
847
848         if (__pIndicator)
849         {
850                 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
851                 {
852                         GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorheight);
853                         __pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, portraitSize.width, indicatorheight));
854                 }
855                 else
856                 {
857                         GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorheight);
858                         __pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, landscapeSize.width, indicatorheight));
859                 }
860
861                 __pIndicator->OnChangeLayout(orientation);
862         }
863
864         if (__isInitialized)
865         {
866                 ChangeLayoutInternal(LAYOUT_CHANGE_ROTATE);
867         }
868
869         return;
870 }
871
872 void
873 _Keypad::OnSettingChanged(String& key)
874 {
875         const wchar_t* LOCALE_LANGUAGE = L"http://tizen.org/setting/locale.language";
876         if (key == LOCALE_LANGUAGE)
877         {
878                 if (__pFooter)
879                 {
880                         _Button* pButton = __pFooter->GetItem(0);
881                         if (pButton)
882                         {
883                                 String doneText;
884                                 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_DONE, doneText);
885                                 pButton->SetText(doneText);
886                         }
887                 }
888         }
889 }
890
891 bool
892 _Keypad::IsLayoutChangable(void) const
893 {
894         return true;
895 }
896
897 } } } // Tizen::Ui::Controls