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_EditPresenter.cpp
20 * @brief This is the implementation file for the _EditPresenter class.
23 #include <FBaseErrorDefine.h>
24 #include <FBaseInternalTypes.h>
25 #include <FBaseSysLog.h>
26 #include <FBaseUtilMath.h>
27 #include <FGrpFloatRectangle.h>
29 #include <FLclLocale.h>
30 #include <FUiCtrlFooter.h>
31 #include <FUiCtrlFooterItem.h>
32 #include <FUiCtrlForm.h>
33 #include <FUiIActionEventListener.h>
34 #include <FGrp_BitmapImpl.h>
35 #include <FGrp_CoordinateSystem.h>
36 #include <FGrp_FontImpl.h>
37 #include <FGrp_Screen.h>
38 #include <FGrp_TextCommon.h>
39 #include <FGrp_TextElementImpl.h>
40 #include <FGrp_TextTextCutLink.h>
41 #include <FGrp_TextTextCutLinkParser.h>
42 #include <FGrp_TextTextElement.h>
43 #include <FGrp_TextTextImage.h>
44 #include <FGrp_TextTextSimple.h>
45 #include "FUi_Clipboard.h"
46 #include "FUi_ClipboardItem.h"
47 #include "FUi_Control.h"
48 #include "FUi_ControlManager.h"
49 #include "FUi_CoordinateSystemUtils.h"
50 #include "FUi_EcoreEvasMgr.h"
51 #include "FUi_ResourceManager.h"
52 #include "FUi_BidiUtils.h"
53 #include "FUi_UiEventManager.h"
54 #include "FUi_UiNotificationEvent.h"
55 #include "FUiAnim_VisualElement.h"
56 #include "FUiAnim_EflNode.h"
57 #include "FUiCtrl_Button.h"
58 #include "FUiCtrl_ContextMenu.h"
59 #include "FUiCtrl_Edit.h"
60 #include "FUiCtrl_EditCopyPasteManager.h"
61 #include "FUiCtrl_EditPresenter.h"
62 #include "FUiCtrl_TokenEditPresenter.h"
63 #include "FUiCtrl_FlickAnimation.h"
64 #include "FUiCtrl_Frame.h"
65 #include "FUiCtrl_Form.h"
66 #include "FUiCtrl_Scroll.h"
67 #include "FUiCtrl_ScrollPanel.h"
68 #include "FUiCtrl_Toolbar.h"
69 #include "FUiCtrl_TableView.h"
70 #include "FUi_Window.h"
73 using namespace Tizen::Base::Runtime;
74 using namespace Tizen::Base::Utility;
75 using namespace Tizen::Media;
76 using namespace Tizen::Ui::Animations;
77 using namespace Tizen::Graphics;
78 using namespace Tizen::Ui;
79 using namespace Tizen::Ui::Controls;
80 using namespace Tizen::Base;
81 using namespace Tizen::Base::Utility;
82 using namespace Tizen::Base::Collection;
83 using namespace Tizen::Locales;
84 using namespace Tizen::Graphics::_Text;
86 namespace Tizen { namespace Ui { namespace Controls
88 const int EDIT_PASSWORD_TIMER_PERIOD = 1000;
89 const int EDIT_CURSOR_TIMER_PERIOD = 600;
90 const int MAX_LINE_NUMBER = 100;
91 const int MAX_FLEXIBLE_HEIGHT_VERTICAL_MODE = 4000;
92 const int MAX_FLEXIBLE_HEIGHT_HORIZONTAL_MODE = 2500;
93 const int EDIT_FLICK_SCROLL_TIMER_INTERVAL = 10;
94 const int EDIT_FLICK_SCROLL_MOVE_AMOUNT_MULTIPLIER = 2;
95 const float DIRECTION_DECISION_RATIO = 1.3f;
96 const float HORIZONTAL_DECISION_RATIO = 1.5f;
97 const float MOVE_SKIP_DECISION_RANGE = 5.0f;
98 const int TITLE_SLIDING_TIME = 800;
100 const int LANGUAGE_CODE_START = 0;
101 const int LANGUAGE_CODE_MAX = 2;
103 bool _EditPresenter::__isKeypadExist = false;
104 bool _EditPresenter::__isClipboardExist = false;
105 float _EditPresenter::__initialParentHeight = 0.0f;
106 float _EditPresenter::__clipboardHeight = 0.0f;
107 _EditFooterVisibleStatus _EditPresenter::__initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
108 bool _EditPresenter::__footerVisibleChanged = false;
109 unsigned int _EditPresenter::__latestBoundedContext = null;
110 const float _EditPresenter::TOUCH_PRESS_THRESHOLD_IN_CLEAR_AREA = 0.04f;
111 _ScrollPanel* _EditPresenter::__pResizedPanel = null;
113 _EditAnimationProvider::_EditAnimationProvider(void)
117 _EditAnimationProvider::~_EditAnimationProvider(void)
121 VisualElementAnimation*
122 _EditAnimationProvider::CreateAnimationForProperty(VisualElement& source, const String& property)
124 VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(source, property);
125 if (pAnimation != null)
127 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseInOut"));
128 pAnimation->SetDuration(ANIMATION_DURATION);
134 _EditPresenter::_EditPresenter(void)
135 : __pTitleSlidingTimer(null)
137 , __pTextBuffer(null)
138 , __pTextString(null)
141 , __pScrollEffect(null)
143 , __horizontalAlignment(ALIGNMENT_LEFT)
144 , __horizontalAlignmentForBidi(ALIGNMENT_LEFT)
145 , __isScrollBarVisible(false)
146 , __scrollBarBounds()
148 , __previousScrollBarPos(0.0f)
149 , __previousScrollBarMaxPos(0.0f)
150 , __pActionEventListener(null)
151 , __pCursorTimer(null)
152 , __pFlickAnimationTimer(null)
153 , __pPasswordTimer(null)
155 , __pCursorVisualElement(null)
156 , __pTextVisualElement(null)
157 , __pTitleTextVisualElement(null)
158 , __pCopyPasteManager(null)
159 , __pFlickAnimation(null)
160 , __pParentForm(null)
161 , __pFullscreenKeypad(null)
162 , __pParentPanel(null)
163 , __pCommandButton(null)
164 , __pInputConnection(null)
165 , __isInputConnectionBound(false)
166 , __sentKeypadEvent(CORE_KEYPAD_EVENT_STATUS_CLOSE)
171 , __isCopyPastePopupMoving(false)
172 , __pressedAbsolutePoint()
173 , __clearIconBounds()
175 , __textObjectBounds()
178 , __previousCursorBounds()
179 , __keypadBounds(0.0f, 0.0f, 0.0f,0.0f)
180 , __pTextObject(null)
181 , __pGuideTextObject(null)
182 , __pTitleTextObject(null)
183 , __titleSlidingAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT)
184 , __textObjectWrap(TEXT_OBJECT_WRAP_TYPE_WORD)
185 , __isTextBlocked(false)
186 , __isGuideTextColorChanged(false)
187 , __isKeypadCommandButtonVisible(false)
188 , __isKeypadCommandButtonUserSetting(false)
189 , __isTextComposing(false)
190 , __isCopyPasteManagerExist(false)
191 , __isCursorChanged(false)
192 , __isCursorInitialized(false)
193 , __isCursorDisabled(false)
194 , __isInitialized(false)
195 , __isMovingCursorByTouchMove(false)
196 , __isTouchMoving(false)
197 , __isTouchPressed(false)
198 , __isClearIconPressed(false)
199 , __isCursorOpaque(false)
200 , __isTouchReleaseSkipped(false)
201 , __isViewerModeEnabled(false)
202 , __isKeypadNormalNumberStyleEnabled(false)
203 , __isTextCompositionFinished(false)
204 , __isFlexibleHeightFrozen(false)
205 , __isKeypadShowing(false)
206 , __isKeypadHiding(false)
207 , __resizedByKeypadHide(false)
210 , __prevTotalTextHeight(-1.0f)
212 , __composingTextLength(0)
213 , __titleWidth(-1.0f)
214 , __verticalMargin(-1.0f)
215 , __isUSBKeyboardConnected(false)
217 , __isCutLinkParserEnabled(false)
219 , __ContentTextStatus(EDIT_TEXT_STATUS_COMPOSE_NON)
220 , __pEditVEDelegator(null)
221 , __isAutoShrinkEnabled(false)
222 , __groupStyle(GROUP_STYLE_NONE)
223 , __isFontInitialized(false)
224 , __contentFontSize(0.0f)
225 , __titleFontSize(0.0f)
226 , __defaultTouchMoveThreshold(0.16f)
227 , __contentFontStyle(FONT_STYLE_PLAIN)
228 , __contentTextStyle(TEXT_BOX_TEXT_STYLE_NORMAL)
229 , __titleFontFaceName("")
230 , __isSearchBar(false)
231 , __pCurrentFrame(null)
232 , __pTextFilter(null)
233 , __textBlockMoveLeft(false)
234 , __textBlockMoving(false)
235 , __clipboardConnected(false)
236 , __updateInitialBounds(true)
237 , __blockTextColor(Color(0, 0, 0))
238 , __rowCursorIndex(-1)
239 , __columnCursorIndex(-1)
240 , __isPasswordVisible(false)
241 , __needToCreateCopyPastePopup(false)
242 , __calculatedCursorBounds(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
247 _EditPresenter::OnInputConnectionPanelShowStateChanged(InputConnection& source, InputPanelShowState showState)
249 if (showState == INPUT_PANEL_SHOW_STATE_SHOW)// 1. keypad show 2.usb on&predictive window show
251 __isKeypadHiding = false;
252 __isKeypadShowing = false;
253 __isKeypadExist = true;
255 CheckUSBKeyboardStatus();
257 SysLog(NID_UI_CTRL, "INPUT_PANEL_SHOW_STATE_SHOW[Target:%x][Bound:%d][Usb mode:%d]", this, __isInputConnectionBound, __isUSBKeyboardConnected);
259 if (__isInputConnectionBound)
261 if (__isKeypadCommandButtonVisible && __pCommandButton)
263 SetFooterVisible(false);
266 ChangeLayoutInternal(__pEdit->GetOrientation());
267 AdjustParentPanelHeight(false);
269 ScrollPanelToCursorPosition();
271 if (__isCopyPasteManagerExist)
273 __pCopyPasteManager->CreateCopyPastePopup();
274 __pCopyPasteManager->Show();
278 if (!__pEdit->IsFullScreenKeypadEdit())
282 __pParentForm->Draw();
286 if (__isUSBKeyboardConnected && (__isKeypadCommandButtonVisible && __pCommandButton))
288 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
290 else if (__isKeypadCommandButtonVisible && __pCommandButton && __pCommandButton->GetVisibleState())//already command exist in usb mode
292 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
296 if (GetLastSentKeypadEvent() != CORE_KEYPAD_EVENT_STATUS_OPEN)
298 if (!__isClipboardExist)
300 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
302 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
306 else if (showState == INPUT_PANEL_SHOW_STATE_HIDE)// 1.unbound 2.bounded&usb off -> usb on 3.Flick keypad hide
308 __isKeypadHiding = false;
310 CheckUSBKeyboardStatus();
311 SysLog(NID_UI_CTRL, "INPUT_PANEL_SHOW_STATE_HIDE[Target:%x][Bound:%d][Usb mode:%d]", this, __isInputConnectionBound, __isUSBKeyboardConnected);
313 __isKeypadExist = false;
315 if (__resizedByKeypadHide)
317 __resizedByKeypadHide = false;
321 if (__isCopyPasteManagerExist)
323 InitializeCopyPasteManager();
324 __pTextObject->SetBlock(false);
325 __isTextBlocked = false;
328 if (__isInputConnectionBound && __isUSBKeyboardConnected) // hide callback from external condition(usb mode off->on), focus remaining
330 if (!__isKeypadCommandButtonVisible && !__isClipboardExist)
332 if (__footerVisibleChanged)
334 SetFooterVisible(true);// must be called ahead of DeflateClientRectHeight
338 ChangeLayoutInternal(__pEdit->GetOrientation());
340 if (__isClipboardExist)
342 AdjustParentPanelHeight(false);
346 AdjustParentPanelHeight(true);
349 if (!__pEdit->IsFullScreenKeypadEdit())
353 __pParentForm->Draw();
359 if (__isInputConnectionBound)// keypad hided by back key or prediction hided by usb mode changed(on -> off)
361 if (!__isKeypadCommandButtonVisible && !__isClipboardExist)
363 if (__footerVisibleChanged)
365 SetFooterVisible(true);// must be called ahead of DeflateClientRectHeight
369 FinishTextComposition();
371 ChangeLayoutInternal(__pEdit->GetOrientation());
373 if (__isClipboardExist)
375 AdjustParentPanelHeight(false);
379 AdjustParentPanelHeight(true);
382 if (!__pEdit->IsFullScreenKeypadEdit())
386 __pParentForm->Draw();
390 else// called by focus move or HideKeypad() api call
392 if (__pCommandButton && __isKeypadCommandButtonVisible)
394 SetFooterVisible(true);// must be called ahead of DeflateClientRectHeight
395 __pCommandButton->SetVisibleState(false);
396 __pCommandButton->Invalidate();
399 __isInputConnectionBound = false;
401 AdjustParentPanelHeight(true);
405 SysLog(NID_UI_CTRL, "Form deflate RESET!!!");
406 __pParentForm->DeflateClientRectHeight(0.0f);
409 if (!__pEdit->IsFullScreenKeypadEdit())
413 __pParentForm->Draw();
419 if ((__isKeypadCommandButtonVisible && __pCommandButton) && __isInputConnectionBound)
421 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
423 else if((__isUSBKeyboardConnected && (__isKeypadCommandButtonVisible &&__pCommandButton) && !__isInputConnectionBound) ||
424 (__isUSBKeyboardConnected && __isClipboardExist))
430 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CLOSED);
431 __pEdit->DetachScrollPanelEvent();
433 if (!__isClipboardExist)
435 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
444 _EditPresenter::OnInputConnectionPanelLanguageChanged(InputConnection& source, LanguageCode language)
446 LanguageCode oldLanguageCode;
447 __pEditModel->GetCurrentLanguage(oldLanguageCode);
449 __pEditModel->SetCurrentLanguage(language);
450 __pEdit->SendLanguageEvent(oldLanguageCode, language);
456 _EditPresenter::OnInputConnectionPanelBoundsChanged(InputConnection& source, const Rectangle& bounds)
458 float previousHeight = __keypadBounds.height;
460 CheckUSBKeyboardStatus();
462 if ((__isUSBKeyboardConnected == false) && __isKeypadExist == false)
464 SysLog(NID_UI_CTRL, "OnInputConnectionPanelBoundsChanged skipped - __isUSBKeyboardConnected:(%), __isKeypadExist:(%d)", __isUSBKeyboardConnected, __isKeypadExist);
468 if (CheckKeypadExist(__pEdit->GetOrientation()) == false)//double check keypad Exist
470 SysLog(NID_UI_CTRL, "OnInputConnectionPanelBoundsChanged skipped - Keypad doesn't exist!!");
475 if (IsKeypadRotating(__pEdit->GetOrientation()))
477 SysLog(NID_UI_CTRL, "OnInputConnectionPanelBoundsChanged skipped - Keypad is rotating!!");
478 AdjustParentPanelHeight(true);
483 SysLog(NID_UI_CTRL, "OnInputConnectionPanelBoundsChanged");
484 ChangeLayoutInternal(__pEdit->GetOrientation());
485 AdjustParentPanelHeight(false);
486 ScrollPanelToCursorPosition();
490 __pParentForm->Draw();
493 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
495 if (__isCopyPasteManagerExist)
498 if (__pCopyPasteManager->GetCopyPastePopup())
500 if (previousHeight != bounds.height)
502 __pCopyPasteManager->CreateCopyPastePopup();
505 __pCopyPasteManager->Show();
512 _EditPresenter::OnInputConnectionTextPredictionShowStateChanged(InputConnection& source, bool isShown)
518 _EditPresenter::OnInputConnectionTextPredictionBoundsChanged(InputConnection& source, const Rectangle& bounds)
524 _EditPresenter::OnInputConnectionTextCommitted(InputConnection& source, const String& committedText)
526 OnTextCommitted(committedText);
532 _EditPresenter::OnTextCommitted(const String& commitText)
534 bool isTextComposingFinished = false;
535 char enterText1[2] = {'\n', };
536 char enterText2[2] = {'\r', };
538 if (IsViewModeEnabled() == true)
543 if (IsBlocked() == true)
545 CoreKeypadAction keypadaction = GetKeypadAction();
546 if (keypadaction == CORE_KEYPAD_ACTION_ENTER || !(commitText == enterText1 || commitText == enterText2))
550 GetBlockRange(start, end);
551 __isFlexibleHeightFrozen = true;
552 DeleteText(start, end);
553 __isFlexibleHeightFrozen = false;
558 if (__isCopyPasteManagerExist)
560 InitializeCopyPasteManager();
563 int textLength = commitText.GetLength();
564 int compositionStart = __cursorPos - textLength;
566 if (__isTextComposing == true)
568 __isFlexibleHeightFrozen = true;
569 DeleteText(__cursorPos-__composingTextLength, __cursorPos);
570 __isFlexibleHeightFrozen = false;
572 __isTextComposing = false;
573 __composingTextLength = 0;
574 isTextComposingFinished = true;
577 if (__ContentTextStatus != EDIT_TEXT_STATUS_COMPOSE_NON)
579 __pTextObject->SetFont(__pFont, __cursorPos, __cursorPos+textLength);
580 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
583 if (__pPasswordTimer)
585 ChangePasswordToEchoCharacter(__pTextBuffer, __echoChar);
589 if (commitText == enterText1 || commitText == enterText2)
591 CoreKeypadAction keypadaction = GetKeypadAction();
593 __pEdit->SendKeypadEvent(keypadaction, CORE_KEYPAD_EVENT_STATUS_ENTERACTION);
594 if (keypadaction != CORE_KEYPAD_ACTION_ENTER)
599 if(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
605 char tapText[2] = {'\t', };
606 if (commitText == tapText)
611 // Limitation Protect
612 String insetText = commitText;
613 int currentLength = GetTextLength();
614 int totalLength = currentLength + textLength;
615 int excessCharacterLength = totalLength - __limitLength;
617 if (excessCharacterLength >= 0)
619 textLength -= excessCharacterLength;
622 insetText.Remove(textLength, excessCharacterLength);
630 InsertTextAt(__cursorPos, insetText);
632 ScrollPanelToCursorPosition();
634 if ((__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) && isTextComposingFinished)
636 ReplaceTextIntoPasswordHyphenString();
639 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
644 ChangePasswordToEchoCharacter((compositionStart + textLength), textLength);
646 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
652 _EditPresenter::OnInputConnectionComposingTextChanged(InputConnection& source, const String& composingText, int cursorPosition)
654 OnComposingTextChanged(composingText, cursorPosition);
660 _EditPresenter::OnComposingTextChanged(const String& composingText, int cursorPosition)
662 if (IsViewModeEnabled() == true)
667 if (IsBlocked() == true)
671 GetBlockRange(start, end);
672 __isFlexibleHeightFrozen = true;
673 DeleteText(start, end);
674 __isFlexibleHeightFrozen = false;
678 if (__isCopyPasteManagerExist)
680 InitializeCopyPasteManager();
683 int textLength = composingText.GetLength();
685 if (__isTextComposing == false)
694 int compositionStart = GetCursorPosition();
698 __isTextComposing = false;
700 // FirstText Check Logic
701 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
702 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine);
703 bool isFirstText = false;
704 if (firstTextIndex + 1 == __pTextObject->GetCursorIndex())
709 DeleteText(compositionStart-__composingTextLength, compositionStart);
713 __isCursorChanged = false;
714 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT);
717 __composingTextLength = 0;
721 if (!__isCursorChanged)
723 __isCursorChanged = true;
725 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
731 __isFlexibleHeightFrozen = true;
732 DeleteText(compositionStart-__composingTextLength, compositionStart);
733 __isFlexibleHeightFrozen = false;
737 __composingTextLength = textLength;
738 if (__composingTextLength > 0)
740 __isTextComposing = true;
743 if (__pPasswordTimer)
745 ChangePasswordToEchoCharacter(__pTextBuffer, __echoChar);
749 // Limitation Protect
750 String insetText = composingText;
751 int currentLength = GetTextLength();
752 int totalLength = currentLength + textLength;
753 int excessCharacterLength = totalLength - __limitLength;
755 if (excessCharacterLength >= 0)
757 __composingTextLength -= excessCharacterLength;
758 if (__composingTextLength > 0)
760 insetText.Remove(__composingTextLength, excessCharacterLength);
764 __composingTextLength = 0;
768 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
769 SysTryReturnVoidResult(NID_UI_CTRL, fontImpl != null, E_SYSTEM, "[E_SYSTEM] fontImpl is null.");
770 fontImpl->SetUnderline(true);
771 __pTextObject->SetFont(__pFont, 0, 0);
773 if (__composingTextLength > 0)
775 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE;
778 InsertTextAt(GetCursorPosition(), insetText);
780 fontImpl->SetUnderline(false);// rollback to default content font
781 __pTextObject->SetFont(__pFont, 0, 0);
783 ScrollPanelToCursorPosition();
786 if (__composingTextLength > 0)
788 ChangePasswordToEchoCharacter((GetCursorPosition() - __composingTextLength), __composingTextLength);
791 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
797 _EditPresenter::DeleteSurroundingText(InputConnection& source, int offset, int charCount)
799 OnSurroundingTextDeleted(offset, charCount);
805 _EditPresenter::OnSurroundingTextDeleted(int offset, int charCount)
810 if (IsBlocked() == true)
812 GetBlockRange(start, end);
816 start = __cursorPos + offset;
821 end = start + charCount;
822 if (end > __cursorPos)
828 DeleteText(start, end);
830 if (__isCopyPasteManagerExist)
832 InitializeCopyPasteManager();
835 if (IsBlocked() == true)
842 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
848 _EditPresenter::GetPreviousText(InputConnection& source, String& text, int& cursorPosition)
850 const int SURRONDING_TEXT_SIZE = 5;
851 int stringLength = 0;
854 if (__cursorPos == 0)
861 if (__cursorPos < SURRONDING_TEXT_SIZE)
863 text = GetText(0, __cursorPos - 1);
867 int previousTextSize = 0;
869 for( int index = 0; index < __cursorPos; index++)
872 if ( __pTextBuffer[__cursorPos-index-1] != 0x20)
878 if (previousTextSize < SURRONDING_TEXT_SIZE)
880 previousTextSize = SURRONDING_TEXT_SIZE;
883 text = GetText(__cursorPos - previousTextSize, __cursorPos - 1);
886 stringLength = text.GetLength();
887 cursorPosition = stringLength;
894 _EditPresenter::OnClipboardPopupOpened(Tizen::Graphics::Dimension& clipboardPopupSize)
896 FloatDimension floatClipboardPopupSize = _CoordinateSystemUtils::ConvertToFloat(clipboardPopupSize);
898 if (__clipboardConnected)
900 __isClipboardExist = true;
901 FloatRectangle absKeypadBounds;
902 GetKeypadBounds(absKeypadBounds);
903 CheckUSBKeyboardStatus();
905 __clipboardHeight = floatClipboardPopupSize.height;
907 SysLog(NID_UI_CTRL, "clipboard height = %f, [KeypadExist:%d]keypad height = %f", floatClipboardPopupSize.height, __isKeypadExist, absKeypadBounds.height);
909 if (__isKeypadExist) //resize as difference between clipboard height vs keypad height
911 if (floatClipboardPopupSize.height > absKeypadBounds.height)
913 ChangeLayoutInternal(__pEdit->GetOrientation());
914 AdjustParentPanelHeight(false);
915 ScrollPanelToCursorPosition();
919 __pParentForm->Draw();
922 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
927 if (!__isKeypadCommandButtonVisible)
929 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
931 ChangeLayoutInternal(__pEdit->GetOrientation());
932 AdjustParentPanelHeight(false);
933 ScrollPanelToCursorPosition();
937 __pParentForm->Draw();
940 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
944 ChangeLayoutInternal(__pEdit->GetOrientation());
945 AdjustParentPanelHeight(false);
946 ScrollPanelToCursorPosition();
950 __pParentForm->Draw();
953 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
956 if (__isCopyPasteManagerExist)
958 __pCopyPasteManager->AdjustBounds();
966 _EditPresenter::OnClipboardPopupBoundsChanged(Tizen::Graphics::Dimension& clipboardPopupSize)
968 FloatDimension floatClipboardPopupSize = _CoordinateSystemUtils::ConvertToFloat(clipboardPopupSize);
970 if (__clipboardConnected)
972 FloatRectangle absKeypadBounds;
973 GetKeypadBounds(absKeypadBounds);
974 CheckUSBKeyboardStatus();
976 __clipboardHeight = floatClipboardPopupSize.height;
978 SysLog(NID_UI_CTRL, "clipboard height = %f, [KeypadExist:%d]keypad height = %f", floatClipboardPopupSize.height, __isKeypadExist, absKeypadBounds.height);
982 if (floatClipboardPopupSize.height >= absKeypadBounds.height)
984 ChangeLayoutInternal(__pEdit->GetOrientation());
985 AdjustParentPanelHeight(false);
986 ScrollPanelToCursorPosition();
990 __pParentForm->Draw();
993 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
997 ChangeLayoutInternal(__pEdit->GetOrientation());
998 AdjustParentPanelHeight(false);
999 ScrollPanelToCursorPosition();
1003 __pParentForm->Draw();
1006 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1011 ChangeLayoutInternal(__pEdit->GetOrientation());
1012 AdjustParentPanelHeight(false);
1013 ScrollPanelToCursorPosition();
1017 __pParentForm->Draw();
1020 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1023 if (__rotated) // Command button should be relocated after rotation in case of no keypad.
1025 if (__isCopyPasteManagerExist)
1027 PostInternalEvent(String(L"ShowCopyPaste"));
1031 else if (__isCopyPasteManagerExist)
1033 __pCopyPasteManager->AdjustBounds();
1041 _EditPresenter::OnClipboardPopupClosed(void)
1043 if (__clipboardConnected)
1045 if (__isCopyPasteManagerExist)
1047 InitializeCopyPasteManager();
1048 __pTextObject->SetBlock(false);
1049 __isTextBlocked = false;
1054 __pClipboard->HidePopup();
1057 __isClipboardExist = false;
1058 FloatRectangle absKeypadBounds;
1059 GetKeypadBounds(absKeypadBounds);
1060 CheckUSBKeyboardStatus();
1062 __clipboardHeight = 0.0f;
1064 SysLog(NID_UI_CTRL, "clipboard closed! [KeypadExist:%d]keypad height = %f", __isKeypadExist, absKeypadBounds.height);
1066 if (__isInputConnectionBound)
1068 ChangeLayoutInternal(__pEdit->GetOrientation());
1071 if (__isKeypadExist)
1073 AdjustParentPanelHeight(false);
1077 __pParentForm->Draw();
1080 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1084 if (__footerVisibleChanged)
1086 SetFooterVisible(true);
1089 AdjustParentPanelHeight(true);
1092 SysLog(NID_UI_CTRL, "Form deflate RESET!!!");
1093 __pParentForm->DeflateClientRectHeight(0.0f);
1094 __pParentForm->Draw();
1097 if (!__isKeypadCommandButtonVisible)
1099 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
1103 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1107 __clipboardConnected = false;
1113 _EditPresenter::~_EditPresenter(void)
1119 _EditPresenter::Dispose(void)
1121 if (__pCurrentFrame)
1123 __pCurrentFrame->RemoveFrameEventListener(*this);
1124 __pCurrentFrame = null;
1127 CheckUSBKeyboardStatus();
1129 if(__latestBoundedContext != (unsigned int)this)//context is already chagned.
1131 __isKeypadHiding = false;
1134 if (__isInputConnectionBound || __isKeypadHiding || __clipboardConnected) //Edit control removed without FocusLost callback or HideKeypad.
1136 if (__clipboardConnected) //Edit control removed after FocusLost or without FocusLost callback.
1138 __pClipboard->HidePopup();
1139 __isClipboardExist = false;
1142 if (__pCommandButton && __isKeypadCommandButtonVisible)
1144 __pCommandButton->SetVisibleState(false);
1146 SetFooterVisible(true);
1148 delete __pCommandButton;
1149 __pCommandButton = null;
1154 SysLog(NID_UI_CTRL, "Form deflate RESET!!!");
1155 __pParentForm->DeflateClientRectHeight(0.0f);
1158 AdjustParentPanelHeight(true);
1160 __isKeypadExist = false;
1162 __latestBoundedContext = null;
1165 __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
1166 __footerVisibleChanged = false;
1171 __pClipboard->RemoveClipboardPopupEventListener(*this);
1174 if (__pFullscreenKeypad)
1176 __pFullscreenKeypad->Close();
1177 delete __pFullscreenKeypad;
1178 __pFullscreenKeypad = null;
1181 delete __pScrollEffect;
1182 __pScrollEffect = null;
1186 delete[] __pTextBuffer;
1187 __pTextBuffer = null;
1190 delete __pTextString;
1191 __pTextString = null;
1193 delete __pEditModel;
1194 __pEditModel = null;
1198 __pCursorTimer->Cancel();
1199 delete __pCursorTimer;
1200 __pCursorTimer = null;
1203 if (__pInputConnection)
1205 delete __pInputConnection;
1206 __pInputConnection = null;
1209 delete __pTextObject;
1210 __pTextObject = null;
1212 delete __pGuideTextObject;
1213 __pGuideTextObject = null;
1215 delete __pTitleTextObject;
1216 __pTitleTextObject = null;
1218 if (__pPasswordTimer)
1220 __pPasswordTimer->Cancel();
1221 delete __pPasswordTimer;
1222 __pPasswordTimer = null;
1225 if (__pScrollBar != null && __pEdit != null)
1227 __pEdit->DetachSystemChild(*__pScrollBar);
1228 delete __pScrollBar;
1229 __pScrollBar = null;
1232 if (__pFlickAnimationTimer)
1234 __pFlickAnimationTimer->Cancel();
1235 delete __pFlickAnimationTimer;
1236 __pFlickAnimationTimer = null;
1239 if (__pTitleSlidingTimer)
1241 __pTitleSlidingTimer->Cancel();
1242 delete __pTitleSlidingTimer;
1243 __pTitleSlidingTimer = null;
1246 delete __pFlickAnimation;
1247 __pFlickAnimation = null;
1249 if (__pCopyPasteManager != null)
1251 delete __pCopyPasteManager;
1252 __pCopyPasteManager = null;
1255 if (__pTextVisualElement)
1257 __pTextVisualElement->Destroy();
1258 __pTextVisualElement = null;
1261 if (__pCursorVisualElement)
1263 __pCursorVisualElement->Destroy();
1264 __pCursorVisualElement = null;
1267 if (__pTitleTextVisualElement)
1269 __pTitleTextVisualElement->Destroy();
1270 __pTitleTextVisualElement = null;
1273 if (__pEditVEDelegator)
1275 delete __pEditVEDelegator;
1276 __pEditVEDelegator = null;
1283 _EditPresenter::IsKeypadExist(void) const
1285 return __isKeypadExist;
1289 _EditPresenter::IsClipboardExist(void) const
1291 return __isClipboardExist;
1295 _EditPresenter::CheckUSBKeyboardStatus(void)
1297 if (__pInputConnection->CheckUSBKeyboardStatus())
1299 __isUSBKeyboardConnected = true;
1303 __isUSBKeyboardConnected = false;
1310 _EditPresenter::IsUsbKeyboardConnected(void) const
1312 if (__pInputConnection->CheckUSBKeyboardStatus())
1323 _EditPresenter::IsCurrentFocused(void)
1325 _ControlManager* pControlManager = _ControlManager::GetInstance();
1327 if (pControlManager)
1329 _Control* pControl = pControlManager->GetFocusControl();
1330 if (pControl != __pEdit)
1341 return __pEdit->IsInternalFocused();
1346 _EditPresenter::InitializeFocusedCondition(void)
1350 __pParentForm = GetParentForm();
1352 if (!__pParentForm && __isKeypadCommandButtonVisible)
1354 __isKeypadCommandButtonVisible = false;
1358 if (!__pTextVisualElement)
1360 result r = E_SUCCESS;
1361 __pTextVisualElement = new (std::nothrow) _VisualElement;
1362 SysTryReturn(NID_UI_CTRL, __pTextVisualElement != null, false, E_OUT_OF_MEMORY, "Unable to create __pTextVisualElement instance.");
1364 r = __pTextVisualElement->Construct();
1365 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r));
1367 __pTextVisualElement->SetSurfaceOpaque(false);
1368 __pTextVisualElement->SetImplicitAnimationEnabled(false);
1370 __pTextVisualElement->SetShowState(true);
1372 _VisualElement* pEditVisualElement = __pEdit->GetVisualElement();
1373 SysTryCatch(NID_UI_CTRL, pEditVisualElement, , r = E_SYSTEM, "[E_SYSTEM] Unable to get root visual element.");
1375 pEditVisualElement->AttachChild(*__pTextVisualElement);
1376 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r));
1379 __isCursorOpaque = true;
1384 __pTextVisualElement->Destroy();
1385 __pTextVisualElement = null;
1391 _EditPresenter::SetSentKeypadEvent(CoreKeypadEventStatus sentKeypadEvent)
1393 __sentKeypadEvent = sentKeypadEvent;
1396 CoreKeypadEventStatus
1397 _EditPresenter::GetLastSentKeypadEvent(void)
1399 return __sentKeypadEvent;
1404 _EditPresenter::CreateInstanceN(void)
1406 _EditPresenter* pPresenter = new (std::nothrow) _EditPresenter;
1407 if (pPresenter == null)
1409 SetLastResult(E_OUT_OF_MEMORY);
1417 _EditPresenter::Initialize(const _Control& control)
1419 result r = E_SUCCESS;
1420 _EditModel* pEditModel = null;
1421 _VisualElement* pEditVisualElement = null;
1422 TextSimple* pSimpleText = null;
1423 _ControlManager* pControlManager = _ControlManager::GetInstance();
1424 _Window* pWindow = null;
1426 __pEdit = dynamic_cast<_Edit*>(const_cast<_Control*>(&control));
1427 SysAssertf(__pEdit != null, "__pEdit is null");
1429 __pTextObject = new (std::nothrow) TextObject;
1430 if (__pTextObject == null)
1432 r = E_OUT_OF_MEMORY;
1436 __pTextObject->Construct();
1437 pSimpleText = new (std::nothrow)TextSimple(null, 0, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1438 __pTextObject->AppendElement(*pSimpleText);
1440 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
1442 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1443 if (__pEdit->IsFullScreenKeypadEdit())
1445 __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
1449 __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
1451 __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
1452 __textObjectWrap = TEXT_OBJECT_WRAP_TYPE_NONE;
1456 __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
1457 __pTextObject->SetWrap(__textObjectWrap);
1460 __pTextString = new (std::nothrow) String;
1461 SysTryCatch(NID_UI_CTRL, __pTextString, , r = E_OUT_OF_MEMORY, "Unable to allocate text buffer.");
1464 if (__pFont == null)
1466 _ControlOrientation orientation = __pEdit->GetOrientation();
1467 float defaultFontSize = 0.0f;
1468 GET_SHAPE_CONFIG(EDIT::DEFAULT_FONT_SIZE, orientation, defaultFontSize);
1470 __contentFontSize = defaultFontSize;
1471 __contentFontStyle = FONT_STYLE_PLAIN;
1473 __pFont = __pEdit->GetFallbackFont();
1475 r = GetLastResult();
1476 SysTryReturn(NID_UI_CTRL, __pFont, r, r, "[%s] Propagating.", GetErrorMessage(r));
1478 __titleFontFaceName = __pFont->GetFaceName();
1480 __isFontInitialized = true;
1481 __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
1482 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
1485 __pScrollEffect = new (std::nothrow) _EditScrollEffectInfo;
1486 SysTryCatch(NID_UI_CTRL, __pScrollEffect, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create EditScrollEffectInfo");
1488 for (int i = 0; i < EDIT_SCROLLFRAME_MAX; i++)
1490 __pScrollEffect->touchScrollFrameLevel[i] = 2 + i;
1493 __pScrollEffect->previousY = -1.0f;
1494 __pScrollEffect->currentY = -1.0f;
1495 __pScrollEffect->previousX = -1.0f;
1496 __pScrollEffect->currentX = -1.0f;
1497 __pScrollEffect->previousAbsX = -1.0f;
1498 __pScrollEffect->currentAbsX = -1.0f;
1499 __pScrollEffect->previousAbsY = -1.0f;
1500 __pScrollEffect->currentAbsY = -1.0f;
1501 __pScrollEffect->cursorPosition = -1;
1503 pEditModel = new (std::nothrow) _EditModel;
1504 SysTryCatch(NID_UI_CTRL, pEditModel, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance");
1506 SetModel(*pEditModel);
1511 if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)
1513 SetViewModeEnabled(true);
1514 __isCutLinkParserEnabled = true;
1518 SetKeypadEnabled(true);
1519 __isCutLinkParserEnabled = false;
1522 if (__pEdit->GetInputStyle() == INPUT_STYLE_FULLSCREEN)
1524 SetCursorDisabled(true);
1527 __initialBounds = __pEdit->GetBoundsF();
1529 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
1531 __pCursorVisualElement = new (std::nothrow) _VisualElement;
1532 SysTryCatch(NID_UI_CTRL, __pCursorVisualElement, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance");
1534 r = __pCursorVisualElement->Construct();
1535 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r));
1537 __pCursorVisualElement->SetSurfaceOpaque(false);
1538 __pCursorVisualElement->SetImplicitAnimationEnabled(false);
1540 pEditVisualElement = __pEdit->GetVisualElement();
1541 SysTryCatch(NID_UI_CTRL, pEditVisualElement, , r = E_SYSTEM, "[E_SYSTEM] Unable to get root visual element.");
1543 __pCursorVisualElement->SetShowState(true);
1545 r = pEditVisualElement->AttachChild(*__pCursorVisualElement);
1546 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r));
1548 __pInputConnection = _InputConnectionImpl::CreateInputConnectionImplN(null);
1549 SysTryCatch(NID_UI_CTRL, __pInputConnection, , r = E_SYSTEM, "[E_SYSTEM] Unable to create an instance .");
1551 __pInputConnection->Initialize(*__pEdit, *this, *this);
1553 __pTextObject->SetBounds(__textObjectBounds);
1554 __pTextObject->HideRearSpace(TEXT_OBJECT_SPACE_HIDE_TYPE_NONE);
1556 __pEditVEDelegator = new (std::nothrow) _EditAnimationProvider();
1557 SysTryCatch(NID_UI_CTRL, __pEditVEDelegator, , E_OUT_OF_MEMORY, "Memory allocation failed.");
1559 pWindow = pControlManager->GetCurrentFrame();
1562 __pCurrentFrame = dynamic_cast<_Frame*>(pWindow);
1563 if (__pCurrentFrame)
1565 __pCurrentFrame->AddFrameEventListener(*this);
1569 __pClipboard = _Clipboard::GetInstance();
1573 __pClipboard->AddClipboardPopupEventListener(*this);
1584 _EditPresenter::InitializeAtFirstDrawing(void)
1586 result r = E_SUCCESS;
1590 InitializeParentPanel();
1592 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT);
1594 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false && (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE))
1596 AdjustFlexibleHeight();
1599 ReplaceTextIntoPasswordHyphenString();
1601 if (__pEdit->IsViewModeEnabled())
1603 __pEdit->SetCursorPosition(0);
1606 __isInitialized = true;
1612 _EditPresenter::DrawBackgroundBitmap(Canvas& canvas, bool focused)
1614 if (!DrawChangeableBackground(canvas, focused, 0, 0))
1623 _EditPresenter::DrawChangeableBackground(Canvas& canvas, bool focused, int bitmapId, int effectBitmapId, bool outLine, int outlineBitmapId)
1625 result r = E_SUCCESS;
1626 FloatRectangle editRect(0.0f, 0.0f, __pEdit->GetBoundsF().width, __pEdit->GetBoundsF().height);
1628 Bitmap* pEditBgBitmap = null;
1629 Bitmap* pEditBgEffectBitmap = null;
1630 Bitmap* pReplacementColorBackgroundBitmap = null;
1631 bool borderRoundEnable = __pEdit->IsBorderRoundStyleEnabled();
1632 EditStatus editStatus = GetCurrentStatus();
1634 pEditBgBitmap = __pEdit->GetDefaultBackgroundBitmap(editStatus);
1636 if (borderRoundEnable)
1638 pEditBgBitmap = null;
1639 r = GET_BITMAP_CONFIG_N(EDIT::BG_ROUND_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pEditBgBitmap);
1640 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap");
1643 bitmapColor = __pEdit->GetColor(editStatus);
1644 if (__groupStyle != GROUP_STYLE_NONE)
1646 GET_COLOR_CONFIG(PANEL::GROUPED_STYLE_BG_NORMAL, bitmapColor);
1649 pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pEditBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), bitmapColor);
1650 if (pReplacementColorBackgroundBitmap)
1652 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pReplacementColorBackgroundBitmap))
1654 canvas.DrawNinePatchedBitmap(editRect, *pReplacementColorBackgroundBitmap);
1658 canvas.DrawBitmap(editRect, *pReplacementColorBackgroundBitmap);
1662 if ((!__pEdit->IsFullScreenKeypadEdit() && __groupStyle != GROUP_STYLE_NONE) || GetSearchBarFlag())
1664 pEditBgEffectBitmap = __pEdit->GetDefaultBackgroundEffectBitmap();
1666 if (pEditBgEffectBitmap)
1668 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pEditBgEffectBitmap))
1670 canvas.DrawNinePatchedBitmap(editRect, *pEditBgEffectBitmap);
1674 canvas.DrawBitmap(editRect, *pEditBgEffectBitmap);
1679 if (borderRoundEnable)
1683 delete pEditBgBitmap;
1684 pEditBgBitmap = null;
1687 if (pEditBgEffectBitmap)
1689 delete pEditBgEffectBitmap;
1690 pEditBgEffectBitmap = null;
1693 delete pReplacementColorBackgroundBitmap;
1694 pReplacementColorBackgroundBitmap = null;
1698 delete pEditBgBitmap;
1704 _EditPresenter::DrawBackground(Canvas& canvas, bool drawTitleText)
1706 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
1708 return DrawSingleLineBackground(canvas, drawTitleText);
1711 FloatRectangle editRect(0.0f, 0.0f, __pEdit->GetBoundsF().width, __pEdit->GetBoundsF().height);
1713 EditStatus editStatus = GetCurrentStatus();
1715 Bitmap* pEditBgBitmap = __pEdit->GetBackgroundBitmap(editStatus);
1719 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pEditBgBitmap))
1721 canvas.DrawNinePatchedBitmap(editRect, *pEditBgBitmap);
1725 canvas.DrawBitmap(editRect, *pEditBgBitmap);
1730 DrawBackgroundBitmap(canvas, IsCurrentFocused());
1733 DrawFocusRing(canvas);
1737 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_TOP) || (__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_LEFT))
1747 _EditPresenter::DrawTitleText()
1749 result r = E_SUCCESS;
1750 if (__titleText == -1)
1756 TextObjectActionType titleAction;
1757 Canvas* pTitleTextCanvas = null;
1758 _VisualElement* pRootElement = __pEdit->GetVisualElement();
1759 SysTryReturn(NID_UI_CTRL, pRootElement, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get root visual element.");
1761 if (!__pTitleTextVisualElement)
1763 __pTitleTextVisualElement = new (std::nothrow) _VisualElement();
1764 SysTryReturnResult(NID_UI_CTRL, __pTitleTextVisualElement, E_OUT_OF_MEMORY, "Memory allocation failed.");
1766 r = __pTitleTextVisualElement->Construct();
1767 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r = E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to construct _VisualElement.");
1769 __pTitleTextVisualElement->SetImplicitAnimationEnabled(false);
1770 __pTitleTextVisualElement->SetShowState(true);
1772 r = pRootElement->AttachChild(*__pTitleTextVisualElement);
1773 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1776 __pTitleTextVisualElement->SetBounds(__titleBounds);
1778 pTitleTextCanvas = __pTitleTextVisualElement->GetCanvasN();
1779 SysTryCatch(NID_UI_CTRL, pTitleTextCanvas, , r, "[%s] Propagating.", GetErrorMessage(r));
1781 pTitleTextCanvas->SetBackgroundColor(Color(0));
1782 pTitleTextCanvas->Clear();
1784 titleAction = __pTitleTextObject->GetAction();
1785 if (IsCurrentFocused() == true)
1787 __pTitleTextObject->SetForegroundColor(__pEdit->GetTitleTextColor(EDIT_STATUS_HIGHLIGHTED), 0, __pTitleTextObject->GetTextLength());
1789 if (titleAction != __titleSlidingAction)
1791 __pTitleTextObject->SetAction(__titleSlidingAction);
1792 __pTitleTextObject->Compose();
1795 __pTitleTextObject->SetBounds(FloatRectangle(0.0f, 0.0f, __titleBounds.width, __titleBounds.height));
1796 __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pTitleTextCanvas));
1798 StopTitleSlidingTimer();
1799 if (__pTitleTextObject->IsActionOn() == true)
1801 StartTitleSlidingTimer();
1806 __pTitleTextObject->SetForegroundColor(__pEdit->GetTitleTextColor(GetCurrentStatus()), 0, __pTitleTextObject->GetTextLength());
1808 if (titleAction != TEXT_OBJECT_ACTION_TYPE_ABBREV)
1810 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1813 __pTitleTextObject->SetBounds(FloatRectangle(0.0f, 0.0f, __titleBounds.width, __titleBounds.height));
1814 __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pTitleTextCanvas));
1817 delete pTitleTextCanvas;
1822 __pTitleTextVisualElement->Destroy();
1823 __pTitleTextVisualElement = null;
1829 _EditPresenter::DrawText(void)
1831 Canvas* pCanvas = null;
1833 // In case of unfocused and touch moving
1834 if (__isTouchMoving && !__pTextVisualElement)
1836 result r = E_SUCCESS;
1837 __pTextVisualElement = new (std::nothrow) _VisualElement;
1838 SysTryReturnVoidResult(NID_UI_CTRL, __pTextVisualElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create __pTextVisualElement instance.");
1840 r = __pTextVisualElement->Construct();
1841 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r));
1843 __pTextVisualElement->SetSurfaceOpaque(false);
1844 __pTextVisualElement->SetImplicitAnimationEnabled(false);
1846 __pTextVisualElement->SetShowState(true);
1848 _VisualElement* pEditVisualElement = __pEdit->GetVisualElement();
1849 SysTryCatch(NID_UI_CTRL, pEditVisualElement, , r = E_SYSTEM, "[E_SYSTEM] Unable to get root visual element.");
1851 pEditVisualElement->AttachChild(*__pTextVisualElement);
1852 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r));
1854 pCanvas = __pEdit->GetCanvasN();
1855 SysTryCatch(NID_UI_CTRL, pCanvas, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance.");
1857 pCanvas->SetBackgroundColor(Color(0));
1858 r = pCanvas->Clear();
1859 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1861 DrawBackground(*pCanvas);
1867 if (__pTextVisualElement)
1869 FloatRectangle editBounds = __pEdit->GetBoundsF();
1870 __pTextVisualElement->SetOpacity(1.0f);
1871 __pTextVisualElement->SetBounds(FloatRectangle(0.0f, 0.0f, editBounds.width, editBounds.height));
1872 pCanvas = __pTextVisualElement->GetCanvasN();
1873 if (pCanvas == null)
1877 pCanvas->SetBackgroundColor(Color(0));
1882 if (__pEdit->GetEditStyle() & EDIT_STYLE_CLEAR)
1884 DrawClearIcon(*pCanvas);
1894 __pTextVisualElement->Destroy();
1895 __pTextVisualElement = null;
1907 _EditPresenter::DrawText(Canvas& canvas)
1909 result r = E_SUCCESS;
1911 if (__pEdit->GetEnableState() == false)
1913 __pTextObject->SetAlternateLookEnabled(true);
1914 Color tempColor = __pEdit->GetTextColor(EDIT_STATUS_DISABLED);
1915 __pTextObject->SetAlternativeForegroundColor(tempColor);
1919 __pTextObject->SetAlternateLookEnabled(false);
1923 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
1925 return DrawTextForEntireFontSetting(canvas);
1928 // initital guide text
1929 if (IsGuideTextActivated())
1931 __pGuideTextObject->SetForegroundColor(__pEdit->GetGuideTextColor(), 0, __pGuideTextObject->GetTextLength());
1933 if (__isGuideTextColorChanged == true && __pEdit->IsSettingGuideTextColor() == false)
1935 __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_NORMAL), 0, __pGuideTextObject->GetTextLength());
1936 __pGuideTextObject->SetBounds(__textObjectBounds);
1937 __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
1938 __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_DISABLED), 0, __pGuideTextObject->GetTextLength());
1939 __isGuideTextColorChanged = false;
1943 __pGuideTextObject->SetBounds(__textObjectBounds);
1944 __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
1948 if (GetTextLength() <= 0)
1954 EditStatus editStatus = GetCurrentStatus();
1956 __pTextObject->SetForegroundColor(__pEdit->GetTextColor(editStatus), 0, __pTextObject->GetTextLength());
1957 if (__isTextBlocked)
1959 __pTextObject->SetForegroundColor(__blockTextColor, __blockStartPos, __cursorPos - __blockStartPos);
1962 if (__isTextBlocked == true && editStatus == EDIT_STATUS_HIGHLIGHTED)
1964 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED), 0, __pTextObject->GetTextLength());
1965 __pTextObject->SetBlock(true);
1966 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
1968 else if (__isTextBlocked == true && editStatus == EDIT_STATUS_PRESSED)
1970 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_PRESSED), 0, __pTextObject->GetTextLength());
1971 __pTextObject->SetBlock(true);
1972 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
1974 else if (__isTextBlocked == true && editStatus == EDIT_STATUS_NORMAL)
1976 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_NORMAL), 0, __pTextObject->GetTextLength());
1977 __pTextObject->SetBlock(true);
1978 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
1982 __pTextObject->SetBlock(false);
1983 __isTextBlocked = false;
1986 UpdateComponentInformation();
1988 __pTextObject->SetBounds(__textObjectBounds);
1989 __pTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
1991 if (__isTextBlocked == true && editStatus == EDIT_STATUS_HIGHLIGHTED)
1993 __pTextObject->SetBackgroundColor(Color::GetColor(COLOR_ID_BLACK), 0, __pTextObject->GetTextLength());
1996 DrawTextBlockLine(canvas);
1998 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
2004 _EditPresenter::DrawTextBlockLine(Canvas& canvas)
2006 if (!__isTextBlocked)
2011 int lengthRange = 0;
2013 int columnIndex = -1;
2015 Color textBlockLineColor;
2016 GET_COLOR_CONFIG(EDIT::CURSOR_NORMAL, textBlockLineColor);
2018 GetBlockRange(startRange, lengthRange);
2020 FloatRectangle cursorBounds;
2021 FloatRectangle textObjectBounds = __textObjectBounds;
2022 textObjectBounds.x -= 1;
2023 textObjectBounds.width = textObjectBounds.width + 2;
2025 if (__pCopyPasteManager)
2027 __pCopyPasteManager->GetHandlerRowColumnIndex(false, true, rowIndex, columnIndex);
2030 if (rowIndex != -1 && columnIndex != -1)
2032 CalculateCursorBounds(__textObjectBounds, cursorBounds, rowIndex, columnIndex);
2036 CalculateCursorBounds(__textObjectBounds, cursorBounds, startRange);
2039 if (cursorBounds.x != -1)
2041 cursorBounds.x -= 1;
2042 cursorBounds = cursorBounds.GetIntersection(textObjectBounds);
2043 canvas.FillRectangle(textBlockLineColor, cursorBounds);
2049 if (__pCopyPasteManager)
2051 __pCopyPasteManager->GetHandlerRowColumnIndex(false, false, rowIndex, columnIndex);
2053 if (rowIndex != -1 && columnIndex != -1)
2055 CalculateCursorBounds(__textObjectBounds, cursorBounds, rowIndex, columnIndex);
2059 CalculateCursorBounds(__textObjectBounds, cursorBounds, lengthRange);
2062 if (cursorBounds.x != -1 && cursorBounds.x <= __textObjectBounds.x + __textObjectBounds.width)
2064 cursorBounds.x -= 1;
2065 cursorBounds = cursorBounds.GetIntersection(textObjectBounds);
2066 canvas.FillRectangle(textBlockLineColor, cursorBounds);
2071 _EditPresenter::DrawTextForEntireFontSetting(Canvas& canvas)
2073 result r = E_SUCCESS;
2075 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) && IsCurrentFocused() == false)
2077 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
2081 if (__pTextObject->GetAction() != TEXT_OBJECT_ACTION_TYPE_NONE)
2083 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE);
2084 __isCursorChanged = true;
2088 // initital guide text
2089 if (IsGuideTextActivated())
2091 __pGuideTextObject->SetForegroundColor(__pEdit->GetGuideTextColor(), 0, __pGuideTextObject->GetTextLength());
2093 if (__isGuideTextColorChanged == true && __pEdit->IsSettingGuideTextColor() == false)
2095 __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_NORMAL), 0, __pGuideTextObject->GetTextLength());
2096 __pGuideTextObject->SetBounds(__textObjectBounds);
2097 __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
2098 __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_DISABLED), 0, __pGuideTextObject->GetTextLength());
2099 __isGuideTextColorChanged = false;
2103 __pGuideTextObject->SetBounds(__textObjectBounds);
2104 __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
2108 if (GetTextLength() <= 0)
2114 EditStatus editStatus = GetCurrentStatus();
2116 if (IsCurrentFocused() == false)
2118 if (__isCursorChanged == true)
2120 if (AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT) == true)
2122 __pTextObject->Compose();
2125 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD))
2127 __pTextObject->SetFirstDisplayLineIndexFromTextIndex(0);
2129 __pTextObject->SetForegroundColor(__pEdit->GetTextColor(editStatus), 0, __pTextObject->GetTextLength());
2130 __pTextObject->SetBlock(false);
2135 int lengthRange = 0;
2137 __pTextObject->GetRange(startRange, lengthRange);
2138 __pTextObject->SetRange(0, GetTextLength());
2139 __pTextObject->SetForegroundColor(__pEdit->GetTextColor(editStatus), 0, __pTextObject->GetTextLength());
2140 if (__isTextBlocked)
2142 __pTextObject->SetForegroundColor(__blockTextColor, __blockStartPos, __cursorPos - __blockStartPos);
2145 if (IsBlocked() == true && editStatus == EDIT_STATUS_HIGHLIGHTED)
2147 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED), 0, __pTextObject->GetTextLength());
2148 __pTextObject->SetBlock(true);
2149 __pTextObject->SetRange(__blockStartPos, __cursorPos - __blockStartPos);
2151 else if (__isTextBlocked == true && editStatus == EDIT_STATUS_PRESSED)
2153 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_PRESSED), 0, __pTextObject->GetTextLength());
2154 __pTextObject->SetBlock(true);
2155 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
2157 else if (__isTextBlocked == true && editStatus == EDIT_STATUS_NORMAL)
2159 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_NORMAL), 0, __pTextObject->GetTextLength());
2160 __pTextObject->SetBlock(true);
2161 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
2165 __pTextObject->SetBlock(false);
2166 __isTextBlocked = false;
2169 UpdateComponentInformation();
2172 __pTextObject->SetBounds(__textObjectBounds);
2173 __pTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
2175 DrawTextBlockLine(canvas);
2181 _EditPresenter::DrawSingleLineBackground(Canvas& canvas, bool drawTitleText)
2183 FloatRectangle editField(0.0f, 0.0f, __pEdit->GetBoundsF().width, __pEdit->GetBoundsF().height);
2184 EditStatus editStatus = GetCurrentStatus();
2186 Bitmap* pEditBgBitmap = __pEdit->GetBackgroundBitmap(editStatus);
2190 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pEditBgBitmap))
2192 canvas.DrawNinePatchedBitmap(editField, *pEditBgBitmap);
2196 canvas.DrawBitmap(editField, *pEditBgBitmap);
2201 DrawSingleLineBackgroundBitmap(canvas, IsCurrentFocused());
2204 DrawFocusRing(canvas);
2208 if (((__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_LEFT) && !(__titleText.GetLength() == 0)) || (__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_TOP))
2219 _EditPresenter::DrawSingleLineBackgroundBitmap(Canvas& canvas, bool focused)
2221 if (__isTouchPressed)
2223 DrawChangeableBackground(canvas, focused, 0, 0);
2229 DrawChangeableBackground(canvas, focused, 0, 0, true, 0);
2233 bool tmpFocused = focused;
2234 DrawChangeableBackground(canvas, tmpFocused, 0, 0);
2242 _EditPresenter::DrawClearIcon(Canvas& canvas)
2244 result r = E_SUCCESS;
2246 float clearIconWidth = 0;
2247 float clearIconHeight = 0;
2249 _ControlOrientation orientation = __pEdit->GetOrientation();
2250 GET_SHAPE_CONFIG(EDIT::CLEAR_ICON_WIDTH, orientation, clearIconWidth);
2251 GET_SHAPE_CONFIG(EDIT::CLEAR_ICON_HEIGHT, orientation, clearIconHeight);
2253 if (__pTextString->GetLength() == 0)
2258 Bitmap* pEditBitmapClear = null;
2259 Bitmap* pEditReplacedBitmapClear = null;
2260 Color editClearIconColor;
2262 if (!__pEdit->IsEnabled())
2264 r = GET_BITMAP_CONFIG_N(EDIT::CLEAR_ICON_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pEditBitmapClear);
2266 if (pEditBitmapClear == null)
2271 GET_COLOR_CONFIG(EDIT::CLEAR_ICON_DISABLED, editClearIconColor);
2273 else if (__isClearIconPressed)
2275 r = GET_BITMAP_CONFIG_N(EDIT::CLEAR_ICON_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pEditBitmapClear);
2277 if (pEditBitmapClear == null)
2282 GET_COLOR_CONFIG(EDIT::CLEAR_ICON_PRESSED, editClearIconColor);
2286 r = GET_BITMAP_CONFIG_N(EDIT::CLEAR_ICON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pEditBitmapClear);
2287 if (pEditBitmapClear == null)
2292 GET_COLOR_CONFIG(EDIT::CLEAR_ICON_NORMAL, editClearIconColor);
2295 FloatRectangle textRect = __textObjectBounds;
2296 FloatRectangle afterClearIconRect(textRect.x + textRect.width, textRect.y + (textRect.height - clearIconHeight) / 2.0f, clearIconWidth, clearIconHeight);
2297 FloatRectangle editBounds = __pEdit->GetBoundsF();
2299 pEditReplacedBitmapClear = _BitmapImpl::GetColorReplacedBitmapN(*pEditBitmapClear, Color::GetColor(COLOR_ID_MAGENTA),
2300 editClearIconColor);
2301 SysTryCatch(NID_UI_CTRL, pEditReplacedBitmapClear, , r = E_SYSTEM, "[E_SYSTEM] Unable to create an instance .");
2303 if (__clearIconBounds != afterClearIconRect)
2305 __clearIconBounds = afterClearIconRect;
2306 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_CLEAR_ICON);
2309 if (editBounds.height < clearIconHeight)
2311 __clearIconBounds.y = textRect.y;
2314 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pEditReplacedBitmapClear))
2316 r = canvas.DrawNinePatchedBitmap(__clearIconBounds, *pEditReplacedBitmapClear);
2320 r = canvas.DrawBitmap(__clearIconBounds, *pEditReplacedBitmapClear);
2323 if (pEditBitmapClear)
2325 delete pEditBitmapClear;
2326 pEditBitmapClear = null;
2329 if (pEditReplacedBitmapClear)
2331 delete pEditReplacedBitmapClear;
2332 pEditReplacedBitmapClear = null;
2338 delete pEditBitmapClear;
2344 _EditPresenter::Draw(Canvas& canvas)
2346 result r = E_SUCCESS;
2348 if (__isInitialized == false)
2350 r = InitializeAtFirstDrawing();
2351 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Faild to initialize.");
2353 if (IsCurrentFocused() == true && __isInputConnectionBound == false)
2355 if (IsViewModeEnabled() == false)
2357 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
2363 ShowFullscreenKeypad();
2369 __isCursorOpaque = true;
2371 canvas.SetBackgroundColor(Color(0));
2373 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2375 DrawBackground(canvas);
2377 if (__pTextVisualElement)
2385 if (__pEdit->GetEditStyle() & EDIT_STYLE_CLEAR)
2387 DrawClearIcon(canvas);
2391 if (__rotated && !__clipboardConnected) // Command button should be relocated after rotation in case of no keypad.
2393 if (__isCopyPasteManagerExist)
2395 PostInternalEvent(String(L"ShowCopyPaste"));
2405 //To avoid resizing to Flexible bounds on User SetBounds in Non-focussed mode
2406 if (IsFocused() || (!__isAutoShrinkEnabled))
2408 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
2410 AdjustFlexibleHeight();
2412 if (__pEdit->HasFocusRing())
2414 __pEdit->RemoveFocusRing();
2415 __pEdit->OnDrawFocus();
2424 _EditPresenter::ConvertLinkType(void)
2426 if (__isCutLinkParserEnabled == false || IsViewModeEnabled() == false)
2431 unsigned long autoLinkMask = GetAutoLinkMask();
2432 bool isChangingCutLink = false;
2433 EditCutLinkType editLinkType = EDIT_LINK_TYPE_INVALID;
2434 TextCutLinkParser cutlinkParser;
2435 cutlinkParser.SetCutLinkMask(autoLinkMask);
2436 TextLinkInfo* pLinkInfo = cutlinkParser.Parse(__pTextBuffer, wcslen(__pTextBuffer), 0);
2437 TextLinkInfo* pNextLinkInfo = null;
2438 int cursorPos = __cursorPos;
2440 __isCutLinkParserEnabled = false;
2442 while (pLinkInfo != null)
2444 if (IsViewModeEnabled() == true)
2446 switch (pLinkInfo->linkType)
2449 if (autoLinkMask & LINK_TYPE_URL)
2451 isChangingCutLink = true;
2452 editLinkType = EDIT_LINK_TYPE_URL;
2456 case LINK_TYPE_EMAIL:
2457 if (autoLinkMask & LINK_TYPE_EMAIL)
2459 isChangingCutLink = true;
2460 editLinkType = EDIT_LINK_TYPE_URL;
2464 case LINK_TYPE_TEL_NUM:
2465 if (autoLinkMask & LINK_TYPE_TEL_NUM)
2467 isChangingCutLink = true;
2468 editLinkType = EDIT_LINK_TYPE_PHONE_NUM;
2473 editLinkType = EDIT_LINK_TYPE_INVALID;
2479 _Text::TextElement* pTextElement = __pTextObject->GetElementAtTextIndex(pLinkInfo->srcOffset);
2480 if (pTextElement != null && pTextElement->GetType() != TEXT_ELEMENT_TYPE_CUTLINK)
2482 pNextLinkInfo = pLinkInfo->pNextLinkInfo;
2484 pLinkInfo = pNextLinkInfo;
2489 wchar_t* pCutLinkString = null;
2490 result r = E_SUCCESS;
2492 pCutLinkString = new(std::nothrow) wchar_t[(pLinkInfo->length + 1) * sizeof(wchar_t)];
2494 if (!pCutLinkString)
2496 while (pLinkInfo != null)
2498 pNextLinkInfo = pLinkInfo->pNextLinkInfo;
2500 pLinkInfo = pNextLinkInfo;
2502 SysLog(NID_UI_CTRL, "[E_SYSTEM] Unable to allocate cutlink text buffer.");
2506 for (int i = 0; i < pLinkInfo->length; i++)
2508 pCutLinkString[i] = __pTextBuffer[pLinkInfo->srcOffset + i];
2510 pCutLinkString[pLinkInfo->length] = null;
2512 r = DeleteText(pLinkInfo->srcOffset, pLinkInfo->srcOffset + pLinkInfo->length);
2516 int currentLength = __pTextString->GetLength();
2517 int fullLength = currentLength + pLinkInfo->length;
2519 r = __pTextString->Insert(String(pCutLinkString), pLinkInfo->srcOffset);
2520 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2522 wchar_t pOriginalString[currentLength - pLinkInfo->srcOffset];
2524 // Save original text.
2525 for (int i = 0; i < currentLength - pLinkInfo->srcOffset; i++)
2527 pOriginalString[i] = __pTextBuffer[pLinkInfo->srcOffset + i];
2529 pOriginalString[currentLength - pLinkInfo->srcOffset] = 0;
2532 for (int i = 0; i < pLinkInfo->length; i++)
2534 __pTextBuffer[i + pLinkInfo->srcOffset] = pCutLinkString[i];
2537 // Append origianal text.
2538 for (int i = 0; i < currentLength - pLinkInfo->srcOffset; i++)
2540 __pTextBuffer[i + pLinkInfo->srcOffset + pLinkInfo->length] = pOriginalString[i];
2542 __pTextBuffer[fullLength] = 0;
2545 if (isChangingCutLink)
2547 TextCutLink* pCutLinkObject = null;
2548 EditCutlinkColor cutlinkColor;
2550 Font* pFont = _FontImpl::CloneN(const_cast <Font&>(*__pFont));
2551 SysTryReturnResult(NID_UI_CTRL, pFont, GetLastResult(), "Unable to get font.");
2553 _FontImpl* fontImpl = _FontImpl::GetInstance(*pFont);
2554 SysTryReturnResult(NID_UI_CTRL, fontImpl, GetLastResult(), "[E_SYSTEM] fontImpl is null.");
2555 fontImpl->SetUnderline(true);
2557 __pEdit->GetCutlinkColorInfo(editLinkType, &cutlinkColor);
2558 pCutLinkObject = new (std::nothrow) TextCutLink(false, pLinkInfo->linkType, pCutLinkString, pLinkInfo->length, TEXT_ELEMENT_SOURCE_TYPE_INTERNAL, pFont,
2559 cutlinkColor.cutlinkFgColor, cutlinkColor.cutlinkBgColor, 0);
2563 if (pCutLinkObject == null)
2565 SysLog(NID_UI_CTRL, "Unable to allocate cutlink object.");
2569 pCutLinkObject->SetEditModeEnable(true);
2570 __pTextObject->InsertElementAt(pLinkInfo->srcOffset, *pCutLinkObject);
2571 __pTextObject->ChangeTextOffset(__pTextBuffer, pLinkInfo->srcOffset, pLinkInfo->length);
2576 TextSimple* pSimpleText = null;
2577 pSimpleText = new (std::nothrow) TextSimple(pCutLinkString, pLinkInfo->length, TEXT_ELEMENT_SOURCE_TYPE_INTERNAL, GetFont());
2579 if (pSimpleText == null)
2581 SysLog(NID_UI_CTRL, "Unable to allocate text object.");
2586 __pTextObject->InsertElementAt(pLinkInfo->srcOffset, *pSimpleText);
2587 __pTextObject->ChangeTextOffset(__pTextBuffer, pLinkInfo->srcOffset, pSimpleText->GetTextLength());
2591 pNextLinkInfo = pLinkInfo->pNextLinkInfo;
2593 pLinkInfo = pNextLinkInfo;
2595 if (pCutLinkString != null)
2597 delete[] pCutLinkString;
2598 pCutLinkString = null;
2602 __pTextObject->Compose();
2604 bool isCursorChanged = __isCursorChanged;
2605 SetCursorPosition(cursorPos);
2606 __isCursorChanged = isCursorChanged;
2612 _EditPresenter::GetLinkElementOffsetInTextBuffer(int elementIndex) const
2614 const int textElementCount = __pTextObject->GetElementCount();
2615 SysTryReturn(NID_UI_CTRL, elementIndex >= 0 && elementIndex <= textElementCount, -1, E_OUT_OF_RANGE, "The Invalid argument is given.");
2617 _Text::TextElement* pTextElement = null;
2618 int elementOffset = -1;
2619 int elementLength = 0;
2623 for (int index = 0; index <= elementIndex; index++)
2625 pTextElement = __pTextObject->GetElementAtElementIndex(index);
2626 if (pTextElement == null)
2631 elementOffset = static_cast<int>(pTextElement->GetValue(SET_TEXT_OFFSET));
2632 elementLength = pTextElement->GetTextLength();
2634 if (pTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)
2636 elementOffset = prevOffset + prevLength;
2639 prevOffset = elementOffset;
2640 prevLength = elementLength;
2641 pTextElement = null;
2644 return elementOffset;
2648 _EditPresenter::IsTextBlockedInTokenEdit(void) const
2654 _EditPresenter::GetCursorPositionAt(const FloatPoint& touchPoint) const
2656 FloatPoint cursorPoint;
2659 FloatRectangle textObjectBounds = __textObjectBounds;
2661 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
2663 if (IsTextBlockedInTokenEdit())
2665 textObjectBounds = GetTextBoundsF();
2669 if (textObjectBounds.Contains(touchPoint))
2671 cursorPoint.x = touchPoint.x - textObjectBounds.x;
2672 cursorPoint.y = touchPoint.y - textObjectBounds.y;
2674 else if (__textBoxBounds.Contains(touchPoint))
2676 if (touchPoint.y <= textObjectBounds.y)
2678 cursorPoint.y = textObjectBounds.y + 1.0f;
2680 else if (touchPoint.y >= (textObjectBounds.y + textObjectBounds.height))
2682 cursorPoint.y = textObjectBounds.y + textObjectBounds.height - 1.0f;
2686 cursorPoint.y = touchPoint.y;
2689 if (touchPoint.x <= textObjectBounds.x)
2691 cursorPoint.x = textObjectBounds.x + 1.0f;
2693 else if (touchPoint.x >= (textObjectBounds.x + textObjectBounds.width))
2695 cursorPoint.x = textObjectBounds.x + textObjectBounds.width - 1.0f;
2699 cursorPoint.x = touchPoint.x;
2701 cursorPoint.y -= textObjectBounds.y;
2702 cursorPoint.x -= textObjectBounds.x;
2709 cursorPos = __pTextObject->GetTextIndexFromPosition(cursorPoint.x, cursorPoint.y);
2714 _EditPresenter::GetCursorPositionAt(const FloatPoint& touchPoint, int& rowIndex, int& columnIndex, bool isMoving)
2716 FloatPoint cursorPoint;
2719 FloatRectangle textObjectBounds = __textObjectBounds;
2721 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
2723 if (IsTextBlockedInTokenEdit())
2725 textObjectBounds = GetTextBoundsF();
2729 if (textObjectBounds.Contains(touchPoint))
2731 cursorPoint.x = touchPoint.x - textObjectBounds.x;
2732 cursorPoint.y = touchPoint.y - textObjectBounds.y;
2734 else if (__textBoxBounds.Contains(touchPoint) && !isMoving)
2736 if (touchPoint.y <= textObjectBounds.y)
2738 cursorPoint.y = textObjectBounds.y + 1.0f;
2740 else if (touchPoint.y >= (textObjectBounds.y + textObjectBounds.height))
2742 cursorPoint.y = textObjectBounds.y + textObjectBounds.height - 1.0f;
2746 cursorPoint.y = touchPoint.y;
2749 if (touchPoint.x <= textObjectBounds.x)
2751 cursorPoint.x = textObjectBounds.x + 1.0f;
2753 else if (touchPoint.x >= (textObjectBounds.x + textObjectBounds.width))
2755 cursorPoint.x = textObjectBounds.x + textObjectBounds.width - 1.0f;
2759 cursorPoint.x = touchPoint.x;
2761 cursorPoint.y -= textObjectBounds.y;
2762 cursorPoint.x -= textObjectBounds.x;
2769 cursorPos = __pTextObject->GetTextIndexFromPosition(cursorPoint.x, cursorPoint.y, rowIndex, columnIndex, true);
2775 _EditPresenter::IsHorizontalDirection(const _TouchInfo& touchInfo)
2777 if (touchInfo.GetTouchStatus() != _TOUCH_MOVED)
2782 if (__isMovingCursorByTouchMove)
2787 FloatRectangle absoluteEditRect = __pEdit->GetAbsoluteBoundsF(true);
2788 FloatPoint touchStartPoint = __pressedAbsolutePoint;
2789 //After internal touch core complete the float conversion, we need to change the code here
2790 FloatPoint touchPoint = touchInfo.GetCurrentPosition();
2792 float movedWidth = touchStartPoint.x - touchPoint.x - absoluteEditRect.x;
2793 float movedHeight = touchStartPoint.y - touchPoint.y - absoluteEditRect.y;
2794 movedWidth = (movedWidth >= 0.0f) ? movedWidth : -(movedWidth);
2795 movedHeight = (movedHeight >= 0.0f) ? movedHeight : -(movedHeight);
2797 if (movedWidth >= movedHeight * DIRECTION_DECISION_RATIO)
2806 _EditPresenter::IsInitialized(void) const
2808 return __isInitialized;
2812 _EditPresenter::CalculateCursorBounds(const FloatRectangle& textBounds, FloatRectangle& cursorBounds, int cursorPos)
2814 float cursorWidth = 0.0f;
2815 float cursorHeight = 0.0f;
2816 float cursorAbsX = 0.0f;
2817 float cursorAbsY = 0.0f;
2818 float cursorRelativeX = 0.0f;
2819 float cursorRelativeY = 0.0f;
2821 __pTextObject->SetBounds(textBounds);
2823 if (cursorPos == -1)
2825 cursorPos = __pTextObject->GetCursorIndex();
2828 if (cursorPos != __cursorPos)
2830 if (__pTextObject->GetTextPositionInfoAt(cursorPos, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
2837 if (__pTextObject->GetTextPositionInfoAt(__rowCursorIndex, __columnCursorIndex, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
2843 cursorBounds.x = cursorRelativeX;
2844 cursorBounds.y = cursorRelativeY;
2845 float cursorWidthValue = 0.0f;
2846 GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorWidthValue);
2847 cursorBounds.width = cursorWidthValue;
2848 cursorBounds.height = cursorHeight;
2850 if (cursorBounds.y == 0.0f)
2852 cursorBounds.y = __textObjectBounds.y;
2855 if (cursorBounds.height == 0.0f)
2857 cursorBounds.height = __textObjectBounds.height;
2860 if (cursorBounds.height == 0.0f)
2865 if (cursorBounds.y < textBounds.y)
2867 float cursorHeightDiff = textBounds.y - cursorBounds.y;
2868 cursorBounds.y = textBounds.y;
2869 cursorBounds.height -= cursorHeightDiff;
2872 if ((cursorBounds.y + cursorBounds.height > textBounds.y + textBounds.height) &&
2873 (cursorBounds.y < textBounds.y + textBounds.height))
2875 float cursorHeightDiff = cursorBounds.y + cursorBounds.height - textBounds.y - textBounds.height - 1.0f;
2876 if (cursorHeightDiff > 0.0f)
2878 cursorBounds.height -= cursorHeightDiff;
2882 cursorBounds.height += cursorHeightDiff;
2886 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
2888 if (__pTextObject->GetBlock() == false)
2890 cursorBounds.x -= 1.0f;
2893 if (cursorBounds.x > textBounds.x + textBounds.width)
2895 if (cursorBounds.x <= textBounds.x + textBounds.width + cursorBounds.width)
2897 cursorBounds.x = textBounds.x + textBounds.width;
2905 if (cursorBounds.x < textBounds.x)
2907 if (cursorBounds.x > textBounds.x - cursorBounds.width)
2909 cursorBounds.x = textBounds.x;
2919 if (cursorBounds.x == textBounds.x + textBounds.width)
2921 cursorBounds.x -= 1.0f;
2923 else if (cursorBounds.x > textBounds.x + textBounds.width)
2925 cursorBounds.x = textBounds.x + textBounds.width;
2929 if (__pTextObject->GetBlock() == false)
2931 cursorBounds.x -= 1.0f;
2932 if (cursorBounds.x < textBounds.x)
2934 cursorBounds.x = textBounds.x;
2938 __calculatedCursorBounds = cursorBounds;
2943 _EditPresenter::CalculateCursorBounds(const FloatRectangle& textBounds, FloatRectangle& cursorBounds, int rowIndex, int columnIndex)
2945 float cursorWidth = 0.0f;
2946 float cursorHeight = 0.0f;
2947 float cursorAbsX = 0.0f;
2948 float cursorAbsY = 0.0f;
2949 float cursorRelativeX = 0.0f;
2950 float cursorRelativeY = 0.0f;
2952 __pTextObject->SetBounds(textBounds);
2954 if (__pTextObject->GetTextPositionInfoAt(rowIndex, columnIndex, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
2959 cursorBounds.x = cursorRelativeX;
2960 cursorBounds.y = cursorRelativeY;
2961 float cursorWidthValue = 0.0f;
2962 GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorWidthValue);
2963 cursorBounds.width = cursorWidthValue;
2964 cursorBounds.height = cursorHeight;
2966 if (cursorBounds.y == 0.0f)
2968 cursorBounds.y = __textObjectBounds.y;
2971 if (cursorBounds.height == 0.0f)
2973 cursorBounds.height = __textObjectBounds.height;
2976 if (cursorBounds.height == 0.0f)
2981 if (cursorBounds.y < textBounds.y)
2983 float cursorHeightDiff = textBounds.y - cursorBounds.y;
2984 cursorBounds.y = textBounds.y;
2985 cursorBounds.height -= cursorHeightDiff;
2988 if ((cursorBounds.y + cursorBounds.height > textBounds.y + textBounds.height) &&
2989 (cursorBounds.y < textBounds.y + textBounds.height))
2991 float cursorHeightDiff = cursorBounds.y + cursorBounds.height - textBounds.y - textBounds.height - 1.0f;
2992 if (cursorHeightDiff > 0.0f)
2994 cursorBounds.height -= cursorHeightDiff;
2998 cursorBounds.height += cursorHeightDiff;
3002 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
3004 if (__pTextObject->GetBlock() == false)
3006 cursorBounds.x -= 1.0f;
3009 if (cursorBounds.x > textBounds.x + textBounds.width)
3011 if (cursorBounds.x <= textBounds.x + textBounds.width + cursorBounds.width)
3013 cursorBounds.x = textBounds.x + textBounds.width;
3021 if (cursorBounds.x < textBounds.x)
3023 if (cursorBounds.x > textBounds.x - cursorBounds.width)
3025 cursorBounds.x = textBounds.x;
3035 if (cursorBounds.x == textBounds.x + textBounds.width)
3037 cursorBounds.x -= 1.0f;
3039 else if (cursorBounds.x > textBounds.x + textBounds.width)
3041 cursorBounds.x = textBounds.x + textBounds.width;
3045 if (__pTextObject->GetBlock() == false)
3047 cursorBounds.x -= 1.0f;
3048 if (cursorBounds.x < textBounds.x)
3050 cursorBounds.x = textBounds.x;
3054 __calculatedCursorBounds = cursorBounds;
3059 _EditPresenter::ScrollContents(float moveY)
3062 float firstDisplayY = 0.0f;
3063 float effectDistance = moveY;
3065 float totalHeight = __pTextObject->GetTotalHeightF();
3066 float newFirstDisplayY = firstDisplayY = __pTextObject->GetFirstDisplayPositionYF();
3067 int currentCursorLine = 0;
3069 if (__pTextObject->GetTextLength() < 1)
3074 if (__pScrollBar && __pScrollBar->GetScrollPosition() == 0 && effectDistance < 0.0f)
3076 if (__pFlickAnimationTimer)
3081 __pScrollBar->SetScrollVisibility(false);
3085 else if (__pScrollBar && __pScrollBar->GetScrollPosition() != 0 && __pScrollBar->GetScrollPosition() == __previousScrollBarMaxPos && effectDistance > 0.0f)
3087 if (__pFlickAnimationTimer)
3092 __pScrollBar->SetScrollVisibility(false);
3097 if (__pTextObject->GetCursorIndex() == __pTextObject->GetTextLength())
3099 currentCursorLine = __pTextObject->GetTotalLineCount() - 1;
3103 currentCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
3106 if (currentCursorLine == -1)
3111 if (currentCursorLine < 0)
3113 currentCursorLine = 0;
3116 newFirstDisplayY += moveY;
3118 if (newFirstDisplayY > (totalHeight - __textObjectBounds.height))
3120 newFirstDisplayY = totalHeight - __textObjectBounds.height;
3123 if (newFirstDisplayY < 0.0f)
3125 newFirstDisplayY = 0.0f;
3128 moveLine = __pTextObject->GetLineIndexAtPositionY(newFirstDisplayY);
3130 __pTextObject->SetFirstDisplayLineIndex(moveLine);
3131 __pTextObject->SetFirstDisplayPositionY(newFirstDisplayY);
3133 __isCursorOpaque = false;
3134 if (__isCopyPasteManagerExist)
3136 __pCopyPasteManager->AdjustBounds();
3143 _EditPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
3145 if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
3150 if (__isCopyPasteManagerExist)
3152 __pCopyPasteManager->ReleaseCopyPastePopup();
3155 __isTouchPressed = true;
3156 __isTouchReleaseSkipped = false;
3158 __pScrollEffect->previousY = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().y);
3159 __pScrollEffect->currentY = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().y);
3160 __pScrollEffect->previousX = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().x);
3161 __pScrollEffect->currentX = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().x);
3163 __pScrollEffect->previousAbsX = _CoordinateSystemUtils::ConvertToFloat(__pEdit->GetAbsoluteBoundsF(true).x + touchInfo.GetCurrentPosition().x);
3164 __pScrollEffect->currentAbsX = _CoordinateSystemUtils::ConvertToFloat(__pEdit->GetAbsoluteBoundsF(true).x + touchInfo.GetCurrentPosition().x);
3165 __pScrollEffect->previousAbsY = _CoordinateSystemUtils::ConvertToFloat(__pEdit->GetAbsoluteBoundsF(true).y + touchInfo.GetCurrentPosition().y);
3166 __pScrollEffect->currentAbsY = _CoordinateSystemUtils::ConvertToFloat(__pEdit->GetAbsoluteBoundsF(true).y + touchInfo.GetCurrentPosition().y);
3168 __pScrollEffect->cursorPosition = GetCursorPosition();
3170 FloatRectangle absoluteEditRect = __pEdit->GetAbsoluteBoundsF(true);
3172 __pressedPoint = touchInfo.GetCurrentPosition();
3173 __pressedAbsolutePoint.x = __pressedPoint.x + absoluteEditRect.x;
3174 __pressedAbsolutePoint.y = __pressedPoint.y + absoluteEditRect.y;
3176 if (IsViewModeEnabled())
3178 int cutLinkIndex = -1;
3180 __pTextObject->ResetAllCutLinkElementsState();
3182 cutLinkIndex = __pTextObject->GetCutLinkIndexFromPositionData(__pressedPoint.x - __textObjectBounds.x, __pressedPoint.y - __textObjectBounds.y);
3184 if (cutLinkIndex != -1)
3186 __pTextObject->ChangeCutLinkState(cutLinkIndex, true);
3190 if (__pEdit->GetEditStyle() & EDIT_STYLE_CLEAR && __pTextString->GetLength() > 0)
3192 if ((__pressedPoint.x >= __clearIconBounds.x) && (__pressedPoint.x <= __clearIconBounds.x + __clearIconBounds.width)
3193 && (__pressedPoint.y >= __clearIconBounds.y) && (__pressedPoint.y <= __clearIconBounds.y + __clearIconBounds.height)) // Clear Icon Pressed
3195 __isClearIconPressed = true;
3196 __pEdit->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_IN_CLEAR_AREA);
3201 __pEdit->Invalidate();
3207 _EditPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
3209 if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
3214 if (__isClearIconPressed)
3216 __isClearIconPressed = false;
3217 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
3220 __isTouchPressed = false;
3221 __isMovingCursorByTouchMove = false;
3223 if (__isTouchReleaseSkipped || __isTouchMoving)
3225 __isTouchReleaseSkipped = false;
3227 __isTouchMoving = false;
3230 if (__isScrollBarVisible && __pScrollBar)
3232 if (__pScrollBar->IsVisible())
3234 __pScrollBar->SetScrollVisibility(false);
3236 __isScrollBarVisible = false;
3239 __isTouchMoving = false;
3240 __pEdit->Invalidate();
3246 _EditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
3248 if (__isCopyPasteManagerExist)
3250 if (__isTouchPressed && !__isCopyPastePopupMoving)
3252 InitializeCopyPasteManager();
3253 if (__isClearIconPressed)
3255 FloatPoint touchPoint = touchInfo.GetCurrentPosition();
3256 __isClearIconPressed = false;
3257 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
3258 if ((touchPoint.x >= __clearIconBounds.x) && (touchPoint.x <= __clearIconBounds.x + __clearIconBounds.width)
3259 && (touchPoint.y >= __clearIconBounds.y) && (touchPoint.y <= __clearIconBounds.y + __clearIconBounds.height))
3262 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
3263 __isMovingCursorByTouchMove = false;
3264 __pEdit->Invalidate();
3270 if (!IsCurrentFocused())
3272 __pEdit->SetFocused();
3274 __pCopyPasteManager->CreateCopyPastePopup();
3275 __pCopyPasteManager->Show();
3277 __isTouchPressed = false;
3278 __isCopyPastePopupMoving = false;
3283 if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
3288 int cutLinkIndex = -1;
3289 FloatRectangle clientBounds;
3290 FloatPoint touchPoint = touchInfo.GetCurrentPosition();
3292 if (__isClearIconPressed)
3294 __isClearIconPressed = false;
3295 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
3297 if ((touchPoint.x >= __clearIconBounds.x) && (touchPoint.x <= __clearIconBounds.x + __clearIconBounds.width)
3298 && (touchPoint.y >= __clearIconBounds.y) && (touchPoint.y <= __clearIconBounds.y + __clearIconBounds.height))
3301 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
3302 __isTouchPressed = false;
3303 __isMovingCursorByTouchMove = false;
3304 __pEdit->Invalidate();
3310 if (!__isCopyPasteManagerExist)
3312 __isTextBlocked = false;
3314 __isTouchPressed = false;
3315 __isMovingCursorByTouchMove = false;
3317 if (__isTouchReleaseSkipped)
3319 __isTouchReleaseSkipped = false;
3321 __isTouchMoving = false;
3322 __pEdit->Invalidate();
3327 if (__isTouchMoving && __isInputConnectionBound == false)
3330 __isTouchMoving = false;
3331 __isTouchReleaseSkipped = false;
3332 __pEdit->Invalidate();
3337 if (IsViewModeEnabled())
3339 __pEdit->SetFocused();
3341 __pTextObject->ResetAllCutLinkElementsState();
3343 cutLinkIndex = __pTextObject->GetCutLinkIndexFromPositionData(touchPoint.x - __textObjectBounds.x, touchPoint.y - __textObjectBounds.y);
3345 if (cutLinkIndex != -1)
3347 TextCutLink* pCutLinkObject = dynamic_cast<TextCutLink*>(__pTextObject->GetCutLinkElementAtCutLinkElementIndex(cutLinkIndex));
3348 if (pCutLinkObject == null)
3353 String cutLinkString(pCutLinkObject->GetText());
3354 LinkType baseLinkType = pCutLinkObject->GetCutLinkType();
3356 // Send Ui Link Event
3357 __pEdit->SendLinkEvent(cutLinkString, baseLinkType, cutLinkString);
3361 clientBounds = __pEdit->GetBoundsF();
3362 clientBounds.x = 0.0f;
3363 clientBounds.y = 0.0f;
3364 touchPoint = touchInfo.GetCurrentPosition();
3365 if (clientBounds.Contains(touchPoint))
3369 int cursorPos = GetCursorPositionAt(touchPoint, rowIndex,columnIndex);
3370 if (cursorPos != -1)
3372 if (__isInputConnectionBound == true && __isTextComposing == true)
3374 __pInputConnection->FinishTextComposition();
3376 if (!__isCopyPasteManagerExist) // Copy&Paste
3378 if ((__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) == true && IsCurrentFocused() == false)
3380 __isCursorChanged = true;
3384 SetCursorPosition(cursorPos, rowIndex, columnIndex);
3390 if ((__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) == false)
3392 SetCursorPosition(GetTextLength());
3397 if (!__isCopyPasteManagerExist && !__pFlickAnimationTimer)
3399 bool tokenEditting = false;
3400 bool needToCreatePopup = true;
3401 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
3403 _TokenEditPresenter* pTokenEditPresenter = dynamic_cast < _TokenEditPresenter* >(this);
3404 if (pTokenEditPresenter)
3406 if (pTokenEditPresenter->GetSelectedTokenIndex() != -1)
3408 tokenEditting = true;
3413 if (!__isUSBKeyboardConnected && !__isKeypadExist && !IsViewModeEnabled())
3415 needToCreatePopup = false;
3418 if (IsViewModeEnabled() && GetTextLength() == 0)
3420 needToCreatePopup = false;
3422 _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance();
3423 SysTryReturn(NID_UI_CTRL, pAccessibilityManager, false, E_SYSTEM, "pAccessibilityManager is null");
3424 if (pAccessibilityManager->IsActivated())
3426 needToCreatePopup = false;
3429 if (IsCurrentFocused() && !tokenEditting && needToCreatePopup)
3431 if (__pPasswordTimer)
3433 ChangePasswordToEchoCharacter(__pTextBuffer, __echoChar);
3434 StopPasswordTimer();
3436 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
3437 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, false, E_SYSTEM, "Unable to create _EditCopyPasteManager instance.");
3438 __pCopyPasteManager->AddCopyPasteEventListener(*this);
3439 __pCopyPasteManager->Show();
3440 __isCopyPasteManagerExist = true;
3444 if (cutLinkIndex < 0)
3446 CheckUSBKeyboardStatus();
3448 if (__isUSBKeyboardConnected)
3450 if (!__isInputConnectionBound)
3452 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
3454 if (IsViewModeEnabled() == false)
3456 if (IsCurrentFocused())
3462 __pEdit->SetFocused();
3468 if (__pEditModel->IsViewModeEnabled() == false) //in case of fullscreen style, should check editModel's viewMode
3470 ShowFullscreenKeypad();
3477 if (!__isKeypadExist || !__isInputConnectionBound)
3479 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
3481 if (IsViewModeEnabled() == false)
3483 if (IsCurrentFocused())
3489 __pEdit->SetFocused();
3495 if (__pEditModel->IsViewModeEnabled() == false) //in case of fullscreen style, should check editModel's viewMode
3497 ShowFullscreenKeypad();
3505 if (__isScrollBarVisible && __pScrollBar)
3507 if (__pScrollBar->IsVisible())
3509 __pScrollBar->SetScrollVisibility(false);
3511 __isScrollBarVisible = false;
3514 __isTouchMoving = false;
3515 __pEdit->Invalidate();
3517 if (GetSearchBarFlag())
3526 _EditPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
3528 if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
3533 FloatPoint touchPoint = touchInfo.GetCurrentPosition();
3535 if (__isClearIconPressed)
3537 if ((touchPoint.x < __clearIconBounds.x) || (touchPoint.x > __clearIconBounds.x + __clearIconBounds.width)
3538 || (touchPoint.y < __clearIconBounds.y) || (touchPoint.y > __clearIconBounds.y + __clearIconBounds.height))
3540 __isClearIconPressed = false;
3541 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
3542 __pEdit->Invalidate();
3546 if (__isCopyPasteManagerExist)
3548 __pCopyPasteManager->Show();
3549 if (!__isClearIconPressed)
3551 __isCopyPastePopupMoving = true;
3555 if (__isTouchMoving == false && IsHorizontalDirection(touchInfo))
3557 if (__isCopyPasteManagerExist && IsBlocked())
3562 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
3564 float horizontalGap = touchInfo.GetCurrentPosition().x - __pScrollEffect->currentX;
3565 FloatRectangle lineBounds = __pTextObject->GetBoundsAtLineF(0);
3566 float textDisplayPositionX = __pTextObject->GetFirstDisplayPositionXF();
3567 float newTextDisplayPositionX = 0;
3569 if (horizontalGap < 0.0f && lineBounds.width - textDisplayPositionX > __textObjectBounds.width)
3571 newTextDisplayPositionX = textDisplayPositionX - horizontalGap;
3573 if (newTextDisplayPositionX > lineBounds.width - __textObjectBounds.width)
3575 newTextDisplayPositionX = lineBounds.width - __textObjectBounds.width;
3578 __pScrollEffect->previousX = __pScrollEffect->currentX;
3579 __pScrollEffect->currentX = touchInfo.GetCurrentPosition().x;
3580 __isMovingCursorByTouchMove = true;
3581 __isTouchReleaseSkipped = true;
3584 __pTextObject->SetFirstDisplayPositionX(newTextDisplayPositionX);
3585 __pEdit->Invalidate();
3588 if (horizontalGap > 0.0f && textDisplayPositionX > 0)
3590 newTextDisplayPositionX = textDisplayPositionX - horizontalGap;
3591 if (newTextDisplayPositionX < 0)
3593 newTextDisplayPositionX = 0;
3596 __pScrollEffect->previousX = __pScrollEffect->currentX;
3597 __pScrollEffect->currentX = touchInfo.GetCurrentPosition().x;
3598 __isMovingCursorByTouchMove = true;
3599 __isTouchReleaseSkipped = true;
3602 __pTextObject->SetFirstDisplayPositionX(newTextDisplayPositionX);
3603 __pEdit->Invalidate();
3610 FloatRectangle fromBounds;
3611 FloatRectangle toBounds;
3612 CalculateCursorBounds(__textObjectBounds, fromBounds);
3613 newIndex = GetCursorPositionAt(touchInfo.GetCurrentPosition());
3616 if (Math::Abs(newIndex - __cursorPos) > 3)
3621 CalculateCursorBounds(__textObjectBounds, toBounds, newIndex);
3622 __isCursorChanged = true;
3623 SetCursorPosition(newIndex);
3625 __isMovingCursorByTouchMove = true;
3626 __isTouchReleaseSkipped = true;
3629 MoveCursor(fromBounds, toBounds);
3630 __pEdit->Invalidate();
3635 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
3637 float horizontalGap = touchInfo.GetCurrentPosition().x - fromBounds.x;
3638 FloatDimension currentCharacterDimension;
3639 if (horizontalGap > 0.0f && __cursorPos < GetTextLength())
3641 currentCharacterDimension = __pTextObject->GetTextExtentF(__cursorPos, 1);
3642 if (horizontalGap >= currentCharacterDimension.width)
3644 SetCursorPosition(__cursorPos+1);
3645 __pEdit->Invalidate();
3649 if (horizontalGap < 0.0f && __cursorPos > 0)
3651 currentCharacterDimension = __pTextObject->GetTextExtentF(__cursorPos-1, 1);
3652 if (Math::Abs(horizontalGap) >= currentCharacterDimension.width)
3654 SetCursorPosition(__cursorPos-1);
3655 __pEdit->Invalidate();
3661 if (__isMovingCursorByTouchMove)
3667 float totalHeight = __pTextObject->GetTotalHeightF();
3671 if (__textObjectBounds.height >= totalHeight)
3673 __isTouchMoving = true;
3674 __isTouchReleaseSkipped = true;
3679 if ((touchInfo.GetCurrentPosition().y == __pScrollEffect->currentY) ||
3680 (Math::Abs(touchInfo.GetCurrentPosition().y - __pScrollEffect->previousY) < MOVE_SKIP_DECISION_RANGE))
3685 __pScrollEffect->previousY = __pScrollEffect->currentY;
3686 __pScrollEffect->currentY = touchInfo.GetCurrentPosition().y;
3688 __pScrollEffect->previousAbsY = __pScrollEffect->currentAbsY;
3689 __pScrollEffect->currentAbsY = _CoordinateSystemUtils::ConvertToFloat(__pEdit->GetAbsoluteBoundsF(true).y + touchInfo.GetCurrentPosition().y);
3691 // float moveGap = __pScrollEffect->previousY - __pScrollEffect->currentY;
3692 float moveGap = __pScrollEffect->previousAbsY - __pScrollEffect->currentAbsY;
3694 if (__isMovingCursorByTouchMove)
3696 __isMovingCursorByTouchMove = false;
3699 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_NOSCROLL) && !(__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN))
3703 if (totalHeight > __textObjectBounds.height)
3705 __pScrollBar->SetScrollVisibility(true);
3709 __pScrollBar->SetScrollVisibility(false);
3714 result returnResult = ScrollContents(moveGap);
3716 __isCursorChanged = false;
3717 __isTouchMoving = true;
3721 if (returnResult == E_SUCCESS)
3727 __isTouchReleaseSkipped = true;
3733 _EditPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
3735 result r = E_SUCCESS;
3736 _KeyCode keyCode = keyInfo.GetKeyCode();
3740 FloatRectangle panelAbsBounds(0.0f, 0.0f, 0.0f, 0.0f);
3741 FloatRectangle absCursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
3743 _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance();
3744 SysTryReturn(NID_UI_CTRL, pAccessibilityManager, false, E_SYSTEM, "pAccessibilityManager is null");
3746 if (__pEditModel->IsViewModeEnabled() == false)
3748 if (__pEdit->GetInputStyle() == INPUT_STYLE_FULLSCREEN)
3750 if (_KEY_ENTER == keyCode)
3752 CheckUSBKeyboardStatus();
3753 if (__isUSBKeyboardConnected)
3755 ShowFullscreenKeypad();
3767 if (__isUSBKeyboardConnected && (keyInfo.GetKeyModifier() & _KEY_MODIFIER_CTRL) && (keyInfo.GetKeyModifier() & _KEY_MODIFIER_SHIFT))
3769 if ((keyCode == _KEY_LEFT) || (keyCode == _KEY_RIGHT))
3771 if (!__isCopyPasteManagerExist)
3773 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
3775 _TokenEditPresenter* pTokenEditPresenter = dynamic_cast < _TokenEditPresenter* >(this);
3776 if (pTokenEditPresenter)
3778 if (pTokenEditPresenter->GetSelectedTokenIndex() != -1)
3784 SetBlockRangeWithCtrlShiftArrowkey(keyCode);
3789 if (__pCopyPasteManager->IsCopyPasteSingleHandleExist())
3791 InitializeCopyPasteManager();
3792 SetBlockRangeWithShiftArrowkey(keyCode);
3798 else if (__isUSBKeyboardConnected && (keyInfo.GetKeyModifier() & _KEY_MODIFIER_CTRL))
3803 FinishTextComposition();
3805 if (__isCopyPasteManagerExist)
3807 InitializeCopyPasteManager();
3810 textLength = __pEdit->GetTextLength();
3815 __pEdit->SetBlockRange(0, textLength);
3816 r = __pEdit->SendTextBlockEvent(0, textLength);
3817 UpdateComponentInformation();
3818 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r));
3820 if (!pAccessibilityManager->IsActivated())
3822 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
3823 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, true, E_OUT_OF_MEMORY, "Unable to create _EditCopyPasteManager instance.");
3824 __pCopyPasteManager->AddCopyPasteEventListener(*this);
3825 __pCopyPasteManager->CreateCopyPastePopup();
3826 __pCopyPasteManager->Show();
3827 __isCopyPasteManagerExist = true;
3832 textLength = __pEdit->GetTextLength();
3838 if (__isCopyPasteManagerExist)
3840 InitializeCopyPasteManager();
3844 textLength = __pEdit->GetTextLength();
3850 if (__isCopyPasteManagerExist)
3852 InitializeCopyPasteManager();
3857 if (__isCopyPasteManagerExist)
3859 InitializeCopyPasteManager();
3862 case _KEY_HOME_BUTTON:
3863 if (__isCopyPasteManagerExist)
3865 InitializeCopyPasteManager();
3867 if (__cursorPos != 0)
3869 SetCursorPosition(0);
3876 case _KEY_END_BUTTON:
3877 if (__isCopyPasteManagerExist)
3879 InitializeCopyPasteManager();
3881 if (__cursorPos != GetTextLength())
3883 SetCursorPosition(GetTextLength());
3891 if (__isCopyPasteManagerExist)
3893 InitializeCopyPasteManager();
3895 if (__cursorPos == 0)
3899 GetWordPosition(__cursorPos, start, end);
3900 if (__cursorPos != start)
3902 SetCursorPosition(start);
3906 GetWordPosition(start-1, start, end);
3907 SetCursorPosition(start);
3911 if (__isCopyPasteManagerExist)
3913 InitializeCopyPasteManager();
3915 if (__cursorPos == GetTextLength())
3919 GetWordPosition(__cursorPos, start, end);
3920 if (__cursorPos != end)
3922 SetCursorPosition(end);
3926 GetWordPosition(end+1, start, end);
3927 SetCursorPosition(end);
3933 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
3939 __pEdit->Invalidate();
3944 else if (__isUSBKeyboardConnected && keyInfo.GetKeyModifier() & _KEY_MODIFIER_SHIFT)
3946 if (!__isCopyPasteManagerExist)
3948 if ( (keyCode == _KEY_LEFT) || (keyCode == _KEY_UP) || (keyCode == _KEY_DOWN) || (keyCode == _KEY_RIGHT) )
3950 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
3952 _TokenEditPresenter* pTokenEditPresenter = dynamic_cast < _TokenEditPresenter* >(this);
3953 if (pTokenEditPresenter)
3955 if (pTokenEditPresenter->GetSelectedTokenIndex() != -1)
3961 SetBlockRangeWithShiftArrowkey(keyCode);
3971 if (__pCopyPasteManager->IsCopyPasteSingleHandleExist())
3973 InitializeCopyPasteManager();
3974 SetBlockRangeWithShiftArrowkey(keyCode);
3982 __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_LEFT);
3985 __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_UP);
3988 __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_DOWN);
3991 __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_RIGHT);
3998 else if (_KEY_END_BUTTON == keyCode || _KEY_HOME_BUTTON == keyCode)
4000 if (__isCopyPasteManagerExist)
4002 InitializeCopyPasteManager();
4005 FinishTextComposition();
4007 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
4008 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine);
4010 if (_KEY_HOME_BUTTON == keyCode)
4012 if(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
4014 if (__cursorPos != 0)
4016 SetCursorPosition(0);
4025 SetCursorPosition(firstTextIndex);
4028 else if (_KEY_END_BUTTON == keyCode)
4030 if(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
4032 if (__cursorPos != GetTextLength())
4034 SetCursorPosition(GetTextLength());
4043 int totalLine = __pTextObject->GetTotalLineCount();
4044 if (curCursorLine < totalLine - 1)
4046 int nextLinefirstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
4047 SetCursorPosition(nextLinefirstTextIndex-1);
4051 if (__cursorPos != GetTextLength())
4053 SetCursorPosition(GetTextLength());
4064 else if (_KEY_ENTER == keyCode || _KEY_NUMPAD_ENTER == keyCode)
4066 if (__isInputConnectionBound != false && __isTextComposing != false)
4072 if (IsKeypadActionEnabled())
4074 char enterText[2] = {'\n', };
4075 OnTextCommitted(String(enterText));
4081 else if (_KEY_BACKSPACE == keyCode)
4083 if (__isTextComposing == false)
4085 if (__isCopyPasteManagerExist)
4089 __pCopyPasteManager->SetTextBlockReleaseFlag(false);
4091 InitializeCopyPasteManager();
4094 OnSurroundingTextDeleted(-1, 1);
4095 if (AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT) == true)
4097 __pTextObject->Compose();
4098 __pEdit->Invalidate();
4100 ScrollPanelToCursorPosition();
4104 else if ((keyInfo.GetKeyModifier() & _KEY_LOCK_NUM) && (_KEY_NUMPAD_4 == keyCode || _KEY_NUMPAD_6 == keyCode || _KEY_NUMPAD_8 == keyCode || _KEY_NUMPAD_2 == keyCode))
4108 else if (_KEY_LEFT == keyCode || _KEY_NUMPAD_4 == keyCode)
4110 if (__isCopyPasteManagerExist)
4112 InitializeCopyPasteManager();
4115 FinishTextComposition();
4117 if (__cursorPos != 0)
4119 int startPosition = -1;
4120 int endPosition = -1;
4121 GetTextImageRangeAt(__cursorPos-1, startPosition, endPosition);
4122 if (endPosition > -1 && startPosition >= 0 && startPosition < __cursorPos-1)
4124 SetCursorPosition(startPosition);
4128 SetCursorPosition(__cursorPos-1);
4133 panelAbsBounds = __pParentPanel->GetAbsoluteBoundsF(true);
4134 GetCursorBounds(true, absCursorBounds);
4136 if (!panelAbsBounds.Contains(FloatPoint(absCursorBounds.x, absCursorBounds.y + absCursorBounds.height)))
4138 ScrollPanelToCursorPosition();
4142 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4148 __pEdit->Invalidate();
4157 else if (_KEY_UP == keyCode || _KEY_NUMPAD_8 == keyCode)
4159 if (__isCopyPasteManagerExist)
4161 InitializeCopyPasteManager();
4164 FinishTextComposition();
4166 if (GetTextLength() == 0)
4171 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
4172 if (curCursorLine !=0 )
4174 int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
4175 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine-1);
4176 int newCursorPosition = offset + firstTextIndex;
4177 int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
4178 if (offset<textLength)
4180 int startPosition = -1;
4181 int endPosition = -1;
4182 GetTextImageRangeAt(newCursorPosition, startPosition, endPosition);
4183 if (endPosition > newCursorPosition && startPosition < newCursorPosition)
4185 newCursorPosition = endPosition;
4187 SetCursorPosition(newCursorPosition);
4192 __pTextString->GetCharAt(firstTextIndex+textLength - 1, ch);
4195 SetCursorPosition(firstTextIndex+textLength - 1);
4199 SetCursorPosition(firstTextIndex+textLength);
4205 panelAbsBounds = __pParentPanel->GetAbsoluteBoundsF(true);
4206 GetCursorBounds(true, absCursorBounds);
4207 if (!panelAbsBounds.Contains(FloatPoint(absCursorBounds.x, absCursorBounds.y)))
4209 ScrollPanelToCursorPosition();
4212 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4223 else if (_KEY_DOWN == keyCode || _KEY_NUMPAD_2 == keyCode)
4225 if (__isCopyPasteManagerExist)
4227 InitializeCopyPasteManager();
4230 FinishTextComposition();
4232 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
4233 int totalLine = __pTextObject->GetTotalLineCount();
4234 if (curCursorLine < totalLine - 1)
4236 int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
4237 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
4238 int newCursorPosition = offset + firstTextIndex;
4239 int textLength = __pTextObject->GetTextLengthAt(curCursorLine+1);
4241 if (offset<textLength)
4243 int startPosition = -1;
4244 int endPosition = -1;
4245 GetTextImageRangeAt(newCursorPosition, startPosition, endPosition);
4246 if (endPosition > newCursorPosition && startPosition < newCursorPosition)
4248 newCursorPosition = endPosition;
4250 SetCursorPosition(newCursorPosition);
4255 __pTextString->GetCharAt(firstTextIndex+textLength - 1, ch);
4258 if (textLength == 0)
4260 SetCursorPosition(firstTextIndex);
4264 SetCursorPosition(firstTextIndex+textLength - 1);
4269 SetCursorPosition(firstTextIndex+textLength);
4275 panelAbsBounds = __pParentPanel->GetAbsoluteBoundsF(true);
4276 GetCursorBounds(true, absCursorBounds);
4278 if (!panelAbsBounds.Contains(FloatPoint(absCursorBounds.x, absCursorBounds.y + absCursorBounds.height)))
4280 ScrollPanelToCursorPosition();
4283 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4294 else if (_KEY_RIGHT == keyCode || _KEY_NUMPAD_6 == keyCode)
4296 if (__isCopyPasteManagerExist)
4298 InitializeCopyPasteManager();
4301 FinishTextComposition();
4303 if (__cursorPos == GetTextLength())
4308 if (__cursorPos < GetTextLength())
4310 int startPosition = -1;
4311 int endPosition = -1;
4312 GetTextImageRangeAt(__cursorPos, startPosition, endPosition);
4313 if (endPosition > __cursorPos+1 && startPosition > -1)
4315 SetCursorPosition(endPosition);
4319 SetCursorPosition(__cursorPos+1);
4324 panelAbsBounds = __pParentPanel->GetAbsoluteBoundsF(true);
4325 GetCursorBounds(true, absCursorBounds);
4327 if (!panelAbsBounds.Contains(FloatPoint(absCursorBounds.x, absCursorBounds.y + absCursorBounds.height)))
4329 ScrollPanelToCursorPosition();
4333 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4339 __pEdit->Invalidate();
4344 else if (_KEY_DELETE == keyCode)
4346 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4348 if (!GetTextLength())
4354 if (__isCopyPasteManagerExist)
4356 if (IsBlocked() == true)
4360 GetBlockRange(start, end);
4361 DeleteText(start, end);
4366 int cursorPosition = GetCursorPosition();
4367 DeleteText(cursorPosition, cursorPosition+1);
4370 InitializeCopyPasteManager();
4374 FinishTextComposition();
4376 int cursorPosition = GetCursorPosition();
4377 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4379 DeleteText(cursorPosition, cursorPosition+1);
4383 OnSurroundingTextDeleted(0, 1);
4386 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4392 __pEdit->Invalidate();
4394 ScrollPanelToCursorPosition();
4398 else if (_KEY_OEM_1 == keyCode)
4400 __pClipboard->ShowPopup(CLIPBOARD_DATA_TYPE_TEXT, *__pEdit, true);
4401 __clipboardConnected = true;
4404 else if (__composingTextLength > 0 && GetTextLength() >= __limitLength)
4408 else if (_KEY_TAB == keyCode)
4410 if (__isCopyPasteManagerExist)
4412 InitializeCopyPasteManager();
4413 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4419 __pEdit->Invalidate();
4429 _EditPresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
4431 _KeyCode keyCode = keyInfo.GetKeyCode();
4433 if (__isUSBKeyboardConnected && (keyCode == _KEY_SHIFT_L || keyCode == _KEY_SHIFT_R))
4435 if (__pCopyPasteManager && __pCopyPasteManager->IsHandlerMovingEnabled())
4437 __pCopyPasteManager->SetHandlerMovingEnabled(false);
4438 __pCopyPasteManager->CreateCopyPastePopup();
4439 __pCopyPasteManager->Show();
4441 else if (__textBlockMoving)
4443 _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance();
4444 SysTryReturn(NID_UI_CTRL, pAccessibilityManager, false, E_SYSTEM, "pAccessibilityManager is null");
4445 if (!pAccessibilityManager->IsActivated())
4447 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
4448 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, true, E_OUT_OF_MEMORY, "Unable to create _EditCopyPasteManager instance.");
4449 __pCopyPasteManager->AddCopyPasteEventListener(*this);
4450 __pCopyPasteManager->CreateCopyPastePopup();
4451 __pCopyPasteManager->Show();
4452 __isCopyPasteManagerExist = true;
4454 __textBlockMoving = false;
4463 _EditPresenter::OnClipboardPopupClosed(const ClipboardItem* pClipboardItem)
4469 String filteredString;
4471 if (!pClipboardItem && IsBlocked())
4476 if (__isCopyPasteManagerExist)
4480 __pCopyPasteManager->SetTextBlockReleaseFlag(false);
4482 InitializeCopyPasteManager();
4485 SysTryReturnVoidResult(NID_UI_CTRL, pClipboardItem != null, E_SYSTEM, "[E_SYSTEM] _EditPresenter::OnClipboardPopupClosed: Unable to get the clipboarditem instance.");
4487 String* pClipString = dynamic_cast<String*>(pClipboardItem->GetData());
4488 SysTryReturnVoidResult(NID_UI_CTRL, pClipString != null, E_SYSTEM, "[E_SYSTEM] _EditPresenter::OnClipboardPopupClosed: Unable to get the clipboarditem instance.");
4491 if (pClipboardItem->GetDataType() == CLIPBOARD_DATA_TYPE_HTML)
4493 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
4496 str = pEcoreEvas->ConvertMarkupToUtf8(*pClipString);
4501 int currentLength = GetTextLength();
4502 String* pSubString = null;
4503 result r = E_SUCCESS;
4505 filteredString = *pClipString;
4509 if(__pTextFilter->ValidatePastedText(*pClipString, userString))
4511 filteredString = userString;
4512 SysLog(NID_UI_CTRL, "ClipString was changed by User");
4515 else if (IsUnsupportedChracterExist(GetKeypadStyle(), *pClipString) == true)
4522 GetBlockRange(start, end);
4523 total = currentLength - (end - start) + filteredString.GetLength();
4524 if (total > __limitLength)
4526 DeleteText(start, end);
4528 pSubString = new String(__limitLength - currentLength + (end - start));
4529 SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "Unable to allocate text buffer.");
4531 filteredString.SubString(0, __limitLength - currentLength + (end - start), *pSubString);
4532 r = InsertTextAt(__cursorPos, pSubString->GetPointer());
4533 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4538 DeleteText(start, end);
4540 r = InsertTextAt(__cursorPos, filteredString.GetPointer());
4541 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4544 else if (currentLength + filteredString.GetLength() > __limitLength)
4546 if (__limitLength == currentLength)
4548 delete pClipboardItem;
4552 pSubString = new String(__limitLength - currentLength);
4553 SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "Unable to allocate text buffer.");
4555 filteredString.SubString(0, __limitLength - currentLength, *pSubString);
4556 r = InsertTextAt(__cursorPos, pSubString->GetPointer());
4557 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4562 r = InsertTextAt(__cursorPos, filteredString.GetPointer());
4563 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4566 ScrollPanelToCursorPosition();
4568 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
4570 __pEdit->Invalidate();
4572 delete pClipboardItem;
4577 delete pClipboardItem;
4583 _EditPresenter::OnLongPressGestureDetected(void)
4585 SysLog(NID_UI_CTRL, "OnLongPressGestureDetected");
4587 if (__isClearIconPressed)
4592 __isTouchPressed = false;
4594 _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance();
4595 SysTryReturn(NID_UI_CTRL, pAccessibilityManager, false, E_SYSTEM, "pAccessibilityManager is null");
4596 if (pAccessibilityManager->IsActivated())
4598 SysLog(NID_UI_CTRL, "Copy&Paste is not created (ScreenReader is activated)");
4602 if (__isCopyPasteManagerExist)
4606 else if (IsCurrentFocused() == false)
4608 if (IsViewModeEnabled())
4610 __pEdit->SetFocused();
4618 FloatRectangle cursorBounds;
4619 InitializeCopyPasteManager();
4620 if (IsClipped() || GetTextLength())
4622 if (IsClipped() && !GetTextLength() && (__pEdit->IsViewModeEnabled()))
4627 if (!IsClipped() && (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD))
4632 FinishTextComposition();
4634 if (__pPasswordTimer)
4636 ChangePasswordToEchoCharacter(__pTextBuffer, __echoChar);
4637 StopPasswordTimer();
4640 int cursorPos = GetCursorPositionAt(__pressedPoint);
4641 if (cursorPos != -1)
4643 SetCursorPosition(cursorPos);
4647 cursorPos = GetTextLength();
4648 SetCursorPosition(cursorPos);
4650 ScrollPanelToCursorPosition();
4651 GetCursorBounds(true, cursorBounds);
4653 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
4654 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, false, E_SYSTEM, "Unable to create _EditCopyPasteManager instance.");
4655 __pCopyPasteManager->AddCopyPasteEventListener(*this);
4656 __pCopyPasteManager->Show();
4657 __isCopyPasteManagerExist = true;
4665 _EditPresenter::OnTapGestureDetected(void)
4667 SysLog(NID_UI_CTRL, "OnTapGestureDetected");
4669 _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance();
4670 SysTryReturn(NID_UI_CTRL, pAccessibilityManager, false, E_SYSTEM, "pAccessibilityManager is null");
4671 if (pAccessibilityManager->IsActivated())
4673 SysLog(NID_UI_CTRL, "Copy&Paste is not created (ScreenReader is activated)");
4677 if (IsCurrentFocused() == false)
4682 if (!__isUSBKeyboardConnected)
4684 if (__isKeypadShowing)
4688 __isTouchPressed = false;
4689 InitializeCopyPasteManager();
4691 if (GetTextLength() > 0)
4693 FloatRectangle cursorBounds;
4696 int cursorPos = GetCursorPositionAt(__pressedPoint);
4698 if (cursorPos == -1)
4700 cursorPos = GetTextLength();
4704 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(cursorPos);
4705 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine);
4706 if (cursorPos != 0 && cursorPos == firstTextIndex && __rowCursorIndex != curCursorLine)
4712 FinishTextComposition();
4714 GetWordPosition(cursorPos, start, end);
4715 SetBlockRange(start, end);
4716 ScrollPanelToCursorPosition();
4717 GetCursorBounds(true, cursorBounds);
4719 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
4720 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, false, E_SYSTEM, "Unable to create _EditCopyPasteManager instance.");
4721 __pCopyPasteManager->AddCopyPasteEventListener(*this);
4722 __pCopyPasteManager->Show();
4723 __isCopyPasteManagerExist = true;
4732 _EditPresenter::GetTextAlignment(void) const
4734 return __horizontalAlignment;
4738 _EditPresenter::GetLineSpacing(void) const
4740 int linePixelGap = -1;
4742 linePixelGap = __pTextObject->GetLineSpace();
4744 return linePixelGap;
4748 _EditPresenter::GetLineSpacingF(void) const
4750 float linePixelGap = -1.0;
4752 linePixelGap = __pTextObject->GetLineSpaceF();
4754 return linePixelGap;
4758 _EditPresenter::GetBlockRange(int& start, int& end) const
4760 if (__isTextBlocked == false || __cursorPos == __blockStartPos)
4765 if (__cursorPos > __blockStartPos)
4767 start = __blockStartPos;
4772 start = __cursorPos;
4773 end = __blockStartPos;
4780 _EditPresenter::SetBlockRange(int start, int end)
4782 result r = E_SUCCESS;
4784 r = SetCursorPosition(start);
4785 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4787 r = BeginTextBlock();
4788 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4790 r = SetCursorPosition(end);
4791 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4797 _EditPresenter::SetBlockRange(int start, int end, int leftRowIndex, int leftColumnIndex, int rightRowIndex, int rightColumnIndex)
4799 result r = E_SUCCESS;
4801 if (leftRowIndex == -1 && leftColumnIndex == -1)
4803 r = SetCursorPosition(start);
4807 r = SetCursorPosition(start, leftRowIndex, leftColumnIndex);
4809 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4811 r = BeginTextBlock();
4812 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4814 if (rightRowIndex == -1 && rightColumnIndex == -1)
4816 r = SetCursorPosition(end);
4820 r = SetCursorPosition(end, rightRowIndex, rightColumnIndex);
4822 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4828 _EditPresenter::BeginTextBlock(void)
4830 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
4833 __isTextBlocked = true;
4834 __blockStartPos = __cursorPos;
4840 _EditPresenter::ReleaseTextBlock(void)
4842 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
4846 if (__isTextBlocked == false)
4851 __isTextBlocked = false;
4857 _EditPresenter::IsBlocked(void) const
4859 return __isTextBlocked;
4863 _EditPresenter::CopyText(void)
4865 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
4868 result r = E_SUCCESS;
4870 _Clipboard* pClipBoard = _Clipboard::GetInstance();
4871 SysTryReturnResult(NID_UI_CTRL, pClipBoard != null, E_SYSTEM, "Unable to get the clipboard instance.");
4875 GetBlockRange(start, end);
4877 String blockString(GetText(start, end - 1));
4879 _ClipboardItem* pClipboardItem = _ClipboardItem::CreateInstanceN(CLIPBOARD_DATA_TYPE_TEXT, blockString);
4880 SysTryReturnResult(NID_UI_CTRL, pClipboardItem != null, E_SYSTEM, "Unable to get the clipboarditem instance.");
4882 r = pClipBoard->CopyItem(*pClipboardItem);
4884 delete pClipboardItem;
4886 _Text::TextElement* pStartTextElement = __pTextObject->GetElementAtTextIndex(start);
4887 _Text::TextElement* pEndTextElement = __pTextObject->GetElementAtTextIndex(end-1);
4889 if (pStartTextElement == null || pEndTextElement == null)
4894 const int startIndex = __pTextObject->GetElementIndexOf(*pStartTextElement);
4895 const int endIndex = __pTextObject->GetElementIndexOf(*pEndTextElement);
4897 for (int index = startIndex; index <= endIndex; index++)
4899 _Text::TextElement* pTextElement = __pTextObject->GetElementAtElementIndex(index);
4900 TextElementType objectType = pTextElement->GetType();
4901 if (objectType != TEXT_ELEMENT_TYPE_IMAGE)
4905 TextImage* pImageText = null;
4906 pImageText = dynamic_cast < TextImage* >(pTextElement);
4907 if ( pImageText == null)
4911 const Bitmap * pImage = pImageText->GetBitmap();
4912 SysTryReturnResult(NID_UI_CTRL, pImage != null, E_SYSTEM, "Unable to get the bitmap from textobject.");
4914 _ClipboardItem* pClipboardImageItem = _ClipboardItem::CreateInstanceN(CLIPBOARD_DATA_TYPE_IMAGE, *pImage);
4915 SysTryReturnResult(NID_UI_CTRL, pClipboardImageItem != null, E_SYSTEM, "Unable to get the clipboardImageitem instance.");
4917 r = pClipBoard->CopyItem(*pClipboardImageItem);
4919 delete pClipboardImageItem;
4926 _EditPresenter::CutText(void)
4928 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
4931 result r = E_SUCCESS;
4934 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4938 GetBlockRange(start, end);
4939 DeleteText(start, end);
4942 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
4948 _EditPresenter::PasteText(void)
4950 result r = E_SUCCESS;
4951 int currentLength = GetTextLength();
4952 String* pSubString = null;
4957 String filteredString;
4959 _Clipboard* pClipBoard = _Clipboard::GetInstance();
4960 SysTryReturnResult(NID_UI_CTRL, pClipBoard != null, E_SYSTEM, "Unable to get the clipboard instance.");
4962 const _ClipboardItem* pClipboardItem = pClipBoard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT|CLIPBOARD_DATA_TYPE_AUDIO | CLIPBOARD_DATA_TYPE_VIDEO);
4963 SysTryReturnResult(NID_UI_CTRL, pClipboardItem != null, E_SYSTEM, "Unable to get the clipboarditem instance.");
4965 const String* pClipString = dynamic_cast<const String*>(pClipboardItem->GetData());
4966 SysTryCatch(NID_UI_CTRL, pClipString, r = E_SYSTEM, E_SYSTEM, "Unable to get the clipboarditem instance.");
4968 filteredString = *pClipString;
4972 if(__pTextFilter->ValidatePastedText(*pClipString, userString))
4974 filteredString = userString;
4975 SysLog(NID_UI_CTRL, "ClipString was changed by User");
4978 else if (IsUnsupportedChracterExist(GetKeypadStyle(), *pClipString) == true)
4985 GetBlockRange(start, end);
4986 total = currentLength - (end - start) + filteredString.GetLength();
4987 if (total > __limitLength)
4989 DeleteText(start, end);
4991 pSubString = new String(__limitLength - currentLength + (end - start));
4992 SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "Unable to allocate text buffer.");
4994 filteredString.SubString(0, __limitLength - currentLength + (end - start), *pSubString);
4995 r = InsertTextAt(__cursorPos, pSubString->GetPointer());
4996 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5001 DeleteText(start, end);
5003 r = InsertTextAt(__cursorPos, filteredString.GetPointer());
5004 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5007 else if (currentLength + filteredString.GetLength() > __limitLength)
5009 if (__limitLength == currentLength)
5011 delete pClipboardItem;
5015 pSubString = new String(__limitLength - currentLength);
5016 SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "Unable to allocate text buffer.");
5018 filteredString.SubString(0, __limitLength - currentLength, *pSubString);
5019 r = InsertTextAt(__cursorPos, pSubString->GetPointer());
5020 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5025 r = InsertTextAt(__cursorPos, filteredString.GetPointer());
5026 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5029 delete pClipboardItem;
5031 ReplaceTextIntoPasswordHyphenString();
5032 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
5034 __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), 0);
5037 ScrollPanelToCursorPosition();
5039 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
5044 delete pClipboardItem;
5050 _EditPresenter::RemoveTextBlock(void)
5052 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
5056 if (!__isTextBlocked)
5058 return E_OBJ_NOT_FOUND;
5064 GetBlockRange(start, end);
5067 return E_OBJ_NOT_FOUND;
5070 result r = DeleteText(start, end);
5071 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5073 __isTextBlocked = false;
5075 InitializeCopyPasteManager();
5081 _EditPresenter::IsClipped(void) const
5083 _Clipboard* pClipBoard = _Clipboard::GetInstance();
5084 SysTryReturn(NID_UI_CTRL, pClipBoard != null, false, E_SYSTEM, "Unable to get the clipboard instance.");
5086 const _ClipboardItem* pClipboardItem = pClipBoard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT|CLIPBOARD_DATA_TYPE_AUDIO | CLIPBOARD_DATA_TYPE_VIDEO);
5087 if (pClipboardItem == null)
5089 SetLastResult(E_SUCCESS);
5092 delete pClipboardItem;
5098 _EditPresenter::SetTextAlignment(HorizontalAlignment alignment)
5100 result r = E_SUCCESS;
5102 int textAlign = TEXT_OBJECT_ALIGNMENT_LEFT;
5104 if (alignment == ALIGNMENT_CENTER)
5106 textAlign = TEXT_OBJECT_ALIGNMENT_CENTER;
5108 else if (alignment == ALIGNMENT_RIGHT)
5110 textAlign = TEXT_OBJECT_ALIGNMENT_RIGHT;
5113 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
5115 r = __pTextObject->SetAlignment(textAlign | TEXT_OBJECT_ALIGNMENT_MIDDLE);
5119 r = __pTextObject->SetAlignment(textAlign | TEXT_OBJECT_ALIGNMENT_TOP);
5121 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Unable to set text alignment.");
5122 __horizontalAlignment = alignment;
5128 _EditPresenter::SetLineSpacing(int linePixelGap)
5130 result r = E_SUCCESS;
5132 __pTextObject->SetLineSpace(linePixelGap);
5138 _EditPresenter::SetLineSpacing(float linePixelGap)
5140 result r = E_SUCCESS;
5142 __pTextObject->SetLineSpace(linePixelGap);
5148 _EditPresenter::GetText(int start, int end) const
5152 if (start != 0 && end != -1)
5154 SysTryReturn(NID_UI_CTRL, (start <= end), tempString, E_SYSTEM, "[E_SYSTEM] The invalid argument(start = %d, end = %d) is given.", start, end);
5155 int textLength = GetTextLength();
5156 SysTryReturn(NID_UI_CTRL, (start < textLength && end < textLength), tempString, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The invalid argument(start = %d, end = %d) is given.", start, end);
5159 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
5161 int length = end - start + 1;
5162 __pTextString->SubString(start, length, tempString);
5167 String resultString;
5168 String elementString;
5169 const int textElementCount = __pTextObject->GetElementCount();
5170 _Text::TextElement* pTextElement = __pTextObject->GetElementAtTextIndex(start);
5172 if (pTextElement == null)
5174 return resultString;
5176 const int startIndex = __pTextObject->GetElementIndexOf(*pTextElement);
5178 for (int index = startIndex; index < textElementCount; index++)
5180 _Text::TextElement* pTextElement = __pTextObject->GetElementAtElementIndex(index);
5181 TextSimple* pSimpleText = null;
5182 if (pTextElement == null)
5187 TextElementType objectType = pTextElement->GetType();
5188 if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK)
5190 pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
5191 if ( pSimpleText == null)
5202 int elementOffset = static_cast < int >(pTextElement->GetValue(SET_TEXT_OFFSET));
5203 int elementLength = pTextElement->GetTextLength();
5205 if (objectType == TEXT_ELEMENT_TYPE_CUTLINK)
5207 elementOffset = GetLinkElementOffsetInTextBuffer(index);
5208 if (elementOffset < 0)
5214 if (end < elementOffset)
5218 if (start >= elementOffset + elementLength)
5223 if (elementLength == 0)
5227 elementString.Clear();
5228 elementString.Append(pSimpleText->GetText());
5229 elementString.SetLength(elementLength);
5230 if (end < elementOffset + elementLength - 1)
5232 int removingStartIndex = end + 1;
5233 elementString.Remove(removingStartIndex - elementOffset, elementOffset + elementLength - removingStartIndex);
5235 if (start > elementOffset)
5237 elementString.Remove(0, start - elementOffset);
5239 resultString.Append(elementString);
5242 return resultString;
5246 _EditPresenter::GetText(void) const
5248 return GetText(0, GetTextLength()-1);
5252 _EditPresenter::SetText(const String& text)
5254 result r = E_SUCCESS;
5256 InitializeCopyPasteManager();
5258 int length = text.GetLength();
5260 if (__pEdit->IsViewModeEnabled())
5262 if (__limitLength <= length)
5264 String tempString = GetText();
5265 SetTextLimitLength(length * 2);
5270 SysTryReturnResult(NID_UI_CTRL, length <= __limitLength, E_INVALID_ARG, "The Invalid argument is given.");
5273 FinishTextComposition();
5275 __pTextString->Clear();
5276 __pTextString->Append(text);
5278 wchar_t* tempString = const_cast<wchar_t*>(text.GetPointer());
5279 for (int i = 0; i < length; i++)
5281 __pTextBuffer[i] = tempString[i];
5283 __pTextBuffer[length] = 0;
5285 if (__isInitialized == true)
5287 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT);
5290 __pTextObject->RemoveAll();
5291 TextSimple* pSimpleText = new (std::nothrow)TextSimple(__pTextBuffer, length,TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, __pFont);
5292 __pTextObject->AppendElement(*pSimpleText);
5293 __pTextObject->Compose();
5295 ReplaceTextIntoPasswordHyphenString();
5297 __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), 0);
5299 SetCursorPosition(length);
5301 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
5303 AdjustFlexibleHeight();
5306 if (__pEdit->IsViewModeEnabled())
5308 __isCutLinkParserEnabled = true;
5311 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
5317 _EditPresenter::GetRemainingLength(void) const
5319 return __limitLength - __pTextObject->GetTextLength();
5323 _EditPresenter::SetCursorPosition(int position)
5325 result r = E_SUCCESS;
5326 int length = GetTextLength();
5328 SysTryReturnResult(NID_UI_CTRL, -1 < position && position <= length, E_INVALID_ARG, "Invalid argument is given.");
5330 if (__isTouchMoving == false)
5332 __isCursorChanged = true;
5335 r = __pTextObject->SetCursorIndex(position);
5336 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Failed to set cursor position");
5338 if (__cursorPos != position)
5340 __pTextObject->ConvertToRowColumn(position, __rowCursorIndex, __columnCursorIndex);
5341 __cursorPos = position;
5348 _EditPresenter::SetCursorPosition(int position,int rowIndex, int columnIndex)
5350 result r = E_SUCCESS;
5351 int length = GetTextLength();
5353 SysTryReturnResult(NID_UI_CTRL, -1 < position && position <= length, E_INVALID_ARG, "Invalid argument is given.");
5355 if (__isTouchMoving == false)
5357 __isCursorChanged = true;
5360 r = __pTextObject->SetCursorIndex(position);
5361 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Failed to set cursor position");
5363 __rowCursorIndex = rowIndex;
5364 __columnCursorIndex = columnIndex;
5366 __cursorPos = position;
5372 _EditPresenter::GetCursorPosition(void) const
5378 _EditPresenter::GetTextLength(void) const
5380 return __pTextObject->GetTextLength();
5384 _EditPresenter::InsertTextAt(int index, const String& text)
5386 result r = E_SUCCESS;
5388 int currentLength = GetTextLength();
5389 int length = text.GetLength();
5390 int totalLength = currentLength + length;
5391 String insertText = text;
5394 SysTryReturnResult(NID_UI_CTRL, index >= 0 && index <= currentLength, E_OUT_OF_RANGE, "The Invalid argument is given.");
5396 if (__pEdit->IsViewModeEnabled())
5398 if (__limitLength <= totalLength)
5400 String tempString = GetText();
5401 SetTextLimitLength(totalLength * 2);
5402 SetText(tempString);
5407 SysTryReturnResult(NID_UI_CTRL, totalLength <= __limitLength, E_MAX_EXCEEDED, "The Invalid argument is given.");
5410 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE || __pEdit->GetEditStyle() & EDIT_STYLE_TOKEN )
5412 while (insertText.Contains(String(L"\n")))
5414 for (i = 0; i < length; i++)
5417 insertText.GetCharAt(i, ch);
5420 insertText.Remove(i, 1);
5421 length = insertText.GetLength();
5434 r = __pTextString->Insert(insertText, index);
5435 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5437 wchar_t* pTempString = const_cast<wchar_t*>(insertText.GetPointer());
5438 wchar_t pOriginalString[currentLength - index];
5440 for (int i = 0; i < currentLength - index; i++)
5442 pOriginalString[i] = __pTextBuffer[index + i];
5444 pOriginalString[currentLength - index] = 0;
5446 for (int i = 0; i < length; i++)
5448 __pTextBuffer[i + index] = pTempString[i];
5451 for (int i = 0; i < currentLength - index; i++)
5453 __pTextBuffer[i + index + length] = pOriginalString[i];
5455 __pTextBuffer[totalLength] = 0;
5457 __pTextObject->InputText(index);
5458 __pTextObject->SetRange(index, length);
5459 r = __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), length);
5460 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Failed to set length");
5462 __pTextObject->Compose();
5464 if (__isTextBlocked == true)
5466 DeleteText(__blockStartPos, __cursorPos);
5469 SetCursorPosition(__cursorPos + length);
5473 SetCursorPosition(index + length);
5476 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
5478 AdjustFlexibleHeight();
5481 __isCursorChanged = true;
5483 if (__pEdit->IsViewModeEnabled())
5485 __isCutLinkParserEnabled = true;
5488 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
5494 _EditPresenter::AppendText(const String& text)
5496 result r = E_SUCCESS;
5498 int currentLength = GetTextLength();
5499 int length = text.GetLength();
5500 int totalLength = currentLength + length;
5502 if (__pEdit->IsViewModeEnabled())
5504 if (__limitLength <= totalLength)
5506 String tempString = GetText();
5507 SetTextLimitLength(totalLength * 2);
5508 SetText(tempString);
5513 SysTryReturnResult(NID_UI_CTRL, totalLength <= __limitLength, E_MAX_EXCEEDED, "The Invalid argument is given.");
5516 r = __pTextString->Append(text);
5517 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5519 wchar_t* pTempString = const_cast<wchar_t*>(text.GetPointer());
5521 for (int i = 0; i < length; i++)
5523 __pTextBuffer[i + currentLength] = pTempString[i];
5525 __pTextBuffer[totalLength] = 0;
5527 __pTextObject->SetRange(currentLength, length);
5528 r = __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), length);
5529 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Failed to set length");
5531 __pTextObject->Compose();
5533 if (!__isTextBlocked)
5535 SetCursorPosition(totalLength);
5538 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
5540 AdjustFlexibleHeight();
5543 if (__pEdit->IsViewModeEnabled())
5545 __isCutLinkParserEnabled = true;
5548 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
5554 _EditPresenter::AppendCharacter(const Character& character)
5556 result r = E_SUCCESS;
5558 r = AppendText(character.ToString());
5564 _EditPresenter::ClearText(void)
5566 InitializeCopyPasteManager();
5568 result r = E_SUCCESS;
5570 FinishTextComposition();
5572 int textLength = GetTextLength();
5574 if (textLength == 0)
5579 r = DeleteText(0, textLength);
5580 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5582 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_CLEAR_ICON);
5588 _EditPresenter::DeleteCharacterAt(int index)
5590 result r = E_SUCCESS;
5593 length = GetTextLength();
5595 SysTryReturnResult(NID_UI_CTRL, index >= 0, E_INVALID_ARG, "Specified index is negative.");
5596 SysTryReturnResult(NID_UI_CTRL, index < length, E_OUT_OF_RANGE, "Specified index is outside the range.");
5598 r = DeleteText(index, index+1);
5603 _EditPresenter::DeleteText(int startCursorPosition, int endCursorPosition)
5605 result r = E_SUCCESS;
5607 int length = GetTextLength();
5609 SysTryReturnResult(NID_UI_CTRL, -1 < startCursorPosition && startCursorPosition < endCursorPosition, E_INVALID_ARG, "Invalid argument is given.");
5610 SysTryReturnResult(NID_UI_CTRL, startCursorPosition < endCursorPosition && endCursorPosition <= length, E_INVALID_ARG, "Invalid argument is given.");
5612 _Text::TextElement* pFirstTextElement = __pTextObject->GetElementAtTextIndex(startCursorPosition);
5613 const TextSimple* pFirstSimpleText = dynamic_cast <const TextSimple*>(pFirstTextElement);
5614 if (pFirstSimpleText != null && pFirstSimpleText->GetBitmap() != null)
5616 if (pFirstSimpleText->GetTextOffset() < startCursorPosition)
5618 startCursorPosition = pFirstSimpleText->GetTextOffset();
5621 _Text::TextElement* pLastTextElement = __pTextObject->GetElementAtTextIndex(endCursorPosition - 1);
5622 const TextSimple* pLastSimpleText = dynamic_cast <const TextSimple*>(pLastTextElement);
5623 if (pLastSimpleText != null && pLastSimpleText->GetBitmap() != null)
5625 if( (pLastSimpleText->GetTextOffset() + pLastSimpleText->GetTextLength()) > endCursorPosition)
5627 endCursorPosition = pLastSimpleText->GetTextOffset() + pLastSimpleText->GetTextLength();
5631 r = __pTextString->Remove(startCursorPosition, endCursorPosition - startCursorPosition);
5632 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5634 int currentLength = __pTextString->GetLength();
5636 for (int i = startCursorPosition; i < length; i++)
5638 if ((i + length - currentLength) >= length)
5642 __pTextBuffer[i] = __pTextBuffer[i + (length - currentLength)];
5645 for (int i = currentLength; i < length; i++)
5647 __pTextBuffer[i] = 0;
5650 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT);
5652 __pTextObject->RemoveText(startCursorPosition);
5653 __pTextObject->SetRange(startCursorPosition, endCursorPosition - startCursorPosition);
5654 r = __pTextObject->NotifyTextChanged(__pTextBuffer, 0, currentLength, -(endCursorPosition - startCursorPosition));
5655 r = __pTextObject->Compose();
5657 SetCursorPosition(startCursorPosition);
5659 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
5661 AdjustFlexibleHeight();
5664 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
5670 _EditPresenter::GetCurrentTextRange(int& start, int& end) const
5672 int currentLength = __pTextString->GetLength();
5674 start = __cursorPos;
5677 if (__pTextBuffer[--start] == TEXT_OBJ_CHARACTER)
5685 while (end < currentLength && __pTextBuffer[end] != TEXT_OBJ_CHARACTER)
5694 _EditPresenter::GetTextLimitLength(void) const
5696 return __limitLength;
5700 _EditPresenter::SetTextLimitLength(int limitLength)
5702 result r = E_SUCCESS;
5704 SysTryReturnResult(NID_UI_CTRL, (limitLength > 0), E_INVALID_ARG, "The invalid limit length is given.");
5706 String tempString = GetText();
5708 int textLength = tempString.GetLength();
5709 SysTryReturnResult(NID_UI_CTRL, (limitLength >= textLength), E_INVALID_ARG, "The invalid argument is given.");
5711 TextSimple* pSimpleText = null;
5713 if (limitLength == GetTextLimitLength())
5718 wchar_t* pTempBuffer = new (std::nothrow) wchar_t[limitLength + 1];
5719 SysTryReturnResult(NID_UI_CTRL, pTempBuffer, E_OUT_OF_MEMORY, "Unable to allocate buffer.");
5721 for (int i = 0; i < textLength; i++)
5723 pTempBuffer[i] = __pTextBuffer[i];
5726 for (int i = textLength; i < limitLength; i++)
5731 pTempBuffer[limitLength] = '\0';
5733 __pTextString->Clear();
5734 __pTextString->Append(tempString);
5737 delete[] __pTextBuffer;
5738 __pTextBuffer = null;
5740 __pTextBuffer = pTempBuffer;
5742 __pTextObject->RemoveAll();
5743 pSimpleText = new (std::nothrow)TextSimple(__pTextBuffer, textLength, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, __pFont);
5744 SysTryReturnResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "Insufficient memory.");
5746 r = __pTextObject->AppendElement(*pSimpleText);
5747 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5749 SetCursorPosition(textLength);
5751 __limitLength = limitLength;
5762 _EditPresenter::InsertCharacterAt(int index, const Character& character)
5764 result r = E_SUCCESS;
5766 r = InsertTextAt(index, character.ToString());
5772 _EditPresenter::SetModel(const _EditModel& editModel)
5776 delete __pEditModel;
5777 __pEditModel = null;
5780 __pEditModel = const_cast<_EditModel*>(&editModel);
5786 _EditPresenter::SetAutoLinkMask(unsigned long autoLinks)
5788 __isCutLinkParserEnabled = true;
5789 return __pEditModel->SetAutoLinkMask(autoLinks);
5793 _EditPresenter::GetAutoLinkMask(void) const
5795 return __pEditModel->GetAutoLinkMask();
5799 _EditPresenter::IsViewModeEnabled(bool internal) const
5801 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
5803 return __pEditModel->IsViewModeEnabled();
5813 return __pEditModel->IsViewModeEnabled();
5819 _EditPresenter::SetViewModeEnabled(bool enable)
5821 if (!enable && __pEditModel->IsViewModeEnabled() && IsCurrentFocused() && (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY))
5823 __pEdit->SetFocused(false);
5826 int editStyle = __pEdit->GetEditStyle();
5830 editStyle = editStyle | EDIT_STYLE_VIEWER;
5834 editStyle = editStyle & (~EDIT_STYLE_VIEWER);
5836 __pEdit->SetEditStyle(editStyle);
5840 __pEdit->SetCursorPosition(0);
5842 if (__pInputConnection && __isInputConnectionBound)
5848 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
5850 __isCursorDisabled = enable;
5851 __pTextObject->SetCutLinkViewMode(enable);
5854 if (__pInputConnection)
5858 __pInputConnection->SetKeyEventSkipped(true);
5862 if (IsKeypadEnabled())
5864 __pInputConnection->SetKeyEventSkipped(false);
5869 return __pEditModel->SetViewModeEnabled(enable);
5873 _EditPresenter::SetKeypadActionEnabled(bool enable)
5876 result r = E_SUCCESS;
5878 r = __pInputConnection->SetInputPanelActionEnabled(enable);
5881 __pEditModel->SetKeypadActionEnabled(enable);
5887 _EditPresenter::IsKeypadActionEnabled(void)
5890 bool enableIc = true;
5892 enable = __pEditModel->IsKeypadActionEnabled();
5893 enableIc = __pInputConnection->IsInputPanelActionEnabled();
5899 _EditPresenter::GetKeypadAction(void) const
5901 return __pEditModel->GetKeypadAction();
5905 _EditPresenter::ConvertKeypadAction(CoreKeypadAction keypadAction)
5907 InputPanelAction inputPanelAction = INPUT_PANEL_ACTION_ENTER;
5909 switch (keypadAction)
5911 case CORE_KEYPAD_ACTION_ENTER:
5912 inputPanelAction = INPUT_PANEL_ACTION_ENTER;
5914 case CORE_KEYPAD_ACTION_GO:
5915 inputPanelAction = INPUT_PANEL_ACTION_GO;
5917 case CORE_KEYPAD_ACTION_NEXT:
5918 inputPanelAction = INPUT_PANEL_ACTION_NEXT;
5920 case CORE_KEYPAD_ACTION_SEND:
5921 inputPanelAction = INPUT_PANEL_ACTION_SEND;
5923 case CORE_KEYPAD_ACTION_SEARCH:
5924 inputPanelAction = INPUT_PANEL_ACTION_SEARCH;
5926 case CORE_KEYPAD_ACTION_LOGIN:
5927 inputPanelAction = INPUT_PANEL_ACTION_LOGIN;
5929 case CORE_KEYPAD_ACTION_SIGN_IN:
5930 inputPanelAction = INPUT_PANEL_ACTION_SIGN_IN;
5932 case CORE_KEYPAD_ACTION_JOIN:
5933 inputPanelAction = INPUT_PANEL_ACTION_JOIN;
5935 case CORE_KEYPAD_ACTION_DONE:
5936 inputPanelAction = INPUT_PANEL_ACTION_DONE;
5942 return inputPanelAction;
5947 _EditPresenter::SetKeypadAction(CoreKeypadAction keypadAction)
5949 return __pEditModel->SetKeypadAction(keypadAction);
5953 _EditPresenter::SetKeypadEnabled(bool enable)
5955 if (!enable && IsKeypadEnabled())
5957 CheckUSBKeyboardStatus();
5959 if (!__isUSBKeyboardConnected && __isInputConnectionBound)
5965 __pEditModel->SetKeypadEnabled(enable);
5967 if (__pInputConnection)
5971 __pInputConnection->SetKeyEventSkipped(true);
5975 if (!__pEditModel->IsViewModeEnabled())
5977 __pInputConnection->SetKeyEventSkipped(false);
5986 _EditPresenter::SetKeypadEventSkipped(bool skip)
5990 __pInputConnection->SetKeyEventSkipped(true);
5994 if (__pEdit->IsEnabled() && !__pEditModel->IsViewModeEnabled() && IsKeypadEnabled())
5996 __pInputConnection->SetKeyEventSkipped(false);
6002 _EditPresenter::IsKeypadEnabled(void)
6006 if (__pEdit->IsEnabled())
6008 enable = __pEditModel->IsKeypadEnabled();
6019 _EditPresenter::SetCurrentLanguage(LanguageCode languageCode)
6021 result r = E_SUCCESS;
6023 if (__pInputConnection && __isInputConnectionBound)
6025 r = __pInputConnection->SetInputPanelLanguage(languageCode);
6026 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
6027 r = __pEditModel->SetInitialKeypadLanguage(LANGUAGE_INVALID);
6028 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
6032 r = __pEditModel->SetInitialKeypadLanguage(languageCode);
6033 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
6036 r = __pEditModel->SetCurrentLanguage(languageCode);
6042 _EditPresenter::GetCurrentLanguage(LanguageCode& language) const
6044 result r = E_SUCCESS;
6045 if (__pInputConnection && __isInputConnectionBound)
6047 language = __pInputConnection->GetInputPanelLanguage();
6048 r = __pEditModel->SetCurrentLanguage(language);
6049 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
6052 return __pEditModel->GetCurrentLanguage(language);
6056 _EditPresenter::SetLowerCaseModeEnabled(bool enable)
6058 __pEditModel->SetLowerCaseModeEnabled(enable);
6064 _EditPresenter::IsLowerCaseModeEnabled(void) const
6066 return __pEditModel->IsLowerCaseModeEnabled();
6070 _EditPresenter::GetKeypadStyle(void) const
6072 return __pEditModel->GetKeypadStyle();
6076 _EditPresenter::SetKeypadStyle(KeypadStyle keypadStyle)
6079 bool textPredictionEnabled = __pEditModel->IsTextPredictionEnabled();
6081 InputPanelStyle inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
6083 switch (keypadStyle)
6085 case KEYPAD_STYLE_NORMAL:
6086 if (__isKeypadNormalNumberStyleEnabled)
6088 inputPanelStyle = INPUT_PANEL_STYLE_NUMBER;
6092 inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
6095 case KEYPAD_STYLE_PASSWORD:
6096 inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
6097 if (__pInputConnection)
6099 __pInputConnection->SetPasswordMode(true);
6102 case KEYPAD_STYLE_EMAIL:
6103 inputPanelStyle = INPUT_PANEL_STYLE_EMAIL;
6105 case KEYPAD_STYLE_URL:
6106 inputPanelStyle = INPUT_PANEL_STYLE_URL;
6108 case KEYPAD_STYLE_NUMBER:
6109 inputPanelStyle = INPUT_PANEL_STYLE_NUMBER_ONLY;
6110 textPredictionEnabled = false;
6112 case KEYPAD_STYLE_PHONE_NUMBER:
6113 inputPanelStyle = INPUT_PANEL_STYLE_PHONE_NUMBER;
6114 textPredictionEnabled = false;
6116 case KEYPAD_STYLE_IP_V4:
6117 inputPanelStyle = INPUT_PANEL_STYLE_IP;
6118 textPredictionEnabled = false;
6124 if (__pInputConnection && __isInputConnectionBound)
6126 __pInputConnection->SetTextPredictionEnabled(textPredictionEnabled);
6127 __pInputConnection->SetInputPanelStyle(inputPanelStyle);
6130 __pEditModel->SetTextPredictionEnabled(textPredictionEnabled);
6132 return __pEditModel->SetKeypadStyle(keypadStyle);
6136 _EditPresenter::SetKeypadNormalNumberStyle(bool enable)
6138 __isKeypadNormalNumberStyleEnabled = enable;
6139 return SetKeypadStyle(__pEditModel->GetKeypadStyle());
6143 _EditPresenter::IsTextPredictionEnabled(void) const
6145 return __pEditModel->IsTextPredictionEnabled();
6149 _EditPresenter::SetTextPredictionEnabled(bool enable)
6151 KeypadStyle keypadStyle = __pEditModel->GetKeypadStyle();
6153 if (keypadStyle == KEYPAD_STYLE_NUMBER ||keypadStyle == KEYPAD_STYLE_PHONE_NUMBER ||
6154 keypadStyle == KEYPAD_STYLE_IP_V4)
6155 return E_UNSUPPORTED_OPERATION;
6157 if (__pInputConnection && __isInputConnectionBound)
6159 __pInputConnection->SetTextPredictionEnabled(enable);
6162 return __pEditModel->SetTextPredictionEnabled(enable);
6166 _EditPresenter::InsertTextAtCursorPosition(const String& text)
6168 return InsertTextAt(__cursorPos, text);
6172 _EditPresenter::InsertTextAt(int position, const String& text, const Bitmap& textImage)
6174 result r = E_SUCCESS;
6176 int currentLength = GetTextLength();
6177 int length = text.GetLength();
6178 int totalLength = currentLength + length;
6180 SysTryReturnResult(NID_UI_CTRL, position >= 0 && position <= currentLength, E_OUT_OF_RANGE, "The given position is out-of-range.");
6182 if ((__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) || (__pEdit->IsViewModeEnabled()))
6184 if (__limitLength <= totalLength)
6186 String backupString = GetText();
6187 SetTextLimitLength(totalLength * 2);
6188 SetText(backupString);
6193 SysTryReturnResult(NID_UI_CTRL, totalLength <= __limitLength, E_MAX_EXCEEDED, "The text exceeds the limitation length.");
6196 FinishTextComposition();
6198 r = __pTextString->Insert(text, position);
6199 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
6201 wchar_t* pInsertString = const_cast<wchar_t*>(text.GetPointer());
6203 if (currentLength > position)
6205 wchar_t pOriginalString[currentLength - position];
6207 for (int i = 0; i < currentLength - position; i++)
6209 pOriginalString[i] = __pTextBuffer[position + i];
6211 pOriginalString[currentLength - position] = 0;
6213 for (int i = 0; i < length; i++)
6215 __pTextBuffer[i + position] = pInsertString[i];
6218 for (int i = 0; i < currentLength - position; i++)
6220 __pTextBuffer[i + position + length] = pOriginalString[i];
6225 for (int i = 0; i < length; i++)
6227 __pTextBuffer[i + position] = pInsertString[i];
6231 __pTextBuffer[totalLength] = 0;
6233 TextSimple* pSimpleText = null;
6234 pSimpleText = new (std::nothrow) TextSimple(__pTextBuffer, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, GetFont());
6235 SysTryReturnResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "Unable to allocate text simple element.");
6237 pSimpleText->ChangeTextOffset(__pTextBuffer, position);
6238 pSimpleText->SetBitmap((Bitmap&)textImage);
6239 __pTextObject->InsertElementAt(position, *pSimpleText);
6240 __pTextObject->ChangeTextOffset(__pTextBuffer, position+pSimpleText->GetTextLength(), pSimpleText->GetTextLength());
6241 __pTextObject->Compose();
6243 if (__isTextBlocked == true)
6245 DeleteText(__blockStartPos, __cursorPos);
6248 SetCursorPosition(__cursorPos + length);
6252 SetCursorPosition(position + length);
6255 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
6257 AdjustFlexibleHeight();
6260 __isCursorChanged = true;
6261 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
6266 _EditPresenter::DeleteCharacterAtCursorPosition(void)
6268 return DeleteCharacterAt(__cursorPos);
6272 _EditPresenter::IsFocused(void) const
6274 return __pEdit->IsFocused();
6278 _EditPresenter::IsInternalFocused(void) const
6280 return __pEdit->IsInternalFocused();
6284 _EditPresenter::GetTextVisualElement(void)
6286 return __pTextVisualElement;
6290 _EditPresenter::SetControlInitialBounds(FloatRectangle initBounds)
6292 __initialBounds = initBounds;
6296 _EditPresenter::SetControlInitialPosition(FloatPoint initPosition)
6298 __initialBounds.x = initPosition.x;
6299 __initialBounds.y = initPosition.y;
6303 _EditPresenter::IsUpdateInitialBounds(void)
6305 return __updateInitialBounds;
6309 _EditPresenter::OnFocusGained(void)
6311 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
6315 __pParentForm = GetParentForm();
6317 if (!__pParentForm && __isKeypadCommandButtonVisible)
6319 __isKeypadCommandButtonVisible = false;
6323 if (__isAutoShrinkEnabled)
6325 float flexibleHeight = CalculateFlexibleHeightF();
6326 FloatRectangle initialRect = GetInitialBoundsF();
6327 initialRect.height = flexibleHeight;
6329 SetFlexBounds(initialRect);
6332 if (!__pTextVisualElement)
6334 result r = E_SUCCESS;
6335 __pTextVisualElement = new (std::nothrow) _VisualElement;
6336 SysTryReturn(NID_UI_CTRL, __pTextVisualElement != null, false, E_OUT_OF_MEMORY, "Unable to create __pTextVisualElement instance.");
6338 r = __pTextVisualElement->Construct();
6339 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r));
6341 __pTextVisualElement->SetSurfaceOpaque(false);
6342 __pTextVisualElement->SetImplicitAnimationEnabled(false);
6344 __pTextVisualElement->SetShowState(true);
6346 _VisualElement* pEditVisualElement = __pEdit->GetVisualElement();
6347 SysTryCatch(NID_UI_CTRL, pEditVisualElement, , r = E_SYSTEM, "[E_SYSTEM] Unable to get root visual element.");
6349 pEditVisualElement->AttachChild(*__pTextVisualElement);
6350 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r));
6353 if (__pEdit->GetEnableState() == false)
6358 __isCursorOpaque = true;
6360 if (__isInputConnectionBound == false && __isInitialized)
6362 if (IsViewModeEnabled() == false)
6364 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
6370 ShowFullscreenKeypad();
6374 __pEdit->Invalidate();
6379 __pTextVisualElement->Destroy();
6380 __pTextVisualElement = null;
6386 _EditPresenter::OnNotifiedN(IList* pArgs)
6388 String showKeypad(L"ShowKeypad");
6389 String showCopyPaste(L"ShowCopyPaste");
6391 String* pType = dynamic_cast <String*>(pArgs->GetAt(0));
6395 if (*pType == showKeypad)
6397 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
6403 ShowFullscreenKeypad();
6406 else if (*pType == showCopyPaste)
6408 if (__pCopyPasteManager)
6410 __pCopyPasteManager->CreateHandle();
6411 if (__needToCreateCopyPastePopup)
6413 __pCopyPasteManager->CreateCopyPastePopup();
6414 __needToCreateCopyPastePopup = false;
6416 __pCopyPasteManager->Show();
6419 pArgs->RemoveAll(true);
6429 _EditPresenter::OnFrameActivated(const _Frame& source)
6431 _ControlManager* pControlManager = _ControlManager::GetInstance();
6432 if (pControlManager)
6434 _Control* pControl = pControlManager->GetFocusControl();
6435 if (pControl != __pEdit)
6441 if (__isInputConnectionBound == false && __isInitialized)
6443 if (IsViewModeEnabled() == false)
6445 CheckUSBKeyboardStatus();
6447 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
6458 _EditPresenter::OnFrameDeactivated(const _Frame& source)
6464 _EditPresenter::OnFrameMinimized(const _Frame& source)
6470 _EditPresenter::OnFrameRestored(const _Frame& source)
6476 _EditPresenter::ChangeToUnbindState(bool removeFocus)
6478 if(__latestBoundedContext != (unsigned int)this)//context is already changed.
6480 __isKeypadHiding = false;
6483 if (IsCopyPasteManagerExist())
6485 InitializeCopyPasteManager();
6488 if (__isInputConnectionBound)
6490 HideKeypad(removeFocus);
6492 if (__isClipboardExist)
6496 __pClipboard->HidePopup();
6497 OnClipboardPopupClosed();
6502 if (__isKeypadHiding)
6504 if (__pParentForm && !__pParentForm->IsVisible()) //Unbind by Scene Change
6506 if (__isCopyPasteManagerExist)
6508 InitializeCopyPasteManager();
6509 __pTextObject->SetBlock(false);
6510 __isTextBlocked = false;
6513 if (__pCommandButton && __isKeypadCommandButtonVisible)
6515 SetFooterVisible(true);
6516 __pCommandButton->SetVisibleState(false);
6517 __pCommandButton->Invalidate();
6520 __isInputConnectionBound = false;
6522 AdjustParentPanelHeight(true);
6523 SysLog(NID_UI_CTRL, "Form deflate RESET!!!");
6524 __pParentForm->DeflateClientRectHeight(0);
6526 if (!__pEdit->IsFullScreenKeypadEdit())
6530 __pParentForm->Draw();
6534 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CLOSED);
6535 __pEdit->DetachScrollPanelEvent();
6537 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
6538 __resizedByKeypadHide = true;
6539 __latestBoundedContext = null;
6547 _EditPresenter::OnFocusLost(void)
6549 if (!__pEdit->IsDestroyed())
6551 InitializeCopyPasteManager();
6552 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
6555 if (__isAutoShrinkEnabled)
6557 FloatRectangle intialWindowBounds = GetInitialBoundsF();
6558 SetFlexBounds(intialWindowBounds);
6561 if (__pTextVisualElement)
6563 __pTextVisualElement->Destroy();
6564 __pTextVisualElement = null;
6567 if (__pEdit == null)
6572 if (__isClipboardExist)
6576 __pClipboard->HidePopup();
6577 OnClipboardPopupClosed();
6581 if (__isInputConnectionBound)
6584 if (__pScrollBar && !(__pEdit->GetEditStyle() & EDIT_STYLE_NOSCROLL))
6586 __pScrollBar->SetScrollVisibility(false);
6589 __isCursorOpaque = false;
6590 __isTouchMoving = false;
6591 __isTouchReleaseSkipped = false;
6596 ReplaceTextIntoPasswordHyphenString();
6598 __pEdit->Invalidate();
6604 _EditPresenter::GetCurrentStatus(void)
6606 EditStatus editState = EDIT_STATUS_NORMAL;
6608 if (__pEdit->IsEnabled())
6610 if (IsCurrentFocused())
6612 editState = EDIT_STATUS_HIGHLIGHTED;
6614 else if (__isTouchPressed)
6616 editState = EDIT_STATUS_PRESSED;
6621 editState = EDIT_STATUS_DISABLED;
6628 _EditPresenter::GetCursorVisualElement(void) const
6630 return __pCursorVisualElement;
6634 _EditPresenter::SetMaxLineCount(int maxLineCount)
6636 __pEditModel->SetMaxLineCount(maxLineCount);
6642 _EditPresenter::GetMaxLineCount(void) const
6644 return __pEditModel->GetMaxLineCount();
6648 _EditPresenter::UpdateComponentInformation(void)
6650 result r = E_SUCCESS;
6652 if (__isCursorChanged == false)
6657 bool IsTextAlignmentChanged = AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT);
6658 bool setFirstDisplayLine = true;
6659 if (!((__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) || (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)))
6661 float firstDisplayY = __pTextObject->GetFirstDisplayPositionYF();
6662 float totalHeight = __pTextObject->GetTotalHeightF();
6663 FloatRectangle displayBounds = __pTextObject->GetBoundsF();
6664 if (totalHeight >= displayBounds.height)
6666 float textGapFromBottom = displayBounds.height - (totalHeight - firstDisplayY);
6667 if (textGapFromBottom > 0)
6669 ScrollText(-textGapFromBottom);
6674 if (firstDisplayY > 0)
6676 ScrollText(-firstDisplayY);
6680 FloatRectangle absCursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
6681 CalculateAbsoluteCursorBounds(__cursorPos, absCursorBounds);
6682 setFirstDisplayLine = (IsContained(absCursorBounds) == false);
6685 if (setFirstDisplayLine || IsTextAlignmentChanged)
6687 if (__pTextObject->IsChanged())
6689 __pTextObject->Compose();
6691 __pTextObject->SetFirstDisplayLineIndexFromTextIndex(__cursorPos);
6694 __pTextObject->SetCursorIndex(__cursorPos);
6696 __isCursorChanged = false;
6702 _EditPresenter::ScrollText(float distance)
6704 float newFirstDisplayY = __pTextObject->GetFirstDisplayPositionYF();
6705 newFirstDisplayY += distance;
6707 int moveLine = __pTextObject->GetLineIndexAtPositionY(newFirstDisplayY);
6709 __pTextObject->SetFirstDisplayLineIndex(moveLine);
6710 __pTextObject->SetFirstDisplayPositionY(newFirstDisplayY);
6716 _EditPresenter::IsContained(FloatRectangle& paramRect) const
6718 FloatRectangle absBounds = __pEdit->GetAbsoluteBoundsF(true);
6720 if ((paramRect.x < absBounds.x) ||
6721 (paramRect.y < absBounds.y) ||
6722 ((paramRect.x + paramRect.width) > (absBounds.x + absBounds.width)) ||
6723 ((paramRect.y + paramRect.height) > (absBounds.y + absBounds.height)))
6732 _EditPresenter::CalculateAbsoluteCursorBounds(int index, FloatRectangle& absCursorBounds)
6734 float cursorAbsX = 0.0f;
6735 float cursorAbsY = 0.0f;
6736 float cursorWidth = 0.0f;
6737 float cursorHeight = 0.0f;
6738 float cursorRelativeX = 0.0f;
6739 float cursorRelativeY = 0.0f;
6741 FloatRectangle absBounds = __pEdit->GetAbsoluteBoundsF(true);
6743 __pTextObject->SetBounds(GetTextBoundsF());
6744 if (index != __cursorPos)
6746 if (__pTextObject->GetTextPositionInfoAt(index, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
6753 if (__pTextObject->GetTextPositionInfoAt(__rowCursorIndex, __columnCursorIndex, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
6759 absCursorBounds.x = absBounds.x + cursorRelativeX;
6761 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
6763 FloatRectangle tempBounds;
6764 GetCursorBounds(true, tempBounds);
6765 absCursorBounds.y = tempBounds.y;
6769 absCursorBounds.y = absBounds.y + cursorRelativeY;
6772 GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorWidth);
6774 absCursorBounds.width = cursorWidth;
6776 if (cursorHeight > 0.0f)
6778 if (cursorHeight <= __calculatedCursorBounds.height)
6780 absCursorBounds.height = cursorHeight;
6784 absCursorBounds.height = __calculatedCursorBounds.height;
6789 absCursorBounds.height = __pTextObject->GetLineHeightAtF(0);
6796 _EditPresenter::CalculateAbsoluteCursorBounds(int rowIndex, int columnIndex, FloatRectangle& absCursorBounds)
6798 float cursorAbsX = 0.0f;
6799 float cursorAbsY = 0.0f;
6800 float cursorWidth = 0.0f;
6801 float cursorHeight = 0.0f;
6802 float cursorRelativeX = 0.0f;
6803 float cursorRelativeY = 0.0f;
6805 FloatRectangle absBounds = __pEdit->GetAbsoluteBoundsF(true);
6807 __pTextObject->SetBounds(GetTextBoundsF());
6809 if (__pTextObject->GetTextPositionInfoAt(rowIndex, columnIndex, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
6814 absCursorBounds.x = absBounds.x + cursorRelativeX;
6816 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
6818 FloatRectangle tempBounds;
6819 GetCursorBounds(true, tempBounds);
6820 absCursorBounds.y = tempBounds.y;
6824 absCursorBounds.y = absBounds.y + cursorRelativeY;
6827 GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorWidth);
6829 absCursorBounds.width = cursorWidth;
6831 if (cursorHeight > 0.0f)
6833 if (cursorHeight <= __calculatedCursorBounds.height)
6835 absCursorBounds.height = cursorHeight;
6839 absCursorBounds.height = __calculatedCursorBounds.height;
6844 absCursorBounds.height = __pTextObject->GetLineHeightAtF(0);
6851 _EditPresenter::GetCursorBounds(bool isAbsRect, FloatRectangle& cursorBounds)
6853 if (__isInitialized == false)
6858 CalculateCursorBounds(GetTextBoundsF(), cursorBounds);
6862 FloatRectangle absBounds = __pEdit->GetAbsoluteBoundsF(true);
6863 cursorBounds.x += absBounds.x;
6864 cursorBounds.y += absBounds.y;
6872 _EditPresenter::SetCursorDisabled(bool disabled)
6874 __isCursorDisabled = disabled;
6880 _EditPresenter::IsGuideTextActivated(void) const
6882 if (__pGuideTextObject == null)
6887 if (GetGuideText().IsEmpty())
6892 if (__pTextObject && GetTextLength() > 0)
6901 _EditPresenter::CreateCommandButtonItemN(int actionId, const String& text)
6903 result r = E_SUCCESS;
6904 _Button* pButton = _Button::CreateButtonN();
6905 SysTryReturn(NID_UI_CTRL, pButton, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance.");
6907 float textSize = 0.0f;
6909 r = pButton->SetActionId(actionId);
6910 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6912 r = pButton->SetText(text);
6913 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6915 r = GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_FONT_SIZE, __pEdit->GetOrientation(), textSize);
6918 r = pButton->SetTextSize(textSize);
6919 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6931 _EditPresenter::SetKeypadCommandButton(const FloatRectangle& bounds)
6933 // This function must be changed after _ toolbar completes their float conversion works
6934 result r = E_SUCCESS;
6935 Bitmap* pNormalBackgroundBitmap = null;
6936 Bitmap* pReplacementColorBackgroundBitmap = null;
6937 String leftButtonText;
6938 String rightButtonText;
6939 _Control* pParent = null;
6940 Color commandBackgroundColor;
6942 if (__pCommandButton)
6944 __pCommandButton->SetResizable(true);
6945 __pCommandButton->SetMovable(true);
6946 SysLog(NID_UI_CTRL, "Command position changed!!! bounds(%f, %f, %f, %f)", bounds.x, bounds.y, bounds.width, bounds.height);
6947 r = __pCommandButton->SetBounds(bounds);
6949 __pCommandButton->SetResizable(false);
6950 __pCommandButton->SetMovable(false);
6955 if (__pParentForm == false)
6957 __isKeypadCommandButtonVisible = false;
6961 __pCommandButton = _Toolbar::CreateToolbarN(false);
6962 SysTryReturn(NID_UI_CTRL, __pCommandButton, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance.");
6964 r = __pCommandButton->Construct();
6965 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6967 GET_BITMAP_CONFIG_N(FOOTER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundBitmap);
6968 if (pNormalBackgroundBitmap)
6970 GET_COLOR_CONFIG(FOOTER::BG_NORMAL, commandBackgroundColor);
6971 pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), commandBackgroundColor);
6973 if (pReplacementColorBackgroundBitmap)
6975 r = __pCommandButton->SetBackgroundBitmap(*pReplacementColorBackgroundBitmap);
6976 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6978 delete pReplacementColorBackgroundBitmap;
6979 pReplacementColorBackgroundBitmap = null;
6981 delete pNormalBackgroundBitmap;
6982 pNormalBackgroundBitmap = null;
6985 r = __pCommandButton->SetStyle(TOOLBAR_COMMAND);
6986 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6988 __pCommandButton->SetResizable(true);
6989 __pCommandButton->SetMovable(true);
6990 SysLog(NID_UI_CTRL, "Command created!!! bounds(%f, %f, %f, %f)", bounds.x, bounds.y, bounds.width, bounds.height);
6991 r = __pCommandButton->SetBounds(bounds);
6992 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6994 __pCommandButton->SetResizable(false);
6995 __pCommandButton->SetMovable(false);
6997 leftButtonText = __pEditModel->GetKeypadCommandButtonText(COMMAND_BUTTON_POSITION_LEFT);
6998 r = __pCommandButton->AddItem(CreateCommandButtonItemN(__pEditModel->GetKeypadCommandButtonActionId(COMMAND_BUTTON_POSITION_LEFT), leftButtonText));
6999 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
7001 rightButtonText = __pEditModel->GetKeypadCommandButtonText(COMMAND_BUTTON_POSITION_RIGHT);
7002 r = __pCommandButton->AddItem(CreateCommandButtonItemN(__pEditModel->GetKeypadCommandButtonActionId(COMMAND_BUTTON_POSITION_RIGHT), rightButtonText));
7003 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
7005 if (__pActionEventListener)
7007 __pCommandButton->AddActionEventListener(*__pActionEventListener);
7012 r = __pParentForm->AttachChild(*__pCommandButton);
7013 __pParentForm->MoveChildToTop(*__pCommandButton);
7017 pParent = __pEdit->GetParent();
7018 SysTryCatch(NID_UI_CTRL, pParent, r = E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
7019 r = pParent->AttachChild(*__pCommandButton);
7021 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
7026 delete pNormalBackgroundBitmap;
7028 delete __pCommandButton;
7029 __pCommandButton = null;
7031 delete pReplacementColorBackgroundBitmap;
7037 _EditPresenter::CheckInitialFooterVisibleState(void)
7039 if (__pParentForm == null)
7044 _Toolbar* pFooter = __pParentForm->GetFooter();
7047 if (pFooter->GetVisibleState() == false)
7049 __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_HIDE;
7050 SysLog(NID_UI_CTRL, "EDIT_FOOTER_VISIBLE_STATUS_HIDE");
7054 __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_SHOW;
7055 SysLog(NID_UI_CTRL, "EDIT_FOOTER_VISIBLE_STATUS_SHOW");
7060 __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
7061 SysLog(NID_UI_CTRL, "EDIT_FOOTER_VISIBLE_STATUS_NONE");
7068 _EditPresenter::SetFooterVisible(bool isVisible)
7070 if (__pParentForm == null)
7075 _Toolbar* pFooter = __pParentForm->GetFooter();
7076 if (pFooter && __initialFooterVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_SHOW)
7078 if ((isVisible == true && pFooter->GetVisibleState() == false) ||
7079 (isVisible == false && pFooter->GetVisibleState() == true))
7083 SysLog(NID_UI_CTRL, "SetFooterVisible TRUE!!!");
7087 SysLog(NID_UI_CTRL, "SetFooterVisible FALSE!!!");
7090 __footerVisibleChanged = true;
7091 pFooter->SetVisibleState(isVisible);
7092 pFooter->Invalidate();
7096 __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
7105 _EditPresenter::ShowFullscreenKeypad(void)
7107 result r = E_SUCCESS;
7109 if (__isCopyPasteManagerExist)
7111 InitializeCopyPasteManager();
7114 if (IsKeypadEnabled() == false)
7116 __pEdit->SetFocused();
7120 if (__pFullscreenKeypad)
7122 __pFullscreenKeypad->Close();
7123 delete __pFullscreenKeypad;
7124 __pFullscreenKeypad = null;
7127 __isKeypadExist = CheckKeypadExist(__pEdit->GetOrientation());
7128 if (__isKeypadExist) //overlay style keypad exist before create fullscreen edit.
7130 AdjustParentPanelHeight(true);
7134 SysLog(NID_UI_CTRL, "Form deflate RESET!!!");
7135 __pParentForm->DeflateClientRectHeight(0);
7136 __pParentForm->Draw();
7140 int editStyle = __pEdit->GetEditStyle();
7142 _KeypadStyleInfo keypadStyleInfo;
7143 keypadStyleInfo.keypadStyle = __pEditModel->GetKeypadStyle();
7144 keypadStyleInfo.textPredictionEnabled = __pEditModel->IsTextPredictionEnabled();
7145 keypadStyleInfo.isNormalNumberStyle = __isKeypadNormalNumberStyleEnabled;
7146 keypadStyleInfo.enterActionEnabled = true;
7147 keypadStyleInfo.isLowerCaseModeEnabled = __pEditModel->IsLowerCaseModeEnabled();
7149 bool inputConnectionBoundState = __isInputConnectionBound;
7150 __isInputConnectionBound = true;
7151 SetKeypadStyle(__pEditModel->GetKeypadStyle());
7152 __isInputConnectionBound = inputConnectionBoundState;
7154 if (editStyle & EDIT_STYLE_SINGLE_LINE)
7156 keypadStyleInfo.enterActionEnabled = false;
7159 if (editStyle & EDIT_STYLE_PASSWORD)
7161 editStyle = EDIT_STYLE_NORMAL | EDIT_STYLE_SINGLE_LINE | EDIT_STYLE_PASSWORD;
7165 editStyle = EDIT_STYLE_NORMAL;
7168 __pFullscreenKeypad = _Keypad::CreateKeypadN();
7169 SysTryReturn(NID_UI_CTRL, __pFullscreenKeypad, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance.");
7170 r = __pFullscreenKeypad->Initialize(editStyle, keypadStyleInfo, GetTextLimitLength(), __pEdit);
7171 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
7173 __pFullscreenKeypad->SetText(GetText());
7175 r = __pFullscreenKeypad->Open();
7176 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
7178 if (__pEdit->IsInputEventEnabled())
7180 __pEdit->LockInputEvent();
7185 __pFullscreenKeypad->SetEditTextFilter(this);
7191 _EditPresenter::DeleteFullscreenKeypad(void)
7193 if (__pFullscreenKeypad)
7195 __pFullscreenKeypad->Close();
7196 delete __pFullscreenKeypad;
7197 __pFullscreenKeypad = null;
7204 _EditPresenter::GetKeypadBounds(FloatRectangle& bounds)
7206 if (__pInputConnection == null)
7211 bounds = __pInputConnection->GetInputPanelBoundsF();
7213 _CoordinateSystem* pCoordSystem = _CoordinateSystem::GetInstance();
7214 SysTryReturnResult(NID_UI_CTRL, pCoordSystem, E_SYSTEM, "Coordinate system load failed.");
7216 _ICoordinateSystemTransformer* pXformer = pCoordSystem->GetInverseTransformer();
7217 SysTryReturnResult(NID_UI_CTRL, pXformer, E_SYSTEM, "Coordinate system load failed.");
7219 bounds = pXformer->Transform(bounds);
7220 __keypadBounds = bounds;
7226 _EditPresenter::GetClipboardHeight(void) const
7228 return __clipboardHeight;
7232 _EditPresenter::IsKeypadRotating(_ControlOrientation orientation)
7234 FloatDimension screenSize;
7235 FloatRectangle absKeypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
7236 _ControlManager* pControlManager = _ControlManager::GetInstance();
7238 GetKeypadBounds(absKeypadBounds);
7240 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
7242 screenSize.height = pControlManager->GetScreenSizeF().height;
7243 screenSize.width = pControlManager->GetScreenSizeF().width;
7247 screenSize.height = pControlManager->GetScreenSizeF().width;
7248 screenSize.width = pControlManager->GetScreenSizeF().height;
7251 if (absKeypadBounds.width == screenSize.width)
7262 _EditPresenter::CheckKeypadExist(_ControlOrientation orientation)
7264 FloatDimension screenSize;
7265 FloatRectangle absKeypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
7266 _ControlManager* pControlManager = _ControlManager::GetInstance();
7268 GetKeypadBounds(absKeypadBounds);
7270 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
7272 screenSize.height = pControlManager->GetScreenSizeF().height;
7273 screenSize.width = pControlManager->GetScreenSizeF().width;
7277 screenSize.height = pControlManager->GetScreenSizeF().width;
7278 screenSize.width = pControlManager->GetScreenSizeF().height;
7281 if (absKeypadBounds.width != 0 && absKeypadBounds.height != 0)
7283 if ((absKeypadBounds.y != screenSize.height))
7285 SysLog(NID_UI_CTRL, "KEYPAD EXIST!!!Keypad(y: %f, w: %f, h: %f)", absKeypadBounds.y, absKeypadBounds.width, absKeypadBounds.height);
7290 SysLog(NID_UI_CTRL, "NO KEYPAD!!!Keypad(y: %f, w: %f, h: %f)", absKeypadBounds.y, absKeypadBounds.width, absKeypadBounds.height);
7296 SysLog(NID_UI_CTRL, "NO KEYPAD!!!Keypad(y: %f, w: %f, h: %f)", absKeypadBounds.y, absKeypadBounds.width, absKeypadBounds.height);
7302 _EditPresenter::ShowKeypad(bool focus)
7304 if (!__pEdit->IsVisible())
7309 if (IsKeypadEnabled() == false)
7316 __pEdit->SetFocused();
7320 if (!__isInitialized)
7325 _ControlManager* pControlManager = _ControlManager::GetInstance();
7327 if (!pControlManager->IsFrameActivated())
7332 bool sendKeypadEventForcely = false;
7334 CheckUSBKeyboardStatus();
7336 __isInputConnectionBound = true;
7338 SetKeypadStyle(__pEditModel->GetKeypadStyle());
7340 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE && GetKeypadAction() == CORE_KEYPAD_ACTION_ENTER)
7342 __pInputConnection->SetInputPanelActionEnabled(false);
7346 __pInputConnection->SetInputPanelAction(ConvertKeypadAction(GetKeypadAction()));
7349 //Need to complete AutoCapitalization functionality
7350 if (__pEditModel->IsLowerCaseModeEnabled())
7352 __pInputConnection->SetAutoCapitalizationMode(AUTO_CAPITALIZATION_MODE_NONE);
7356 __pInputConnection->SetAutoCapitalizationMode(AUTO_CAPITALIZATION_MODE_SENTENCE);
7359 __pInputConnection->BindInputMethod();
7360 __isKeypadShowing = true;
7361 __isKeypadHiding = false;
7362 __resizedByKeypadHide = false;
7363 __latestBoundedContext = (unsigned int)this;
7365 LanguageCode initialKeypadLanguage = LANGUAGE_INVALID;
7366 __pEditModel->GetInitialKeypadLanguage(initialKeypadLanguage);
7367 if (initialKeypadLanguage != LANGUAGE_INVALID)
7369 SetCurrentLanguage(initialKeypadLanguage);
7372 if (__isUSBKeyboardConnected)
7374 SysLog(NID_UI_CTRL, "ShowKeypad called in USB ON mode!!!");
7376 __isKeypadExist = CheckKeypadExist(__pEdit->GetOrientation()); //prediction alreaedy exists
7378 if (__isKeypadCommandButtonVisible)
7380 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
7381 __pEdit->AttachScrollPanelEvent();
7382 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
7384 if (__initialFooterVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_NONE)
7386 CheckInitialFooterVisibleState();
7389 SetFooterVisible(false);
7390 ChangeLayoutInternal(__pEdit->GetOrientation());
7391 AdjustParentPanelHeight(false);
7392 ScrollPanelToCursorPosition();
7394 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
7395 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
7399 __pParentForm->Draw();
7404 if (__initialFooterVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_NONE)
7406 CheckInitialFooterVisibleState();
7409 if (__isKeypadExist)
7413 sendKeypadEventForcely = !__pParentForm->IsDeflated();
7416 if (sendKeypadEventForcely)
7418 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
7419 __pEdit->AttachScrollPanelEvent();
7420 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
7423 ChangeLayoutInternal(__pEdit->GetOrientation());
7424 AdjustParentPanelHeight(false);
7425 ScrollPanelToCursorPosition();
7429 __pParentForm->Draw();
7432 if (sendKeypadEventForcely)
7434 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
7435 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
7442 SysLog(NID_UI_CTRL, "ShowKeypad called in USB OFF mode!!!");
7444 __isKeypadExist = CheckKeypadExist(__pEdit->GetOrientation()); //call once only from here.
7446 if (!__isKeypadExist)
7448 if (__isKeypadCommandButtonVisible)
7450 if (!__pCommandButton || (__pCommandButton && !__pCommandButton->GetVisibleState()))
7452 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
7453 __pEdit->AttachScrollPanelEvent();
7454 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
7455 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
7456 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
7461 if (!__isClipboardExist)
7463 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
7465 __pEdit->AttachScrollPanelEvent();
7466 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
7469 if (__initialFooterVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_NONE)
7471 CheckInitialFooterVisibleState();
7476 if (__footerVisibleChanged)
7478 SetFooterVisible(true);
7481 if (__initialFooterVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_NONE)
7483 CheckInitialFooterVisibleState();
7487 if (__isKeypadCommandButtonVisible)
7489 SetFooterVisible(false);
7492 if (__isKeypadExist) //edit switiching
7496 sendKeypadEventForcely = !__pParentForm->IsDeflated();
7499 if (sendKeypadEventForcely)
7501 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
7502 __pEdit->AttachScrollPanelEvent();
7503 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
7506 ChangeLayoutInternal(__pEdit->GetOrientation());
7507 AdjustParentPanelHeight(false);
7508 ScrollPanelToCursorPosition();
7512 __pParentForm->Draw();
7514 __isKeypadShowing = false;
7516 if (sendKeypadEventForcely)
7518 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
7519 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
7524 if(!__isClipboardExist && __pParentPanel)
7526 if (__initialParentHeight)
7528 AdjustParentPanelHeight(true);
7531 ScrollPanelToCursorPosition();
7534 __pInputConnection->ShowInputPanel();
7541 _EditPresenter::ChangeLayout(_ControlOrientation orientation)
7543 result r = E_SUCCESS;
7545 if (__pCopyPasteManager)
7547 if (__pCopyPasteManager->GetCopyPastePopup())
7549 __needToCreateCopyPastePopup = true;
7551 __pCopyPasteManager->Release();
7554 bool isScrollPanelBoundsReloaded = false;
7558 _ControlImpl* pParentPanelImpl = static_cast <_ControlImpl* >(__pParentPanel->GetUserData());
7559 Rectangle builderBounds;
7560 isScrollPanelBoundsReloaded= pParentPanelImpl->GetBuilderBounds(orientation, builderBounds);
7565 CheckUSBKeyboardStatus();
7567 if (__isInputConnectionBound || __clipboardConnected)
7569 SysLog(NID_UI_CTRL, "-------------------ChangeLayout------------------------");
7571 if (!isScrollPanelBoundsReloaded)
7573 SysLog(NID_UI_CTRL, "ScrollPanel bounds is not changed by UIBuilder, so forcely reset ScrollPanel's height");
7574 AdjustParentPanelHeight(true);
7578 SysLog(NID_UI_CTRL, "ScrollPanel bounds is changed by UIBuilder");
7583 SysLog(NID_UI_CTRL, "Form deflate RESET!!!");
7584 __pParentForm->DeflateClientRectHeight(0.0f);
7587 if (__pCommandButton && __isKeypadCommandButtonVisible)
7589 __pCommandButton->SetVisibleState(false);
7592 if (__isKeypadExist && ! __isClipboardExist) //only keypad exists, already get keypadbounds before callback [Causion]this timing clipboard height is still previous height
7594 if (isScrollPanelBoundsReloaded)
7596 __initialParentHeight = 0.0f;
7599 ChangeLayoutInternal(orientation);
7600 AdjustParentPanelHeight(false);
7601 ScrollPanelToCursorPosition();
7603 else // if clipboard exists, boundsChanged callback will delivered after rotate callback
7606 if (__isClipboardExist)
7608 __initialParentHeight = 0.0f;
7610 else //no keypad, no clipboard
7612 if (__isKeypadCommandButtonVisible)
7614 __initialParentHeight = 0.0f;
7615 ChangeLayoutInternal(orientation);
7616 AdjustParentPanelHeight(false);
7617 ScrollPanelToCursorPosition();
7621 if (!__isClipboardExist)
7623 if (__isKeypadCommandButtonVisible)
7625 __initialParentHeight = 0.0f;
7626 ChangeLayoutInternal(orientation);
7627 AdjustParentPanelHeight(false);
7628 ScrollPanelToCursorPosition();
7634 if ((__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) == false)
7636 __initialBounds = __pEdit->GetBoundsF();
7639 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to change layout.", GetErrorMessage(r));
7645 _EditPresenter::ChangeLayout(_ControlRotation rotation)
7647 _ControlOrientation orientation = _CONTROL_ORIENTATION_PORTRAIT;
7649 if (rotation == _CONTROL_ROTATION_0 || rotation == _CONTROL_ROTATION_180)
7651 orientation = _CONTROL_ORIENTATION_PORTRAIT;
7655 orientation = _CONTROL_ORIENTATION_LANDSCAPE;
7658 return ChangeLayout(orientation);
7662 _EditPresenter::ChangeLayoutInternal(_ControlOrientation orientation, bool deflateForm)
7664 result r = E_SUCCESS;
7666 FloatRectangle keypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
7668 _ControlManager* pControlManager = _ControlManager::GetInstance();
7669 SysTryReturnResult(NID_UI_CTRL, pControlManager, E_SYSTEM, "Failed to get root.");
7670 FloatDimension screenSize;
7671 FloatRectangle commandButtonBounds(0.0f, 0.0f, 0.0f, 0.0f);
7673 float formDeflateHeight = 0.0f;
7674 float shrinkedHeight = 0.0f;
7676 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
7678 screenSize.width = pControlManager->GetScreenSizeF().width;
7679 screenSize.height = pControlManager->GetScreenSizeF().height;
7683 screenSize.width = pControlManager->GetScreenSizeF().height;
7684 screenSize.height = pControlManager->GetScreenSizeF().width;
7687 if (__isInputConnectionBound || __clipboardConnected)
7689 GetKeypadBounds(keypadBounds);
7691 if (__isKeypadExist)
7693 if (__isClipboardExist)
7695 if (__clipboardHeight > keypadBounds.height)
7697 shrinkedHeight = __clipboardHeight;
7701 shrinkedHeight = keypadBounds.height;
7706 shrinkedHeight = keypadBounds.height;
7711 if (__isClipboardExist)
7713 shrinkedHeight = __clipboardHeight;
7717 if (__isKeypadCommandButtonVisible)
7719 commandButtonBounds.width = screenSize.width;
7720 float commandButtonHeight = 0.0f;
7724 GET_SHAPE_CONFIG(FOOTER::HEIGHT, orientation, commandButtonHeight);
7725 commandButtonBounds.height = commandButtonHeight;
7726 formDeflateHeight += commandButtonBounds.height;
7728 if (__isKeypadExist || __isClipboardExist)
7730 formDeflateHeight += shrinkedHeight;
7731 commandButtonBounds.y = screenSize.height - shrinkedHeight - commandButtonBounds.height - __pParentForm->GetClientBoundsF().y;
7735 commandButtonBounds.y = screenSize.height - commandButtonBounds.height - __pParentForm->GetClientBoundsF().y;
7738 SetKeypadCommandButton(commandButtonBounds);
7740 if (__pCommandButton)
7742 __pCommandButton->SetVisibleState(true);
7743 __pCommandButton->Invalidate();
7751 if (__isKeypadExist || __isClipboardExist)
7753 formDeflateHeight += shrinkedHeight;
7759 if (__pParentForm && deflateForm)
7761 SysLog(NID_UI_CTRL, "FormDeflateHeight:%f, KeypadExist(%d), ClipboardExist(%d), CommandButtonVisible(%d)",
7762 formDeflateHeight, __isKeypadExist, __isClipboardExist, __isKeypadCommandButtonVisible);
7763 __pParentForm->DeflateClientRectHeight(formDeflateHeight);
7770 _EditPresenter::OnScrollPanelBoundsChanged(void)
7776 _EditPresenter::AdjustParentPanelHeight(bool restore)
7778 if (__pParentPanel == null)
7780 SysLog(NID_UI_CTRL, "__pParentPanel is NULL!!!, so skip resizing scrollpanel");
7784 float initialParentHeight = __initialParentHeight;
7785 if (__pResizedPanel != __pParentPanel)
7787 initialParentHeight = 0.0f;
7790 _ControlOrientation orientation;
7791 float commandButtonHeight = 0.0f;
7793 FloatRectangle absKeypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
7795 _Toolbar* pFooter = null;
7799 pFooter = __pParentForm->GetFooter();
7802 FloatRectangle absScrollPanelBounds(0.0f, 0.0f, 0.0f, 0.0f);
7803 FloatRectangle scrollPanelBounds = __pParentPanel->GetBoundsF();
7806 _ControlManager* pControlManager = _ControlManager::GetInstance();
7807 float displayedPanelHeight = 0.0f;
7808 FloatDimension screenSize;
7810 if (__pEdit->GetOrientation()== _CONTROL_ORIENTATION_PORTRAIT)
7812 screenSize.width = pControlManager->GetScreenSizeF().width;
7813 screenSize.height = pControlManager->GetScreenSizeF().height;
7817 screenSize.width = pControlManager->GetScreenSizeF().height;
7818 screenSize.height = pControlManager->GetScreenSizeF().width;
7823 if (initialParentHeight)
7825 scrollPanelBounds.height = __initialParentHeight;
7826 SysLog(NID_UI_CTRL, "Rollback ScrollPanel's height to %f and Set __initialParentHeight to 'Zero' ", __initialParentHeight);
7827 __initialParentHeight = 0.0f;
7828 __pResizedPanel = null;
7829 __pParentPanel->SetBounds(scrollPanelBounds);
7830 __pParentPanel->Invalidate();
7834 SysLog(NID_UI_CTRL, "initialParentHeight is ZERO!!!, so skip scrollPanel height recovery!!!");
7839 if (__isKeypadExist)
7841 GetKeypadBounds(absKeypadBounds);
7843 if (__isClipboardExist)
7845 if (__clipboardHeight > absKeypadBounds.height)
7847 absKeypadBounds.y = screenSize.height - __clipboardHeight;
7852 if (__isUSBKeyboardConnected)//predictive window shown
7854 absKeypadBounds.y = screenSize.height - absKeypadBounds.height;//only absKeypadBounds.height is meaningful in USB on.
7860 if (__isClipboardExist)
7862 absKeypadBounds.y = screenSize.height - __clipboardHeight;
7866 absKeypadBounds.y = screenSize.height;
7870 if ((__pParentForm && __isKeypadCommandButtonVisible) || (pFooter && (pFooter->GetVisibleState() == true)))
7872 orientation = __pEdit->GetOrientation();
7873 GET_SHAPE_CONFIG(FOOTER::HEIGHT, orientation, commandButtonHeight);
7876 absScrollPanelBounds = __pParentPanel->GetAbsoluteBoundsF(true);
7877 displayedPanelHeight = screenSize.height - commandButtonHeight - absScrollPanelBounds.y;
7878 gapY = (absKeypadBounds.y - commandButtonHeight)- absScrollPanelBounds.y;
7880 bool isOverlapped = true;
7882 if (((absKeypadBounds.y - commandButtonHeight) >= (absScrollPanelBounds.y + absScrollPanelBounds.height)) || ( absScrollPanelBounds.y > absKeypadBounds.y))
7884 isOverlapped = false;
7887 SysLog(NID_UI_CTRL, "IsOverlapped:(%d), __initialParentHeight:(%f), gapY:(%f)", isOverlapped, __initialParentHeight, gapY);
7889 if (!initialParentHeight)
7898 initialParentHeight = scrollPanelBounds.height;
7899 __initialParentHeight = initialParentHeight;
7900 __pResizedPanel = __pParentPanel;
7902 SysLog(NID_UI_CTRL, "Set ScrollPanel's height to %f and Set __initialParentHeight:(%f)", gapY, __initialParentHeight);
7904 scrollPanelBounds.height = gapY;
7905 __pParentPanel->SetBounds(scrollPanelBounds);
7906 __pParentPanel->Invalidate();
7913 if ((gapY < initialParentHeight) && (gapY > 0.0f))
7915 SysLog(NID_UI_CTRL, "Set ScrollPanel's height to %f", gapY);
7917 scrollPanelBounds.height = gapY;
7918 __pParentPanel->SetBounds(scrollPanelBounds);
7919 __pParentPanel->Invalidate();
7924 if (gapY > initialParentHeight)
7926 if (scrollPanelBounds.height > initialParentHeight)
7928 __initialParentHeight = scrollPanelBounds.height ;
7932 SysLog(NID_UI_CTRL, "Set ScrollPanel's height to %f", __initialParentHeight);
7934 scrollPanelBounds.height = initialParentHeight;
7935 __pParentPanel->SetBounds(scrollPanelBounds);
7936 __pParentPanel->Invalidate();
7944 if (scrollPanelBounds.height > initialParentHeight)
7946 __initialParentHeight = scrollPanelBounds.height ;
7949 SysLog(NID_UI_CTRL, "Set ScrollPanel's height to %f", gapY);
7950 scrollPanelBounds.height = gapY;
7951 __pParentPanel->SetBounds(scrollPanelBounds);
7952 __pParentPanel->Invalidate();
7959 _EditPresenter::HideKeypad(bool focus)
7961 InitializeCopyPasteManager();
7963 __isKeypadShowing = false;
7964 __resizedByKeypadHide = false;
7966 if (__isInitialized == false || !__isInputConnectionBound)
7971 CheckUSBKeyboardStatus();
7973 if (__isUSBKeyboardConnected)
7975 SysLog(NID_UI_CTRL, "HideKeypad called in USB ON mode!!!");
7976 if (__pCommandButton && __isKeypadCommandButtonVisible)
7978 SetFooterVisible(true);
7980 __pCommandButton->SetVisibleState(false);
7984 SysLog(NID_UI_CTRL, "Form deflate RESET!!!");
7985 __pParentForm->DeflateClientRectHeight(0.0f);
7988 AdjustParentPanelHeight(true);
7990 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
7995 SysLog(NID_UI_CTRL, "HideKeypad called in USB OFF mode!!!");
7996 if (__pCommandButton && __isKeypadCommandButtonVisible)
7998 if (!__isKeypadExist)
8000 SetFooterVisible(true);//must be called ahead of DeflateClientRectHeights
8004 SysLog(NID_UI_CTRL, "Form deflate RESET!!!");
8005 __pParentForm->DeflateClientRectHeight(0.0f);
8007 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
8009 __pCommandButton->SetVisibleState(false);
8013 FinishTextComposition();
8014 __pInputConnection->HideInputPanel();
8015 __pInputConnection->UnbindInputMethod();
8017 if (__isKeypadExist)
8019 __isKeypadHiding = true;
8022 __isInputConnectionBound = false;
8024 if (focus && __pEdit->IsFocused())
8026 __pEdit->SetFocused(false);
8033 _EditPresenter::ChangeKeypadStatus(void)
8035 InitializeCopyPasteManager();
8037 if (__isInputConnectionBound)
8039 __isInputConnectionBound = false;
8046 _EditPresenter::OnTimerExpired(Timer& timer)
8048 Timer* onTimer = &timer;
8050 if (onTimer == __pCursorTimer)
8052 OnCursorTimerExpired();
8054 else if (onTimer == __pTitleSlidingTimer)
8056 OnTitleSlidingTimerExpired();
8058 else if (onTimer == __pPasswordTimer)
8060 OnPasswordTimerExpired();
8062 else if (onTimer == __pFlickAnimationTimer)
8064 OnFlickTimerExpired();
8071 _EditPresenter::OnEditCopyPasteStatusChanged(CoreCopyPasteStatus status, CoreCopyPasteAction action)
8075 case CORE_COPY_PASTE_ACTION_COPY:
8076 __pEdit->CopyText();
8078 case CORE_COPY_PASTE_ACTION_CUT:
8080 InitializeCopyPasteManager();
8082 case CORE_COPY_PASTE_ACTION_PASTE:
8083 __pEdit->PasteText();
8084 InitializeCopyPasteManager();
8086 case CORE_COPY_PASTE_ACTION_SEARCH:
8087 InitializeCopyPasteManager();
8089 case CORE_COPY_PASTE_ACTION_CLIPBOARD:
8090 __clipboardConnected = true;
8095 __pEdit->Invalidate();
8101 _EditPresenter::InitializeCursor(void)
8105 if (__isCursorDisabled == false && IsCurrentFocused() && __isTextBlocked == false)
8107 bool outOfRangeInSignleLine = false;
8108 FloatRectangle cursorBounds;
8109 if (CalculateCursorBounds(__textObjectBounds, cursorBounds) != E_SUCCESS)
8111 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
8113 outOfRangeInSignleLine = true;
8117 __pCursorVisualElement->SetOpacity(1.0f);
8118 __pCursorVisualElement->SetBounds(cursorBounds);
8120 Canvas* pCanvas = __pCursorVisualElement->GetCanvasN();
8121 if (pCanvas == null)
8126 if (outOfRangeInSignleLine)
8128 __isCursorOpaque = false;
8132 __isCursorInitialized = false;
8135 DrawCursor(*pCanvas, cursorBounds, __isCursorOpaque);
8137 if (__pInputConnection)
8139 FloatRectangle absoluteEditRectangle;
8140 if (GetCursorBounds(false, absoluteEditRectangle) == E_SUCCESS)
8142 __pInputConnection->SetCursorBounds(absoluteEditRectangle);
8145 __isCursorOpaque = __isCursorOpaque ? false : true;
8149 __previousCursorBounds = cursorBounds;
8154 __pCursorVisualElement->SetOpacity(0);
8157 if (__pInputConnection != null && __isInputConnectionBound == true && !__isCopyPasteManagerExist)
8159 __pInputConnection->SetCursorPosition(__cursorPos);
8166 _EditPresenter::StopCursorTimer(void)
8170 __pCursorTimer->Cancel();
8176 _EditPresenter::StartCursorTimer(void)
8178 result r = E_SUCCESS;
8180 if (__pCursorTimer == null)
8182 __pCursorTimer = new (std::nothrow) Timer;
8183 if (__pCursorTimer == null)
8185 return E_OUT_OF_MEMORY;
8188 r = __pCursorTimer->Construct(*this);
8195 r = __pCursorTimer->Start(EDIT_CURSOR_TIMER_PERIOD);
8206 delete __pCursorTimer;
8207 __pCursorTimer = null;
8213 _EditPresenter::DrawCursor(Canvas& canvas, FloatRectangle& cursorBounds, bool isCursorOpaque)
8215 result r = E_SUCCESS;
8217 if (__isCursorDisabled == false)
8220 GET_COLOR_CONFIG(EDIT::CURSOR_NORMAL, cursorColor);
8222 if (__isCursorInitialized)
8224 cursorBounds.SetPosition(0.0f, 0.0f);
8226 if (canvas.GetBackgroundColor() != cursorColor)
8228 canvas.FillRectangle(cursorColor, cursorBounds);
8233 __pCursorVisualElement->SetOpacity(1.0f);
8237 __pCursorVisualElement->SetOpacity(0);
8242 cursorBounds.SetPosition(0.0f, 0.0f);
8244 canvas.FillRectangle(cursorColor, cursorBounds);
8245 __isCursorInitialized = true;
8251 __pCursorVisualElement->SetOpacity(0);
8258 _EditPresenter::MoveCursor(const FloatRectangle& fromRect, const FloatRectangle& toRect)
8260 if ((__previousCursorBounds.x != fromRect.x) || (__previousCursorBounds.y != fromRect.y) || (__previousCursorBounds.width != fromRect.width) || (__previousCursorBounds.height != fromRect.height))
8265 __pCursorVisualElement->SetOpacity(0);
8267 __pCursorVisualElement->SetBounds(toRect);
8268 Canvas* pCanvas = __pCursorVisualElement->GetCanvasN();
8270 if (pCanvas == null)
8275 if (toRect.y < 0.0f || toRect.y >= __clientBounds.height ||
8276 toRect.x < 0.0f || toRect.x >= __clientBounds.width)
8282 __pCursorVisualElement->SetOpacity(1.0f);
8286 GET_COLOR_CONFIG(EDIT::CURSOR_NORMAL, cursorColor);
8288 pCanvas->FillRectangle(cursorColor, toRect);
8290 __previousCursorBounds = toRect;
8297 _EditPresenter::OnCursorTimerExpired(void)
8299 if (!IsCurrentFocused() && __isCursorDisabled)
8305 FloatRectangle cursorBounds;
8307 if (CalculateCursorBounds(__textObjectBounds, cursorBounds) != E_SUCCESS)
8312 if ((__previousCursorBounds.x != cursorBounds.x) || (__previousCursorBounds.y != cursorBounds.y) || (__previousCursorBounds.width != cursorBounds.width) || (__previousCursorBounds.height != cursorBounds.height))
8314 __previousCursorBounds = cursorBounds;
8317 if (__pCursorVisualElement)
8319 __pCursorVisualElement->SetBounds(cursorBounds);
8320 Canvas* pCanvas = __pCursorVisualElement->GetCanvasN();
8321 if (pCanvas == null)
8326 DrawCursor(*pCanvas, cursorBounds, __isCursorOpaque);
8331 __isCursorOpaque = __isCursorOpaque ? false : true;
8334 if (__pCopyPasteManager)
8336 __pCopyPasteManager->UpdateCopyPasteMagnifier();
8343 _EditPresenter::GetEllipsisPosition(void) const
8345 return __pEdit->GetEllipsisPosition();
8349 _EditPresenter::SetEllipsisPosition(EllipsisPosition position)
8351 result r = E_SUCCESS;
8352 TextObjectEllipsisType ellipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_TAIL;
8353 if (position == ELLIPSIS_POSITION_START)
8355 ellipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_HEAD;
8357 else if (position == ELLIPSIS_POSITION_MIDDLE)
8359 ellipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_MIDDLE;
8362 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
8364 r = __pTextObject->SetTextObjectEllipsisType(ellipsisType);
8365 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Unable to Set ellipsis position.");
8371 _EditPresenter::OnFontInfoRequested(unsigned long& style, float& size)
8373 style = __contentFontStyle;
8374 size = __contentFontSize;
8380 _EditPresenter::OnFontChanged(Font* pFont)
8382 if (!__isFontInitialized)
8387 result r = E_SUCCESS;
8389 r = AdjustFont(*pFont, EDIT_FONT_CHANGE_ALL);
8390 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "Unable to set font.");
8392 __titleFontFaceName = pFont->GetFaceName();
8398 _EditPresenter::GetFont(void) const
8404 _EditPresenter::GetTextSize(void) const
8406 return _CoordinateSystemUtils::ConvertToInteger(__contentFontSize);
8410 _EditPresenter::GetTextSizeF(void) const
8412 return __contentFontSize;
8416 _EditPresenter::GetFontStyle(const Font* pBaseFont) const
8418 unsigned long style = FONT_STYLE_MIN;
8420 if (pBaseFont->IsPlain())
8422 style |= FONT_STYLE_PLAIN;
8424 if (pBaseFont->IsItalic())
8426 style |= FONT_STYLE_ITALIC;
8428 if (pBaseFont->IsBold())
8430 style |= FONT_STYLE_BOLD;
8437 _EditPresenter::SetTextSize(const int size)
8439 result r = E_SUCCESS;
8440 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
8441 r = GetLastResult();
8442 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
8444 r = fontImpl->SetSize(size);
8445 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "SetSize is failed.");
8449 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
8450 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
8451 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
8454 if (IsGuideTextActivated())
8456 r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
8457 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
8460 __contentFontSize = _CoordinateSystemUtils::ConvertToFloat(size);
8465 _EditPresenter::SetTextSize(const float size)
8467 result r = E_SUCCESS;
8468 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
8469 r = GetLastResult();
8470 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
8472 r = fontImpl->SetSize(size);
8473 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "SetSize is failed.");
8477 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
8478 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
8479 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
8482 if (IsGuideTextActivated())
8484 r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
8485 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
8488 __contentFontSize = size;
8493 _EditPresenter::SetFont(const Font& font)
8495 result r = E_SUCCESS;
8497 Font* pFont = _FontImpl::CloneN(const_cast <Font&>(font));
8498 SysTryReturnResult(NID_UI_CTRL, pFont, GetLastResult(), "Unable to create font.");
8504 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
8505 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
8506 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "Unable to set font.");
8509 if (IsGuideTextActivated())
8511 r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
8512 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "Unable to set font.");
8519 _EditPresenter::AdjustFont(Font& font, _EditFontChange fontChange)
8521 result r = E_SUCCESS;
8522 Font* pFont = &font;
8524 _FontImpl* fontImpl = _FontImpl::GetInstance(*pFont);
8525 r = GetLastResult();
8526 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
8528 if (fontChange == EDIT_FONT_CHANGE_TITLE || fontChange == EDIT_FONT_CHANGE_ALL)
8530 if (__pTitleTextObject)
8532 r = fontImpl->SetSize(__titleFontSize);
8533 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "SetSize is failed.");
8535 r = __pTitleTextObject->SetFont(pFont, 0, __pTitleTextObject->GetTextLength());
8536 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
8540 if (fontChange == EDIT_FONT_CHANGE_CONTENT || fontChange == EDIT_FONT_CHANGE_ALL)
8542 r = fontImpl->SetSize(__contentFontSize);
8543 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "SetSize is failed.");
8545 unsigned long style = FONT_STYLE_PLAIN;
8547 if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_BOLD)
8549 style |= FONT_STYLE_BOLD;
8551 if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_ITALIC)
8553 style |= FONT_STYLE_ITALIC;
8556 fontImpl->SetStyle(style);
8558 if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_UNDERLINE)
8560 fontImpl->SetUnderline(true);
8562 if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_STRIKEOUT)
8564 fontImpl->SetStrikeOut(true);
8569 r = __pTextObject->SetFont(pFont, 0, __pTextObject->GetTextLength());
8570 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
8571 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
8574 if (__pGuideTextObject)
8576 r = __pGuideTextObject->SetFont(pFont, 0, __pGuideTextObject->GetTextLength());
8577 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
8583 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
8592 _EditPresenter::GetTitleFontFaceName(void)
8594 return __titleFontFaceName;
8598 _EditPresenter::GetFontType(String& typefaceName, unsigned long& styleMask) const
8600 result r = E_SUCCESS;
8604 typefaceName = __pFont->GetFaceName();
8607 styleMask = __contentTextStyle;
8613 _EditPresenter::SetFontType(const String& typefaceName, unsigned long styleMask)
8615 result r = E_SUCCESS;
8618 IList* systemFontList = Font::GetSystemFontListN();
8619 SysTryReturnResult(NID_UI_CTRL, systemFontList, E_SYSTEM, "Unable to get system font list.\n");
8621 int fontListCount = systemFontList->GetCount();
8622 String tempFontFaceName;
8623 bool isFaceNameAvailable = false;
8625 float textSize = __pFont->GetSizeF();
8626 unsigned long fontStyle = FONT_STYLE_PLAIN;
8628 if (styleMask & TEXT_BOX_TEXT_STYLE_ITALIC)
8630 fontStyle |= FONT_STYLE_ITALIC;
8632 if (styleMask & TEXT_BOX_TEXT_STYLE_BOLD)
8634 fontStyle |= FONT_STYLE_BOLD;
8637 for (int i = 0; i < fontListCount; i++)
8639 tempFontFaceName = *static_cast<String*>(systemFontList->GetAt(i));
8641 pFont = new (std::nothrow) Font;
8642 SysTryCatch(NID_UI_CTRL, pFont, , r = E_OUT_OF_MEMORY, "Unable to get text information.\n");
8643 r = pFont->Construct(tempFontFaceName, fontStyle, textSize);
8644 SysTryCatch(NID_UI_CTRL, !IsFailed(r), , r, "Unable to construct Font.\n");
8646 // check font face name.
8647 if (typefaceName.Equals(pFont->GetFaceName(), true))
8649 isFaceNameAvailable = true;
8657 SysTryCatch(NID_UI_CTRL, isFaceNameAvailable, , r = E_INVALID_ARG, "The unsupported font face name is given.\n");
8659 if (styleMask & TEXT_BOX_TEXT_STYLE_UNDERLINE)
8661 pFont->SetUnderline(true);
8663 if (styleMask & TEXT_BOX_TEXT_STYLE_STRIKEOUT)
8665 pFont->SetStrikeOut(true);
8668 __contentFontStyle = fontStyle;
8669 __contentTextStyle = styleMask;
8673 systemFontList->RemoveAll(true);
8674 delete systemFontList;
8675 systemFontList = null;
8679 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
8680 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
8681 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "Unable to set font.");
8692 systemFontList->RemoveAll(true);
8693 delete systemFontList;
8694 systemFontList = null;
8700 _EditPresenter::GetTextStyle(void) const
8702 return __contentTextStyle;
8706 _EditPresenter::SetTextStyle(unsigned long textStyle)
8708 result r = E_SUCCESS;
8710 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
8711 r = GetLastResult();
8712 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
8714 unsigned long style = FONT_STYLE_PLAIN;
8716 if (textStyle & TEXT_BOX_TEXT_STYLE_BOLD)
8718 style |= FONT_STYLE_BOLD;
8720 if (textStyle & TEXT_BOX_TEXT_STYLE_ITALIC)
8722 style |= FONT_STYLE_ITALIC;
8725 fontImpl->SetStyle(style);
8727 if (textStyle & TEXT_BOX_TEXT_STYLE_UNDERLINE)
8729 fontImpl->SetUnderline(true);
8733 fontImpl->SetUnderline(false);
8736 if (textStyle & TEXT_BOX_TEXT_STYLE_STRIKEOUT)
8738 fontImpl->SetStrikeOut(true);
8742 fontImpl->SetStrikeOut(false);
8747 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
8748 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
8749 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
8752 if (IsGuideTextActivated())
8754 r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
8755 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
8758 __contentTextStyle = textStyle;
8764 _EditPresenter::GetGuideText(void) const
8770 _EditPresenter::SetGuideText(const String& guideText)
8772 result r = E_SUCCESS;
8774 int length = guideText.GetLength();
8776 __guideText = String(guideText);
8777 wchar_t* tempString = const_cast<wchar_t*>(__guideText.GetPointer());
8780 if (__pGuideTextObject != null)
8782 delete __pGuideTextObject;
8783 __pGuideTextObject = null;
8786 __pGuideTextObject = new (std::nothrow) TextObject;
8787 if (__pGuideTextObject == null)
8789 return E_OUT_OF_MEMORY;
8791 __pGuideTextObject->Construct();
8792 TextSimple* pSimpleText = new (std::nothrow)TextSimple(tempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
8793 __pGuideTextObject->AppendElement(*pSimpleText);
8795 __pGuideTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
8796 __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
8798 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_GUIDE);
8800 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
8802 __pGuideTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_CHARACTER);
8806 __pGuideTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
8809 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
8815 _EditPresenter::GetTitleText(void) const
8821 _EditPresenter::SetTitleText(const String& title)
8823 result r = E_SUCCESS;
8825 int length = title.GetLength();
8827 __titleText = String(title);
8828 wchar_t* tempString = const_cast<wchar_t*>(__titleText.GetPointer());
8830 if (__pTitleTextObject != null)
8832 delete __pTitleTextObject;
8833 __pTitleTextObject = null;
8836 __pTitleTextObject = new (std::nothrow) TextObject;
8837 if (__pTitleTextObject == null)
8839 return E_OUT_OF_MEMORY;
8841 __pTitleTextObject->Construct();
8842 TextSimple* pSimpleText = new (std::nothrow)TextSimple(tempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
8843 __pTitleTextObject->AppendElement(*pSimpleText);
8845 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_TITLE);
8846 __pTitleTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
8847 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
8848 __pTitleTextObject->Compose();
8850 float titleFontSize = 0.0f;
8851 GET_SHAPE_CONFIG(EDIT::DEFAULT_TITLE_FONT_SIZE, __pEdit->GetOrientation(), titleFontSize);
8853 __titleFontSize = titleFontSize;
8855 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
8859 r = fontImpl->SetSize(__titleFontSize);
8860 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "SetSize is failed.");
8864 r = GetLastResult();
8865 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
8868 __pTitleTextObject->SetFont(__pFont, 0, __pTitleTextObject->GetTextLength());
8870 r = fontImpl->SetSize(__contentFontSize);
8871 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "SetSize is failed.");
8873 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
8879 _EditPresenter::GetTextLineCount(void) const
8881 if (GetTextLength() == 0)
8886 if (__isInitialized == false)
8888 __pTextObject->SetBounds(__textObjectBounds);
8889 __pTextObject->Compose();
8892 return __pTextObject->GetTotalLineCount();
8896 _EditPresenter::GetTextTotalHeight(void) const
8898 if (GetTextLength() == 0)
8903 if (__isInitialized == false)
8905 __pTextObject->SetBounds(__textObjectBounds);
8906 __pTextObject->Compose();
8909 return __pTextObject->GetTotalHeight();
8913 _EditPresenter::GetTextTotalHeightF(void) const
8915 if (GetTextLength() == 0)
8920 if (__isInitialized == false)
8922 __pTextObject->SetBounds(__textObjectBounds);
8923 __pTextObject->Compose();
8926 return __pTextObject->GetTotalHeightF();
8930 _EditPresenter::Resize(void)
8935 __pTextObject->SetBounds(__textObjectBounds);
8936 __pTextObject->Compose();
8937 __isCursorChanged = true;
8938 __pTextObject->ConvertToRowColumn(__cursorPos, __rowCursorIndex, __columnCursorIndex);
8940 __pTextObject->SetFirstDisplayLineIndex(0);
8941 __pTextObject->SetFirstDisplayPositionY(0);
8943 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_NOSCROLL))
8945 if (__pScrollBar == null)
8947 __pScrollBar = _Scroll::CreateScrollN(*__pEdit,
8948 SCROLL_DIRECTION_VERTICAL,
8956 SysTryReturn(NID_UI_CTRL, __pScrollBar != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to create the scroll.");
8957 __pEdit->AttachSystemChild(*__pScrollBar);
8959 __pScrollBar->SetScrollVisibility(false);
8960 __pScrollBar->OnParentBoundsChanged();
8963 __verticalMargin = __pEdit->GetBoundsF().height - __textObjectBounds.height;
8965 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
8967 if (__initialBounds.height > __verticalMargin)
8969 if (__initialBounds.height > __pEdit->GetBoundsF().height)
8971 __prevTotalTextHeight = __initialBounds.height - __verticalMargin;
8975 __prevTotalTextHeight = __pEdit->GetBoundsF().height - __verticalMargin;
8985 _EditPresenter::SetClientBounds(void)
8987 int editStyle = __pEdit->GetEditStyle();
8989 __clientBounds = __pEdit->GetBoundsF();
8990 __clientBounds.x = 0.0f;
8991 __clientBounds.y = 0.0f;
8993 if (!(editStyle & EDIT_STYLE_SINGLE_LINE))
8998 float leftBorder = 0.0f;
8999 float rightBorder = 0.0f;
9000 float topBorder = 0.0f;
9001 float bottomBorder = 0.0f;
9002 float leftMargin = 0.0f;
9003 float rightMargin = 0.0f;
9004 float topMargin = 0.0f;
9005 float bottomMargin = 0.0f;
9006 _ControlOrientation orientation = __pEdit->GetOrientation();
9008 GET_SHAPE_CONFIG(EDIT::FIELD_LEFT_MARGIN, orientation, leftMargin);
9009 GET_SHAPE_CONFIG(EDIT::FIELD_RIGHT_MARGIN, orientation, rightMargin);
9010 GET_SHAPE_CONFIG(EDIT::FIELD_TOP_MARGIN, orientation, topMargin);
9011 GET_SHAPE_CONFIG(EDIT::FIELD_BOTTOM_MARGIN, orientation, bottomMargin);
9013 if (editStyle & EDIT_STYLE_TITLE_LEFT)
9015 float titleWidth = 0.0f;
9016 if (__titleWidth != -1.0f)
9018 titleWidth = __titleWidth;
9022 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_RECT_WIDTH, orientation, titleWidth);
9025 leftBorder = titleWidth;
9026 rightBorder = rightMargin;
9027 topBorder = topMargin;
9028 bottomBorder = bottomMargin;
9030 else if (editStyle & EDIT_STYLE_TITLE_TOP)
9032 result r = E_SUCCESS;
9033 float titletHeight = 0.0f;
9034 float titleTextTopMargin = 0.0f;
9035 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_RECT_HEIGHT, orientation, titletHeight);
9036 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_TOP_MARGIN, orientation, titleTextTopMargin);
9038 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
9039 SysTryReturnVoidResult(NID_UI_CTRL, fontImpl != null, E_SYSTEM, "[E_SYSTEM] fontImpl is null.");
9041 float originalSize = fontImpl->GetSizeF();
9042 float titleFontSize = 0.0f;
9043 GET_SHAPE_CONFIG(EDIT::DEFAULT_TITLE_FONT_SIZE, __pEdit->GetOrientation(), titleFontSize);
9045 r = fontImpl->SetSize(titleFontSize);
9046 SysTryReturnVoidResult(NID_UI_CTRL, !(IsFailed(r)), r, "SetSize is failed.");
9048 if (titletHeight < fontImpl->GetMaxHeightF())
9050 titleTextTopMargin -= (fontImpl->GetMaxHeightF()-titletHeight);
9051 titletHeight = fontImpl->GetMaxHeightF();
9054 r = fontImpl->SetSize(originalSize);
9055 SysTryReturnVoidResult(NID_UI_CTRL, !(IsFailed(r)), r, "SetSize is failed.");
9057 leftBorder = leftMargin;
9058 rightBorder = rightMargin;
9059 topBorder = titletHeight + titleTextTopMargin;
9060 bottomBorder = bottomMargin;
9063 __clientBounds.x = leftBorder;
9064 __clientBounds.y = topBorder;
9065 __clientBounds.width -= leftBorder + rightBorder;
9066 __clientBounds.height -= topBorder + bottomBorder;
9072 _EditPresenter::SetInitialEditFieldBounds(void)
9074 result r = E_SUCCESS;
9075 int editStyle = __pEdit->GetEditStyle();
9076 float bottomMargin = 0.0f;
9077 float textLeftMargin = 0.0f;
9078 float textRightMargin =0.0f;
9079 float textTopMargin = 0.0f;
9080 float textBottomMargin = 0.0f;
9081 float titleTextLeftMargin = 0.0f;
9082 float titleTextRightMargin =0.0f;
9083 float titleTextTopMargin = 0.0f;
9084 float titleTextBottomMargin = 0.0f;
9085 float clearIconWidth = 0.0f;
9086 float titletHeight = 0.0f;
9087 _ControlOrientation orientation = __pEdit->GetOrientation();
9089 GET_SHAPE_CONFIG(EDIT::FIELD_BOTTOM_MARGIN, orientation, bottomMargin);
9090 GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_LEFT_MARGIN, orientation, textLeftMargin);
9091 GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_RIGHT_MARGIN, orientation, textRightMargin);
9092 GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_TOP_MARGIN, orientation, textTopMargin);
9093 GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_BOTTOM_MARGIN, orientation, textBottomMargin);
9094 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_LEFT_MARGIN, orientation, titleTextLeftMargin);
9095 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_RIGHT_MARGIN, orientation, titleTextRightMargin);
9096 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_TOP_MARGIN, orientation, titleTextTopMargin);
9097 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_BOTTOM_MARGIN, orientation, titleTextBottomMargin);
9098 GET_SHAPE_CONFIG(EDIT::CLEAR_ICON_WIDTH, orientation, clearIconWidth);
9099 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_RECT_HEIGHT, orientation, titletHeight);
9101 if (!(editStyle & EDIT_STYLE_SINGLE_LINE))
9106 FloatRectangle bounds = __pEdit->GetBoundsF();
9107 if (editStyle & EDIT_STYLE_TITLE_LEFT)
9109 __textObjectBounds.x = __clientBounds.x + textLeftMargin;
9110 __textObjectBounds.y = __clientBounds.y + textTopMargin;
9111 __textObjectBounds.width = __clientBounds.width - textLeftMargin
9113 __textObjectBounds.height = __clientBounds.height - textTopMargin
9116 __titleBounds.x = titleTextLeftMargin;
9117 __titleBounds.y = titleTextTopMargin;
9118 __titleBounds.width = bounds.width - __clientBounds.width - __titleBounds.x;
9119 __titleBounds.height = __clientBounds.height - titleTextTopMargin
9120 - titleTextBottomMargin;
9122 if (editStyle & EDIT_STYLE_CLEAR)
9124 __textObjectBounds.width -= clearIconWidth;
9127 else if (editStyle & EDIT_STYLE_TITLE_TOP)
9129 __textObjectBounds.x = __clientBounds.x + textLeftMargin;
9130 __textObjectBounds.y = __clientBounds.y;
9131 __textObjectBounds.width = __clientBounds.width - textLeftMargin
9133 __textObjectBounds.height = __clientBounds.height - textBottomMargin;
9135 __titleBounds.x = titleTextLeftMargin;
9137 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
9138 SysTryReturnResult(NID_UI_CTRL, fontImpl != null, E_SYSTEM, "fontImpl is null.");
9140 float originalSize = fontImpl->GetSizeF();
9141 float titleFontSize = 0.0f;
9142 GET_SHAPE_CONFIG(EDIT::DEFAULT_TITLE_FONT_SIZE, __pEdit->GetOrientation(), titleFontSize);
9144 r = fontImpl->SetSize(titleFontSize);
9145 SysTryReturnResult(NID_UI_CTRL, !(IsFailed(r)), r, "SetSize is failed.");
9147 if (titletHeight < fontImpl->GetMaxHeightF())
9149 titleTextTopMargin -= (fontImpl->GetMaxHeightF()-titletHeight);
9152 r = fontImpl->SetSize(originalSize);
9153 SysTryReturnResult(NID_UI_CTRL, !(IsFailed(r)), r, "SetSize is failed.");
9155 __titleBounds.y = titleTextTopMargin;
9156 __titleBounds.width = bounds.width - __titleBounds.x - titleTextRightMargin;
9157 __titleBounds.height = bounds.height - __titleBounds.y - __clientBounds.height
9160 if (editStyle & EDIT_STYLE_CLEAR)
9162 __textObjectBounds.width -= clearIconWidth;
9165 else if ((editStyle & EDIT_STYLE_NORMAL) || (editStyle & EDIT_STYLE_CLEAR))
9167 __textObjectBounds = __clientBounds;
9168 float tempLeftMargin = __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
9169 float tempRightMargin = __pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
9171 if (tempLeftMargin != -1.0f)
9173 __textObjectBounds.x = __clientBounds.x + tempLeftMargin;
9174 __textObjectBounds.width = __clientBounds.width - tempLeftMargin;
9178 __textObjectBounds.x = __clientBounds.x + textLeftMargin;
9179 __textObjectBounds.width = __clientBounds.width - textLeftMargin;
9182 if (tempRightMargin != -1.0f)
9184 __textObjectBounds.width -= tempRightMargin;
9188 __textObjectBounds.width -= textRightMargin;
9191 if (editStyle & EDIT_STYLE_CLEAR)
9193 __textObjectBounds.width -= clearIconWidth;
9195 __textObjectBounds.y = __clientBounds.y + textTopMargin;
9196 __textObjectBounds.height = __clientBounds.height - textTopMargin
9201 float tempLeftMargin = __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
9202 float tempRightMargin = __pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
9203 if (tempLeftMargin != -1.0f)
9205 __textObjectBounds.x = __clientBounds.x + tempLeftMargin;
9206 __textObjectBounds.width = __clientBounds.width - tempLeftMargin;
9210 __textObjectBounds.x = __clientBounds.x + textLeftMargin;
9211 __textObjectBounds.width = __clientBounds.width - textLeftMargin;
9214 if (tempRightMargin != -1.0f)
9216 __textObjectBounds.width -= tempRightMargin;
9220 __textObjectBounds.width -= textRightMargin;
9222 __textObjectBounds.y = __clientBounds.y + textTopMargin;
9223 __textObjectBounds.height = __clientBounds.height - textTopMargin
9227 float textObectMinimumWidth = 0.0f;
9228 float textObjectMinimumHeight = 0.0f;
9229 GET_SHAPE_CONFIG(EDIT::TEXT_OBJECT_MININMUM_WIDTH, orientation, textObectMinimumWidth);
9230 GET_SHAPE_CONFIG(EDIT::TEXT_OBJECT_MININMUM_HEIGHT, orientation, textObjectMinimumHeight);
9232 if (__textObjectBounds.width < textObectMinimumWidth)
9234 __textObjectBounds.width = textObectMinimumWidth;
9237 if (__textObjectBounds.height <= textObjectMinimumHeight)
9239 __textObjectBounds.height = __contentFontSize;
9241 else if (__textObjectBounds.height < __contentFontSize)
9243 __textObjectBounds.y -= (__contentFontSize - __textObjectBounds.height)/2.0f;
9244 __textObjectBounds.height = __contentFontSize;
9247 if (editStyle & EDIT_STYLE_TITLE_LEFT)
9250 if (__titleBounds.width < textObectMinimumWidth)
9252 gap = textObectMinimumWidth - __titleBounds.width;
9253 __titleBounds.width = textObectMinimumWidth;
9254 __textObjectBounds.x += gap;
9256 if (__titleBounds.height < __titleFontSize)
9258 __titleBounds.height = __titleFontSize;
9266 _EditPresenter::SetInitialBounds(void)
9268 result r = E_SUCCESS;
9269 FloatRectangle bounds = __pEdit->GetBoundsF();
9270 int editStyle = __pEdit->GetEditStyle();
9272 if (editStyle & EDIT_STYLE_SINGLE_LINE)
9274 r = SetInitialEditFieldBounds();
9275 __textBoxBounds.x = 0.0f;
9276 __textBoxBounds.y = 0.0f;
9277 __textBoxBounds.width = bounds.width;
9278 __textBoxBounds.height = bounds.height;
9283 float leftMargin = 0.0f;
9284 float rightMargin = 0.0f;
9285 float topMargin = 0.0f;
9286 float bottomMargin = 0.0f;
9287 float textLeftMargin = 0.0f;
9288 float textRightMargin =0.0f;
9289 float textTopMargin = 0.0f;
9290 float textBottomMargin = 0.0f;
9291 float titleRectWidth = 0.0f;
9292 float titleRectHeight = 0.0f;
9293 float titleTextLeftMargin = 0.0f;
9294 float titleTextRightMargin = 0.0f;
9295 float titleTextTopMargin = 0.0f;
9296 float titleTextBottomMargin = 0.0f;
9297 float scrollWidth = 0.0f;
9298 _ControlOrientation orientation = __pEdit->GetOrientation();
9300 GET_SHAPE_CONFIG(EDIT::AREA_LEFT_MARGIN, orientation, leftMargin);
9301 GET_SHAPE_CONFIG(EDIT::AREA_RIGHT_MARGIN, orientation, rightMargin);
9302 GET_SHAPE_CONFIG(EDIT::AREA_TOP_MARGIN, orientation, topMargin);
9303 GET_SHAPE_CONFIG(EDIT::AREA_BOTTOM_MARGIN, orientation, bottomMargin);
9304 GET_SHAPE_CONFIG(EDIT::AREA_TEXT_LEFT_MARGIN, orientation, textLeftMargin);
9305 GET_SHAPE_CONFIG(EDIT::AREA_TEXT_RIGHT_MARGIN, orientation, textRightMargin);
9306 GET_SHAPE_CONFIG(EDIT::AREA_TEXT_TOP_MARGIN, orientation, textTopMargin);
9307 GET_SHAPE_CONFIG(EDIT::AREA_TEXT_BOTTOM_MARGIN, orientation, textBottomMargin);
9308 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_RECT_WIDTH, orientation, titleRectWidth);
9309 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_RECT_HEIGHT, orientation, titleRectHeight);
9310 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_LEFT_MARGIN, orientation, titleTextLeftMargin);
9311 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_RIGHT_MARGIN, orientation, titleTextRightMargin);
9312 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_TOP_MARGIN, orientation, titleTextTopMargin);
9313 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_BOTTOM_MARGIN, orientation, titleTextBottomMargin);
9314 GET_SHAPE_CONFIG(EDIT::AREA_SCROLL_WIDTH, orientation, scrollWidth);
9316 if (editStyle & EDIT_STYLE_TITLE_TOP)
9318 __textBoxBounds.x = leftMargin;
9319 __textBoxBounds.y = titleRectHeight + titleTextTopMargin;
9320 __textBoxBounds.width = bounds.width - leftMargin - rightMargin;
9321 __textBoxBounds.height = bounds.height - titleRectHeight - titleTextTopMargin - bottomMargin;
9323 else if (editStyle & EDIT_STYLE_TITLE_LEFT)
9325 float titleWidth = 0.0f;
9327 if (__titleWidth != -1.0f)
9329 titleWidth = __titleWidth;
9333 titleWidth = titleRectWidth;
9335 __textBoxBounds.x = titleWidth;
9336 __textBoxBounds.y = topMargin;
9337 __textBoxBounds.width = bounds.width - titleWidth - leftMargin;
9338 __textBoxBounds.height = bounds.height - topMargin - bottomMargin;
9342 __textBoxBounds.x = 0.0f;
9343 __textBoxBounds.y = 0.0f;
9344 __textBoxBounds.width = bounds.width;
9345 __textBoxBounds.height = bounds.height;
9348 // setting textBounds
9349 if (editStyle & EDIT_STYLE_TITLE_TOP)
9351 if (__pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN) != -1.0f)
9353 __textObjectBounds.x = __textBoxBounds.x + __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
9354 __textObjectBounds.width = __textBoxBounds.width - __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
9358 __textObjectBounds.x = __textBoxBounds.x + textLeftMargin;
9359 __textObjectBounds.width = __textBoxBounds.width - textLeftMargin;
9362 if (__pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN) != -1.0f)
9364 __textObjectBounds.width -= __pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
9368 __textObjectBounds.width -= textRightMargin;
9372 __textObjectBounds.y = __textBoxBounds.y;
9373 __textObjectBounds.height = __textBoxBounds.height - textBottomMargin;
9377 if (__pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN) != -1.0f)
9379 __textObjectBounds.x = __textBoxBounds.x + __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
9380 __textObjectBounds.width = __textBoxBounds.width - __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
9384 __textObjectBounds.x = __textBoxBounds.x + textLeftMargin;
9385 __textObjectBounds.width = __textBoxBounds.width - textLeftMargin;
9388 if (__pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN) != -1.0f)
9390 __textObjectBounds.width -= __pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
9394 __textObjectBounds.width -= textRightMargin;
9398 if (__pEdit->GetVerticalMarginF(EDIT_TEXT_TOP_MARGIN) != -1.0f)
9400 __textObjectBounds.y = __textBoxBounds.y + __pEdit->GetVerticalMarginF(EDIT_TEXT_TOP_MARGIN);
9401 __textObjectBounds.height = __textBoxBounds.height - __pEdit->GetVerticalMarginF(EDIT_TEXT_TOP_MARGIN);
9405 __textObjectBounds.y = __textBoxBounds.y + textTopMargin;
9406 __textObjectBounds.height = __textBoxBounds.height - textTopMargin;
9409 if (__pEdit->GetVerticalMarginF(EDIT_TEXT_BOTTOM_MARGIN) != -1.0f)
9411 __textObjectBounds.height -= __pEdit->GetVerticalMarginF(EDIT_TEXT_BOTTOM_MARGIN);
9415 __textObjectBounds.height -= textBottomMargin;
9419 if (editStyle & EDIT_STYLE_TITLE_TOP)
9421 __titleBounds.x = titleTextLeftMargin;
9422 __titleBounds.y = titleTextTopMargin;
9423 __titleBounds.width = bounds.width - titleTextLeftMargin
9424 - titleTextRightMargin;
9425 __titleBounds.height = bounds.height - __textBoxBounds.height - __titleBounds.y
9429 else if (editStyle & EDIT_STYLE_TITLE_LEFT)
9431 __titleBounds.x = titleTextLeftMargin;
9432 __titleBounds.y = titleTextTopMargin;
9433 __titleBounds.width = bounds.width - __textBoxBounds.width - __titleBounds.x
9434 - titleTextRightMargin;
9435 __titleBounds.height = __textBoxBounds.height - titleTextTopMargin
9436 - titleTextBottomMargin;
9439 if (editStyle & EDIT_STYLE_NOSCROLL)
9441 __isScrollBarVisible = false;
9442 __scrollBarBounds.x = 0.0f;
9443 __scrollBarBounds.y = 0.0f;
9444 __scrollBarBounds.width = 0.0f;
9445 __scrollBarBounds.height = 0.0f;
9449 __scrollBarBounds.width = scrollWidth;
9451 __scrollBarBounds.x = bounds.width - __scrollBarBounds.width;
9452 __scrollBarBounds.y = __textBoxBounds.y + textTopMargin;
9453 __scrollBarBounds.height = __textBoxBounds.height - textTopMargin - textBottomMargin;
9454 if (__scrollBarBounds.height < 0.0f)
9456 __scrollBarBounds.height = 0.0f;
9459 __isScrollBarVisible = true;
9461 if (editStyle & EDIT_STYLE_TITLE_TOP)
9463 __titleBounds.width -= __scrollBarBounds.width;
9467 float textObectMinimumWidth = 0.0f;
9468 GET_SHAPE_CONFIG(EDIT::TEXT_OBJECT_MININMUM_WIDTH, orientation, textObectMinimumWidth);
9470 if (__textObjectBounds.width < textObectMinimumWidth)
9472 __textObjectBounds.width = textObectMinimumWidth;
9475 if (__textObjectBounds.height < __contentFontSize)
9477 __textObjectBounds.height = __contentFontSize;
9484 _EditPresenter::StopTitleSlidingTimer(void)
9486 if (__pTitleSlidingTimer)
9488 __pTitleSlidingTimer->Cancel();
9489 delete __pTitleSlidingTimer;
9490 __pTitleSlidingTimer = null;
9497 _EditPresenter::StartTitleSlidingTimer(void)
9499 result r = E_SUCCESS;
9501 if (__pTitleSlidingTimer == null)
9503 __pTitleSlidingTimer = new (std::nothrow) Timer;
9504 if (__pTitleSlidingTimer == null)
9506 return E_OUT_OF_MEMORY;
9509 r = __pTitleSlidingTimer->Construct(*this);
9515 r = __pTitleSlidingTimer->Start(TITLE_SLIDING_TIME);
9523 StopTitleSlidingTimer();
9528 _EditPresenter::OnTitleSlidingTimerExpired(void)
9530 result r = E_SUCCESS;
9532 if (!IsCurrentFocused())
9534 StopTitleSlidingTimer();
9538 if (__pTitleTextObject->IsChanged())
9540 r = DrawTitleText();
9541 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to draw title text");
9544 Canvas *pTitleTextCanvas = __pTitleTextVisualElement->GetCanvasN();
9545 SysTryReturnResult(NID_UI_CTRL, pTitleTextCanvas, E_SYSTEM, "A system error has occurred. Failed to get canvas of VisualElement");
9547 if (__isTouchPressed)
9549 pTitleTextCanvas->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_PRESSED));
9553 pTitleTextCanvas->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED));
9556 pTitleTextCanvas->Clear();
9557 __pTitleTextObject->DrawWithOffset(*_CanvasImpl::GetInstance(*pTitleTextCanvas));
9558 r = pTitleTextCanvas->Show();
9560 delete pTitleTextCanvas;
9562 r = StartTitleSlidingTimer();
9568 _EditPresenter::ChangePasswordToEchoCharacter(int cursorPos, int textLength)
9570 result r = E_SUCCESS;
9572 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD))
9577 if (__isPasswordVisible)
9582 StartPasswordTimer();
9583 if (IsBlocked() == true)
9585 __pTextObject->SetRange(cursorPos, textLength);
9589 __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), 0);
9596 _EditPresenter::StopPasswordTimer(void)
9598 if (__pPasswordTimer)
9600 __pPasswordTimer->Cancel();
9601 delete __pPasswordTimer;
9602 __pPasswordTimer = null;
9609 _EditPresenter::StartPasswordTimer(void)
9611 result r = E_SUCCESS;
9613 if (__isPasswordVisible)
9618 if (__pPasswordTimer == null)
9620 __pPasswordTimer = new (std::nothrow) Timer;
9621 if (__pPasswordTimer == null)
9623 return E_OUT_OF_MEMORY;
9626 r = __pPasswordTimer->Construct(*this);
9629 StopPasswordTimer();
9634 r = __pPasswordTimer->Start(EDIT_PASSWORD_TIMER_PERIOD);
9637 StopPasswordTimer();
9644 _EditPresenter::OnPasswordTimerExpired(void)
9646 result r = E_SUCCESS;
9648 if (!IsCurrentFocused())
9653 ReplaceTextIntoPasswordHyphenString();
9654 if (__composingTextLength > 0)
9656 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
9657 SysTryReturnResult(NID_UI_CTRL, fontImpl != null, E_SYSTEM, "[E_SYSTEM] fontImpl is null.");
9658 fontImpl->SetUnderline(false);
9659 int composingStartPosition = GetCursorPosition()-__composingTextLength;
9660 __pTextObject->SetFont(__pFont, composingStartPosition, composingStartPosition+__composingTextLength);
9663 __isCursorChanged = true;
9665 __pEdit->Invalidate();
9671 _EditPresenter::ReplaceTextIntoPasswordHyphenString(void)
9673 result r = E_SUCCESS;
9675 if (__isPasswordVisible)
9680 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
9682 if (GetTextLength() > 0)
9684 ChangePasswordToEchoCharacter(__pTextBuffer, __echoChar);
9685 __isCursorChanged = true;
9693 _EditPresenter::ChangePasswordToEchoCharacter(wchar_t* dspStrBuffer, wchar_t echoChar)
9695 result r = E_SUCCESS;
9697 if (__isPasswordVisible)
9702 int bufferLength = GetTextLength();
9704 for (int i = 0; i < bufferLength && i < EDIT_PASSWORD_BUFFER_MAX - 1; i++)
9706 dspStrBuffer[i] = echoChar;
9708 dspStrBuffer[bufferLength] = null;
9709 __isCursorChanged = true;
9711 __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), 0);
9712 UpdateComponentInformation();
9718 _EditPresenter::ChangePasswordToPlainText(void)
9720 result r = E_SUCCESS;
9722 if (__isPasswordVisible == false)
9727 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
9729 int textLength = GetTextLength();
9730 if ((textLength > 0) && (textLength <= __limitLength))
9732 wchar_t* tempString = const_cast<wchar_t*>(__pTextString->GetPointer());
9733 for (int i = 0; i < textLength; i++)
9735 __pTextBuffer[i] = tempString[i];
9737 __pTextBuffer[textLength] = 0;
9738 __pTextObject->RemoveAll();
9739 TextSimple* pSimpleText = new (std::nothrow)TextSimple(__pTextBuffer, textLength,TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, __pFont);
9740 __pTextObject->AppendElement(*pSimpleText);
9741 __pTextObject->Compose();
9742 __isCursorChanged = true;
9750 _EditPresenter::SetAutoResizingEnabled(bool enable)
9752 return __pEditModel->SetAutoResizingEnabled(enable);
9756 _EditPresenter::IsAutoResizingEnabled(void) const
9758 return __pEditModel->IsAutoResizingEnabled();
9762 _EditPresenter::CalculateFlexibleHeightF(void)
9764 float height = 0.0f;
9765 float expectedEditHeight = __pTextObject->GetTotalHeightF() + __verticalMargin;
9766 int lineCount = __pTextObject->GetTotalLineCount();
9768 if (__pTextObject->GetTotalHeight())
9770 if ((lineCount >= MAX_LINE_NUMBER) && (GetMaxLineCount() > MAX_LINE_NUMBER))
9772 height = MAX_LINE_NUMBER * __pTextObject->GetLineHeightAtF(0) + __verticalMargin;
9776 float maxHeight = CalculateMaximumFlexibleHeight();
9778 //If InitialBounds is more than expectedEdit height, set flexible height as initial height
9779 if (expectedEditHeight < __initialBounds.height)
9781 height = __initialBounds.height;
9783 else if (expectedEditHeight >= maxHeight)
9789 height = expectedEditHeight;
9794 height = __initialBounds.height;
9801 _EditPresenter::AdjustFlexibleHeight(void)
9803 result r = E_SUCCESS;
9805 if (__isFlexibleHeightFrozen == true)
9810 __pTextObject->Compose();
9812 if (__prevTotalTextHeight == __pTextObject->GetTotalHeightF()) // if text height has not changed.
9814 __prevTotalTextHeight = __pTextObject->GetTotalHeightF();
9819 FloatRectangle bounds = __pEdit->GetBoundsF();
9820 float calculateHeight = CalculateFlexibleHeightF();
9822 FloatDimension flexHeightDim = CoordinateSystem::AlignToDevice(FloatDimension(0, calculateHeight));
9823 if (bounds.height != flexHeightDim.height)
9825 bounds.height = flexHeightDim.height;
9826 __prevTotalTextHeight = __pTextObject->GetTotalHeightF();
9828 FloatRectangle editBounds = CoordinateSystem::AlignToDevice(bounds);
9829 return SetFlexBounds(editBounds);
9831 __prevTotalTextHeight = __pTextObject->GetTotalHeight();
9836 _EditPresenter::SetFlexBounds(const FloatRectangle& bounds)
9838 result r = E_SUCCESS;
9840 _ExpandableEditAreaEventStatus expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_ADDED;
9841 if (__pEdit->GetBoundsF().height > bounds.height)
9843 expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_REMOVED;
9845 else if (__pEdit->GetBoundsF().height < bounds.height)
9847 expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_ADDED;
9850 _VisualElement* pVisualElement = __pEdit->GetVisualElement();
9851 SysTryReturnResult(NID_UI_CTRL, pVisualElement, E_SYSTEM, "A system error has occurred. Unable to get root visual element.");
9853 pVisualElement->SetAnimationProvider(__pEditVEDelegator);
9854 pVisualElement->SetImplicitAnimationEnabled(true);
9856 //Modify InitialBounds only on User calls and on Orientation change
9857 if (!((__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) == false))
9859 __updateInitialBounds = false;
9862 __pEdit->SetBounds(bounds);
9863 __updateInitialBounds = true;
9867 __pEdit->Invalidate();
9869 pVisualElement->SetImplicitAnimationEnabled(false);
9871 __prevTotalTextHeight = __pTextObject->GetTotalHeightF();
9872 __pEdit->SendExpandableEditAreaEvent(expandableEditAreaStatus, __pTextObject->GetTotalLineCount());
9878 _EditPresenter::CalculateMaximumFlexibleHeight(void)
9880 float maxHeight = 0.0f;
9881 int maximumFlexibleLineNumber = GetMaxLineCount();
9883 if (maximumFlexibleLineNumber > 0) // if max line number is set.
9885 maxHeight = maximumFlexibleLineNumber * __pTextObject->GetLineHeightAtF(0) + __verticalMargin;
9887 FloatDimension dim = __pEdit->GetMaximumSizeF();
9888 if (maxHeight > dim.height)
9890 maxHeight = dim.height;
9898 _EditPresenter::GetKeypadBoundsEx(Tizen::Graphics::FloatRectangle& bounds) const
9900 bounds.x = __keypadBounds.x;
9901 bounds.y = __keypadBounds.y;
9902 bounds.width = __keypadBounds.width;
9903 bounds.height = __keypadBounds.height;
9908 _EditPresenter::GetParentForm(void)
9915 if (__pParentForm == null)
9917 result r = E_SUCCESS;
9919 _Form* pForm = null;
9920 _Control* pControlCore = null;
9922 for (pControlCore = __pEdit->GetParent(); pForm == null; pControlCore = pControlCore->GetParent())
9924 if (pControlCore == null)
9930 pForm = dynamic_cast<_Form*>(pControlCore);
9940 _EditPresenter::GetParentPanel(void) const
9942 return __pParentPanel;
9946 _EditPresenter::SetKeypadCommandButtonVisible(bool visible)
9948 __isKeypadCommandButtonVisible = visible;
9953 _EditPresenter::SetKeypadCommandButton(CommandButtonPosition position, const String& text, int actionId)
9955 result r = E_SUCCESS;
9956 FooterItem footerItem;
9957 footerItem.Construct(actionId);
9958 footerItem.SetText(text);
9959 __isKeypadCommandButtonUserSetting = true;
9961 __pEditModel->SetCommandButtonItem(position, actionId, text);
9962 if (__pCommandButton)
9964 _Button* pButton = __pCommandButton->GetItem(static_cast<int>(position));
9967 pButton->SetActionId(actionId);
9968 pButton->SetText(text);
9976 _EditPresenter::GetKeypadCommandButton(void) const
9978 return __pCommandButton;
9982 _EditPresenter::AddActionEventListener(const _IActionEventListener& listener)
9986 if (__pCommandButton)
9988 __pCommandButton->AddActionEventListener(listener);
9991 __pActionEventListener = const_cast<_IActionEventListener*>(&listener);
9997 _EditPresenter::RemoveActionEventListener(const _IActionEventListener& listener)
10001 if (__pCommandButton)
10003 __pCommandButton->RemoveActionEventListener(listener);
10006 __pActionEventListener = null;
10012 _EditPresenter::SetTextBounds(Rectangle& bounds)
10014 __textObjectBounds = _CoordinateSystemUtils::ConvertToFloat(bounds);
10015 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
10017 __pTextObject->SetBounds(__textObjectBounds);
10018 __pTextObject->Compose();
10024 _EditPresenter::SetTextBounds(FloatRectangle& bounds)
10026 __textObjectBounds = bounds;
10027 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
10029 __pTextObject->SetBounds(__textObjectBounds);
10030 __pTextObject->Compose();
10036 _EditPresenter::GetTextBoundsF(void) const
10038 return __textObjectBounds;
10042 _EditPresenter::GetTextBounds(void) const
10044 return _CoordinateSystemUtils::ConvertToInteger(__textObjectBounds);
10048 _EditPresenter::IsKeypadCommandButtonVisible(void) const
10050 return __isKeypadCommandButtonVisible;
10054 _EditPresenter::GetKeypadCommandButtonText(CommandButtonPosition position) const
10056 return __pEditModel->GetKeypadCommandButtonText(position);
10060 _EditPresenter::GetKeypadCommandButtonActionId(CommandButtonPosition position) const
10062 return __pEditModel->GetKeypadCommandButtonActionId(position);
10066 _EditPresenter::DrawScrollBar(void)
10068 result r = E_SUCCESS;
10070 if (__pScrollBar == null)
10075 float totalHeight = __pTextObject->GetTotalHeightF();
10076 float dspHeight = __textObjectBounds.height;
10077 float firstDisplayY = __pTextObject->GetFirstDisplayPositionYF();
10079 if (totalHeight <= dspHeight)
10081 if (__prevTotalTextHeight != 0.0f && __prevTotalTextHeight == totalHeight) // flexible edit's case
10086 __pScrollBar->SetScrollRange(1, 1);
10087 __pScrollBar->SetScrollPosition(0.0f);
10089 __isScrollBarVisible = false;
10090 __previousScrollBarPos = 0.0f;
10091 __previousScrollBarMaxPos = 0.0f;
10095 if (firstDisplayY > 0)
10097 __pScrollBar->SetScrollRange(dspHeight, totalHeight);
10098 __pScrollBar->SetScrollPosition(firstDisplayY);
10099 __previousScrollBarMaxPos = totalHeight - dspHeight;
10103 __pScrollBar->SetScrollRange(dspHeight, totalHeight);
10104 __pScrollBar->SetScrollPosition(0.0f);
10105 __previousScrollBarMaxPos = 0.0f;
10108 if (__pScrollBar->GetScrollVisibility())
10110 __isScrollBarVisible = true;
10113 __previousScrollBarPos = firstDisplayY;
10120 _EditPresenter::FadeOutScrollBar(void)
10124 __pScrollBar->SetScrollVisibility(false);
10126 __isScrollBarVisible = false;
10132 _EditPresenter::InitializeFlickAnimation(void)
10134 result r = E_SUCCESS;
10136 if (__pFlickAnimation == null)
10138 __pFlickAnimation = new (std::nothrow) _FlickAnimation;
10141 // Init Flick Animation Config
10142 if (__pFlickAnimation)
10144 float width = 0.0f;
10145 float height = 0.0f;
10146 Tizen::Graphics::FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
10147 Tizen::Graphics::FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
10148 if (__pEdit->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
10150 width = portraitSize.width;
10151 height = portraitSize.height;
10155 width = landscapeSize.width;
10156 height = landscapeSize.height;
10159 __pFlickAnimation->SetSizeInformation(width, height, DEVICE_SIZE_HORIZONTAL, DEVICE_SIZE_VERTICAL);
10160 __pFlickAnimation->SetSensitivity(FLICK_ANIMATION_FPS_PANEL, FLICK_ANIMATION_SENSITIVITY_PANEL);
10167 if (__pFlickAnimationTimer == null)
10169 __pFlickAnimationTimer = new (std::nothrow) Timer;
10170 if (__pFlickAnimationTimer == null)
10172 r = E_OUT_OF_MEMORY;
10176 r = __pFlickAnimationTimer->Construct(*this);
10179 delete __pFlickAnimationTimer;
10191 _EditPresenter::StartFlickAnimation(const FloatPoint& flickPosition, int flickTime)
10193 // delete Scroll Fadeout Timer
10199 if (__textObjectBounds.height >= __pTextObject->GetTotalHeightF())
10204 if (InitializeFlickAnimation() != E_SUCCESS)
10209 //We must check the flick animation about float conversion work at later
10211 // Initialize flick animation
10215 __pFlickAnimation->CalculateInitializeVelocity(_CoordinateSystemUtils::ConvertToInteger(flickPosition.x), _CoordinateSystemUtils::ConvertToInteger(flickPosition.y), flickTime, &velocityX, &velocityY);
10217 if (Math::Abs(flickPosition.x) > Math::Abs(flickPosition.y))
10219 __pFlickAnimation->InitializeFlickAmount(velocityX);
10223 __pFlickAnimation->InitializeFlickAmount(velocityY);
10226 return StartFlickTimer(velocityY, velocityX);
10230 _EditPresenter::StartFlickTimer(int flickVelocityX, int flickVelocityY)
10232 if (__pFlickAnimation)
10234 if (ScrollContentsOnFlick() != E_SUCCESS)
10243 if (__pFlickAnimationTimer)
10245 if (__pFlickAnimationTimer->Start(EDIT_FLICK_SCROLL_TIMER_INTERVAL) != E_SUCCESS)
10261 _EditPresenter::ScrollContentsOnFlick(void)
10263 //We must check the flick animation about float conversion work at later
10265 if (__pFlickAnimation)
10267 int moveAmountX = 0;
10268 int moveAmountY = 0;
10269 __pFlickAnimation->CalculateNextMove(&moveAmountX, &moveAmountY);
10272 if (ScrollOnFlick(_CoordinateSystemUtils::ConvertToFloat(-moveAmountY*EDIT_FLICK_SCROLL_MOVE_AMOUNT_MULTIPLIER)))
10284 _EditPresenter::ScrollOnFlick(float moveDistanceY)
10286 if (moveDistanceY == 0)
10288 FadeOutScrollBar();
10292 if (!__pScrollBar->GetScrollVisibility())
10294 __pScrollBar->SetScrollVisibility(true);
10297 ScrollContents(moveDistanceY);
10303 _EditPresenter::SetCursorEnabled(bool enable)
10305 __isCursorOpaque = enable;
10311 _EditPresenter::IsCursorEnabled(void) const
10313 return __isCursorOpaque;
10317 _EditPresenter::StopFlickTimer(void)
10319 if (__pFlickAnimationTimer != null)
10321 __pFlickAnimationTimer->Cancel();
10322 delete __pFlickAnimationTimer;
10323 __pFlickAnimationTimer = null;
10330 _EditPresenter::OnFlickTimerExpired(void)
10332 result r = E_SUCCESS;
10334 if (__pFlickAnimationTimer)
10337 if (__pFlickAnimationTimer->Start(EDIT_FLICK_SCROLL_TIMER_INTERVAL) != E_SUCCESS)
10344 if (ScrollContentsOnFlick() != E_SUCCESS)
10349 FadeOutScrollBar();
10363 _EditPresenter::SetScrollBarVisible(bool enable)
10365 __isScrollBarVisible = enable;
10371 _EditPresenter::SetScrollBarBounds(const FloatRectangle& bounds)
10373 __scrollBarBounds = bounds;
10379 _EditPresenter::GetDisplayScrollBoundsF(void) const
10381 return __scrollBarBounds;
10385 _EditPresenter::GetInitialBoundsF(void) const
10387 return __initialBounds;
10391 _EditPresenter::SetPreviousScrollBarPosition(int position)
10393 __previousScrollBarPos = _CoordinateSystemUtils::ConvertToFloat(position);
10399 _EditPresenter::SetPreviousScrollBarPosition(float position)
10401 __previousScrollBarPos = position;
10407 _EditPresenter::GetPreviousScrollPosition(void) const
10409 return _CoordinateSystemUtils::ConvertToInteger(__previousScrollBarPos);
10413 _EditPresenter::GetPreviousScrollPositionF(void) const
10415 return __previousScrollBarPos;
10419 _EditPresenter::SetMaximumPreviousScrollBarPosition(int position)
10421 __previousScrollBarMaxPos = _CoordinateSystemUtils::ConvertToFloat(position);
10427 _EditPresenter::SetMaximumPreviousScrollBarPosition(float position)
10429 __previousScrollBarMaxPos = position;
10435 _EditPresenter::GetScrollBar(void) const
10437 return __pScrollBar;
10441 _EditPresenter::GetTextObject(void) const
10443 return __pTextObject;
10447 _EditPresenter::SetAutoShrinkModeEnabled(bool enable)
10449 __isAutoShrinkEnabled = enable;
10455 _EditPresenter::IsAutoShrinkModeEnabled(void) const
10457 return __isAutoShrinkEnabled;
10461 _EditPresenter::GetEditView(void) const
10467 _EditPresenter::InitializeParentPanel(void)
10469 if (__pParentPanel == null)
10471 _ScrollPanel* pScrollPanel = null;
10472 _Control* pControlCore = null;
10474 for (pControlCore = __pEdit->GetParent(); pScrollPanel == null; pControlCore = pControlCore->GetParent())
10476 if (pControlCore == null)
10481 pScrollPanel = dynamic_cast<_ScrollPanel*>(pControlCore);
10484 __pParentPanel = pScrollPanel;
10494 _EditPresenter::ScrollPanelToTop(bool show)
10496 if (!__pParentPanel)
10499 FloatRectangle editAbsoluteBounds = __pEdit->GetAbsoluteBoundsF(true);
10500 FloatRectangle panelAbsoluteBounds = __pParentPanel->GetAbsoluteBoundsF(true);
10501 float scrollPosition = __pParentPanel->GetScrollPosition() + (editAbsoluteBounds.y - panelAbsoluteBounds.y);
10503 __pParentPanel->SetScrollPosition(scrollPosition);
10507 __pParentPanel->Invalidate();
10514 _EditPresenter::ScrollPanelToCursorPosition(bool show)
10516 if (!__pParentPanel)
10519 result r = E_SUCCESS;
10521 UpdateComponentInformation();
10523 FloatRectangle absCursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
10524 r = CalculateAbsoluteCursorBounds(__cursorPos, absCursorBounds);
10526 if (r != E_SUCCESS)
10531 FloatRectangle absPanelRect = __pParentPanel->GetAbsoluteBoundsF(true);
10532 float panelHeight = __pParentPanel->GetBoundsF().height;
10534 float scrollPosition = __pParentPanel->GetScrollPosition();
10535 float cursorBoundsY = absCursorBounds.y - absPanelRect.y;
10537 float topYCompared = 0.0f;
10538 float bottomYCompared = panelHeight;
10540 if (__textObjectBounds.height < absCursorBounds.height)
10542 absCursorBounds.height = __textObjectBounds.height;
10545 float upSideGap = topYCompared - cursorBoundsY;
10546 float downSideGap = (upSideGap > 0.0f) ? 0.0f : cursorBoundsY + absCursorBounds.height - bottomYCompared;
10548 if (upSideGap > 0.0f || downSideGap > 0.0f)
10551 float topTextMargin = 0.0f;
10552 float bottomTextMargin = 0.0f;
10554 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
10556 topTextMargin = __pEdit->GetBoundsF().y;
10557 bottomTextMargin = __pEdit->GetBoundsF().height;
10561 topTextMargin = __textObjectBounds.y;
10562 bottomTextMargin = __pEdit->GetBoundsF().height - __textObjectBounds.y - __textObjectBounds.height;
10565 if (upSideGap > 0.0f)
10567 gap = scrollPosition - (upSideGap + topTextMargin);
10571 gap = scrollPosition + (downSideGap + bottomTextMargin);
10574 __pParentPanel->SetScrollPosition(gap);
10576 __pParentPanel->Invalidate();
10583 _EditPresenter::SetSearchBarFlag(bool enabled)
10585 __isSearchBar = enabled;
10591 _EditPresenter::GetSearchBarFlag(void) const
10593 return __isSearchBar;
10597 _EditPresenter::SetFocused(void)
10599 bool focused = true;
10600 if (__pParentPanel)
10602 _Window* pTop = __pParentPanel->GetRootWindow();
10605 if ((pTop->GetFocusControl(__pEdit) != __pEdit) && __pEdit->IsFocused() == false)
10611 else if (__pEdit->IsFocused() == false)
10616 if (focused == false)
10618 __pEdit->SetFocused();
10625 _EditPresenter::GetWordPosition(int cursorPos, int& startPos, int& endPos) const
10627 int textLength = GetTextLength();
10628 bool isDetected = false;
10630 if (cursorPos >= textLength && cursorPos > 0)
10636 if (IsDelimiter(__pTextBuffer[cursorPos]) && cursorPos > 0)
10642 for (int i = cursorPos; i >= 0; i--)
10644 if (IsDelimiter(__pTextBuffer[i]))
10652 if (isDetected == false)
10658 isDetected = false;
10661 for (int i = cursorPos; i < textLength; i++)
10663 if (IsDelimiter(__pTextBuffer[i]))
10671 if (isDetected == false)
10673 endPos = textLength;
10676 if (startPos > endPos)
10678 int temp = startPos;
10686 _EditPresenter::GetTextImageRangeAt(int postion, int& startPosition, int& endPosition) const
10688 int length = GetTextLength();
10689 startPosition = -1;
10692 SysTryReturnResult(NID_UI_CTRL, postion >= 0 && postion <= length, E_OUT_OF_RANGE, "The given index is out-of-range.");
10694 _Text::TextElement* pTextElement = __pTextObject->GetElementAtTextIndex(postion);
10695 const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
10696 if (pSimpleText != null && pSimpleText->GetBitmap() != null)
10698 startPosition = pSimpleText->GetTextOffset();
10699 endPosition = startPosition + pSimpleText->GetTextLength();
10703 return E_OBJ_NOT_FOUND;
10707 _EditPresenter::IsDelimiter(wchar_t character) const
10713 case 0x0A: // NLine Feed
10716 case 0x0D: // Carriage Return
10719 case 0x20: // Space
10730 _EditPresenter::InitializeCopyPasteManager(void)
10732 bool releaseBlock = true;
10734 if (__pCopyPasteManager)
10736 releaseBlock = __pCopyPasteManager->GetTextBlockReleaseFlag();
10737 delete __pCopyPasteManager;
10738 __pCopyPasteManager = null;
10741 if (IsBlocked() == true && releaseBlock)
10743 ReleaseTextBlock();
10744 __pEdit->Invalidate();
10747 __isCopyPasteManagerExist = false;
10748 __isCopyPastePopupMoving = false;
10754 _EditPresenter::IsCopyPasteManagerExist(void) const
10756 return __isCopyPasteManagerExist;
10760 _EditPresenter::GetTextAreaBoundsF(void) const
10762 return __textObjectBounds;
10766 _EditPresenter::GetTitleBoundsF(void) const
10768 return __titleBounds;
10772 _EditPresenter::GetClearIconBoundsF(void) const
10774 return __clearIconBounds;
10778 _EditPresenter::FinishTextComposition(void)
10780 if (__isInputConnectionBound && __isTextComposing)
10782 __pEdit->SetTextEventEnabled(false);
10783 __pInputConnection->FinishTextComposition();
10784 __isTextComposing = false;
10785 __composingTextLength = 0;
10786 __pEdit->SetTextEventEnabled(true);
10793 _EditPresenter::GetTextCompositionState(void) const
10795 return __isTextComposing;
10799 _EditPresenter::IsCopyPastePopup(const _Control& control) const
10801 if (__pCopyPasteManager)
10803 return __pCopyPasteManager->IsCopyPastePopup(control);
10810 _EditPresenter::IsCopyPasteHandle(const _Control& control) const
10812 if (__pCopyPasteManager)
10814 return __pCopyPasteManager->IsCopyPasteHandle(control);
10821 _EditPresenter::SetCursorChangedFlag(bool enabled)
10823 __isCursorChanged = enabled;
10829 _EditPresenter::GetCursorChangedFlag(void) const
10831 return __isCursorChanged;
10835 _EditPresenter::SetEditGroupStyle(GroupStyle groupStyle)
10837 __groupStyle = groupStyle;
10843 _EditPresenter::PostInternalEvent(const Tizen::Base::String& type)
10847 ArrayList* pArgs = new (std::nothrow) ArrayList();
10848 SysTryReturnVoidResult(NID_UI_CTRL, pArgs != null, E_SYSTEM, "[E_SYSTEM] pArgs is null.");
10850 result r = E_SYSTEM;
10851 r = pArgs->Construct();
10852 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to construct pArgs");
10854 String* pType = new (std::nothrow) String(type);
10855 SysTryReturnVoidResult(NID_UI, pType, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
10857 r = pArgs->Add(*pType);
10858 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to add type to pArgs");
10860 _UiNotificationEvent event(__pEdit->GetHandle(), pArgs);
10861 r = _UiEventManager::GetInstance()->PostEvent(event);
10862 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to send event");
10868 _EditPresenter::ReleaseCopyPastePopup(void)
10870 if (__pCopyPasteManager)
10872 return __pCopyPasteManager->ReleaseCopyPastePopup();
10877 _EditPresenter::IsCopyPastePopupExist(void) const
10879 if (__pCopyPasteManager)
10881 if (__pCopyPasteManager->GetCopyPastePopup())
10894 _EditPresenter::IsCopyPasteHandleExist(void) const
10896 if (__pCopyPasteManager)
10898 return __pCopyPasteManager->IsCopyPasteHandleExist();
10904 _EditPresenter::IsUnsupportedChracterExist(const KeypadStyle keypadStyle, const Tizen::Base::String& text)
10906 const int numberOfCharOnNumOnlyStyle = 10;
10907 const int numberOfCharOnPhoneNumStyle = 14;
10908 const int numberOfCharOnIpStyle = 18;
10910 const wchar_t* TempKey = null;
10911 const wchar_t characterOnNumOnlyStyle[numberOfCharOnNumOnlyStyle+1] = { 0x30/*0*/, 0x31/*1*/, 0x32/*2*/, 0x33/*3*/, 0x34/*4*/, 0x35/*5*/, 0x36/*6*/, 0x37/*7*/, 0x38/*8*/, 0x39/*9*/, 0};
10912 const wchar_t characterOnPhoneNumStyle[numberOfCharOnPhoneNumStyle+1] = { 0x30/*0*/, 0x31/*1*/, 0x32/*2*/, 0x33/*3*/, 0x34/*4*/, 0x35/*5*/, 0x36/*6*/, 0x37/*7*/, 0x38/*8*/, 0x39/*9*/,
10913 0x2a/***/, 0x2b/*+*/, 0x23/*#*/, 0x70/*p*/, 0};
10914 const wchar_t characterOnIPStyle[numberOfCharOnIpStyle+1] = { 0x30/*0*/, 0x31/*1*/, 0x32/*2*/, 0x33/*3*/, 0x34/*4*/, 0x35/*5*/, 0x36/*6*/, 0x37/*7*/, 0x38/*8*/, 0x39/*9*/,
10915 0x3a/*:*/, 0x2e/*.*/, 0x61/*a*/, 0x62/*b*/, 0x63/*c*/, 0x64/*d*/, 0x65/*e*/, 0x66/*f*/, 0};
10916 bool isSupportedCharacterExist = false;
10917 int supportedCharacterCount = 0;
10919 switch (keypadStyle)
10921 case KEYPAD_STYLE_NUMBER:
10922 supportedCharacterCount = numberOfCharOnNumOnlyStyle;
10923 TempKey = characterOnNumOnlyStyle;
10925 case KEYPAD_STYLE_PHONE_NUMBER:
10926 supportedCharacterCount = numberOfCharOnPhoneNumStyle;
10927 TempKey = characterOnPhoneNumStyle;
10929 case KEYPAD_STYLE_IP_V4:
10930 supportedCharacterCount = numberOfCharOnIpStyle;
10931 TempKey = characterOnIPStyle;
10937 if (text.GetLength() < 1)
10942 for (int i = 0; i < text.GetLength(); i++)
10944 isSupportedCharacterExist = false;
10945 wchar_t checkChar =0;
10946 if ( text.GetCharAt(i, checkChar) != E_SUCCESS)
10950 for (int j = 0; j < supportedCharacterCount ; j++)
10952 if (TempKey[j] == checkChar)
10954 isSupportedCharacterExist = true;
10958 if (!isSupportedCharacterExist)
10968 _EditPresenter::SetBlockRangeWithShiftArrowkey(_KeyCode keyCode)
10972 if (IsBlocked() == true)
10974 GetBlockRange(start, end);
10978 if (__textBlockMoveLeft)
10982 SetBlockRange(--start, end);
10987 if (start < end - 1)
10989 SetBlockRange(start, --end);
10991 else if (start == end - 1)
10993 ReleaseTextBlock();
10994 SetCursorPosition(start);
10999 if (__textBlockMoveLeft)
11001 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(start);
11003 if (curCursorLine > 0)
11005 int offset = start - __pTextObject->GetFirstTextIndexAt(curCursorLine);
11006 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine-1);
11007 start = offset + firstTextIndex;
11008 int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
11009 if (offset > textLength)
11011 start = firstTextIndex+textLength-1;
11013 SetBlockRange(start, end);
11018 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(end);
11020 if (curCursorLine > 0)
11022 int offset = end - __pTextObject->GetFirstTextIndexAt(curCursorLine);
11023 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine-1);
11024 end = offset + firstTextIndex;
11025 int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
11026 if (offset > textLength)
11028 end = firstTextIndex+textLength;
11035 __textBlockMoveLeft = true;
11036 SetBlockRange(start, end);
11038 else if (start == end)
11040 ReleaseTextBlock();
11041 SetCursorPosition(end);
11045 SetBlockRange(start, end);
11051 if (__textBlockMoveLeft)
11053 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(start);
11054 int totalLine = __pTextObject->GetTotalLineCount();
11055 if (curCursorLine < totalLine - 1)
11057 int offset = start - __pTextObject->GetFirstTextIndexAt(curCursorLine);
11058 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
11059 start = offset + firstTextIndex;
11060 int textLength = __pTextObject->GetTextLengthAt(curCursorLine+1);
11061 if (offset > textLength)
11063 start = firstTextIndex+textLength;
11071 __textBlockMoveLeft = false;
11072 SetBlockRange(start, end);
11074 else if (start == end)
11076 ReleaseTextBlock();
11077 SetCursorPosition(end);
11081 SetBlockRange(start, end);
11087 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(end);
11088 int totalLine = __pTextObject->GetTotalLineCount();
11089 if (curCursorLine < totalLine - 1)
11091 int offset = end - __pTextObject->GetFirstTextIndexAt(curCursorLine);
11092 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
11093 end = offset + firstTextIndex;
11094 int textLength = __pTextObject->GetTextLengthAt(curCursorLine+1);
11095 if (offset > textLength)
11097 end = firstTextIndex+textLength;
11099 SetBlockRange(start, end);
11104 if (__textBlockMoveLeft)
11106 if (start + 1 < end)
11108 SetBlockRange(++start, end);
11110 else if (start + 1 == end)
11112 ReleaseTextBlock();
11113 SetCursorPosition(end);
11118 if (end + 1 <= GetTextLength())
11120 SetBlockRange(start, ++end);
11130 if (__textBlockMoveLeft)
11132 __pTextObject->SetFirstDisplayLineIndexFromTextIndex(start);
11134 SetCursorChangedFlag(!__textBlockMoveLeft);
11143 if (__cursorPos > 0)
11145 start = __cursorPos - 1;
11147 SetBlockRange(start, end);
11148 __textBlockMoveLeft = true;
11153 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
11155 if (curCursorLine > 0)
11157 int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
11158 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine-1);
11159 start = offset + firstTextIndex;
11160 int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
11161 if (offset > textLength)
11163 start = firstTextIndex+textLength -1;
11166 SetBlockRange(start, end);
11167 __textBlockMoveLeft = true;
11172 if (GetTextLength() >= __cursorPos + 1)
11174 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
11175 int totalLine = __pTextObject->GetTotalLineCount();
11176 if (curCursorLine < totalLine - 1)
11178 int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
11179 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
11180 end = offset + firstTextIndex;
11181 int textLength = __pTextObject->GetTextLengthAt(curCursorLine+1);
11182 if (offset > textLength)
11184 end = firstTextIndex+textLength;
11187 else if (curCursorLine == totalLine - 1)
11189 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine);
11190 int textLength = __pTextObject->GetTextLengthAt(curCursorLine);
11191 end = firstTextIndex + textLength;
11193 start = __cursorPos;
11194 SetBlockRange(start, end);
11195 __textBlockMoveLeft = false;
11199 if (GetTextLength() >= __cursorPos + 1)
11201 start = __cursorPos;
11202 end = __cursorPos + 1;
11203 SetBlockRange(start, end);
11204 __textBlockMoveLeft = false;
11214 __textBlockMoving = true;
11219 _EditPresenter::SetBlockRangeWithCtrlShiftArrowkey(_KeyCode keyCode)
11223 int originalStart = 0;
11224 int originalEnd = 0;
11225 if (IsBlocked() == true)
11227 GetBlockRange(start, end);
11231 if (__textBlockMoveLeft)
11235 originalStart = start;
11237 GetWordPosition(start-1, start, end);
11238 SetBlockRange(start, originalEnd);
11243 originalStart = start;
11245 GetWordPosition(end, start, end);
11246 if (originalEnd == start)
11248 GetWordPosition(start-1, start, end);
11251 if (originalStart < start)
11253 SetBlockRange(originalStart, start);
11255 else if (originalStart > start)
11257 SetBlockRange(start, originalStart);
11258 __textBlockMoveLeft = true;
11260 else if (originalStart == start)
11262 ReleaseTextBlock();
11263 SetCursorPosition(start);
11264 __textBlockMoveLeft = true;
11269 if (__textBlockMoveLeft)
11271 originalStart = start;
11273 GetWordPosition(start, start, end);
11274 if (originalStart == end)
11276 GetWordPosition(end+1, start, end);
11278 if (originalEnd > end)
11280 SetBlockRange(end, originalEnd);
11282 else if (originalEnd < end)
11284 SetBlockRange(originalEnd, end);
11285 __textBlockMoveLeft = false;
11287 else if (originalEnd == end)
11289 ReleaseTextBlock();
11290 SetCursorPosition(end);
11291 __textBlockMoveLeft = false;
11296 if (end < GetTextLength())
11298 originalStart = start;
11300 GetWordPosition(end+1, start, end);
11301 SetBlockRange(originalStart, end);
11311 if (__textBlockMoveLeft)
11313 __pTextObject->SetFirstDisplayLineIndexFromTextIndex(start);
11315 SetCursorChangedFlag(!__textBlockMoveLeft);
11324 if (__cursorPos > 0)
11326 GetWordPosition(__cursorPos, start, end);
11327 if (__cursorPos != start)
11329 SetBlockRange(start, __cursorPos);
11333 GetWordPosition(start-1, start, end);
11334 SetBlockRange(start, __cursorPos);
11336 __textBlockMoveLeft = true;
11340 if (GetTextLength() >= __cursorPos + 1)
11342 GetWordPosition(__cursorPos, start, end);
11343 if (__cursorPos != end)
11345 SetBlockRange(__cursorPos, end);
11349 GetWordPosition(end+1, start, end);
11350 SetBlockRange(__cursorPos, end);
11352 __textBlockMoveLeft = false;
11362 __textBlockMoving = true;
11367 _EditPresenter::SetEditTextFilter(_IEditTextFilter* pFilter)
11369 __pTextFilter = pFilter;
11375 _EditPresenter::ValidatePastedText(const String& pastedText, String& replacedText)
11377 bool enable = false;
11380 enable = __pTextFilter->ValidatePastedText(pastedText, replacedText);
11387 _EditPresenter::SendOpaqueCommand (const String& command)
11389 if (command.Equals(L"KEYPAD_STYLE: PASSWORD", true))
11391 if (__pInputConnection)
11393 __pInputConnection->SetPasswordMode(true);
11397 if (__pInputConnection)
11399 __pInputConnection->SendOpaqueCommand(command);
11406 _EditPresenter::IsBounded(void) const
11408 return __isInputConnectionBound;
11412 _EditPresenter::AdjustRTLTextAlignment(const _EditTextType textType)
11414 result r = E_SUCCESS;
11418 case EDIT_TEXT_TYPE_INPUT:
11419 if (GetTextAlignment() != ALIGNMENT_LEFT)
11421 if (_BidiUtils::IsRTL(GetText()) == true)
11423 __pTextObject->SetTextBidiHint(TEXT_BIDI_HINT_RTL);
11427 __pTextObject->SetTextBidiHint(TEXT_BIDI_HINT_LTR);
11431 if (_BidiUtils::IsRTL(GetText()) == true)
11433 if (__horizontalAlignmentForBidi == ALIGNMENT_LEFT)
11435 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
11437 r = __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
11441 r = __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_TOP);
11443 __horizontalAlignmentForBidi = ALIGNMENT_RIGHT;
11444 __pTextObject->SetTextBidiHint(TEXT_BIDI_HINT_RTL);
11445 if (r == E_SUCCESS)
11453 if (__horizontalAlignmentForBidi == ALIGNMENT_RIGHT)
11455 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
11457 r = __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
11461 r = __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
11463 __horizontalAlignmentForBidi = ALIGNMENT_LEFT;
11464 __pTextObject->SetTextBidiHint(TEXT_BIDI_HINT_LTR);
11465 if (r == E_SUCCESS)
11472 case EDIT_TEXT_TYPE_GUIDE:
11473 if (__pGuideTextObject == null)
11477 if (_BidiUtils::IsRTL(__guideText) == true)
11479 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
11481 r = __pGuideTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
11485 r = __pGuideTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_TOP);
11487 __pGuideTextObject->SetTextBidiHint(TEXT_BIDI_HINT_RTL);
11488 if (r == E_SUCCESS)
11495 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
11497 r = __pGuideTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
11501 r = __pGuideTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
11503 __pGuideTextObject->SetTextBidiHint(TEXT_BIDI_HINT_LTR);
11504 if (r == E_SUCCESS)
11510 case EDIT_TEXT_TYPE_TITLE:
11511 if (__pTitleTextObject == null)
11515 if (_BidiUtils::IsRTL(__titleText) == true)
11517 r = __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
11518 if (r == E_SUCCESS)
11525 r = __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
11526 if (r == E_SUCCESS)
11540 _EditPresenter::UpdateKeypadCommandString(void)
11542 if (!__isKeypadCommandButtonUserSetting)
11544 __pEditModel->UpdateKeypadCommandButtonText();
11545 if (__pCommandButton)
11547 _Button* pLeftButton = __pCommandButton->GetItem(COMMAND_BUTTON_POSITION_LEFT);
11550 pLeftButton->SetText(__pEditModel->GetKeypadCommandButtonText(COMMAND_BUTTON_POSITION_LEFT));
11552 _Button* pRightButton = __pCommandButton->GetItem(COMMAND_BUTTON_POSITION_RIGHT);
11555 pRightButton->SetText(__pEditModel->GetKeypadCommandButtonText(COMMAND_BUTTON_POSITION_RIGHT));
11562 _EditPresenter::SetPasswordVisible(bool visible)
11564 result r = E_SUCCESS;
11566 SysTryReturnResult(NID_UI_CTRL, (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD), E_INVALID_OPERATION,
11567 "Edit Style is not EDIT_STYLE_PASSWORD.\n")
11570 if (__isPasswordVisible == visible)
11575 __isPasswordVisible = visible;
11577 if (GetTextLength()== 0)
11582 InitializeCopyPasteManager();
11584 FinishTextComposition();
11586 if (__isPasswordVisible)
11588 StopPasswordTimer();
11589 ChangePasswordToPlainText();
11593 ReplaceTextIntoPasswordHyphenString();
11594 __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), 0);
11601 _EditPresenter::IsPasswordVisible(void) const
11603 return __isPasswordVisible;
11607 _EditPresenter::IsClearIconPressed(void) const
11609 return __isClearIconPressed;
11613 _EditPresenter::DrawFocusRing(Tizen::Graphics::Canvas& canvas)
11615 if (__pEditModel->IsViewModeEnabled() || !__pEdit->IsEnabled())
11620 result r = E_SUCCESS;
11621 Bitmap* pFocusRing = null;
11622 Color color = __pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED);
11624 if (IsCurrentFocused() && color.GetAlpha())
11627 GET_COLOR_CONFIG(FOCUSUI::CONTENT_BG_HIGHLIGHTED, focusColor);
11628 focusColor.SetAlpha(color.GetAlpha());
11630 r = GET_BITMAP_CONFIG_N(EDIT::BG_RING_FOCUSED, BITMAP_PIXEL_FORMAT_ARGB8888, pFocusRing);
11631 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
11633 FloatRectangle editRect(0.0f, 0.0f, __pEdit->GetBoundsF().width, __pEdit->GetBoundsF().height);
11635 Bitmap* pReplacementFocusRing = _BitmapImpl::GetColorReplacedBitmapN(*pFocusRing, Color::GetColor(COLOR_ID_MAGENTA), focusColor);
11636 SysTryCatch(NID_UI_CTRL, pReplacementFocusRing, , r = GetLastResult(), "Unable to allocate text buffer.");
11638 if (pReplacementFocusRing)
11640 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pReplacementFocusRing))
11642 canvas.DrawNinePatchedBitmap(editRect, *pReplacementFocusRing);
11646 delete pReplacementFocusRing;
11657 }}} // Tizen::Ui::Controls