add patch
[framework/osp/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         FloatDimension indicatorDimension(0.0f, 0.0f);
429         FloatDimension keypadDimsnsion(0.0f, 0.0f);
430
431         if (__isInitialized || __pChildEdit->IsUsbKeyboardConnected())
432         {
433                 isKeypadExist = __pChildEdit->CheckKeypadExist(orientation);
434                 isClipboardExist = __pChildEdit->IsClipboardExist();
435         }
436
437         if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
438         {
439                 bounds.width = screenSize.width;
440                 bounds.height = screenSize.height;
441         }
442         else
443         {
444                 bounds.width = screenSize.height;
445                 bounds.height = screenSize.width;
446         }
447
448         if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
449         {
450                 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorHeight);
451         }
452
453         indicatorDimension.height = indicatorHeight;
454
455         SetResizable(true);
456         SetMovable(true);
457         r = SetBounds(CoordinateSystem::AlignToDevice(bounds));
458         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
459         SetResizable(false);
460         SetMovable(false);
461
462         FloatRectangle editRect = CoordinateSystem::AlignToDevice(bounds);
463
464         editRect.y = CoordinateSystem::AlignToDevice(indicatorDimension).height;
465
466         float footerHeight = 0.0f;
467         FloatDimension footerDimension(0.0f, 0.0f);
468
469         GET_SHAPE_CONFIG(FOOTER::HEIGHT, orientation, footerHeight);
470         footerDimension.height = footerHeight;
471
472         editRect.height -= CoordinateSystem::AlignToDevice(indicatorDimension).height;
473         editRect.height -= CoordinateSystem::AlignToDevice(footerDimension).height;
474
475         if ((isClipboardExist && layoutChangeState == LAYOUT_CHANGE_ROTATE))
476         {
477                 ;
478         }
479         else
480         {
481                 if ( isKeypadExist || isClipboardExist)
482                 {
483                         if (isKeypadExist)
484                         {
485                                 r = __pChildEdit->GetKeypadBounds(keypadRect);
486                                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
487                         }
488
489                         if (isClipboardExist)
490                         {
491                                 clipboardHeight = __pChildEdit->GetClipboardHeight();
492                         }
493
494                         if (clipboardHeight > keypadRect.height)
495                         {
496                                 keypadDimsnsion.height = clipboardHeight;
497                         }
498                         else
499                         {
500                                 keypadDimsnsion.height = keypadRect.height;
501                         }
502
503                         editRect.height -= CoordinateSystem::AlignToDevice(keypadDimsnsion).height;
504                 }
505         }
506
507         r = __pChildEdit->SetBounds(editRect);
508         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS,  r, r, "[%s] Propagating.", GetErrorMessage(r));
509
510         FloatRectangle footerBounds(0.0f, 0.0f, 0.0f, 0.0f);
511
512         footerBounds.y = editRect.height + CoordinateSystem::AlignToDevice(indicatorDimension).height;
513         footerBounds.width = editRect.width;
514         footerBounds.height = CoordinateSystem::AlignToDevice(footerDimension).height;
515
516         __pFooter->SetResizable(true);
517         __pFooter->SetMovable(true);
518
519         __pFooter->SetBounds(footerBounds);
520
521         __pFooter->SetResizable(false);
522         __pFooter->SetMovable(false);
523
524         SysLog(NID_UI_CTRL, "[FULLEDIT] ChangeLayoutInternal Draw FullScreen window- Footer position(%f, %f, %f, %f)", footerBounds.x, footerBounds.y, footerBounds.width, footerBounds.height);
525         Invalidate(true);
526
527         return r;
528 }
529
530 result
531 _Keypad::OnAttachedToMainTree(void)
532 {
533         result r = E_SUCCESS;
534
535         GetEcoreEvasMgr()->GetEcoreEvas()->SetOwner(*this, *GetOwner());//set owner to EcoreEvas for orientation set.
536
537         r = __pChildEdit->SetText(__text);
538         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
539
540         if (__pIndicator)
541         {
542                 __pIndicator->OnAttachedToMainTree();
543                 __pIndicator->AddIndicatorObject(this, GetRootWindow());
544                 __pIndicator->SetIndicatorShowState(true);
545                 __pIndicator->SetIndicatorAutoHide(false, true);
546         }
547
548         Invalidate(true);
549
550         return r;
551 }
552
553 result
554 _Keypad::OnDetachingFromMainTree(void)
555 {
556         if (__pIndicator)
557         {
558                 __pIndicator->DeleteIndicatorObject();
559         }
560
561         if (__pCallerEdit && !__pCallerEdit->IsInputEventEnabled())
562         {
563                 __pCallerEdit->UnlockInputEvent();
564         }
565
566         return _Window::OnDetachingFromMainTree();
567 }
568
569 void
570 _Keypad::OnNativeWindowActivated(void)
571 {
572         if (__isFirstCall && __pChildEdit)
573         {
574                 __pChildEdit->SetFocused();
575                 __isFirstCall = false;
576         }
577
578         return;
579 }
580
581 bool
582 _Keypad::IsRotationSynchronized(void) const
583 {
584         return true;
585 }
586
587 void
588 _Keypad::OnDraw(void)
589 {
590         Color backgroundColor;
591         GET_COLOR_CONFIG(EDIT::BG_NORMAL, backgroundColor);
592         SetBackgroundColor(backgroundColor);
593
594         return;
595 }
596
597 result
598 _Keypad::SetSingleLineEnabled(bool enabled)
599 {
600         SetProperty("singleLineEnabled", Variant(enabled));
601
602         return E_SUCCESS;
603 }
604
605 bool
606 _Keypad::IsSingleLineEnabled(void) const
607 {
608         Variant enabled = GetProperty("singleLineEnabled");
609
610         return enabled.ToBool();
611 }
612
613 result
614 _Keypad::SetPropertySingleLineEnabled(const Variant& enabled)
615 {
616         __isSingleLineEnabled = enabled.ToBool();
617
618         return E_SUCCESS;
619 }
620
621 Variant
622 _Keypad::GetPropertySingleLineEnabled(void) const
623 {
624         return Variant(__isSingleLineEnabled);
625 }
626
627 String
628 _Keypad::GetText(void) const
629 {
630         Variant text = GetProperty("text");
631
632         return text.ToString();
633 }
634
635 void
636 _Keypad::SetText(const String& text)
637 {
638         SetProperty("text", Variant(text));
639
640         return;
641 }
642
643 result
644 _Keypad::SetPropertyText(const Variant& text)
645 {
646         __text = text.ToString();
647
648         return E_SUCCESS;
649 }
650
651 Variant
652 _Keypad::GetPropertyText(void) const
653 {
654         return Variant(__text);
655 }
656
657 result
658 _Keypad::AddTextEventListener(const _ITextEventListener& listener)
659 {
660         if (__pTextEvent == null)
661         {
662                 __pTextEvent = _TextEvent::CreateInstanceN(*this);
663                 SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.\n");
664         }
665
666         return __pTextEvent->AddListener(listener);
667 }
668
669 result
670 _Keypad::RemoveTextEventListener(const _ITextEventListener& listener)
671 {
672         SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.");
673         __pTextEvent->RemoveListener(listener);
674
675         return E_SUCCESS;
676 }
677
678 void
679 _Keypad::SetEditTextFilter(IEditTextFilter* pFilter)
680 {
681         if (__pChildEdit)
682         {
683                 __pChildEdit->SetEditTextFilter(pFilter);
684         }
685
686         return;
687 }
688
689 void
690 _Keypad::SendOpaqueCommand (const Tizen::Base::String& command)
691 {
692         if (__pChildEdit)
693         {
694                 __pChildEdit->SendOpaqueCommand(command);
695         }
696
697         return;
698 }
699
700 bool
701 _Keypad::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
702 {
703         if (keyInfo.GetKeyCode() == _KEY_ESC || keyInfo.GetKeyCode() == _KEY_BACK)
704         {
705                 OnActionPerformed(source, FOOTER_BACK_BUTTON_ID);
706         }
707
708         return true;
709 }
710
711 void
712 _Keypad::OnActionPerformed(const _Control& source, int actionId)
713 {
714         bool isReCreationLock = false;
715         if ((actionId != COMMAND_DONE_BUTTON_ID) && (actionId != FOOTER_BACK_BUTTON_ID))
716         {
717                 return;
718         }
719
720         __pChildEdit->HideKeypad();
721
722         if (__pCallerEdit)
723         {
724                 __pCallerEdit->SetKeypadEnabled(false);
725                 isReCreationLock = true;
726         }
727         Close();
728         if (isReCreationLock)
729         {
730                 __pCallerEdit->SetKeypadEnabled(true);
731         }
732
733         CoreTextEventStatus textEventStatus = CORE_TEXT_EVENT_CHANGED;
734         if (actionId == COMMAND_DONE_BUTTON_ID)
735         {
736                 __text = __pChildEdit->GetText();
737                 textEventStatus = CORE_TEXT_EVENT_CHANGED;
738         }
739         else
740         {
741                 textEventStatus = CORE_TEXT_EVENT_CANCELED;
742         }
743
744         __isCommandButtonPressed = true;
745
746         if (__pCallerEdit)
747         {
748                 __pCallerEdit->SetText(__text);
749                 _Control* pParent = __pCallerEdit->GetParent();
750                 if (pParent)
751                 {
752                         pParent->Invalidate(true);
753                 }
754
755                 __pCallerEdit->SendTextEvent(textEventStatus);
756         }
757         else
758         {
759                 GetOwner()->Invalidate(true);
760                 if (__pTextEvent)
761                 {
762                         IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(textEventStatus);
763                         if (pEventArg)
764                         {
765                                 __pTextEvent->Fire(*pEventArg);
766                         }
767                 }
768         }
769
770         return;
771 }
772
773 void
774 _Keypad::OnKeypadWillOpen(void)
775 {
776         SysLog(NID_UI_CTRL, "[FULLEDIT] OnKeypadWillOpen");
777         return;
778 }
779
780 void
781 _Keypad::OnKeypadOpened(void)
782 {
783         if (__pChildEdit->IsUsbKeyboardConnected())
784         {
785                 __isPredictionWindowOpendInUSBMode = true;
786         }
787
788         SysLog(NID_UI_CTRL, "[FULLEDIT] OnKeypadOpened");
789
790         ChangeLayoutInternal(LAYOUT_CHANGE_KEYPAD_SHOW);//usb off & bounded or usb on & prediction
791
792         return;
793 }
794
795 void
796 _Keypad::OnKeypadClosed(void)
797 {
798         __isPredictionWindowOpendInUSBMode = false;
799
800         SysLog(NID_UI_CTRL, "[FULLEDIT] OnKeypadClosed");
801
802         ChangeLayoutInternal(LAYOUT_CHANGE_KEYPAD_HIDE);
803
804         return;
805 }
806
807 void
808 _Keypad::OnKeypadBoundsChanged(void)
809 {
810         SysLog(NID_UI_CTRL, "[FULLEDIT] OnKeypadBoundsChanged");
811
812         ChangeLayoutInternal(LAYOUT_CHANGE_KEYPAD_BOUNDS_CHANGED);// predictive window show/hide
813
814         return;
815 }
816
817 void
818 _Keypad::OnKeypadActionPerformed(CoreKeypadAction keypadAction)
819 {
820         return;
821 }
822
823 void
824 _Keypad::OnChangeLayout(_ControlOrientation orientation)
825 {
826         float indicatorheight = 0.0f;
827
828         const FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
829         const FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
830
831         if (__pIndicator)
832         {
833                 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
834                 {
835                         GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorheight);
836                         __pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, portraitSize.width, indicatorheight));
837                 }
838                 else
839                 {
840                         GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorheight);
841                         __pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, landscapeSize.width, indicatorheight));
842                 }
843
844                 __pIndicator->OnChangeLayout(orientation);
845         }
846
847         if (__isInitialized)
848         {
849                 ChangeLayoutInternal(LAYOUT_CHANGE_ROTATE);
850         }
851
852         return;
853 }
854
855 void
856 _Keypad::OnSettingChanged(String& key)
857 {
858         const wchar_t* LOCALE_LANGUAGE = L"http://tizen.org/setting/locale.language";
859         if (key == LOCALE_LANGUAGE)
860         {
861                 if (__pFooter)
862                 {
863                         _Button* pButton = __pFooter->GetItem(0);
864                         if (pButton)
865                         {
866                                 String doneText;
867                                 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_DONE, doneText);
868                                 pButton->SetText(doneText);
869                         }
870                 }
871         }
872 }
873
874 bool
875 _Keypad::IsLayoutChangable(void) const
876 {
877         return true;
878 }
879
880 } } } // Tizen::Ui::Controls