2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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_ResourceManager.h"
51 #include "FUi_BidiUtils.h"
52 #include "FUi_UiEventManager.h"
53 #include "FUi_UiNotificationEvent.h"
54 #include "FUiAnim_VisualElement.h"
55 #include "FUiAnim_EflNode.h"
56 #include "FUiCtrl_Button.h"
57 #include "FUiCtrl_ContextMenu.h"
58 #include "FUiCtrl_Edit.h"
59 #include "FUiCtrl_EditCopyPasteManager.h"
60 #include "FUiCtrl_EditPresenter.h"
61 #include "FUiCtrl_FlickAnimation.h"
62 #include "FUiCtrl_Frame.h"
63 #include "FUiCtrl_Form.h"
64 #include "FUiCtrl_Scroll.h"
65 #include "FUiCtrl_ScrollPanel.h"
66 #include "FUiCtrl_Toolbar.h"
67 #include "FUiCtrl_TableView.h"
70 using namespace Tizen::Base::Runtime;
71 using namespace Tizen::Base::Utility;
72 using namespace Tizen::Media;
73 using namespace Tizen::Ui::Animations;
74 using namespace Tizen::Graphics;
75 using namespace Tizen::Ui;
76 using namespace Tizen::Ui::Controls;
77 using namespace Tizen::Base;
78 using namespace Tizen::Base::Utility;
79 using namespace Tizen::Base::Collection;
80 using namespace Tizen::Locales;
81 using namespace Tizen::Graphics::_Text;
83 namespace Tizen { namespace Ui { namespace Controls
85 const int EDIT_PASSWORD_TIMER_PERIOD = 1000;
86 const int EDIT_CURSOR_TIMER_PERIOD = 600;
87 const int MAX_LINE_NUMBER = 100;
88 const int MAX_FLEXIBLE_HEIGHT_VERTICAL_MODE = 4000;
89 const int MAX_FLEXIBLE_HEIGHT_HORIZONTAL_MODE = 2500;
90 const int EDIT_FLICK_SCROLL_TIMER_INTERVAL = 10;
91 const int EDIT_FLICK_SCROLL_MOVE_AMOUNT_MULTIPLIER = 2;
92 const float DIRECTION_DECISION_RATIO = 1.3f;
93 const float HORIZONTAL_DECISION_RATIO = 1.5f;
94 const float MOVE_SKIP_DECISION_RANGE = 5.0f;
95 const int TITLE_SLIDING_TIME = 800;
97 const int LANGUAGE_CODE_START = 0;
98 const int LANGUAGE_CODE_MAX = 2;
100 bool _EditPresenter::__isKeypadExist = false;
101 bool _EditPresenter::__isClipboardExist = false;
102 float _EditPresenter::__initialParentHeight = 0.0f;
103 float _EditPresenter::__clipboardHeight = 0.0f;
104 _EditFooterVisibleStatus _EditPresenter::__initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
106 _EditAnimationProvider::_EditAnimationProvider(void)
110 _EditAnimationProvider::~_EditAnimationProvider(void)
114 VisualElementAnimation*
115 _EditAnimationProvider::CreateAnimationForProperty(VisualElement& source, const String& property)
117 VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(source, property);
118 if (pAnimation != null)
120 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseInOut"));
121 pAnimation->SetDuration(ANIMATION_DURATION);
127 _EditPresenter::_EditPresenter(void)
128 : __pTitleSlidingTimer(null)
130 , __pTextBuffer(null)
131 , __pTextString(null)
134 , __pScrollEffect(null)
136 , __horizontalAlignment(ALIGNMENT_LEFT)
137 , __horizontalAlignmentForBidi(ALIGNMENT_LEFT)
138 , __isScrollBarVisible(false)
139 , __scrollBarBounds()
141 , __previousScrollBarPos(0.0f)
142 , __previousScrollBarMaxPos(0.0f)
143 , __pActionEventListener(null)
144 , __pCursorTimer(null)
145 , __pFlickAnimationTimer(null)
146 , __pPasswordTimer(null)
148 , __pCursorVisualElement(null)
149 , __pTextVisualElement(null)
150 , __pTitleTextVisualElement(null)
151 , __pCopyPasteManager(null)
152 , __pFlickAnimation(null)
153 , __pParentForm(null)
154 , __pFullscreenKeypad(null)
155 , __pParentPanel(null)
156 , __pCommandButton(null)
157 , __pInputConnection(null)
158 , __isInputConnectionBound(false)
163 , __isCopyPastePopupMoving(false)
164 , __pressedAbsolutePoint()
165 , __clearIconBounds()
167 , __textObjectBounds()
170 , __previousCursorBounds()
172 , __pTextObject(null)
173 , __pGuideTextObject(null)
174 , __pTitleTextObject(null)
175 , __titleSlidingAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT)
176 , __textObjectWrap(TEXT_OBJECT_WRAP_TYPE_WORD)
177 , __isTextBlocked(false)
178 , __isGuideTextColorChanged(false)
179 , __isKeypadCommandButtonVisible(false)
180 , __isTextComposing(false)
181 , __isCopyPasteManagerExist(false)
182 , __isCursorChanged(false)
183 , __isCursorInitialized(false)
184 , __isCursorDisabled(false)
185 , __isInitialized(false)
186 , __isInitializing(false)
187 , __isMovingCursorByTouchMove(false)
188 , __isTouchMoving(false)
189 , __isTouchPressed(false)
190 , __isClearIconPressed(false)
191 , __isCursorOpaque(false)
192 , __isTouchReleaseSkipped(false)
193 , __isViewerModeEnabled(false)
194 , __isKeypadNormalNumberStyleEnabled(false)
195 , __isTextCompositionFinished(false)
196 , __isFlexibleHeightFrozen(false)
197 , __isKeypadShowing(false)
198 , __isKeypadHiding(false)
201 , __maximumFlexibleHeight(-1.0f)
202 , __prevTotalTextHeight(-1.0f)
204 , __composingTextLength(0)
205 , __titleWidth(-1.0f)
206 , __verticalMargin(-1.0f)
207 , __isUSBKeyboardConnected(false)
209 , __isCutLinkParserEnabled(false)
211 , __ContentTextStatus(EDIT_TEXT_STATUS_COMPOSE_NON)
212 , __pEditVEDelegator(null)
213 , __isAutoShrinkEnabled(false)
214 , __groupStyle(GROUP_STYLE_NONE)
215 , __isFontInitialized(false)
216 , __contentFontSize(0.0f)
217 , __titleFontSize(0.0f)
218 , __contentFontStyle(FONT_STYLE_PLAIN)
219 , __contentTextStyle(TEXT_BOX_TEXT_STYLE_NORMAL)
220 , __titleFontFaceName("")
221 , __isSearchBar(false)
222 , __pCurrentFrame(null)
223 , __pTextFilter(null)
224 , __textBlockMoveLeft(false)
225 , __textBlockMoving(false)
226 , __clipboardConnected(false)
227 , __updateInitialBounds(true)
228 , __blockTextColor(Color(0, 0, 0))
233 _EditPresenter::OnInputConnectionPanelShowStateChanged(InputConnection& source, InputPanelShowState showState)
235 if (showState == INPUT_PANEL_SHOW_STATE_SHOW)// 1. keypad show 2.usb on&predictive window show
237 __isKeypadHiding = false;
238 __isKeypadShowing = false;
239 __isKeypadExist = true;
241 CheckUSBKeyboardStatus();
243 SysLog(NID_UI_CTRL, "[EDIT] INPUT_PANEL_SHOW_STATE_SHOW[Target:%x][Bound:%d][Usb mode:%d]", this, __isInputConnectionBound, __isUSBKeyboardConnected);
245 if (__isInputConnectionBound)
247 if (__isKeypadCommandButtonVisible)
249 SetFooterVisible(false);
252 ChangeLayoutInternal(__pEdit->GetOrientation());
253 AdjustParentPanelHeight(false);
255 ScrollPanelToCursorPosition();
257 if (__isCopyPasteManagerExist)
259 __pCopyPasteManager->CreateCopyPastePopup();
260 __pCopyPasteManager->Show();
264 if (!__pEdit->IsFullScreenKeypadEdit())
268 if (!__isUSBKeyboardConnected)
270 __pParentForm->SetKeypadShowState(true);
273 __pParentForm->Draw();
277 if ((__isUSBKeyboardConnected && __isKeypadCommandButtonVisible))
279 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
281 else if (__isKeypadCommandButtonVisible && __pCommandButton && __pCommandButton->GetVisibleState())//already command exist in usb mode
283 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
287 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
288 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
291 else if (showState == INPUT_PANEL_SHOW_STATE_HIDE)// 1.unbound 2.bounded&usb off -> usb on 3.Flick keypad hide
293 __isKeypadHiding = false;
295 CheckUSBKeyboardStatus();
296 SysLog(NID_UI_CTRL, "[EDIT] INPUT_PANEL_SHOW_STATE_HIDE[Target:%x][Bound:%d][Usb mode:%d]", this, __isInputConnectionBound, __isUSBKeyboardConnected);
298 __isKeypadExist = false;
300 if (__isCopyPasteManagerExist)
302 InitializeCopyPasteManager();
303 __pTextObject->SetBlock(false);
304 __isTextBlocked = false;
307 if (__isInputConnectionBound && __isUSBKeyboardConnected) // hide callback from external condition(usb mode off->on), focus remaining
309 if (!__isKeypadCommandButtonVisible)
311 SetFooterVisible(true);// must be called ahead of DeflateClientRectHeight
314 if (!__pEdit->IsFullScreenKeypadEdit())
318 __pParentForm->SetKeypadShowState(false);
322 ChangeLayoutInternal(__pEdit->GetOrientation());
323 AdjustParentPanelHeight(true);
327 if (__isInputConnectionBound)// keypad drag down
329 if (!__isKeypadCommandButtonVisible)
331 SetFooterVisible(true);// must be called ahead of DeflateClientRectHeight
334 if ( __isTextComposing)
336 __pInputConnection->FinishTextComposition();
337 __isTextComposing = false;
338 __composingTextLength = 0;
341 ChangeLayoutInternal(__pEdit->GetOrientation());
342 AdjustParentPanelHeight(true);
344 else// called by focus move or HideKeypad() api call
346 if (__pCommandButton && __isKeypadCommandButtonVisible)
348 SetFooterVisible(true);// must be called ahead of DeflateClientRectHeight
349 __pCommandButton->SetVisibleState(false);
350 __pCommandButton->Invalidate();
353 __pEdit->DetachScrollPanelEvent();
354 __isInputConnectionBound = false;
356 AdjustParentPanelHeight(true);
360 SysLog(NID_UI_CTRL, "[EDIT] Form deflate RESET!!!!!!!!!!");
361 __pParentForm->DeflateClientRectHeight(0.0f);
366 if (!__pEdit->IsFullScreenKeypadEdit())
370 if (!__isUSBKeyboardConnected)
372 __pParentForm->SetKeypadShowState(false);
375 __pParentForm->Draw();
379 if (__isKeypadCommandButtonVisible && __isInputConnectionBound)
381 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
383 else if((__isUSBKeyboardConnected && __isKeypadCommandButtonVisible && !__isInputConnectionBound) ||
384 (__isUSBKeyboardConnected && __isClipboardExist))
390 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CLOSED);
391 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
399 _EditPresenter::OnInputConnectionPanelLanguageChanged(InputConnection& source, LanguageCode language)
401 LanguageCode oldLanguageCode;
402 __pEditModel->GetCurrentLanguage(oldLanguageCode);
404 __pEditModel->SetCurrentLanguage(language);
405 __pEdit->SendLanguageEvent(oldLanguageCode, language);
411 _EditPresenter::OnInputConnectionPanelBoundsChanged(InputConnection& source, const Rectangle& bounds)
413 CheckUSBKeyboardStatus();
415 if ((__isUSBKeyboardConnected == false) && __isKeypadExist == false)
420 if (CheckKeypadExist(__pEdit->GetOrientation()) == false)//double check keypad Exist
425 SysLog(NID_UI_CTRL, "[EDIT] OnInputConnectionPanelBoundsChanged");
426 ChangeLayoutInternal(__pEdit->GetOrientation());
427 AdjustParentPanelHeight(false, true);
431 ScrollPanelToCursorPosition();
432 __pParentForm->Draw();
435 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
441 _EditPresenter::OnInputConnectionTextPredictionShowStateChanged(InputConnection& source, bool isShown)
447 _EditPresenter::OnInputConnectionTextPredictionBoundsChanged(InputConnection& source, const Rectangle& bounds)
453 _EditPresenter::OnInputConnectionTextCommitted(InputConnection& source, const String& committedText)
455 OnTextCommitted(committedText);
461 _EditPresenter::OnTextCommitted(const String& commitText)
463 bool isTextComposingFinished = false;
464 char enterText1[2] = {'\n', };
465 char enterText2[2] = {'\r', };
467 if (IsViewModeEnabled() == true)
472 if (IsBlocked() == true)
474 CoreKeypadAction keypadaction = GetKeypadAction();
475 if (keypadaction == CORE_KEYPAD_ACTION_ENTER || !(commitText == enterText1 || commitText == enterText2))
479 GetBlockRange(start, end);
480 __isFlexibleHeightFrozen = true;
481 DeleteText(start, end);
482 __isFlexibleHeightFrozen = false;
487 if (__isCopyPasteManagerExist)
489 InitializeCopyPasteManager();
492 int textLength = commitText.GetLength();
493 int compositionStart = __cursorPos - textLength;
495 if (__isTextComposing == true)
497 __isFlexibleHeightFrozen = true;
498 DeleteText(__cursorPos-__composingTextLength, __cursorPos);
499 __isFlexibleHeightFrozen = false;
501 __isTextComposing = false;
502 __composingTextLength = 0;
503 isTextComposingFinished = true;
506 if (__ContentTextStatus != EDIT_TEXT_STATUS_COMPOSE_NON)
508 __pTextObject->SetFont(__pFont, __cursorPos, __cursorPos+textLength);
509 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
512 if (__pPasswordTimer)
514 ChangePasswordToEchoCharacter(__pTextBuffer, __echoChar);
518 if (commitText == enterText1 || commitText == enterText2)
520 CoreKeypadAction keypadaction = GetKeypadAction();
522 __pEdit->SendKeypadEvent(keypadaction, CORE_KEYPAD_EVENT_STATUS_ENTERACTION);
523 if (keypadaction != CORE_KEYPAD_ACTION_ENTER)
528 if(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
534 char tapText[2] = {'\t', };
535 if (commitText == tapText)
540 // Limitation Protect
541 String insetText = commitText;
542 int currentLength = GetTextLength();
543 int totalLength = currentLength + textLength;
544 int excessCharacterLength = totalLength - __limitLength;
546 if (excessCharacterLength >= 0)
548 textLength -= excessCharacterLength;
551 insetText.Remove(textLength, excessCharacterLength);
559 InsertTextAt(__cursorPos, insetText);
561 ScrollPanelToCursorPosition();
563 if ((__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) && isTextComposingFinished)
565 ReplaceTextIntoPasswordHyphenString();
568 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
573 ChangePasswordToEchoCharacter((compositionStart + textLength), textLength);
575 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
581 _EditPresenter::OnInputConnectionComposingTextChanged(InputConnection& source, const String& composingText, int cursorPosition)
583 OnComposingTextChanged(composingText, cursorPosition);
589 _EditPresenter::OnComposingTextChanged(const String& composingText, int cursorPosition)
591 if (IsViewModeEnabled() == true)
596 if (IsBlocked() == true)
600 GetBlockRange(start, end);
601 __isFlexibleHeightFrozen = true;
602 DeleteText(start, end);
603 __isFlexibleHeightFrozen = false;
607 if (__isCopyPasteManagerExist)
609 InitializeCopyPasteManager();
612 int textLength = composingText.GetLength();
614 if (__isTextComposing == true)
616 int compositionStart = GetCursorPosition();
620 __isTextComposing = false;
622 // FirstText Check Logic
623 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
624 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine);
625 bool isFirstText = false;
626 if (firstTextIndex + 1 == __pTextObject->GetCursorIndex())
631 DeleteText(compositionStart-__composingTextLength, compositionStart);
635 __isCursorChanged = false;
636 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT);
639 __composingTextLength = 0;
643 if (!__isCursorChanged)
645 __isCursorChanged = true;
647 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
653 __isFlexibleHeightFrozen = true;
654 DeleteText(compositionStart-__composingTextLength, compositionStart);
655 __isFlexibleHeightFrozen = false;
659 __composingTextLength = textLength;
660 if (__composingTextLength > 0)
662 __isTextComposing = true;
665 if (__pPasswordTimer)
667 ChangePasswordToEchoCharacter(__pTextBuffer, __echoChar);
671 // Limitation Protect
672 String insetText = composingText;
673 int currentLength = GetTextLength();
674 int totalLength = currentLength + textLength;
675 int excessCharacterLength = totalLength - __limitLength;
677 if (excessCharacterLength >= 0)
679 __composingTextLength -= excessCharacterLength;
680 if (__composingTextLength > 0)
682 insetText.Remove(__composingTextLength, excessCharacterLength);
686 __composingTextLength = 0;
690 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
691 SysTryReturnVoidResult(NID_UI_CTRL, fontImpl != null, E_SYSTEM, "[E_SYSTEM] fontImpl is null.");
692 fontImpl->SetUnderline(true);
693 __pTextObject->SetFont(__pFont, 0, 0);
695 if (__composingTextLength > 0)
697 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE;
700 InsertTextAt(GetCursorPosition(), insetText);
702 fontImpl->SetUnderline(false);// rollback to default content font
703 __pTextObject->SetFont(__pFont, 0, 0);
705 ScrollPanelToCursorPosition();
709 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
715 _EditPresenter::DeleteSurroundingText(InputConnection& source, int offset, int charCount)
717 OnSurroundingTextDeleted(offset, charCount);
723 _EditPresenter::OnSurroundingTextDeleted(int offset, int charCount)
728 if (IsBlocked() == true)
730 GetBlockRange(start, end);
734 start = __cursorPos + offset;
739 end = start + charCount;
740 if (end > __cursorPos)
746 DeleteText(start, end);
748 if (__isCopyPasteManagerExist)
750 InitializeCopyPasteManager();
753 if (IsBlocked() == true)
760 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
766 _EditPresenter::GetPreviousText(InputConnection& source, String& text, int& cursorPosition)
768 const int SURRONDING_TEXT_SIZE = 5;
769 int stringLength = 0;
772 if (__cursorPos == 0)
779 if (__cursorPos < SURRONDING_TEXT_SIZE)
781 text = GetText(0, __cursorPos - 1);
785 text = GetText(__cursorPos-SURRONDING_TEXT_SIZE, __cursorPos - 1);
787 stringLength = text.GetLength();
788 cursorPosition = stringLength;
795 _EditPresenter::OnClipboardPopupOpened(Tizen::Graphics::Dimension& clipboardPopupSize)
797 FloatDimension floatClipboardPopupSize = _CoordinateSystemUtils::ConvertToFloat(clipboardPopupSize);
799 if (__clipboardConnected)
801 __isClipboardExist = true;
802 FloatRectangle absKeypadBounds;
803 GetKeypadBounds(absKeypadBounds);
804 CheckUSBKeyboardStatus();
806 __clipboardHeight = floatClipboardPopupSize.height;
808 SysLog(NID_UI_CTRL, "[EDIT] clipboard height = %f, [KeypadExist:%d]keypad height = %f", floatClipboardPopupSize.height, __isKeypadExist, absKeypadBounds.height);
810 if (__isKeypadExist) //resize as difference between clipboard height vs keypad height
812 if (floatClipboardPopupSize.height > absKeypadBounds.height)
814 ChangeLayoutInternal(__pEdit->GetOrientation());
815 AdjustParentPanelHeight(false, true);
819 ScrollPanelToCursorPosition();
820 __pParentForm->SetClipboardShowState(true);
821 __pParentForm->Draw();
824 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
830 __pParentForm->SetClipboardShowState(true);
836 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
838 ChangeLayoutInternal(__pEdit->GetOrientation());
839 AdjustParentPanelHeight(false);
843 ScrollPanelToCursorPosition();
844 __pParentForm->SetClipboardShowState(true);
845 __pParentForm->Draw();
848 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
856 _EditPresenter::OnClipboardPopupBoundsChanged(Tizen::Graphics::Dimension& clipboardPopupSize)
858 FloatDimension floatClipboardPopupSize = _CoordinateSystemUtils::ConvertToFloat(clipboardPopupSize);
860 if (__clipboardConnected)
862 FloatRectangle absKeypadBounds;
863 GetKeypadBounds(absKeypadBounds);
864 CheckUSBKeyboardStatus();
866 __clipboardHeight = floatClipboardPopupSize.height;
868 SysLog(NID_UI_CTRL, "[EDIT] clipboard height = %f, [KeypadExist:%d]keypad height = %f", floatClipboardPopupSize.height, __isKeypadExist, absKeypadBounds.height);
872 if (floatClipboardPopupSize.height >= absKeypadBounds.height)
874 ChangeLayoutInternal(__pEdit->GetOrientation());
875 AdjustParentPanelHeight(false, true);
878 __pParentForm->Draw();
879 ScrollPanelToCursorPosition();
882 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
887 ChangeLayoutInternal(__pEdit->GetOrientation());
888 AdjustParentPanelHeight(false);
891 __pParentForm->Draw();
892 ScrollPanelToCursorPosition();
895 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
903 _EditPresenter::OnClipboardPopupClosed(void)
905 if (__clipboardConnected)
909 __pClipboard->HidePopup();
912 __isClipboardExist = false;
913 FloatRectangle absKeypadBounds;
914 GetKeypadBounds(absKeypadBounds);
915 CheckUSBKeyboardStatus();
917 __clipboardHeight = 0.0f;
919 SysLog(NID_UI_CTRL, "[EDIT] clipboard closed! [KeypadExist:%d]keypad height = %f", __isKeypadExist, absKeypadBounds.height);
921 ChangeLayoutInternal(__pEdit->GetOrientation());
925 AdjustParentPanelHeight(false, true);
929 __pParentForm->SetClipboardShowState(false);
930 __pParentForm->Draw();
933 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
937 AdjustParentPanelHeight(true);
940 SysLog(NID_UI_CTRL, "[EDIT] Form deflate RESET!!!!!!!!!!");
941 __pParentForm->DeflateClientRectHeight(0.0f);
942 __pParentForm->SetClipboardShowState(false);
943 __pParentForm->Draw();
946 if (!__isKeypadCommandButtonVisible)
948 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
952 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
956 __clipboardConnected = false;
962 _EditPresenter::~_EditPresenter(void)
968 _EditPresenter::Dispose(void)
972 __pCurrentFrame->RemoveFrameEventListener(*this);
973 __pCurrentFrame = null;
976 CheckUSBKeyboardStatus();
978 if (__isInputConnectionBound || __isKeypadHiding)
980 if (__pCommandButton && __isKeypadCommandButtonVisible)
982 __pCommandButton->SetVisibleState(false);
984 SetFooterVisible(true);
986 delete __pCommandButton;
987 __pCommandButton = null;
992 SysLog(NID_UI_CTRL, "[EDIT] Form deflate RESET!!!!!!!!!!");
993 __pParentForm->DeflateClientRectHeight(0.0f);
994 __pParentForm->SetKeypadShowState(false);
996 if (__pParentForm->GetFooter())
998 if (__pParentForm->GetFooter()->GetButton(BACK_BUTTON))
1000 __pParentForm->GetFooter()->Invalidate(true);
1004 if (__pParentForm->GetHeader())
1006 if (__pParentForm->GetHeader()->GetButton(BACK_BUTTON))
1008 __pParentForm->GetHeader()->Invalidate(true);
1013 if (__pEdit && !__pEdit->IsDestroyed())//restore ScrollPanel when force deleted
1015 AdjustParentPanelHeight(true);
1018 __isKeypadExist = false;
1019 __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
1022 if (__clipboardConnected)
1024 __pClipboard->HidePopup();
1025 __isClipboardExist = false;
1030 __pClipboard->RemoveClipboardPopupEventListener(*this);
1033 delete __pFullscreenKeypad;
1034 __pFullscreenKeypad = null;
1036 delete __pScrollEffect;
1037 __pScrollEffect = null;
1041 delete[] __pTextBuffer;
1042 __pTextBuffer = null;
1045 delete __pTextString;
1046 __pTextString = null;
1048 delete __pEditModel;
1049 __pEditModel = null;
1053 __pCursorTimer->Cancel();
1054 delete __pCursorTimer;
1055 __pCursorTimer = null;
1058 if (__pInputConnection)
1060 delete __pInputConnection;
1061 __pInputConnection = null;
1064 delete __pTextObject;
1065 __pTextObject = null;
1067 delete __pGuideTextObject;
1068 __pGuideTextObject = null;
1070 delete __pTitleTextObject;
1071 __pTitleTextObject = null;
1073 if (__pPasswordTimer)
1075 __pPasswordTimer->Cancel();
1076 delete __pPasswordTimer;
1077 __pPasswordTimer = null;
1080 if (__pScrollBar != null && __pEdit != null)
1082 result r = __pEdit->DetachSystemChild(*__pScrollBar);
1086 delete __pScrollBar;
1087 __pScrollBar = null;
1091 if (__pFlickAnimationTimer)
1093 __pFlickAnimationTimer->Cancel();
1094 delete __pFlickAnimationTimer;
1095 __pFlickAnimationTimer = null;
1098 if (__pTitleSlidingTimer)
1100 __pTitleSlidingTimer->Cancel();
1101 delete __pTitleSlidingTimer;
1102 __pTitleSlidingTimer = null;
1105 delete __pFlickAnimation;
1106 __pFlickAnimation = null;
1108 if (__pCopyPasteManager != null)
1110 delete __pCopyPasteManager;
1111 __pCopyPasteManager = null;
1114 if (__pTextVisualElement)
1116 __pTextVisualElement->Destroy();
1117 __pTextVisualElement = null;
1120 if (__pCursorVisualElement)
1122 __pCursorVisualElement->Destroy();
1123 __pCursorVisualElement = null;
1126 if (__pTitleTextVisualElement)
1128 __pTitleTextVisualElement->Destroy();
1129 __pTitleTextVisualElement = null;
1132 if (__pEditVEDelegator)
1134 delete __pEditVEDelegator;
1135 __pEditVEDelegator = null;
1142 _EditPresenter::IsKeypadExist(void) const
1144 return __isKeypadExist;
1148 _EditPresenter::IsClipboardExist(void) const
1150 return __isClipboardExist;
1154 _EditPresenter::CheckUSBKeyboardStatus(void)
1156 if (__pInputConnection->CheckUSBKeyboardStatus())
1158 __isUSBKeyboardConnected = true;
1162 __isUSBKeyboardConnected = false;
1169 _EditPresenter::IsUsbKeyboardConnected(void) const
1171 if (__pInputConnection->CheckUSBKeyboardStatus())
1182 _EditPresenter::CreateInstanceN(void)
1184 _EditPresenter* pPresenter = new (std::nothrow) _EditPresenter;
1185 if (pPresenter == null)
1187 SetLastResult(E_OUT_OF_MEMORY);
1195 _EditPresenter::Initialize(const _Control& control)
1197 result r = E_SUCCESS;
1198 _EditModel* pEditModel = null;
1199 _VisualElement* pEditVisualElement = null;
1200 TextSimple* pSimpleText = null;
1201 _ControlManager* pControlManager = _ControlManager::GetInstance();
1202 _Window* pWindow = null;
1204 __pEdit = dynamic_cast<_Edit*>(const_cast<_Control*>(&control));
1205 SysAssertf(__pEdit != null, "__pEdit is null");
1207 __pTextObject = new (std::nothrow) TextObject;
1208 if (__pTextObject == null)
1210 r = E_OUT_OF_MEMORY;
1214 __pTextObject->Construct();
1215 pSimpleText = new (std::nothrow)TextSimple(null, 0, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1216 __pTextObject->AppendElement(*pSimpleText);
1218 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
1220 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1221 if (__pEdit->IsFullScreenKeypadEdit())
1223 __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
1227 __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
1229 __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
1230 __textObjectWrap = TEXT_OBJECT_WRAP_TYPE_NONE;
1234 __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
1235 __pTextObject->SetWrap(__textObjectWrap);
1238 __pTextString = new (std::nothrow) String;
1239 SysTryCatch(NID_UI_CTRL, __pTextString, , r = E_OUT_OF_MEMORY, "[EDIT] Unable to allocate text buffer.");
1242 if (__pFont == null)
1244 _ControlOrientation orientation = __pEdit->GetOrientation();
1245 float defaultFontSize = 0.0f;
1246 GET_SHAPE_CONFIG(EDIT::DEFAULT_FONT_SIZE, orientation, defaultFontSize);
1248 __contentFontSize = defaultFontSize;
1249 __contentFontStyle = FONT_STYLE_PLAIN;
1251 __pFont = __pEdit->GetFallbackFont();
1253 r = GetLastResult();
1254 SysTryReturn(NID_UI_CTRL, __pFont, r, r, "[%s] Propagating.", GetErrorMessage(r));
1256 __titleFontFaceName = __pFont->GetFaceName();
1258 __isFontInitialized = true;
1259 __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
1260 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
1263 __pScrollEffect = new (std::nothrow) _EditScrollEffectInfo;
1264 SysTryCatch(NID_UI_CTRL, __pScrollEffect, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create EditScrollEffectInfo");
1266 for (int i = 0; i < EDIT_SCROLLFRAME_MAX; i++)
1268 __pScrollEffect->touchScrollFrameLevel[i] = 2 + i;
1271 __pScrollEffect->previousY = -1.0f;
1272 __pScrollEffect->currentY = -1.0f;
1274 pEditModel = new (std::nothrow) _EditModel;
1275 SysTryCatch(NID_UI_CTRL, pEditModel, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance");
1277 SetModel(*pEditModel);
1282 if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)
1284 SetViewModeEnabled(true);
1285 __isCutLinkParserEnabled = true;
1289 SetKeypadEnabled(true);
1290 __isCutLinkParserEnabled = false;
1293 __initialBounds = __pEdit->GetBoundsF();
1295 __pCursorVisualElement = new (std::nothrow) _VisualElement;
1296 SysTryCatch(NID_UI_CTRL, __pCursorVisualElement, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance");
1298 r = __pCursorVisualElement->Construct();
1299 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r));
1301 __pCursorVisualElement->SetSurfaceOpaque(false);
1302 __pCursorVisualElement->SetImplicitAnimationEnabled(false);
1304 pEditVisualElement = __pEdit->GetVisualElement();
1305 SysTryCatch(NID_UI_CTRL, pEditVisualElement, , r = E_SYSTEM, "[E_SYSTEM] Unable to get root visual element.");
1307 __pCursorVisualElement->SetShowState(true);
1309 r = pEditVisualElement->AttachChild(*__pCursorVisualElement);
1310 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r));
1312 __pInputConnection = _InputConnectionImpl::CreateInputConnectionImplN(null);
1313 SysTryCatch(NID_UI_CTRL, __pInputConnection, , r = E_SYSTEM, "[E_SYSTEM] Unable to create an instance .");
1315 __pInputConnection->Initialize(*__pEdit, *this, *this);
1317 __pTextObject->SetBounds(__textObjectBounds);
1318 __pTextObject->HideRearSpace(TEXT_OBJECT_SPACE_HIDE_TYPE_NONE);
1320 __maximumFlexibleHeight = GetMaxLineCount() * __pFont->GetMaxHeight() + __verticalMargin;
1322 __pEditVEDelegator = new (std::nothrow) _EditAnimationProvider();
1323 SysTryCatch(NID_UI_CTRL, __pEditVEDelegator, , E_OUT_OF_MEMORY, "Memory allocation failed.");
1325 pWindow = pControlManager->GetCurrentFrame();
1328 __pCurrentFrame = dynamic_cast<_Frame*>(pWindow);
1329 if (__pCurrentFrame)
1331 __pCurrentFrame->AddFrameEventListener(*this);
1335 __pClipboard = _Clipboard::GetInstance();
1339 __pClipboard->AddClipboardPopupEventListener(*this);
1350 _EditPresenter::InitializeAtFirstDrawing(void)
1352 result r = E_SUCCESS;
1354 __isInitializing = true;
1358 InitializeParentPanel();
1360 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT);
1362 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false && (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE))
1364 r = AdjustFlexibleHeight();
1365 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Faild to adjust flexible height.");
1368 ReplaceTextIntoPasswordHyphenString();
1370 if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)
1372 __pEdit->SetCursorPosition(0);
1375 __isInitialized = true;
1381 _EditPresenter::DrawBackgroundBitmap(Canvas& canvas, bool focused)
1383 if (!DrawChangeableBackground(canvas, focused, 0, 0))
1392 _EditPresenter::DrawChangeableBackground(Canvas& canvas, bool focused, int bitmapId, int effectBitmapId, bool outLine, int outlineBitmapId)
1394 result r = E_SUCCESS;
1395 FloatRectangle editRect(0.0f, 0.0f, __pEdit->GetBoundsF().width, __pEdit->GetBoundsF().height);
1397 Bitmap* pEditBgBitmap = null;
1398 Bitmap* pEditBgEffectBitmap = null;
1399 Bitmap* pReplacementColorBackgroundBitmap = null;
1400 bool borderRoundEnable = __pEdit->IsBorderRoundStyleEnabled();
1401 EditStatus editStatus = GetCurrentStatus();
1403 pEditBgBitmap = __pEdit->GetDefaultBackgroundBitmap(editStatus);
1405 if (borderRoundEnable)
1407 pEditBgBitmap = null;
1408 r = GET_BITMAP_CONFIG_N(EDIT::BG_ROUND_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pEditBgBitmap);
1409 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap");
1412 bitmapColor = __pEdit->GetColor(editStatus);
1413 if (__groupStyle != GROUP_STYLE_NONE)
1415 GET_COLOR_CONFIG(PANEL::GROUPED_STYLE_BG_NORMAL, bitmapColor);
1418 pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pEditBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), bitmapColor);
1419 if (pReplacementColorBackgroundBitmap)
1421 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pReplacementColorBackgroundBitmap))
1423 canvas.DrawNinePatchedBitmap(editRect, *pReplacementColorBackgroundBitmap);
1427 canvas.DrawBitmap(editRect, *pReplacementColorBackgroundBitmap);
1431 if ((!__pEdit->IsFullScreenKeypadEdit() && __groupStyle != GROUP_STYLE_NONE) || GetSearchBarFlag())
1433 pEditBgEffectBitmap = __pEdit->GetDefaultBackgroundEffectBitmap();
1435 if (pEditBgEffectBitmap)
1437 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pEditBgEffectBitmap))
1439 canvas.DrawNinePatchedBitmap(editRect, *pEditBgEffectBitmap);
1443 canvas.DrawBitmap(editRect, *pEditBgEffectBitmap);
1448 if (borderRoundEnable)
1452 delete pEditBgBitmap;
1453 pEditBgBitmap = null;
1456 if (pEditBgEffectBitmap)
1458 delete pEditBgEffectBitmap;
1459 pEditBgEffectBitmap = null;
1462 delete pReplacementColorBackgroundBitmap;
1463 pReplacementColorBackgroundBitmap = null;
1467 delete pEditBgBitmap;
1473 _EditPresenter::DrawBackground(Canvas& canvas, bool drawTitleText)
1475 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
1477 return DrawSingleLineBackground(canvas, drawTitleText);
1480 FloatRectangle editRect(0.0f, 0.0f, __pEdit->GetBoundsF().width, __pEdit->GetBoundsF().height);
1482 EditStatus editStatus = GetCurrentStatus();
1484 Bitmap* pEditBgBitmap = __pEdit->GetBackgroundBitmap(editStatus);
1488 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pEditBgBitmap))
1490 canvas.DrawNinePatchedBitmap(editRect, *pEditBgBitmap);
1494 canvas.DrawBitmap(editRect, *pEditBgBitmap);
1499 DrawBackgroundBitmap(canvas, IsInternalFocused());
1504 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_TOP) || (__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_LEFT))
1514 _EditPresenter::DrawTitleText()
1516 result r = E_SUCCESS;
1517 if (__titleText == -1)
1523 TextObjectActionType titleAction;
1524 Canvas* pTitleTextCanvas = null;
1525 _VisualElement* pRootElement = __pEdit->GetVisualElement();
1526 SysTryReturn(NID_UI_CTRL, pRootElement, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get root visual element.");
1528 if (!__pTitleTextVisualElement)
1530 __pTitleTextVisualElement = new (std::nothrow) _VisualElement();
1531 SysTryReturnResult(NID_UI_CTRL, __pTitleTextVisualElement, E_OUT_OF_MEMORY, "Memory allocation failed.");
1533 r = __pTitleTextVisualElement->Construct();
1534 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r = E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to construct _VisualElement.");
1536 __pTitleTextVisualElement->SetImplicitAnimationEnabled(false);
1537 __pTitleTextVisualElement->SetShowState(true);
1539 r = pRootElement->AttachChild(*__pTitleTextVisualElement);
1540 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1543 __pTitleTextVisualElement->SetBounds(__titleBounds);
1545 pTitleTextCanvas = __pTitleTextVisualElement->GetCanvasN();
1546 SysTryCatch(NID_UI_CTRL, pTitleTextCanvas, , r, "[%s] Propagating.", GetErrorMessage(r));
1548 pTitleTextCanvas->SetBackgroundColor(Color(0));
1549 pTitleTextCanvas->Clear();
1551 titleAction = __pTitleTextObject->GetAction();
1552 if (IsInternalFocused() == true)
1554 __pTitleTextObject->SetForegroundColor(__pEdit->GetTitleTextColor(EDIT_STATUS_HIGHLIGHTED), 0, __pTitleTextObject->GetTextLength());
1556 if (titleAction != __titleSlidingAction)
1558 __pTitleTextObject->SetAction(__titleSlidingAction);
1559 __pTitleTextObject->Compose();
1562 __pTitleTextObject->SetBounds(FloatRectangle(0.0f, 0.0f, __titleBounds.width, __titleBounds.height));
1563 __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pTitleTextCanvas));
1565 StopTitleSlidingTimer();
1566 if (__pTitleTextObject->IsActionOn() == true)
1568 StartTitleSlidingTimer();
1573 __pTitleTextObject->SetForegroundColor(__pEdit->GetTitleTextColor(GetCurrentStatus()), 0, __pTitleTextObject->GetTextLength());
1575 if (titleAction != TEXT_OBJECT_ACTION_TYPE_ABBREV)
1577 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1580 __pTitleTextObject->SetBounds(FloatRectangle(0.0f, 0.0f, __titleBounds.width, __titleBounds.height));
1581 __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pTitleTextCanvas));
1584 delete pTitleTextCanvas;
1589 __pTitleTextVisualElement->Destroy();
1590 __pTitleTextVisualElement = null;
1596 _EditPresenter::DrawText(void)
1598 Canvas* pCanvas = null;
1600 // In case of unfocused and touch moving
1601 if (__isTouchMoving && !__pTextVisualElement)
1603 result r = E_SUCCESS;
1604 __pTextVisualElement = new (std::nothrow) _VisualElement;
1605 SysTryReturnVoidResult(NID_UI_CTRL, __pTextVisualElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create __pTextVisualElement instance.");
1607 r = __pTextVisualElement->Construct();
1608 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r));
1610 __pTextVisualElement->SetSurfaceOpaque(false);
1611 __pTextVisualElement->SetImplicitAnimationEnabled(false);
1613 __pTextVisualElement->SetShowState(true);
1615 _VisualElement* pEditVisualElement = __pEdit->GetVisualElement();
1616 SysTryCatch(NID_UI_CTRL, pEditVisualElement, , r = E_SYSTEM, "[E_SYSTEM] Unable to get root visual element.");
1618 pEditVisualElement->AttachChild(*__pTextVisualElement);
1619 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r));
1621 pCanvas = __pEdit->GetCanvasN();
1622 SysTryCatch(NID_UI_CTRL, pCanvas, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance.");
1624 pCanvas->SetBackgroundColor(Color(0));
1625 r = pCanvas->Clear();
1626 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1628 DrawBackground(*pCanvas);
1634 if (__pTextVisualElement)
1636 FloatRectangle editBounds = __pEdit->GetBoundsF();
1637 __pTextVisualElement->SetOpacity(1.0f);
1638 __pTextVisualElement->SetBounds(FloatRectangle(0.0f, 0.0f, editBounds.width, editBounds.height));
1639 pCanvas = __pTextVisualElement->GetCanvasN();
1640 if (pCanvas == null)
1644 pCanvas->SetBackgroundColor(Color(0));
1649 if (__pEdit->GetEditStyle() & EDIT_STYLE_CLEAR)
1651 DrawClearIcon(*pCanvas);
1661 __pTextVisualElement->Destroy();
1662 __pTextVisualElement = null;
1674 _EditPresenter::DrawText(Canvas& canvas)
1676 result r = E_SUCCESS;
1678 if (__pEdit->GetEnableState() == false)
1680 __pTextObject->SetAlternateLookEnabled(true);
1681 Color tempColor = __pEdit->GetTextColor(EDIT_STATUS_DISABLED);
1682 __pTextObject->SetAlternativeForegroundColor(tempColor);
1686 __pTextObject->SetAlternateLookEnabled(false);
1690 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
1692 return DrawTextForEntireFontSetting(canvas);
1695 // initital guide text
1696 if (IsGuideTextActivated())
1698 __pGuideTextObject->SetForegroundColor(__pEdit->GetGuideTextColor(), 0, __pGuideTextObject->GetTextLength());
1700 if (__isGuideTextColorChanged == true && __pEdit->IsSettingGuideTextColor() == false)
1702 __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_NORMAL), 0, __pGuideTextObject->GetTextLength());
1703 __pGuideTextObject->SetBounds(__textObjectBounds);
1704 __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
1705 __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_DISABLED), 0, __pGuideTextObject->GetTextLength());
1706 __isGuideTextColorChanged = false;
1710 __pGuideTextObject->SetBounds(__textObjectBounds);
1711 __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
1715 if (GetTextLength() <= 0)
1721 EditStatus editStatus = GetCurrentStatus();
1723 __pTextObject->SetForegroundColor(__pEdit->GetTextColor(editStatus), 0, __pTextObject->GetTextLength());
1724 if (__isTextBlocked)
1726 __pTextObject->SetForegroundColor(__blockTextColor, __blockStartPos, __cursorPos - __blockStartPos);
1729 if (__isTextBlocked == true && editStatus == EDIT_STATUS_HIGHLIGHTED)
1731 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED), 0, __pTextObject->GetTextLength());
1732 __pTextObject->SetBlock(true);
1733 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
1735 else if (__isTextBlocked == true && editStatus == EDIT_STATUS_PRESSED)
1737 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_PRESSED), 0, __pTextObject->GetTextLength());
1738 __pTextObject->SetBlock(true);
1739 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
1741 else if (__isTextBlocked == true && editStatus == EDIT_STATUS_NORMAL)
1743 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_NORMAL), 0, __pTextObject->GetTextLength());
1744 __pTextObject->SetBlock(true);
1745 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
1749 __pTextObject->SetBlock(false);
1750 __isTextBlocked = false;
1753 UpdateComponentInformation();
1755 __pTextObject->SetBounds(__textObjectBounds);
1756 __pTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
1758 if (__isTextBlocked == true && editStatus == EDIT_STATUS_HIGHLIGHTED)
1760 __pTextObject->SetBackgroundColor(Color::GetColor(COLOR_ID_BLACK), 0, __pTextObject->GetTextLength());
1763 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
1769 _EditPresenter::DrawTextForEntireFontSetting(Canvas& canvas)
1771 result r = E_SUCCESS;
1773 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) && IsInternalFocused() == false)
1775 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1779 if (__pTextObject->GetAction() != TEXT_OBJECT_ACTION_TYPE_NONE)
1781 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE);
1782 __isCursorChanged = true;
1786 // initital guide text
1787 if (IsGuideTextActivated())
1789 __pGuideTextObject->SetForegroundColor(__pEdit->GetGuideTextColor(), 0, __pGuideTextObject->GetTextLength());
1791 if (__isGuideTextColorChanged == true && __pEdit->IsSettingGuideTextColor() == false)
1793 __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_NORMAL), 0, __pGuideTextObject->GetTextLength());
1794 __pGuideTextObject->SetBounds(__textObjectBounds);
1795 __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
1796 __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_DISABLED), 0, __pGuideTextObject->GetTextLength());
1797 __isGuideTextColorChanged = false;
1801 __pGuideTextObject->SetBounds(__textObjectBounds);
1802 __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
1806 if (GetTextLength() <= 0)
1812 EditStatus editStatus = GetCurrentStatus();
1814 if (IsInternalFocused() == false)
1816 if (__isCursorChanged == true)
1818 if (AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT) == true)
1820 __pTextObject->Compose();
1824 __pTextObject->SetFirstDisplayLineIndexFromTextIndex(0);
1825 __pTextObject->SetForegroundColor(__pEdit->GetTextColor(editStatus), 0, __pTextObject->GetTextLength());
1826 __pTextObject->SetBlock(false);
1831 int lengthRange = 0;
1833 __pTextObject->GetRange(startRange, lengthRange);
1834 __pTextObject->SetRange(0, GetTextLength());
1835 __pTextObject->SetForegroundColor(__pEdit->GetTextColor(editStatus), 0, __pTextObject->GetTextLength());
1836 if (__isTextBlocked)
1838 __pTextObject->SetForegroundColor(__blockTextColor, __blockStartPos, __cursorPos - __blockStartPos);
1841 if (IsBlocked() == true && editStatus == EDIT_STATUS_HIGHLIGHTED)
1843 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED), 0, __pTextObject->GetTextLength());
1844 __pTextObject->SetBlock(true);
1845 __pTextObject->SetRange(__blockStartPos, __cursorPos - __blockStartPos);
1847 else if (__isTextBlocked == true && editStatus == EDIT_STATUS_PRESSED)
1849 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_PRESSED), 0, __pTextObject->GetTextLength());
1850 __pTextObject->SetBlock(true);
1851 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
1853 else if (__isTextBlocked == true && editStatus == EDIT_STATUS_NORMAL)
1855 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_NORMAL), 0, __pTextObject->GetTextLength());
1856 __pTextObject->SetBlock(true);
1857 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
1861 __pTextObject->SetBlock(false);
1862 __isTextBlocked = false;
1865 UpdateComponentInformation();
1868 __pTextObject->SetBounds(__textObjectBounds);
1869 __pTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
1875 _EditPresenter::DrawSingleLineBackground(Canvas& canvas, bool drawTitleText)
1877 FloatRectangle editField(0.0f, 0.0f, __pEdit->GetBoundsF().width, __pEdit->GetBoundsF().height);
1878 EditStatus editStatus = GetCurrentStatus();
1880 Bitmap* pEditBgBitmap = __pEdit->GetBackgroundBitmap(editStatus);
1884 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pEditBgBitmap))
1886 canvas.DrawNinePatchedBitmap(editField, *pEditBgBitmap);
1890 canvas.DrawBitmap(editField, *pEditBgBitmap);
1895 DrawSingleLineBackgroundBitmap(canvas, IsInternalFocused());
1900 if (((__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_LEFT) && !(__titleText.GetLength() == 0)) || (__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_TOP))
1911 _EditPresenter::DrawSingleLineBackgroundBitmap(Canvas& canvas, bool focused)
1913 if (__isTouchPressed)
1915 DrawChangeableBackground(canvas, focused, 0, 0);
1921 DrawChangeableBackground(canvas, focused, 0, 0, true, 0);
1925 bool tmpFocused = focused;
1926 DrawChangeableBackground(canvas, tmpFocused, 0, 0);
1934 _EditPresenter::DrawClearIcon(Canvas& canvas)
1936 result r = E_SUCCESS;
1938 float clearIconWidth = 0;
1939 float clearIconHeight = 0;
1941 _ControlOrientation orientation = __pEdit->GetOrientation();
1942 GET_SHAPE_CONFIG(EDIT::CLEAR_ICON_WIDTH, orientation, clearIconWidth);
1943 GET_SHAPE_CONFIG(EDIT::CLEAR_ICON_HEIGHT, orientation, clearIconHeight);
1945 if (__pTextString->GetLength() == 0)
1950 Bitmap* pEditBitmapClear = null;
1951 Bitmap* pEditReplacedBitmapClear = null;
1952 Color editClearIconColor;
1954 if (__isClearIconPressed)
1956 r = GET_BITMAP_CONFIG_N(EDIT::CLEAR_ICON_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pEditBitmapClear);
1958 if (pEditBitmapClear == null)
1963 GET_COLOR_CONFIG(EDIT::CLEAR_ICON_PRESSED, editClearIconColor);
1967 r = GET_BITMAP_CONFIG_N(EDIT::CLEAR_ICON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pEditBitmapClear);
1968 if (pEditBitmapClear == null)
1973 GET_COLOR_CONFIG(EDIT::CLEAR_ICON_NORMAL, editClearIconColor);
1976 FloatRectangle textRect = __textObjectBounds;
1977 FloatRectangle afterClearIconRect(textRect.x + textRect.width, textRect.y + (textRect.height - clearIconHeight) / 2.0f, clearIconWidth, clearIconHeight);
1978 FloatRectangle editBounds = __pEdit->GetBoundsF();
1980 pEditReplacedBitmapClear = _BitmapImpl::GetColorReplacedBitmapN(*pEditBitmapClear, Color::GetColor(COLOR_ID_MAGENTA),
1981 editClearIconColor);
1982 SysTryCatch(NID_UI_CTRL, pEditReplacedBitmapClear, , r = E_SYSTEM, "[E_SYSTEM] Unable to create an instance .");
1984 if (__clearIconBounds != afterClearIconRect)
1986 __clearIconBounds = afterClearIconRect;
1987 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_CLEAR_ICON);
1990 if (editBounds.height < clearIconHeight)
1992 __clearIconBounds.y = textRect.y;
1995 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pEditReplacedBitmapClear))
1997 r = canvas.DrawNinePatchedBitmap(__clearIconBounds, *pEditReplacedBitmapClear);
2001 r = canvas.DrawBitmap(__clearIconBounds, *pEditReplacedBitmapClear);
2004 if (pEditBitmapClear)
2006 delete pEditBitmapClear;
2007 pEditBitmapClear = null;
2010 if (pEditReplacedBitmapClear)
2012 delete pEditReplacedBitmapClear;
2013 pEditReplacedBitmapClear = null;
2019 delete pEditBitmapClear;
2025 _EditPresenter::Draw(Canvas& canvas)
2027 result r = E_SUCCESS;
2029 if (__isInitialized == false)
2031 r = InitializeAtFirstDrawing();
2032 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Faild to initialize.");
2034 if (IsInternalFocused() == true && __isInputConnectionBound == false)
2036 if (IsViewModeEnabled() == false)
2038 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
2044 ShowFullscreenKeypad();
2050 __isCursorOpaque = true;
2052 canvas.SetBackgroundColor(Color(0));
2054 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2056 DrawBackground(canvas);
2058 if (__pTextVisualElement)
2066 if (__pEdit->GetEditStyle() & EDIT_STYLE_CLEAR)
2068 DrawClearIcon(canvas);
2072 if (__rotated) // Command button should be relocated after rotation in case of no keypad.
2074 if (__isCopyPasteManagerExist)
2076 __pCopyPasteManager->CreateHandle();
2077 __pCopyPasteManager->CreateCopyPastePopup();
2078 __pCopyPasteManager->Show();
2088 //To avoid resizing to Flexible bounds on User SetBounds in Non-focussed mode
2091 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
2093 AdjustFlexibleHeight();
2101 _EditPresenter::ConvertLinkType(void)
2103 if (__isCutLinkParserEnabled == false || IsViewModeEnabled() == false)
2108 unsigned long autoLinkMask = GetAutoLinkMask();
2109 bool isChangingCutLink = false;
2110 EditCutLinkType editLinkType = EDIT_LINK_TYPE_INVALID;
2111 TextCutLinkParser cutlinkParser;
2112 cutlinkParser.SetCutLinkMask(autoLinkMask);
2113 TextLinkInfo* pLinkInfo = cutlinkParser.Parse(__pTextBuffer, wcslen(__pTextBuffer), 0);
2114 TextLinkInfo* pNextLinkInfo = null;
2115 int cursorPos = __cursorPos;
2117 __isCutLinkParserEnabled = false;
2119 while (pLinkInfo != null)
2121 if (IsViewModeEnabled() == true)
2123 switch (pLinkInfo->linkType)
2126 if (autoLinkMask & LINK_TYPE_URL)
2128 isChangingCutLink = true;
2129 editLinkType = EDIT_LINK_TYPE_URL;
2133 case LINK_TYPE_EMAIL:
2134 if (autoLinkMask & LINK_TYPE_EMAIL)
2136 isChangingCutLink = true;
2137 editLinkType = EDIT_LINK_TYPE_URL;
2141 case LINK_TYPE_TEL_NUM:
2142 if (autoLinkMask & LINK_TYPE_TEL_NUM)
2144 isChangingCutLink = true;
2145 editLinkType = EDIT_LINK_TYPE_PHONE_NUM;
2150 editLinkType = EDIT_LINK_TYPE_INVALID;
2156 _Text::TextElement* pTextElement = __pTextObject->GetElementAtTextIndex(pLinkInfo->srcOffset);
2157 if (pTextElement != null && pTextElement->GetType() != TEXT_ELEMENT_TYPE_CUTLINK)
2159 pNextLinkInfo = pLinkInfo->pNextLinkInfo;
2161 pLinkInfo = pNextLinkInfo;
2166 wchar_t* pCutLinkString = null;
2167 result r = E_SUCCESS;
2169 pCutLinkString = new(std::nothrow) wchar_t[(pLinkInfo->length + 1) * sizeof(wchar_t)];
2171 if (!pCutLinkString)
2173 while (pLinkInfo != null)
2175 pNextLinkInfo = pLinkInfo->pNextLinkInfo;
2177 pLinkInfo = pNextLinkInfo;
2179 SysLog(NID_UI_CTRL, "[E_SYSTEM] Unable to allocate cutlink text buffer.");
2183 for (int i = 0; i < pLinkInfo->length; i++)
2185 pCutLinkString[i] = __pTextBuffer[pLinkInfo->srcOffset + i];
2187 pCutLinkString[pLinkInfo->length] = null;
2189 r = DeleteText(pLinkInfo->srcOffset, pLinkInfo->srcOffset + pLinkInfo->length);
2193 int currentLength = __pTextString->GetLength();
2194 int fullLength = currentLength + pLinkInfo->length;
2196 r = __pTextString->Insert(String(pCutLinkString), pLinkInfo->srcOffset);
2197 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2199 wchar_t pOriginalString[currentLength - pLinkInfo->srcOffset];
2201 // Save original text.
2202 for (int i = 0; i < currentLength - pLinkInfo->srcOffset; i++)
2204 pOriginalString[i] = __pTextBuffer[pLinkInfo->srcOffset + i];
2206 pOriginalString[currentLength - pLinkInfo->srcOffset] = 0;
2209 for (int i = 0; i < pLinkInfo->length; i++)
2211 __pTextBuffer[i + pLinkInfo->srcOffset] = pCutLinkString[i];
2214 // Append origianal text.
2215 for (int i = 0; i < currentLength - pLinkInfo->srcOffset; i++)
2217 __pTextBuffer[i + pLinkInfo->srcOffset + pLinkInfo->length] = pOriginalString[i];
2219 __pTextBuffer[fullLength] = 0;
2222 if (isChangingCutLink)
2224 TextCutLink* pCutLinkObject = null;
2225 EditCutlinkColor cutlinkColor;
2227 Font* pFont = _FontImpl::CloneN(const_cast <Font&>(*__pFont));
2228 SysTryReturnResult(NID_UI_CTRL, pFont, GetLastResult(), "[EDIT] Unable to get font.");
2230 _FontImpl* fontImpl = _FontImpl::GetInstance(*pFont);
2231 SysTryReturnResult(NID_UI_CTRL, fontImpl, GetLastResult(), "[E_SYSTEM] fontImpl is null.");
2232 fontImpl->SetUnderline(true);
2234 __pEdit->GetCutlinkColorInfo(editLinkType, &cutlinkColor);
2235 pCutLinkObject = new (std::nothrow) TextCutLink(false, pLinkInfo->linkType, pCutLinkString, pLinkInfo->length, TEXT_ELEMENT_SOURCE_TYPE_INTERNAL, pFont,
2236 cutlinkColor.cutlinkFgColor, cutlinkColor.cutlinkBgColor, 0);
2240 if (pCutLinkObject == null)
2242 SysLog(NID_UI_CTRL, "[EDIT] Unable to allocate cutlink object.");
2246 pCutLinkObject->SetEditModeEnable(true);
2247 __pTextObject->InsertElementAt(pLinkInfo->srcOffset, *pCutLinkObject);
2248 __pTextObject->ChangeTextOffset(__pTextBuffer, pLinkInfo->srcOffset, pLinkInfo->length);
2253 TextSimple* pSimpleText = null;
2254 pSimpleText = new (std::nothrow) TextSimple(pCutLinkString, pLinkInfo->length, TEXT_ELEMENT_SOURCE_TYPE_INTERNAL, GetFont());
2256 if (pSimpleText == null)
2258 SysLog(NID_UI_CTRL, "[EDIT] Unable to allocate text object.");
2263 __pTextObject->InsertElementAt(pLinkInfo->srcOffset, *pSimpleText);
2264 __pTextObject->ChangeTextOffset(__pTextBuffer, pLinkInfo->srcOffset, pSimpleText->GetTextLength());
2268 pNextLinkInfo = pLinkInfo->pNextLinkInfo;
2270 pLinkInfo = pNextLinkInfo;
2272 if (pCutLinkString != null)
2274 delete[] pCutLinkString;
2275 pCutLinkString = null;
2279 __pTextObject->Compose();
2281 bool isCursorChanged = __isCursorChanged;
2282 SetCursorPosition(cursorPos);
2283 __isCursorChanged = isCursorChanged;
2289 _EditPresenter::GetLinkElementOffsetInTextBuffer(int elementIndex) const
2291 const int textElementCount = __pTextObject->GetElementCount();
2292 SysTryReturn(NID_UI_CTRL, elementIndex >= 0 && elementIndex <= textElementCount, -1, E_OUT_OF_RANGE, "[EDIT] The Invalid argument is given.");
2294 _Text::TextElement* pTextElement = null;
2295 int elementOffset = -1;
2296 int elementLength = 0;
2300 for (int index = 0; index <= elementIndex; index++)
2302 pTextElement = __pTextObject->GetElementAtElementIndex(index);
2303 if (pTextElement == null)
2308 elementOffset = static_cast<int>(pTextElement->GetValue(SET_TEXT_OFFSET));
2309 elementLength = pTextElement->GetTextLength();
2311 if (pTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)
2313 elementOffset = prevOffset + prevLength;
2316 prevOffset = elementOffset;
2317 prevLength = elementLength;
2318 pTextElement = null;
2321 return elementOffset;
2325 _EditPresenter::IsTextBlockedInTokenEdit(void) const
2331 _EditPresenter::GetCursorPositionAt(const Point& touchPoint) const
2336 Rectangle textObjectBounds = _CoordinateSystemUtils::ConvertToInteger(__textObjectBounds);
2337 Rectangle textBoxBounds = _CoordinateSystemUtils::ConvertToInteger(__textBoxBounds);
2339 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
2341 if (IsTextBlockedInTokenEdit())
2343 textObjectBounds = GetTextBounds();
2347 if (textObjectBounds.Contains(touchPoint))
2349 cursorPoint.x = touchPoint.x - textObjectBounds.x;
2350 cursorPoint.y = touchPoint.y - textObjectBounds.y;
2352 else if (textBoxBounds.Contains(touchPoint))
2354 if (touchPoint.y <= textObjectBounds.y)
2356 cursorPoint.y = textObjectBounds.y + 1;
2358 else if (touchPoint.y >= (textObjectBounds.y + textObjectBounds.height))
2360 cursorPoint.y = textObjectBounds.y + textObjectBounds.height - 1;
2364 cursorPoint.y = touchPoint.y;
2367 if (touchPoint.x <= textObjectBounds.x)
2369 cursorPoint.x = textObjectBounds.x + 1;
2371 else if (touchPoint.x >= (textObjectBounds.x + textObjectBounds.width))
2373 cursorPoint.x = textObjectBounds.x + textObjectBounds.width - 1;
2377 cursorPoint.x = touchPoint.x;
2379 cursorPoint.y -= textObjectBounds.y;
2380 cursorPoint.x -= textObjectBounds.x;
2387 cursorPos = __pTextObject->GetTextIndexFromPosition(cursorPoint.x, cursorPoint.y);
2393 _EditPresenter::GetCursorPositionAt(const FloatPoint& touchPoint) const
2395 FloatPoint cursorPoint;
2398 FloatRectangle textObjectBounds = __textObjectBounds;
2400 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
2402 if (IsTextBlockedInTokenEdit())
2404 textObjectBounds = GetTextBoundsF();
2408 if (textObjectBounds.Contains(touchPoint))
2410 cursorPoint.x = touchPoint.x - textObjectBounds.x;
2411 cursorPoint.y = touchPoint.y - textObjectBounds.y;
2413 else if (__textBoxBounds.Contains(touchPoint))
2415 if (touchPoint.y <= textObjectBounds.y)
2417 cursorPoint.y = textObjectBounds.y + 1.0f;
2419 else if (touchPoint.y >= (textObjectBounds.y + textObjectBounds.height))
2421 cursorPoint.y = textObjectBounds.y + textObjectBounds.height - 1.0f;
2425 cursorPoint.y = touchPoint.y;
2428 if (touchPoint.x <= textObjectBounds.x)
2430 cursorPoint.x = textObjectBounds.x + 1.0f;
2432 else if (touchPoint.x >= (textObjectBounds.x + textObjectBounds.width))
2434 cursorPoint.x = textObjectBounds.x + textObjectBounds.width - 1.0f;
2438 cursorPoint.x = touchPoint.x;
2440 cursorPoint.y -= textObjectBounds.y;
2441 cursorPoint.x -= textObjectBounds.x;
2448 cursorPos = __pTextObject->GetTextIndexFromPosition(cursorPoint.x, cursorPoint.y);
2454 _EditPresenter::IsHorizontalDirection(const _TouchInfo& touchInfo)
2456 if (touchInfo.GetTouchStatus() != _TOUCH_MOVED)
2461 if (__isMovingCursorByTouchMove)
2466 FloatRectangle absoluteEditRect = __pEdit->GetAbsoluteBoundsF();
2467 FloatPoint touchStartPoint = __pressedAbsolutePoint;
2468 //After internal touch core complete the float conversion, we need to change the code here
2469 FloatPoint touchPoint = touchInfo.GetCurrentPosition();
2471 float movedWidth = touchStartPoint.x - touchPoint.x - absoluteEditRect.x;
2472 float movedHeight = touchStartPoint.y - touchPoint.y - absoluteEditRect.y;
2473 movedWidth = (movedWidth >= 0.0f) ? movedWidth : -(movedWidth);
2474 movedHeight = (movedHeight >= 0.0f) ? movedHeight : -(movedHeight);
2476 if (movedWidth >= movedHeight * DIRECTION_DECISION_RATIO)
2485 _EditPresenter::IsInitialized(void) const
2487 return __isInitialized;
2491 _EditPresenter::CalculateCursorBounds(const FloatRectangle& textBounds, FloatRectangle& cursorBounds, int cursorPos)
2493 float cursorWidth = 0.0f;
2494 float cursorHeight = 0.0f;
2495 float cursorAbsX = 0.0f;
2496 float cursorAbsY = 0.0f;
2497 float cursorRelativeX = 0.0f;
2498 float cursorRelativeY = 0.0f;
2500 __pTextObject->SetBounds(textBounds);
2502 if (cursorPos == -1)
2504 cursorPos = __pTextObject->GetCursorIndex();
2507 if (__pTextObject->GetTextPositionInfoAt(cursorPos, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
2512 cursorBounds.x = cursorRelativeX;
2513 cursorBounds.y = cursorRelativeY;
2514 float cursorWidthValue = 0.0f;
2515 GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorWidthValue);
2516 cursorBounds.width = cursorWidthValue;
2517 cursorBounds.height = cursorHeight;
2519 if (cursorBounds.y == 0.0f)
2521 cursorBounds.y = __textObjectBounds.y;
2524 if (cursorBounds.height == 0.0f)
2526 cursorBounds.height = __textObjectBounds.height;
2529 if (cursorBounds.height == 0.0f)
2534 if (cursorBounds.y < textBounds.y)
2536 float cursorHeightDiff = textBounds.y - cursorBounds.y;
2537 cursorBounds.y = textBounds.y;
2538 cursorBounds.height -= cursorHeightDiff;
2541 if (cursorBounds.x == textBounds.x + textBounds.width)
2543 cursorBounds.x -= 1.0f;
2545 else if (cursorBounds.x > textBounds.x + textBounds.width)
2547 cursorBounds.x = textBounds.x + textBounds.width;
2551 if (__pTextObject->GetBlock() == false)
2553 cursorBounds.x -= 1.0f;
2554 if (cursorBounds.x < textBounds.x)
2556 cursorBounds.x = textBounds.x;
2564 _EditPresenter::CalculateCursorBounds(const Rectangle& textBounds, Rectangle& cursorBounds, int cursorPos)
2566 int cursorWidth = 0;
2567 int cursorHeight = 0;
2570 int cursorRelativeX = 0;
2571 int cursorRelativeY = 0;
2573 __pTextObject->SetBounds(textBounds);
2575 if (cursorPos == -1)
2577 cursorPos = __pTextObject->GetCursorIndex();
2580 if (__pTextObject->GetTextPositionInfoAt(cursorPos, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
2585 cursorBounds.x = cursorRelativeX;
2586 cursorBounds.y = cursorRelativeY;
2587 GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorBounds.width);
2588 cursorBounds.height = cursorHeight;
2590 if (cursorBounds.y == 0)
2592 cursorBounds.y = _CoordinateSystemUtils::ConvertToInteger(__textObjectBounds.y);
2595 if (cursorBounds.height == 0)
2597 cursorBounds.height = _CoordinateSystemUtils::ConvertToInteger(__textObjectBounds.height);
2600 if (cursorBounds.height == 0)
2605 if (cursorBounds.y < textBounds.y)
2607 int cursorHeightDiff = textBounds.y - cursorBounds.y;
2608 cursorBounds.y = textBounds.y;
2609 cursorBounds.height -= cursorHeightDiff;
2612 if (cursorBounds.x == textBounds.x + textBounds.width)
2614 cursorBounds.x -= 1;
2616 else if (cursorBounds.x > textBounds.x + textBounds.width)
2618 cursorBounds.x = textBounds.x + textBounds.width;
2622 if (__pTextObject->GetBlock() == false)
2624 cursorBounds.x -= 1;
2625 if (cursorBounds.x < textBounds.x)
2627 cursorBounds.x = textBounds.x;
2631 GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorBounds.width);
2637 _EditPresenter::ScrollContents(float moveY)
2640 float firstDisplayY = 0.0f;
2641 float effectDistance = moveY;
2643 float totalHeight = __pTextObject->GetTotalHeightF();
2644 float newFirstDisplayY = firstDisplayY = __pTextObject->GetFirstDisplayPositionYF();
2645 int currentCursorLine = 0;
2647 if (__pTextObject->GetTextLength() < 1)
2652 if (__pScrollBar && __pScrollBar->GetScrollPosition() == 0 && effectDistance < 0.0f)
2654 if (__pFlickAnimationTimer)
2659 if (__pScrollBar->IsOnFadeEffect() == true)
2661 __pScrollBar->SetScrollVisibility(false);
2666 else if (__pScrollBar && __pScrollBar->GetScrollPosition() != 0 && __pScrollBar->GetScrollPosition() == __previousScrollBarMaxPos && effectDistance > 0.0f)
2668 if (__pFlickAnimationTimer)
2673 if (__pScrollBar->IsOnFadeEffect() == true)
2675 __pScrollBar->SetScrollVisibility(false);
2681 if (__pTextObject->GetCursorIndex() == __pTextObject->GetTextLength())
2683 currentCursorLine = __pTextObject->GetTotalLineCount() - 1;
2687 currentCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
2690 if (currentCursorLine == -1)
2695 if (currentCursorLine < 0)
2697 currentCursorLine = 0;
2700 newFirstDisplayY += moveY;
2702 if (newFirstDisplayY > (totalHeight - __textObjectBounds.height))
2704 newFirstDisplayY = totalHeight - __textObjectBounds.height;
2707 if (newFirstDisplayY < 0.0f)
2709 newFirstDisplayY = 0.0f;
2712 moveLine = __pTextObject->GetLineIndexAtPositionY(newFirstDisplayY);
2714 __pTextObject->SetFirstDisplayLineIndex(moveLine);
2715 __pTextObject->SetFirstDisplayPositionY(newFirstDisplayY);
2717 __isCursorOpaque = false;
2718 if (__isCopyPasteManagerExist)
2720 __pCopyPasteManager->AdjustBounds();
2727 _EditPresenter::ScrollContents(int moveY)
2730 int firstDisplayY = 0;
2731 int effectDistance = moveY;
2733 int totalHeight = __pTextObject->GetTotalHeight();
2734 int newFirstDisplayY = firstDisplayY = __pTextObject->GetFirstDisplayPositionY();
2735 int currentCursorLine = 0;
2737 if (__pTextObject->GetTextLength() < 1)
2742 if (__pScrollBar && __pScrollBar->GetScrollPosition() == 0 && effectDistance < 0)
2744 if (__pFlickAnimationTimer)
2749 if (__pScrollBar->IsOnFadeEffect() == true)
2751 __pScrollBar->SetScrollVisibility(false);
2756 else if (__pScrollBar && __pScrollBar->GetScrollPosition() != 0 && __pScrollBar->GetScrollPosition() == __previousScrollBarMaxPos && effectDistance > 0)
2758 if (__pFlickAnimationTimer)
2763 if (__pScrollBar->IsOnFadeEffect() == true)
2765 __pScrollBar->SetScrollVisibility(false);
2771 if (__pTextObject->GetCursorIndex() == __pTextObject->GetTextLength())
2773 currentCursorLine = __pTextObject->GetTotalLineCount() - 1;
2777 currentCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
2780 if (currentCursorLine == -1)
2785 if (currentCursorLine < 0)
2787 currentCursorLine = 0;
2790 newFirstDisplayY += moveY;
2792 if (newFirstDisplayY > (totalHeight - _CoordinateSystemUtils::ConvertToInteger(__textObjectBounds.height)))
2794 newFirstDisplayY = totalHeight - _CoordinateSystemUtils::ConvertToInteger(__textObjectBounds.height);
2797 if (newFirstDisplayY < 0)
2799 newFirstDisplayY = 0;
2802 moveLine = __pTextObject->GetLineIndexAtPositionY(newFirstDisplayY);
2804 __pTextObject->SetFirstDisplayLineIndex(moveLine);
2805 __pTextObject->SetFirstDisplayPositionY(newFirstDisplayY);
2807 __isCursorOpaque = false;
2808 if (__isCopyPasteManagerExist)
2810 __pCopyPasteManager->AdjustBounds();
2817 _EditPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
2819 if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
2824 if (__isCopyPasteManagerExist)
2826 __pCopyPasteManager->ReleaseCopyPastePopup();
2829 __isTouchPressed = true;
2831 __pScrollEffect->previousY = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().y);
2832 __pScrollEffect->currentY = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().y);
2834 FloatRectangle absoluteEditRect = __pEdit->GetAbsoluteBoundsF();
2836 __pressedPoint = touchInfo.GetCurrentPosition();
2837 __pressedAbsolutePoint.x = __pressedPoint.x + absoluteEditRect.x;
2838 __pressedAbsolutePoint.y = __pressedPoint.y + absoluteEditRect.y;
2840 if (IsViewModeEnabled())
2842 int cutLinkIndex = -1;
2844 __pTextObject->ResetAllCutLinkElementsState();
2846 cutLinkIndex = __pTextObject->GetCutLinkIndexFromPositionData(__pressedPoint.x - __textObjectBounds.x, __pressedPoint.y - __textObjectBounds.y);
2848 if (cutLinkIndex != -1)
2850 __pTextObject->ChangeCutLinkState(cutLinkIndex, true);
2854 if (__pEdit->GetEditStyle() & EDIT_STYLE_CLEAR)
2856 if ((__pressedPoint.x >= __clearIconBounds.x) && (__pressedPoint.x <= __clearIconBounds.x + __clearIconBounds.width)) // Clear Icon Pressed
2858 __isClearIconPressed = true;
2863 __pEdit->Invalidate();
2869 _EditPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
2871 if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
2876 if (__isClearIconPressed)
2878 __isClearIconPressed = false;
2881 __isTouchPressed = false;
2882 __isMovingCursorByTouchMove = false;
2884 if (__isTouchReleaseSkipped || __isTouchMoving)
2886 __isTouchReleaseSkipped = false;
2888 __isTouchMoving = false;
2891 if (__isScrollBarVisible && __pScrollBar)
2893 if (__pScrollBar->IsVisible())
2895 __pScrollBar->SetScrollVisibility(false);
2897 __isScrollBarVisible = false;
2900 __isTouchMoving = false;
2901 __pEdit->Invalidate();
2907 _EditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
2909 if (__isCopyPasteManagerExist)
2911 if (__isTouchPressed && !__isCopyPastePopupMoving)
2913 InitializeCopyPasteManager();
2914 if (__isClearIconPressed)
2916 FloatPoint touchPoint = touchInfo.GetCurrentPosition();
2917 __isClearIconPressed = false;
2918 if ((touchPoint.x >= __clearIconBounds.x) && (touchPoint.x <= __clearIconBounds.x + __clearIconBounds.width)
2919 && (touchPoint.y >= __clearIconBounds.y) && (touchPoint.y <= __clearIconBounds.y + __clearIconBounds.height))
2922 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
2923 __isTouchPressed = false;
2924 __isMovingCursorByTouchMove = false;
2925 __pEdit->Invalidate();
2931 if (!IsInternalFocused())
2933 __pEdit->SetFocused();
2935 __pCopyPasteManager->CreateCopyPastePopup();
2936 __pCopyPasteManager->Show();
2938 __isCopyPastePopupMoving = false;
2943 if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
2948 int cutLinkIndex = -1;
2949 FloatRectangle clientBounds;
2950 FloatPoint touchPoint = touchInfo.GetCurrentPosition();
2952 if (IsViewModeEnabled())
2954 __pEdit->SetFocused();
2955 __pTextObject->ResetAllCutLinkElementsState();
2958 if (__isClearIconPressed)
2960 __isClearIconPressed = false;
2961 if ((touchPoint.x >= __clearIconBounds.x) && (touchPoint.x <= __clearIconBounds.x + __clearIconBounds.width)
2962 && (touchPoint.y >= __clearIconBounds.y) && (touchPoint.y <= __clearIconBounds.y + __clearIconBounds.height))
2965 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
2966 __isTouchPressed = false;
2967 __isMovingCursorByTouchMove = false;
2968 __pEdit->Invalidate();
2974 if (!__isCopyPasteManagerExist)
2976 __isTextBlocked = false;
2978 __isTouchPressed = false;
2979 __isMovingCursorByTouchMove = false;
2981 if (__isTouchReleaseSkipped)
2983 __isTouchReleaseSkipped = false;
2985 __isTouchMoving = false;
2986 __pEdit->Invalidate();
2991 if (IsViewModeEnabled())
2993 cutLinkIndex = __pTextObject->GetCutLinkIndexFromPositionData(touchPoint.x - __textObjectBounds.x, touchPoint.y - __textObjectBounds.y);
2995 if (cutLinkIndex != -1)
2997 TextCutLink* pCutLinkObject = dynamic_cast<TextCutLink*>(__pTextObject->GetCutLinkElementAtCutLinkElementIndex(cutLinkIndex));
2998 if (pCutLinkObject == null)
3003 String cutLinkString(pCutLinkObject->GetText());
3004 LinkType baseLinkType = pCutLinkObject->GetCutLinkType();
3006 // Send Ui Link Event
3007 __pEdit->SendLinkEvent(cutLinkString, baseLinkType, cutLinkString);
3010 if (__isTouchMoving && __isInputConnectionBound == false)
3013 __isTouchMoving = false;
3014 __isTouchReleaseSkipped = false;
3015 __pEdit->Invalidate();
3020 clientBounds = __pEdit->GetBoundsF();
3021 clientBounds.x = 0.0f;
3022 clientBounds.y = 0.0f;
3023 touchPoint = touchInfo.GetCurrentPosition();
3024 if (clientBounds.Contains(touchPoint))
3026 int cursorPos = GetCursorPositionAt(touchPoint);
3027 if (cursorPos != -1)
3029 if (__isInputConnectionBound == true && __isTextComposing == true)
3031 __pInputConnection->FinishTextComposition();
3033 if (!__isCopyPasteManagerExist) // Copy&Paste
3035 if ((__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) == true && IsInternalFocused() == false)
3037 __isCursorChanged = true;
3041 SetCursorPosition(cursorPos);
3047 if (!__isCopyPasteManagerExist)
3049 if (IsInternalFocused())
3051 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
3052 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, false, E_SYSTEM, "[EDIT] Unable to create _EditCopyPasteManager instance.");
3053 __pCopyPasteManager->AddCopyPasteEventListener(*this);
3054 __pCopyPasteManager->Show();
3055 __isCopyPasteManagerExist = true;
3059 //if ((cutLinkIndex < 0) && ((__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER) == false) && (IsKeypadEnabled()))
3060 if ((cutLinkIndex < 0) && ((__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER) == false))
3062 CheckUSBKeyboardStatus();
3064 if (__isUSBKeyboardConnected)
3066 if (!__isInputConnectionBound)
3068 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
3070 if (IsInternalFocused())
3076 __pEdit->SetFocused();
3081 ShowFullscreenKeypad();
3088 if (!__isKeypadExist || !__isInputConnectionBound)
3090 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
3092 if (IsInternalFocused())
3098 __pEdit->SetFocused();
3103 ShowFullscreenKeypad();
3110 if (__isScrollBarVisible && __pScrollBar)
3112 if (__pScrollBar->IsVisible())
3114 __pScrollBar->SetScrollVisibility(false);
3116 __isScrollBarVisible = false;
3119 __isTouchMoving = false;
3120 __pEdit->Invalidate();
3126 _EditPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
3128 if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
3133 FloatPoint touchPoint = touchInfo.GetCurrentPosition();
3135 if (__isClearIconPressed)
3137 if ((touchPoint.x < __clearIconBounds.x) || (touchPoint.x > __clearIconBounds.x + __clearIconBounds.width)
3138 || (touchPoint.y < __clearIconBounds.y) || (touchPoint.y > __clearIconBounds.y + __clearIconBounds.height))
3140 __isClearIconPressed = false;
3141 __pEdit->Invalidate();
3145 if (__isCopyPasteManagerExist)
3147 __pCopyPasteManager->Show();
3148 __isCopyPastePopupMoving = true;
3151 if (__isTouchMoving == false && IsHorizontalDirection(touchInfo))
3153 if (__isCopyPasteManagerExist && IsBlocked())
3159 FloatRectangle fromBounds;
3160 FloatRectangle toBounds;
3162 CalculateCursorBounds(__textObjectBounds, fromBounds);
3163 newIndex = GetCursorPositionAt(touchInfo.GetCurrentPosition());
3166 if (Math::Abs(newIndex - __cursorPos) > 3)
3171 CalculateCursorBounds(__textObjectBounds, toBounds, newIndex);
3172 __isCursorChanged = true;
3173 SetCursorPosition(newIndex);
3175 __isMovingCursorByTouchMove = true;
3176 __isTouchReleaseSkipped = true;
3179 MoveCursor(fromBounds, toBounds);
3180 __pEdit->Invalidate();
3185 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE || __pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
3187 float horizontalGap = touchInfo.GetCurrentPosition().x - fromBounds.x;
3188 FloatDimension currentCharacterDimension;
3189 if (horizontalGap > 0.0f && __cursorPos < GetTextLength())
3191 currentCharacterDimension = __pTextObject->GetTextExtentF(__cursorPos, 1);
3192 if (horizontalGap >= currentCharacterDimension.width)
3194 SetCursorPosition(__cursorPos+1);
3195 __pEdit->Invalidate();
3199 if (horizontalGap < 0.0f && __cursorPos > 0)
3201 currentCharacterDimension = __pTextObject->GetTextExtentF(__cursorPos-1, 1);
3202 if (Math::Abs(horizontalGap) >= currentCharacterDimension.width)
3204 SetCursorPosition(__cursorPos-1);
3205 __pEdit->Invalidate();
3211 if (__isMovingCursorByTouchMove)
3217 float totalHeight = __pTextObject->GetTotalHeightF();
3221 if (__textObjectBounds.height >= totalHeight)
3223 __isTouchMoving = true;
3224 __isTouchReleaseSkipped = true;
3229 if ((touchInfo.GetCurrentPosition().y == __pScrollEffect->currentY) ||
3230 (Math::Abs(touchInfo.GetCurrentPosition().y - __pScrollEffect->previousY) < MOVE_SKIP_DECISION_RANGE))
3235 __pScrollEffect->previousY = __pScrollEffect->currentY;
3236 __pScrollEffect->currentY = touchInfo.GetCurrentPosition().y;
3238 float moveGap = __pScrollEffect->previousY - __pScrollEffect->currentY;
3240 if (__isMovingCursorByTouchMove)
3242 __isMovingCursorByTouchMove = false;
3245 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_NOSCROLL))
3249 if (totalHeight > __textObjectBounds.height)
3251 __pScrollBar->SetScrollVisibility(true);
3255 __pScrollBar->SetScrollVisibility(false);
3260 result returnResult = ScrollContents(moveGap);
3262 __isCursorChanged = false;
3263 __isTouchMoving = true;
3267 if (returnResult == E_SUCCESS)
3273 __isTouchReleaseSkipped = true;
3279 _EditPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
3281 result r = E_SUCCESS;
3282 _KeyCode keyCode = keyInfo.GetKeyCode();
3285 if (IsViewModeEnabled() == true)
3290 if (__isUSBKeyboardConnected && (keyInfo.GetKeyModifier() & _KEY_MODIFIER_CTRL))
3295 if (__isInputConnectionBound && __isTextComposing)
3297 __pInputConnection->FinishTextComposition();
3298 __isTextComposing = false;
3299 __composingTextLength = 0;
3302 if (__isCopyPasteManagerExist)
3304 InitializeCopyPasteManager();
3307 textLength = __pEdit->GetTextLength();
3312 __pEdit->SetBlockRange(0, textLength);
3313 r = __pEdit->SendTextBlockEvent(0, textLength);
3314 UpdateComponentInformation();
3315 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r));
3316 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
3317 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, true, E_OUT_OF_MEMORY, "[EDIT] Unable to create _EditCopyPasteManager instance.");
3318 __pCopyPasteManager->AddCopyPasteEventListener(*this);
3319 __pCopyPasteManager->CreateCopyPastePopup();
3320 __pCopyPasteManager->Show();
3321 __isCopyPasteManagerExist = true;
3324 textLength = __pEdit->GetTextLength();
3330 if (__isCopyPasteManagerExist)
3332 InitializeCopyPasteManager();
3336 textLength = __pEdit->GetTextLength();
3342 if (__isCopyPasteManagerExist)
3344 InitializeCopyPasteManager();
3349 if (__isCopyPasteManagerExist)
3351 InitializeCopyPasteManager();
3357 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
3363 __pEdit->Invalidate();
3368 else if (__isUSBKeyboardConnected && keyInfo.GetKeyModifier() & _KEY_MODIFIER_SHIFT)
3370 if (!__isCopyPasteManagerExist)
3372 if ( (keyCode == _KEY_LEFT) || (keyCode == _KEY_UP) || (keyCode == _KEY_DOWN) || (keyCode == _KEY_RIGHT) )
3374 SetBlockRangeWithShiftArrowkey(keyCode);
3386 __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_LEFT);
3389 __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_UP);
3392 __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_DOWN);
3395 __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_RIGHT);
3402 else if (_KEY_ENTER == keyCode)
3404 if (__isInputConnectionBound != false && __isTextComposing != false)
3410 if (IsKeypadActionEnabled())
3412 char enterText[2] = {'\n', };
3413 OnTextCommitted(String(enterText));
3419 else if (_KEY_BACKSPACE == keyCode)
3421 if (__isTextComposing == false)
3423 OnSurroundingTextDeleted(-1, 1);
3424 if (AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT) == true)
3426 __pTextObject->Compose();
3427 __pEdit->Invalidate();
3429 ScrollPanelToCursorPosition();
3433 else if ((keyInfo.GetKeyModifier() & _KEY_LOCK_NUM) && (_KEY_NUM_LEFT == keyCode || _KEY_NUM_RIGHT == keyCode || _KEY_NUM_UP == keyCode || _KEY_NUM_DOWN == keyCode))
3437 else if (_KEY_LEFT == keyCode || _KEY_NUM_LEFT == keyCode)
3439 if (__isCopyPasteManagerExist)
3441 InitializeCopyPasteManager();
3444 if (__isInputConnectionBound != false && __isTextComposing != false)
3446 __pInputConnection->FinishTextComposition();
3447 __isTextComposing = false;
3448 __composingTextLength = 0;
3451 if (__cursorPos != 0)
3453 int startPosition = -1;
3454 int endPosition = -1;
3455 GetTextImageRangeAt(__cursorPos-1, startPosition, endPosition);
3456 if (endPosition > -1 && startPosition >= 0 && startPosition < __cursorPos-1)
3458 SetCursorPosition(startPosition);
3462 SetCursorPosition(__cursorPos-1);
3465 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
3471 __pEdit->Invalidate();
3476 else if (_KEY_UP == keyCode || _KEY_NUM_UP == keyCode)
3478 if (__isCopyPasteManagerExist)
3480 InitializeCopyPasteManager();
3483 if (__isInputConnectionBound != false && __isTextComposing != false)
3485 __pInputConnection->FinishTextComposition();
3486 __isTextComposing = false;
3487 __composingTextLength = 0;
3490 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
3491 if (curCursorLine !=0 )
3493 int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
3494 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine-1);
3495 int newCursorPosition = offset + firstTextIndex;
3496 int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
3497 FloatRectangle clientBounds(0.0f, 0.0f, 0.0f, 0.0f);
3498 FloatRectangle absCursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
3499 if (offset<textLength)
3501 int startPosition = -1;
3502 int endPosition = -1;
3503 GetTextImageRangeAt(newCursorPosition, startPosition, endPosition);
3504 if (endPosition > newCursorPosition && startPosition < newCursorPosition)
3506 newCursorPosition = endPosition;
3508 SetCursorPosition(newCursorPosition);
3513 __pTextString->GetCharAt(firstTextIndex+textLength - 1, ch);
3516 SetCursorPosition(firstTextIndex+textLength - 1);
3520 SetCursorPosition(firstTextIndex+textLength);
3526 clientBounds = __pParentForm->GetClientBoundsF();
3527 GetCursorBounds(true, absCursorBounds);
3528 if (!clientBounds.Contains(FloatPoint(absCursorBounds.x, absCursorBounds.y)))
3530 ScrollPanelToCursorPosition();
3531 __pParentForm->Draw();
3534 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
3541 else if (_KEY_DOWN == keyCode || _KEY_NUM_DOWN == keyCode)
3543 if (__isCopyPasteManagerExist)
3545 InitializeCopyPasteManager();
3548 if (__isInputConnectionBound != false && __isTextComposing != false)
3550 __pInputConnection->FinishTextComposition();
3551 __isTextComposing = false;
3552 __composingTextLength = 0;
3555 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
3556 int totalLine = __pTextObject->GetTotalLineCount();
3557 if (curCursorLine < totalLine - 1)
3559 int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
3560 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
3561 int newCursorPosition = offset + firstTextIndex;
3562 int textLength = __pTextObject->GetTextLengthAt(curCursorLine+1);
3563 FloatRectangle clientBounds(0.0f, 0.0f, 0.0f, 0.0f);
3564 FloatRectangle absCursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
3566 if (offset<textLength)
3568 int startPosition = -1;
3569 int endPosition = -1;
3570 GetTextImageRangeAt(newCursorPosition, startPosition, endPosition);
3571 if (endPosition > newCursorPosition && startPosition < newCursorPosition)
3573 newCursorPosition = endPosition;
3575 SetCursorPosition(newCursorPosition);
3580 __pTextString->GetCharAt(firstTextIndex+textLength - 1, ch);
3583 SetCursorPosition(firstTextIndex+textLength - 1);
3587 SetCursorPosition(firstTextIndex+textLength);
3593 clientBounds = __pParentForm->GetClientBoundsF();
3594 GetCursorBounds(true, absCursorBounds);
3596 if (!clientBounds.Contains(FloatPoint(absCursorBounds.x, absCursorBounds.y + absCursorBounds.height)))
3598 ScrollPanelToCursorPosition();
3599 __pParentForm->Draw();
3602 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
3609 else if (_KEY_RIGHT == keyCode || _KEY_NUM_RIGHT == keyCode)
3611 if (__isCopyPasteManagerExist)
3613 InitializeCopyPasteManager();
3616 if (__isInputConnectionBound != false && __isTextComposing != false)
3618 __pInputConnection->FinishTextComposition();
3619 __isTextComposing = false;
3620 __composingTextLength = 0;
3623 if (__cursorPos == GetTextLength())
3628 if (__cursorPos < GetTextLength())
3630 int startPosition = -1;
3631 int endPosition = -1;
3632 GetTextImageRangeAt(__cursorPos, startPosition, endPosition);
3633 if (endPosition > __cursorPos+1 && startPosition > -1)
3635 SetCursorPosition(endPosition);
3639 SetCursorPosition(__cursorPos+1);
3642 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
3648 __pEdit->Invalidate();
3653 else if (_KEY_DELETE == keyCode)
3655 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
3657 if (!GetTextLength())
3663 if (__isCopyPasteManagerExist)
3665 if (IsBlocked() == true)
3669 GetBlockRange(start, end);
3670 DeleteText(start, end);
3675 int cursorPosition = GetCursorPosition();
3676 DeleteText(cursorPosition, cursorPosition+1);
3679 InitializeCopyPasteManager();
3683 if (__isInputConnectionBound && __isTextComposing)
3685 __pInputConnection->FinishTextComposition();
3686 __isTextComposing = false;
3687 __composingTextLength = 0;
3690 int cursorPosition = GetCursorPosition();
3691 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
3693 DeleteText(cursorPosition, cursorPosition+1);
3697 OnSurroundingTextDeleted(0, 1);
3700 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
3706 __pEdit->Invalidate();
3708 ScrollPanelToCursorPosition();
3712 else if (_KEY_OEM_1 == keyCode)
3714 __pClipboard->ShowPopup(CLIPBOARD_DATA_TYPE_TEXT, *__pEdit);
3715 __isClipboardExist = true;
3718 else if (__composingTextLength > 0 && GetTextLength() >= __limitLength)
3727 _EditPresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
3729 _KeyCode keyCode = keyInfo.GetKeyCode();
3731 if (__isUSBKeyboardConnected && (keyCode == _KEY_SHIFT_L || keyCode == _KEY_SHIFT_R))
3733 if (__pCopyPasteManager && __pCopyPasteManager->IsHandlerMovingEnabled())
3735 __pCopyPasteManager->SetHandlerMovingEnabled(false);
3736 __pCopyPasteManager->CreateCopyPastePopup();
3737 __pCopyPasteManager->Show();
3739 else if (__textBlockMoving)
3741 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
3742 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, true, E_OUT_OF_MEMORY, "[EDIT] Unable to create _EditCopyPasteManager instance.");
3743 __pCopyPasteManager->AddCopyPasteEventListener(*this);
3744 __pCopyPasteManager->CreateCopyPastePopup();
3745 __pCopyPasteManager->Show();
3746 __isCopyPasteManagerExist = true;
3748 __textBlockMoving = false;
3757 _EditPresenter::OnClipboardPopupClosed(const ClipboardItem* pClipboardItem)
3763 String filteredString;
3765 if (!pClipboardItem && IsBlocked())
3770 if (__isCopyPasteManagerExist)
3774 __pCopyPasteManager->SetTextBlockReleaseFlag(false);
3776 InitializeCopyPasteManager();
3779 SysTryReturnVoidResult(NID_UI_CTRL, pClipboardItem != null, E_SYSTEM, "[E_SYSTEM] _EditPresenter::OnClipboardPopupClosed: Unable to get the clipboarditem instance.");
3781 String* pClipString = dynamic_cast<String*>(pClipboardItem->GetData());
3782 SysTryReturnVoidResult(NID_UI_CTRL, pClipString != null, E_SYSTEM, "[E_SYSTEM] _EditPresenter::OnClipboardPopupClosed: Unable to get the clipboarditem instance.");
3784 int currentLength = GetTextLength();
3785 String* pSubString = null;
3786 result r = E_SUCCESS;
3788 filteredString = *pClipString;
3792 if(__pTextFilter->ValidatePastedText(*pClipString, userString))
3794 filteredString = userString;
3795 SysLog(NID_UI_CTRL, "ClipString was changed by User");
3798 else if (IsUnsupportedChracterExist(GetKeypadStyle(), *pClipString) == true)
3805 GetBlockRange(start, end);
3806 total = currentLength - (end - start) + filteredString.GetLength();
3807 if (total > __limitLength)
3809 DeleteText(start, end);
3811 pSubString = new String(__limitLength - currentLength + (end - start));
3812 SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "[EDIT] Unable to allocate text buffer.");
3814 filteredString.SubString(0, __limitLength - currentLength + (end - start), *pSubString);
3815 r = InsertTextAt(__cursorPos, pSubString->GetPointer());
3816 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3821 DeleteText(start, end);
3823 r = InsertTextAt(__cursorPos, filteredString.GetPointer());
3824 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3827 else if (currentLength + filteredString.GetLength() > __limitLength)
3829 if (__limitLength == currentLength)
3831 delete pClipboardItem;
3835 pSubString = new String(__limitLength - currentLength);
3836 SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "[EDIT] Unable to allocate text buffer.");
3838 filteredString.SubString(0, __limitLength - currentLength, *pSubString);
3839 r = InsertTextAt(__cursorPos, pSubString->GetPointer());
3840 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3845 r = InsertTextAt(__cursorPos, filteredString.GetPointer());
3846 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3849 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
3851 __pEdit->Invalidate();
3853 delete pClipboardItem;
3858 delete pClipboardItem;
3864 _EditPresenter::OnLongPressGestureDetected(void)
3866 if (__isClearIconPressed)
3871 if (__isCopyPasteManagerExist)
3875 else if (IsInternalFocused() == false && !IsViewModeEnabled())
3880 __isTouchPressed = false;
3881 FloatRectangle cursorBounds;
3882 InitializeCopyPasteManager();
3883 if (IsClipped() || GetTextLength())
3885 if (IsClipped() && !GetTextLength() && (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER))
3890 if (!IsClipped() && (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD))
3895 if (__isInputConnectionBound && __isTextComposing)
3897 __pInputConnection->FinishTextComposition();
3898 __isTextComposing = false;
3899 __composingTextLength = 0;
3902 int cursorPos = GetCursorPositionAt(__pressedPoint);
3903 if (cursorPos != -1)
3905 SetCursorPosition(cursorPos);
3907 ScrollPanelToCursorPosition();
3908 GetCursorBounds(true, cursorBounds);
3910 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
3911 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, false, E_SYSTEM, "[EDIT] Unable to create _EditCopyPasteManager instance.");
3912 __pCopyPasteManager->AddCopyPasteEventListener(*this);
3913 __pCopyPasteManager->Show();
3914 __isCopyPasteManagerExist = true;
3922 _EditPresenter::OnTapGestureDetected(void)
3924 if (IsInternalFocused() == false)
3929 if (!__isUSBKeyboardConnected)
3931 if (__isKeypadShowing)
3935 __isTouchPressed = false;
3936 InitializeCopyPasteManager();
3938 if (GetTextLength() > 0)
3940 FloatRectangle cursorBounds;
3943 int cursorPos = GetCursorPositionAt(__pressedPoint);
3945 if (cursorPos == -1)
3950 GetWordPosition(cursorPos, start, end);
3951 SetBlockRange(start, end);
3952 ScrollPanelToCursorPosition();
3953 GetCursorBounds(true, cursorBounds);
3955 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
3956 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, false, E_SYSTEM, "[EDIT] Unable to create _EditCopyPasteManager instance.");
3957 __pCopyPasteManager->AddCopyPasteEventListener(*this);
3958 __pCopyPasteManager->CreateCopyPastePopup();
3959 __pCopyPasteManager->Show();
3960 __isCopyPasteManagerExist = true;
3962 if (__isInputConnectionBound && __isTextComposing)
3964 __pInputConnection->FinishTextComposition();
3965 __isTextComposing = false;
3966 __composingTextLength = 0;
3975 _EditPresenter::GetTextAlignment(void) const
3977 return __horizontalAlignment;
3981 _EditPresenter::GetLineSpacing(void) const
3983 int linePixelGap = -1;
3985 linePixelGap = __pTextObject->GetLineSpace();
3987 return linePixelGap;
3991 _EditPresenter::GetLineSpacingF(void) const
3993 float linePixelGap = -1.0;
3995 linePixelGap = __pTextObject->GetLineSpaceF();
3997 return linePixelGap;
4001 _EditPresenter::GetBlockRange(int& start, int& end) const
4003 if (__isTextBlocked == false || __cursorPos == __blockStartPos)
4008 if (__cursorPos > __blockStartPos)
4010 start = __blockStartPos;
4015 start = __cursorPos;
4016 end = __blockStartPos;
4023 _EditPresenter::SetBlockRange(int start, int end)
4025 result r = E_SUCCESS;
4027 r = SetCursorPosition(start);
4028 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4030 r = BeginTextBlock();
4031 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4033 r = SetCursorPosition(end);
4034 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4040 _EditPresenter::BeginTextBlock(void)
4042 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
4045 __isTextBlocked = true;
4046 __blockStartPos = __cursorPos;
4052 _EditPresenter::ReleaseTextBlock(void)
4054 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
4058 if (__isTextBlocked == false)
4063 __isTextBlocked = false;
4069 _EditPresenter::IsBlocked(void) const
4071 return __isTextBlocked;
4075 _EditPresenter::CopyText(void)
4077 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
4080 result r = E_SUCCESS;
4082 _Clipboard* pClipBoard = _Clipboard::GetInstance();
4083 SysTryReturnResult(NID_UI_CTRL, pClipBoard != null, E_SYSTEM, "[EDIT] Unable to get the clipboard instance.");
4087 GetBlockRange(start, end);
4089 String blockString(GetText(start, end - 1));
4091 _ClipboardItem* pClipboardItem = _ClipboardItem::CreateInstanceN(CLIPBOARD_DATA_TYPE_TEXT, blockString);
4092 SysTryReturnResult(NID_UI_CTRL, pClipboardItem != null, E_SYSTEM, "[EDIT] Unable to get the clipboarditem instance.");
4094 r = pClipBoard->CopyItem(*pClipboardItem);
4096 delete pClipboardItem;
4098 _Text::TextElement* pStartTextElement = __pTextObject->GetElementAtTextIndex(start);
4099 _Text::TextElement* pEndTextElement = __pTextObject->GetElementAtTextIndex(end-1);
4101 if (pStartTextElement == null || pEndTextElement == null)
4106 const int startIndex = __pTextObject->GetElementIndexOf(*pStartTextElement);
4107 const int endIndex = __pTextObject->GetElementIndexOf(*pEndTextElement);
4109 for (int index = startIndex; index <= endIndex; index++)
4111 _Text::TextElement* pTextElement = __pTextObject->GetElementAtElementIndex(index);
4112 TextElementType objectType = pTextElement->GetType();
4113 if (objectType != TEXT_ELEMENT_TYPE_IMAGE)
4117 TextImage* pImageText = null;
4118 pImageText = dynamic_cast < TextImage* >(pTextElement);
4119 if ( pImageText == null)
4123 const Bitmap * pImage = pImageText->GetBitmap();
4124 SysTryReturnResult(NID_UI_CTRL, pImage != null, E_SYSTEM, "[EDIT] Unable to get the bitmap from textobject.");
4126 _ClipboardItem* pClipboardImageItem = _ClipboardItem::CreateInstanceN(CLIPBOARD_DATA_TYPE_IMAGE, *pImage);
4127 SysTryReturnResult(NID_UI_CTRL, pClipboardImageItem != null, E_SYSTEM, "[EDIT] Unable to get the clipboardImageitem instance.");
4129 r = pClipBoard->CopyItem(*pClipboardImageItem);
4131 delete pClipboardImageItem;
4138 _EditPresenter::CutText(void)
4140 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
4143 result r = E_SUCCESS;
4146 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4150 GetBlockRange(start, end);
4151 DeleteText(start, end);
4154 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
4160 _EditPresenter::PasteText(void)
4162 result r = E_SUCCESS;
4163 int currentLength = GetTextLength();
4164 String* pSubString = null;
4169 String filteredString;
4171 _Clipboard* pClipBoard = _Clipboard::GetInstance();
4172 SysTryReturnResult(NID_UI_CTRL, pClipBoard != null, E_SYSTEM, "[EDIT] Unable to get the clipboard instance.");
4174 const _ClipboardItem* pClipboardItem = pClipBoard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT);
4175 SysTryReturnResult(NID_UI_CTRL, pClipboardItem != null, E_SYSTEM, "[EDIT] Unable to get the clipboarditem instance.");
4177 const String* pClipString = dynamic_cast<const String*>(pClipboardItem->GetData());
4178 SysTryCatch(NID_UI_CTRL, pClipString, r = E_SYSTEM, E_SYSTEM, "[EDIT] Unable to get the clipboarditem instance.");
4180 filteredString = *pClipString;
4184 if(__pTextFilter->ValidatePastedText(*pClipString, userString))
4186 filteredString = userString;
4187 SysLog(NID_UI_CTRL, "ClipString was changed by User");
4190 else if (IsUnsupportedChracterExist(GetKeypadStyle(), *pClipString) == true)
4197 GetBlockRange(start, end);
4198 total = currentLength - (end - start) + filteredString.GetLength();
4199 if (total > __limitLength)
4201 DeleteText(start, end);
4203 pSubString = new String(__limitLength - currentLength + (end - start));
4204 SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "[EDIT] Unable to allocate text buffer.");
4206 filteredString.SubString(0, __limitLength - currentLength + (end - start), *pSubString);
4207 r = InsertTextAt(__cursorPos, pSubString->GetPointer());
4208 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4213 DeleteText(start, end);
4215 r = InsertTextAt(__cursorPos, filteredString.GetPointer());
4216 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4219 else if (currentLength + filteredString.GetLength() > __limitLength)
4221 if (__limitLength == currentLength)
4223 delete pClipboardItem;
4227 pSubString = new String(__limitLength - currentLength);
4228 SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "[EDIT] Unable to allocate text buffer.");
4230 filteredString.SubString(0, __limitLength - currentLength, *pSubString);
4231 r = InsertTextAt(__cursorPos, pSubString->GetPointer());
4232 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4237 r = InsertTextAt(__cursorPos, filteredString.GetPointer());
4238 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4241 delete pClipboardItem;
4243 ReplaceTextIntoPasswordHyphenString();
4245 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
4250 delete pClipboardItem;
4256 _EditPresenter::RemoveTextBlock(void)
4258 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
4262 if (!__isTextBlocked)
4264 return E_OBJ_NOT_FOUND;
4270 GetBlockRange(start, end);
4273 return E_OBJ_NOT_FOUND;
4276 result r = DeleteText(start, end);
4277 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4279 __isTextBlocked = false;
4281 InitializeCopyPasteManager();
4287 _EditPresenter::IsClipped(void) const
4289 _Clipboard* pClipBoard = _Clipboard::GetInstance();
4290 SysTryReturn(NID_UI_CTRL, pClipBoard != null, false, E_SYSTEM, "[EDIT] Unable to get the clipboard instance.");
4292 const _ClipboardItem* pClipboardItem = pClipBoard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT);
4293 if (pClipboardItem == null)
4295 SetLastResult(E_SUCCESS);
4298 delete pClipboardItem;
4304 _EditPresenter::SetTextAlignment(HorizontalAlignment alignment)
4306 result r = E_SUCCESS;
4308 int textAlign = TEXT_OBJECT_ALIGNMENT_LEFT;
4310 if (alignment == ALIGNMENT_CENTER)
4312 textAlign = TEXT_OBJECT_ALIGNMENT_CENTER;
4314 else if (alignment == ALIGNMENT_RIGHT)
4316 textAlign = TEXT_OBJECT_ALIGNMENT_RIGHT;
4319 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
4321 r = __pTextObject->SetAlignment(textAlign | TEXT_OBJECT_ALIGNMENT_MIDDLE);
4325 r = __pTextObject->SetAlignment(textAlign | TEXT_OBJECT_ALIGNMENT_TOP);
4327 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[EDIT] Unable to set text alignment.");
4328 __horizontalAlignment = alignment;
4334 _EditPresenter::SetLineSpacing(int linePixelGap)
4336 result r = E_SUCCESS;
4338 __pTextObject->SetLineSpace(linePixelGap);
4344 _EditPresenter::SetLineSpacing(float linePixelGap)
4346 result r = E_SUCCESS;
4348 __pTextObject->SetLineSpace(linePixelGap);
4354 _EditPresenter::GetText(int start, int end) const
4357 SysTryReturn(NID_UI_CTRL, (start <= end), tempString, E_SYSTEM, "[E_SYSTEM] The invalid argument(start = %d, end = %d) is given.", start, end);
4359 int textLength = GetTextLength();
4360 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);
4362 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
4364 int length = end - start + 1;
4365 __pTextString->SubString(start, length, tempString);
4370 String resultString;
4371 String elementString;
4372 const int textElementCount = __pTextObject->GetElementCount();
4373 _Text::TextElement* pTextElement = __pTextObject->GetElementAtTextIndex(start);
4375 if (pTextElement == null)
4377 return resultString;
4379 const int startIndex = __pTextObject->GetElementIndexOf(*pTextElement);
4381 for (int index = startIndex; index < textElementCount; index++)
4383 _Text::TextElement* pTextElement = __pTextObject->GetElementAtElementIndex(index);
4384 TextSimple* pSimpleText = null;
4385 if (pTextElement == null)
4390 TextElementType objectType = pTextElement->GetType();
4391 if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK)
4393 pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
4394 if ( pSimpleText == null)
4405 int elementOffset = static_cast < int >(pTextElement->GetValue(SET_TEXT_OFFSET));
4406 int elementLength = pTextElement->GetTextLength();
4408 if (objectType == TEXT_ELEMENT_TYPE_CUTLINK)
4410 elementOffset = GetLinkElementOffsetInTextBuffer(index);
4411 if (elementOffset < 0)
4417 if (end < elementOffset)
4421 if (start >= elementOffset + elementLength)
4426 if (elementLength == 0)
4430 elementString.Clear();
4431 elementString.Append(pSimpleText->GetText());
4432 elementString.SetLength(elementLength);
4433 if (end < elementOffset + elementLength - 1)
4435 int removingStartIndex = end + 1;
4436 elementString.Remove(removingStartIndex - elementOffset, elementOffset + elementLength - removingStartIndex);
4438 if (start > elementOffset)
4440 elementString.Remove(0, start - elementOffset);
4442 resultString.Append(elementString);
4445 return resultString;
4449 _EditPresenter::GetText(void) const
4451 return GetText(0, GetTextLength()-1);
4455 _EditPresenter::SetText(const String& text)
4457 result r = E_SUCCESS;
4459 InitializeCopyPasteManager();
4461 int length = text.GetLength();
4462 if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)
4464 if (__limitLength <= length)
4466 String tempString = GetText();
4467 SetTextLimitLength(length * 2);
4472 SysTryReturnResult(NID_UI_CTRL, length <= __limitLength, E_INVALID_ARG, "[EDIT] The Invalid argument is given.");
4475 if (__isInputConnectionBound && __isTextComposing)
4477 __pInputConnection->FinishTextComposition();
4478 __isTextComposing = false;
4479 __composingTextLength = 0;
4482 __pTextString->Clear();
4483 __pTextString->Append(text);
4485 wchar_t* tempString = const_cast<wchar_t*>(text.GetPointer());
4486 for (int i = 0; i < length; i++)
4488 __pTextBuffer[i] = tempString[i];
4490 __pTextBuffer[length] = 0;
4492 __pTextObject->RemoveAll();
4493 TextSimple* pSimpleText = new (std::nothrow)TextSimple(__pTextBuffer, length,TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, __pFont);
4494 __pTextObject->AppendElement(*pSimpleText);
4495 __pTextObject->Compose();
4497 ReplaceTextIntoPasswordHyphenString();
4499 SetCursorPosition(length);
4501 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
4503 AdjustFlexibleHeight();
4506 if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)
4508 __isCutLinkParserEnabled = true;
4511 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
4517 _EditPresenter::GetRemainingLength(void) const
4519 return __limitLength - __pTextObject->GetTextLength();
4523 _EditPresenter::SetCursorPosition(int position)
4525 result r = E_SUCCESS;
4526 int length = GetTextLength();
4528 SysTryReturnResult(NID_UI_CTRL, -1 < position && position <= length, E_INVALID_ARG, "[Edit] Invalid argument is given.");
4530 if (__isTouchMoving == false)
4532 __isCursorChanged = true;
4535 r = __pTextObject->SetCursorIndex(position);
4536 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[Edit] Failed to set cursor position");
4538 __cursorPos = position;
4544 _EditPresenter::GetCursorPosition(void) const
4550 _EditPresenter::GetTextLength(void) const
4552 return __pTextObject->GetTextLength();
4556 _EditPresenter::InsertTextAt(int index, const String& text)
4558 result r = E_SUCCESS;
4560 int currentLength = GetTextLength();
4561 int length = text.GetLength();
4562 int totalLength = currentLength + length;
4563 String insertText = text;
4566 SysTryReturnResult(NID_UI_CTRL, index >= 0 && index <= currentLength, E_OUT_OF_RANGE, "[EDIT] The Invalid argument is given.");
4568 if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)
4570 if (__limitLength <= totalLength)
4572 String tempString = GetText();
4573 SetTextLimitLength(totalLength * 2);
4574 SetText(tempString);
4579 SysTryReturnResult(NID_UI_CTRL, totalLength <= __limitLength, E_MAX_EXCEEDED, "[EDIT] The Invalid argument is given.");
4582 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE || __pEdit->GetEditStyle() & EDIT_STYLE_TOKEN )
4584 while (insertText.Contains(String(L"\n")))
4586 for (i = 0; i < length; i++)
4589 insertText.GetCharAt(i, ch);
4592 insertText.Remove(i, 1);
4593 length = insertText.GetLength();
4606 r = __pTextString->Insert(insertText, index);
4607 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4609 wchar_t* pTempString = const_cast<wchar_t*>(insertText.GetPointer());
4610 wchar_t pOriginalString[currentLength - index];
4612 for (int i = 0; i < currentLength - index; i++)
4614 pOriginalString[i] = __pTextBuffer[index + i];
4616 pOriginalString[currentLength - index] = 0;
4618 for (int i = 0; i < length; i++)
4620 __pTextBuffer[i + index] = pTempString[i];
4623 for (int i = 0; i < currentLength - index; i++)
4625 __pTextBuffer[i + index + length] = pOriginalString[i];
4627 __pTextBuffer[totalLength] = 0;
4629 __pTextObject->SetRange(index, length);
4630 r = __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), length);
4631 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[Edit] Failed to set length");
4633 __pTextObject->Compose();
4635 if (__isTextBlocked == true)
4637 DeleteText(__blockStartPos, __cursorPos);
4640 SetCursorPosition(__cursorPos + length);
4644 SetCursorPosition(index + length);
4647 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
4649 AdjustFlexibleHeight();
4652 __isCursorChanged = true;
4654 if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)
4656 __isCutLinkParserEnabled = true;
4659 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
4665 _EditPresenter::AppendText(const String& text)
4667 result r = E_SUCCESS;
4669 int currentLength = GetTextLength();
4670 int length = text.GetLength();
4671 int totalLength = currentLength + length;
4673 if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)
4675 if (__limitLength <= totalLength)
4677 String tempString = GetText();
4678 SetTextLimitLength(totalLength * 2);
4679 SetText(tempString);
4684 SysTryReturnResult(NID_UI_CTRL, totalLength <= __limitLength, E_MAX_EXCEEDED, "[EDIT] The Invalid argument is given.");
4687 r = __pTextString->Append(text);
4688 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4690 wchar_t* pTempString = const_cast<wchar_t*>(text.GetPointer());
4692 for (int i = 0; i < length; i++)
4694 __pTextBuffer[i + currentLength] = pTempString[i];
4696 __pTextBuffer[totalLength] = 0;
4698 __pTextObject->SetRange(currentLength, length);
4699 r = __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), length);
4700 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[Edit] Failed to set length");
4702 __pTextObject->Compose();
4704 if (!__isTextBlocked)
4706 SetCursorPosition(totalLength);
4709 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
4711 AdjustFlexibleHeight();
4714 if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)
4716 __isCutLinkParserEnabled = true;
4719 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
4725 _EditPresenter::AppendCharacter(const Character& character)
4727 result r = E_SUCCESS;
4729 r = AppendText(character.ToString());
4735 _EditPresenter::ClearText(void)
4737 InitializeCopyPasteManager();
4739 result r = E_SUCCESS;
4741 if (__isInputConnectionBound && __isTextComposing)
4743 __pInputConnection->FinishTextComposition();
4744 __isTextComposing = false;
4745 __composingTextLength = 0;
4748 int textLength = GetTextLength();
4750 if (textLength == 0)
4755 r = DeleteText(0, textLength);
4756 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4758 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_CLEAR_ICON);
4764 _EditPresenter::DeleteCharacterAt(int index)
4766 result r = E_SUCCESS;
4769 length = GetTextLength();
4771 SysTryReturnResult(NID_UI_CTRL, index >= 0, E_INVALID_ARG, "Specified index is negative.");
4772 SysTryReturnResult(NID_UI_CTRL, index < length, E_OUT_OF_RANGE, "Specified index is outside the range.");
4774 r = DeleteText(index, index+1);
4779 _EditPresenter::DeleteText(int start, int end)
4781 result r = E_SUCCESS;
4783 int length = GetTextLength();
4785 SysTryReturnResult(NID_UI_CTRL, -1 < start && start < end, E_INVALID_ARG, "[EDIT] Invalid argument is given.");
4786 SysTryReturnResult(NID_UI_CTRL, start < end && end <= length, E_INVALID_ARG, "[EDIT] Invalid argument is given.");
4788 _Text::TextElement* pFirstTextElement = __pTextObject->GetElementAtTextIndex(start);
4789 const TextSimple* pFirstSimpleText = dynamic_cast <const TextSimple*>(pFirstTextElement);
4790 if (pFirstSimpleText != null && pFirstSimpleText->GetBitmap() != null)
4792 if (pFirstSimpleText->GetTextOffset() < start)
4794 start = pFirstSimpleText->GetTextOffset();
4797 _Text::TextElement* pLastTextElement = __pTextObject->GetElementAtTextIndex(end - 1);
4798 const TextSimple* pLastSimpleText = dynamic_cast <const TextSimple*>(pLastTextElement);
4799 if (pLastSimpleText != null && pLastSimpleText->GetBitmap() != null)
4801 if( (pLastSimpleText->GetTextOffset() + pLastSimpleText->GetTextLength()) > end)
4803 end = pLastSimpleText->GetTextOffset() + pLastSimpleText->GetTextLength();
4807 r = __pTextString->Remove(start, end - start);
4808 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4810 int currentLength = __pTextString->GetLength();
4812 for (int i = start; i < length; i++)
4814 __pTextBuffer[i] = __pTextBuffer[i + (length - currentLength)];
4817 for (int i = currentLength; i < length; i++)
4819 __pTextBuffer[i] = 0;
4822 SetCursorPosition(start);
4824 __pTextObject->SetRange(start, end - start);
4825 r = __pTextObject->NotifyTextChanged(__pTextBuffer, 0, currentLength, -(end - start));
4826 r = __pTextObject->Compose();
4828 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
4830 AdjustFlexibleHeight();
4833 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
4839 _EditPresenter::GetCurrentTextRange(int& start, int& end) const
4841 int currentLength = __pTextString->GetLength();
4843 start = __cursorPos;
4846 if (__pTextBuffer[--start] == TEXT_OBJ_CHARACTER)
4854 while (end < currentLength && __pTextBuffer[end] != TEXT_OBJ_CHARACTER)
4863 _EditPresenter::GetTextLimitLength(void) const
4865 return __limitLength;
4869 _EditPresenter::SetTextLimitLength(int limitLength)
4871 result r = E_SUCCESS;
4873 SysTryReturnResult(NID_UI_CTRL, (limitLength > 0), E_INVALID_ARG, "The invalid limit length is given.");
4875 String tempString = GetText();
4877 int textLength = tempString.GetLength();
4878 SysTryReturnResult(NID_UI_CTRL, (limitLength >= textLength), E_INVALID_ARG, "The invalid argument is given.");
4880 TextSimple* pSimpleText = null;
4882 if (limitLength == GetTextLimitLength())
4887 wchar_t* pTempBuffer = new (std::nothrow) wchar_t[limitLength + 1];
4888 SysTryReturnResult(NID_UI_CTRL, pTempBuffer, E_OUT_OF_MEMORY, "Unable to allocate buffer.");
4890 for (int i = 0; i < textLength; i++)
4892 pTempBuffer[i] = __pTextBuffer[i];
4895 for (int i = textLength; i < limitLength; i++)
4900 pTempBuffer[limitLength] = '\0';
4902 __pTextString->Clear();
4903 __pTextString->Append(tempString);
4906 delete[] __pTextBuffer;
4907 __pTextBuffer = null;
4909 __pTextBuffer = pTempBuffer;
4911 __pTextObject->RemoveAll();
4912 pSimpleText = new (std::nothrow)TextSimple(__pTextBuffer, textLength, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, __pFont);
4913 SysTryReturnResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "Insufficient memory.");
4915 r = __pTextObject->AppendElement(*pSimpleText);
4916 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4918 SetCursorPosition(textLength);
4920 __limitLength = limitLength;
4931 _EditPresenter::InsertCharacterAt(int index, const Character& character)
4933 result r = E_SUCCESS;
4935 r = InsertTextAt(index, character.ToString());
4941 _EditPresenter::SetModel(const _EditModel& editModel)
4945 delete __pEditModel;
4946 __pEditModel = null;
4949 __pEditModel = const_cast<_EditModel*>(&editModel);
4955 _EditPresenter::SetAutoLinkMask(unsigned long autoLinks)
4957 __isCutLinkParserEnabled = true;
4958 return __pEditModel->SetAutoLinkMask(autoLinks);
4962 _EditPresenter::GetAutoLinkMask(void) const
4964 return __pEditModel->GetAutoLinkMask();
4968 _EditPresenter::IsViewModeEnabled(void) const
4970 return __pEditModel->IsViewModeEnabled();
4974 _EditPresenter::SetViewModeEnabled(bool enable)
4976 if (!enable && __pEditModel->IsViewModeEnabled() && IsInternalFocused())
4978 __pEdit->SetFocused(false);
4981 int editStyle = __pEdit->GetEditStyle();
4985 editStyle = editStyle | EDIT_STYLE_VIEWER;
4989 editStyle = editStyle & (~EDIT_STYLE_VIEWER);
4991 __pEdit->SetEditStyle(editStyle);
4995 __pEdit->SetCursorPosition(0);
4997 if (__pInputConnection && __isInputConnectionBound)
5003 __isCursorDisabled = enable;
5004 __pTextObject->SetCutLinkViewMode(enable);
5006 if (__pInputConnection)
5008 __pInputConnection->SetKeyEventSkipped(enable);
5012 return __pEditModel->SetViewModeEnabled(enable);
5016 _EditPresenter::SetKeypadActionEnabled(bool enable)
5019 result r = E_SUCCESS;
5021 r = __pInputConnection->SetInputPanelActionEnabled(enable);
5024 __pEditModel->SetKeypadActionEnabled(enable);
5030 _EditPresenter::IsKeypadActionEnabled(void)
5033 bool enableIc = true;
5035 enable = __pEditModel->IsKeypadActionEnabled();
5036 enableIc = __pInputConnection->IsInputPanelActionEnabled();
5042 _EditPresenter::GetKeypadAction(void) const
5044 return __pEditModel->GetKeypadAction();
5048 _EditPresenter::ConvertKeypadAction(CoreKeypadAction keypadAction)
5050 InputPanelAction inputPanelAction = INPUT_PANEL_ACTION_ENTER;
5052 switch (keypadAction)
5054 case CORE_KEYPAD_ACTION_ENTER:
5055 inputPanelAction = INPUT_PANEL_ACTION_ENTER;
5057 case CORE_KEYPAD_ACTION_GO:
5058 inputPanelAction = INPUT_PANEL_ACTION_GO;
5060 case CORE_KEYPAD_ACTION_NEXT:
5061 inputPanelAction = INPUT_PANEL_ACTION_NEXT;
5063 case CORE_KEYPAD_ACTION_SEND:
5064 inputPanelAction = INPUT_PANEL_ACTION_SEND;
5066 case CORE_KEYPAD_ACTION_SEARCH:
5067 inputPanelAction = INPUT_PANEL_ACTION_SEARCH;
5069 case CORE_KEYPAD_ACTION_LOGIN:
5070 inputPanelAction = INPUT_PANEL_ACTION_LOGIN;
5072 case CORE_KEYPAD_ACTION_SIGN_IN:
5073 inputPanelAction = INPUT_PANEL_ACTION_SIGN_IN;
5075 case CORE_KEYPAD_ACTION_JOIN:
5076 inputPanelAction = INPUT_PANEL_ACTION_JOIN;
5078 case CORE_KEYPAD_ACTION_DONE:
5079 inputPanelAction = INPUT_PANEL_ACTION_DONE;
5085 return inputPanelAction;
5090 _EditPresenter::SetKeypadAction(CoreKeypadAction keypadAction)
5092 return __pEditModel->SetKeypadAction(keypadAction);
5096 _EditPresenter::SetKeypadEnabled(bool enable)
5098 if (!enable && IsKeypadEnabled())
5100 CheckUSBKeyboardStatus();
5102 if (!__isUSBKeyboardConnected && __isInputConnectionBound)
5108 __pEditModel->SetKeypadEnabled(enable);
5110 if (__pInputConnection)
5112 __pInputConnection->SetKeyEventSkipped(!enable);
5119 _EditPresenter::IsKeypadEnabled(void)
5123 if (__pEdit->IsEnabled())
5125 enable = __pEditModel->IsKeypadEnabled();
5136 _EditPresenter::SetCurrentLanguage(LanguageCode languageCode)
5138 result r = E_SUCCESS;
5140 if (__pInputConnection && __isInputConnectionBound)
5142 r = __pInputConnection->SetInputPanelLanguage(languageCode);
5143 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5144 r = __pEditModel->SetInitialKeypadLanguage(LANGUAGE_INVALID);
5145 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5149 r = __pEditModel->SetInitialKeypadLanguage(languageCode);
5150 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5153 r = __pEditModel->SetCurrentLanguage(languageCode);
5159 _EditPresenter::GetCurrentLanguage(LanguageCode& language) const
5161 result r = E_SUCCESS;
5162 if (__pInputConnection && __isInputConnectionBound)
5164 language = __pInputConnection->GetInputPanelLanguage();
5165 r = __pEditModel->SetCurrentLanguage(language);
5166 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5169 return __pEditModel->GetCurrentLanguage(language);
5173 _EditPresenter::SetLowerCaseModeEnabled(bool enable)
5175 __pEditModel->SetLowerCaseModeEnabled(enable);
5181 _EditPresenter::IsLowerCaseModeEnabled(void) const
5183 return __pEditModel->IsLowerCaseModeEnabled();
5187 _EditPresenter::GetKeypadStyle(void) const
5189 return __pEditModel->GetKeypadStyle();
5193 _EditPresenter::SetKeypadStyle(KeypadStyle keypadStyle)
5196 bool textPredictionEnabled = __pEditModel->IsTextPredictionEnabled();
5198 InputPanelStyle inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
5200 switch (keypadStyle)
5202 case KEYPAD_STYLE_NORMAL:
5203 if (__isKeypadNormalNumberStyleEnabled)
5205 inputPanelStyle = INPUT_PANEL_STYLE_NUMBER;
5209 inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
5212 case KEYPAD_STYLE_PASSWORD:
5213 inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
5215 case KEYPAD_STYLE_EMAIL:
5216 inputPanelStyle = INPUT_PANEL_STYLE_EMAIL;
5218 case KEYPAD_STYLE_URL:
5219 inputPanelStyle = INPUT_PANEL_STYLE_URL;
5221 case KEYPAD_STYLE_NUMBER:
5222 inputPanelStyle = INPUT_PANEL_STYLE_NUMBER_ONLY;
5223 textPredictionEnabled = false;
5225 case KEYPAD_STYLE_PHONE_NUMBER:
5226 inputPanelStyle = INPUT_PANEL_STYLE_PHONE_NUMBER;
5227 textPredictionEnabled = false;
5229 case KEYPAD_STYLE_IP_V4:
5230 inputPanelStyle = INPUT_PANEL_STYLE_IP;
5231 textPredictionEnabled = false;
5237 if (__pInputConnection && __isInputConnectionBound)
5239 __pInputConnection->SetTextPredictionEnabled(textPredictionEnabled);
5240 __pInputConnection->SetInputPanelStyle(inputPanelStyle);
5243 __pEditModel->SetTextPredictionEnabled(textPredictionEnabled);
5245 return __pEditModel->SetKeypadStyle(keypadStyle);
5249 _EditPresenter::SetKeypadNormalNumberStyle(bool enable)
5251 __isKeypadNormalNumberStyleEnabled = enable;
5252 return SetKeypadStyle(__pEditModel->GetKeypadStyle());
5256 _EditPresenter::IsTextPredictionEnabled(void) const
5258 return __pEditModel->IsTextPredictionEnabled();
5262 _EditPresenter::SetTextPredictionEnabled(bool enable)
5264 KeypadStyle keypadStyle = __pEditModel->GetKeypadStyle();
5266 if (keypadStyle == KEYPAD_STYLE_NUMBER ||keypadStyle == KEYPAD_STYLE_PHONE_NUMBER ||
5267 keypadStyle == KEYPAD_STYLE_IP_V4)
5268 return E_UNSUPPORTED_OPERATION;
5270 if (__pInputConnection && __isInputConnectionBound)
5272 __pInputConnection->SetTextPredictionEnabled(enable);
5275 return __pEditModel->SetTextPredictionEnabled(enable);
5279 _EditPresenter::InsertTextAtCursorPosition(const String& text)
5281 return InsertTextAt(__cursorPos, text);
5285 _EditPresenter::InsertTextAt(int position, const String& text, const Bitmap& textImage)
5287 result r = E_SUCCESS;
5289 int currentLength = GetTextLength();
5290 int length = text.GetLength();
5291 int totalLength = currentLength + length;
5293 SysTryReturnResult(NID_UI_CTRL, position >= 0 && position <= currentLength, E_OUT_OF_RANGE, "[EDIT] The given position is out-of-range.");
5295 if ((__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) || (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER))
5297 if (__limitLength <= totalLength)
5299 String backupString = GetText();
5300 SetTextLimitLength(totalLength * 2);
5301 SetText(backupString);
5306 SysTryReturnResult(NID_UI_CTRL, totalLength <= __limitLength, E_MAX_EXCEEDED, "[EDIT] The text exceeds the limitation length.");
5309 if (__isInputConnectionBound == true && __isTextComposing == true)
5311 __pInputConnection->FinishTextComposition();
5312 __isTextComposing = false;
5313 __composingTextLength = 0;
5316 r = __pTextString->Insert(text, position);
5317 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5319 wchar_t* pInsertString = const_cast<wchar_t*>(text.GetPointer());
5321 if (currentLength > position)
5323 wchar_t pOriginalString[currentLength - position];
5325 for (int i = 0; i < currentLength - position; i++)
5327 pOriginalString[i] = __pTextBuffer[position + i];
5329 pOriginalString[currentLength - position] = 0;
5331 for (int i = 0; i < length; i++)
5333 __pTextBuffer[i + position] = pInsertString[i];
5336 for (int i = 0; i < currentLength - position; i++)
5338 __pTextBuffer[i + position + length] = pOriginalString[i];
5343 for (int i = 0; i < length; i++)
5345 __pTextBuffer[i + position] = pInsertString[i];
5349 __pTextBuffer[totalLength] = 0;
5351 TextSimple* pSimpleText = null;
5352 pSimpleText = new (std::nothrow) TextSimple(__pTextBuffer, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, GetFont());
5353 SysTryReturnResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "[Edit] Unable to allocate text simple element.");
5355 pSimpleText->ChangeTextOffset(__pTextBuffer, position);
5356 pSimpleText->SetBitmap((Bitmap&)textImage);
5357 __pTextObject->InsertElementAt(position, *pSimpleText);
5358 __pTextObject->ChangeTextOffset(__pTextBuffer, position+pSimpleText->GetTextLength(), pSimpleText->GetTextLength());
5359 __pTextObject->Compose();
5361 if (__isTextBlocked == true)
5363 DeleteText(__blockStartPos, __cursorPos);
5366 SetCursorPosition(__cursorPos + length);
5370 SetCursorPosition(position + length);
5373 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
5375 AdjustFlexibleHeight();
5378 __isCursorChanged = true;
5379 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
5384 _EditPresenter::DeleteCharacterAtCursorPosition(void)
5386 return DeleteCharacterAt(__cursorPos);
5390 _EditPresenter::IsFocused(void) const
5392 return __pEdit->IsFocused();
5396 _EditPresenter::IsInternalFocused(void) const
5398 return __pEdit->IsInternalFocused();
5402 _EditPresenter::GetTextVisualElement(void)
5404 return __pTextVisualElement;
5408 _EditPresenter::SetControlInitialBounds(FloatRectangle initBounds)
5410 __initialBounds = initBounds;
5414 _EditPresenter::IsUpdateInitialBounds(void)
5416 return __updateInitialBounds;
5420 _EditPresenter::OnFocusGained(void)
5424 __pParentForm = GetParentForm();
5427 if (__isAutoShrinkEnabled)
5429 float flexibleHeight = CalculateFlexibleHeightF();
5430 FloatRectangle initialRect = GetInitialBoundsF();
5431 initialRect.height = flexibleHeight;
5433 SetFlexBounds(initialRect);
5436 if (!__pTextVisualElement)
5438 result r = E_SUCCESS;
5439 __pTextVisualElement = new (std::nothrow) _VisualElement;
5440 SysTryReturn(NID_UI_CTRL, __pTextVisualElement != null, false, E_OUT_OF_MEMORY, "[EDIT] Unable to create __pTextVisualElement instance.");
5442 r = __pTextVisualElement->Construct();
5443 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r));
5445 __pTextVisualElement->SetSurfaceOpaque(false);
5446 __pTextVisualElement->SetImplicitAnimationEnabled(false);
5448 __pTextVisualElement->SetShowState(true);
5450 _VisualElement* pEditVisualElement = __pEdit->GetVisualElement();
5451 SysTryCatch(NID_UI_CTRL, pEditVisualElement, , r = E_SYSTEM, "[E_SYSTEM] Unable to get root visual element.");
5453 pEditVisualElement->AttachChild(*__pTextVisualElement);
5454 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r));
5457 if (__pEdit->GetEnableState() == false)
5462 __isCursorOpaque = true;
5464 if (__isInputConnectionBound == false && __isInitialized)
5466 if (IsViewModeEnabled() == false)
5468 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
5474 ShowFullscreenKeypad();
5478 __pEdit->Invalidate();
5483 __pTextVisualElement->Destroy();
5484 __pTextVisualElement = null;
5490 _EditPresenter::OnNotifiedN(IList* pArgs)
5492 String showKeypad(L"ShowKeypad");
5493 String* pType = dynamic_cast <String*>(pArgs->GetAt(0));
5497 if (*pType == showKeypad)
5499 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
5505 ShowFullscreenKeypad();
5508 pArgs->RemoveAll(true);
5518 _EditPresenter::OnFrameActivated(const _Frame& source)
5520 if (IsInternalFocused() == true && __isInputConnectionBound == false && __isInitialized)
5522 if (IsViewModeEnabled() == false)
5524 CheckUSBKeyboardStatus();
5526 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
5537 _EditPresenter::OnFrameDeactivated(const _Frame& source)
5543 _EditPresenter::OnFrameMinimized(const _Frame& source)
5548 _EditPresenter::OnFrameRestored(const _Frame& source)
5553 _EditPresenter::OnFocusLost(void)
5555 if (!__pEdit->IsDestroyed())
5557 InitializeCopyPasteManager();
5560 if (__isAutoShrinkEnabled)
5562 FloatRectangle intialWindowBounds = GetInitialBoundsF();
5563 SetFlexBounds(intialWindowBounds);
5566 if (__pTextVisualElement)
5568 __pTextVisualElement->Destroy();
5569 __pTextVisualElement = null;
5572 if (__pEdit == null)
5577 ReplaceTextIntoPasswordHyphenString();
5579 if (__isClipboardExist)
5583 __pClipboard->HidePopup();
5587 if (__isInputConnectionBound)
5590 if (__pScrollBar && !(__pEdit->GetEditStyle() & EDIT_STYLE_NOSCROLL))
5592 __pScrollBar->SetScrollVisibility(false);
5595 __isCursorOpaque = false;
5596 __isTouchMoving = false;
5597 __isTouchReleaseSkipped = false;
5602 __pEdit->Invalidate();
5608 _EditPresenter::GetCurrentStatus(void) const
5610 EditStatus editState = EDIT_STATUS_NORMAL;
5612 if (__pEdit->IsEnabled())
5614 if (IsInternalFocused())
5616 editState = EDIT_STATUS_HIGHLIGHTED;
5618 else if (__isTouchPressed)
5620 editState = EDIT_STATUS_PRESSED;
5625 editState = EDIT_STATUS_DISABLED;
5632 _EditPresenter::GetCursorVisualElement(void) const
5634 return __pCursorVisualElement;
5638 _EditPresenter::SetMaxLineCount(int maxLineCount)
5640 __pEditModel->SetMaxLineCount(maxLineCount);
5646 _EditPresenter::GetMaxLineCount(void) const
5648 return __pEditModel->GetMaxLineCount();
5652 _EditPresenter::UpdateComponentInformation(void)
5654 result r = E_SUCCESS;
5656 if (__isCursorChanged == false)
5661 bool IsTextAlignmentChanged = AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT);
5662 bool setFirstDisplayLine = true;
5663 if (!((__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) || (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)))
5665 float firstDisplayY = __pTextObject->GetFirstDisplayPositionYF();
5666 float totalHeight = __pTextObject->GetTotalHeightF();
5667 FloatRectangle displayBounds = __pTextObject->GetBoundsF();
5668 if (totalHeight >= displayBounds.height)
5670 float textGapFromBottom = displayBounds.height - (totalHeight - firstDisplayY);
5671 if (textGapFromBottom > 0)
5673 ScrollText(-textGapFromBottom);
5677 FloatRectangle absCursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
5678 CalculateAbsoluteCursorBounds(__cursorPos, absCursorBounds);
5679 setFirstDisplayLine = (IsContained(absCursorBounds) == false);
5682 if (setFirstDisplayLine || IsTextAlignmentChanged)
5684 if (__pTextObject->IsChanged())
5686 __pTextObject->Compose();
5688 __pTextObject->SetFirstDisplayLineIndexFromTextIndex(__cursorPos);
5691 __pTextObject->SetCursorIndex(__cursorPos);
5693 __isCursorChanged = false;
5700 _EditPresenter::UpdateComponentInformation(void)
5702 result r = E_SUCCESS;
5704 if (__isCursorChanged == false)
5709 bool setFirstDisplayLine = true;
5710 if (!((__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) || (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)))
5712 int firstDisplayY = __pTextObject->GetFirstDisplayPositionY();
5713 int totalHeight = __pTextObject->GetTotalHeight();
5714 Rectangle displayBounds = __pTextObject->GetBounds();
5715 if (totalHeight >= displayBounds.height)
5717 int textGapFromBottom = displayBounds.height - (totalHeight - firstDisplayY);
5718 if (textGapFromBottom > 0)
5720 ScrollText(_CoordinateSystemUtils::ConvertToFloat(-textGapFromBottom));
5724 Rectangle absCursorBounds(0, 0, 0, 0);
5725 CalculateAbsoluteCursorBounds(__cursorPos, absCursorBounds);
5726 FloatRectangle floatAbsCursorBounds = _CoordinateSystemUtils::ConvertToFloat(absCursorBounds);
5727 setFirstDisplayLine = (IsContained(floatAbsCursorBounds) == false);
5730 if (setFirstDisplayLine)
5732 if (__pTextObject->IsChanged())
5734 __pTextObject->Compose();
5736 __pTextObject->SetFirstDisplayLineIndexFromTextIndex(__cursorPos);
5739 __pTextObject->SetCursorIndex(__cursorPos);
5741 __isCursorChanged = false;
5748 _EditPresenter::ScrollText(float distance)
5750 float newFirstDisplayY = __pTextObject->GetFirstDisplayPositionYF();
5751 newFirstDisplayY += distance;
5753 int moveLine = __pTextObject->GetLineIndexAtPositionY(newFirstDisplayY);
5755 __pTextObject->SetFirstDisplayLineIndex(moveLine);
5756 __pTextObject->SetFirstDisplayPositionY(newFirstDisplayY);
5762 _EditPresenter::IsContained(FloatRectangle& paramRect) const
5764 FloatRectangle absBounds = __pEdit->GetAbsoluteBoundsF();
5766 if ((paramRect.x < absBounds.x) ||
5767 (paramRect.y < absBounds.y) ||
5768 ((paramRect.x + paramRect.width) > (absBounds.x + absBounds.width)) ||
5769 ((paramRect.y + paramRect.height) > (absBounds.y + absBounds.height)))
5778 _EditPresenter::CalculateAbsoluteCursorBounds(int index, Rectangle& absCursorBounds)
5782 int cursorWidth = 0;
5783 int cursorHeight = 0;
5784 int cursorRelativeX = 0;
5785 int cursorRelativeY = 0;
5787 Rectangle absBounds = __pEdit->GetAbsoluteBounds();
5789 __pTextObject->SetBounds(GetTextBounds());
5790 if (__pTextObject->GetTextPositionInfoAt(index, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
5795 absCursorBounds.x = absBounds.x + cursorRelativeX;
5797 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
5799 Rectangle tempBounds;
5800 GetCursorBounds(true, tempBounds);
5801 absCursorBounds.y = tempBounds.y;
5805 absCursorBounds.y = absBounds.y + cursorRelativeY;
5808 absCursorBounds.width = cursorWidth;
5810 if (cursorHeight > 0)
5812 absCursorBounds.height = cursorHeight;
5816 absCursorBounds.height = __pTextObject->GetLineHeightAt(0);
5823 _EditPresenter::GetCursorBounds(bool isAbsRect, Rectangle& cursorBounds)
5825 if (__isInitialized == false)
5830 CalculateCursorBounds(GetTextBounds(), cursorBounds);
5834 Rectangle absBounds = __pEdit->GetAbsoluteBounds();
5835 cursorBounds.x += absBounds.x;
5836 cursorBounds.y += absBounds.y;
5843 _EditPresenter::CalculateAbsoluteCursorBounds(int index, FloatRectangle& absCursorBounds)
5845 float cursorAbsX = 0.0f;
5846 float cursorAbsY = 0.0f;
5847 float cursorWidth = 0.0f;
5848 float cursorHeight = 0.0f;
5849 float cursorRelativeX = 0.0f;
5850 float cursorRelativeY = 0.0f;
5852 FloatRectangle absBounds = __pEdit->GetAbsoluteBoundsF();
5854 __pTextObject->SetBounds(GetTextBoundsF());
5855 if (__pTextObject->GetTextPositionInfoAt(index, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
5860 absCursorBounds.x = absBounds.x + cursorRelativeX;
5862 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
5864 FloatRectangle tempBounds;
5865 GetCursorBounds(true, tempBounds);
5866 absCursorBounds.y = tempBounds.y;
5870 absCursorBounds.y = absBounds.y + cursorRelativeY;
5873 absCursorBounds.width = cursorWidth;
5875 if (cursorHeight > 0.0f)
5877 absCursorBounds.height = cursorHeight;
5881 absCursorBounds.height = __pTextObject->GetLineHeightAtF(0);
5888 _EditPresenter::GetCursorBounds(bool isAbsRect, FloatRectangle& cursorBounds)
5890 if (__isInitialized == false)
5895 CalculateCursorBounds(GetTextBoundsF(), cursorBounds);
5899 FloatRectangle absBounds = __pEdit->GetAbsoluteBoundsF();
5900 cursorBounds.x += absBounds.x;
5901 cursorBounds.y += absBounds.y;
5909 _EditPresenter::SetCursorDisabled(bool disabled)
5911 __isCursorDisabled = disabled;
5917 _EditPresenter::IsGuideTextActivated(void) const
5919 if (__pGuideTextObject == null)
5924 if (GetGuideText().IsEmpty())
5929 if (__pTextObject && GetTextLength() > 0)
5938 _EditPresenter::CreateCommandButtonItemN(int actionId, const String& text)
5940 result r = E_SUCCESS;
5941 _Button* pButton = _Button::CreateButtonN();
5942 SysTryReturn(NID_UI_CTRL, pButton, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance.");
5944 float textSize = 0.0f;
5946 r = pButton->SetActionId(actionId);
5947 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5949 r = pButton->SetText(text);
5950 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5952 r = GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_FONT_SIZE, __pEdit->GetOrientation(), textSize);
5955 r = pButton->SetTextSize(textSize);
5956 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5968 _EditPresenter::SetKeypadCommandButton(const FloatRectangle& bounds)
5970 // This function must be changed after _ toolbar completes their float conversion works
5971 result r = E_SUCCESS;
5972 Bitmap* pNormalBackgroundBitmap = null;
5973 Bitmap* pReplacementColorBackgroundBitmap = null;
5974 String leftButtonText;
5975 String rightButtonText;
5976 _Control* pParent = null;
5977 Color commandBackgroundColor;
5979 if (__pCommandButton)
5981 __pCommandButton->SetResizable(true);
5982 __pCommandButton->SetMovable(true);
5983 SysLog(NID_UI_CTRL, "[EDIT]Command position changed!!!! bounds(%f, %f, %f, %f)", bounds.x, bounds.y, bounds.width, bounds.height);
5984 r = __pCommandButton->SetBounds(bounds);
5986 __pCommandButton->SetResizable(false);
5987 __pCommandButton->SetMovable(false);
5992 if (__pParentForm == false)
5997 __pCommandButton = _Toolbar::CreateToolbarN(false);
5998 SysTryReturn(NID_UI_CTRL, __pCommandButton, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance.");
6000 r = __pCommandButton->Construct();
6001 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6003 GET_BITMAP_CONFIG_N(FOOTER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundBitmap);
6004 if (pNormalBackgroundBitmap)
6006 GET_COLOR_CONFIG(FOOTER::BG_NORMAL, commandBackgroundColor);
6007 pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), commandBackgroundColor);
6009 if (pReplacementColorBackgroundBitmap)
6011 r = __pCommandButton->SetBackgroundBitmap(*pReplacementColorBackgroundBitmap);
6012 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6014 delete pReplacementColorBackgroundBitmap;
6015 pReplacementColorBackgroundBitmap = null;
6017 delete pNormalBackgroundBitmap;
6018 pNormalBackgroundBitmap = null;
6021 r = __pCommandButton->SetStyle(TOOLBAR_COMMAND);
6022 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6024 __pCommandButton->SetResizable(true);
6025 __pCommandButton->SetMovable(true);
6026 SysLog(NID_UI_CTRL, "[EDIT]Command created!!!! bounds(%f, %f, %f, %f)", bounds.x, bounds.y, bounds.width, bounds.height);
6027 r = __pCommandButton->SetBounds(bounds);
6028 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6030 __pCommandButton->SetResizable(false);
6031 __pCommandButton->SetMovable(false);
6033 leftButtonText = __pEditModel->GetKeypadCommandButtonText(COMMAND_BUTTON_POSITION_LEFT);
6034 r = __pCommandButton->AddItem(CreateCommandButtonItemN(__pEditModel->GetKeypadCommandButtonActionId(COMMAND_BUTTON_POSITION_LEFT), leftButtonText));
6035 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6037 rightButtonText = __pEditModel->GetKeypadCommandButtonText(COMMAND_BUTTON_POSITION_RIGHT);
6038 r = __pCommandButton->AddItem(CreateCommandButtonItemN(__pEditModel->GetKeypadCommandButtonActionId(COMMAND_BUTTON_POSITION_RIGHT), rightButtonText));
6039 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6041 if (__pActionEventListener)
6043 __pCommandButton->AddActionEventListener(*__pActionEventListener);
6048 r = __pParentForm->AttachChild(*__pCommandButton);
6049 __pParentForm->MoveChildToTop(*__pCommandButton);
6053 pParent = __pEdit->GetParent();
6054 SysTryCatch(NID_UI_CTRL, pParent, r = E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
6055 r = pParent->AttachChild(*__pCommandButton);
6057 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6062 delete pNormalBackgroundBitmap;
6064 delete __pCommandButton;
6065 __pCommandButton = null;
6067 delete pReplacementColorBackgroundBitmap;
6073 _EditPresenter::CheckInitialFooterVisibleState(void)
6075 if (__pParentForm == null)
6080 _Toolbar* pFooter = __pParentForm->GetFooter();
6083 if (pFooter->GetVisibleState() == false)
6085 __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_HIDE;
6086 SysLog(NID_UI_CTRL, "[EDIT] CheckInitialFooterVisibleState - EDIT_FOOTER_VISIBLE_STATUS_HIDE");
6090 __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_SHOW;
6091 SysLog(NID_UI_CTRL, "[EDIT] CheckInitialFooterVisibleState - EDIT_FOOTER_VISIBLE_STATUS_SHOW");
6096 __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
6097 SysLog(NID_UI_CTRL, "[EDIT] CheckInitialFooterVisibleState - EDIT_FOOTER_VISIBLE_STATUS_NONE");
6104 _EditPresenter::SetFooterVisible(bool isVisible)
6106 if (__pParentForm == null)
6111 _Toolbar* pFooter = __pParentForm->GetFooter();
6112 if (pFooter && __initialFooterVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_SHOW)
6114 if ((isVisible == true && pFooter->GetVisibleState() == false) ||
6115 (isVisible == false && pFooter->GetVisibleState() == true))
6119 SysLog(NID_UI_CTRL, "[EDIT] SetFooterVisible TRUE!!!!!");
6123 SysLog(NID_UI_CTRL, "[EDIT] SetFooterVisible FALSE!!!!!");
6126 pFooter->SetVisibleState(isVisible);
6127 pFooter->Invalidate();
6131 __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
6140 _EditPresenter::ShowFullscreenKeypad(void)
6142 result r = E_SUCCESS;
6144 if (IsKeypadEnabled() == false)
6146 __pEdit->SetFocused();
6150 if (__pFullscreenKeypad)
6152 __pFullscreenKeypad->Close();
6153 delete __pFullscreenKeypad;
6154 __pFullscreenKeypad = null;
6157 int editStyle = __pEdit->GetEditStyle();
6159 _KeypadStyleInfo keypadStyleInfo;
6160 keypadStyleInfo.keypadStyle = __pEditModel->GetKeypadStyle();
6161 keypadStyleInfo.textPredictionEnabled = __pEditModel->IsTextPredictionEnabled();
6162 keypadStyleInfo.isNormalNumberStyle = __isKeypadNormalNumberStyleEnabled;
6163 keypadStyleInfo.enterActionEnabled = true;
6164 keypadStyleInfo.isLowerCaseModeEnabled = __pEditModel->IsLowerCaseModeEnabled();
6166 if (editStyle & EDIT_STYLE_SINGLE_LINE)
6168 keypadStyleInfo.enterActionEnabled = false;
6171 if (editStyle & EDIT_STYLE_PASSWORD)
6173 editStyle = EDIT_STYLE_NORMAL | EDIT_STYLE_SINGLE_LINE | EDIT_STYLE_PASSWORD;
6177 editStyle = EDIT_STYLE_NORMAL;
6180 __pFullscreenKeypad = _Keypad::CreateKeypadN();
6181 SysTryReturn(NID_UI_CTRL, __pFullscreenKeypad, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance.");
6182 r = __pFullscreenKeypad->Initialize(editStyle, keypadStyleInfo, GetTextLimitLength(), __pEdit);
6183 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
6185 __pFullscreenKeypad->SetText(GetText());
6187 r = __pFullscreenKeypad->Open();
6188 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
6190 if (__pEdit->IsInputEventEnabled())
6192 __pEdit->LockInputEvent();
6197 __pFullscreenKeypad->SetEditTextFilter(this);
6203 _EditPresenter::DeleteFullscreenKeypad(void)
6205 if (__pFullscreenKeypad)
6207 delete __pFullscreenKeypad;
6208 __pFullscreenKeypad = null;
6215 _EditPresenter::GetKeypadBounds(Rectangle& bounds) const
6217 if (__pInputConnection == null)
6222 bounds = __pInputConnection->GetInputPanelBounds();
6224 _CoordinateSystem* pCoordSystem = _CoordinateSystem::GetInstance();
6225 SysTryReturnResult(NID_UI_CTRL, pCoordSystem, E_SYSTEM, "[EDIT] Coordinate system load failed.");
6227 _ICoordinateSystemTransformer* pXformer = pCoordSystem->GetInverseTransformer();
6228 SysTryReturnResult(NID_UI_CTRL, pXformer, E_SYSTEM, "[EDIT] Coordinate system load failed.");
6230 bounds = pXformer->Transform(bounds);
6236 _EditPresenter::GetKeypadBounds(FloatRectangle& bounds) const
6238 if (__pInputConnection == null)
6243 bounds = __pInputConnection->GetInputPanelBoundsF();
6245 _CoordinateSystem* pCoordSystem = _CoordinateSystem::GetInstance();
6246 SysTryReturnResult(NID_UI_CTRL, pCoordSystem, E_SYSTEM, "[EDIT] Coordinate system load failed.");
6248 _ICoordinateSystemTransformer* pXformer = pCoordSystem->GetInverseTransformer();
6249 SysTryReturnResult(NID_UI_CTRL, pXformer, E_SYSTEM, "[EDIT] Coordinate system load failed.");
6251 bounds = pXformer->Transform(bounds);
6257 _EditPresenter::GetClipboardHeight(void) const
6259 return __clipboardHeight;
6263 _EditPresenter::CheckKeypadExist(_ControlOrientation orientation)
6265 FloatDimension screenSize;
6266 FloatRectangle absKeypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
6267 _ControlManager* pControlManager = _ControlManager::GetInstance();
6269 GetKeypadBounds(absKeypadBounds);
6271 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
6273 screenSize.height = pControlManager->GetScreenSizeF().height;
6274 screenSize.width = pControlManager->GetScreenSizeF().width;
6278 screenSize.height = pControlManager->GetScreenSizeF().width;
6279 screenSize.width = pControlManager->GetScreenSizeF().height;
6282 if ((absKeypadBounds.y != screenSize.height) && (absKeypadBounds.width == screenSize.width))
6284 SysLog(NID_UI_CTRL, "[EDIT] CheckKeypadExist: KEYPAD EXIST!!!!Keypad(y: %f, h: %f)", absKeypadBounds.y, absKeypadBounds.height);
6289 SysLog(NID_UI_CTRL, "[EDIT] CheckKeypadExist: NO KEYPAD!!!!Keypad(y: %f, h: %f)", absKeypadBounds.y, absKeypadBounds.height);
6295 _EditPresenter::ShowKeypad(bool focus)
6297 if (IsKeypadEnabled() == false)
6304 __pEdit->SetFocused();
6308 if (!__isInitialized)
6314 _ControlManager* pControlManager = _ControlManager::GetInstance();
6316 if (!pControlManager->IsFrameActivated())
6321 CheckUSBKeyboardStatus();
6323 __pInputConnection->BindInputMethod();
6324 __isInputConnectionBound = true;
6325 __isKeypadShowing = true;
6326 __isKeypadHiding = false;
6328 SetKeypadStyle(__pEditModel->GetKeypadStyle());
6330 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE && GetKeypadAction() == CORE_KEYPAD_ACTION_ENTER)
6332 __pInputConnection->SetInputPanelActionEnabled(false);
6336 __pInputConnection->SetInputPanelAction(ConvertKeypadAction(GetKeypadAction()));
6339 //Need to complete AutoCapitalization functionality
6340 if (__pEditModel->IsLowerCaseModeEnabled())
6342 __pInputConnection->SetAutoCapitalizationMode(AUTO_CAPITALIZATION_MODE_NONE);
6346 __pInputConnection->SetAutoCapitalizationMode(AUTO_CAPITALIZATION_MODE_SENTENCE);
6349 LanguageCode initialKeypadLanguage = LANGUAGE_INVALID;
6350 __pEditModel->GetInitialKeypadLanguage(initialKeypadLanguage);
6351 if (initialKeypadLanguage != LANGUAGE_INVALID)
6353 SetCurrentLanguage(initialKeypadLanguage);
6356 if (__isUSBKeyboardConnected)
6358 SysLog(NID_UI_CTRL, "[EDIT]ShowKeypad called in USB ON mode!!!!");
6359 if (__initialFooterVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_NONE)
6361 CheckInitialFooterVisibleState();
6364 if (__isKeypadCommandButtonVisible)
6366 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
6367 __pEdit->AttachScrollPanelEvent();
6368 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
6370 SetFooterVisible(false);
6371 ChangeLayoutInternal(__pEdit->GetOrientation());
6372 AdjustParentPanelHeight(false);
6374 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
6375 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
6378 ScrollPanelToCursorPosition();
6382 SysLog(NID_UI_CTRL, "[EDIT]ShowKeypad called in USB OFF mode!!!!");
6384 __isKeypadExist = CheckKeypadExist(__pEdit->GetOrientation()); //call once only from here.
6386 if (!__isKeypadExist)
6388 if (__isKeypadCommandButtonVisible)
6390 if (!__pCommandButton || (__pCommandButton && !__pCommandButton->GetVisibleState()))
6392 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
6393 __pEdit->AttachScrollPanelEvent();
6394 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
6395 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
6396 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
6401 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
6402 __pEdit->AttachScrollPanelEvent();
6403 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
6406 if (__initialFooterVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_NONE)
6408 CheckInitialFooterVisibleState();
6412 if (__isKeypadCommandButtonVisible)
6414 SetFooterVisible(false);
6417 if (__isKeypadExist)
6419 ChangeLayoutInternal(__pEdit->GetOrientation());
6420 //ChangeLayoutInternal(__pEdit->GetOrientation(), false);
6421 ScrollPanelToCursorPosition();
6424 __pParentForm->SetKeypadShowState(true);//First show keypad after dispose
6425 __pParentForm->Draw();
6430 __initialParentHeight = 0.0f;
6431 ScrollPanelToCursorPosition();
6434 __pInputConnection->ShowInputPanel();
6441 _EditPresenter::ChangeLayout(_ControlOrientation orientation)
6443 result r = E_SUCCESS;
6445 if (__pCopyPasteManager)
6447 __pCopyPasteManager->Release();
6452 CheckUSBKeyboardStatus();
6454 if (__isInputConnectionBound || __clipboardConnected)
6456 SysLog(NID_UI_CTRL, "[EDIT]-------------------ChangeLayout------------------------");
6460 SysLog(NID_UI_CTRL, "[EDIT] Form deflate RESET!!!!!!!!!!");
6461 __pParentForm->DeflateClientRectHeight(0.0f);
6464 if (__pCommandButton && __isKeypadCommandButtonVisible)
6466 __pCommandButton->SetVisibleState(false);
6469 if (__isKeypadExist && ! __clipboardConnected) //only keypad exists, already get keypadbounds before callback
6471 __initialParentHeight = 0.0f;
6472 ChangeLayoutInternal(orientation);
6473 AdjustParentPanelHeight(false);
6474 ScrollPanelToCursorPosition();
6476 else // if clipboard exists, boundsChanged callback will delivered after rotate callback
6478 __initialParentHeight = 0.0f;
6480 if (__isKeypadCommandButtonVisible)
6482 ChangeLayoutInternal(orientation);
6483 AdjustParentPanelHeight(false);
6484 ScrollPanelToCursorPosition();
6489 if ((__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) == false)
6491 __initialBounds = __pEdit->GetBoundsF();
6494 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to change layout.", GetErrorMessage(r));
6500 _EditPresenter::ChangeLayoutInternal(_ControlOrientation orientation, bool deflateForm)
6502 result r = E_SUCCESS;
6504 FloatRectangle keypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
6506 _ControlManager* pControlManager = _ControlManager::GetInstance();
6507 SysTryReturnResult(NID_UI_CTRL, pControlManager, E_SYSTEM, "[EDIT] Failed to get root.");
6508 FloatDimension screenSize;
6509 FloatRectangle commandButtonBounds(0.0f, 0.0f, 0.0f, 0.0f);
6511 float formDeflateHeight = 0.0f;
6512 float shrinkedHeight = 0.0f;
6514 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
6516 screenSize.width = pControlManager->GetScreenSizeF().width;
6517 screenSize.height = pControlManager->GetScreenSizeF().height;
6521 screenSize.width = pControlManager->GetScreenSizeF().height;
6522 screenSize.height = pControlManager->GetScreenSizeF().width;
6525 if (__isInputConnectionBound || __clipboardConnected)
6527 GetKeypadBounds(keypadBounds);
6529 if (__isKeypadExist)
6531 if (__isClipboardExist)
6533 if (__clipboardHeight > keypadBounds.height)
6535 shrinkedHeight = __clipboardHeight;
6539 shrinkedHeight = keypadBounds.height;
6544 shrinkedHeight = keypadBounds.height;
6549 if (__isClipboardExist)
6551 shrinkedHeight = __clipboardHeight;
6555 if (__isKeypadCommandButtonVisible)
6557 if (__isClipboardExist)
6561 formDeflateHeight += shrinkedHeight;
6566 commandButtonBounds.width = screenSize.width;
6567 float commandButtonHeight = 0.0f;
6568 GET_SHAPE_CONFIG(FOOTER::HEIGHT, orientation, commandButtonHeight);
6569 commandButtonBounds.height = commandButtonHeight;
6573 formDeflateHeight += commandButtonBounds.height;
6575 if (__isKeypadExist)
6577 formDeflateHeight += shrinkedHeight;
6578 commandButtonBounds.y = screenSize.height - shrinkedHeight - commandButtonBounds.height - __pParentForm->GetClientBoundsF().y;
6582 commandButtonBounds.y = screenSize.height - commandButtonBounds.height - __pParentForm->GetClientBoundsF().y;
6587 if (__isKeypadExist)
6589 commandButtonBounds.y = screenSize.height - shrinkedHeight - commandButtonBounds.height;
6593 commandButtonBounds.y = screenSize.height - commandButtonBounds.height;
6597 r = SetKeypadCommandButton(commandButtonBounds);
6598 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
6600 if (__pCommandButton)
6602 __pCommandButton->SetVisibleState(true);
6603 __pCommandButton->Invalidate();
6611 if (__isKeypadExist || __isClipboardExist)
6613 formDeflateHeight += shrinkedHeight;
6619 if (__pParentForm && deflateForm)
6621 SysLog(NID_UI_CTRL, "[EDIT]ChangeLayoutInternal: formDeflateHeight:%f, KeypadExist(%d), ClipboardExist(%d), CommandButtonVisible(%d)",
6622 formDeflateHeight, __isKeypadExist, __isClipboardExist, __isKeypadCommandButtonVisible);
6623 __pParentForm->DeflateClientRectHeight(formDeflateHeight);
6630 _EditPresenter::OnScrollPanelBoundsChanged(void)
6636 _EditPresenter::AdjustParentPanelHeight(bool restore, bool panelResizeByPrediction)
6638 if (__pParentPanel == null)
6643 _ControlOrientation orientation;
6644 float commandButtonHeight = 0.0f;
6646 FloatRectangle absKeypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
6648 _Toolbar* pFooter = null;
6652 pFooter = __pParentForm->GetFooter();
6655 FloatRectangle absScrollPanelBounds(0.0f, 0.0f, 0.0f, 0.0f);
6656 FloatRectangle scrollPanelBounds = __pParentPanel->GetBoundsF();
6659 _ControlManager* pControlManager = _ControlManager::GetInstance();
6660 float displayedPanelHeight = 0.0f;
6661 FloatDimension screenSize;
6663 if (__pEdit->GetOrientation()== _CONTROL_ORIENTATION_PORTRAIT)
6665 screenSize.width = pControlManager->GetScreenSizeF().width;
6666 screenSize.height = pControlManager->GetScreenSizeF().height;
6670 screenSize.width = pControlManager->GetScreenSizeF().height;
6671 screenSize.height = pControlManager->GetScreenSizeF().width;
6674 if (panelResizeByPrediction)
6679 if (__initialParentHeight)
6681 scrollPanelBounds.height = __initialParentHeight;
6683 __initialParentHeight = 0.0f;
6684 __pParentPanel->SetBounds(scrollPanelBounds);
6685 __pParentPanel->Invalidate();
6690 if (__isKeypadExist)
6692 GetKeypadBounds(absKeypadBounds);
6694 if (__isClipboardExist)
6696 if (__clipboardHeight > absKeypadBounds.height)
6698 absKeypadBounds.y = screenSize.height - __clipboardHeight;
6703 if (__isUSBKeyboardConnected)//predictive window shown
6705 absKeypadBounds.y = screenSize.height - absKeypadBounds.height;//only absKeypadBounds.height is meaningful in USB on.
6711 if (__isClipboardExist)
6713 absKeypadBounds.y = screenSize.height - __clipboardHeight;
6717 absKeypadBounds.y = screenSize.height;
6721 if ((__pParentForm && __isKeypadCommandButtonVisible) || (pFooter && (pFooter->GetVisibleState() == true)))
6723 orientation = __pEdit->GetOrientation();
6724 GET_SHAPE_CONFIG(FOOTER::HEIGHT, orientation, commandButtonHeight);
6727 absScrollPanelBounds = __pParentPanel->GetAbsoluteBoundsF();
6728 displayedPanelHeight = screenSize.height - commandButtonHeight - absScrollPanelBounds.y;
6729 gapY = (absKeypadBounds.y - commandButtonHeight)- absScrollPanelBounds.y;
6731 if (panelResizeByPrediction)
6733 if (__isUSBKeyboardConnected)
6737 scrollPanelBounds.height = gapY;
6738 __pParentPanel->SetBounds(scrollPanelBounds);
6739 __pParentPanel->Invalidate();
6744 if ((gapY > 0.0f) && __initialParentHeight)
6746 scrollPanelBounds.height = gapY;
6747 __pParentPanel->SetBounds(scrollPanelBounds);
6748 __pParentPanel->Invalidate();
6754 if ((absKeypadBounds.y - commandButtonHeight) >= (absScrollPanelBounds.y + absScrollPanelBounds.height))
6759 if ((gapY > 0) && (gapY < displayedPanelHeight) && !__initialParentHeight)
6761 __initialParentHeight = scrollPanelBounds.height;
6763 scrollPanelBounds.height = gapY;
6764 __pParentPanel->SetBounds(scrollPanelBounds);
6765 __pParentPanel->Invalidate();
6774 _EditPresenter::HideKeypad(bool focus)
6776 InitializeCopyPasteManager();
6778 __isKeypadShowing = false;
6780 if (__isInitialized == false || !__isInputConnectionBound)
6785 CheckUSBKeyboardStatus();
6787 if (__isUSBKeyboardConnected)
6789 SysLog(NID_UI_CTRL, "[EDIT]HideKeypad called in USB ON mode!!!!");
6790 SetFooterVisible(true);
6791 if (__pCommandButton && __isKeypadCommandButtonVisible)
6793 __pCommandButton->SetVisibleState(false);
6797 SysLog(NID_UI_CTRL, "[EDIT] Form deflate RESET!!!!!!!!!!");
6798 __pParentForm->DeflateClientRectHeight(0.0f);
6801 AdjustParentPanelHeight(true);
6803 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
6808 SysLog(NID_UI_CTRL, "[EDIT]HideKeypad called in USB OFF mode!!!!");
6809 if (__pCommandButton && __isKeypadCommandButtonVisible)
6811 if (!__isKeypadExist)
6813 SetFooterVisible(true);//must be called ahead of DeflateClientRectHeights
6816 SysLog(NID_UI_CTRL, "[EDIT] Form deflate RESET!!!!!!!!!!");
6817 __pParentForm->DeflateClientRectHeight(0.0f);
6819 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
6821 __pCommandButton->SetVisibleState(false);
6825 __pInputConnection->FinishTextComposition();
6826 __pInputConnection->HideInputPanel();
6827 __pInputConnection->UnbindInputMethod();
6828 __isTextComposing = false;
6829 __composingTextLength = 0;
6831 if (__isKeypadExist && focus)
6833 __isKeypadHiding = true;
6836 __isInputConnectionBound = false;
6838 if (focus && IsInternalFocused())
6840 __pEdit->SetFocused(false);
6847 _EditPresenter::ChangeKeypadStatus(void)
6849 InitializeCopyPasteManager();
6851 if (__isInputConnectionBound)
6853 __isInputConnectionBound = false;
6860 _EditPresenter::OnTimerExpired(Timer& timer)
6862 Timer* onTimer = &timer;
6864 if (onTimer == __pCursorTimer)
6866 OnCursorTimerExpired();
6868 else if (onTimer == __pTitleSlidingTimer)
6870 OnTitleSlidingTimerExpired();
6872 else if (onTimer == __pPasswordTimer)
6874 OnPasswordTimerExpired();
6876 else if (onTimer == __pFlickAnimationTimer)
6878 OnFlickTimerExpired();
6885 _EditPresenter::OnEditCopyPasteStatusChanged(CoreCopyPasteStatus status, CoreCopyPasteAction action)
6889 case CORE_COPY_PASTE_ACTION_COPY:
6890 __pEdit->CopyText();
6892 case CORE_COPY_PASTE_ACTION_CUT:
6895 case CORE_COPY_PASTE_ACTION_PASTE:
6896 __pEdit->PasteText();
6898 case CORE_COPY_PASTE_ACTION_SEARCH:
6899 case CORE_COPY_PASTE_ACTION_CLIPBOARD:
6900 __clipboardConnected = true;
6905 InitializeCopyPasteManager();
6906 __pEdit->Invalidate();
6912 _EditPresenter::InitializeCursor(void)
6916 if (__isCursorDisabled == false && IsInternalFocused() && __isTextBlocked == false)
6918 FloatRectangle cursorBounds;
6919 CalculateCursorBounds(__textObjectBounds, cursorBounds);
6921 __pCursorVisualElement->SetOpacity(1.0f);
6922 __pCursorVisualElement->SetBounds(cursorBounds);
6924 Canvas* pCanvas = __pCursorVisualElement->GetCanvasN();
6925 if (pCanvas == null)
6929 __isCursorInitialized = false;
6930 DrawCursor(*pCanvas, cursorBounds, __isCursorOpaque);
6932 if (__pInputConnection)
6934 FloatRectangle absoluteEditRectangle;
6935 if (GetCursorBounds(false, absoluteEditRectangle) == E_SUCCESS)
6937 __pInputConnection->SetCursorBounds(absoluteEditRectangle);
6940 __isCursorOpaque = __isCursorOpaque ? false : true;
6944 __previousCursorBounds = cursorBounds;
6949 __pCursorVisualElement->SetOpacity(0);
6952 if (__pInputConnection != null && __isInputConnectionBound == true && !__isCopyPasteManagerExist)
6954 __pInputConnection->SetCursorPosition(__cursorPos);
6961 _EditPresenter::StopCursorTimer(void)
6965 __pCursorTimer->Cancel();
6971 _EditPresenter::StartCursorTimer(void)
6973 result r = E_SUCCESS;
6975 if (__pCursorTimer == null)
6977 __pCursorTimer = new (std::nothrow) Timer;
6978 if (__pCursorTimer == null)
6980 return E_OUT_OF_MEMORY;
6983 r = __pCursorTimer->Construct(*this);
6990 r = __pCursorTimer->Start(EDIT_CURSOR_TIMER_PERIOD);
7001 delete __pCursorTimer;
7002 __pCursorTimer = null;
7008 _EditPresenter::DrawCursor(Canvas& canvas, Rectangle& cursorBounds, bool isCursorOpaque)
7010 result r = E_SUCCESS;
7012 if (__isCursorDisabled == false)
7015 GET_COLOR_CONFIG(EDIT::CURSOR_NORMAL, cursorColor);
7017 if (__isCursorInitialized)
7019 cursorBounds.SetPosition(0, 0);
7021 if (canvas.GetBackgroundColor() != cursorColor)
7023 canvas.FillRectangle(cursorColor, cursorBounds);
7028 __pCursorVisualElement->SetOpacity(1.0f);
7032 __pCursorVisualElement->SetOpacity(0);
7037 cursorBounds.SetPosition(0, 0);
7039 canvas.FillRectangle(cursorColor, cursorBounds);
7040 __isCursorInitialized = true;
7046 __pCursorVisualElement->SetOpacity(0);
7053 _EditPresenter::DrawCursor(Canvas& canvas, FloatRectangle& cursorBounds, bool isCursorOpaque)
7055 result r = E_SUCCESS;
7057 if (__isCursorDisabled == false)
7060 GET_COLOR_CONFIG(EDIT::CURSOR_NORMAL, cursorColor);
7062 if (__isCursorInitialized)
7064 cursorBounds.SetPosition(0.0f, 0.0f);
7066 if (canvas.GetBackgroundColor() != cursorColor)
7068 canvas.FillRectangle(cursorColor, cursorBounds);
7073 __pCursorVisualElement->SetOpacity(1.0f);
7077 __pCursorVisualElement->SetOpacity(0);
7082 cursorBounds.SetPosition(0.0f, 0.0f);
7084 canvas.FillRectangle(cursorColor, cursorBounds);
7085 __isCursorInitialized = true;
7091 __pCursorVisualElement->SetOpacity(0);
7098 _EditPresenter::MoveCursor(const FloatRectangle& fromRect, const FloatRectangle& toRect)
7100 if ((__previousCursorBounds.x != fromRect.x) || (__previousCursorBounds.y != fromRect.y) || (__previousCursorBounds.width != fromRect.width) || (__previousCursorBounds.height != fromRect.height))
7105 __pCursorVisualElement->SetOpacity(0);
7107 __pCursorVisualElement->SetBounds(toRect);
7108 Canvas* pCanvas = __pCursorVisualElement->GetCanvasN();
7110 if (pCanvas == null)
7115 if (toRect.y < 0.0f || toRect.y >= __clientBounds.height ||
7116 toRect.x < 0.0f || toRect.x >= __clientBounds.width)
7122 __pCursorVisualElement->SetOpacity(1.0f);
7126 GET_COLOR_CONFIG(EDIT::CURSOR_NORMAL, cursorColor);
7128 pCanvas->FillRectangle(cursorColor, toRect);
7130 __previousCursorBounds = toRect;
7137 _EditPresenter::OnCursorTimerExpired(void)
7139 if (!IsInternalFocused() && __isCursorDisabled)
7145 FloatRectangle cursorBounds;
7147 if (CalculateCursorBounds(__textObjectBounds, cursorBounds) != E_SUCCESS)
7152 if ((__previousCursorBounds.x != cursorBounds.x) || (__previousCursorBounds.y != cursorBounds.y) || (__previousCursorBounds.width != cursorBounds.width) || (__previousCursorBounds.height != cursorBounds.height))
7154 __previousCursorBounds = cursorBounds;
7157 if (__pCursorVisualElement)
7159 __pCursorVisualElement->SetBounds(cursorBounds);
7160 Canvas* pCanvas = __pCursorVisualElement->GetCanvasN();
7161 if (pCanvas == null)
7166 DrawCursor(*pCanvas, cursorBounds, __isCursorOpaque);
7171 __isCursorOpaque = __isCursorOpaque ? false : true;
7178 _EditPresenter::GetEllipsisPosition(void) const
7180 return __pEdit->GetEllipsisPosition();
7184 _EditPresenter::SetEllipsisPosition(EllipsisPosition position)
7186 result r = E_SUCCESS;
7187 TextObjectEllipsisType ellipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_TAIL;
7188 if (position == ELLIPSIS_POSITION_START)
7190 ellipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_HEAD;
7192 else if (position == ELLIPSIS_POSITION_MIDDLE)
7194 ellipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_MIDDLE;
7197 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
7199 r = __pTextObject->SetTextObjectEllipsisType(ellipsisType);
7200 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[EDIT] Unable to Set ellipsis position.");
7206 _EditPresenter::OnFontInfoRequested(unsigned long& style, float& size)
7208 style = __contentFontStyle;
7209 size = __contentFontSize;
7215 _EditPresenter::OnFontChanged(Font* pFont)
7217 if (!__isFontInitialized)
7222 result r = E_SUCCESS;
7224 r = AdjustFont(*pFont, EDIT_FONT_CHANGE_ALL);
7225 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "[EDIT] Unable to set font.");
7227 __titleFontFaceName = pFont->GetFaceName();
7233 _EditPresenter::GetFont(void) const
7239 _EditPresenter::GetTextSize(void) const
7241 return _CoordinateSystemUtils::ConvertToInteger(__contentFontSize);
7245 _EditPresenter::GetTextSizeF(void) const
7247 return __contentFontSize;
7251 _EditPresenter::GetFontStyle(const Font* pBaseFont) const
7253 unsigned long style = FONT_STYLE_MIN;
7255 if (pBaseFont->IsPlain())
7257 style |= FONT_STYLE_PLAIN;
7259 if (pBaseFont->IsItalic())
7261 style |= FONT_STYLE_ITALIC;
7263 if (pBaseFont->IsBold())
7265 style |= FONT_STYLE_BOLD;
7272 _EditPresenter::SetTextSize(const int size)
7274 result r = E_SUCCESS;
7275 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
7276 r = GetLastResult();
7277 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
7279 r = fontImpl->SetSize(size);
7280 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "[EDIT] SetSize is failed.");
7284 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
7285 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
7286 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font.");
7289 if (IsGuideTextActivated())
7291 r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
7292 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font.");
7295 __contentFontSize = _CoordinateSystemUtils::ConvertToFloat(size);
7300 _EditPresenter::SetTextSize(const float size)
7302 result r = E_SUCCESS;
7303 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
7304 r = GetLastResult();
7305 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
7307 r = fontImpl->SetSize(size);
7308 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "[EDIT] SetSize is failed.");
7312 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
7313 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
7314 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font.");
7317 if (IsGuideTextActivated())
7319 r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
7320 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font.");
7323 __contentFontSize = size;
7328 _EditPresenter::SetFont(const Font& font)
7330 result r = E_SUCCESS;
7332 Font* pFont = _FontImpl::CloneN(const_cast <Font&>(font));
7333 SysTryReturnResult(NID_UI_CTRL, pFont, GetLastResult(), "[EDIT] Unable to create font.");
7339 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
7340 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
7341 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "[EDIT] Unable to set font.");
7344 if (IsGuideTextActivated())
7346 r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
7347 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "[EDIT] Unable to set font.");
7354 _EditPresenter::AdjustFont(Font& font, _EditFontChange fontChange)
7356 result r = E_SUCCESS;
7357 Font* pFont = &font;
7359 _FontImpl* fontImpl = _FontImpl::GetInstance(*pFont);
7360 r = GetLastResult();
7361 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
7363 if (fontChange == EDIT_FONT_CHANGE_TITLE || fontChange == EDIT_FONT_CHANGE_ALL)
7365 if (__pTitleTextObject)
7367 r = fontImpl->SetSize(__titleFontSize);
7368 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "[EDIT] SetSize is failed.");
7370 r = __pTitleTextObject->SetFont(pFont, 0, __pTitleTextObject->GetTextLength());
7371 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font.");
7375 if (fontChange == EDIT_FONT_CHANGE_CONTENT || fontChange == EDIT_FONT_CHANGE_ALL)
7377 r = fontImpl->SetSize(__contentFontSize);
7378 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "[EDIT] SetSize is failed.");
7380 unsigned long style = FONT_STYLE_PLAIN;
7382 if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_BOLD)
7384 style |= FONT_STYLE_BOLD;
7386 if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_ITALIC)
7388 style |= FONT_STYLE_ITALIC;
7391 fontImpl->SetStyle(style);
7393 if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_UNDERLINE)
7395 fontImpl->SetUnderline(true);
7397 if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_STRIKEOUT)
7399 fontImpl->SetStrikeOut(true);
7404 r = __pTextObject->SetFont(pFont, 0, __pTextObject->GetTextLength());
7405 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
7406 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font.");
7409 if (__pGuideTextObject)
7411 r = __pGuideTextObject->SetFont(pFont, 0, __pGuideTextObject->GetTextLength());
7412 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font.");
7418 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
7427 _EditPresenter::GetTitleFontFaceName(void)
7429 return __titleFontFaceName;
7433 _EditPresenter::GetFontType(String& typefaceName, unsigned long& styleMask) const
7435 result r = E_SUCCESS;
7439 typefaceName = __pFont->GetFaceName();
7442 styleMask = __contentTextStyle;
7448 _EditPresenter::SetFontType(const String& typefaceName, unsigned long styleMask)
7450 result r = E_SUCCESS;
7453 IList* systemFontList = Font::GetSystemFontListN();
7454 SysTryReturnResult(NID_UI_CTRL, systemFontList, E_SYSTEM, "[EDIT] Unable to get system font list.\n");
7456 int fontListCount = systemFontList->GetCount();
7457 String tempFontFaceName;
7458 bool isFaceNameAvailable = false;
7460 float textSize = __pFont->GetSizeF();
7461 unsigned long fontStyle = FONT_STYLE_PLAIN;
7463 if (styleMask & TEXT_BOX_TEXT_STYLE_ITALIC)
7465 fontStyle |= FONT_STYLE_ITALIC;
7467 if (styleMask & TEXT_BOX_TEXT_STYLE_BOLD)
7469 fontStyle |= FONT_STYLE_BOLD;
7472 for (int i = 0; i < fontListCount; i++)
7474 tempFontFaceName = *static_cast<String*>(systemFontList->GetAt(i));
7476 pFont = new (std::nothrow) Font;
7477 SysTryCatch(NID_UI_CTRL, pFont, , r = E_OUT_OF_MEMORY, "[EDIT] Unable to get text information.\n");
7478 r = pFont->Construct(tempFontFaceName, fontStyle, textSize);
7479 SysTryCatch(NID_UI_CTRL, !IsFailed(r), , r, "[EDIT] Unable to construct Font.\n");
7481 // check font face name.
7482 if (typefaceName.Equals(pFont->GetFaceName(), true))
7484 isFaceNameAvailable = true;
7492 SysTryCatch(NID_UI_CTRL, isFaceNameAvailable, , r = E_INVALID_ARG, "[EDIT] The unsupported font face name is given.\n");
7494 if (styleMask & TEXT_BOX_TEXT_STYLE_UNDERLINE)
7496 pFont->SetUnderline(true);
7498 if (styleMask & TEXT_BOX_TEXT_STYLE_STRIKEOUT)
7500 pFont->SetStrikeOut(true);
7503 __contentFontStyle = fontStyle;
7504 __contentTextStyle = styleMask;
7508 systemFontList->RemoveAll(true);
7509 delete systemFontList;
7510 systemFontList = null;
7514 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
7515 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
7516 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "[EDIT] Unable to set font.");
7527 systemFontList->RemoveAll(true);
7528 delete systemFontList;
7529 systemFontList = null;
7535 _EditPresenter::GetTextStyle(void) const
7537 return __contentTextStyle;
7541 _EditPresenter::SetTextStyle(unsigned long textStyle)
7543 result r = E_SUCCESS;
7545 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
7546 r = GetLastResult();
7547 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
7549 unsigned long style = FONT_STYLE_PLAIN;
7551 if (textStyle & TEXT_BOX_TEXT_STYLE_BOLD)
7553 style |= FONT_STYLE_BOLD;
7555 if (textStyle & TEXT_BOX_TEXT_STYLE_ITALIC)
7557 style |= FONT_STYLE_ITALIC;
7560 fontImpl->SetStyle(style);
7562 if (textStyle & TEXT_BOX_TEXT_STYLE_UNDERLINE)
7564 fontImpl->SetUnderline(true);
7568 fontImpl->SetUnderline(false);
7571 if (textStyle & TEXT_BOX_TEXT_STYLE_STRIKEOUT)
7573 fontImpl->SetStrikeOut(true);
7577 fontImpl->SetStrikeOut(false);
7582 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
7583 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
7584 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font.");
7587 if (IsGuideTextActivated())
7589 r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
7590 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font.");
7593 __contentTextStyle = textStyle;
7599 _EditPresenter::GetGuideText(void) const
7605 _EditPresenter::SetGuideText(const String& guideText)
7607 result r = E_SUCCESS;
7609 int length = guideText.GetLength();
7611 __guideText = String(guideText);
7612 wchar_t* tempString = const_cast<wchar_t*>(__guideText.GetPointer());
7615 if (__pGuideTextObject != null)
7617 delete __pGuideTextObject;
7618 __pGuideTextObject = null;
7621 __pGuideTextObject = new (std::nothrow) TextObject;
7622 if (__pGuideTextObject == null)
7624 return E_OUT_OF_MEMORY;
7626 __pGuideTextObject->Construct();
7627 TextSimple* pSimpleText = new (std::nothrow)TextSimple(tempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
7628 __pGuideTextObject->AppendElement(*pSimpleText);
7630 __pGuideTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
7631 __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
7633 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_GUIDE);
7635 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
7637 __pGuideTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_CHARACTER);
7641 __pGuideTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
7648 _EditPresenter::GetTitleText(void) const
7654 _EditPresenter::SetTitleText(const String& title)
7656 result r = E_SUCCESS;
7658 int length = title.GetLength();
7660 __titleText = String(title);
7661 wchar_t* tempString = const_cast<wchar_t*>(__titleText.GetPointer());
7663 if (__pTitleTextObject != null)
7665 delete __pTitleTextObject;
7666 __pTitleTextObject = null;
7669 __pTitleTextObject = new (std::nothrow) TextObject;
7670 if (__pTitleTextObject == null)
7672 return E_OUT_OF_MEMORY;
7674 __pTitleTextObject->Construct();
7675 TextSimple* pSimpleText = new (std::nothrow)TextSimple(tempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
7676 __pTitleTextObject->AppendElement(*pSimpleText);
7678 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_TITLE);
7679 __pTitleTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
7680 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
7681 __pTitleTextObject->Compose();
7683 float titleFontSize = 0.0f;
7684 GET_SHAPE_CONFIG(EDIT::DEFAULT_TITLE_FONT_SIZE, __pEdit->GetOrientation(), titleFontSize);
7686 __titleFontSize = titleFontSize;
7688 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
7692 r = fontImpl->SetSize(__titleFontSize);
7693 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "[EDIT] SetSize is failed.");
7697 r = GetLastResult();
7698 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
7701 __pTitleTextObject->SetFont(__pFont, 0, __pTitleTextObject->GetTextLength());
7703 r = fontImpl->SetSize(__contentFontSize);
7704 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "[EDIT] SetSize is failed.");
7706 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
7712 _EditPresenter::GetTextLineCount(void) const
7714 if (GetTextLength() == 0)
7719 if (__isInitialized == false)
7721 __pTextObject->SetBounds(__textObjectBounds);
7722 __pTextObject->Compose();
7725 return __pTextObject->GetTotalLineCount();
7729 _EditPresenter::GetTextTotalHeight(void) const
7731 if (GetTextLength() == 0)
7736 if (__isInitialized == false)
7738 __pTextObject->SetBounds(__textObjectBounds);
7739 __pTextObject->Compose();
7742 return __pTextObject->GetTotalHeight();
7746 _EditPresenter::GetTextTotalHeightF(void) const
7748 if (GetTextLength() == 0)
7753 if (__isInitialized == false)
7755 __pTextObject->SetBounds(__textObjectBounds);
7756 __pTextObject->Compose();
7759 return __pTextObject->GetTotalHeightF();
7763 _EditPresenter::Resize(void)
7768 __pTextObject->SetBounds(__textObjectBounds);
7769 __pTextObject->Compose();
7770 __isCursorChanged = true;
7772 __pTextObject->SetFirstDisplayLineIndex(0);
7773 __pTextObject->SetFirstDisplayPositionY(0);
7775 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_NOSCROLL))
7777 if (__pScrollBar == null)
7779 __pScrollBar = _Scroll::CreateScrollN(*__pEdit,
7780 SCROLL_DIRECTION_VERTICAL,
7788 SysTryReturn(NID_UI_CTRL, __pScrollBar != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to create the scroll.");
7789 __pEdit->AttachSystemChild(*__pScrollBar);
7791 __pScrollBar->SetScrollVisibility(false);
7792 __pScrollBar->OnParentBoundsChanged();
7795 __verticalMargin = __pEdit->GetBoundsF().height - __textObjectBounds.height;
7797 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
7799 if (__initialBounds.height > __verticalMargin)
7801 if (__initialBounds.height > __pEdit->GetBoundsF().height)
7803 __prevTotalTextHeight = __initialBounds.height - __verticalMargin;
7807 __prevTotalTextHeight = __pEdit->GetBoundsF().height - __verticalMargin;
7817 _EditPresenter::SetClientBounds(void)
7819 int editStyle = __pEdit->GetEditStyle();
7821 __clientBounds = __pEdit->GetBoundsF();
7822 __clientBounds.x = 0.0f;
7823 __clientBounds.y = 0.0f;
7825 if (!(editStyle & EDIT_STYLE_SINGLE_LINE))
7830 float leftBorder = 0.0f;
7831 float rightBorder = 0.0f;
7832 float topBorder = 0.0f;
7833 float bottomBorder = 0.0f;
7834 float leftMargin = 0.0f;
7835 float rightMargin = 0.0f;
7836 float topMargin = 0.0f;
7837 float bottomMargin = 0.0f;
7838 _ControlOrientation orientation = __pEdit->GetOrientation();
7840 GET_SHAPE_CONFIG(EDIT::FIELD_LEFT_MARGIN, orientation, leftMargin);
7841 GET_SHAPE_CONFIG(EDIT::FIELD_RIGHT_MARGIN, orientation, rightMargin);
7842 GET_SHAPE_CONFIG(EDIT::FIELD_TOP_MARGIN, orientation, topMargin);
7843 GET_SHAPE_CONFIG(EDIT::FIELD_BOTTOM_MARGIN, orientation, bottomMargin);
7845 if (editStyle & EDIT_STYLE_TITLE_LEFT)
7847 float titleWidth = 0.0f;
7848 if (__titleWidth != -1.0f)
7850 titleWidth = __titleWidth;
7854 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_RECT_WIDTH, orientation, titleWidth);
7857 leftBorder = titleWidth;
7858 rightBorder = rightMargin;
7859 topBorder = topMargin;
7860 bottomBorder = bottomMargin;
7862 else if (editStyle & EDIT_STYLE_TITLE_TOP)
7864 float titletHeight = 0.0f;
7865 float titleTextTopMargin = 0.0f;
7866 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_RECT_HEIGHT, orientation, titletHeight);
7867 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_TOP_MARGIN, orientation, titleTextTopMargin);
7869 leftBorder = leftMargin;
7870 rightBorder = rightMargin;
7871 topBorder = titletHeight + titleTextTopMargin;
7872 bottomBorder = bottomMargin;
7875 __clientBounds.x = leftBorder;
7876 __clientBounds.y = topBorder;
7877 __clientBounds.width -= leftBorder + rightBorder;
7878 __clientBounds.height -= topBorder + bottomBorder;
7884 _EditPresenter::SetInitialEditFieldBounds(void)
7886 result r = E_SUCCESS;
7887 int editStyle = __pEdit->GetEditStyle();
7888 float bottomMargin = 0.0f;
7889 float textLeftMargin = 0.0f;
7890 float textRightMargin =0.0f;
7891 float textTopMargin = 0.0f;
7892 float textBottomMargin = 0.0f;
7893 float titleTextLeftMargin = 0.0f;
7894 float titleTextRightMargin =0.0f;
7895 float titleTextTopMargin = 0.0f;
7896 float titleTextBottomMargin = 0.0f;
7897 float clearIconWidth = 0.0f;
7898 _ControlOrientation orientation = __pEdit->GetOrientation();
7900 GET_SHAPE_CONFIG(EDIT::FIELD_BOTTOM_MARGIN, orientation, bottomMargin);
7901 GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_LEFT_MARGIN, orientation, textLeftMargin);
7902 GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_RIGHT_MARGIN, orientation, textRightMargin);
7903 GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_TOP_MARGIN, orientation, textTopMargin);
7904 GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_BOTTOM_MARGIN, orientation, textBottomMargin);
7905 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_LEFT_MARGIN, orientation, titleTextLeftMargin);
7906 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_RIGHT_MARGIN, orientation, titleTextRightMargin);
7907 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_TOP_MARGIN, orientation, titleTextTopMargin);
7908 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_BOTTOM_MARGIN, orientation, titleTextBottomMargin);
7909 GET_SHAPE_CONFIG(EDIT::CLEAR_ICON_WIDTH, orientation, clearIconWidth);
7911 if (!(editStyle & EDIT_STYLE_SINGLE_LINE))
7916 FloatRectangle bounds = __pEdit->GetBoundsF();
7917 if (editStyle & EDIT_STYLE_TITLE_LEFT)
7919 __textObjectBounds.x = __clientBounds.x + textLeftMargin;
7920 __textObjectBounds.y = __clientBounds.y + textTopMargin;
7921 __textObjectBounds.width = __clientBounds.width - textLeftMargin
7923 __textObjectBounds.height = __clientBounds.height - textTopMargin
7926 __titleBounds.x = titleTextLeftMargin;
7927 __titleBounds.y = titleTextTopMargin;
7928 __titleBounds.width = bounds.width - __clientBounds.width - __titleBounds.x;
7929 __titleBounds.height = __clientBounds.height - titleTextTopMargin
7930 - titleTextBottomMargin;
7932 if (editStyle & EDIT_STYLE_CLEAR)
7934 __textObjectBounds.width -= clearIconWidth;
7937 else if (editStyle & EDIT_STYLE_TITLE_TOP)
7939 __textObjectBounds.x = __clientBounds.x + textLeftMargin;
7940 __textObjectBounds.y = __clientBounds.y;
7941 __textObjectBounds.width = __clientBounds.width - textLeftMargin
7943 __textObjectBounds.height = __clientBounds.height - textBottomMargin;
7945 __titleBounds.x = titleTextLeftMargin;
7946 __titleBounds.y = titleTextTopMargin;
7947 __titleBounds.width = bounds.width - __titleBounds.x
7948 - titleTextRightMargin;
7949 __titleBounds.height = bounds.height - __titleBounds.y - __clientBounds.height
7952 if (editStyle & EDIT_STYLE_CLEAR)
7954 __textObjectBounds.width -= clearIconWidth;
7957 else if ((editStyle & EDIT_STYLE_NORMAL) || (editStyle & EDIT_STYLE_CLEAR))
7959 __textObjectBounds = __clientBounds;
7960 float tempLeftMargin = __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
7961 float tempRightMargin = __pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
7963 if (tempLeftMargin != -1.0f)
7965 __textObjectBounds.x = __clientBounds.x + tempLeftMargin;
7966 __textObjectBounds.width = __clientBounds.width - tempLeftMargin;
7970 __textObjectBounds.x = __clientBounds.x + textLeftMargin;
7971 __textObjectBounds.width = __clientBounds.width - textLeftMargin;
7974 if (tempRightMargin != -1.0f)
7976 __textObjectBounds.width -= tempRightMargin;
7980 __textObjectBounds.width -= textRightMargin;
7983 if (editStyle & EDIT_STYLE_CLEAR)
7985 __textObjectBounds.width -= clearIconWidth;
7987 __textObjectBounds.y = __clientBounds.y + textTopMargin;
7988 __textObjectBounds.height = __clientBounds.height - textTopMargin
7993 float tempLeftMargin = __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
7994 float tempRightMargin = __pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
7995 if (tempLeftMargin != -1.0f)
7997 __textObjectBounds.x = __clientBounds.x + tempLeftMargin;
7998 __textObjectBounds.width = __clientBounds.width - tempLeftMargin;
8002 __textObjectBounds.x = __clientBounds.x + textLeftMargin;
8003 __textObjectBounds.width = __clientBounds.width - textLeftMargin;
8006 if (tempRightMargin != -1.0f)
8008 __textObjectBounds.width -= tempRightMargin;
8012 __textObjectBounds.width -= textRightMargin;
8014 __textObjectBounds.y = __clientBounds.y + textTopMargin;
8015 __textObjectBounds.height = __clientBounds.height - textTopMargin
8019 float textObectMinimumWidth = 0.0f;
8020 GET_SHAPE_CONFIG(EDIT::TEXT_OBJECT_MININMUM_WIDTH, orientation, textObectMinimumWidth);
8022 if (__textObjectBounds.width < textObectMinimumWidth)
8024 __textObjectBounds.width = textObectMinimumWidth;
8027 if (__textObjectBounds.height < __contentFontSize)
8029 __textObjectBounds.height = __contentFontSize;
8032 if (editStyle & EDIT_STYLE_TITLE_LEFT)
8035 if (__titleBounds.width < textObectMinimumWidth)
8037 gap = textObectMinimumWidth - __titleBounds.width;
8038 __titleBounds.width = textObectMinimumWidth;
8039 __textObjectBounds.x += gap;
8041 if (__titleBounds.height < __titleFontSize)
8043 __titleBounds.height = __titleFontSize;
8051 _EditPresenter::SetInitialBounds(void)
8053 result r = E_SUCCESS;
8054 FloatRectangle bounds = __pEdit->GetBoundsF();
8055 int editStyle = __pEdit->GetEditStyle();
8057 if (editStyle & EDIT_STYLE_SINGLE_LINE)
8059 r = SetInitialEditFieldBounds();
8060 __textBoxBounds.x = 0.0f;
8061 __textBoxBounds.y = 0.0f;
8062 __textBoxBounds.width = bounds.width;
8063 __textBoxBounds.height = bounds.height;
8068 float leftMargin = 0.0f;
8069 float rightMargin = 0.0f;
8070 float topMargin = 0.0f;
8071 float bottomMargin = 0.0f;
8072 float textLeftMargin = 0.0f;
8073 float textRightMargin =0.0f;
8074 float textTopMargin = 0.0f;
8075 float textBottomMargin = 0.0f;
8076 float titleRectWidth = 0.0f;
8077 float titleRectHeight = 0.0f;
8078 float titleTextLeftMargin = 0.0f;
8079 float titleTextRightMargin = 0.0f;
8080 float titleTextTopMargin = 0.0f;
8081 float titleTextBottomMargin = 0.0f;
8082 float scrollWidth = 0.0f;
8083 _ControlOrientation orientation = __pEdit->GetOrientation();
8085 GET_SHAPE_CONFIG(EDIT::AREA_LEFT_MARGIN, orientation, leftMargin);
8086 GET_SHAPE_CONFIG(EDIT::AREA_RIGHT_MARGIN, orientation, rightMargin);
8087 GET_SHAPE_CONFIG(EDIT::AREA_TOP_MARGIN, orientation, topMargin);
8088 GET_SHAPE_CONFIG(EDIT::AREA_BOTTOM_MARGIN, orientation, bottomMargin);
8089 GET_SHAPE_CONFIG(EDIT::AREA_TEXT_LEFT_MARGIN, orientation, textLeftMargin);
8090 GET_SHAPE_CONFIG(EDIT::AREA_TEXT_RIGHT_MARGIN, orientation, textRightMargin);
8091 GET_SHAPE_CONFIG(EDIT::AREA_TEXT_TOP_MARGIN, orientation, textTopMargin);
8092 GET_SHAPE_CONFIG(EDIT::AREA_TEXT_BOTTOM_MARGIN, orientation, textBottomMargin);
8093 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_RECT_WIDTH, orientation, titleRectWidth);
8094 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_RECT_HEIGHT, orientation, titleRectHeight);
8095 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_LEFT_MARGIN, orientation, titleTextLeftMargin);
8096 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_RIGHT_MARGIN, orientation, titleTextRightMargin);
8097 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_TOP_MARGIN, orientation, titleTextTopMargin);
8098 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_BOTTOM_MARGIN, orientation, titleTextBottomMargin);
8099 GET_SHAPE_CONFIG(EDIT::AREA_SCROLL_WIDTH, orientation, scrollWidth);
8101 if (editStyle & EDIT_STYLE_TITLE_TOP)
8103 __textBoxBounds.x = leftMargin;
8104 __textBoxBounds.y = titleRectHeight + titleTextTopMargin;
8105 __textBoxBounds.width = bounds.width - leftMargin - rightMargin;
8106 __textBoxBounds.height = bounds.height - titleRectHeight - titleTextTopMargin - bottomMargin;
8108 else if (editStyle & EDIT_STYLE_TITLE_LEFT)
8110 float titleWidth = 0.0f;
8112 if (__titleWidth != -1.0f)
8114 titleWidth = __titleWidth;
8118 titleWidth = titleRectWidth;
8120 __textBoxBounds.x = titleWidth;
8121 __textBoxBounds.y = topMargin;
8122 __textBoxBounds.width = bounds.width - titleWidth - leftMargin;
8123 __textBoxBounds.height = bounds.height - topMargin - bottomMargin;
8127 __textBoxBounds.x = 0.0f;
8128 __textBoxBounds.y = 0.0f;
8129 __textBoxBounds.width = bounds.width;
8130 __textBoxBounds.height = bounds.height;
8133 // setting textBounds
8134 if (editStyle & EDIT_STYLE_TITLE_TOP)
8136 if (__pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN) != -1.0f)
8138 __textObjectBounds.x = __textBoxBounds.x + __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
8139 __textObjectBounds.width = __textBoxBounds.width - __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
8143 __textObjectBounds.x = __textBoxBounds.x + textLeftMargin;
8144 __textObjectBounds.width = __textBoxBounds.width - textLeftMargin;
8147 if (__pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN) != -1.0f)
8149 __textObjectBounds.width -= __pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
8153 __textObjectBounds.width -= textRightMargin;
8157 __textObjectBounds.y = __textBoxBounds.y;
8158 __textObjectBounds.height = __textBoxBounds.height - textBottomMargin;
8162 if (__pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN) != -1.0f)
8164 __textObjectBounds.x = __textBoxBounds.x + __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
8165 __textObjectBounds.width = __textBoxBounds.width - __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
8169 __textObjectBounds.x = __textBoxBounds.x + textLeftMargin;
8170 __textObjectBounds.width = __textBoxBounds.width - textLeftMargin;
8173 if (__pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN) != -1.0f)
8175 __textObjectBounds.width -= __pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
8179 __textObjectBounds.width -= textRightMargin;
8183 if (__pEdit->GetVerticalMarginF(EDIT_TEXT_TOP_MARGIN) != -1.0f)
8185 __textObjectBounds.y = __textBoxBounds.y + __pEdit->GetVerticalMarginF(EDIT_TEXT_TOP_MARGIN);
8186 __textObjectBounds.height = __textBoxBounds.height - __pEdit->GetVerticalMarginF(EDIT_TEXT_TOP_MARGIN);
8190 __textObjectBounds.y = __textBoxBounds.y + textTopMargin;
8191 __textObjectBounds.height = __textBoxBounds.height - textTopMargin;
8194 if (__pEdit->GetVerticalMarginF(EDIT_TEXT_BOTTOM_MARGIN) != -1.0f)
8196 __textObjectBounds.height -= __pEdit->GetVerticalMarginF(EDIT_TEXT_BOTTOM_MARGIN);
8200 __textObjectBounds.height -= textBottomMargin;
8204 if (editStyle & EDIT_STYLE_TITLE_TOP)
8206 __titleBounds.x = titleTextLeftMargin;
8207 __titleBounds.y = titleTextTopMargin;
8208 __titleBounds.width = bounds.width - titleTextLeftMargin
8209 - titleTextRightMargin;
8210 __titleBounds.height = bounds.height - __textBoxBounds.height - __titleBounds.y
8214 else if (editStyle & EDIT_STYLE_TITLE_LEFT)
8216 __titleBounds.x = titleTextLeftMargin;
8217 __titleBounds.y = titleTextTopMargin;
8218 __titleBounds.width = bounds.width - __textBoxBounds.width - __titleBounds.x
8219 - titleTextRightMargin;
8220 __titleBounds.height = __textBoxBounds.height - titleTextTopMargin
8221 - titleTextBottomMargin;
8224 if (editStyle & EDIT_STYLE_NOSCROLL)
8226 __isScrollBarVisible = false;
8227 __scrollBarBounds.x = 0.0f;
8228 __scrollBarBounds.y = 0.0f;
8229 __scrollBarBounds.width = 0.0f;
8230 __scrollBarBounds.height = 0.0f;
8234 __scrollBarBounds.width = scrollWidth;
8236 __scrollBarBounds.x = bounds.width - __scrollBarBounds.width;
8237 __scrollBarBounds.y = __textBoxBounds.y + textTopMargin;
8238 __scrollBarBounds.height = __textBoxBounds.height - textTopMargin - textBottomMargin;
8239 if (__scrollBarBounds.height < 0.0f)
8241 __scrollBarBounds.height = 0.0f;
8244 __isScrollBarVisible = true;
8246 if (editStyle & EDIT_STYLE_TITLE_TOP)
8248 __titleBounds.width -= __scrollBarBounds.width;
8252 float textObectMinimumWidth = 0.0f;
8253 GET_SHAPE_CONFIG(EDIT::TEXT_OBJECT_MININMUM_WIDTH, orientation, textObectMinimumWidth);
8255 if (__textObjectBounds.width < textObectMinimumWidth)
8257 __textObjectBounds.width = textObectMinimumWidth;
8260 if (__textObjectBounds.height < __contentFontSize)
8262 __textObjectBounds.height = __contentFontSize;
8269 _EditPresenter::StopTitleSlidingTimer(void)
8271 if (__pTitleSlidingTimer)
8273 __pTitleSlidingTimer->Cancel();
8274 delete __pTitleSlidingTimer;
8275 __pTitleSlidingTimer = null;
8282 _EditPresenter::StartTitleSlidingTimer(void)
8284 result r = E_SUCCESS;
8286 if (__pTitleSlidingTimer == null)
8288 __pTitleSlidingTimer = new (std::nothrow) Timer;
8289 if (__pTitleSlidingTimer == null)
8291 return E_OUT_OF_MEMORY;
8294 r = __pTitleSlidingTimer->Construct(*this);
8300 r = __pTitleSlidingTimer->Start(TITLE_SLIDING_TIME);
8308 StopTitleSlidingTimer();
8313 _EditPresenter::OnTitleSlidingTimerExpired(void)
8315 result r = E_SUCCESS;
8317 if (!IsInternalFocused())
8319 StopTitleSlidingTimer();
8323 if (__pTitleTextObject->IsChanged())
8325 r = DrawTitleText();
8326 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to draw title text");
8329 Canvas *pTitleTextCanvas = __pTitleTextVisualElement->GetCanvasN();
8330 SysTryReturnResult(NID_UI_CTRL, pTitleTextCanvas, E_SYSTEM, "A system error has occurred. Failed to get canvas of VisualElement");
8332 if (__isTouchPressed)
8334 pTitleTextCanvas->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_PRESSED));
8338 pTitleTextCanvas->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED));
8341 pTitleTextCanvas->Clear();
8342 __pTitleTextObject->DrawWithOffset(*_CanvasImpl::GetInstance(*pTitleTextCanvas));
8343 r = pTitleTextCanvas->Show();
8345 delete pTitleTextCanvas;
8347 r = StartTitleSlidingTimer();
8353 _EditPresenter::ChangePasswordToEchoCharacter(int cursorPos, int textLength)
8355 result r = E_SUCCESS;
8357 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD))
8362 StartPasswordTimer();
8363 if (IsBlocked() == true)
8365 __pTextObject->SetRange(cursorPos, textLength);
8369 __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), 0);
8376 _EditPresenter::StopPasswordTimer(void)
8378 if (__pPasswordTimer)
8380 __pPasswordTimer->Cancel();
8381 delete __pPasswordTimer;
8382 __pPasswordTimer = null;
8389 _EditPresenter::StartPasswordTimer(void)
8391 result r = E_SUCCESS;
8393 if (__pPasswordTimer == null)
8395 __pPasswordTimer = new (std::nothrow) Timer;
8396 if (__pPasswordTimer == null)
8398 return E_OUT_OF_MEMORY;
8401 r = __pPasswordTimer->Construct(*this);
8404 StopPasswordTimer();
8409 r = __pPasswordTimer->Start(EDIT_PASSWORD_TIMER_PERIOD);
8412 StopPasswordTimer();
8419 _EditPresenter::OnPasswordTimerExpired(void)
8421 result r = E_SUCCESS;
8423 if (!IsInternalFocused())
8428 ReplaceTextIntoPasswordHyphenString();
8429 __isCursorChanged = true;
8431 __pEdit->Invalidate();
8437 _EditPresenter::ReplaceTextIntoPasswordHyphenString(void)
8439 result r = E_SUCCESS;
8441 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
8443 if (GetTextLength() > 0)
8445 ChangePasswordToEchoCharacter(__pTextBuffer, __echoChar);
8453 _EditPresenter::ChangePasswordToEchoCharacter(wchar_t* dspStrBuffer, wchar_t echoChar)
8455 result r = E_SUCCESS;
8457 int bufferLength = GetTextLength();
8459 for (int i = 0; i < bufferLength && i < EDIT_PASSWORD_BUFFER_MAX - 1; i++)
8461 dspStrBuffer[i] = echoChar;
8463 dspStrBuffer[bufferLength] = null;
8469 _EditPresenter::SetAutoResizingEnabled(bool enable)
8471 return __pEditModel->SetAutoResizingEnabled(enable);
8475 _EditPresenter::IsAutoResizingEnabled(void) const
8477 return __pEditModel->IsAutoResizingEnabled();
8481 _EditPresenter::CalculateFlexibleHeightF(void)
8483 float height = 0.0f;
8484 float expectedEditHeight = __pTextObject->GetTotalHeightF() + __verticalMargin;
8485 int lineCount = __pTextObject->GetTotalLineCount();
8487 if (__pTextObject->GetTotalHeight())
8489 if ((lineCount >= MAX_LINE_NUMBER) && (GetMaxLineCount() > MAX_LINE_NUMBER))
8491 height = MAX_LINE_NUMBER * __pTextObject->GetLineHeightAtF(0) + __verticalMargin;
8495 float maxHeight = CalculateMaximumFlexibleHeight();
8497 //If InitialBounds is more than expectedEdit height, set flexible height as initial height
8498 if (expectedEditHeight < __initialBounds.height)
8500 height = __initialBounds.height;
8502 else if (expectedEditHeight >= maxHeight)
8508 height = expectedEditHeight;
8513 height = __initialBounds.height;
8520 _EditPresenter::CalculateFlexibleHeight(void)
8523 int expectedEditHeight = __pTextObject->GetTotalHeight() + _CoordinateSystemUtils::ConvertToInteger(__verticalMargin);
8524 int lineCount = __pTextObject->GetTotalLineCount();
8526 if (__pTextObject->GetTotalHeight())
8528 if ((lineCount >= MAX_LINE_NUMBER) && (GetMaxLineCount() > MAX_LINE_NUMBER))
8530 height = MAX_LINE_NUMBER * __pTextObject->GetLineHeightAt(0) + _CoordinateSystemUtils::ConvertToInteger(__verticalMargin);
8534 int maxHeight = _CoordinateSystemUtils::ConvertToInteger(CalculateMaximumFlexibleHeight());
8536 //If InitialBounds is more than expectedEdit height, set flexible height as initial height
8537 if (expectedEditHeight < _CoordinateSystemUtils::ConvertToInteger(__initialBounds.height))
8539 height = _CoordinateSystemUtils::ConvertToInteger(__initialBounds.height);
8541 else if (expectedEditHeight >= maxHeight)
8547 height = expectedEditHeight;
8552 height = _CoordinateSystemUtils::ConvertToInteger(__initialBounds.height);
8559 _EditPresenter::AdjustFlexibleHeight(void)
8561 result r = E_SUCCESS;
8563 if (__isFlexibleHeightFrozen == true)
8568 if (__maximumFlexibleHeight > 0 && __maximumFlexibleHeight <= __initialBounds.height)
8573 __pTextObject->Compose();
8575 if (__prevTotalTextHeight == __pTextObject->GetTotalHeightF()) // if text height has not changed.
8577 __prevTotalTextHeight = __pTextObject->GetTotalHeightF();
8582 FloatRectangle bounds = __pEdit->GetBoundsF();
8583 float calculateHeight = CalculateFlexibleHeight();
8585 if (bounds.height != calculateHeight)
8587 bounds.height = calculateHeight;
8588 __prevTotalTextHeight = __pTextObject->GetTotalHeightF();
8589 return SetFlexBounds(bounds);
8591 __prevTotalTextHeight = __pTextObject->GetTotalHeight();
8596 _EditPresenter::SetFlexBounds(const Rectangle& bounds)
8598 result r = E_SUCCESS;
8600 if (!__isInitializing)
8605 _ExpandableEditAreaEventStatus expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_ADDED;
8606 if (__pEdit->GetBounds().height > bounds.height)
8608 expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_REMOVED;
8610 else if (__pEdit->GetBounds().height < bounds.height)
8612 expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_ADDED;
8615 _VisualElement* pVisualElement = __pEdit->GetVisualElement();
8616 SysTryReturnResult(NID_UI_CTRL, pVisualElement, E_SYSTEM, "A system error has occurred. Unable to get root visual element.");
8618 pVisualElement->SetAnimationProvider(__pEditVEDelegator);
8619 pVisualElement->SetImplicitAnimationEnabled(true);
8621 if (!((__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) == false))
8623 __updateInitialBounds = false;
8626 __pEdit->SetBounds(bounds);
8627 __updateInitialBounds = true;
8631 __pEdit->Invalidate();
8633 __prevTotalTextHeight = _CoordinateSystemUtils::ConvertToFloat(__pTextObject->GetTotalHeight());
8634 __pEdit->SendExpandableEditAreaEvent(expandableEditAreaStatus);
8636 pVisualElement->SetImplicitAnimationEnabled(false);
8642 _EditPresenter::SetFlexBounds(const FloatRectangle& bounds)
8644 result r = E_SUCCESS;
8646 if (!__isInitializing)
8651 _ExpandableEditAreaEventStatus expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_ADDED;
8652 if (__pEdit->GetBoundsF().height > bounds.height)
8654 expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_REMOVED;
8656 else if (__pEdit->GetBoundsF().height < bounds.height)
8658 expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_ADDED;
8661 _VisualElement* pVisualElement = __pEdit->GetVisualElement();
8662 SysTryReturnResult(NID_UI_CTRL, pVisualElement, E_SYSTEM, "A system error has occurred. Unable to get root visual element.");
8664 pVisualElement->SetAnimationProvider(__pEditVEDelegator);
8665 pVisualElement->SetImplicitAnimationEnabled(true);
8667 //Modify InitialBounds only on User calls and on Orientation change
8668 if (!((__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) == false))
8670 __updateInitialBounds = false;
8673 __pEdit->SetBounds(bounds);
8674 __updateInitialBounds = true;
8678 __pEdit->Invalidate();
8680 __prevTotalTextHeight = __pTextObject->GetTotalHeightF();
8681 __pEdit->SendExpandableEditAreaEvent(expandableEditAreaStatus);
8683 pVisualElement->SetImplicitAnimationEnabled(false);
8689 _EditPresenter::CalculateMaximumFlexibleHeight(void)
8691 float maxHeight = __maximumFlexibleHeight;
8692 float expectedEditHeight = __pTextObject->GetTotalHeightF() + __verticalMargin;
8693 int maximumFlexibleLineNumber = GetMaxLineCount();
8695 // if height is longer than max height.
8696 if (maxHeight > 0 && expectedEditHeight >= maxHeight)
8698 maxHeight = __maximumFlexibleHeight;
8700 else if (maximumFlexibleLineNumber > 0) // if max line number is set.
8702 maxHeight = maximumFlexibleLineNumber * __pTextObject->GetLineHeightAtF(0) + __verticalMargin;
8704 FloatDimension dim = __pEdit->GetMaximumSizeF();
8705 if (maxHeight > dim.height)
8707 maxHeight = dim.height;
8715 _EditPresenter::SetKeypadBounds(const Rectangle& bounds)
8717 __keypadBounds.x = _CoordinateSystemUtils::ConvertToFloat(bounds.x);
8718 __keypadBounds.y = _CoordinateSystemUtils::ConvertToFloat(bounds.y);
8719 __keypadBounds.width = _CoordinateSystemUtils::ConvertToFloat(bounds.width);
8720 __keypadBounds.height = _CoordinateSystemUtils::ConvertToFloat(bounds.height);
8725 _EditPresenter::SetKeypadBounds(const FloatRectangle& bounds)
8727 __keypadBounds.x = bounds.x;
8728 __keypadBounds.y = bounds.y;
8729 __keypadBounds.width = bounds.width;
8730 __keypadBounds.height = bounds.height;
8735 _EditPresenter::GetParentForm(void)
8742 if (__pEdit->GetInputStyle() == INPUT_STYLE_FULLSCREEN)
8747 if (__pParentForm == null)
8749 result r = E_SUCCESS;
8751 _Form* pForm = null;
8752 _Control* pControlCore = null;
8754 for (pControlCore = __pEdit->GetParent(); pForm == null; pControlCore = pControlCore->GetParent())
8756 if (pControlCore == null)
8762 pForm = dynamic_cast<_Form*>(pControlCore);
8772 _EditPresenter::GetParentPanel(void) const
8774 return __pParentPanel;
8778 _EditPresenter::SetKeypadCommandButtonVisible(bool visible)
8780 __isKeypadCommandButtonVisible = visible;
8785 _EditPresenter::SetKeypadCommandButton(CommandButtonPosition position, const String& text, int actionId)
8787 result r = E_SUCCESS;
8788 FooterItem footerItem;
8789 footerItem.Construct(actionId);
8790 footerItem.SetText(text);
8792 __pEditModel->SetCommandButtonItem(position, actionId, text);
8793 if (__pCommandButton)
8795 _Button* pButton = __pCommandButton->GetItem(static_cast<int>(position));
8798 pButton->SetActionId(actionId);
8799 pButton->SetText(text);
8807 _EditPresenter::GetKeypadCommandButton(void) const
8809 return __pCommandButton;
8813 _EditPresenter::AddActionEventListener(const _IActionEventListener& listener)
8817 if (__pCommandButton)
8819 __pCommandButton->AddActionEventListener(listener);
8822 __pActionEventListener = const_cast<_IActionEventListener*>(&listener);
8828 _EditPresenter::RemoveActionEventListener(const _IActionEventListener& listener)
8832 if (__pCommandButton)
8834 __pCommandButton->RemoveActionEventListener(listener);
8837 __pActionEventListener = null;
8843 _EditPresenter::SetTextBounds(Rectangle& bounds)
8845 __textObjectBounds = _CoordinateSystemUtils::ConvertToFloat(bounds);
8850 _EditPresenter::SetTextBounds(FloatRectangle& bounds)
8852 __textObjectBounds = bounds;
8857 _EditPresenter::GetTextBoundsF(void) const
8859 return __textObjectBounds;
8863 _EditPresenter::GetTextBounds(void) const
8865 return _CoordinateSystemUtils::ConvertToInteger(__textObjectBounds);
8869 _EditPresenter::IsKeypadCommandButtonVisible(void) const
8871 return __isKeypadCommandButtonVisible;
8875 _EditPresenter::GetKeypadCommandButtonText(CommandButtonPosition position) const
8877 return __pEditModel->GetKeypadCommandButtonText(position);
8881 _EditPresenter::GetKeypadCommandButtonActionId(CommandButtonPosition position) const
8883 return __pEditModel->GetKeypadCommandButtonActionId(position);
8887 _EditPresenter::DrawScrollBar(void)
8889 result r = E_SUCCESS;
8891 if (__pScrollBar == null)
8896 float totalHeight = __pTextObject->GetTotalHeightF();
8897 float dspHeight = __textObjectBounds.height;
8898 float firstDisplayY = __pTextObject->GetFirstDisplayPositionYF();
8900 if (totalHeight <= dspHeight)
8902 if (__prevTotalTextHeight != 0.0f && __prevTotalTextHeight == totalHeight) // flexible edit's case
8907 __pScrollBar->SetScrollRange(1, 1);
8908 __pScrollBar->SetScrollPosition(0.0f);
8910 __isScrollBarVisible = false;
8911 __previousScrollBarPos = 0.0f;
8912 __previousScrollBarMaxPos = 0.0f;
8916 if (firstDisplayY > 0)
8918 __pScrollBar->SetScrollRange(dspHeight, totalHeight);
8919 __pScrollBar->SetScrollPosition(firstDisplayY);
8920 __previousScrollBarMaxPos = totalHeight - dspHeight;
8924 __pScrollBar->SetScrollRange(dspHeight, totalHeight);
8925 __pScrollBar->SetScrollPosition(0.0f);
8926 __previousScrollBarMaxPos = 0.0f;
8929 if (__pScrollBar->GetScrollVisibility())
8931 __isScrollBarVisible = true;
8934 __previousScrollBarPos = firstDisplayY;
8941 _EditPresenter::FadeOutScrollBar(void)
8945 __pScrollBar->SetScrollVisibility(false);
8947 __isScrollBarVisible = false;
8953 _EditPresenter::InitializeFlickAnimation(void)
8955 result r = E_SUCCESS;
8957 if (__pFlickAnimation == null)
8959 __pFlickAnimation = new (std::nothrow) _FlickAnimation;
8962 // Init Flick Animation Config
8963 if (__pFlickAnimation)
8966 float height = 0.0f;
8967 Tizen::Graphics::FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
8968 Tizen::Graphics::FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
8969 if (__pEdit->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
8971 width = portraitSize.width;
8972 height = portraitSize.height;
8976 width = landscapeSize.width;
8977 height = landscapeSize.height;
8980 __pFlickAnimation->SetSizeInformation(width, height, DEVICE_SIZE_HORIZONTAL, DEVICE_SIZE_VERTICAL);
8981 __pFlickAnimation->SetSensitivity(FLICK_ANIMATION_FPS_PANEL, FLICK_ANIMATION_SENSITIVITY_PANEL);
8988 if (__pFlickAnimationTimer == null)
8990 __pFlickAnimationTimer = new (std::nothrow) Timer;
8991 if (__pFlickAnimationTimer == null)
8993 r = E_OUT_OF_MEMORY;
8997 r = __pFlickAnimationTimer->Construct(*this);
9000 delete __pFlickAnimationTimer;
9012 _EditPresenter::StartFlickAnimation(const FloatPoint& flickPosition, int flickTime)
9014 // delete Scroll Fadeout Timer
9020 if (__pScrollBar->IsOnFadeEffect() == true)
9022 __pScrollBar->CancelFadeEffect();
9025 if (InitializeFlickAnimation() != E_SUCCESS)
9030 //We must check the flick animation about float conversion work at later
9032 // Initialize flick animation
9036 __pFlickAnimation->CalculateInitializeVelocity(_CoordinateSystemUtils::ConvertToInteger(flickPosition.x), _CoordinateSystemUtils::ConvertToInteger(flickPosition.y), flickTime, &velocityX, &velocityY);
9038 if (Math::Abs(flickPosition.x) > Math::Abs(flickPosition.y))
9040 __pFlickAnimation->InitializeFlickAmount(velocityX);
9044 __pFlickAnimation->InitializeFlickAmount(velocityY);
9047 return StartFlickTimer(velocityY, velocityX);
9051 _EditPresenter::StartFlickTimer(int flickVelocityX, int flickVelocityY)
9053 if (__pFlickAnimation)
9055 if (ScrollContentsOnFlick() != E_SUCCESS)
9064 if (__pFlickAnimationTimer)
9066 if (__pFlickAnimationTimer->Start(EDIT_FLICK_SCROLL_TIMER_INTERVAL) != E_SUCCESS)
9082 _EditPresenter::ScrollContentsOnFlick(void)
9084 //We must check the flick animation about float conversion work at later
9086 if (__pFlickAnimation)
9088 int moveAmountX = 0;
9089 int moveAmountY = 0;
9090 __pFlickAnimation->CalculateNextMove(&moveAmountX, &moveAmountY);
9093 if (ScrollOnFlick(_CoordinateSystemUtils::ConvertToFloat(-moveAmountY*EDIT_FLICK_SCROLL_MOVE_AMOUNT_MULTIPLIER)))
9105 _EditPresenter::ScrollOnFlick(float moveDistanceY)
9107 if (moveDistanceY == 0)
9113 if (__pScrollBar->IsOnFadeEffect() == true)
9115 __pScrollBar->CancelFadeEffect();
9118 ScrollContents(moveDistanceY);
9124 _EditPresenter::SetCursorEnabled(bool enable)
9126 __isCursorOpaque = enable;
9132 _EditPresenter::IsCursorEnabled(void) const
9134 return __isCursorOpaque;
9138 _EditPresenter::StopFlickTimer(void)
9140 if (__pFlickAnimationTimer != null)
9142 __pFlickAnimationTimer->Cancel();
9143 delete __pFlickAnimationTimer;
9144 __pFlickAnimationTimer = null;
9151 _EditPresenter::OnFlickTimerExpired(void)
9153 result r = E_SUCCESS;
9155 if (__pFlickAnimationTimer)
9158 if (__pFlickAnimationTimer->Start(EDIT_FLICK_SCROLL_TIMER_INTERVAL) != E_SUCCESS)
9165 if (ScrollContentsOnFlick() != E_SUCCESS)
9184 _EditPresenter::SetScrollBarVisible(bool enable)
9186 __isScrollBarVisible = enable;
9192 _EditPresenter::SetScrollBarBounds(const FloatRectangle& bounds)
9194 __scrollBarBounds = bounds;
9200 _EditPresenter::SetScrollBarBounds(const Rectangle& bounds)
9202 __scrollBarBounds = _CoordinateSystemUtils::ConvertToFloat(bounds);
9208 _EditPresenter::GetDisplayScrollBoundsF(void) const
9210 return __scrollBarBounds;
9214 _EditPresenter::GetDisplayScrollBounds(void) const
9216 return _CoordinateSystemUtils::ConvertToInteger(__scrollBarBounds);
9220 _EditPresenter::GetInitialBoundsF(void) const
9222 return __initialBounds;
9226 _EditPresenter::GetInitialBounds(void) const
9228 return _CoordinateSystemUtils::ConvertToInteger(__initialBounds);
9232 _EditPresenter::SetPreviousScrollBarPosition(int position)
9234 __previousScrollBarPos = _CoordinateSystemUtils::ConvertToFloat(position);
9240 _EditPresenter::SetPreviousScrollBarPosition(float position)
9242 __previousScrollBarPos = position;
9248 _EditPresenter::GetPreviousScrollPosition(void) const
9250 return _CoordinateSystemUtils::ConvertToInteger(__previousScrollBarPos);
9254 _EditPresenter::GetPreviousScrollPositionF(void) const
9256 return __previousScrollBarPos;
9260 _EditPresenter::SetMaximumPreviousScrollBarPosition(int position)
9262 __previousScrollBarMaxPos = _CoordinateSystemUtils::ConvertToFloat(position);
9268 _EditPresenter::SetMaximumPreviousScrollBarPosition(float position)
9270 __previousScrollBarMaxPos = position;
9276 _EditPresenter::GetScrollBar(void) const
9278 return __pScrollBar;
9282 _EditPresenter::GetTextObject(void) const
9284 return __pTextObject;
9288 _EditPresenter::SetAutoShrinkModeEnabled(bool enable)
9290 __isAutoShrinkEnabled = enable;
9296 _EditPresenter::IsAutoShrinkModeEnabled(void) const
9298 return __isAutoShrinkEnabled;
9302 _EditPresenter::GetEditView(void) const
9308 _EditPresenter::InitializeParentPanel(void)
9310 if (__pParentPanel == null)
9312 _ScrollPanel* pScrollPanel = null;
9313 _Control* pControlCore = null;
9315 for (pControlCore = __pEdit->GetParent(); pScrollPanel == null; pControlCore = pControlCore->GetParent())
9317 if (pControlCore == null)
9322 pScrollPanel = dynamic_cast<_ScrollPanel*>(pControlCore);
9325 __pParentPanel = pScrollPanel;
9335 _EditPresenter::ScrollPanelToTop(bool show)
9337 if (!__pParentPanel)
9340 FloatRectangle editAbsoluteBounds = __pEdit->GetAbsoluteBoundsF();
9341 FloatRectangle panelAbsoluteBounds = __pParentPanel->GetAbsoluteBoundsF();
9342 float scrollPosition = __pParentPanel->GetScrollPosition() + (editAbsoluteBounds.y - panelAbsoluteBounds.y);
9344 __pParentPanel->SetScrollPosition(scrollPosition);
9348 __pParentPanel->Invalidate();
9355 _EditPresenter::ScrollPanelToCursorPosition(bool show)
9357 if (!__pParentPanel)
9360 result r = E_SUCCESS;
9362 FloatRectangle absCursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
9363 r = CalculateAbsoluteCursorBounds(__cursorPos, absCursorBounds);
9370 FloatRectangle absPanelRect = __pParentPanel->GetAbsoluteBoundsF();
9371 float panelHeight = __pParentPanel->GetBoundsF().height;
9373 float scrollPosition = __pParentPanel->GetScrollPosition();
9374 float cursorBoundsY = absCursorBounds.y - absPanelRect.y;
9376 float topYCompared = 0.0f;
9377 float bottomYCompared = panelHeight;
9379 if (__textObjectBounds.height < absCursorBounds.height)
9381 absCursorBounds.height = __textObjectBounds.height;
9384 float upSideGap = topYCompared - cursorBoundsY;
9385 float downSideGap = (upSideGap > 0.0f) ? 0.0f : cursorBoundsY + absCursorBounds.height - bottomYCompared;
9387 if (upSideGap > 0.0f || downSideGap > 0.0f)
9390 float GAP_CORRECTION = __verticalMargin / 2.0f;
9392 if (upSideGap > 0.0f)
9394 gap = scrollPosition - (upSideGap + GAP_CORRECTION);
9398 gap = scrollPosition + (downSideGap + GAP_CORRECTION);
9401 __pParentPanel->SetScrollPosition(gap);
9403 __pParentPanel->Invalidate();
9410 _EditPresenter::SetSearchBarFlag(bool enabled)
9412 __isSearchBar = enabled;
9418 _EditPresenter::GetSearchBarFlag(void) const
9420 return __isSearchBar;
9424 _EditPresenter::SetFocused(void)
9426 bool focused = true;
9429 if ((__pParentPanel->GetFocused() != __pEdit) && IsInternalFocused() == false)
9434 else if (IsInternalFocused() == false)
9439 if (focused == false)
9441 __pEdit->SetFocused();
9448 _EditPresenter::GetWordPosition(int cursorPos, int& startPos, int& endPos) const
9450 int textLength = GetTextLength();
9451 bool isDetected = false;
9453 if (cursorPos >= textLength && cursorPos > 0)
9458 if (IsDelimiter(__pTextBuffer[cursorPos]) && cursorPos > 0)
9463 for (int i = cursorPos; i >= 0; i--)
9465 if (IsDelimiter(__pTextBuffer[i]))
9473 if (isDetected == false)
9482 for (int i = cursorPos; i < textLength; i++)
9484 if (IsDelimiter(__pTextBuffer[i]))
9492 if (isDetected == false)
9494 endPos = textLength;
9501 _EditPresenter::GetTextImageRangeAt(int postion, int& startPosition, int& endPosition) const
9503 int length = GetTextLength();
9507 SysTryReturnResult(NID_UI_CTRL, postion >= 0 && postion <= length, E_OUT_OF_RANGE, "[EDIT] The given index is out-of-range.");
9509 _Text::TextElement* pTextElement = __pTextObject->GetElementAtTextIndex(postion);
9510 const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
9511 if (pSimpleText != null && pSimpleText->GetBitmap() != null)
9513 startPosition = pSimpleText->GetTextOffset();
9514 endPosition = startPosition + pSimpleText->GetTextLength();
9518 return E_OBJ_NOT_FOUND;
9522 _EditPresenter::IsDelimiter(wchar_t character) const
9528 case 0x0A: // NLine Feed
9531 case 0x0D: // Carriage Return
9545 _EditPresenter::InitializeCopyPasteManager(void)
9547 bool releaseBlock = true;
9549 if (__pCopyPasteManager)
9551 releaseBlock = __pCopyPasteManager->GetTextBlockReleaseFlag();
9552 delete __pCopyPasteManager;
9553 __pCopyPasteManager = null;
9556 if (IsBlocked() == true && releaseBlock)
9559 __pEdit->Invalidate();
9562 __isCopyPasteManagerExist = false;
9563 __isCopyPastePopupMoving = false;
9569 _EditPresenter::IsCopyPasteManagerExist(void) const
9571 return __isCopyPasteManagerExist;
9575 _EditPresenter::GetTextAreaBounds(void) const
9577 return _CoordinateSystemUtils::ConvertToInteger(__textObjectBounds);
9581 _EditPresenter::GetTextAreaBoundsF(void) const
9583 return __textObjectBounds;
9587 _EditPresenter::GetTitleBounds(void) const
9589 return _CoordinateSystemUtils::ConvertToInteger(__titleBounds);
9593 _EditPresenter::GetTitleBoundsF(void) const
9595 return __titleBounds;
9599 _EditPresenter::GetClearIconBounds(void) const
9601 return _CoordinateSystemUtils::ConvertToInteger(__clearIconBounds);
9605 _EditPresenter::GetClearIconBoundsF(void) const
9607 return __clearIconBounds;
9611 _EditPresenter::FinishTextComposition(void)
9613 if (__isInputConnectionBound)
9615 __pInputConnection->FinishTextComposition();
9616 __isTextComposing = false;
9617 __composingTextLength = 0;
9624 _EditPresenter::GetTextCompositionState(void) const
9626 return __isTextComposing;
9630 _EditPresenter::IsCopyPastePopup(const _Control& control) const
9632 if (__pCopyPasteManager)
9634 return __pCopyPasteManager->IsCopyPastePopup(control);
9641 _EditPresenter::IsCopyPasteHandle(const _Control& control) const
9643 if (__pCopyPasteManager)
9645 return __pCopyPasteManager->IsCopyPasteHandle(control);
9652 _EditPresenter::SetCursorChangedFlag(bool enabled)
9654 __isCursorChanged = enabled;
9660 _EditPresenter::GetCursorChangedFlag(void) const
9662 return __isCursorChanged;
9666 _EditPresenter::SetEditGroupStyle(GroupStyle groupStyle)
9668 __groupStyle = groupStyle;
9674 _EditPresenter::PostInternalEvent(const Tizen::Base::String& type)
9678 ArrayList* pArgs = new (std::nothrow) ArrayList();
9679 SysTryReturnVoidResult(NID_UI_CTRL, pArgs != null, E_SYSTEM, "[E_SYSTEM] pArgs is null.");
9681 result r = E_SYSTEM;
9682 r = pArgs->Construct();
9683 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to construct pArgs");
9685 String* pType = new (std::nothrow) String(type);
9686 SysTryReturnVoidResult(NID_UI, pType, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
9688 r = pArgs->Add(*pType);
9689 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to add type to pArgs");
9691 _UiNotificationEvent event(__pEdit->GetHandle(), pArgs);
9692 r = _UiEventManager::GetInstance()->PostEvent(event);
9693 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to send event");
9699 _EditPresenter::ReleaseCopyPastePopup(void)
9701 if (__pCopyPasteManager)
9703 return __pCopyPasteManager->ReleaseCopyPastePopup();
9708 _EditPresenter::IsCopyPastePopupExist(void) const
9710 if (__pCopyPasteManager)
9712 if (__pCopyPasteManager->GetCopyPastePopup())
9725 _EditPresenter::IsCopyPasteHandleExist(void) const
9727 if (__pCopyPasteManager)
9729 return __pCopyPasteManager->IsCopyPasteHandleExist();
9735 _EditPresenter::IsUnsupportedChracterExist(const KeypadStyle keypadStyle, const Tizen::Base::String& text)
9737 const int numberOfCharOnNumOnlyStyle = 10;
9738 const int numberOfCharOnPhoneNumStyle = 13;
9739 const int numberOfCharOnIpStyle = 18;
9741 const wchar_t* TempKey = null;
9742 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};
9743 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*/,
9744 0x2a/***/, 0x2b/*+*/, 0x23/*#*/, 0};
9745 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*/,
9746 0x3a/*:*/, 0x2e/*.*/, 0x61/*a*/, 0x62/*b*/, 0x63/*c*/, 0x64/*d*/, 0x65/*e*/, 0x66/*f*/, 0};
9747 bool isSupportedCharacterExist = false;
9748 int supportedCharacterCount = 0;
9750 switch (keypadStyle)
9752 case KEYPAD_STYLE_NUMBER:
9753 supportedCharacterCount = numberOfCharOnNumOnlyStyle;
9754 TempKey = characterOnNumOnlyStyle;
9756 case KEYPAD_STYLE_PHONE_NUMBER:
9757 supportedCharacterCount = numberOfCharOnPhoneNumStyle;
9758 TempKey = characterOnPhoneNumStyle;
9760 case KEYPAD_STYLE_IP_V4:
9761 supportedCharacterCount = numberOfCharOnIpStyle;
9762 TempKey = characterOnIPStyle;
9768 if (text.GetLength() < 1)
9773 for (int i = 0; i < text.GetLength(); i++)
9775 isSupportedCharacterExist = false;
9776 wchar_t checkChar =0;
9777 if ( text.GetCharAt(i, checkChar) != E_SUCCESS)
9781 for (int j = 0; j < supportedCharacterCount ; j++)
9783 if (TempKey[j] == checkChar)
9785 isSupportedCharacterExist = true;
9789 if (!isSupportedCharacterExist)
9799 _EditPresenter::SetBlockRangeWithShiftArrowkey(_KeyCode keyCode)
9803 if (IsBlocked() == true)
9805 GetBlockRange(start, end);
9809 if (__textBlockMoveLeft)
9813 SetBlockRange(--start, end);
9818 if (start < end - 1)
9820 SetBlockRange(start, --end);
9822 else if (start == end - 1)
9825 SetCursorPosition(start);
9830 if (__textBlockMoveLeft)
9832 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(start);
9834 if (curCursorLine > 0)
9836 int offset = start - __pTextObject->GetFirstTextIndexAt(curCursorLine);
9837 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine-1);
9838 start = offset + firstTextIndex;
9839 int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
9840 if (offset > textLength)
9842 start = firstTextIndex+textLength;
9844 SetBlockRange(start, end);
9849 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(end);
9851 if (curCursorLine > 0)
9853 int offset = end - __pTextObject->GetFirstTextIndexAt(curCursorLine);
9854 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine-1);
9855 end = offset + firstTextIndex;
9856 int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
9857 if (offset > textLength)
9859 end = firstTextIndex+textLength;
9866 __textBlockMoveLeft = true;
9867 SetBlockRange(start, end);
9869 else if (start == end)
9872 SetCursorPosition(end);
9876 SetBlockRange(start, end);
9882 if (__textBlockMoveLeft)
9884 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(start);
9885 int totalLine = __pTextObject->GetTotalLineCount();
9886 if (curCursorLine < totalLine - 1)
9888 int offset = start - __pTextObject->GetFirstTextIndexAt(curCursorLine);
9889 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
9890 start = offset + firstTextIndex;
9891 int textLength = __pTextObject->GetTextLengthAt(curCursorLine+1);
9892 if (offset > textLength)
9894 start = firstTextIndex+textLength;
9902 __textBlockMoveLeft = false;
9903 SetBlockRange(start, end);
9905 else if (start == end)
9908 SetCursorPosition(end);
9912 SetBlockRange(start, end);
9918 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(end);
9919 int totalLine = __pTextObject->GetTotalLineCount();
9920 if (curCursorLine < totalLine - 1)
9922 int offset = end - __pTextObject->GetFirstTextIndexAt(curCursorLine);
9923 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
9924 end = offset + firstTextIndex;
9925 int textLength = __pTextObject->GetTextLengthAt(curCursorLine+1);
9926 if (offset > textLength)
9928 end = firstTextIndex+textLength;
9930 SetBlockRange(start, end);
9935 if (__textBlockMoveLeft)
9937 if (start + 1 < end)
9939 SetBlockRange(++start, end);
9941 else if (start + 1 == end)
9944 SetCursorPosition(end);
9949 if (end + 1 <= GetTextLength())
9951 SetBlockRange(start, ++end);
9961 if (__textBlockMoveLeft)
9963 __pTextObject->SetFirstDisplayLineIndexFromTextIndex(start);
9965 SetCursorChangedFlag(!__textBlockMoveLeft);
9974 if (__cursorPos > 0)
9976 start = __cursorPos - 1;
9978 SetBlockRange(start, end);
9979 __textBlockMoveLeft = true;
9984 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
9986 if (curCursorLine > 0)
9988 int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
9989 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine-1);
9990 start = offset + firstTextIndex;
9991 int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
9992 if (offset > textLength)
9994 start = firstTextIndex+textLength;
9997 SetBlockRange(start, end);
9998 __textBlockMoveLeft = true;
10003 if (GetTextLength() >= __cursorPos + 1)
10005 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
10006 int totalLine = __pTextObject->GetTotalLineCount();
10007 if (curCursorLine < totalLine - 1)
10009 int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
10010 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
10011 end = offset + firstTextIndex;
10012 int textLength = __pTextObject->GetTextLengthAt(curCursorLine+1);
10013 if (offset > textLength)
10015 end = firstTextIndex+textLength;
10018 else if (curCursorLine == totalLine - 1)
10020 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine);
10021 int textLength = __pTextObject->GetTextLengthAt(curCursorLine);
10022 end = firstTextIndex + textLength;
10024 start = __cursorPos;
10025 SetBlockRange(start, end);
10026 __textBlockMoveLeft = false;
10030 if (GetTextLength() >= __cursorPos + 1)
10032 start = __cursorPos;
10033 end = __cursorPos + 1;
10034 SetBlockRange(start, end);
10035 __textBlockMoveLeft = false;
10045 __textBlockMoving = true;
10050 _EditPresenter::SetEditTextFilter(_IEditTextFilter* pFilter)
10052 __pTextFilter = pFilter;
10058 _EditPresenter::ValidatePastedText(const String& pastedText, String& replacedText)
10060 bool enable = false;
10063 enable = __pTextFilter->ValidatePastedText(pastedText, replacedText);
10070 _EditPresenter::SendOpaqueCommand (const String& command)
10072 if (__pInputConnection)
10074 __pInputConnection->SendOpaqueCommand(command);
10081 _EditPresenter::IsBounded(void) const
10083 return __isInputConnectionBound;
10087 _EditPresenter::AdjustRTLTextAlignment(const _EditTextType textType)
10089 result r = E_SUCCESS;
10093 case EDIT_TEXT_TYPE_INPUT:
10094 if (GetTextAlignment() != ALIGNMENT_LEFT)
10098 if (_BidiUtils::IsRTL(GetText()) == true)
10100 if (__horizontalAlignmentForBidi == ALIGNMENT_LEFT)
10102 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
10104 r = __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
10108 r = __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_TOP);
10110 __horizontalAlignmentForBidi = ALIGNMENT_RIGHT;
10111 if (r == E_SUCCESS)
10119 if (__horizontalAlignmentForBidi == ALIGNMENT_RIGHT)
10121 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
10123 r = __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
10127 r = __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
10129 __horizontalAlignmentForBidi = ALIGNMENT_LEFT;
10130 if (r == E_SUCCESS)
10137 case EDIT_TEXT_TYPE_GUIDE:
10138 if (__pGuideTextObject == null)
10142 if (_BidiUtils::IsRTL(__guideText) == true)
10144 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
10146 r = __pGuideTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
10150 r = __pGuideTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_TOP);
10152 if (r == E_SUCCESS)
10159 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
10161 r = __pGuideTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
10165 r = __pGuideTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
10167 if (r == E_SUCCESS)
10173 case EDIT_TEXT_TYPE_TITLE:
10174 if (__pTitleTextObject == null)
10178 if (_BidiUtils::IsRTL(__titleText) == true)
10180 r = __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
10181 if (r == E_SUCCESS)
10188 r = __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
10189 if (r == E_SUCCESS)
10202 }}} // Tizen::Ui::Controls