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