2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrl_EditPresenter.cpp
20 * @brief This is the implementation file for the _EditPresenter class.
23 #include <FBaseErrorDefine.h>
24 #include <FBaseInternalTypes.h>
25 #include <FBaseSysLog.h>
26 #include <FBaseUtilMath.h>
27 #include <FGrpFloatRectangle.h>
29 #include <FLclLocale.h>
30 #include <FUiCtrlFooter.h>
31 #include <FUiCtrlFooterItem.h>
32 #include <FUiCtrlForm.h>
33 #include <FUiIActionEventListener.h>
34 #include <FGrp_BitmapImpl.h>
35 #include <FGrp_CoordinateSystem.h>
36 #include <FGrp_FontImpl.h>
37 #include <FGrp_Screen.h>
38 #include <FGrp_TextCommon.h>
39 #include <FGrp_TextElementImpl.h>
40 #include <FGrp_TextTextCutLink.h>
41 #include <FGrp_TextTextCutLinkParser.h>
42 #include <FGrp_TextTextElement.h>
43 #include <FGrp_TextTextImage.h>
44 #include <FGrp_TextTextSimple.h>
45 #include "FUi_Clipboard.h"
46 #include "FUi_ClipboardItem.h"
47 #include "FUi_Control.h"
48 #include "FUi_ControlManager.h"
49 #include "FUi_CoordinateSystemUtils.h"
50 #include "FUi_EcoreEvasMgr.h"
51 #include "FUi_ResourceManager.h"
52 #include "FUi_BidiUtils.h"
53 #include "FUi_UiEventManager.h"
54 #include "FUi_UiNotificationEvent.h"
55 #include "FUiAnim_VisualElement.h"
56 #include "FUiAnim_EflNode.h"
57 #include "FUiCtrl_Button.h"
58 #include "FUiCtrl_ContextMenu.h"
59 #include "FUi_DragAndDropItem.h"
60 #include "FUiCtrl_Edit.h"
61 #include "FUiCtrl_EditCopyPasteManager.h"
62 #include "FUiCtrl_EditPresenter.h"
63 #include "FUiCtrl_TokenEditPresenter.h"
64 #include "FUiCtrl_FlickAnimation.h"
65 #include "FUiCtrl_Frame.h"
66 #include "FUiCtrl_Form.h"
67 #include "FUiCtrl_Scroll.h"
68 #include "FUiCtrl_ScrollPanel.h"
69 #include "FUiCtrl_Toolbar.h"
70 #include "FUiCtrl_TableView.h"
71 #include "FUi_Window.h"
73 #define EDIT_DRAG_AND_DROP_ENABLED 0
75 using namespace Tizen::Base::Runtime;
76 using namespace Tizen::Base::Utility;
77 using namespace Tizen::Media;
78 using namespace Tizen::Ui::Animations;
79 using namespace Tizen::Graphics;
80 using namespace Tizen::Ui;
81 using namespace Tizen::Ui::Controls;
82 using namespace Tizen::Base;
83 using namespace Tizen::Base::Utility;
84 using namespace Tizen::Base::Collection;
85 using namespace Tizen::Locales;
86 using namespace Tizen::Graphics::_Text;
88 namespace Tizen { namespace Ui { namespace Controls
90 const int EDIT_PASSWORD_TIMER_PERIOD = 1000;
91 const int EDIT_CURSOR_TIMER_PERIOD = 600;
92 const int MAX_LINE_NUMBER = 100;
93 const int MAX_FLEXIBLE_HEIGHT_VERTICAL_MODE = 4000;
94 const int MAX_FLEXIBLE_HEIGHT_HORIZONTAL_MODE = 2500;
95 const int EDIT_FLICK_SCROLL_TIMER_INTERVAL = 10;
96 const int EDIT_FLICK_SCROLL_MOVE_AMOUNT_MULTIPLIER = 2;
97 const float DIRECTION_DECISION_RATIO = 1.3f;
98 const float HORIZONTAL_DECISION_RATIO = 1.5f;
99 const float MOVE_SKIP_DECISION_RANGE = 5.0f;
100 const int TITLE_SLIDING_TIME = 800;
102 const int LANGUAGE_CODE_START = 0;
103 const int LANGUAGE_CODE_MAX = 2;
105 bool _EditPresenter::__isKeypadExist = false;
106 bool _EditPresenter::__isClipboardExist = false;
107 float _EditPresenter::__initialParentHeight = 0.0f;
108 float _EditPresenter::__clipboardHeight = 0.0f;
109 _EditFooterVisibleStatus _EditPresenter::__initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
110 bool _EditPresenter::__footerVisibleChanged = false;
111 unsigned int _EditPresenter::__latestBoundedContext = null;
112 const float _EditPresenter::TOUCH_PRESS_THRESHOLD_IN_CLEAR_AREA = 0.04f;
113 _ScrollPanel* _EditPresenter::__pResizedPanel = null;
116 class _EditDragAndDropWindow
117 : public Tizen::Ui::_Window
120 _EditDragAndDropWindow(void);
121 virtual ~_EditDragAndDropWindow(void);
123 virtual result OnAttachedToMainTree(void);
124 void SetLabel(_Label* pLabel);
127 }; // _EditDragAndDropWindow
129 _EditDragAndDropWindow::_EditDragAndDropWindow(void)
134 _EditDragAndDropWindow::~_EditDragAndDropWindow(void)
138 DetachChild(*__pLabel);
145 _EditDragAndDropWindow::OnAttachedToMainTree(void)
153 _EditDragAndDropWindow::SetLabel(_Label* pLabel)
158 _EditPresenter::_EditPresenter(void)
159 : __pTitleSlidingTimer(null)
161 , __pTextBuffer(null)
162 , __pTextString(null)
165 , __pScrollEffect(null)
167 , __horizontalAlignment(ALIGNMENT_LEFT)
168 , __horizontalAlignmentForBidi(ALIGNMENT_LEFT)
169 , __isScrollBarVisible(false)
170 , __scrollBarBounds()
172 , __previousScrollBarPos(0.0f)
173 , __previousScrollBarMaxPos(0.0f)
174 , __pActionEventListener(null)
175 , __pCursorTimer(null)
176 , __pFlickAnimationTimer(null)
177 , __pPasswordTimer(null)
179 , __pCursorVisualElement(null)
180 , __pDragAndDropCueVisualElement(null)
181 , __pTextVisualElement(null)
182 , __pTitleTextVisualElement(null)
183 , __pCopyPasteManager(null)
184 , __pFlickAnimation(null)
185 , __pParentForm(null)
186 , __pFullscreenKeypad(null)
187 , __pParentPanel(null)
188 , __pCommandButton(null)
189 , __pInputConnection(null)
190 , __isInputConnectionBound(false)
191 , __sentKeypadEvent(CORE_KEYPAD_EVENT_STATUS_CLOSE)
196 , __isCopyPastePopupMoving(false)
197 , __pressedAbsolutePoint()
198 , __clearIconBounds()
200 , __textObjectBounds()
203 , __previousCursorBounds()
204 , __keypadBounds(0.0f, 0.0f, 0.0f,0.0f)
205 , __pTextObject(null)
206 , __pGuideTextObject(null)
207 , __pTitleTextObject(null)
208 , __titleSlidingAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT)
209 , __textObjectWrap(TEXT_OBJECT_WRAP_TYPE_WORD)
210 , __isTextBlocked(false)
211 , __isGuideTextColorChanged(false)
212 , __isKeypadCommandButtonVisible(false)
213 , __isKeypadCommandButtonUserSetting(false)
214 , __isTextComposing(false)
215 , __isCopyPasteManagerExist(false)
216 , __isCursorChanged(false)
217 , __isCursorInitialized(false)
218 , __isCursorDisabled(false)
219 , __isInitialized(false)
220 , __isMovingCursorByTouchMove(false)
221 , __isTouchMoving(false)
222 , __isTouchPressed(false)
223 , __isClearIconPressed(false)
224 , __isClearIconVisible(false)
225 , __isCursorOpaque(false)
226 , __isTouchReleaseSkipped(false)
227 , __isViewerModeEnabled(false)
228 , __isKeypadNormalNumberStyleEnabled(false)
229 , __isTextCompositionFinished(false)
230 , __isFlexibleHeightFrozen(false)
231 , __isKeypadShowing(false)
232 , __isKeypadHiding(false)
233 , __resizedByKeypadHide(false)
236 , __prevTotalTextHeight(-1.0f)
238 , __composingTextLength(0)
239 , __titleWidth(-1.0f)
240 , __verticalMargin(-1.0f)
241 , __isUSBKeyboardConnected(false)
243 , __isCutLinkParserEnabled(false)
245 , __ContentTextStatus(EDIT_TEXT_STATUS_COMPOSE_NON)
246 , __isAutoShrinkEnabled(false)
247 , __groupStyle(GROUP_STYLE_NONE)
248 , __isFontInitialized(false)
249 , __contentFontSize(0.0f)
250 , __titleFontSize(0.0f)
251 , __defaultTouchMoveThreshold(0.16f)
252 , __contentFontStyle(FONT_STYLE_PLAIN)
253 , __contentTextStyle(TEXT_BOX_TEXT_STYLE_NORMAL)
254 , __titleFontFaceName("")
255 , __isSearchBar(false)
256 , __pCurrentFrame(null)
257 , __pTextFilter(null)
258 , __textBlockMoveLeft(false)
259 , __textBlockMoving(false)
260 , __clipboardConnected(false)
261 , __updateInitialBounds(true)
262 , __blockTextColor(Color(0, 0, 0))
263 , __rowCursorIndex(-1)
264 , __columnCursorIndex(-1)
265 , __isPasswordVisible(false)
266 , __needToCreateCopyPastePopup(false)
267 , __calculatedCursorBounds(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
268 , __dragAndDropStarted(false)
269 , __dragAndDropString("")
270 , __isTouchLongPressed(false)
275 _EditPresenter::OnInputConnectionPanelShowStateChanged(InputConnection& source, InputPanelShowState showState)
277 if (showState == INPUT_PANEL_SHOW_STATE_SHOW)// 1. keypad show 2.usb on&predictive window show
279 __isKeypadHiding = false;
280 __isKeypadShowing = false;
281 __isKeypadExist = true;
283 CheckUSBKeyboardStatus();
285 SysLog(NID_UI_CTRL, "INPUT_PANEL_SHOW_STATE_SHOW[Target:%x][Bound:%d][Usb mode:%d]", this, __isInputConnectionBound, __isUSBKeyboardConnected);
287 if (__isInputConnectionBound)
289 if (__isKeypadCommandButtonVisible && __pCommandButton)
291 SetFooterVisible(false);
294 ChangeLayoutInternal(__pEdit->GetOrientation());
295 AdjustParentPanelHeight(false);
297 ScrollPanelToCursorPosition();
299 if (__isCopyPasteManagerExist)
301 __pCopyPasteManager->CreateCopyPastePopup();
302 __pCopyPasteManager->Show();
306 if (!__pEdit->IsFullScreenKeypadEdit())
310 __pParentForm->Draw();
314 if (__isUSBKeyboardConnected && (__isKeypadCommandButtonVisible && __pCommandButton))
316 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
318 else if (__isKeypadCommandButtonVisible && __pCommandButton && __pCommandButton->GetVisibleState())//already command exist in usb mode
320 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
324 if (GetLastSentKeypadEvent() != CORE_KEYPAD_EVENT_STATUS_OPEN)
326 if (!__isClipboardExist)
328 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
330 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
334 else if (showState == INPUT_PANEL_SHOW_STATE_HIDE)// 1.unbound 2.bounded&usb off -> usb on 3.Flick keypad hide
336 __isKeypadHiding = false;
338 CheckUSBKeyboardStatus();
339 SysLog(NID_UI_CTRL, "INPUT_PANEL_SHOW_STATE_HIDE[Target:%x][Bound:%d][Usb mode:%d]", this, __isInputConnectionBound, __isUSBKeyboardConnected);
341 __isKeypadExist = false;
343 if (__resizedByKeypadHide)
345 __resizedByKeypadHide = false;
349 if (__isCopyPasteManagerExist)
351 InitializeCopyPasteManager();
352 __pTextObject->SetBlock(false);
353 __isTextBlocked = false;
356 if (__isInputConnectionBound && __isUSBKeyboardConnected) // hide callback from external condition(usb mode off->on), focus remaining
358 if (!__isKeypadCommandButtonVisible && !__isClipboardExist)
360 if (__footerVisibleChanged)
362 SetFooterVisible(true);// must be called ahead of DeflateClientRectHeight
366 ChangeLayoutInternal(__pEdit->GetOrientation());
368 if (__isClipboardExist)
370 AdjustParentPanelHeight(false);
374 AdjustParentPanelHeight(true);
377 if (!__pEdit->IsFullScreenKeypadEdit())
381 __pParentForm->Draw();
387 if (__isInputConnectionBound)// keypad hided by back key or prediction hided by usb mode changed(on -> off)
389 if (!__isKeypadCommandButtonVisible && !__isClipboardExist)
391 if (__footerVisibleChanged)
393 SetFooterVisible(true);// must be called ahead of DeflateClientRectHeight
397 FinishTextComposition();
399 ChangeLayoutInternal(__pEdit->GetOrientation());
401 if (__isClipboardExist)
403 AdjustParentPanelHeight(false);
407 AdjustParentPanelHeight(true);
410 if (!__pEdit->IsFullScreenKeypadEdit())
414 __pParentForm->Draw();
418 else// called by focus move or HideKeypad() api call
420 if (__pCommandButton && __isKeypadCommandButtonVisible)
422 SetFooterVisible(true);// must be called ahead of DeflateClientRectHeight
423 __pCommandButton->SetVisibleState(false);
424 __pCommandButton->Invalidate();
427 __isInputConnectionBound = false;
429 AdjustParentPanelHeight(true);
433 SysLog(NID_UI_CTRL, "Form deflate RESET!!!");
434 __pParentForm->DeflateClientRectHeight(0.0f);
437 if (!__pEdit->IsFullScreenKeypadEdit())
441 __pParentForm->Draw();
447 if ((__isKeypadCommandButtonVisible && __pCommandButton) && __isInputConnectionBound)
449 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
451 else if((__isUSBKeyboardConnected && (__isKeypadCommandButtonVisible &&__pCommandButton) && !__isInputConnectionBound) ||
452 (__isUSBKeyboardConnected && __isClipboardExist))
458 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CLOSED);
459 __pEdit->DetachScrollPanelEvent();
461 if (!__isClipboardExist)
463 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
472 _EditPresenter::OnInputConnectionPanelLanguageChanged(InputConnection& source, LanguageCode language)
474 LanguageCode oldLanguageCode;
475 __pEditModel->GetCurrentLanguage(oldLanguageCode);
477 __pEditModel->SetCurrentLanguage(language);
478 __pEdit->SendLanguageEvent(oldLanguageCode, language);
484 _EditPresenter::OnInputConnectionPanelBoundsChanged(InputConnection& source, const Rectangle& bounds)
486 float previousHeight = __keypadBounds.height;
488 CheckUSBKeyboardStatus();
490 if ((__isUSBKeyboardConnected == false) && __isKeypadExist == false)
492 SysLog(NID_UI_CTRL, "OnInputConnectionPanelBoundsChanged skipped - __isUSBKeyboardConnected:(%), __isKeypadExist:(%d)", __isUSBKeyboardConnected, __isKeypadExist);
496 if (CheckKeypadExist(__pEdit->GetOrientation()) == false)//double check keypad Exist
498 SysLog(NID_UI_CTRL, "OnInputConnectionPanelBoundsChanged skipped - Keypad doesn't exist!!");
503 if (IsKeypadRotating(__pEdit->GetOrientation()))
505 SysLog(NID_UI_CTRL, "OnInputConnectionPanelBoundsChanged skipped - Keypad is rotating!!");
506 AdjustParentPanelHeight(true);
511 SysLog(NID_UI_CTRL, "OnInputConnectionPanelBoundsChanged");
512 ChangeLayoutInternal(__pEdit->GetOrientation());
513 AdjustParentPanelHeight(false);
514 ScrollPanelToCursorPosition();
518 __pParentForm->Draw();
521 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
523 if (__isCopyPasteManagerExist)
526 if (__pCopyPasteManager->GetCopyPastePopup())
528 if (previousHeight != bounds.height)
530 __pCopyPasteManager->CreateCopyPastePopup();
533 __pCopyPasteManager->Show();
540 _EditPresenter::OnInputConnectionTextPredictionShowStateChanged(InputConnection& source, bool isShown)
546 _EditPresenter::OnInputConnectionTextPredictionBoundsChanged(InputConnection& source, const Rectangle& bounds)
552 _EditPresenter::OnInputConnectionTextCommitted(InputConnection& source, const String& committedText)
554 OnTextCommitted(committedText);
560 _EditPresenter::OnTextCommitted(const String& commitText)
562 bool isTextComposingFinished = false;
563 char enterText1[2] = {'\n', };
564 char enterText2[2] = {'\r', };
566 if (IsViewModeEnabled() == true)
571 if (IsBlocked() == true)
573 CoreKeypadAction keypadaction = GetKeypadAction();
574 if (keypadaction == CORE_KEYPAD_ACTION_ENTER || !(commitText == enterText1 || commitText == enterText2))
578 GetBlockRange(start, end);
579 __isFlexibleHeightFrozen = true;
580 DeleteText(start, end);
581 __isFlexibleHeightFrozen = false;
586 if (__isCopyPasteManagerExist)
588 InitializeCopyPasteManager();
591 int textLength = commitText.GetLength();
592 int compositionStart = __cursorPos - textLength;
594 if (__isTextComposing == true)
596 __isFlexibleHeightFrozen = true;
597 DeleteText(__cursorPos-__composingTextLength, __cursorPos);
598 __isFlexibleHeightFrozen = false;
600 __isTextComposing = false;
601 __composingTextLength = 0;
602 isTextComposingFinished = true;
605 if (__ContentTextStatus != EDIT_TEXT_STATUS_COMPOSE_NON)
607 __pTextObject->SetFont(__pFont, __cursorPos, __cursorPos+textLength);
608 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
611 if (__pPasswordTimer)
613 ChangePasswordToEchoCharacter(__pTextBuffer, __echoChar);
617 if (commitText == enterText1 || commitText == enterText2)
619 CoreKeypadAction keypadaction = GetKeypadAction();
621 __pEdit->SendKeypadEvent(keypadaction, CORE_KEYPAD_EVENT_STATUS_ENTERACTION);
622 if (keypadaction != CORE_KEYPAD_ACTION_ENTER)
627 if(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
634 char tapText[2] = {'\t', };
635 if (commitText == tapText)
640 // Limitation Protect
641 String insetText = commitText;
642 int currentLength = GetTextLength();
643 int totalLength = currentLength + textLength;
644 int excessCharacterLength = totalLength - __limitLength;
646 if (excessCharacterLength >= 0)
648 textLength -= excessCharacterLength;
651 insetText.Remove(textLength, excessCharacterLength);
659 InsertTextAt(__cursorPos, insetText);
661 ScrollPanelToCursorPosition();
663 if ((__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) && isTextComposingFinished)
665 ReplaceTextIntoPasswordHyphenString();
668 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
673 ChangePasswordToEchoCharacter((compositionStart + textLength), textLength);
675 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
681 _EditPresenter::OnInputConnectionComposingTextChanged(InputConnection& source, const String& composingText, int cursorPosition)
683 OnComposingTextChanged(composingText, cursorPosition);
689 _EditPresenter::OnComposingTextChanged(const String& composingText, int cursorPosition)
691 if (IsViewModeEnabled() == true)
696 if (IsBlocked() == true)
700 GetBlockRange(start, end);
701 __isFlexibleHeightFrozen = true;
702 DeleteText(start, end);
703 __isFlexibleHeightFrozen = false;
707 if (__isCopyPasteManagerExist)
709 InitializeCopyPasteManager();
712 int textLength = composingText.GetLength();
714 if (__isTextComposing == false)
723 int compositionStart = GetCursorPosition();
727 __isTextComposing = false;
729 // FirstText Check Logic
730 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
731 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine);
732 bool isFirstText = false;
733 if (firstTextIndex + 1 == __pTextObject->GetCursorIndex())
738 DeleteText(compositionStart-__composingTextLength, compositionStart);
742 __isCursorChanged = false;
743 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT);
746 __composingTextLength = 0;
750 if (!__isCursorChanged)
752 __isCursorChanged = true;
754 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
760 __isFlexibleHeightFrozen = true;
761 DeleteText(compositionStart-__composingTextLength, compositionStart);
762 __isFlexibleHeightFrozen = false;
766 __composingTextLength = textLength;
767 if (__composingTextLength > 0)
769 __isTextComposing = true;
772 if (__pPasswordTimer)
774 ChangePasswordToEchoCharacter(__pTextBuffer, __echoChar);
778 // Limitation Protect
779 String insetText = composingText;
780 int currentLength = GetTextLength();
781 int totalLength = currentLength + textLength;
782 int excessCharacterLength = totalLength - __limitLength;
784 if (excessCharacterLength >= 0)
786 __composingTextLength -= excessCharacterLength;
787 if (__composingTextLength > 0)
789 insetText.Remove(__composingTextLength, excessCharacterLength);
793 __composingTextLength = 0;
797 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
798 SysTryReturnVoidResult(NID_UI_CTRL, fontImpl != null, E_SYSTEM, "[E_SYSTEM] fontImpl is null.");
799 fontImpl->SetUnderline(true);
800 __pTextObject->SetFont(__pFont, 0, 0);
802 if (__composingTextLength > 0)
804 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE;
807 InsertTextAt(GetCursorPosition(), insetText);
809 fontImpl->SetUnderline(false);// rollback to default content font
810 __pTextObject->SetFont(__pFont, 0, 0);
812 ScrollPanelToCursorPosition();
815 if (__composingTextLength > 0)
817 ChangePasswordToEchoCharacter((GetCursorPosition() - __composingTextLength), __composingTextLength);
820 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
826 _EditPresenter::DeleteSurroundingText(InputConnection& source, int offset, int charCount)
828 OnSurroundingTextDeleted(offset, charCount);
834 _EditPresenter::OnSurroundingTextDeleted(int offset, int charCount)
839 if (IsBlocked() == true)
841 GetBlockRange(start, end);
845 start = __cursorPos + offset;
850 end = start + charCount;
851 if (end > __cursorPos)
857 DeleteText(start, end);
859 if (__isCopyPasteManagerExist)
861 InitializeCopyPasteManager();
864 if (IsBlocked() == true)
871 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
877 _EditPresenter::GetPreviousText(InputConnection& source, String& text, int& cursorPosition)
879 const int SURRONDING_TEXT_SIZE = 5;
880 int stringLength = 0;
883 if (__cursorPos == 0)
890 if (__cursorPos < SURRONDING_TEXT_SIZE)
892 text = GetText(0, __cursorPos - 1);
896 int previousTextSize = 0;
898 for (int index = 0; index < __cursorPos; index++)
901 if (__pTextBuffer[__cursorPos-index-1] != 0x20)
907 if (previousTextSize < SURRONDING_TEXT_SIZE)
909 previousTextSize = SURRONDING_TEXT_SIZE;
912 text = GetText(__cursorPos - previousTextSize, __cursorPos - 1);
915 stringLength = text.GetLength();
916 cursorPosition = stringLength;
923 _EditPresenter::OnClipboardPopupOpened(Tizen::Graphics::Dimension& clipboardPopupSize)
925 FloatDimension floatClipboardPopupSize = _CoordinateSystemUtils::ConvertToFloat(clipboardPopupSize);
927 if (__clipboardConnected)
929 __isClipboardExist = true;
930 FloatRectangle absKeypadBounds;
931 GetKeypadBounds(absKeypadBounds);
932 CheckUSBKeyboardStatus();
934 __clipboardHeight = floatClipboardPopupSize.height;
936 SysLog(NID_UI_CTRL, "clipboard height = %f, [KeypadExist:%d]keypad height = %f", floatClipboardPopupSize.height, __isKeypadExist, absKeypadBounds.height);
938 if (__isKeypadExist) //resize as difference between clipboard height vs keypad height
940 if (floatClipboardPopupSize.height > absKeypadBounds.height)
942 ChangeLayoutInternal(__pEdit->GetOrientation());
943 AdjustParentPanelHeight(false);
944 ScrollPanelToCursorPosition();
948 __pParentForm->Draw();
951 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
956 if (!__isKeypadCommandButtonVisible)
958 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
960 ChangeLayoutInternal(__pEdit->GetOrientation());
961 AdjustParentPanelHeight(false);
962 ScrollPanelToCursorPosition();
966 __pParentForm->Draw();
969 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
973 ChangeLayoutInternal(__pEdit->GetOrientation());
974 AdjustParentPanelHeight(false);
975 ScrollPanelToCursorPosition();
979 __pParentForm->Draw();
982 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
985 if (__isCopyPasteManagerExist)
987 UpdateComponentInformation();
988 __pCopyPasteManager->Show();
996 _EditPresenter::OnClipboardPopupBoundsChanged(Tizen::Graphics::Dimension& clipboardPopupSize)
998 FloatDimension floatClipboardPopupSize = _CoordinateSystemUtils::ConvertToFloat(clipboardPopupSize);
1000 if (__clipboardConnected)
1002 FloatRectangle absKeypadBounds;
1003 GetKeypadBounds(absKeypadBounds);
1004 CheckUSBKeyboardStatus();
1006 __clipboardHeight = floatClipboardPopupSize.height;
1008 SysLog(NID_UI_CTRL, "clipboard height = %f, [KeypadExist:%d]keypad height = %f", floatClipboardPopupSize.height, __isKeypadExist, absKeypadBounds.height);
1010 if (__isKeypadExist)
1012 if (floatClipboardPopupSize.height >= absKeypadBounds.height)
1014 ChangeLayoutInternal(__pEdit->GetOrientation());
1015 AdjustParentPanelHeight(false);
1016 ScrollPanelToCursorPosition();
1020 __pParentForm->Draw();
1023 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1027 ChangeLayoutInternal(__pEdit->GetOrientation());
1028 AdjustParentPanelHeight(false);
1029 ScrollPanelToCursorPosition();
1033 __pParentForm->Draw();
1036 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1041 ChangeLayoutInternal(__pEdit->GetOrientation());
1042 AdjustParentPanelHeight(false);
1043 ScrollPanelToCursorPosition();
1047 __pParentForm->Draw();
1050 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1053 if (__rotated) // Command button should be relocated after rotation in case of no keypad.
1055 if (__isCopyPasteManagerExist)
1057 PostInternalEvent(String(L"ShowCopyPaste"));
1061 else if (__isCopyPasteManagerExist)
1063 __pCopyPasteManager->AdjustBounds();
1071 _EditPresenter::OnClipboardPopupClosed(void)
1073 if (__clipboardConnected)
1075 if (__isCopyPasteManagerExist)
1077 InitializeCopyPasteManager();
1078 __pTextObject->SetBlock(false);
1079 __isTextBlocked = false;
1084 __pClipboard->HidePopup();
1087 __isClipboardExist = false;
1088 FloatRectangle absKeypadBounds;
1089 GetKeypadBounds(absKeypadBounds);
1090 CheckUSBKeyboardStatus();
1092 __clipboardHeight = 0.0f;
1094 SysLog(NID_UI_CTRL, "clipboard closed! [KeypadExist:%d]keypad height = %f", __isKeypadExist, absKeypadBounds.height);
1096 if (__isInputConnectionBound)
1098 ChangeLayoutInternal(__pEdit->GetOrientation());
1101 if (__isKeypadExist)
1103 AdjustParentPanelHeight(false);
1107 __pParentForm->Draw();
1110 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1114 if (__footerVisibleChanged)
1116 SetFooterVisible(true);
1119 AdjustParentPanelHeight(true);
1122 SysLog(NID_UI_CTRL, "Form deflate RESET!!!");
1123 __pParentForm->DeflateClientRectHeight(0.0f);
1124 __pParentForm->Draw();
1127 if (!__isKeypadCommandButtonVisible)
1129 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
1133 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1137 __clipboardConnected = false;
1143 _EditPresenter::~_EditPresenter(void)
1149 _EditPresenter::Dispose(void)
1151 if (__pCurrentFrame)
1153 __pCurrentFrame->RemoveFrameEventListener(*this);
1154 __pCurrentFrame = null;
1157 CheckUSBKeyboardStatus();
1159 if(__latestBoundedContext != (unsigned int)this)//context is already chagned.
1161 __isKeypadHiding = false;
1164 if (__isInputConnectionBound || __isKeypadHiding || __clipboardConnected) //Edit control removed without FocusLost callback or HideKeypad.
1166 if (__clipboardConnected) //Edit control removed after FocusLost or without FocusLost callback.
1168 __pClipboard->HidePopup();
1169 __isClipboardExist = false;
1172 if (__pCommandButton && __isKeypadCommandButtonVisible)
1174 __pCommandButton->SetVisibleState(false);
1176 SetFooterVisible(true);
1178 delete __pCommandButton;
1179 __pCommandButton = null;
1184 SysLog(NID_UI_CTRL, "Form deflate RESET!!!");
1185 __pParentForm->DeflateClientRectHeight(0.0f);
1188 AdjustParentPanelHeight(true);
1190 __isKeypadExist = false;
1192 __latestBoundedContext = null;
1195 __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
1196 __footerVisibleChanged = false;
1200 __pParentPanel->RemoveScrollEventListener(*__pEdit);
1205 __pClipboard->RemoveClipboardPopupEventListener(*this);
1208 if (__pFullscreenKeypad)
1210 __pFullscreenKeypad->Close();
1211 delete __pFullscreenKeypad;
1212 __pFullscreenKeypad = null;
1215 delete __pScrollEffect;
1216 __pScrollEffect = null;
1220 delete[] __pTextBuffer;
1221 __pTextBuffer = null;
1224 delete __pTextString;
1225 __pTextString = null;
1227 delete __pEditModel;
1228 __pEditModel = null;
1232 __pCursorTimer->Cancel();
1233 delete __pCursorTimer;
1234 __pCursorTimer = null;
1237 if (__pInputConnection)
1239 delete __pInputConnection;
1240 __pInputConnection = null;
1243 delete __pTextObject;
1244 __pTextObject = null;
1246 delete __pGuideTextObject;
1247 __pGuideTextObject = null;
1249 delete __pTitleTextObject;
1250 __pTitleTextObject = null;
1252 if (__pPasswordTimer)
1254 __pPasswordTimer->Cancel();
1255 delete __pPasswordTimer;
1256 __pPasswordTimer = null;
1259 if (__pScrollBar != null && __pEdit != null)
1261 __pEdit->DetachSystemChild(*__pScrollBar);
1262 delete __pScrollBar;
1263 __pScrollBar = null;
1266 if (__pFlickAnimationTimer)
1268 __pFlickAnimationTimer->Cancel();
1269 delete __pFlickAnimationTimer;
1270 __pFlickAnimationTimer = null;
1273 if (__pTitleSlidingTimer)
1275 __pTitleSlidingTimer->Cancel();
1276 delete __pTitleSlidingTimer;
1277 __pTitleSlidingTimer = null;
1280 delete __pFlickAnimation;
1281 __pFlickAnimation = null;
1283 if (__pCopyPasteManager != null)
1285 delete __pCopyPasteManager;
1286 __pCopyPasteManager = null;
1289 if (__pTextVisualElement)
1291 __pTextVisualElement->Destroy();
1292 __pTextVisualElement = null;
1295 if (__pCursorVisualElement)
1297 __pCursorVisualElement->Destroy();
1298 __pCursorVisualElement = null;
1301 if (__pDragAndDropCueVisualElement)
1303 __pDragAndDropCueVisualElement->Destroy();
1304 __pDragAndDropCueVisualElement = null;
1307 if (__pTitleTextVisualElement)
1309 __pTitleTextVisualElement->Destroy();
1310 __pTitleTextVisualElement = null;
1317 _EditPresenter::IsKeypadExist(void) const
1319 return __isKeypadExist;
1323 _EditPresenter::IsClipboardExist(void) const
1325 return __isClipboardExist;
1329 _EditPresenter::CheckUSBKeyboardStatus(void)
1331 if (__pInputConnection->CheckUSBKeyboardStatus())
1333 __isUSBKeyboardConnected = true;
1337 __isUSBKeyboardConnected = false;
1344 _EditPresenter::IsUsbKeyboardConnected(void) const
1346 if (__pInputConnection->CheckUSBKeyboardStatus())
1357 _EditPresenter::IsCurrentFocused(void)
1359 _ControlManager* pControlManager = _ControlManager::GetInstance();
1361 if (pControlManager)
1363 _Control* pControl = pControlManager->GetFocusControl();
1364 if (pControl != __pEdit)
1375 return __pEdit->IsInternalFocused();
1380 _EditPresenter::InitializeFocusedCondition(void)
1384 __pParentForm = GetParentForm();
1386 if (!__pParentForm && __isKeypadCommandButtonVisible)
1388 __isKeypadCommandButtonVisible = false;
1392 if (!__pTextVisualElement)
1394 result r = E_SUCCESS;
1395 __pTextVisualElement = new (std::nothrow) _VisualElement;
1396 SysTryReturn(NID_UI_CTRL, __pTextVisualElement != null, false, E_OUT_OF_MEMORY, "Memory allocation failed.");
1398 r = __pTextVisualElement->Construct();
1399 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r));
1401 __pTextVisualElement->SetSurfaceOpaque(false);
1402 __pTextVisualElement->SetImplicitAnimationEnabled(false);
1404 __pTextVisualElement->SetShowState(true);
1406 _VisualElement* pEditVisualElement = __pEdit->GetVisualElement();
1407 SysTryCatch(NID_UI_CTRL, pEditVisualElement, , r = E_SYSTEM, "[E_SYSTEM] Unable to get root visual element.");
1409 pEditVisualElement->AttachChild(*__pTextVisualElement);
1410 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r));
1413 __isCursorOpaque = true;
1418 __pTextVisualElement->Destroy();
1419 __pTextVisualElement = null;
1425 _EditPresenter::SetSentKeypadEvent(CoreKeypadEventStatus sentKeypadEvent)
1427 __sentKeypadEvent = sentKeypadEvent;
1430 CoreKeypadEventStatus
1431 _EditPresenter::GetLastSentKeypadEvent(void)
1433 return __sentKeypadEvent;
1438 _EditPresenter::CreateInstanceN(void)
1440 _EditPresenter* pPresenter = new (std::nothrow) _EditPresenter;
1441 if (pPresenter == null)
1443 SetLastResult(E_OUT_OF_MEMORY);
1451 _EditPresenter::Initialize(const _Control& control)
1453 result r = E_SUCCESS;
1454 _EditModel* pEditModel = null;
1455 _VisualElement* pEditVisualElement = null;
1456 TextSimple* pSimpleText = null;
1457 _ControlManager* pControlManager = _ControlManager::GetInstance();
1458 _Window* pWindow = null;
1460 __pEdit = dynamic_cast<_Edit*>(const_cast<_Control*>(&control));
1461 SysAssertf(__pEdit != null, "__pEdit is null");
1463 __pTextObject = new (std::nothrow) TextObject;
1464 if (__pTextObject == null)
1466 r = E_OUT_OF_MEMORY;
1470 __pTextObject->Construct();
1471 pSimpleText = new (std::nothrow)TextSimple(null, 0, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1472 __pTextObject->AppendElement(*pSimpleText);
1474 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
1476 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1477 if (__pEdit->IsFullScreenKeypadEdit())
1479 __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
1483 __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
1485 __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
1486 __textObjectWrap = TEXT_OBJECT_WRAP_TYPE_NONE;
1490 __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
1491 __pTextObject->SetWrap(__textObjectWrap);
1494 __pTextString = new (std::nothrow) String;
1495 SysTryCatch(NID_UI_CTRL, __pTextString, , r = E_OUT_OF_MEMORY, "Memory allocation failed.");
1498 if (__pFont == null)
1500 _ControlOrientation orientation = __pEdit->GetOrientation();
1501 float defaultFontSize = 0.0f;
1502 GET_SHAPE_CONFIG(EDIT::DEFAULT_FONT_SIZE, orientation, defaultFontSize);
1504 __contentFontSize = defaultFontSize;
1505 __contentFontStyle = FONT_STYLE_PLAIN;
1507 __pFont = __pEdit->GetFallbackFont();
1509 r = GetLastResult();
1510 SysTryReturn(NID_UI_CTRL, __pFont, r, r, "[%s] Propagating.", GetErrorMessage(r));
1512 __titleFontFaceName = __pFont->GetFaceName();
1514 __isFontInitialized = true;
1515 __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
1516 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
1519 __pScrollEffect = new (std::nothrow) _EditScrollEffectInfo;
1520 SysTryCatch(NID_UI_CTRL, __pScrollEffect, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1522 for (int i = 0; i < EDIT_SCROLLFRAME_MAX; i++)
1524 __pScrollEffect->touchScrollFrameLevel[i] = 2 + i;
1527 __pScrollEffect->previousY = -1.0f;
1528 __pScrollEffect->currentY = -1.0f;
1529 __pScrollEffect->previousX = -1.0f;
1530 __pScrollEffect->currentX = -1.0f;
1531 __pScrollEffect->previousAbsX = -1.0f;
1532 __pScrollEffect->currentAbsX = -1.0f;
1533 __pScrollEffect->previousAbsY = -1.0f;
1534 __pScrollEffect->currentAbsY = -1.0f;
1535 __pScrollEffect->cursorPosition = -1;
1537 pEditModel = new (std::nothrow) _EditModel;
1538 SysTryCatch(NID_UI_CTRL, pEditModel, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1540 SetModel(*pEditModel);
1545 if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)
1547 SetViewModeEnabled(true);
1548 __isCutLinkParserEnabled = true;
1552 SetKeypadEnabled(true);
1553 __isCutLinkParserEnabled = false;
1556 if (__pEdit->GetInputStyle() == INPUT_STYLE_FULLSCREEN)
1558 SetCursorDisabled(true);
1561 __initialBounds = __pEdit->GetBoundsF();
1563 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
1565 __pCursorVisualElement = new (std::nothrow) _VisualElement;
1566 SysTryCatch(NID_UI_CTRL, __pCursorVisualElement, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1568 r = __pCursorVisualElement->Construct();
1569 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r));
1571 __pCursorVisualElement->SetSurfaceOpaque(false);
1572 __pCursorVisualElement->SetImplicitAnimationEnabled(false);
1574 __pDragAndDropCueVisualElement = new (std::nothrow) _VisualElement;
1575 SysTryCatch(NID_UI_CTRL, __pDragAndDropCueVisualElement, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1577 r = __pDragAndDropCueVisualElement->Construct();
1578 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r));
1580 __pDragAndDropCueVisualElement->SetSurfaceOpaque(false);
1581 __pDragAndDropCueVisualElement->SetImplicitAnimationEnabled(false);
1583 pEditVisualElement = __pEdit->GetVisualElement();
1584 SysTryCatch(NID_UI_CTRL, pEditVisualElement, , r = E_SYSTEM, "[E_SYSTEM] Unable to get root visual element.");
1586 __pCursorVisualElement->SetShowState(true);
1587 __pDragAndDropCueVisualElement->SetShowState(false);
1589 r = pEditVisualElement->AttachChild(*__pCursorVisualElement);
1590 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r));
1592 r = pEditVisualElement->AttachChild(*__pDragAndDropCueVisualElement);
1593 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r));
1595 __pInputConnection = _InputConnectionImpl::CreateInputConnectionImplN(null);
1596 SysTryCatch(NID_UI_CTRL, __pInputConnection, , r = E_SYSTEM, "[E_SYSTEM] Unable to create an instance .");
1598 __pInputConnection->Initialize(*__pEdit, *this, *this);
1600 __pTextObject->SetBounds(__textObjectBounds);
1601 __pTextObject->HideRearSpace(TEXT_OBJECT_SPACE_HIDE_TYPE_NONE);
1603 pWindow = pControlManager->GetCurrentFrame();
1606 __pCurrentFrame = dynamic_cast<_Frame*>(pWindow);
1607 if (__pCurrentFrame)
1609 __pCurrentFrame->AddFrameEventListener(*this);
1613 __pClipboard = _Clipboard::GetInstance();
1617 __pClipboard->AddClipboardPopupEventListener(*this);
1628 _EditPresenter::InitializeAtFirstDrawing(void)
1630 result r = E_SUCCESS;
1634 InitializeParentPanel();
1636 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT);
1638 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false && (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE))
1640 AdjustFlexibleHeight();
1643 ReplaceTextIntoPasswordHyphenString();
1645 if (__pEdit->IsViewModeEnabled())
1647 __pEdit->SetCursorPosition(0);
1650 __isInitialized = true;
1656 _EditPresenter::DrawBackgroundBitmap(Canvas& canvas, bool focused)
1658 if (!DrawChangeableBackground(canvas, focused, 0, 0))
1667 _EditPresenter::DrawChangeableBackground(Canvas& canvas, bool focused, int bitmapId, int effectBitmapId, bool outLine, int outlineBitmapId)
1669 result r = E_SUCCESS;
1670 FloatRectangle editRect(0.0f, 0.0f, __pEdit->GetBoundsF().width, __pEdit->GetBoundsF().height);
1672 Bitmap* pEditBgBitmap = null;
1673 Bitmap* pEditBgEffectBitmap = null;
1674 Bitmap* pReplacementColorBackgroundBitmap = null;
1675 bool borderRoundEnable = __pEdit->IsBorderRoundStyleEnabled();
1676 EditStatus editStatus = GetCurrentStatus();
1678 pEditBgBitmap = __pEdit->GetDefaultBackgroundBitmap(editStatus);
1680 if (borderRoundEnable)
1682 pEditBgBitmap = null;
1683 r = GET_BITMAP_CONFIG_N(EDIT::BG_ROUND_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pEditBgBitmap);
1684 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap");
1687 bitmapColor = __pEdit->GetColor(editStatus);
1688 if (__groupStyle != GROUP_STYLE_NONE)
1690 GET_COLOR_CONFIG(PANEL::GROUPED_STYLE_BG_NORMAL, bitmapColor);
1693 pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pEditBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), bitmapColor);
1694 if (pReplacementColorBackgroundBitmap)
1696 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pReplacementColorBackgroundBitmap))
1698 canvas.DrawNinePatchedBitmap(editRect, *pReplacementColorBackgroundBitmap);
1702 canvas.DrawBitmap(editRect, *pReplacementColorBackgroundBitmap);
1706 if ((!__pEdit->IsFullScreenKeypadEdit() && __groupStyle != GROUP_STYLE_NONE) || GetSearchBarFlag())
1708 pEditBgEffectBitmap = __pEdit->GetDefaultBackgroundEffectBitmap();
1710 if (pEditBgEffectBitmap)
1712 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pEditBgEffectBitmap))
1714 canvas.DrawNinePatchedBitmap(editRect, *pEditBgEffectBitmap);
1718 canvas.DrawBitmap(editRect, *pEditBgEffectBitmap);
1723 if (borderRoundEnable)
1727 delete pEditBgBitmap;
1728 pEditBgBitmap = null;
1731 if (pEditBgEffectBitmap)
1733 delete pEditBgEffectBitmap;
1734 pEditBgEffectBitmap = null;
1737 delete pReplacementColorBackgroundBitmap;
1738 pReplacementColorBackgroundBitmap = null;
1742 delete pEditBgBitmap;
1748 _EditPresenter::DrawBackground(Canvas& canvas, bool drawTitleText)
1750 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
1752 return DrawSingleLineBackground(canvas, drawTitleText);
1755 FloatRectangle editRect(0.0f, 0.0f, __pEdit->GetBoundsF().width, __pEdit->GetBoundsF().height);
1757 EditStatus editStatus = GetCurrentStatus();
1759 Bitmap* pEditBgBitmap = __pEdit->GetBackgroundBitmap(editStatus);
1763 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pEditBgBitmap))
1765 canvas.DrawNinePatchedBitmap(editRect, *pEditBgBitmap);
1769 canvas.DrawBitmap(editRect, *pEditBgBitmap);
1774 DrawBackgroundBitmap(canvas, IsCurrentFocused());
1777 DrawFocusRing(canvas);
1781 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_TOP) || (__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_LEFT))
1791 _EditPresenter::DrawTitleText()
1793 result r = E_SUCCESS;
1794 if (__titleText == -1)
1800 TextObjectActionType titleAction;
1801 Canvas* pTitleTextCanvas = null;
1802 _VisualElement* pRootElement = __pEdit->GetVisualElement();
1803 SysTryReturn(NID_UI_CTRL, pRootElement, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get root visual element.");
1805 if (!__pTitleTextVisualElement)
1807 __pTitleTextVisualElement = new (std::nothrow) _VisualElement();
1808 SysTryReturnResult(NID_UI_CTRL, __pTitleTextVisualElement, E_OUT_OF_MEMORY, "Memory allocation failed.");
1810 r = __pTitleTextVisualElement->Construct();
1811 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r = E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to construct _VisualElement.");
1813 __pTitleTextVisualElement->SetImplicitAnimationEnabled(false);
1814 __pTitleTextVisualElement->SetShowState(true);
1816 r = pRootElement->AttachChild(*__pTitleTextVisualElement);
1817 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1820 __pTitleTextVisualElement->SetBounds(__titleBounds);
1822 pTitleTextCanvas = __pTitleTextVisualElement->GetCanvasN();
1823 SysTryCatch(NID_UI_CTRL, pTitleTextCanvas, , r, "[%s] Propagating.", GetErrorMessage(r));
1825 pTitleTextCanvas->SetBackgroundColor(Color(0));
1826 pTitleTextCanvas->Clear();
1828 titleAction = __pTitleTextObject->GetAction();
1829 if (IsCurrentFocused() == true)
1831 __pTitleTextObject->SetForegroundColor(__pEdit->GetTitleTextColor(EDIT_STATUS_HIGHLIGHTED), 0, __pTitleTextObject->GetTextLength());
1833 if (titleAction != __titleSlidingAction)
1835 __pTitleTextObject->SetAction(__titleSlidingAction);
1836 __pTitleTextObject->Compose();
1839 __pTitleTextObject->SetBounds(FloatRectangle(0.0f, 0.0f, __titleBounds.width, __titleBounds.height));
1840 __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pTitleTextCanvas));
1842 StopTitleSlidingTimer();
1843 if (__pTitleTextObject->IsActionOn() == true)
1845 StartTitleSlidingTimer();
1850 __pTitleTextObject->SetForegroundColor(__pEdit->GetTitleTextColor(GetCurrentStatus()), 0, __pTitleTextObject->GetTextLength());
1852 if (titleAction != TEXT_OBJECT_ACTION_TYPE_ABBREV)
1854 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1857 __pTitleTextObject->SetBounds(FloatRectangle(0.0f, 0.0f, __titleBounds.width, __titleBounds.height));
1858 __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pTitleTextCanvas));
1861 delete pTitleTextCanvas;
1866 __pTitleTextVisualElement->Destroy();
1867 __pTitleTextVisualElement = null;
1873 _EditPresenter::DrawText(void)
1875 Canvas* pCanvas = null;
1877 // In case of unfocused and touch moving
1878 if (__isTouchMoving && !__pTextVisualElement)
1880 result r = E_SUCCESS;
1881 __pTextVisualElement = new (std::nothrow) _VisualElement;
1882 SysTryReturnVoidResult(NID_UI_CTRL, __pTextVisualElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1884 r = __pTextVisualElement->Construct();
1885 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r));
1887 __pTextVisualElement->SetSurfaceOpaque(false);
1888 __pTextVisualElement->SetImplicitAnimationEnabled(false);
1890 __pTextVisualElement->SetShowState(true);
1892 _VisualElement* pEditVisualElement = __pEdit->GetVisualElement();
1893 SysTryCatch(NID_UI_CTRL, pEditVisualElement, , r = E_SYSTEM, "[E_SYSTEM] Unable to get root visual element.");
1895 pEditVisualElement->AttachChild(*__pTextVisualElement);
1896 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r));
1898 pCanvas = __pEdit->GetCanvasN();
1899 SysTryCatch(NID_UI_CTRL, pCanvas, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1901 pCanvas->SetBackgroundColor(Color(0));
1902 r = pCanvas->Clear();
1903 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1905 DrawBackground(*pCanvas);
1911 if (__pTextVisualElement)
1913 FloatRectangle editBounds = __pEdit->GetBoundsF();
1914 __pTextVisualElement->SetOpacity(1.0f);
1915 __pTextVisualElement->SetBounds(FloatRectangle(0.0f, 0.0f, editBounds.width, editBounds.height));
1916 pCanvas = __pTextVisualElement->GetCanvasN();
1917 if (pCanvas == null)
1921 pCanvas->SetBackgroundColor(Color(0));
1924 if (__pEdit->GetEditStyle() & EDIT_STYLE_CLEAR)
1926 if (GetSearchBarFlag()) //SearchBar
1928 if (__pTextString->GetLength() == 0)
1930 if (__isClearIconVisible)
1932 __isClearIconVisible = false;
1933 AdjustTextBounds(__isClearIconVisible);
1938 if (!__isClearIconVisible)
1940 __isClearIconVisible = true;
1941 AdjustTextBounds(__isClearIconVisible);
1944 DrawClearIcon(*pCanvas);
1949 if (IsCurrentFocused() == true)
1951 if (__pTextString->GetLength() == 0)
1953 if (__isClearIconVisible)
1955 __isClearIconVisible = false;
1956 AdjustTextBounds(__isClearIconVisible);
1961 if (!__isClearIconVisible)
1963 __isClearIconVisible = true;
1964 AdjustTextBounds(__isClearIconVisible);
1967 DrawClearIcon(*pCanvas);
1972 if (__isClearIconVisible)
1974 __isClearIconVisible = false;
1975 AdjustTextBounds(__isClearIconVisible);
1989 __pTextVisualElement->Destroy();
1990 __pTextVisualElement = null;
2002 _EditPresenter::DrawText(Canvas& canvas)
2004 result r = E_SUCCESS;
2006 if (__pEdit->GetEnableState() == false)
2008 __pTextObject->SetAlternateLookEnabled(true);
2009 Color tempColor = __pEdit->GetTextColor(EDIT_STATUS_DISABLED);
2010 __pTextObject->SetAlternativeForegroundColor(tempColor);
2014 __pTextObject->SetAlternateLookEnabled(false);
2018 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
2020 return DrawTextForEntireFontSetting(canvas);
2023 // initital guide text
2024 if (IsGuideTextActivated())
2026 __pGuideTextObject->SetForegroundColor(__pEdit->GetGuideTextColor(), 0, __pGuideTextObject->GetTextLength());
2028 if (__isGuideTextColorChanged == true && __pEdit->IsSettingGuideTextColor() == false)
2030 __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_NORMAL), 0, __pGuideTextObject->GetTextLength());
2031 __pGuideTextObject->SetBounds(__textObjectBounds);
2032 __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
2033 __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_DISABLED), 0, __pGuideTextObject->GetTextLength());
2034 __isGuideTextColorChanged = false;
2038 __pGuideTextObject->SetBounds(__textObjectBounds);
2039 __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
2043 if (GetTextLength() <= 0)
2049 EditStatus editStatus = GetCurrentStatus();
2051 __pTextObject->SetForegroundColor(__pEdit->GetTextColor(editStatus), 0, __pTextObject->GetTextLength());
2052 if (__isTextBlocked)
2054 __pTextObject->SetForegroundColor(__blockTextColor, __blockStartPos, __cursorPos - __blockStartPos);
2057 if (__isTextBlocked == true && editStatus == EDIT_STATUS_HIGHLIGHTED)
2059 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED), 0, __pTextObject->GetTextLength());
2060 __pTextObject->SetBlock(true);
2061 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
2063 else if (__isTextBlocked == true && editStatus == EDIT_STATUS_PRESSED)
2065 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_PRESSED), 0, __pTextObject->GetTextLength());
2066 __pTextObject->SetBlock(true);
2067 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
2069 else if (__isTextBlocked == true && editStatus == EDIT_STATUS_NORMAL)
2071 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_NORMAL), 0, __pTextObject->GetTextLength());
2072 __pTextObject->SetBlock(true);
2073 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
2077 __pTextObject->SetBlock(false);
2078 __isTextBlocked = false;
2081 UpdateComponentInformation();
2083 __pTextObject->SetBounds(__textObjectBounds);
2084 __pTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
2086 if (__isTextBlocked == true && editStatus == EDIT_STATUS_HIGHLIGHTED)
2088 __pTextObject->SetBackgroundColor(Color::GetColor(COLOR_ID_BLACK), 0, __pTextObject->GetTextLength());
2091 DrawTextBlockLine(canvas);
2093 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
2099 _EditPresenter::DrawTextBlockLine(Canvas& canvas)
2101 if (!__isTextBlocked)
2105 int leftHandlerCursorPos = 0;
2106 int rightHandlerCursorPos = 0;
2107 int leftRowIndex = -1;
2108 int leftColumnIndex = -1;
2109 int rightRowIndex = -1;
2110 int rightColumnIndex = -1;
2112 Color textBlockLineColor;
2113 GET_COLOR_CONFIG(EDIT::CURSOR_NORMAL, textBlockLineColor);
2115 FloatRectangle cursorBounds;
2116 FloatRectangle textObjectBounds = __textObjectBounds;
2117 textObjectBounds.x -= 1;
2118 textObjectBounds.width = textObjectBounds.width + 2;
2120 if (__pCopyPasteManager)
2122 __pCopyPasteManager->GetHandlerRowColumnIndex(false, true, leftRowIndex, leftColumnIndex);
2123 __pCopyPasteManager->GetHandlerRowColumnIndex(false, false, rightRowIndex, rightColumnIndex);
2124 leftHandlerCursorPos = __pCopyPasteManager->GetHandlerCursorPosition(_EditCopyPasteManager::HANDLER_TYPE_LEFT);
2125 rightHandlerCursorPos = __pCopyPasteManager->GetHandlerCursorPosition(_EditCopyPasteManager::HANDLER_TYPE_RIGHT);
2127 if (leftRowIndex != -1 && leftColumnIndex != -1)
2129 CalculateCursorBounds(__textObjectBounds, cursorBounds, leftRowIndex, leftColumnIndex);
2133 CalculateCursorBounds(__textObjectBounds, cursorBounds, leftHandlerCursorPos);
2135 if (cursorBounds.x != -1)
2137 cursorBounds.x -= 1;
2138 cursorBounds = cursorBounds.GetIntersection(textObjectBounds);
2139 canvas.FillRectangle(textBlockLineColor, cursorBounds);
2141 if (rightRowIndex != -1 && rightColumnIndex != -1)
2143 CalculateCursorBounds(__textObjectBounds, cursorBounds, rightRowIndex, rightColumnIndex);
2147 CalculateCursorBounds(__textObjectBounds, cursorBounds, rightHandlerCursorPos);
2149 if (cursorBounds.x != -1 && cursorBounds.x <= __textObjectBounds.x + __textObjectBounds.width)
2151 cursorBounds.x -= 1;
2152 cursorBounds = cursorBounds.GetIntersection(textObjectBounds);
2153 canvas.FillRectangle(textBlockLineColor, cursorBounds);
2159 _EditPresenter::DrawTextForEntireFontSetting(Canvas& canvas)
2161 result r = E_SUCCESS;
2163 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) && IsCurrentFocused() == false)
2165 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
2169 if (__pTextObject->GetAction() != TEXT_OBJECT_ACTION_TYPE_NONE)
2171 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE);
2172 __isCursorChanged = true;
2176 // initital guide text
2177 if (IsGuideTextActivated())
2179 __pGuideTextObject->SetForegroundColor(__pEdit->GetGuideTextColor(), 0, __pGuideTextObject->GetTextLength());
2181 if (__isGuideTextColorChanged == true && __pEdit->IsSettingGuideTextColor() == false)
2183 __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_NORMAL), 0, __pGuideTextObject->GetTextLength());
2184 __pGuideTextObject->SetBounds(__textObjectBounds);
2185 __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
2186 __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_DISABLED), 0, __pGuideTextObject->GetTextLength());
2187 __isGuideTextColorChanged = false;
2191 __pGuideTextObject->SetBounds(__textObjectBounds);
2192 __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
2196 if (GetTextLength() <= 0)
2202 EditStatus editStatus = GetCurrentStatus();
2204 if (IsCurrentFocused() == false)
2206 if (__isCursorChanged == true)
2208 if (AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT) == true)
2210 __pTextObject->Compose();
2213 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD))
2215 __pTextObject->SetFirstDisplayLineIndexFromTextIndex(0);
2217 __pTextObject->SetForegroundColor(__pEdit->GetTextColor(editStatus), 0, __pTextObject->GetTextLength());
2218 __pTextObject->SetBlock(false);
2223 int lengthRange = 0;
2225 __pTextObject->GetRange(startRange, lengthRange);
2226 __pTextObject->SetRange(0, GetTextLength());
2227 __pTextObject->SetForegroundColor(__pEdit->GetTextColor(editStatus), 0, __pTextObject->GetTextLength());
2228 if (__isTextBlocked)
2230 __pTextObject->SetForegroundColor(__blockTextColor, __blockStartPos, __cursorPos - __blockStartPos);
2233 if (IsBlocked() == true && editStatus == EDIT_STATUS_HIGHLIGHTED)
2235 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED), 0, __pTextObject->GetTextLength());
2236 __pTextObject->SetBlock(true);
2237 __pTextObject->SetRange(__blockStartPos, __cursorPos - __blockStartPos);
2239 else if (__isTextBlocked == true && editStatus == EDIT_STATUS_PRESSED)
2241 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_PRESSED), 0, __pTextObject->GetTextLength());
2242 __pTextObject->SetBlock(true);
2243 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
2245 else if (__isTextBlocked == true && editStatus == EDIT_STATUS_NORMAL)
2247 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_NORMAL), 0, __pTextObject->GetTextLength());
2248 __pTextObject->SetBlock(true);
2249 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
2253 __pTextObject->SetBlock(false);
2254 __isTextBlocked = false;
2257 UpdateComponentInformation();
2260 __pTextObject->SetBounds(__textObjectBounds);
2261 __pTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
2263 DrawTextBlockLine(canvas);
2269 _EditPresenter::DrawSingleLineBackground(Canvas& canvas, bool drawTitleText)
2271 FloatRectangle editField(0.0f, 0.0f, __pEdit->GetBoundsF().width, __pEdit->GetBoundsF().height);
2272 EditStatus editStatus = GetCurrentStatus();
2274 Bitmap* pEditBgBitmap = __pEdit->GetBackgroundBitmap(editStatus);
2278 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pEditBgBitmap))
2280 canvas.DrawNinePatchedBitmap(editField, *pEditBgBitmap);
2284 canvas.DrawBitmap(editField, *pEditBgBitmap);
2289 DrawSingleLineBackgroundBitmap(canvas, IsCurrentFocused());
2292 DrawFocusRing(canvas);
2296 if (((__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_LEFT) && !(__titleText.GetLength() == 0)) || (__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_TOP))
2307 _EditPresenter::DrawSingleLineBackgroundBitmap(Canvas& canvas, bool focused)
2309 if (__isTouchPressed)
2311 DrawChangeableBackground(canvas, focused, 0, 0);
2317 DrawChangeableBackground(canvas, focused, 0, 0, true, 0);
2321 bool tmpFocused = focused;
2322 DrawChangeableBackground(canvas, tmpFocused, 0, 0);
2330 _EditPresenter::DrawClearIcon(Canvas& canvas)
2332 result r = E_SUCCESS;
2334 float clearIconWidth = 0.0f;
2335 float clearIconHeight = 0.0f;
2336 float cursorWidth = 0.0f;
2338 _ControlOrientation orientation = __pEdit->GetOrientation();
2339 GET_SHAPE_CONFIG(EDIT::CLEAR_ICON_WIDTH, orientation, clearIconWidth);
2340 GET_SHAPE_CONFIG(EDIT::CLEAR_ICON_HEIGHT, orientation, clearIconHeight);
2341 GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorWidth);
2343 if (__pTextString->GetLength() == 0)
2348 Bitmap* pEditBitmapClear = null;
2349 Color editClearIconColor;
2351 if (!__pEdit->IsEnabled())
2353 GET_COLOR_CONFIG(EDIT::CLEAR_ICON_DISABLED, editClearIconColor);
2354 r = GET_REPLACED_BITMAP_CONFIG_N(EDIT::CLEAR_ICON_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, editClearIconColor, pEditBitmapClear);
2356 if (pEditBitmapClear == null)
2361 else if (__isClearIconPressed)
2363 GET_COLOR_CONFIG(EDIT::CLEAR_ICON_PRESSED, editClearIconColor);
2364 r = GET_REPLACED_BITMAP_CONFIG_N(EDIT::CLEAR_ICON_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, editClearIconColor, pEditBitmapClear);
2366 if (pEditBitmapClear == null)
2373 GET_COLOR_CONFIG(EDIT::CLEAR_ICON_NORMAL, editClearIconColor);
2374 r = GET_REPLACED_BITMAP_CONFIG_N(EDIT::CLEAR_ICON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, editClearIconColor, pEditBitmapClear);
2375 if (pEditBitmapClear == null)
2381 FloatRectangle textRect = __textObjectBounds;
2382 FloatRectangle afterClearIconRect(textRect.x + textRect.width + cursorWidth, textRect.y + (textRect.height - clearIconHeight) / 2.0f, clearIconWidth, clearIconHeight);
2383 FloatRectangle editBounds = __pEdit->GetBoundsF();
2385 if (__clearIconBounds != afterClearIconRect)
2387 __clearIconBounds = afterClearIconRect;
2388 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_CLEAR_ICON);
2391 if (editBounds.height < clearIconHeight)
2393 __clearIconBounds.y = textRect.y;
2396 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pEditBitmapClear))
2398 r = canvas.DrawNinePatchedBitmap(__clearIconBounds, *pEditBitmapClear);
2402 r = canvas.DrawBitmap(__clearIconBounds, *pEditBitmapClear);
2405 if (pEditBitmapClear)
2407 delete pEditBitmapClear;
2408 pEditBitmapClear = null;
2415 _EditPresenter::Draw(void)
2417 result r = E_SUCCESS;
2419 if (__isInitialized == false)
2421 r = InitializeAtFirstDrawing();
2422 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Faild to initialize.");
2424 if (IsCurrentFocused() == true && __isInputConnectionBound == false)
2426 if (IsViewModeEnabled() == false)
2428 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
2434 ShowFullscreenKeypad();
2440 //Do not change the bounds of the edit control after acquiring a canvas.
2441 Canvas* pCanvas = __pEdit->GetCanvasN();
2442 SysTryReturnResult(NID_UI_CTRL, pCanvas, E_OUT_OF_MEMORY, "Memory allocation failed.");
2444 __isCursorOpaque = true;
2446 pCanvas->SetBackgroundColor(Color(0));
2447 r = pCanvas->Clear();
2448 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2450 DrawBackground(*pCanvas);
2452 if (__pTextVisualElement)
2459 if (__pEdit->GetEditStyle() & EDIT_STYLE_CLEAR)
2461 if (GetSearchBarFlag()) //SearchBar
2463 if (__pTextString->GetLength() == 0)
2465 if (__isClearIconVisible)
2467 __isClearIconVisible = false;
2468 AdjustTextBounds(__isClearIconVisible);
2473 if (!__isClearIconVisible)
2475 __isClearIconVisible = true;
2476 AdjustTextBounds(__isClearIconVisible);
2479 DrawClearIcon(*pCanvas);
2484 if (IsCurrentFocused() == true)
2486 if (__pTextString->GetLength() == 0)
2488 if (__isClearIconVisible)
2490 __isClearIconVisible = false;
2491 AdjustTextBounds(__isClearIconVisible);
2496 if (!__isClearIconVisible)
2498 __isClearIconVisible = true;
2499 AdjustTextBounds(__isClearIconVisible);
2502 DrawClearIcon(*pCanvas);
2507 if(__isClearIconVisible)
2509 __isClearIconVisible = false;
2510 AdjustTextBounds(__isClearIconVisible);
2519 RestoreCopyPasteManager();
2521 if (__isCopyPasteManagerExist)
2523 __pCopyPasteManager->Show();
2531 //To avoid resizing to Flexible bounds on User SetBounds in Non-focussed mode
2532 if (IsFocused() || (!__isAutoShrinkEnabled))
2534 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
2536 AdjustFlexibleHeight();
2551 _EditPresenter::RestoreCopyPasteManager(void)
2553 if (__rotated && !__clipboardConnected) // Command button should be relocated after rotation in case of no keypad.
2555 if (__isCopyPasteManagerExist)
2557 PostInternalEvent(String(L"ShowCopyPaste"));
2564 _EditPresenter::ConvertLinkType(void)
2566 if (__isCutLinkParserEnabled == false || IsViewModeEnabled() == false)
2571 unsigned long autoLinkMask = GetAutoLinkMask();
2572 bool isChangingCutLink = false;
2573 EditCutLinkType editLinkType = EDIT_LINK_TYPE_INVALID;
2574 TextCutLinkParser cutlinkParser;
2575 cutlinkParser.SetCutLinkMask(autoLinkMask);
2576 TextLinkInfo* pLinkInfo = cutlinkParser.Parse(__pTextBuffer, wcslen(__pTextBuffer), 0);
2577 TextLinkInfo* pNextLinkInfo = null;
2578 int cursorPos = __cursorPos;
2580 __isCutLinkParserEnabled = false;
2582 while (pLinkInfo != null)
2584 if (IsViewModeEnabled() == true)
2586 switch (pLinkInfo->linkType)
2589 if (autoLinkMask & LINK_TYPE_URL)
2591 isChangingCutLink = true;
2592 editLinkType = EDIT_LINK_TYPE_URL;
2596 case LINK_TYPE_EMAIL:
2597 if (autoLinkMask & LINK_TYPE_EMAIL)
2599 isChangingCutLink = true;
2600 editLinkType = EDIT_LINK_TYPE_URL;
2604 case LINK_TYPE_TEL_NUM:
2605 if (autoLinkMask & LINK_TYPE_TEL_NUM)
2607 isChangingCutLink = true;
2608 editLinkType = EDIT_LINK_TYPE_PHONE_NUM;
2613 editLinkType = EDIT_LINK_TYPE_INVALID;
2619 _Text::TextElement* pTextElement = __pTextObject->GetElementAtTextIndex(pLinkInfo->srcOffset);
2620 if (pTextElement != null && pTextElement->GetType() != TEXT_ELEMENT_TYPE_CUTLINK)
2622 pNextLinkInfo = pLinkInfo->pNextLinkInfo;
2624 pLinkInfo = pNextLinkInfo;
2629 wchar_t* pCutLinkString = null;
2630 result r = E_SUCCESS;
2632 pCutLinkString = new(std::nothrow) wchar_t[(pLinkInfo->length + 1) * sizeof(wchar_t)];
2634 if (!pCutLinkString)
2636 while (pLinkInfo != null)
2638 pNextLinkInfo = pLinkInfo->pNextLinkInfo;
2640 pLinkInfo = pNextLinkInfo;
2642 SysLog(NID_UI_CTRL, "[E_SYSTEM] Unable to allocate cutlink text buffer.");
2646 for (int i = 0; i < pLinkInfo->length; i++)
2648 pCutLinkString[i] = __pTextBuffer[pLinkInfo->srcOffset + i];
2650 pCutLinkString[pLinkInfo->length] = null;
2652 r = DeleteText(pLinkInfo->srcOffset, pLinkInfo->srcOffset + pLinkInfo->length);
2656 int currentLength = __pTextString->GetLength();
2657 int fullLength = currentLength + pLinkInfo->length;
2659 r = __pTextString->Insert(String(pCutLinkString), pLinkInfo->srcOffset);
2660 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2662 wchar_t pOriginalString[currentLength - pLinkInfo->srcOffset];
2664 // Save original text.
2665 for (int i = 0; i < currentLength - pLinkInfo->srcOffset; i++)
2667 pOriginalString[i] = __pTextBuffer[pLinkInfo->srcOffset + i];
2669 pOriginalString[currentLength - pLinkInfo->srcOffset] = 0;
2672 for (int i = 0; i < pLinkInfo->length; i++)
2674 __pTextBuffer[i + pLinkInfo->srcOffset] = pCutLinkString[i];
2677 // Append origianal text.
2678 for (int i = 0; i < currentLength - pLinkInfo->srcOffset; i++)
2680 __pTextBuffer[i + pLinkInfo->srcOffset + pLinkInfo->length] = pOriginalString[i];
2682 __pTextBuffer[fullLength] = 0;
2685 if (isChangingCutLink)
2687 TextCutLink* pCutLinkObject = null;
2688 EditCutlinkColor cutlinkColor;
2690 Font* pFont = _FontImpl::CloneN(const_cast <Font&>(*__pFont));
2691 SysTryReturnResult(NID_UI_CTRL, pFont, GetLastResult(), "Unable to get font.");
2693 _FontImpl* fontImpl = _FontImpl::GetInstance(*pFont);
2694 SysTryReturnResult(NID_UI_CTRL, fontImpl, GetLastResult(), "fontImpl is null.");
2695 fontImpl->SetUnderline(true);
2697 __pEdit->GetCutlinkColorInfo(editLinkType, &cutlinkColor);
2698 pCutLinkObject = new (std::nothrow) TextCutLink(false, pLinkInfo->linkType, pCutLinkString, pLinkInfo->length, TEXT_ELEMENT_SOURCE_TYPE_INTERNAL, pFont,
2699 cutlinkColor.cutlinkFgColor, cutlinkColor.cutlinkBgColor, 0);
2703 if (pCutLinkObject == null)
2705 SysLog(NID_UI_CTRL, "Unable to allocate cutlink object.");
2709 pCutLinkObject->SetEditModeEnable(true);
2710 __pTextObject->InsertElementAt(pLinkInfo->srcOffset, *pCutLinkObject);
2711 __pTextObject->ChangeTextOffset(__pTextBuffer, pLinkInfo->srcOffset, pLinkInfo->length);
2716 TextSimple* pSimpleText = null;
2717 pSimpleText = new (std::nothrow) TextSimple(pCutLinkString, pLinkInfo->length, TEXT_ELEMENT_SOURCE_TYPE_INTERNAL, GetFont());
2719 if (pSimpleText == null)
2721 SysLog(NID_UI_CTRL, "Unable to allocate text object.");
2726 __pTextObject->InsertElementAt(pLinkInfo->srcOffset, *pSimpleText);
2727 __pTextObject->ChangeTextOffset(__pTextBuffer, pLinkInfo->srcOffset, pSimpleText->GetTextLength());
2731 pNextLinkInfo = pLinkInfo->pNextLinkInfo;
2733 pLinkInfo = pNextLinkInfo;
2735 if (pCutLinkString != null)
2737 delete[] pCutLinkString;
2738 pCutLinkString = null;
2742 __pTextObject->Compose();
2744 bool isCursorChanged = __isCursorChanged;
2745 SetCursorPosition(cursorPos);
2746 __isCursorChanged = isCursorChanged;
2752 _EditPresenter::GetLinkElementOffsetInTextBuffer(int elementIndex) const
2754 const int textElementCount = __pTextObject->GetElementCount();
2755 SysTryReturn(NID_UI_CTRL, elementIndex >= 0 && elementIndex <= textElementCount, -1, E_OUT_OF_RANGE, "The Invalid argument is given.");
2757 _Text::TextElement* pTextElement = null;
2758 int elementOffset = -1;
2759 int elementLength = 0;
2763 for (int index = 0; index <= elementIndex; index++)
2765 pTextElement = __pTextObject->GetElementAtElementIndex(index);
2766 if (pTextElement == null)
2771 elementOffset = static_cast<int>(pTextElement->GetValue(SET_TEXT_OFFSET));
2772 elementLength = pTextElement->GetTextLength();
2774 if (pTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)
2776 elementOffset = prevOffset + prevLength;
2779 prevOffset = elementOffset;
2780 prevLength = elementLength;
2781 pTextElement = null;
2784 return elementOffset;
2788 _EditPresenter::IsTextBlockedInTokenEdit(void) const
2794 _EditPresenter::GetCursorPositionAt(const FloatPoint& touchPoint) const
2796 FloatPoint cursorPoint;
2799 FloatRectangle textObjectBounds = __textObjectBounds;
2801 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
2803 if (IsTextBlockedInTokenEdit())
2805 textObjectBounds = GetTextBoundsF();
2809 if (textObjectBounds.Contains(touchPoint))
2811 cursorPoint.x = touchPoint.x - textObjectBounds.x;
2812 cursorPoint.y = touchPoint.y - textObjectBounds.y;
2814 else if (__textBoxBounds.Contains(touchPoint))
2816 if (touchPoint.y <= textObjectBounds.y)
2818 cursorPoint.y = textObjectBounds.y + 1.0f;
2820 else if (touchPoint.y >= (textObjectBounds.y + textObjectBounds.height))
2822 cursorPoint.y = textObjectBounds.y + textObjectBounds.height - 1.0f;
2826 cursorPoint.y = touchPoint.y;
2829 if (touchPoint.x <= textObjectBounds.x)
2831 cursorPoint.x = textObjectBounds.x + 1.0f;
2833 else if (touchPoint.x >= (textObjectBounds.x + textObjectBounds.width))
2835 cursorPoint.x = textObjectBounds.x + textObjectBounds.width - 1.0f;
2839 cursorPoint.x = touchPoint.x;
2841 cursorPoint.y -= textObjectBounds.y;
2842 cursorPoint.x -= textObjectBounds.x;
2849 cursorPos = __pTextObject->GetTextIndexFromPosition(cursorPoint.x, cursorPoint.y);
2854 _EditPresenter::GetCursorPositionAt(const FloatPoint& touchPoint, int& rowIndex, int& columnIndex, bool isMoving)
2856 FloatPoint cursorPoint;
2859 FloatRectangle textObjectBounds = __textObjectBounds;
2861 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
2863 if (IsTextBlockedInTokenEdit())
2865 textObjectBounds = GetTextBoundsF();
2869 if (textObjectBounds.Contains(touchPoint))
2871 cursorPoint.x = touchPoint.x - textObjectBounds.x;
2872 cursorPoint.y = touchPoint.y - textObjectBounds.y;
2874 else if (__textBoxBounds.Contains(touchPoint) && !isMoving)
2876 if (touchPoint.y <= textObjectBounds.y)
2878 cursorPoint.y = textObjectBounds.y + 1.0f;
2880 else if (touchPoint.y >= (textObjectBounds.y + textObjectBounds.height))
2882 cursorPoint.y = textObjectBounds.y + textObjectBounds.height - 1.0f;
2886 cursorPoint.y = touchPoint.y;
2889 if (touchPoint.x <= textObjectBounds.x)
2891 cursorPoint.x = textObjectBounds.x + 1.0f;
2893 else if (touchPoint.x >= (textObjectBounds.x + textObjectBounds.width))
2895 cursorPoint.x = textObjectBounds.x + textObjectBounds.width - 1.0f;
2899 cursorPoint.x = touchPoint.x;
2901 cursorPoint.y -= textObjectBounds.y;
2902 cursorPoint.x -= textObjectBounds.x;
2909 cursorPos = __pTextObject->GetTextIndexFromPosition(cursorPoint.x, cursorPoint.y, rowIndex, columnIndex, true);
2915 _EditPresenter::IsHorizontalDirection(const _TouchInfo& touchInfo)
2917 if (touchInfo.GetTouchStatus() != _TOUCH_MOVED)
2922 if (__isMovingCursorByTouchMove)
2927 FloatRectangle absoluteEditRect = __pEdit->GetAbsoluteBoundsF(true);
2928 FloatPoint touchStartPoint = __pressedAbsolutePoint;
2929 //After internal touch core complete the float conversion, we need to change the code here
2930 FloatPoint touchPoint = touchInfo.GetCurrentPosition();
2932 float movedWidth = touchStartPoint.x - touchPoint.x - absoluteEditRect.x;
2933 float movedHeight = touchStartPoint.y - touchPoint.y - absoluteEditRect.y;
2934 movedWidth = (movedWidth >= 0.0f) ? movedWidth : -(movedWidth);
2935 movedHeight = (movedHeight >= 0.0f) ? movedHeight : -(movedHeight);
2937 if (movedWidth >= movedHeight * DIRECTION_DECISION_RATIO)
2946 _EditPresenter::IsInitialized(void) const
2948 return __isInitialized;
2952 _EditPresenter::CalculateCursorBounds(const FloatRectangle& textBounds, FloatRectangle& cursorBounds, int cursorPos)
2954 float cursorWidth = 0.0f;
2955 float cursorHeight = 0.0f;
2956 float cursorAbsX = 0.0f;
2957 float cursorAbsY = 0.0f;
2958 float cursorRelativeX = 0.0f;
2959 float cursorRelativeY = 0.0f;
2961 __pTextObject->SetBounds(textBounds);
2963 if (cursorPos == -1)
2965 cursorPos = __pTextObject->GetCursorIndex();
2968 if (cursorPos != __cursorPos)
2970 if (__pTextObject->GetTextPositionInfoAt(cursorPos, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
2977 if (__pTextObject->GetTextPositionInfoAt(__rowCursorIndex, __columnCursorIndex, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
2983 cursorBounds.x = cursorRelativeX;
2984 cursorBounds.y = cursorRelativeY;
2985 float cursorWidthValue = 0.0f;
2986 GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorWidthValue);
2987 cursorBounds.width = cursorWidthValue;
2988 cursorBounds.height = cursorHeight;
2990 if (cursorBounds.y == 0.0f)
2992 cursorBounds.y = __textObjectBounds.y;
2995 if (cursorBounds.height == 0.0f)
2997 cursorBounds.height = __textObjectBounds.height;
3000 if (cursorBounds.height == 0.0f)
3005 if (cursorBounds.y < textBounds.y)
3007 float cursorHeightDiff = textBounds.y - cursorBounds.y;
3008 cursorBounds.y = textBounds.y;
3009 cursorBounds.height -= cursorHeightDiff;
3012 if ((cursorBounds.y + cursorBounds.height > textBounds.y + textBounds.height) &&
3013 (cursorBounds.y < textBounds.y + textBounds.height))
3015 float cursorHeightDiff = cursorBounds.y + cursorBounds.height - textBounds.y - textBounds.height;
3016 if (cursorHeightDiff > 0.0f)
3018 cursorBounds.height -= cursorHeightDiff;
3022 cursorBounds.height += cursorHeightDiff;
3026 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
3028 if (__pTextObject->GetBlock() == false)
3030 cursorBounds.x -= 1.0f;
3033 if (cursorBounds.x > textBounds.x + textBounds.width)
3035 if (cursorBounds.x <= textBounds.x + textBounds.width + cursorBounds.width)
3037 cursorBounds.x = textBounds.x + textBounds.width;
3045 if (cursorBounds.x < textBounds.x)
3047 if (cursorBounds.x > textBounds.x - cursorBounds.width)
3049 cursorBounds.x = textBounds.x;
3059 if (cursorBounds.x == textBounds.x + textBounds.width)
3061 cursorBounds.x -= 1.0f;
3063 else if (cursorBounds.x > textBounds.x + textBounds.width)
3065 cursorBounds.x = textBounds.x + textBounds.width;
3069 if (__pTextObject->GetBlock() == false)
3071 cursorBounds.x -= 1.0f;
3072 if (cursorBounds.x < textBounds.x)
3074 cursorBounds.x = textBounds.x;
3078 __calculatedCursorBounds = cursorBounds;
3083 _EditPresenter::CalculateCursorBounds(const FloatRectangle& textBounds, FloatRectangle& cursorBounds, int rowIndex, int columnIndex)
3085 float cursorWidth = 0.0f;
3086 float cursorHeight = 0.0f;
3087 float cursorAbsX = 0.0f;
3088 float cursorAbsY = 0.0f;
3089 float cursorRelativeX = 0.0f;
3090 float cursorRelativeY = 0.0f;
3092 __pTextObject->SetBounds(textBounds);
3094 if (__pTextObject->GetTextPositionInfoAt(rowIndex, columnIndex, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
3099 cursorBounds.x = cursorRelativeX;
3100 cursorBounds.y = cursorRelativeY;
3101 float cursorWidthValue = 0.0f;
3102 GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorWidthValue);
3103 cursorBounds.width = cursorWidthValue;
3104 cursorBounds.height = cursorHeight;
3106 if (cursorBounds.y == 0.0f)
3108 cursorBounds.y = __textObjectBounds.y;
3111 if (cursorBounds.height == 0.0f)
3113 cursorBounds.height = __textObjectBounds.height;
3116 if (cursorBounds.height == 0.0f)
3121 if (cursorBounds.y < textBounds.y)
3123 float cursorHeightDiff = textBounds.y - cursorBounds.y;
3124 cursorBounds.y = textBounds.y;
3125 cursorBounds.height -= cursorHeightDiff;
3128 if ((cursorBounds.y + cursorBounds.height > textBounds.y + textBounds.height) &&
3129 (cursorBounds.y < textBounds.y + textBounds.height))
3131 float cursorHeightDiff = cursorBounds.y + cursorBounds.height - textBounds.y - textBounds.height;
3132 if (cursorHeightDiff > 0.0f)
3134 cursorBounds.height -= cursorHeightDiff;
3138 cursorBounds.height += cursorHeightDiff;
3142 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
3144 if (__pTextObject->GetBlock() == false)
3146 cursorBounds.x -= 1.0f;
3149 if (cursorBounds.x > textBounds.x + textBounds.width)
3151 if (cursorBounds.x <= textBounds.x + textBounds.width + cursorBounds.width)
3153 cursorBounds.x = textBounds.x + textBounds.width;
3161 if (cursorBounds.x < textBounds.x)
3163 if (cursorBounds.x > textBounds.x - cursorBounds.width)
3165 cursorBounds.x = textBounds.x;
3175 if (cursorBounds.x == textBounds.x + textBounds.width)
3177 cursorBounds.x -= 1.0f;
3179 else if (cursorBounds.x > textBounds.x + textBounds.width)
3181 cursorBounds.x = textBounds.x + textBounds.width;
3185 if (__pTextObject->GetBlock() == false)
3187 cursorBounds.x -= 1.0f;
3188 if (cursorBounds.x < textBounds.x)
3190 cursorBounds.x = textBounds.x;
3194 __calculatedCursorBounds = cursorBounds;
3199 _EditPresenter::ScrollContents(float moveY)
3202 float firstDisplayY = 0.0f;
3203 float effectDistance = moveY;
3205 float totalHeight = __pTextObject->GetTotalHeightF();
3206 float newFirstDisplayY = firstDisplayY = __pTextObject->GetFirstDisplayPositionYF();
3207 int currentCursorLine = 0;
3209 if (__pTextObject->GetTextLength() < 1)
3214 if (__pScrollBar && __pScrollBar->GetScrollPosition() == 0 && effectDistance < 0.0f)
3216 if (__pFlickAnimationTimer)
3221 __pScrollBar->SetScrollVisibility(false);
3225 else if (__pScrollBar && __pScrollBar->GetScrollPosition() != 0 && __pScrollBar->GetScrollPosition() == __previousScrollBarMaxPos && effectDistance > 0.0f)
3227 if (__pFlickAnimationTimer)
3232 __pScrollBar->SetScrollVisibility(false);
3237 if (__pTextObject->GetCursorIndex() == __pTextObject->GetTextLength())
3239 currentCursorLine = __pTextObject->GetTotalLineCount() - 1;
3243 currentCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
3246 if (currentCursorLine == -1)
3251 if (currentCursorLine < 0)
3253 currentCursorLine = 0;
3256 newFirstDisplayY += moveY;
3258 if (newFirstDisplayY > (totalHeight - __textObjectBounds.height))
3260 newFirstDisplayY = totalHeight - __textObjectBounds.height;
3263 if (newFirstDisplayY < 0.0f)
3265 newFirstDisplayY = 0.0f;
3268 moveLine = __pTextObject->GetLineIndexAtPositionY(newFirstDisplayY);
3270 __pTextObject->SetFirstDisplayLineIndex(moveLine);
3271 __pTextObject->SetFirstDisplayPositionY(newFirstDisplayY);
3273 __isCursorOpaque = false;
3274 if (__isCopyPasteManagerExist)
3276 __pCopyPasteManager->AdjustBounds();
3283 _EditPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
3285 if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
3290 if (__isCopyPasteManagerExist)
3292 __pCopyPasteManager->ReleaseCopyPastePopup();
3295 __isTouchPressed = true;
3296 __isTouchReleaseSkipped = false;
3298 __pScrollEffect->previousY = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().y);
3299 __pScrollEffect->currentY = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().y);
3300 __pScrollEffect->previousX = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().x);
3301 __pScrollEffect->currentX = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().x);
3303 __pScrollEffect->previousAbsX = _CoordinateSystemUtils::ConvertToFloat(__pEdit->GetAbsoluteBoundsF(true).x + touchInfo.GetCurrentPosition().x);
3304 __pScrollEffect->currentAbsX = _CoordinateSystemUtils::ConvertToFloat(__pEdit->GetAbsoluteBoundsF(true).x + touchInfo.GetCurrentPosition().x);
3305 __pScrollEffect->previousAbsY = _CoordinateSystemUtils::ConvertToFloat(__pEdit->GetAbsoluteBoundsF(true).y + touchInfo.GetCurrentPosition().y);
3306 __pScrollEffect->currentAbsY = _CoordinateSystemUtils::ConvertToFloat(__pEdit->GetAbsoluteBoundsF(true).y + touchInfo.GetCurrentPosition().y);
3308 __pScrollEffect->cursorPosition = GetCursorPosition();
3310 FloatRectangle absoluteEditRect = __pEdit->GetAbsoluteBoundsF(true);
3312 __pressedPoint = touchInfo.GetCurrentPosition();
3313 __pressedAbsolutePoint.x = __pressedPoint.x + absoluteEditRect.x;
3314 __pressedAbsolutePoint.y = __pressedPoint.y + absoluteEditRect.y;
3316 if (IsViewModeEnabled())
3318 int cutLinkIndex = -1;
3320 __pTextObject->ResetAllCutLinkElementsState();
3322 cutLinkIndex = __pTextObject->GetCutLinkIndexFromPositionData(__pressedPoint.x - __textObjectBounds.x, __pressedPoint.y - __textObjectBounds.y);
3324 if (cutLinkIndex != -1)
3326 __pTextObject->ChangeCutLinkState(cutLinkIndex, true);
3330 if (__pEdit->GetEditStyle() & EDIT_STYLE_CLEAR && __pTextString->GetLength() > 0 && __isClearIconVisible)
3332 if ((__pressedPoint.x >= __clearIconBounds.x) && (__pressedPoint.x <= __clearIconBounds.x + __clearIconBounds.width)
3333 && (__pressedPoint.y >= __clearIconBounds.y) && (__pressedPoint.y <= __clearIconBounds.y + __clearIconBounds.height)) // Clear Icon Pressed
3335 __isClearIconPressed = true;
3336 __pEdit->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_IN_CLEAR_AREA);
3341 __pEdit->Invalidate();
3347 _EditPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
3349 InitializeCopyPasteManager();
3351 if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
3356 if (__isClearIconPressed)
3358 __isClearIconPressed = false;
3359 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
3362 __isTouchPressed = false;
3363 __isMovingCursorByTouchMove = false;
3365 if (__isTouchReleaseSkipped || __isTouchMoving)
3367 __isTouchReleaseSkipped = false;
3369 __isTouchMoving = false;
3372 if (__isScrollBarVisible && __pScrollBar)
3374 if (__pScrollBar->IsVisible())
3376 __pScrollBar->SetScrollVisibility(false);
3378 __isScrollBarVisible = false;
3381 __isTouchMoving = false;
3382 __pEdit->Invalidate();
3388 _EditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
3390 if (__dragAndDropStarted)
3396 __isTouchLongPressed = false;
3398 if (__isCopyPasteManagerExist)
3400 if (__isTouchPressed && !__isCopyPastePopupMoving)
3402 InitializeCopyPasteManager();
3403 if (__isClearIconPressed)
3405 FloatPoint touchPoint = touchInfo.GetCurrentPosition();
3406 __isClearIconPressed = false;
3407 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
3408 if ((touchPoint.x >= __clearIconBounds.x) && (touchPoint.x <= __clearIconBounds.x + __clearIconBounds.width)
3409 && (touchPoint.y >= __clearIconBounds.y) && (touchPoint.y <= __clearIconBounds.y + __clearIconBounds.height))
3412 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
3413 __isMovingCursorByTouchMove = false;
3414 __pEdit->Invalidate();
3418 __isTouchPressed = false;
3419 __isCopyPastePopupMoving = false;
3421 if (IsCurrentFocused())
3428 if (!IsCurrentFocused())
3430 __pEdit->SetFocused();
3433 FadeOutScrollBar(); // Fade out scrollbar when copypaste popup is moving.
3434 if (__needToCreateCopyPastePopup)
3436 __pCopyPasteManager->CreateCopyPastePopup();
3438 __needToCreateCopyPastePopup = false;
3439 __pCopyPasteManager->Show();
3441 __isTouchPressed = false;
3442 __isCopyPastePopupMoving = false;
3448 if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
3453 int cutLinkIndex = -1;
3454 FloatRectangle clientBounds;
3455 FloatPoint touchPoint = touchInfo.GetCurrentPosition();
3457 if (__isClearIconPressed)
3459 __isClearIconPressed = false;
3460 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
3462 if ((touchPoint.x >= __clearIconBounds.x) && (touchPoint.x <= __clearIconBounds.x + __clearIconBounds.width)
3463 && (touchPoint.y >= __clearIconBounds.y) && (touchPoint.y <= __clearIconBounds.y + __clearIconBounds.height))
3466 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
3467 __isTouchPressed = false;
3468 __isMovingCursorByTouchMove = false;
3469 __pEdit->Invalidate();
3471 __isTouchMoving = false;
3472 if (IsCurrentFocused() || GetSearchBarFlag())
3479 if (!__isCopyPasteManagerExist)
3481 __isTextBlocked = false;
3483 __isTouchPressed = false;
3484 __isMovingCursorByTouchMove = false;
3486 if (__isTouchReleaseSkipped)
3488 __isTouchReleaseSkipped = false;
3490 __isTouchMoving = false;
3491 __pEdit->Invalidate();
3496 if (__isTouchMoving && __isInputConnectionBound == false)
3499 __isTouchMoving = false;
3500 __isTouchReleaseSkipped = false;
3501 __pEdit->Invalidate();
3506 if (IsViewModeEnabled())
3508 __pEdit->SetFocused();
3510 __pTextObject->ResetAllCutLinkElementsState();
3512 cutLinkIndex = __pTextObject->GetCutLinkIndexFromPositionData(touchPoint.x - __textObjectBounds.x, touchPoint.y - __textObjectBounds.y);
3514 if (cutLinkIndex != -1)
3516 TextCutLink* pCutLinkObject = dynamic_cast<TextCutLink*>(__pTextObject->GetCutLinkElementAtCutLinkElementIndex(cutLinkIndex));
3517 if (pCutLinkObject == null)
3522 String cutLinkString(pCutLinkObject->GetText());
3523 LinkType baseLinkType = pCutLinkObject->GetCutLinkType();
3525 // Send Ui Link Event
3526 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, __pEdit);
3527 __pEdit->SendLinkEvent(cutLinkString, baseLinkType, cutLinkString);
3531 clientBounds = __pEdit->GetBoundsF();
3532 clientBounds.x = 0.0f;
3533 clientBounds.y = 0.0f;
3534 touchPoint = touchInfo.GetCurrentPosition();
3535 if (clientBounds.Contains(touchPoint))
3539 int cursorPos = GetCursorPositionAt(touchPoint, rowIndex,columnIndex);
3540 if (cursorPos != -1)
3542 if (__isInputConnectionBound == true && __isTextComposing == true)
3544 __pInputConnection->FinishTextComposition();
3546 if (!__isCopyPasteManagerExist) // Copy&Paste
3548 if ((__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) == true && IsCurrentFocused() == false)
3550 __isCursorChanged = true;
3554 SetCursorPosition(cursorPos, rowIndex, columnIndex);
3560 if ((__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) == false)
3562 if (__isInputConnectionBound == true && __isTextComposing == true)
3564 __pInputConnection->FinishTextComposition();
3566 SetCursorPosition(GetTextLength());
3571 if (!__isCopyPasteManagerExist && !__pFlickAnimationTimer)
3573 bool tokenEditting = false;
3574 bool needToCreatePopup = true;
3575 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
3577 _TokenEditPresenter* pTokenEditPresenter = dynamic_cast < _TokenEditPresenter* >(this);
3578 if (pTokenEditPresenter)
3580 if (pTokenEditPresenter->GetSelectedTokenIndex() != -1)
3582 tokenEditting = true;
3587 if (!__isUSBKeyboardConnected && !__isKeypadExist && !IsViewModeEnabled() && IsKeypadEnabled())
3589 needToCreatePopup = false;
3592 if (IsViewModeEnabled())
3594 needToCreatePopup = false;
3596 _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance();
3597 SysTryReturn(NID_UI_CTRL, pAccessibilityManager, false, E_SYSTEM, "pAccessibilityManager is null");
3598 if (pAccessibilityManager->IsActivated())
3600 needToCreatePopup = false;
3603 if (IsCurrentFocused() && !tokenEditting && needToCreatePopup)
3605 if (__pPasswordTimer)
3607 ChangePasswordToEchoCharacter(__pTextBuffer, __echoChar);
3608 StopPasswordTimer();
3610 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
3611 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, false, E_SYSTEM, "Unable to create _EditCopyPasteManager instance.");
3612 __pCopyPasteManager->AddCopyPasteEventListener(*this);
3613 UpdateComponentInformation();
3614 __pCopyPasteManager->DestroyCopyPasteMagnifier();
3615 __pCopyPasteManager->Show();
3616 __isCopyPasteManagerExist = true;
3620 if (cutLinkIndex < 0)
3622 CheckUSBKeyboardStatus();
3624 if (__isUSBKeyboardConnected)
3626 if (!__isInputConnectionBound)
3628 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
3630 if (IsViewModeEnabled() == false)
3632 if (IsCurrentFocused())
3638 __pEdit->SetFocused();
3644 if (__pEditModel->IsViewModeEnabled() == false) //in case of fullscreen style, should check editModel's viewMode
3646 ShowFullscreenKeypad();
3653 if (!__isKeypadExist || !__isInputConnectionBound)
3655 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
3657 if (IsViewModeEnabled() == false)
3659 if (IsCurrentFocused())
3665 __pEdit->SetFocused();
3671 if (__pEditModel->IsViewModeEnabled() == false) //in case of fullscreen style, should check editModel's viewMode
3673 ShowFullscreenKeypad();
3681 if (__isScrollBarVisible && __pScrollBar)
3683 if (__pScrollBar->IsVisible())
3685 __pScrollBar->SetScrollVisibility(false);
3687 __isScrollBarVisible = false;
3690 __isTouchMoving = false;
3691 __pEdit->Invalidate();
3693 if (GetSearchBarFlag())
3702 _EditPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
3704 if (__dragAndDropStarted)
3706 _Window* pDragWindow = __pEdit->GetDragWindow();
3709 FloatPoint dragPoint = touchInfo.GetCurrentPosition();
3710 dragPoint.x += __pEdit->GetAbsoluteBoundsF(true).x;
3711 dragPoint.y += __pEdit->GetAbsoluteBoundsF(true).y;
3712 pDragWindow->SetPosition(FloatPoint(dragPoint.x - pDragWindow->GetBoundsF().width/2.0f, dragPoint.y - pDragWindow->GetBoundsF().height/2.0f));
3717 if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
3722 FloatPoint touchPoint = touchInfo.GetCurrentPosition();
3724 if (__isClearIconPressed)
3726 if ((touchPoint.x < __clearIconBounds.x) || (touchPoint.x > __clearIconBounds.x + __clearIconBounds.width)
3727 || (touchPoint.y < __clearIconBounds.y) || (touchPoint.y > __clearIconBounds.y + __clearIconBounds.height))
3729 __isClearIconPressed = false;
3730 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
3731 __pEdit->Invalidate();
3735 if (__isCopyPasteManagerExist)
3737 if (!IsBlocked() && GetTextLength() > 0 && __isTouchLongPressed)
3741 int columnIndex = -1;
3742 FloatPoint touchPoint = touchInfo.GetCurrentPosition();
3743 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__cursorPos);
3744 int totalLine = __pTextObject->GetTotalLineCount();
3745 float firstDisplayY = __pTextObject->GetFirstDisplayPositionYF();
3746 float totalHeight = __pTextObject->GetTotalHeightF();
3748 if (touchPoint.x < __textObjectBounds.x)
3750 touchPoint.x = __textObjectBounds.x;
3752 if (touchPoint.x > __textObjectBounds.x + __textObjectBounds.width)
3754 touchPoint.x = __textObjectBounds.x + __textObjectBounds.width;
3756 if (__textObjectBounds.y > touchPoint.y)
3758 if (totalLine == 1 || firstDisplayY == 0.0f) // whether need to scroll the text or not
3760 touchPoint.y = __textObjectBounds.y; //not need to scroll the text.
3763 if (__textObjectBounds.y + __textObjectBounds.height < touchPoint.y)
3765 if (totalLine == 1 || (totalHeight - firstDisplayY < __textObjectBounds.height) || curCursorLine == (totalLine - 1)) // || pTextObject->IsDisplayedLastLine()) // whether need to scroll the text or not
3767 touchPoint.y = __textObjectBounds.y + __textObjectBounds.height; // check TextObject
3771 if(!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
3773 if (totalHeight < __textObjectBounds.height)
3775 if (totalHeight < touchPoint.y)
3777 touchPoint.y = totalHeight;
3781 cursorPos = GetCursorPositionAt(touchPoint, rowIndex, columnIndex);
3782 if (cursorPos == -1)
3784 FloatRectangle cursorRect(0.0f, 0.0f, 0.0f, 0.0f);
3785 CalculateCursorBounds(__textObjectBounds, cursorRect, __rowCursorIndex, __columnCursorIndex);
3788 if (touchPoint.y > (cursorRect.y + cursorRect.height))
3790 if (curCursorLine < totalLine - 1)
3792 int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
3793 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
3794 cursorPos = offset + firstTextIndex;
3795 int textLength = __pTextObject->GetTextLengthAt(curCursorLine+1);
3796 if (offset > textLength)
3798 cursorPos = firstTextIndex+textLength;
3804 if (curCursorLine !=0)
3806 if (__rowCursorIndex == 0)
3812 int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
3813 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine-1);
3814 cursorPos = offset + firstTextIndex;
3815 int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
3816 if (offset > textLength)
3818 cursorPos = firstTextIndex+textLength;
3824 if (cursorPos == -1)
3828 SetCursorPosition(cursorPos);
3832 SetCursorPosition(cursorPos, rowIndex, columnIndex);
3834 ScrollPanelToCursorPosition(true);
3835 __pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos);
3836 __pCopyPasteManager->Show();
3837 if (!__isClearIconPressed)
3839 __isCopyPastePopupMoving = true;
3845 __pCopyPasteManager->Show();
3846 if (!__isClearIconPressed)
3848 __isCopyPastePopupMoving = true;
3853 if (__isTouchMoving == false && IsHorizontalDirection(touchInfo))
3855 if (__isCopyPasteManagerExist && IsBlocked())
3860 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
3862 float horizontalGap = touchInfo.GetCurrentPosition().x - __pScrollEffect->currentX;
3863 FloatRectangle lineBounds = __pTextObject->GetBoundsAtLineF(0);
3864 float textDisplayPositionX = __pTextObject->GetFirstDisplayPositionXF();
3865 float newTextDisplayPositionX = 0;
3867 if (horizontalGap < 0.0f && lineBounds.width - textDisplayPositionX > __textObjectBounds.width)
3869 newTextDisplayPositionX = textDisplayPositionX - horizontalGap;
3871 if (newTextDisplayPositionX > lineBounds.width - __textObjectBounds.width)
3873 newTextDisplayPositionX = lineBounds.width - __textObjectBounds.width;
3876 __pScrollEffect->previousX = __pScrollEffect->currentX;
3877 __pScrollEffect->currentX = touchInfo.GetCurrentPosition().x;
3878 __isMovingCursorByTouchMove = true;
3879 __isTouchReleaseSkipped = true;
3882 __pTextObject->SetFirstDisplayPositionX(newTextDisplayPositionX);
3883 __pEdit->Invalidate();
3886 if (horizontalGap > 0.0f && textDisplayPositionX > 0)
3888 newTextDisplayPositionX = textDisplayPositionX - horizontalGap;
3889 if (newTextDisplayPositionX < 0)
3891 newTextDisplayPositionX = 0;
3894 __pScrollEffect->previousX = __pScrollEffect->currentX;
3895 __pScrollEffect->currentX = touchInfo.GetCurrentPosition().x;
3896 __isMovingCursorByTouchMove = true;
3897 __isTouchReleaseSkipped = true;
3900 __pTextObject->SetFirstDisplayPositionX(newTextDisplayPositionX);
3901 __pEdit->Invalidate();
3908 FloatRectangle fromBounds;
3909 FloatRectangle toBounds;
3910 CalculateCursorBounds(__textObjectBounds, fromBounds);
3911 newIndex = GetCursorPositionAt(touchInfo.GetCurrentPosition());
3914 if (Math::Abs(newIndex - __cursorPos) > 3)
3919 CalculateCursorBounds(__textObjectBounds, toBounds, newIndex);
3920 __isCursorChanged = true;
3921 SetCursorPosition(newIndex);
3923 __isMovingCursorByTouchMove = true;
3924 __isTouchReleaseSkipped = true;
3927 MoveCursor(fromBounds, toBounds);
3928 __pEdit->Invalidate();
3933 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
3935 float horizontalGap = touchInfo.GetCurrentPosition().x - fromBounds.x;
3936 FloatDimension currentCharacterDimension;
3937 if (horizontalGap > 0.0f && __cursorPos < GetTextLength())
3939 currentCharacterDimension = __pTextObject->GetTextExtentF(__cursorPos, 1);
3940 if (horizontalGap >= currentCharacterDimension.width)
3942 SetCursorPosition(__cursorPos+1);
3943 __pEdit->Invalidate();
3947 if (horizontalGap < 0.0f && __cursorPos > 0)
3949 currentCharacterDimension = __pTextObject->GetTextExtentF(__cursorPos-1, 1);
3950 if (Math::Abs(horizontalGap) >= currentCharacterDimension.width)
3952 SetCursorPosition(__cursorPos-1);
3953 __pEdit->Invalidate();
3959 if (__isMovingCursorByTouchMove)
3965 float totalHeight = __pTextObject->GetTotalHeightF();
3967 if (__textObjectBounds.height >= totalHeight)
3969 __isTouchMoving = true;
3970 __isTouchReleaseSkipped = true;
3974 if ((touchInfo.GetCurrentPosition().y == __pScrollEffect->currentY) ||
3975 (Math::Abs(touchInfo.GetCurrentPosition().y - __pScrollEffect->previousY) < MOVE_SKIP_DECISION_RANGE))
3980 __pScrollEffect->previousY = __pScrollEffect->currentY;
3981 __pScrollEffect->currentY = touchInfo.GetCurrentPosition().y;
3983 __pScrollEffect->previousAbsY = __pScrollEffect->currentAbsY;
3984 __pScrollEffect->currentAbsY = _CoordinateSystemUtils::ConvertToFloat(__pEdit->GetAbsoluteBoundsF(true).y + touchInfo.GetCurrentPosition().y);
3986 float moveGap = __pScrollEffect->previousAbsY - __pScrollEffect->currentAbsY;
3988 if (__isMovingCursorByTouchMove)
3990 __isMovingCursorByTouchMove = false;
3993 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_NOSCROLL) && !(__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN))
3997 if (totalHeight > __textObjectBounds.height)
3999 __pScrollBar->SetScrollVisibility(true);
4003 __pScrollBar->SetScrollVisibility(false);
4008 result returnResult = ScrollContents(moveGap);
4010 __isCursorChanged = false;
4011 __isTouchMoving = true;
4015 if (returnResult == E_SUCCESS)
4021 __isTouchReleaseSkipped = true;
4027 _EditPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
4029 result r = E_SUCCESS;
4030 _KeyCode keyCode = keyInfo.GetKeyCode();
4034 FloatRectangle panelAbsBounds(0.0f, 0.0f, 0.0f, 0.0f);
4035 FloatRectangle absCursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
4037 if (__dragAndDropStarted)
4039 if (keyCode == _KEY_ESC)
4046 _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance();
4047 SysTryReturn(NID_UI_CTRL, pAccessibilityManager, false, E_SYSTEM, "pAccessibilityManager is null");
4049 if (__pEditModel->IsViewModeEnabled() == false)
4051 if (__pEdit->GetInputStyle() == INPUT_STYLE_FULLSCREEN)
4053 if (_KEY_ENTER == keyCode)
4055 CheckUSBKeyboardStatus();
4056 if (__isUSBKeyboardConnected)
4058 ShowFullscreenKeypad();
4070 if (__isUSBKeyboardConnected && (keyInfo.GetKeyModifier() & _KEY_MODIFIER_CTRL) && (keyInfo.GetKeyModifier() & _KEY_MODIFIER_SHIFT))
4072 if ((keyCode == _KEY_LEFT) || (keyCode == _KEY_RIGHT))
4074 if (!__isCopyPasteManagerExist)
4076 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
4078 _TokenEditPresenter* pTokenEditPresenter = dynamic_cast < _TokenEditPresenter* >(this);
4079 if (pTokenEditPresenter)
4081 if (pTokenEditPresenter->GetSelectedTokenIndex() != -1)
4087 SetBlockRangeWithCtrlShiftArrowkey(keyCode);
4092 if (__pCopyPasteManager->IsCopyPasteSingleHandleExist())
4094 InitializeCopyPasteManager();
4095 SetBlockRangeWithShiftArrowkey(keyCode);
4101 else if (__isUSBKeyboardConnected && (keyInfo.GetKeyModifier() & _KEY_MODIFIER_CTRL))
4106 FinishTextComposition();
4108 if (__isCopyPasteManagerExist)
4110 InitializeCopyPasteManager();
4113 textLength = __pEdit->GetTextLength();
4118 __pEdit->SetBlockRange(0, textLength);
4119 r = __pEdit->SendTextBlockEvent(0, textLength);
4120 UpdateComponentInformation();
4121 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r));
4123 if (!pAccessibilityManager->IsActivated())
4125 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
4126 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, true, E_OUT_OF_MEMORY, "Memory allocation failed.");
4127 __pCopyPasteManager->AddCopyPasteEventListener(*this);
4128 __pCopyPasteManager->CreateCopyPastePopup();
4129 __pCopyPasteManager->Show();
4130 __isCopyPasteManagerExist = true;
4135 textLength = __pEdit->GetTextLength();
4141 if (__isCopyPasteManagerExist)
4143 InitializeCopyPasteManager();
4147 textLength = __pEdit->GetTextLength();
4153 if (__isCopyPasteManagerExist)
4155 InitializeCopyPasteManager();
4160 if (__isCopyPasteManagerExist)
4162 InitializeCopyPasteManager();
4165 case _KEY_HOME_BUTTON:
4166 if (__isCopyPasteManagerExist)
4168 InitializeCopyPasteManager();
4170 if (__cursorPos != 0)
4172 SetCursorPosition(0);
4179 case _KEY_END_BUTTON:
4180 if (__isCopyPasteManagerExist)
4182 InitializeCopyPasteManager();
4184 if (__cursorPos != GetTextLength())
4186 SetCursorPosition(GetTextLength());
4194 if (__isCopyPasteManagerExist)
4196 InitializeCopyPasteManager();
4198 if (__cursorPos == 0)
4202 GetWordPosition(__cursorPos, start, end);
4203 if (__cursorPos != start)
4205 SetCursorPosition(start);
4209 GetWordPosition(start-1, start, end);
4210 SetCursorPosition(start);
4214 if (__isCopyPasteManagerExist)
4216 InitializeCopyPasteManager();
4218 if (__cursorPos == GetTextLength())
4222 GetWordPosition(__cursorPos, start, end);
4223 if (__cursorPos != end)
4225 SetCursorPosition(end);
4229 GetWordPosition(end+1, start, end);
4230 SetCursorPosition(end);
4236 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4242 __pEdit->Invalidate();
4247 else if (__isUSBKeyboardConnected && keyInfo.GetKeyModifier() & _KEY_MODIFIER_SHIFT)
4249 if (!__isCopyPasteManagerExist)
4251 if ((keyCode == _KEY_LEFT) || (keyCode == _KEY_UP) || (keyCode == _KEY_DOWN) || (keyCode == _KEY_RIGHT))
4253 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
4255 _TokenEditPresenter* pTokenEditPresenter = dynamic_cast < _TokenEditPresenter* >(this);
4256 if (pTokenEditPresenter)
4258 if (pTokenEditPresenter->GetSelectedTokenIndex() != -1)
4264 SetBlockRangeWithShiftArrowkey(keyCode);
4274 if (__pCopyPasteManager->IsCopyPasteSingleHandleExist())
4276 InitializeCopyPasteManager();
4277 SetBlockRangeWithShiftArrowkey(keyCode);
4285 __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_LEFT);
4288 __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_UP);
4291 __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_DOWN);
4294 __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_RIGHT);
4301 else if (_KEY_END_BUTTON == keyCode || _KEY_HOME_BUTTON == keyCode)
4303 if (__isCopyPasteManagerExist)
4305 InitializeCopyPasteManager();
4308 FinishTextComposition();
4310 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
4311 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine);
4313 if (_KEY_HOME_BUTTON == keyCode)
4315 if(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
4317 if (__cursorPos != 0)
4319 SetCursorPosition(0);
4328 SetCursorPosition(firstTextIndex);
4331 else if (_KEY_END_BUTTON == keyCode)
4333 if(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
4335 if (__cursorPos != GetTextLength())
4337 SetCursorPosition(GetTextLength());
4346 int totalLine = __pTextObject->GetTotalLineCount();
4347 if (curCursorLine < totalLine - 1)
4349 int nextLinefirstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
4350 SetCursorPosition(nextLinefirstTextIndex-1);
4354 if (__cursorPos != GetTextLength())
4356 SetCursorPosition(GetTextLength());
4367 else if (_KEY_ENTER == keyCode || _KEY_NUMPAD_ENTER == keyCode)
4369 if (__isInputConnectionBound != false && __isTextComposing != false)
4375 if (IsKeypadActionEnabled())
4377 char enterText[2] = {'\n', };
4378 OnTextCommitted(String(enterText));
4384 else if (_KEY_BACKSPACE == keyCode)
4386 if (__isTextComposing == false)
4388 if (__isCopyPasteManagerExist)
4392 __pCopyPasteManager->SetTextBlockReleaseFlag(false);
4394 InitializeCopyPasteManager();
4397 OnSurroundingTextDeleted(-1, 1);
4398 if (AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT) == true)
4400 __pTextObject->Compose();
4401 __pEdit->Invalidate();
4403 ScrollPanelToCursorPosition();
4407 else if ((keyInfo.GetKeyModifier() & _KEY_LOCK_NUM) && (_KEY_NUMPAD_4 == keyCode || _KEY_NUMPAD_6 == keyCode || _KEY_NUMPAD_8 == keyCode || _KEY_NUMPAD_2 == keyCode))
4411 else if (_KEY_LEFT == keyCode || _KEY_NUMPAD_4 == keyCode)
4413 if (__isCopyPasteManagerExist)
4415 InitializeCopyPasteManager();
4418 FinishTextComposition();
4420 if (__cursorPos != 0)
4422 int startPosition = -1;
4423 int endPosition = -1;
4424 GetTextImageRangeAt(__cursorPos-1, startPosition, endPosition);
4425 if (endPosition > -1 && startPosition >= 0 && startPosition < __cursorPos-1)
4427 SetCursorPosition(startPosition);
4431 SetCursorPosition(__cursorPos-1);
4436 panelAbsBounds = __pParentPanel->GetAbsoluteBoundsF(true);
4437 GetCursorBounds(true, absCursorBounds);
4439 if (!panelAbsBounds.Contains(FloatPoint(absCursorBounds.x, absCursorBounds.y + absCursorBounds.height)))
4441 ScrollPanelToCursorPosition();
4445 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4451 __pEdit->Invalidate();
4460 else if (_KEY_UP == keyCode || _KEY_NUMPAD_8 == keyCode)
4462 if (__isCopyPasteManagerExist)
4464 InitializeCopyPasteManager();
4467 FinishTextComposition();
4469 if (GetTextLength() == 0)
4474 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
4475 if (curCursorLine !=0)
4477 int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
4478 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine-1);
4479 int newCursorPosition = offset + firstTextIndex;
4480 int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
4481 if (offset<textLength)
4483 int startPosition = -1;
4484 int endPosition = -1;
4485 GetTextImageRangeAt(newCursorPosition, startPosition, endPosition);
4486 if (endPosition > newCursorPosition && startPosition < newCursorPosition)
4488 newCursorPosition = endPosition;
4490 SetCursorPosition(newCursorPosition);
4495 __pTextString->GetCharAt(firstTextIndex+textLength - 1, ch);
4498 SetCursorPosition(firstTextIndex+textLength - 1);
4502 SetCursorPosition(firstTextIndex+textLength);
4508 panelAbsBounds = __pParentPanel->GetAbsoluteBoundsF(true);
4509 GetCursorBounds(true, absCursorBounds);
4510 if (!panelAbsBounds.Contains(FloatPoint(absCursorBounds.x, absCursorBounds.y)))
4512 ScrollPanelToCursorPosition();
4515 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4526 else if (_KEY_DOWN == keyCode || _KEY_NUMPAD_2 == keyCode)
4528 if (__isCopyPasteManagerExist)
4530 InitializeCopyPasteManager();
4533 FinishTextComposition();
4535 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
4536 int totalLine = __pTextObject->GetTotalLineCount();
4537 if (curCursorLine < totalLine - 1)
4539 int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
4540 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
4541 int newCursorPosition = offset + firstTextIndex;
4542 int textLength = __pTextObject->GetTextLengthAt(curCursorLine+1);
4544 if (offset<textLength)
4546 int startPosition = -1;
4547 int endPosition = -1;
4548 GetTextImageRangeAt(newCursorPosition, startPosition, endPosition);
4549 if (endPosition > newCursorPosition && startPosition < newCursorPosition)
4551 newCursorPosition = endPosition;
4553 SetCursorPosition(newCursorPosition);
4558 __pTextString->GetCharAt(firstTextIndex+textLength - 1, ch);
4561 if (textLength == 0)
4563 SetCursorPosition(firstTextIndex);
4567 SetCursorPosition(firstTextIndex+textLength - 1);
4572 SetCursorPosition(firstTextIndex+textLength);
4578 panelAbsBounds = __pParentPanel->GetAbsoluteBoundsF(true);
4579 GetCursorBounds(true, absCursorBounds);
4581 if (!panelAbsBounds.Contains(FloatPoint(absCursorBounds.x, absCursorBounds.y + absCursorBounds.height)))
4583 ScrollPanelToCursorPosition();
4586 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4597 else if (_KEY_RIGHT == keyCode || _KEY_NUMPAD_6 == keyCode)
4599 if (__isCopyPasteManagerExist)
4601 InitializeCopyPasteManager();
4604 FinishTextComposition();
4606 if (__cursorPos == GetTextLength())
4611 if (__cursorPos < GetTextLength())
4613 int startPosition = -1;
4614 int endPosition = -1;
4615 GetTextImageRangeAt(__cursorPos, startPosition, endPosition);
4617 if (endPosition > __cursorPos+1 && startPosition > -1)
4619 SetCursorPosition(endPosition);
4623 SetCursorPosition(__cursorPos+1);
4628 panelAbsBounds = __pParentPanel->GetAbsoluteBoundsF(true);
4629 GetCursorBounds(true, absCursorBounds);
4631 if (!panelAbsBounds.Contains(FloatPoint(absCursorBounds.x, absCursorBounds.y + absCursorBounds.height)))
4633 ScrollPanelToCursorPosition();
4637 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4643 __pEdit->Invalidate();
4648 else if (_KEY_DELETE == keyCode)
4650 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4652 if (!GetTextLength())
4658 if (__isCopyPasteManagerExist)
4660 if (IsBlocked() == true)
4664 GetBlockRange(start, end);
4665 DeleteText(start, end);
4670 int cursorPosition = GetCursorPosition();
4671 DeleteText(cursorPosition, cursorPosition+1);
4674 InitializeCopyPasteManager();
4678 FinishTextComposition();
4680 int cursorPosition = GetCursorPosition();
4681 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4683 DeleteText(cursorPosition, cursorPosition+1);
4687 OnSurroundingTextDeleted(0, 1);
4691 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4694 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
4698 __pEdit->Invalidate();
4701 ScrollPanelToCursorPosition();
4705 else if (_KEY_CLIPBOARD== keyCode)
4707 __pClipboard->ShowPopup(CLIPBOARD_DATA_TYPE_TEXT, *__pEdit, true);
4708 __clipboardConnected = true;
4711 else if (__composingTextLength > 0 && GetTextLength() >= __limitLength)
4715 else if (_KEY_TAB == keyCode)
4717 if (__isCopyPasteManagerExist)
4719 InitializeCopyPasteManager();
4720 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4726 __pEdit->Invalidate();
4736 _EditPresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
4738 _KeyCode keyCode = keyInfo.GetKeyCode();
4740 if (__isUSBKeyboardConnected && (keyCode == _KEY_SHIFT_L || keyCode == _KEY_SHIFT_R))
4742 if (__pCopyPasteManager && __pCopyPasteManager->IsHandlerMovingEnabled())
4744 int leftHandler = __pCopyPasteManager->GetHandlerCursorPosition(_EditCopyPasteManager::HANDLER_TYPE_LEFT);
4745 int rightHandler = __pCopyPasteManager->GetHandlerCursorPosition(_EditCopyPasteManager::HANDLER_TYPE_RIGHT);
4746 if (leftHandler > rightHandler)
4748 __pCopyPasteManager->CreateHandle();
4750 __pCopyPasteManager->SetHandlerMovingEnabled(false);
4751 __pCopyPasteManager->CreateCopyPastePopup();
4752 __pCopyPasteManager->Show();
4754 else if (__textBlockMoving)
4756 _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance();
4757 SysTryReturn(NID_UI_CTRL, pAccessibilityManager, false, E_SYSTEM, "pAccessibilityManager is null");
4758 if (!pAccessibilityManager->IsActivated())
4760 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
4761 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, true, E_OUT_OF_MEMORY, "Memory allocation failed.");
4762 __pCopyPasteManager->AddCopyPasteEventListener(*this);
4763 __pCopyPasteManager->CreateCopyPastePopup();
4764 __pCopyPasteManager->Show();
4765 __isCopyPasteManagerExist = true;
4767 __textBlockMoving = false;
4776 _EditPresenter::OnClipboardPopupClosed(const ClipboardItem* pClipboardItem)
4782 String filteredString;
4784 if (!pClipboardItem && IsBlocked())
4789 if (__isCopyPasteManagerExist)
4793 __pCopyPasteManager->SetTextBlockReleaseFlag(false);
4795 InitializeCopyPasteManager();
4798 SysTryReturnVoidResult(NID_UI_CTRL, pClipboardItem != null, E_SYSTEM, "[E_SYSTEM] Unable to get the clipboarditem instance.");
4800 String* pClipString = dynamic_cast<String*>(pClipboardItem->GetData());
4801 SysTryReturnVoidResult(NID_UI_CTRL, pClipString != null, E_SYSTEM, "[E_SYSTEM] Unable to get the clipboarditem instance.");
4804 if (pClipboardItem->GetDataType() == CLIPBOARD_DATA_TYPE_HTML)
4806 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
4809 str = pEcoreEvas->ConvertMarkupToUtf8(*pClipString);
4818 delete pClipboardItem;
4823 int currentLength = GetTextLength();
4824 String* pSubString = null;
4825 result r = E_SUCCESS;
4827 filteredString = *pClipString;
4831 if(__pTextFilter->ValidatePastedText(*pClipString, userString))
4833 filteredString = userString;
4834 SysLog(NID_UI_CTRL, "ClipString was changed by User");
4837 else if (IsUnsupportedChracterExist(GetKeypadStyle(), *pClipString) == true)
4844 GetBlockRange(start, end);
4845 total = currentLength - (end - start) + filteredString.GetLength();
4846 if (total > __limitLength)
4848 DeleteText(start, end);
4850 pSubString = new String(__limitLength - currentLength + (end - start));
4851 SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "Memory allocation failed.");
4853 filteredString.SubString(0, __limitLength - currentLength + (end - start), *pSubString);
4854 r = InsertTextAt(__cursorPos, pSubString->GetPointer());
4855 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4860 DeleteText(start, end);
4862 r = InsertTextAt(__cursorPos, filteredString.GetPointer());
4863 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4866 else if (currentLength + filteredString.GetLength() > __limitLength)
4868 if (__limitLength == currentLength)
4870 delete pClipboardItem;
4874 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE || __pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
4876 int length = filteredString.GetLength();
4877 for (int i = length-1; i >= 0; i--)
4880 filteredString.GetCharAt(i, ch);
4883 filteredString.Remove(i, 1);
4888 pSubString = new String(__limitLength - currentLength);
4889 SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "Memory allocation failed.");
4891 filteredString.SubString(0, __limitLength - currentLength, *pSubString);
4892 r = InsertTextAt(__cursorPos, pSubString->GetPointer());
4893 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4898 r = InsertTextAt(__cursorPos, filteredString.GetPointer());
4899 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4902 ScrollPanelToCursorPosition();
4904 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
4906 __pEdit->Invalidate();
4908 delete pClipboardItem;
4913 delete pClipboardItem;
4919 _EditPresenter::OnLongPressGestureDetected(void)
4921 SysLog(NID_UI_CTRL, "OnLongPressGestureDetected");
4923 if (__isClearIconPressed)
4928 __isTouchPressed = false;
4930 _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance();
4931 SysTryReturn(NID_UI_CTRL, pAccessibilityManager, false, E_SYSTEM, "pAccessibilityManager is null");
4932 if (pAccessibilityManager->IsActivated())
4934 SysLog(NID_UI_CTRL, "Copy&Paste is not created (ScreenReader is activated)");
4939 int columnIndex = -1;
4942 if (__isCopyPasteManagerExist)
4945 #if EDIT_DRAG_AND_DROP_ENABLED
4950 GetBlockRange(start, end);
4951 __dragAndDropString = GetText(start, end-1);
4952 _DragAndDropItem* pDragAndDropItem = _DragAndDropItem::CreateInstanceN(_DRAG_AND_DROP_TYPE_TEXT, __dragAndDropString);
4953 SysTryReturn(NID_UI_CTRL, pDragAndDropItem, false, E_OUT_OF_MEMORY, "Memory allocation failed.");
4955 cursorPos = GetCursorPositionAt(__pressedPoint, rowIndex, columnIndex);
4956 if (cursorPos != -1)
4958 SetCursorPosition(cursorPos);
4962 cursorPos = GetTextLength();
4963 SetCursorPosition(cursorPos);
4966 __pEdit->DragAndDropBegin(*pDragAndDropItem);
4967 delete pDragAndDropItem;
4969 __dragAndDropStarted = true;
4970 InitializeCopyPasteManager();
4976 cursorPos = GetCursorPositionAt(__pressedPoint, rowIndex, columnIndex);
4977 if (cursorPos != -1)
4979 SetCursorPosition(cursorPos);
4985 __pCopyPasteManager->CreateCopyPasteMagnifier();
4986 __pCopyPasteManager->Show();
4987 __isTouchLongPressed = true;
4988 __needToCreateCopyPastePopup = true;
4992 else if (IsCurrentFocused() == false)
4994 if (IsViewModeEnabled())
4996 __pEdit->SetFocused();
5004 FloatRectangle cursorBounds;
5005 InitializeCopyPasteManager();
5006 if (IsClipped() || GetTextLength())
5008 if (IsClipped() && !GetTextLength() && (__pEdit->IsViewModeEnabled()))
5013 if (!IsClipped() && (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD))
5018 FinishTextComposition();
5020 if (__pPasswordTimer)
5022 ChangePasswordToEchoCharacter(__pTextBuffer, __echoChar);
5023 StopPasswordTimer();
5026 cursorPos = GetCursorPositionAt(__pressedPoint, rowIndex, columnIndex);
5027 if (cursorPos != -1)
5029 SetCursorPosition(cursorPos);
5033 cursorPos = GetTextLength();
5034 SetCursorPosition(cursorPos);
5036 ScrollPanelToCursorPosition();
5037 GetCursorBounds(true, cursorBounds);
5039 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
5040 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, false, E_SYSTEM, "Unable to create _EditCopyPasteManager instance.");
5041 __pCopyPasteManager->AddCopyPasteEventListener(*this);
5042 __pCopyPasteManager->Show();
5043 __isCopyPasteManagerExist = true;
5044 __isTouchLongPressed = true;
5045 __needToCreateCopyPastePopup = true;
5053 _EditPresenter::OnTapGestureDetected(void)
5055 SysLog(NID_UI_CTRL, "OnTapGestureDetected");
5057 _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance();
5058 SysTryReturn(NID_UI_CTRL, pAccessibilityManager, false, E_SYSTEM, "pAccessibilityManager is null");
5059 if (pAccessibilityManager->IsActivated())
5061 SysLog(NID_UI_CTRL, "Copy&Paste is not created (ScreenReader is activated)");
5065 if (IsCurrentFocused() == false)
5070 if (!__isUSBKeyboardConnected)
5072 if (__isKeypadShowing)
5076 __isTouchPressed = false;
5077 InitializeCopyPasteManager();
5079 if (GetTextLength() > 0)
5081 FloatRectangle cursorBounds;
5084 int cursorPos = GetCursorPositionAt(__pressedPoint);
5086 if (cursorPos == -1)
5088 cursorPos = GetTextLength();
5092 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(cursorPos);
5093 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine);
5094 if (cursorPos != 0 && cursorPos == firstTextIndex && __rowCursorIndex != curCursorLine)
5100 FinishTextComposition();
5102 GetWordPosition(cursorPos, start, end);
5103 SetBlockRange(start, end);
5104 ScrollPanelToCursorPosition();
5105 GetCursorBounds(true, cursorBounds);
5107 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
5108 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, false, E_SYSTEM, "Unable to create _EditCopyPasteManager instance.");
5109 __pCopyPasteManager->AddCopyPasteEventListener(*this);
5110 __pCopyPasteManager->Show();
5111 __isCopyPasteManagerExist = true;
5112 __needToCreateCopyPastePopup = true;
5121 _EditPresenter::GetTextAlignment(void) const
5123 return __horizontalAlignment;
5127 _EditPresenter::GetLineSpacing(void) const
5129 int linePixelGap = -1;
5131 linePixelGap = __pTextObject->GetLineSpace();
5133 return linePixelGap;
5137 _EditPresenter::GetLineSpacingF(void) const
5139 float linePixelGap = -1.0;
5141 linePixelGap = __pTextObject->GetLineSpaceF();
5143 return linePixelGap;
5147 _EditPresenter::GetBlockRange(int& start, int& end) const
5149 if (__isTextBlocked == false || __cursorPos == __blockStartPos)
5154 if (__cursorPos > __blockStartPos)
5156 start = __blockStartPos;
5161 start = __cursorPos;
5162 end = __blockStartPos;
5169 _EditPresenter::SetBlockRange(int start, int end)
5171 result r = E_SUCCESS;
5173 r = SetCursorPosition(start);
5174 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5176 r = BeginTextBlock();
5177 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5179 r = SetCursorPosition(end);
5180 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5186 _EditPresenter::SetBlockRange(int start, int end, int leftRowIndex, int leftColumnIndex, int rightRowIndex, int rightColumnIndex)
5188 result r = E_SUCCESS;
5190 if (leftRowIndex == -1 && leftColumnIndex == -1)
5192 r = SetCursorPosition(start);
5196 r = SetCursorPosition(start, leftRowIndex, leftColumnIndex);
5198 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5200 r = BeginTextBlock();
5201 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5203 if (rightRowIndex == -1 && rightColumnIndex == -1)
5205 r = SetCursorPosition(end);
5209 r = SetCursorPosition(end, rightRowIndex, rightColumnIndex);
5211 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5217 _EditPresenter::BeginTextBlock(void)
5219 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
5222 __isTextBlocked = true;
5223 __blockStartPos = __cursorPos;
5229 _EditPresenter::ReleaseTextBlock(void)
5231 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
5235 if (__isTextBlocked == false)
5240 __isTextBlocked = false;
5246 _EditPresenter::IsBlocked(void) const
5248 return __isTextBlocked;
5252 _EditPresenter::CopyText(void)
5254 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
5257 result r = E_SUCCESS;
5259 _Clipboard* pClipBoard = _Clipboard::GetInstance();
5260 SysTryReturnResult(NID_UI_CTRL, pClipBoard != null, E_SYSTEM, "Unable to get the clipboard instance.");
5264 GetBlockRange(start, end);
5266 String blockString(GetText(start, end - 1));
5268 _ClipboardItem* pClipboardItem = _ClipboardItem::CreateInstanceN(CLIPBOARD_DATA_TYPE_TEXT, blockString);
5269 SysTryReturnResult(NID_UI_CTRL, pClipboardItem != null, E_SYSTEM, "Unable to get the clipboarditem instance.");
5271 r = pClipBoard->CopyItem(*pClipboardItem);
5273 delete pClipboardItem;
5275 _Text::TextElement* pStartTextElement = __pTextObject->GetElementAtTextIndex(start);
5276 _Text::TextElement* pEndTextElement = __pTextObject->GetElementAtTextIndex(end-1);
5278 if (pStartTextElement == null || pEndTextElement == null)
5283 const int startIndex = __pTextObject->GetElementIndexOf(*pStartTextElement);
5284 const int endIndex = __pTextObject->GetElementIndexOf(*pEndTextElement);
5286 for (int index = startIndex; index <= endIndex; index++)
5288 _Text::TextElement* pTextElement = __pTextObject->GetElementAtElementIndex(index);
5289 TextElementType objectType = pTextElement->GetType();
5290 if (objectType != TEXT_ELEMENT_TYPE_IMAGE)
5294 TextImage* pImageText = null;
5295 pImageText = dynamic_cast < TextImage* >(pTextElement);
5296 if (pImageText == null)
5300 const Bitmap * pImage = pImageText->GetBitmap();
5301 SysTryReturnResult(NID_UI_CTRL, pImage != null, E_SYSTEM, "Unable to get the bitmap from textobject.");
5303 _ClipboardItem* pClipboardImageItem = _ClipboardItem::CreateInstanceN(CLIPBOARD_DATA_TYPE_IMAGE, *pImage);
5304 SysTryReturnResult(NID_UI_CTRL, pClipboardImageItem != null, E_SYSTEM, "Unable to get the clipboardImageitem instance.");
5306 r = pClipBoard->CopyItem(*pClipboardImageItem);
5308 delete pClipboardImageItem;
5315 _EditPresenter::CutText(void)
5317 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
5320 result r = E_SUCCESS;
5323 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5327 GetBlockRange(start, end);
5328 DeleteText(start, end);
5331 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
5337 _EditPresenter::PasteText(void)
5339 result r = E_SUCCESS;
5340 int currentLength = GetTextLength();
5341 String* pSubString = null;
5346 String filteredString;
5349 _Clipboard* pClipBoard = _Clipboard::GetInstance();
5350 SysTryReturnResult(NID_UI_CTRL, pClipBoard != null, E_SYSTEM, "Unable to get the clipboard instance.");
5352 const _ClipboardItem* pClipboardItem = pClipBoard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT|CLIPBOARD_DATA_TYPE_AUDIO | CLIPBOARD_DATA_TYPE_VIDEO|CLIPBOARD_DATA_TYPE_HTML);
5353 SysTryReturnResult(NID_UI_CTRL, pClipboardItem != null, E_SYSTEM, "Unable to get the clipboarditem instance.");
5355 const String* pClipString = dynamic_cast<const String*>(pClipboardItem->GetData());
5356 SysTryCatch(NID_UI_CTRL, pClipString, r = E_SYSTEM, E_SYSTEM, "Unable to get the clipboarditem instance.");
5358 if (pClipboardItem->GetDataType() == CLIPBOARD_DATA_TYPE_HTML)
5360 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
5363 str = pEcoreEvas->ConvertMarkupToUtf8(*pClipString);
5368 delete pClipboardItem;
5373 filteredString = *pClipString;
5377 if(__pTextFilter->ValidatePastedText(*pClipString, userString))
5379 filteredString = userString;
5380 SysLog(NID_UI_CTRL, "ClipString was changed by User");
5383 else if (IsUnsupportedChracterExist(GetKeypadStyle(), *pClipString) == true)
5390 GetBlockRange(start, end);
5391 total = currentLength - (end - start) + filteredString.GetLength();
5392 if (total > __limitLength)
5394 DeleteText(start, end);
5396 pSubString = new String(__limitLength - currentLength + (end - start));
5397 SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "Memory allocation failed.");
5399 filteredString.SubString(0, __limitLength - currentLength + (end - start), *pSubString);
5400 r = InsertTextAt(__cursorPos, pSubString->GetPointer());
5401 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5406 DeleteText(start, end);
5408 r = InsertTextAt(__cursorPos, filteredString.GetPointer());
5409 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5412 else if (currentLength + filteredString.GetLength() > __limitLength)
5414 if (__limitLength == currentLength)
5416 delete pClipboardItem;
5419 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE || __pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
5421 int length = filteredString.GetLength();
5422 for (int i = length-1; i >= 0; i--)
5425 filteredString.GetCharAt(i, ch);
5428 filteredString.Remove(i, 1);
5432 pSubString = new String(__limitLength - currentLength);
5433 SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "Memory allocation failed.");
5435 filteredString.SubString(0, __limitLength - currentLength, *pSubString);
5436 r = InsertTextAt(__cursorPos, pSubString->GetPointer());
5437 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5442 r = InsertTextAt(__cursorPos, filteredString.GetPointer());
5443 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5446 delete pClipboardItem;
5448 ReplaceTextIntoPasswordHyphenString();
5449 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
5451 __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), 0);
5454 ScrollPanelToCursorPosition();
5456 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
5461 delete pClipboardItem;
5467 _EditPresenter::RemoveTextBlock(void)
5469 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
5473 if (!__isTextBlocked)
5475 return E_OBJ_NOT_FOUND;
5481 GetBlockRange(start, end);
5484 return E_OBJ_NOT_FOUND;
5487 result r = DeleteText(start, end);
5488 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5490 __isTextBlocked = false;
5492 InitializeCopyPasteManager();
5498 _EditPresenter::IsClipped(void) const
5501 _Clipboard* pClipBoard = _Clipboard::GetInstance();
5502 SysTryReturn(NID_UI_CTRL, pClipBoard != null, false, E_SYSTEM, "Unable to get the clipboard instance.");
5504 const _ClipboardItem* pClipboardItem = pClipBoard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT|CLIPBOARD_DATA_TYPE_AUDIO | CLIPBOARD_DATA_TYPE_VIDEO|CLIPBOARD_DATA_TYPE_HTML);
5505 if (pClipboardItem == null)
5507 SetLastResult(E_SUCCESS);
5511 const String* pClipString = dynamic_cast<const String*>(pClipboardItem->GetData());
5512 SysTryCatch(NID_UI_CTRL, pClipString, , GetLastResult(), "Unable to get the clipboarditem data.");
5514 if (pClipboardItem->GetDataType() == CLIPBOARD_DATA_TYPE_HTML)
5516 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
5519 str = pEcoreEvas->ConvertMarkupToUtf8(*pClipString);
5524 delete pClipboardItem;
5529 delete pClipboardItem;
5533 delete pClipboardItem;
5538 _EditPresenter::SetTextAlignment(HorizontalAlignment alignment)
5540 result r = E_SUCCESS;
5542 int textAlign = TEXT_OBJECT_ALIGNMENT_LEFT;
5544 if (alignment == ALIGNMENT_CENTER)
5546 textAlign = TEXT_OBJECT_ALIGNMENT_CENTER;
5548 else if (alignment == ALIGNMENT_RIGHT)
5550 textAlign = TEXT_OBJECT_ALIGNMENT_RIGHT;
5553 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
5555 r = __pTextObject->SetAlignment(textAlign | TEXT_OBJECT_ALIGNMENT_MIDDLE);
5559 r = __pTextObject->SetAlignment(textAlign | TEXT_OBJECT_ALIGNMENT_TOP);
5561 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Unable to set text alignment.");
5562 __horizontalAlignment = alignment;
5568 _EditPresenter::SetLineSpacing(int linePixelGap)
5570 result r = E_SUCCESS;
5572 __pTextObject->SetLineSpace(linePixelGap);
5578 _EditPresenter::SetLineSpacing(float linePixelGap)
5580 result r = E_SUCCESS;
5582 __pTextObject->SetLineSpace(linePixelGap);
5588 _EditPresenter::GetText(int start, int end) const
5592 if (start != 0 && end != -1)
5594 SysTryReturn(NID_UI_CTRL, (start <= end), tempString, E_SYSTEM, "[E_SYSTEM] The invalid argument(start = %d, end = %d) is given.", start, end);
5595 int textLength = GetTextLength();
5596 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);
5599 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
5601 int length = end - start + 1;
5602 __pTextString->SubString(start, length, tempString);
5607 String resultString;
5608 String elementString;
5609 const int textElementCount = __pTextObject->GetElementCount();
5610 _Text::TextElement* pTextElement = __pTextObject->GetElementAtTextIndex(start);
5612 if (pTextElement == null)
5614 return resultString;
5616 const int startIndex = __pTextObject->GetElementIndexOf(*pTextElement);
5618 for (int index = startIndex; index < textElementCount; index++)
5620 _Text::TextElement* pTextElement = __pTextObject->GetElementAtElementIndex(index);
5621 TextSimple* pSimpleText = null;
5622 if (pTextElement == null)
5627 TextElementType objectType = pTextElement->GetType();
5628 if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK)
5630 pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
5631 if (pSimpleText == null)
5642 int elementOffset = static_cast < int >(pTextElement->GetValue(SET_TEXT_OFFSET));
5643 int elementLength = pTextElement->GetTextLength();
5645 if (objectType == TEXT_ELEMENT_TYPE_CUTLINK)
5647 elementOffset = GetLinkElementOffsetInTextBuffer(index);
5648 if (elementOffset < 0)
5654 if (end < elementOffset)
5658 if (start >= elementOffset + elementLength)
5663 if (elementLength == 0)
5667 elementString.Clear();
5668 elementString.Append(pSimpleText->GetText());
5669 elementString.SetLength(elementLength);
5670 if (end < elementOffset + elementLength - 1)
5672 int removingStartIndex = end + 1;
5673 elementString.Remove(removingStartIndex - elementOffset, elementOffset + elementLength - removingStartIndex);
5675 if (start > elementOffset)
5677 elementString.Remove(0, start - elementOffset);
5679 resultString.Append(elementString);
5682 return resultString;
5686 _EditPresenter::GetText(void) const
5688 return GetText(0, GetTextLength()-1);
5692 _EditPresenter::SetText(const String& text)
5694 result r = E_SUCCESS;
5696 InitializeCopyPasteManager();
5698 int length = text.GetLength();
5700 if (__pEdit->IsViewModeEnabled())
5702 if (__limitLength <= length)
5704 String tempString = GetText();
5705 SetTextLimitLength(length * 2);
5710 SysTryReturnResult(NID_UI_CTRL, length <= __limitLength, E_INVALID_ARG, "The Invalid argument is given.");
5713 FinishTextComposition();
5715 __pTextString->Clear();
5716 __pTextString->Append(text);
5718 wchar_t* tempString = const_cast<wchar_t*>(text.GetPointer());
5719 for (int i = 0; i < length; i++)
5721 __pTextBuffer[i] = tempString[i];
5723 __pTextBuffer[length] = 0;
5725 __pTextObject->RemoveAll();
5726 TextSimple* pSimpleText = new (std::nothrow)TextSimple(__pTextBuffer, length,TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, __pFont);
5727 __pTextObject->AppendElement(*pSimpleText);
5729 if (__isInitialized == true)
5731 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT);
5733 __pTextObject->Compose();
5735 ReplaceTextIntoPasswordHyphenString();
5737 __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), 0);
5739 SetCursorPosition(length);
5741 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
5743 AdjustFlexibleHeight();
5746 if (__pEdit->IsViewModeEnabled())
5748 __isCutLinkParserEnabled = true;
5751 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
5757 _EditPresenter::GetRemainingLength(void) const
5759 return __limitLength - __pTextObject->GetTextLength();
5763 _EditPresenter::SetCursorPosition(int position)
5765 result r = E_SUCCESS;
5766 int length = GetTextLength();
5768 SysTryReturnResult(NID_UI_CTRL, -1 < position && position <= length, E_INVALID_ARG, "Invalid argument is given.");
5770 if (__isTouchMoving == false)
5772 __isCursorChanged = true;
5775 r = __pTextObject->SetCursorIndex(position);
5776 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Failed to set cursor position");
5778 if (__cursorPos != position)
5780 __pTextObject->ConvertToRowColumn(position, __rowCursorIndex, __columnCursorIndex);
5781 __cursorPos = position;
5788 _EditPresenter::SetCursorPosition(int position,int rowIndex, int columnIndex)
5790 result r = E_SUCCESS;
5791 int length = GetTextLength();
5793 SysTryReturnResult(NID_UI_CTRL, -1 < position && position <= length, E_INVALID_ARG, "Invalid argument is given.");
5795 if (__isTouchMoving == false)
5797 __isCursorChanged = true;
5800 r = __pTextObject->SetCursorIndex(position);
5801 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Failed to set cursor position");
5803 __rowCursorIndex = rowIndex;
5804 __columnCursorIndex = columnIndex;
5806 __cursorPos = position;
5812 _EditPresenter::GetCursorPosition(void) const
5818 _EditPresenter::GetTextLength(void) const
5820 return __pTextObject->GetTextLength();
5824 _EditPresenter::InsertTextAt(int index, const String& text)
5826 result r = E_SUCCESS;
5828 int currentLength = GetTextLength();
5829 int length = text.GetLength();
5830 int totalLength = currentLength + length;
5831 String insertText = text;
5834 SysTryReturnResult(NID_UI_CTRL, index >= 0 && index <= currentLength, E_OUT_OF_RANGE, "The Invalid argument is given.");
5836 if (__pEdit->IsViewModeEnabled())
5838 if (__limitLength <= totalLength)
5840 String tempString = GetText();
5841 SetTextLimitLength(totalLength * 2);
5842 SetText(tempString);
5847 SysTryReturnResult(NID_UI_CTRL, totalLength <= __limitLength, E_MAX_EXCEEDED, "The Invalid argument is given.");
5850 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE || __pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
5852 while (insertText.Contains(String(L"\n")))
5854 for (i = 0; i < length; i++)
5857 insertText.GetCharAt(i, ch);
5860 insertText.Remove(i, 1);
5861 length = insertText.GetLength();
5874 r = __pTextString->Insert(insertText, index);
5875 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5877 wchar_t* pTempString = const_cast<wchar_t*>(insertText.GetPointer());
5878 wchar_t pOriginalString[currentLength - index];
5880 for (int i = 0; i < currentLength - index; i++)
5882 pOriginalString[i] = __pTextBuffer[index + i];
5884 pOriginalString[currentLength - index] = 0;
5886 for (int i = 0; i < length; i++)
5888 __pTextBuffer[i + index] = pTempString[i];
5891 for (int i = 0; i < currentLength - index; i++)
5893 __pTextBuffer[i + index + length] = pOriginalString[i];
5895 __pTextBuffer[totalLength] = 0;
5897 __pTextObject->InputText(index);
5898 __pTextObject->SetRange(index, length);
5899 r = __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), length);
5900 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Failed to set length");
5902 __pTextObject->Compose();
5904 if (__isTextBlocked == true)
5906 DeleteText(__blockStartPos, __cursorPos);
5909 SetCursorPosition(__cursorPos + length);
5913 SetCursorPosition(index + length);
5916 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
5918 AdjustFlexibleHeight();
5921 __isCursorChanged = true;
5923 if (__pEdit->IsViewModeEnabled())
5925 __isCutLinkParserEnabled = true;
5928 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
5934 _EditPresenter::AppendText(const String& text)
5936 result r = E_SUCCESS;
5938 int currentLength = GetTextLength();
5939 int length = text.GetLength();
5940 int totalLength = currentLength + length;
5942 if (__pEdit->IsViewModeEnabled())
5944 if (__limitLength <= totalLength)
5946 String tempString = GetText();
5947 SetTextLimitLength(totalLength * 2);
5948 SetText(tempString);
5953 SysTryReturnResult(NID_UI_CTRL, totalLength <= __limitLength, E_MAX_EXCEEDED, "The Invalid argument is given.");
5956 r = __pTextString->Append(text);
5957 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5959 wchar_t* pTempString = const_cast<wchar_t*>(text.GetPointer());
5961 for (int i = 0; i < length; i++)
5963 __pTextBuffer[i + currentLength] = pTempString[i];
5965 __pTextBuffer[totalLength] = 0;
5967 __pTextObject->SetRange(currentLength, length);
5968 r = __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), length);
5969 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Failed to set length");
5971 __pTextObject->Compose();
5973 if (!__isTextBlocked)
5975 SetCursorPosition(totalLength);
5978 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
5980 AdjustFlexibleHeight();
5983 if (__pEdit->IsViewModeEnabled())
5985 __isCutLinkParserEnabled = true;
5988 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
5994 _EditPresenter::AppendCharacter(const Character& character)
5996 result r = E_SUCCESS;
5998 r = AppendText(character.ToString());
6004 _EditPresenter::ClearText(void)
6006 InitializeCopyPasteManager();
6008 result r = E_SUCCESS;
6010 FinishTextComposition();
6012 int textLength = GetTextLength();
6014 if (textLength == 0)
6019 r = DeleteText(0, textLength);
6020 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
6022 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_CLEAR_ICON);
6028 _EditPresenter::DeleteCharacterAt(int index)
6030 result r = E_SUCCESS;
6033 length = GetTextLength();
6035 SysTryReturnResult(NID_UI_CTRL, index >= 0, E_INVALID_ARG, "Specified index is negative.");
6036 SysTryReturnResult(NID_UI_CTRL, index < length, E_OUT_OF_RANGE, "Specified index is outside the range.");
6038 r = DeleteText(index, index+1);
6043 _EditPresenter::DeleteText(int startCursorPosition, int endCursorPosition)
6045 result r = E_SUCCESS;
6047 int length = GetTextLength();
6049 SysTryReturnResult(NID_UI_CTRL, -1 < startCursorPosition && startCursorPosition < endCursorPosition, E_INVALID_ARG, "Invalid argument is given.");
6050 SysTryReturnResult(NID_UI_CTRL, startCursorPosition < endCursorPosition && endCursorPosition <= length, E_INVALID_ARG, "Invalid argument is given.");
6052 _Text::TextElement* pFirstTextElement = __pTextObject->GetElementAtTextIndex(startCursorPosition);
6053 const TextSimple* pFirstSimpleText = dynamic_cast <const TextSimple*>(pFirstTextElement);
6054 if (pFirstSimpleText != null && pFirstSimpleText->GetBitmap() != null)
6056 if (pFirstSimpleText->GetTextOffset() < startCursorPosition)
6058 startCursorPosition = pFirstSimpleText->GetTextOffset();
6061 _Text::TextElement* pLastTextElement = __pTextObject->GetElementAtTextIndex(endCursorPosition - 1);
6062 const TextSimple* pLastSimpleText = dynamic_cast <const TextSimple*>(pLastTextElement);
6063 if (pLastSimpleText != null && pLastSimpleText->GetBitmap() != null)
6065 if ((pLastSimpleText->GetTextOffset() + pLastSimpleText->GetTextLength()) > endCursorPosition)
6067 endCursorPosition = pLastSimpleText->GetTextOffset() + pLastSimpleText->GetTextLength();
6071 r = __pTextString->Remove(startCursorPosition, endCursorPosition - startCursorPosition);
6072 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
6074 int currentLength = __pTextString->GetLength();
6076 for (int i = startCursorPosition; i < length; i++)
6078 if ((i + length - currentLength) >= length)
6082 __pTextBuffer[i] = __pTextBuffer[i + (length - currentLength)];
6085 for (int i = currentLength; i < length; i++)
6087 __pTextBuffer[i] = 0;
6090 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT);
6092 __pTextObject->RemoveText(startCursorPosition);
6093 __pTextObject->SetRange(startCursorPosition, endCursorPosition - startCursorPosition);
6094 r = __pTextObject->NotifyTextChanged(__pTextBuffer, 0, currentLength, -(endCursorPosition - startCursorPosition));
6095 r = __pTextObject->Compose();
6097 SetCursorPosition(startCursorPosition);
6099 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
6101 AdjustFlexibleHeight();
6104 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
6110 _EditPresenter::GetCurrentTextRange(int& start, int& end) const
6112 int currentLength = __pTextString->GetLength();
6114 start = __cursorPos;
6117 if (__pTextBuffer[--start] == TEXT_OBJ_CHARACTER)
6125 while (end < currentLength && __pTextBuffer[end] != TEXT_OBJ_CHARACTER)
6134 _EditPresenter::GetTextLimitLength(void) const
6136 return __limitLength;
6140 _EditPresenter::SetTextLimitLength(int limitLength)
6142 result r = E_SUCCESS;
6144 SysTryReturnResult(NID_UI_CTRL, (limitLength > 0), E_INVALID_ARG, "The invalid limit length is given.");
6146 String tempString = GetText();
6148 int textLength = tempString.GetLength();
6149 SysTryReturnResult(NID_UI_CTRL, (limitLength >= textLength), E_INVALID_ARG, "The invalid argument is given.");
6151 TextSimple* pSimpleText = null;
6153 if (limitLength == GetTextLimitLength())
6158 wchar_t* pTempBuffer = new (std::nothrow) wchar_t[limitLength + 1];
6159 SysTryReturnResult(NID_UI_CTRL, pTempBuffer, E_OUT_OF_MEMORY, "Memory allocation failed.");
6161 for (int i = 0; i < textLength; i++)
6163 pTempBuffer[i] = __pTextBuffer[i];
6166 for (int i = textLength; i < limitLength; i++)
6171 pTempBuffer[limitLength] = '\0';
6173 __pTextString->Clear();
6174 __pTextString->Append(tempString);
6177 delete[] __pTextBuffer;
6178 __pTextBuffer = null;
6180 __pTextBuffer = pTempBuffer;
6182 __pTextObject->RemoveAll();
6183 pSimpleText = new (std::nothrow)TextSimple(__pTextBuffer, textLength, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, __pFont);
6184 SysTryReturnResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "Memory allocation failed.");
6186 r = __pTextObject->AppendElement(*pSimpleText);
6187 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6189 SetCursorPosition(textLength);
6191 __limitLength = limitLength;
6202 _EditPresenter::InsertCharacterAt(int index, const Character& character)
6204 result r = E_SUCCESS;
6206 r = InsertTextAt(index, character.ToString());
6212 _EditPresenter::SetModel(const _EditModel& editModel)
6216 delete __pEditModel;
6217 __pEditModel = null;
6220 __pEditModel = const_cast<_EditModel*>(&editModel);
6226 _EditPresenter::SetAutoLinkMask(unsigned long autoLinks)
6228 __isCutLinkParserEnabled = true;
6229 return __pEditModel->SetAutoLinkMask(autoLinks);
6233 _EditPresenter::GetAutoLinkMask(void) const
6235 return __pEditModel->GetAutoLinkMask();
6239 _EditPresenter::IsViewModeEnabled(bool internal) const
6241 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
6243 return __pEditModel->IsViewModeEnabled();
6253 return __pEditModel->IsViewModeEnabled();
6259 _EditPresenter::SetViewModeEnabled(bool enable)
6261 if (!enable && __pEditModel->IsViewModeEnabled() && IsCurrentFocused() && (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY))
6263 __pEdit->SetFocused(false);
6266 int editStyle = __pEdit->GetEditStyle();
6270 editStyle = editStyle | EDIT_STYLE_VIEWER;
6274 editStyle = editStyle & (~EDIT_STYLE_VIEWER);
6276 __pEdit->SetEditStyle(editStyle);
6280 __pEdit->SetCursorPosition(0);
6282 if (__pInputConnection && __isInputConnectionBound)
6288 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
6290 __isCursorDisabled = enable;
6291 __pTextObject->SetCutLinkViewMode(enable);
6294 if (__pInputConnection)
6298 __pInputConnection->SetKeyEventSkipped(true);
6302 if (IsKeypadEnabled())
6304 __pInputConnection->SetKeyEventSkipped(false);
6309 return __pEditModel->SetViewModeEnabled(enable);
6313 _EditPresenter::SetKeypadActionEnabled(bool enable)
6316 result r = E_SUCCESS;
6318 r = __pInputConnection->SetInputPanelActionEnabled(enable);
6321 __pEditModel->SetKeypadActionEnabled(enable);
6327 _EditPresenter::IsKeypadActionEnabled(void)
6330 bool enableIc = true;
6332 enable = __pEditModel->IsKeypadActionEnabled();
6333 enableIc = __pInputConnection->IsInputPanelActionEnabled();
6339 _EditPresenter::GetKeypadAction(void) const
6341 return __pEditModel->GetKeypadAction();
6345 _EditPresenter::ConvertKeypadAction(CoreKeypadAction keypadAction)
6347 InputPanelAction inputPanelAction = INPUT_PANEL_ACTION_ENTER;
6349 switch (keypadAction)
6351 case CORE_KEYPAD_ACTION_ENTER:
6352 inputPanelAction = INPUT_PANEL_ACTION_ENTER;
6354 case CORE_KEYPAD_ACTION_GO:
6355 inputPanelAction = INPUT_PANEL_ACTION_GO;
6357 case CORE_KEYPAD_ACTION_NEXT:
6358 inputPanelAction = INPUT_PANEL_ACTION_NEXT;
6360 case CORE_KEYPAD_ACTION_SEND:
6361 inputPanelAction = INPUT_PANEL_ACTION_SEND;
6363 case CORE_KEYPAD_ACTION_SEARCH:
6364 inputPanelAction = INPUT_PANEL_ACTION_SEARCH;
6366 case CORE_KEYPAD_ACTION_LOGIN:
6367 inputPanelAction = INPUT_PANEL_ACTION_LOGIN;
6369 case CORE_KEYPAD_ACTION_SIGN_IN:
6370 inputPanelAction = INPUT_PANEL_ACTION_SIGN_IN;
6372 case CORE_KEYPAD_ACTION_JOIN:
6373 inputPanelAction = INPUT_PANEL_ACTION_JOIN;
6375 case CORE_KEYPAD_ACTION_DONE:
6376 inputPanelAction = INPUT_PANEL_ACTION_DONE;
6382 return inputPanelAction;
6387 _EditPresenter::SetKeypadAction(CoreKeypadAction keypadAction)
6389 return __pEditModel->SetKeypadAction(keypadAction);
6393 _EditPresenter::SetKeypadEnabled(bool enable)
6395 if (!enable && IsKeypadEnabled())
6397 CheckUSBKeyboardStatus();
6399 if (!__isUSBKeyboardConnected && __isInputConnectionBound)
6405 __pEditModel->SetKeypadEnabled(enable);
6407 if (__pInputConnection)
6411 __pInputConnection->SetKeyEventSkipped(true);
6415 if (!__pEditModel->IsViewModeEnabled())
6417 __pInputConnection->SetKeyEventSkipped(false);
6426 _EditPresenter::SetKeypadEventSkipped(bool skip)
6430 __pInputConnection->SetKeyEventSkipped(true);
6434 if (__pEdit->IsEnabled() && !__pEditModel->IsViewModeEnabled() && IsKeypadEnabled())
6436 __pInputConnection->SetKeyEventSkipped(false);
6442 _EditPresenter::IsKeypadEnabled(void)
6446 if (__pEdit->IsEnabled())
6448 enable = __pEditModel->IsKeypadEnabled();
6459 _EditPresenter::SetCurrentLanguage(LanguageCode languageCode)
6461 result r = E_SUCCESS;
6463 if (__pInputConnection && __isInputConnectionBound)
6465 r = __pInputConnection->SetInputPanelLanguage(languageCode);
6466 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
6467 r = __pEditModel->SetInitialKeypadLanguage(LANGUAGE_INVALID);
6468 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
6472 r = __pEditModel->SetInitialKeypadLanguage(languageCode);
6473 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
6476 r = __pEditModel->SetCurrentLanguage(languageCode);
6482 _EditPresenter::GetCurrentLanguage(LanguageCode& language) const
6484 result r = E_SUCCESS;
6485 if (__pInputConnection && __isInputConnectionBound)
6487 language = __pInputConnection->GetInputPanelLanguage();
6488 r = __pEditModel->SetCurrentLanguage(language);
6489 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
6492 return __pEditModel->GetCurrentLanguage(language);
6496 _EditPresenter::SetLowerCaseModeEnabled(bool enable)
6498 __pEditModel->SetLowerCaseModeEnabled(enable);
6504 _EditPresenter::IsLowerCaseModeEnabled(void) const
6506 return __pEditModel->IsLowerCaseModeEnabled();
6510 _EditPresenter::GetKeypadStyle(void) const
6512 return __pEditModel->GetKeypadStyle();
6516 _EditPresenter::SetKeypadStyle(KeypadStyle keypadStyle)
6519 bool textPredictionEnabled = __pEditModel->IsTextPredictionEnabled();
6521 InputPanelStyle inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
6523 switch (keypadStyle)
6525 case KEYPAD_STYLE_NORMAL:
6526 if (__isKeypadNormalNumberStyleEnabled)
6528 inputPanelStyle = INPUT_PANEL_STYLE_NUMBER;
6532 inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
6535 case KEYPAD_STYLE_PASSWORD:
6536 inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
6537 if (__pInputConnection)
6539 __pInputConnection->SetPasswordMode(true);
6542 case KEYPAD_STYLE_EMAIL:
6543 inputPanelStyle = INPUT_PANEL_STYLE_EMAIL;
6545 case KEYPAD_STYLE_URL:
6546 inputPanelStyle = INPUT_PANEL_STYLE_URL;
6548 case KEYPAD_STYLE_NUMBER:
6549 inputPanelStyle = INPUT_PANEL_STYLE_NUMBER_ONLY;
6550 textPredictionEnabled = false;
6552 case KEYPAD_STYLE_PHONE_NUMBER:
6553 inputPanelStyle = INPUT_PANEL_STYLE_PHONE_NUMBER;
6554 textPredictionEnabled = false;
6556 case KEYPAD_STYLE_IP_V4:
6557 inputPanelStyle = INPUT_PANEL_STYLE_IP;
6558 textPredictionEnabled = false;
6564 if (__pInputConnection && __isInputConnectionBound)
6566 __pInputConnection->SetTextPredictionEnabled(textPredictionEnabled);
6567 __pInputConnection->SetInputPanelStyle(inputPanelStyle);
6570 __pEditModel->SetTextPredictionEnabled(textPredictionEnabled);
6572 return __pEditModel->SetKeypadStyle(keypadStyle);
6576 _EditPresenter::SetKeypadNormalNumberStyle(bool enable)
6578 __isKeypadNormalNumberStyleEnabled = enable;
6579 return SetKeypadStyle(__pEditModel->GetKeypadStyle());
6583 _EditPresenter::IsTextPredictionEnabled(void) const
6585 return __pEditModel->IsTextPredictionEnabled();
6589 _EditPresenter::SetTextPredictionEnabled(bool enable)
6591 KeypadStyle keypadStyle = __pEditModel->GetKeypadStyle();
6593 if (keypadStyle == KEYPAD_STYLE_NUMBER ||keypadStyle == KEYPAD_STYLE_PHONE_NUMBER ||
6594 keypadStyle == KEYPAD_STYLE_IP_V4)
6595 return E_UNSUPPORTED_OPERATION;
6597 if (__pInputConnection && __isInputConnectionBound)
6599 __pInputConnection->SetTextPredictionEnabled(enable);
6602 return __pEditModel->SetTextPredictionEnabled(enable);
6606 _EditPresenter::InsertTextAtCursorPosition(const String& text)
6608 return InsertTextAt(__cursorPos, text);
6612 _EditPresenter::InsertTextAt(int position, const String& text, const Bitmap& textImage)
6614 result r = E_SUCCESS;
6616 int currentLength = GetTextLength();
6617 int length = text.GetLength();
6618 int totalLength = currentLength + length;
6620 SysTryReturnResult(NID_UI_CTRL, position >= 0 && position <= currentLength, E_OUT_OF_RANGE, "The given position is out-of-range.");
6622 if ((__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) || (__pEdit->IsViewModeEnabled()))
6624 if (__limitLength <= totalLength)
6626 String backupString = GetText();
6627 SetTextLimitLength(totalLength * 2);
6628 SetText(backupString);
6633 SysTryReturnResult(NID_UI_CTRL, totalLength <= __limitLength, E_MAX_EXCEEDED, "The text exceeds the limitation length.");
6636 FinishTextComposition();
6638 r = __pTextString->Insert(text, position);
6639 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
6641 wchar_t* pInsertString = const_cast<wchar_t*>(text.GetPointer());
6643 if (currentLength > position)
6645 wchar_t pOriginalString[currentLength - position];
6647 for (int i = 0; i < currentLength - position; i++)
6649 pOriginalString[i] = __pTextBuffer[position + i];
6651 pOriginalString[currentLength - position] = 0;
6653 for (int i = 0; i < length; i++)
6655 __pTextBuffer[i + position] = pInsertString[i];
6658 for (int i = 0; i < currentLength - position; i++)
6660 __pTextBuffer[i + position + length] = pOriginalString[i];
6665 for (int i = 0; i < length; i++)
6667 __pTextBuffer[i + position] = pInsertString[i];
6671 __pTextBuffer[totalLength] = 0;
6673 TextSimple* pSimpleText = null;
6674 pSimpleText = new (std::nothrow) TextSimple(__pTextBuffer, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, GetFont());
6675 SysTryReturnResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "Memory allocation failed.");
6677 pSimpleText->ChangeTextOffset(__pTextBuffer, position);
6678 pSimpleText->SetBitmap((Bitmap&)textImage);
6679 __pTextObject->InsertElementAt(position, *pSimpleText);
6680 __pTextObject->ChangeTextOffset(__pTextBuffer, position+pSimpleText->GetTextLength(), pSimpleText->GetTextLength());
6681 __pTextObject->Compose();
6683 if (__isTextBlocked == true)
6685 DeleteText(__blockStartPos, __cursorPos);
6688 SetCursorPosition(__cursorPos + length);
6692 SetCursorPosition(position + length);
6695 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
6697 AdjustFlexibleHeight();
6700 __isCursorChanged = true;
6701 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
6706 _EditPresenter::DeleteCharacterAtCursorPosition(void)
6708 return DeleteCharacterAt(__cursorPos);
6712 _EditPresenter::IsFocused(void) const
6714 return __pEdit->IsFocused();
6718 _EditPresenter::IsInternalFocused(void) const
6720 return __pEdit->IsInternalFocused();
6724 _EditPresenter::GetTextVisualElement(void)
6726 return __pTextVisualElement;
6730 _EditPresenter::SetControlInitialBounds(FloatRectangle initBounds)
6732 __initialBounds = initBounds;
6736 _EditPresenter::SetControlInitialPosition(FloatPoint initPosition)
6738 __initialBounds.x = initPosition.x;
6739 __initialBounds.y = initPosition.y;
6743 _EditPresenter::IsUpdateInitialBounds(void)
6745 return __updateInitialBounds;
6749 _EditPresenter::OnFocusGained(void)
6751 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
6755 __pParentForm = GetParentForm();
6757 if (!__pParentForm && __isKeypadCommandButtonVisible)
6759 __isKeypadCommandButtonVisible = false;
6763 if (__isAutoShrinkEnabled)
6765 float flexibleHeight = CalculateFlexibleHeightF();
6766 FloatRectangle initialRect = GetInitialBoundsF();
6767 initialRect.height = flexibleHeight;
6769 SetFlexBounds(initialRect);
6772 if (!__pTextVisualElement)
6774 result r = E_SUCCESS;
6775 __pTextVisualElement = new (std::nothrow) _VisualElement;
6776 SysTryReturn(NID_UI_CTRL, __pTextVisualElement != null, false, E_OUT_OF_MEMORY, "Memory allocation failed.");
6778 r = __pTextVisualElement->Construct();
6779 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r));
6781 __pTextVisualElement->SetSurfaceOpaque(false);
6782 __pTextVisualElement->SetImplicitAnimationEnabled(false);
6784 __pTextVisualElement->SetShowState(true);
6786 _VisualElement* pEditVisualElement = __pEdit->GetVisualElement();
6787 SysTryCatch(NID_UI_CTRL, pEditVisualElement, , r = E_SYSTEM, "[E_SYSTEM] Unable to get root visual element.");
6789 pEditVisualElement->AttachChild(*__pTextVisualElement);
6790 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r));
6793 if (__pEdit->GetEnableState() == false)
6798 __isCursorOpaque = true;
6800 if (__isInputConnectionBound == false && __isInitialized)
6802 if (IsViewModeEnabled() == false)
6804 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
6810 ShowFullscreenKeypad();
6814 __pEdit->Invalidate();
6819 __pTextVisualElement->Destroy();
6820 __pTextVisualElement = null;
6826 _EditPresenter::OnNotifiedN(IList* pArgs)
6828 String showKeypad(L"ShowKeypad");
6829 String showCopyPaste(L"ShowCopyPaste");
6831 String* pType = dynamic_cast <String*>(pArgs->GetAt(0));
6835 if (*pType == showKeypad)
6837 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
6843 ShowFullscreenKeypad();
6846 else if (*pType == showCopyPaste)
6848 if (__pCopyPasteManager)
6850 __pCopyPasteManager->CreateHandle();
6851 __pCopyPasteManager->DestroyCopyPasteMagnifier();
6852 if (__needToCreateCopyPastePopup)
6856 if (!__pParentPanel->IsScrollAnimationRunning())
6858 __pCopyPasteManager->CreateCopyPastePopup();
6859 if (__pCopyPasteManager->GetCopyPastePopup())
6861 __needToCreateCopyPastePopup = false;
6867 __pCopyPasteManager->CreateCopyPastePopup();
6868 if (__pCopyPasteManager->GetCopyPastePopup())
6870 __needToCreateCopyPastePopup = false;
6874 __pCopyPasteManager->Show();
6877 pArgs->RemoveAll(true);
6887 _EditPresenter::OnFrameActivated(const _Frame& source)
6889 _ControlManager* pControlManager = _ControlManager::GetInstance();
6890 if (pControlManager)
6892 _Control* pControl = pControlManager->GetFocusControl();
6893 if (pControl != __pEdit)
6899 if (__isInputConnectionBound == false && __isInitialized)
6901 if (IsViewModeEnabled() == false)
6903 CheckUSBKeyboardStatus();
6905 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
6916 _EditPresenter::OnFrameDeactivated(const _Frame& source)
6922 _EditPresenter::OnFrameMinimized(const _Frame& source)
6928 _EditPresenter::OnFrameRestored(const _Frame& source)
6934 _EditPresenter::ChangeToUnbindState(bool removeFocus)
6936 if(__latestBoundedContext != (unsigned int)this)//context is already changed.
6938 __isKeypadHiding = false;
6941 if (IsCopyPasteManagerExist())
6943 InitializeCopyPasteManager();
6946 if (__isInputConnectionBound)
6948 HideKeypad(removeFocus);
6950 if (__isClipboardExist)
6954 __pClipboard->HidePopup();
6955 OnClipboardPopupClosed();
6960 if (__isKeypadHiding)
6962 if (__pParentForm && !__pParentForm->IsVisible()) //Unbind by Scene Change
6964 if (__isCopyPasteManagerExist)
6966 InitializeCopyPasteManager();
6967 __pTextObject->SetBlock(false);
6968 __isTextBlocked = false;
6971 if (__pCommandButton && __isKeypadCommandButtonVisible)
6973 SetFooterVisible(true);
6974 __pCommandButton->SetVisibleState(false);
6975 __pCommandButton->Invalidate();
6978 __isInputConnectionBound = false;
6980 AdjustParentPanelHeight(true);
6981 SysLog(NID_UI_CTRL, "Form deflate RESET!!!");
6982 __pParentForm->DeflateClientRectHeight(0);
6984 if (!__pEdit->IsFullScreenKeypadEdit())
6988 __pParentForm->Draw();
6992 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CLOSED);
6993 __pEdit->DetachScrollPanelEvent();
6995 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
6996 __resizedByKeypadHide = true;
6997 __latestBoundedContext = null;
7005 _EditPresenter::OnFocusLost(void)
7007 if (__dragAndDropStarted)
7012 if (!__pEdit->IsDestroyed())
7014 InitializeCopyPasteManager();
7015 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
7018 if (__isAutoShrinkEnabled)
7020 FloatRectangle intialWindowBounds = GetInitialBoundsF();
7021 SetFlexBounds(intialWindowBounds);
7024 if (__pTextVisualElement)
7026 __pTextVisualElement->Destroy();
7027 __pTextVisualElement = null;
7030 if (__pEdit == null)
7035 if (__isClipboardExist)
7039 __pClipboard->HidePopup();
7040 OnClipboardPopupClosed();
7044 if (__isInputConnectionBound)
7047 if (__pScrollBar && !(__pEdit->GetEditStyle() & EDIT_STYLE_NOSCROLL))
7049 __pScrollBar->SetScrollVisibility(false);
7052 __isCursorOpaque = false;
7053 __isTouchMoving = false;
7054 __isTouchReleaseSkipped = false;
7059 ReplaceTextIntoPasswordHyphenString();
7061 __pEdit->Invalidate();
7067 _EditPresenter::GetCurrentStatus(void)
7069 EditStatus editState = EDIT_STATUS_NORMAL;
7071 if (__pEdit->IsEnabled())
7073 if (IsCurrentFocused())
7075 editState = EDIT_STATUS_HIGHLIGHTED;
7077 else if (__isTouchPressed)
7079 editState = EDIT_STATUS_PRESSED;
7084 editState = EDIT_STATUS_DISABLED;
7091 _EditPresenter::GetCursorVisualElement(void) const
7093 return __pCursorVisualElement;
7097 _EditPresenter::SetMaxLineCount(int maxLineCount)
7099 __pEditModel->SetMaxLineCount(maxLineCount);
7105 _EditPresenter::GetMaxLineCount(void) const
7107 return __pEditModel->GetMaxLineCount();
7111 _EditPresenter::UpdateComponentInformation(void)
7113 result r = E_SUCCESS;
7115 if (__isCursorChanged == false)
7120 bool IsTextAlignmentChanged = AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT);
7121 bool setFirstDisplayLine = true;
7122 if (!((__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) || (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)))
7124 float firstDisplayY = __pTextObject->GetFirstDisplayPositionYF();
7125 float totalHeight = __pTextObject->GetTotalHeightF();
7126 FloatRectangle displayBounds = __pTextObject->GetBoundsF();
7127 if (totalHeight >= displayBounds.height)
7129 float textGapFromBottom = displayBounds.height - (totalHeight - firstDisplayY);
7130 if (textGapFromBottom > 0)
7132 ScrollText(-textGapFromBottom);
7137 if (firstDisplayY > 0)
7139 ScrollText(-firstDisplayY);
7143 FloatRectangle absCursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
7144 CalculateAbsoluteCursorBounds(__cursorPos, absCursorBounds);
7145 setFirstDisplayLine = (IsContained(absCursorBounds) == false);
7148 if (setFirstDisplayLine || IsTextAlignmentChanged)
7150 if (__pTextObject->IsChanged())
7152 __pTextObject->Compose();
7154 __pTextObject->SetFirstDisplayLineIndexFromTextIndex(__cursorPos);
7157 __pTextObject->SetCursorIndex(__cursorPos);
7159 __isCursorChanged = false;
7165 _EditPresenter::ScrollText(float distance)
7167 float newFirstDisplayY = __pTextObject->GetFirstDisplayPositionYF();
7168 newFirstDisplayY += distance;
7170 int moveLine = __pTextObject->GetLineIndexAtPositionY(newFirstDisplayY);
7172 __pTextObject->SetFirstDisplayLineIndex(moveLine);
7173 __pTextObject->SetFirstDisplayPositionY(newFirstDisplayY);
7179 _EditPresenter::IsContained(FloatRectangle& paramRect) const
7181 FloatRectangle absBounds = __pEdit->GetAbsoluteBoundsF(true);
7183 if ((paramRect.x < absBounds.x) ||
7184 (paramRect.y < absBounds.y) ||
7185 ((paramRect.x + paramRect.width) > (absBounds.x + absBounds.width)) ||
7186 ((paramRect.y + paramRect.height) > (absBounds.y + absBounds.height)))
7195 _EditPresenter::CalculateAbsoluteCursorBounds(int index, FloatRectangle& absCursorBounds, bool clipCursorHeight)
7197 float cursorAbsX = 0.0f;
7198 float cursorAbsY = 0.0f;
7199 float cursorWidth = 0.0f;
7200 float cursorHeight = 0.0f;
7201 float cursorRelativeX = 0.0f;
7202 float cursorRelativeY = 0.0f;
7204 FloatRectangle absBounds = __pEdit->GetAbsoluteBoundsF(true);
7206 __pTextObject->SetBounds(GetTextBoundsF());
7207 if (index != __cursorPos)
7209 if (__pTextObject->GetTextPositionInfoAt(index, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
7216 if (__pTextObject->GetTextPositionInfoAt(__rowCursorIndex, __columnCursorIndex, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
7222 absCursorBounds.x = absBounds.x + cursorRelativeX;
7224 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
7226 FloatRectangle tempBounds;
7227 GetCursorBounds(true, tempBounds);
7228 absCursorBounds.y = tempBounds.y;
7232 absCursorBounds.y = absBounds.y + cursorRelativeY;
7235 GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorWidth);
7237 absCursorBounds.width = cursorWidth;
7239 if (cursorHeight > 0.0f)
7241 if (cursorHeight <= __calculatedCursorBounds.height || !clipCursorHeight)
7243 absCursorBounds.height = cursorHeight;
7247 if (__calculatedCursorBounds.height > 0)
7249 absCursorBounds.height = __calculatedCursorBounds.height;
7253 absCursorBounds.height = cursorHeight;
7259 absCursorBounds.height = __pTextObject->GetLineHeightAtF(0);
7266 _EditPresenter::CalculateAbsoluteCursorBounds(int rowIndex, int columnIndex, FloatRectangle& absCursorBounds, bool clipCursorHeight)
7268 float cursorAbsX = 0.0f;
7269 float cursorAbsY = 0.0f;
7270 float cursorWidth = 0.0f;
7271 float cursorHeight = 0.0f;
7272 float cursorRelativeX = 0.0f;
7273 float cursorRelativeY = 0.0f;
7275 FloatRectangle absBounds = __pEdit->GetAbsoluteBoundsF(true);
7277 __pTextObject->SetBounds(GetTextBoundsF());
7279 if (__pTextObject->GetTextPositionInfoAt(rowIndex, columnIndex, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
7284 absCursorBounds.x = absBounds.x + cursorRelativeX;
7286 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
7288 FloatRectangle tempBounds;
7289 GetCursorBounds(true, tempBounds);
7290 absCursorBounds.y = tempBounds.y;
7294 absCursorBounds.y = absBounds.y + cursorRelativeY;
7297 GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorWidth);
7299 absCursorBounds.width = cursorWidth;
7301 if (cursorHeight > 0.0f)
7303 if (cursorHeight <= __calculatedCursorBounds.height || !clipCursorHeight)
7305 absCursorBounds.height = cursorHeight;
7309 if (__calculatedCursorBounds.height > 0)
7311 absCursorBounds.height = __calculatedCursorBounds.height;
7315 absCursorBounds.height = cursorHeight;
7321 absCursorBounds.height = __pTextObject->GetLineHeightAtF(0);
7328 _EditPresenter::GetCursorBounds(bool isAbsRect, FloatRectangle& cursorBounds)
7330 if (__isInitialized == false)
7335 CalculateCursorBounds(GetTextBoundsF(), cursorBounds);
7339 FloatRectangle absBounds = __pEdit->GetAbsoluteBoundsF(true);
7340 cursorBounds.x += absBounds.x;
7341 cursorBounds.y += absBounds.y;
7349 _EditPresenter::SetCursorDisabled(bool disabled)
7351 __isCursorDisabled = disabled;
7357 _EditPresenter::IsGuideTextActivated(void) const
7359 if (__pGuideTextObject == null)
7364 if (GetGuideText().IsEmpty())
7369 if (__pTextObject && GetTextLength() > 0)
7378 _EditPresenter::CreateCommandButtonItemN(int actionId, const String& text)
7380 result r = E_SUCCESS;
7381 _Button* pButton = _Button::CreateButtonN();
7382 SysTryReturn(NID_UI_CTRL, pButton, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
7384 float textSize = 0.0f;
7386 r = pButton->SetActionId(actionId);
7387 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
7389 r = pButton->SetText(text);
7390 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
7392 r = GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_FONT_SIZE, __pEdit->GetOrientation(), textSize);
7395 r = pButton->SetTextSize(textSize);
7396 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
7408 _EditPresenter::SetKeypadCommandButton(const FloatRectangle& bounds)
7410 // This function must be changed after _ toolbar completes their float conversion works
7411 result r = E_SUCCESS;
7412 Bitmap* pNormalBackgroundBitmap = null;
7413 Bitmap* pReplacementColorBackgroundBitmap = null;
7414 String leftButtonText;
7415 String rightButtonText;
7416 _Control* pParent = null;
7417 Color commandBackgroundColor;
7419 if (__pCommandButton)
7421 __pCommandButton->SetResizable(true);
7422 __pCommandButton->SetMovable(true);
7423 SysLog(NID_UI_CTRL, "Command position changed!!! bounds(%f, %f, %f, %f)", bounds.x, bounds.y, bounds.width, bounds.height);
7424 r = __pCommandButton->SetBounds(bounds);
7426 __pCommandButton->SetResizable(false);
7427 __pCommandButton->SetMovable(false);
7432 if (__pParentForm == false)
7434 __isKeypadCommandButtonVisible = false;
7438 __pCommandButton = _Toolbar::CreateToolbarN(false);
7439 SysTryReturn(NID_UI_CTRL, __pCommandButton, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
7441 r = __pCommandButton->Construct();
7442 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
7444 GET_BITMAP_CONFIG_N(FOOTER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundBitmap);
7445 if (pNormalBackgroundBitmap)
7447 GET_COLOR_CONFIG(FOOTER::BG_NORMAL, commandBackgroundColor);
7448 pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), commandBackgroundColor);
7450 if (pReplacementColorBackgroundBitmap)
7452 r = __pCommandButton->SetBackgroundBitmap(*pReplacementColorBackgroundBitmap);
7453 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
7455 delete pReplacementColorBackgroundBitmap;
7456 pReplacementColorBackgroundBitmap = null;
7458 delete pNormalBackgroundBitmap;
7459 pNormalBackgroundBitmap = null;
7462 r = __pCommandButton->SetStyle(TOOLBAR_COMMAND);
7463 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
7465 __pCommandButton->SetResizable(true);
7466 __pCommandButton->SetMovable(true);
7467 SysLog(NID_UI_CTRL, "Command created!!! bounds(%f, %f, %f, %f)", bounds.x, bounds.y, bounds.width, bounds.height);
7468 r = __pCommandButton->SetBounds(bounds);
7469 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
7471 __pCommandButton->SetResizable(false);
7472 __pCommandButton->SetMovable(false);
7474 leftButtonText = __pEditModel->GetKeypadCommandButtonText(COMMAND_BUTTON_POSITION_LEFT);
7475 r = __pCommandButton->AddItem(CreateCommandButtonItemN(__pEditModel->GetKeypadCommandButtonActionId(COMMAND_BUTTON_POSITION_LEFT), leftButtonText));
7476 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
7478 rightButtonText = __pEditModel->GetKeypadCommandButtonText(COMMAND_BUTTON_POSITION_RIGHT);
7479 r = __pCommandButton->AddItem(CreateCommandButtonItemN(__pEditModel->GetKeypadCommandButtonActionId(COMMAND_BUTTON_POSITION_RIGHT), rightButtonText));
7480 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
7482 if (__pActionEventListener)
7484 __pCommandButton->AddActionEventListener(*__pActionEventListener);
7489 r = __pParentForm->AttachChild(*__pCommandButton);
7490 __pParentForm->MoveChildToTop(*__pCommandButton);
7494 pParent = __pEdit->GetParent();
7495 SysTryCatch(NID_UI_CTRL, pParent, r = E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
7496 r = pParent->AttachChild(*__pCommandButton);
7498 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
7503 delete pNormalBackgroundBitmap;
7505 delete __pCommandButton;
7506 __pCommandButton = null;
7508 delete pReplacementColorBackgroundBitmap;
7514 _EditPresenter::CheckInitialFooterVisibleState(void)
7516 if (__pParentForm == null)
7521 _Toolbar* pFooter = __pParentForm->GetFooter();
7524 if (pFooter->GetVisibleState() == false)
7526 __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_HIDE;
7527 SysLog(NID_UI_CTRL, "EDIT_FOOTER_VISIBLE_STATUS_HIDE");
7531 __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_SHOW;
7532 SysLog(NID_UI_CTRL, "EDIT_FOOTER_VISIBLE_STATUS_SHOW");
7537 __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
7538 SysLog(NID_UI_CTRL, "EDIT_FOOTER_VISIBLE_STATUS_NONE");
7545 _EditPresenter::SetFooterVisible(bool isVisible)
7547 if (__pParentForm == null)
7552 _Toolbar* pFooter = __pParentForm->GetFooter();
7553 if (pFooter && __initialFooterVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_SHOW)
7555 if ((isVisible == true && pFooter->GetVisibleState() == false) ||
7556 (isVisible == false && pFooter->GetVisibleState() == true))
7560 SysLog(NID_UI_CTRL, "SetFooterVisible TRUE!!!");
7564 SysLog(NID_UI_CTRL, "SetFooterVisible FALSE!!!");
7567 __footerVisibleChanged = true;
7568 pFooter->SetVisibleState(isVisible);
7569 pFooter->Invalidate();
7573 __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
7582 _EditPresenter::ShowFullscreenKeypad(void)
7584 result r = E_SUCCESS;
7586 if (__isCopyPasteManagerExist)
7588 InitializeCopyPasteManager();
7591 if (IsKeypadEnabled() == false)
7593 __pEdit->SetFocused();
7597 if (__pFullscreenKeypad)
7599 __pFullscreenKeypad->Close();
7600 delete __pFullscreenKeypad;
7601 __pFullscreenKeypad = null;
7604 __isKeypadExist = CheckKeypadExist(__pEdit->GetOrientation());
7605 if (__isKeypadExist) //overlay style keypad exist before create fullscreen edit.
7607 AdjustParentPanelHeight(true);
7609 //Do not use the Draw() API. If we use the Draw() API, it's possible to occur the memory crash.
7612 SysLog(NID_UI_CTRL, "Form deflate RESET!!!");
7613 __pParentForm->DeflateClientRectHeight(0);
7614 __pParentForm->Invalidate(true);
7618 int editStyle = __pEdit->GetEditStyle();
7620 _KeypadStyleInfo keypadStyleInfo;
7621 keypadStyleInfo.keypadStyle = __pEditModel->GetKeypadStyle();
7622 keypadStyleInfo.textPredictionEnabled = __pEditModel->IsTextPredictionEnabled();
7623 keypadStyleInfo.isNormalNumberStyle = __isKeypadNormalNumberStyleEnabled;
7624 keypadStyleInfo.enterActionEnabled = true;
7625 keypadStyleInfo.isLowerCaseModeEnabled = __pEditModel->IsLowerCaseModeEnabled();
7627 bool inputConnectionBoundState = __isInputConnectionBound;
7628 __isInputConnectionBound = true;
7629 SetKeypadStyle(__pEditModel->GetKeypadStyle());
7630 __isInputConnectionBound = inputConnectionBoundState;
7632 if (editStyle & EDIT_STYLE_SINGLE_LINE)
7634 keypadStyleInfo.enterActionEnabled = false;
7637 if (editStyle & EDIT_STYLE_PASSWORD)
7639 editStyle = EDIT_STYLE_NORMAL | EDIT_STYLE_SINGLE_LINE | EDIT_STYLE_PASSWORD;
7643 editStyle = EDIT_STYLE_NORMAL;
7646 __pFullscreenKeypad = _Keypad::CreateKeypadN();
7647 SysTryReturn(NID_UI_CTRL, __pFullscreenKeypad, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
7648 r = __pFullscreenKeypad->Initialize(editStyle, keypadStyleInfo, GetTextLimitLength(), __pEdit);
7649 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
7651 __pFullscreenKeypad->SetText(GetText());
7653 r = __pFullscreenKeypad->Open();
7654 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
7656 if (__pEdit->IsInputEventEnabled())
7658 __pEdit->LockInputEvent();
7663 __pFullscreenKeypad->SetEditTextFilter(this);
7669 _EditPresenter::DeleteFullscreenKeypad(void)
7671 if (__pFullscreenKeypad)
7673 __pFullscreenKeypad->Close();
7674 delete __pFullscreenKeypad;
7675 __pFullscreenKeypad = null;
7682 _EditPresenter::GetKeypadBounds(FloatRectangle& bounds)
7684 if (__pInputConnection == null)
7689 bounds = __pInputConnection->GetInputPanelBoundsF();
7691 _CoordinateSystem* pCoordSystem = _CoordinateSystem::GetInstance();
7692 SysTryReturnResult(NID_UI_CTRL, pCoordSystem, E_SYSTEM, "Coordinate system load failed.");
7694 _ICoordinateSystemTransformer* pXformer = pCoordSystem->GetInverseTransformer();
7695 SysTryReturnResult(NID_UI_CTRL, pXformer, E_SYSTEM, "Coordinate system load failed.");
7697 bounds = pXformer->Transform(bounds);
7698 __keypadBounds = bounds;
7704 _EditPresenter::GetClipboardHeight(void) const
7706 return __clipboardHeight;
7710 _EditPresenter::IsKeypadRotating(_ControlOrientation orientation)
7712 FloatDimension screenSize;
7713 FloatRectangle absKeypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
7714 _ControlManager* pControlManager = _ControlManager::GetInstance();
7716 GetKeypadBounds(absKeypadBounds);
7718 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
7720 screenSize.height = pControlManager->GetScreenSizeF().height;
7721 screenSize.width = pControlManager->GetScreenSizeF().width;
7725 screenSize.height = pControlManager->GetScreenSizeF().width;
7726 screenSize.width = pControlManager->GetScreenSizeF().height;
7729 if (absKeypadBounds.width == screenSize.width)
7740 _EditPresenter::CheckKeypadExist(_ControlOrientation orientation)
7742 FloatDimension screenSize;
7743 FloatRectangle absKeypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
7744 _ControlManager* pControlManager = _ControlManager::GetInstance();
7746 GetKeypadBounds(absKeypadBounds);
7748 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
7750 screenSize.height = pControlManager->GetScreenSizeF().height;
7751 screenSize.width = pControlManager->GetScreenSizeF().width;
7755 screenSize.height = pControlManager->GetScreenSizeF().width;
7756 screenSize.width = pControlManager->GetScreenSizeF().height;
7759 if (absKeypadBounds.width != 0 && absKeypadBounds.height != 0)
7761 if ((absKeypadBounds.y != screenSize.height))
7763 SysLog(NID_UI_CTRL, "KEYPAD EXIST!!!Keypad(y: %f, w: %f, h: %f)", absKeypadBounds.y, absKeypadBounds.width, absKeypadBounds.height);
7768 SysLog(NID_UI_CTRL, "NO KEYPAD!!!Keypad(y: %f, w: %f, h: %f)", absKeypadBounds.y, absKeypadBounds.width, absKeypadBounds.height);
7774 SysLog(NID_UI_CTRL, "NO KEYPAD!!!Keypad(y: %f, w: %f, h: %f)", absKeypadBounds.y, absKeypadBounds.width, absKeypadBounds.height);
7780 _EditPresenter::ShowKeypad(bool focus)
7782 if (!__pEdit->IsVisible())
7787 if (IsKeypadEnabled() == false)
7794 __pEdit->SetFocused();
7798 if (!__isInitialized)
7803 _ControlManager* pControlManager = _ControlManager::GetInstance();
7805 if (!pControlManager->IsFrameActivated())
7810 bool sendKeypadEventForcely = false;
7812 CheckUSBKeyboardStatus();
7814 __isInputConnectionBound = true;
7816 SetKeypadStyle(__pEditModel->GetKeypadStyle());
7818 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE && GetKeypadAction() == CORE_KEYPAD_ACTION_ENTER)
7820 __pInputConnection->SetInputPanelActionEnabled(false);
7824 __pInputConnection->SetInputPanelAction(ConvertKeypadAction(GetKeypadAction()));
7827 //Need to complete AutoCapitalization functionality
7828 if (__pEditModel->IsLowerCaseModeEnabled())
7830 __pInputConnection->SetAutoCapitalizationMode(AUTO_CAPITALIZATION_MODE_NONE);
7834 __pInputConnection->SetAutoCapitalizationMode(AUTO_CAPITALIZATION_MODE_SENTENCE);
7837 __pInputConnection->BindInputMethod();
7838 __isKeypadShowing = true;
7839 __isKeypadHiding = false;
7840 __resizedByKeypadHide = false;
7841 __latestBoundedContext = (unsigned int)this;
7843 LanguageCode initialKeypadLanguage = LANGUAGE_INVALID;
7844 __pEditModel->GetInitialKeypadLanguage(initialKeypadLanguage);
7845 if (initialKeypadLanguage != LANGUAGE_INVALID)
7847 SetCurrentLanguage(initialKeypadLanguage);
7850 if (__isUSBKeyboardConnected)
7852 SysLog(NID_UI_CTRL, "ShowKeypad called in USB ON mode!!!");
7854 __isKeypadExist = CheckKeypadExist(__pEdit->GetOrientation()); //prediction alreaedy exists
7856 if (__isKeypadCommandButtonVisible)
7858 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
7859 __pEdit->AttachScrollPanelEvent();
7860 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
7862 if (__initialFooterVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_NONE)
7864 CheckInitialFooterVisibleState();
7867 SetFooterVisible(false);
7868 ChangeLayoutInternal(__pEdit->GetOrientation());
7869 AdjustParentPanelHeight(false);
7870 ScrollPanelToCursorPosition();
7872 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
7873 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
7875 //Do not use the Draw() API. If we use the Draw() API, it's possible to occur the memory crash.
7878 __pParentForm->Invalidate(true);
7883 if (__initialFooterVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_NONE)
7885 CheckInitialFooterVisibleState();
7888 if (__isKeypadExist)
7892 sendKeypadEventForcely = !__pParentForm->IsDeflated();
7895 if (sendKeypadEventForcely)
7897 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
7898 __pEdit->AttachScrollPanelEvent();
7899 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
7902 ChangeLayoutInternal(__pEdit->GetOrientation());
7903 AdjustParentPanelHeight(false);
7904 ScrollPanelToCursorPosition();
7906 //Do not use the Draw() API. If we use the Draw() API, it's possible to occur the memory crash.
7909 __pParentForm->Invalidate(true);
7912 if (sendKeypadEventForcely)
7914 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
7915 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
7920 ScrollPanelToCursorPosition();
7926 SysLog(NID_UI_CTRL, "ShowKeypad called in USB OFF mode!!!");
7928 __isKeypadExist = CheckKeypadExist(__pEdit->GetOrientation()); //call once only from here.
7930 if (!__isKeypadExist)
7932 if (__isKeypadCommandButtonVisible)
7934 if (!__pCommandButton || (__pCommandButton && !__pCommandButton->GetVisibleState()))
7936 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
7937 __pEdit->AttachScrollPanelEvent();
7938 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
7939 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
7940 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
7945 if (!__isClipboardExist)
7947 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
7949 __pEdit->AttachScrollPanelEvent();
7950 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
7953 if (__initialFooterVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_NONE)
7955 CheckInitialFooterVisibleState();
7960 if (__footerVisibleChanged)
7962 SetFooterVisible(true);
7965 if (__initialFooterVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_NONE)
7967 CheckInitialFooterVisibleState();
7971 if (__isKeypadCommandButtonVisible)
7973 SetFooterVisible(false);
7976 if (__isKeypadExist) //edit switiching
7980 sendKeypadEventForcely = !__pParentForm->IsDeflated();
7983 if (sendKeypadEventForcely)
7985 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
7986 __pEdit->AttachScrollPanelEvent();
7987 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
7990 ChangeLayoutInternal(__pEdit->GetOrientation());
7991 AdjustParentPanelHeight(false);
7992 ScrollPanelToCursorPosition();
7994 //Do not use the Draw() API. If we use the Draw() API, it's possible to occur the memory crash.
7997 __pParentForm->Invalidate(true);
7999 __isKeypadShowing = false;
8001 if (sendKeypadEventForcely)
8003 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
8004 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
8009 if(!__isClipboardExist && __pParentPanel)
8011 if (__initialParentHeight)
8013 AdjustParentPanelHeight(true);
8016 ScrollPanelToCursorPosition();
8019 __pInputConnection->ShowInputPanel();
8026 _EditPresenter::ChangeLayout(_ControlOrientation orientation)
8028 result r = E_SUCCESS;
8031 __pDragAndDropCueVisualElement->SetShowState(false);
8033 if (__dragAndDropStarted)
8038 if (__pCopyPasteManager)
8040 if (__pCopyPasteManager->GetCopyPastePopup())
8042 __needToCreateCopyPastePopup = true;
8044 __pCopyPasteManager->ReleaseCopyPastePopup();
8045 __pCopyPasteManager->ReleaseHandle();
8048 bool isScrollPanelBoundsReloaded = false;
8052 _ControlImpl* pParentPanelImpl = static_cast <_ControlImpl* >(__pParentPanel->GetUserData());
8053 Rectangle builderBounds;
8054 isScrollPanelBoundsReloaded= pParentPanelImpl->GetBuilderBounds(orientation, builderBounds);
8059 CheckUSBKeyboardStatus();
8061 if (__isInputConnectionBound || __clipboardConnected)
8063 SysLog(NID_UI_CTRL, "-------------------ChangeLayout------------------------");
8065 if (!isScrollPanelBoundsReloaded)
8067 SysLog(NID_UI_CTRL, "ScrollPanel bounds is not changed by UIBuilder, so forcely reset ScrollPanel's height");
8068 AdjustParentPanelHeight(true);
8072 SysLog(NID_UI_CTRL, "ScrollPanel bounds is changed by UIBuilder");
8077 SysLog(NID_UI_CTRL, "Form deflate RESET!!!");
8078 __pParentForm->DeflateClientRectHeight(0.0f);
8081 if (__pCommandButton && __isKeypadCommandButtonVisible)
8083 __pCommandButton->SetVisibleState(false);
8086 if (__isKeypadExist && ! __isClipboardExist) //only keypad exists, already get keypadbounds before callback [Causion]this timing clipboard height is still previous height
8088 if (isScrollPanelBoundsReloaded)
8090 __initialParentHeight = 0.0f;
8093 ChangeLayoutInternal(orientation);
8094 AdjustParentPanelHeight(false);
8095 ScrollPanelToCursorPosition();
8097 else // if clipboard exists, boundsChanged callback will delivered after rotate callback
8100 if (__isClipboardExist)
8102 __initialParentHeight = 0.0f;
8104 else //no keypad, no clipboard
8106 if (__isKeypadCommandButtonVisible)
8108 __initialParentHeight = 0.0f;
8109 ChangeLayoutInternal(orientation);
8110 AdjustParentPanelHeight(false);
8111 ScrollPanelToCursorPosition();
8115 if (!__isClipboardExist)
8117 if (__isKeypadCommandButtonVisible)
8119 __initialParentHeight = 0.0f;
8120 ChangeLayoutInternal(orientation);
8121 AdjustParentPanelHeight(false);
8123 ScrollPanelToCursorPosition();
8128 if ((__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) == false)
8130 __initialBounds = __pEdit->GetBoundsF();
8133 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to change layout.", GetErrorMessage(r));
8139 _EditPresenter::ChangeLayout(_ControlRotation rotation)
8141 _ControlOrientation orientation = _CONTROL_ORIENTATION_PORTRAIT;
8143 if (rotation == _CONTROL_ROTATION_0 || rotation == _CONTROL_ROTATION_180)
8145 orientation = _CONTROL_ORIENTATION_PORTRAIT;
8149 orientation = _CONTROL_ORIENTATION_LANDSCAPE;
8152 return ChangeLayout(orientation);
8156 _EditPresenter::ChangeLayoutInternal(_ControlOrientation orientation, bool deflateForm)
8158 result r = E_SUCCESS;
8160 FloatRectangle keypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
8162 _ControlManager* pControlManager = _ControlManager::GetInstance();
8163 SysTryReturnResult(NID_UI_CTRL, pControlManager, E_SYSTEM, "Failed to get root.");
8165 _Frame* pCurrentFrame = dynamic_cast<_Frame*>(pControlManager->GetCurrentFrame());
8166 if (!pCurrentFrame || (pCurrentFrame && pCurrentFrame->GetShowMode() != FRAME_SHOW_MODE_FULL_SCREEN))
8170 SysLog(NID_UI_CTRL, "FrameShowMode[%d]", pCurrentFrame->GetShowMode());
8174 SysLog(NID_UI_CTRL, "Frame is null");
8179 FloatDimension screenSize;
8180 FloatRectangle commandButtonBounds(0.0f, 0.0f, 0.0f, 0.0f);
8182 float formDeflateHeight = 0.0f;
8183 float shrinkedHeight = 0.0f;
8185 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
8187 screenSize.width = pControlManager->GetScreenSizeF().width;
8188 screenSize.height = pControlManager->GetScreenSizeF().height;
8192 screenSize.width = pControlManager->GetScreenSizeF().height;
8193 screenSize.height = pControlManager->GetScreenSizeF().width;
8196 if (__isInputConnectionBound || __clipboardConnected)
8198 GetKeypadBounds(keypadBounds);
8200 if (__isKeypadExist)
8202 if (__isClipboardExist)
8204 if (__clipboardHeight > keypadBounds.height)
8206 shrinkedHeight = __clipboardHeight;
8210 shrinkedHeight = keypadBounds.height;
8215 shrinkedHeight = keypadBounds.height;
8220 if (__isClipboardExist)
8222 shrinkedHeight = __clipboardHeight;
8226 if (__isKeypadCommandButtonVisible)
8228 commandButtonBounds.width = screenSize.width;
8229 float commandButtonHeight = 0.0f;
8233 GET_SHAPE_CONFIG(FOOTER::HEIGHT, orientation, commandButtonHeight);
8234 commandButtonBounds.height = commandButtonHeight;
8235 formDeflateHeight += commandButtonBounds.height;
8237 if (__isKeypadExist || __isClipboardExist)
8239 formDeflateHeight += shrinkedHeight;
8240 commandButtonBounds.y = screenSize.height - shrinkedHeight - commandButtonBounds.height - __pParentForm->GetClientBoundsF().y;
8244 commandButtonBounds.y = screenSize.height - commandButtonBounds.height - __pParentForm->GetClientBoundsF().y;
8247 SetKeypadCommandButton(commandButtonBounds);
8249 if (__pCommandButton)
8251 __pCommandButton->SetVisibleState(true);
8252 __pCommandButton->Invalidate();
8260 if (__isKeypadExist || __isClipboardExist)
8262 formDeflateHeight += shrinkedHeight;
8268 if (__pParentForm && deflateForm)
8270 SysLog(NID_UI_CTRL, "FormDeflateHeight:%f, KeypadExist(%d), ClipboardExist(%d), CommandButtonVisible(%d)",
8271 formDeflateHeight, __isKeypadExist, __isClipboardExist, __isKeypadCommandButtonVisible);
8272 __pParentForm->DeflateClientRectHeight(formDeflateHeight);
8279 _EditPresenter::OnScrollPanelBoundsChanged(void)
8285 _EditPresenter::AdjustParentPanelHeight(bool restore)
8287 if (__pParentPanel == null)
8289 SysLog(NID_UI_CTRL, "__pParentPanel is NULL!!!, so skip resizing scrollpanel");
8293 _ControlManager* pControlManager = _ControlManager::GetInstance();
8294 SysTryReturnVoidResult(NID_UI_CTRL, pControlManager, E_SYSTEM, "[E_SYSTEM] Failed to get root.");
8296 _Frame* pCurrentFrame = dynamic_cast<_Frame*>(pControlManager->GetCurrentFrame());
8297 if (!pCurrentFrame || (pCurrentFrame && pCurrentFrame->GetShowMode() != FRAME_SHOW_MODE_FULL_SCREEN))
8301 SysLog(NID_UI_CTRL, "FrameShowMode[%d]", pCurrentFrame->GetShowMode());
8305 SysLog(NID_UI_CTRL, "Frame is null");
8310 float initialParentHeight = __initialParentHeight;
8311 if (__pResizedPanel != __pParentPanel)
8313 initialParentHeight = 0.0f;
8316 _ControlOrientation orientation;
8317 float commandButtonHeight = 0.0f;
8319 FloatRectangle absKeypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
8321 _Toolbar* pFooter = null;
8325 pFooter = __pParentForm->GetFooter();
8328 FloatRectangle absScrollPanelBounds(0.0f, 0.0f, 0.0f, 0.0f);
8329 FloatRectangle scrollPanelBounds = __pParentPanel->GetBoundsF();
8332 float displayedPanelHeight = 0.0f;
8333 FloatDimension screenSize;
8335 if (__pEdit->GetOrientation()== _CONTROL_ORIENTATION_PORTRAIT)
8337 screenSize.width = pControlManager->GetScreenSizeF().width;
8338 screenSize.height = pControlManager->GetScreenSizeF().height;
8342 screenSize.width = pControlManager->GetScreenSizeF().height;
8343 screenSize.height = pControlManager->GetScreenSizeF().width;
8348 if (initialParentHeight)
8350 scrollPanelBounds.height = __initialParentHeight;
8351 SysLog(NID_UI_CTRL, "Rollback ScrollPanel's height to %f and Set __initialParentHeight to 'Zero' ", __initialParentHeight);
8352 __initialParentHeight = 0.0f;
8353 __pResizedPanel = null;
8354 __pParentPanel->SetBounds(scrollPanelBounds);
8355 __pParentPanel->Invalidate();
8359 SysLog(NID_UI_CTRL, "initialParentHeight is ZERO!!!, so skip scrollPanel height recovery!!!");
8364 if (__isKeypadExist)
8366 GetKeypadBounds(absKeypadBounds);
8368 if (__isClipboardExist)
8370 if (__clipboardHeight > absKeypadBounds.height)
8372 absKeypadBounds.y = screenSize.height - __clipboardHeight;
8377 if (__isUSBKeyboardConnected)//predictive window shown
8379 absKeypadBounds.y = screenSize.height - absKeypadBounds.height;//only absKeypadBounds.height is meaningful in USB on.
8385 if (__isClipboardExist)
8387 absKeypadBounds.y = screenSize.height - __clipboardHeight;
8391 absKeypadBounds.y = screenSize.height;
8395 if ((__pParentForm && __isKeypadCommandButtonVisible) || (pFooter && (pFooter->GetVisibleState() == true)))
8397 orientation = __pEdit->GetOrientation();
8398 GET_SHAPE_CONFIG(FOOTER::HEIGHT, orientation, commandButtonHeight);
8401 absScrollPanelBounds = __pParentPanel->GetAbsoluteBoundsF(true);
8402 displayedPanelHeight = screenSize.height - commandButtonHeight - absScrollPanelBounds.y;
8403 gapY = (absKeypadBounds.y - commandButtonHeight)- absScrollPanelBounds.y;
8405 bool isOverlapped = true;
8407 if (((absKeypadBounds.y - commandButtonHeight) >= (absScrollPanelBounds.y + absScrollPanelBounds.height)) || ( absScrollPanelBounds.y > absKeypadBounds.y))
8409 isOverlapped = false;
8412 SysLog(NID_UI_CTRL, "IsOverlapped:(%d), __initialParentHeight:(%f), gapY:(%f)", isOverlapped, __initialParentHeight, gapY);
8414 if (!initialParentHeight)
8423 initialParentHeight = scrollPanelBounds.height;
8424 __initialParentHeight = initialParentHeight;
8425 __pResizedPanel = __pParentPanel;
8427 SysLog(NID_UI_CTRL, "Set ScrollPanel's height to %f and Set __initialParentHeight:(%f)", gapY, __initialParentHeight);
8429 scrollPanelBounds.height = gapY;
8430 __pParentPanel->SetBounds(scrollPanelBounds);
8431 __pParentPanel->Invalidate();
8438 if ((gapY < initialParentHeight) && (gapY > 0.0f))
8440 SysLog(NID_UI_CTRL, "Set ScrollPanel's height to %f", gapY);
8442 scrollPanelBounds.height = gapY;
8443 __pParentPanel->SetBounds(scrollPanelBounds);
8444 __pParentPanel->Invalidate();
8449 if (gapY > initialParentHeight)
8451 if (scrollPanelBounds.height > initialParentHeight)
8453 __initialParentHeight = scrollPanelBounds.height ;
8457 SysLog(NID_UI_CTRL, "Set ScrollPanel's height to %f", __initialParentHeight);
8459 scrollPanelBounds.height = initialParentHeight;
8460 __pParentPanel->SetBounds(scrollPanelBounds);
8461 __pParentPanel->Invalidate();
8469 if (scrollPanelBounds.height > initialParentHeight)
8471 __initialParentHeight = scrollPanelBounds.height ;
8474 SysLog(NID_UI_CTRL, "Set ScrollPanel's height to %f", gapY);
8475 scrollPanelBounds.height = gapY;
8476 __pParentPanel->SetBounds(scrollPanelBounds);
8477 __pParentPanel->Invalidate();
8484 _EditPresenter::HideKeypad(bool focus)
8486 InitializeCopyPasteManager();
8488 __isKeypadShowing = false;
8489 __resizedByKeypadHide = false;
8491 if (__isInitialized == false || !__isInputConnectionBound)
8496 CheckUSBKeyboardStatus();
8498 if (__isUSBKeyboardConnected)
8500 SysLog(NID_UI_CTRL, "HideKeypad called in USB ON mode!!!");
8501 if (__pCommandButton && __isKeypadCommandButtonVisible)
8503 SetFooterVisible(true);
8505 __pCommandButton->SetVisibleState(false);
8509 SysLog(NID_UI_CTRL, "Form deflate RESET!!!");
8510 __pParentForm->DeflateClientRectHeight(0.0f);
8513 AdjustParentPanelHeight(true);
8515 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
8520 SysLog(NID_UI_CTRL, "HideKeypad called in USB OFF mode!!!");
8521 if (__pCommandButton && __isKeypadCommandButtonVisible)
8523 if (!__isKeypadExist)
8525 SetFooterVisible(true);//must be called ahead of DeflateClientRectHeights
8529 SysLog(NID_UI_CTRL, "Form deflate RESET!!!");
8530 __pParentForm->DeflateClientRectHeight(0.0f);
8532 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
8534 __pCommandButton->SetVisibleState(false);
8538 FinishTextComposition();
8539 __pInputConnection->HideInputPanel();
8540 __pInputConnection->UnbindInputMethod();
8542 if (__isKeypadExist)
8544 __isKeypadHiding = true;
8547 __isInputConnectionBound = false;
8549 if (focus && __pEdit->IsFocused())
8551 __pEdit->SetFocused(false);
8558 _EditPresenter::ChangeKeypadStatus(void)
8560 InitializeCopyPasteManager();
8562 if (__isInputConnectionBound)
8564 __isInputConnectionBound = false;
8571 _EditPresenter::OnTimerExpired(Timer& timer)
8573 Timer* onTimer = &timer;
8575 if (onTimer == __pCursorTimer)
8577 OnCursorTimerExpired();
8579 else if (onTimer == __pTitleSlidingTimer)
8581 OnTitleSlidingTimerExpired();
8583 else if (onTimer == __pPasswordTimer)
8585 OnPasswordTimerExpired();
8587 else if (onTimer == __pFlickAnimationTimer)
8589 OnFlickTimerExpired();
8596 _EditPresenter::OnEditCopyPasteStatusChanged(CoreCopyPasteStatus status, CoreCopyPasteAction action)
8600 case CORE_COPY_PASTE_ACTION_COPY:
8601 __pEdit->CopyText();
8603 case CORE_COPY_PASTE_ACTION_CUT:
8605 InitializeCopyPasteManager();
8607 case CORE_COPY_PASTE_ACTION_PASTE:
8608 __pEdit->PasteText();
8609 InitializeCopyPasteManager();
8611 case CORE_COPY_PASTE_ACTION_SEARCH:
8612 InitializeCopyPasteManager();
8614 case CORE_COPY_PASTE_ACTION_CLIPBOARD:
8615 __clipboardConnected = true;
8620 __pEdit->Invalidate();
8626 _EditPresenter::InitializeCursor(void)
8630 if (__isCursorDisabled == false && IsCurrentFocused() && __isTextBlocked == false)
8632 bool outOfRangeInSignleLine = false;
8633 FloatRectangle cursorBounds;
8634 if (CalculateCursorBounds(__textObjectBounds, cursorBounds) != E_SUCCESS)
8636 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
8638 outOfRangeInSignleLine = true;
8642 __pCursorVisualElement->SetOpacity(1.0f);
8643 __pCursorVisualElement->SetBounds(cursorBounds);
8645 Canvas* pCanvas = __pCursorVisualElement->GetCanvasN();
8646 if (pCanvas == null)
8651 if (outOfRangeInSignleLine)
8653 __isCursorOpaque = false;
8657 __isCursorInitialized = false;
8660 DrawCursor(*pCanvas, cursorBounds, __isCursorOpaque);
8662 if (__pInputConnection)
8664 FloatRectangle absoluteEditRectangle;
8665 if (GetCursorBounds(false, absoluteEditRectangle) == E_SUCCESS)
8667 __pInputConnection->SetCursorBounds(absoluteEditRectangle);
8670 __isCursorOpaque = __isCursorOpaque ? false : true;
8674 __previousCursorBounds = cursorBounds;
8679 __pCursorVisualElement->SetOpacity(0);
8682 if (__pInputConnection != null && __isInputConnectionBound == true && !__isCopyPasteManagerExist)
8684 __pInputConnection->SetCursorPosition(__cursorPos);
8691 _EditPresenter::StopCursorTimer(void)
8695 __pCursorTimer->Cancel();
8701 _EditPresenter::StartCursorTimer(void)
8703 result r = E_SUCCESS;
8705 if (__pCursorTimer == null)
8707 __pCursorTimer = new (std::nothrow) Timer;
8708 if (__pCursorTimer == null)
8710 return E_OUT_OF_MEMORY;
8713 r = __pCursorTimer->Construct(*this);
8720 r = __pCursorTimer->Start(EDIT_CURSOR_TIMER_PERIOD);
8731 delete __pCursorTimer;
8732 __pCursorTimer = null;
8738 _EditPresenter::DrawCursor(Canvas& canvas, FloatRectangle& cursorBounds, bool isCursorOpaque)
8740 result r = E_SUCCESS;
8742 if (__isCursorDisabled == false)
8745 GET_COLOR_CONFIG(EDIT::CURSOR_NORMAL, cursorColor);
8747 if (__isCursorInitialized)
8749 cursorBounds.SetPosition(0.0f, 0.0f);
8751 if (canvas.GetBackgroundColor() != cursorColor)
8753 canvas.FillRectangle(cursorColor, cursorBounds);
8758 __pCursorVisualElement->SetOpacity(1.0f);
8762 __pCursorVisualElement->SetOpacity(0);
8767 cursorBounds.SetPosition(0.0f, 0.0f);
8769 canvas.FillRectangle(cursorColor, cursorBounds);
8770 __isCursorInitialized = true;
8776 __pCursorVisualElement->SetOpacity(0);
8783 _EditPresenter::MoveCursor(const FloatRectangle& fromRect, const FloatRectangle& toRect)
8785 if ((__previousCursorBounds.x != fromRect.x) || (__previousCursorBounds.y != fromRect.y) || (__previousCursorBounds.width != fromRect.width) || (__previousCursorBounds.height != fromRect.height))
8790 __pCursorVisualElement->SetOpacity(0);
8792 __pCursorVisualElement->SetBounds(toRect);
8793 Canvas* pCanvas = __pCursorVisualElement->GetCanvasN();
8795 if (pCanvas == null)
8800 if (toRect.y < 0.0f || toRect.y >= __clientBounds.height ||
8801 toRect.x < 0.0f || toRect.x >= __clientBounds.width)
8807 __pCursorVisualElement->SetOpacity(1.0f);
8811 GET_COLOR_CONFIG(EDIT::CURSOR_NORMAL, cursorColor);
8813 pCanvas->FillRectangle(cursorColor, toRect);
8815 __previousCursorBounds = toRect;
8822 _EditPresenter::OnCursorTimerExpired(void)
8824 if (!IsCurrentFocused() || __isCursorDisabled)
8830 FloatRectangle cursorBounds;
8832 if (CalculateCursorBounds(__textObjectBounds, cursorBounds) != E_SUCCESS)
8837 if ((__previousCursorBounds.x != cursorBounds.x) || (__previousCursorBounds.y != cursorBounds.y) || (__previousCursorBounds.width != cursorBounds.width) || (__previousCursorBounds.height != cursorBounds.height))
8839 __previousCursorBounds = cursorBounds;
8842 if (__pCursorVisualElement)
8844 __pCursorVisualElement->SetBounds(cursorBounds);
8845 Canvas* pCanvas = __pCursorVisualElement->GetCanvasN();
8846 if (pCanvas == null)
8851 DrawCursor(*pCanvas, cursorBounds, __isCursorOpaque);
8856 __isCursorOpaque = __isCursorOpaque ? false : true;
8859 if (__pCopyPasteManager)
8861 __pCopyPasteManager->UpdateCopyPasteMagnifier();
8868 _EditPresenter::GetEllipsisPosition(void) const
8870 return __pEdit->GetEllipsisPosition();
8874 _EditPresenter::SetEllipsisPosition(EllipsisPosition position)
8876 result r = E_SUCCESS;
8877 TextObjectEllipsisType ellipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_TAIL;
8878 if (position == ELLIPSIS_POSITION_START)
8880 ellipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_HEAD;
8882 else if (position == ELLIPSIS_POSITION_MIDDLE)
8884 ellipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_MIDDLE;
8887 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
8889 r = __pTextObject->SetTextObjectEllipsisType(ellipsisType);
8890 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Unable to Set ellipsis position.");
8896 _EditPresenter::OnFontInfoRequested(unsigned long& style, float& size)
8898 style = __contentFontStyle;
8899 size = __contentFontSize;
8905 _EditPresenter::OnFontChanged(Font* pFont)
8907 if (!__isFontInitialized)
8912 result r = E_SUCCESS;
8914 r = AdjustFont(*pFont, EDIT_FONT_CHANGE_ALL);
8915 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
8917 __titleFontFaceName = pFont->GetFaceName();
8923 _EditPresenter::GetFont(void) const
8929 _EditPresenter::GetTextSize(void) const
8931 return _CoordinateSystemUtils::ConvertToInteger(__contentFontSize);
8935 _EditPresenter::GetTextSizeF(void) const
8937 return __contentFontSize;
8941 _EditPresenter::GetFontStyle(const Font* pBaseFont) const
8943 unsigned long style = FONT_STYLE_MIN;
8945 if (pBaseFont->IsPlain())
8947 style |= FONT_STYLE_PLAIN;
8949 if (pBaseFont->IsItalic())
8951 style |= FONT_STYLE_ITALIC;
8953 if (pBaseFont->IsBold())
8955 style |= FONT_STYLE_BOLD;
8962 _EditPresenter::SetTextSize(const int size)
8964 result r = E_SUCCESS;
8965 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
8966 r = GetLastResult();
8967 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
8969 r = fontImpl->SetSize(size);
8970 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "SetSize is failed.");
8974 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
8975 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
8976 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
8979 if (IsGuideTextActivated())
8981 r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
8982 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
8985 __contentFontSize = _CoordinateSystemUtils::ConvertToFloat(size);
8990 _EditPresenter::SetTextSize(const float size)
8992 result r = E_SUCCESS;
8993 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
8994 r = GetLastResult();
8995 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
8997 r = fontImpl->SetSize(size);
8998 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "SetSize is failed.");
9002 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
9003 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
9004 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
9007 if (IsGuideTextActivated())
9009 r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
9010 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
9013 __contentFontSize = size;
9018 _EditPresenter::SetFont(const Font& font)
9020 result r = E_SUCCESS;
9022 Font* pFont = _FontImpl::CloneN(const_cast <Font&>(font));
9023 SysTryReturnResult(NID_UI_CTRL, pFont, GetLastResult(), "Unable to create font.");
9029 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
9030 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
9031 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "Unable to set font.");
9034 if (IsGuideTextActivated())
9036 r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
9037 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "Unable to set font.");
9044 _EditPresenter::AdjustFont(Font& font, _EditFontChange fontChange)
9046 result r = E_SUCCESS;
9047 Font* pFont = &font;
9049 _FontImpl* fontImpl = _FontImpl::GetInstance(*pFont);
9050 r = GetLastResult();
9051 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
9053 if (fontChange == EDIT_FONT_CHANGE_TITLE || fontChange == EDIT_FONT_CHANGE_ALL)
9055 if (__pTitleTextObject)
9057 r = fontImpl->SetSize(__titleFontSize);
9058 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "SetSize is failed.");
9060 r = __pTitleTextObject->SetFont(pFont, 0, __pTitleTextObject->GetTextLength());
9061 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
9065 if (fontChange == EDIT_FONT_CHANGE_CONTENT || fontChange == EDIT_FONT_CHANGE_ALL)
9067 r = fontImpl->SetSize(__contentFontSize);
9068 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "SetSize is failed.");
9070 unsigned long style = FONT_STYLE_PLAIN;
9072 if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_BOLD)
9074 style |= FONT_STYLE_BOLD;
9076 if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_ITALIC)
9078 style |= FONT_STYLE_ITALIC;
9081 fontImpl->SetStyle(style);
9083 if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_UNDERLINE)
9085 fontImpl->SetUnderline(true);
9087 if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_STRIKEOUT)
9089 fontImpl->SetStrikeOut(true);
9094 r = __pTextObject->SetFont(pFont, 0, __pTextObject->GetTextLength());
9095 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
9096 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
9099 if (__pGuideTextObject)
9101 r = __pGuideTextObject->SetFont(pFont, 0, __pGuideTextObject->GetTextLength());
9102 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
9108 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
9117 _EditPresenter::GetTitleFontFaceName(void)
9119 return __titleFontFaceName;
9123 _EditPresenter::GetFontType(String& typefaceName, unsigned long& styleMask) const
9125 result r = E_SUCCESS;
9129 typefaceName = __pFont->GetFaceName();
9132 styleMask = __contentTextStyle;
9138 _EditPresenter::SetFontType(const String& typefaceName, unsigned long styleMask)
9140 result r = E_SUCCESS;
9143 IList* systemFontList = Font::GetSystemFontListN();
9144 SysTryReturnResult(NID_UI_CTRL, systemFontList, E_SYSTEM, "Unable to get system font list.\n");
9146 int fontListCount = systemFontList->GetCount();
9147 String tempFontFaceName;
9148 bool isFaceNameAvailable = false;
9150 float textSize = __pFont->GetSizeF();
9151 unsigned long fontStyle = FONT_STYLE_PLAIN;
9153 if (styleMask & TEXT_BOX_TEXT_STYLE_ITALIC)
9155 fontStyle |= FONT_STYLE_ITALIC;
9157 if (styleMask & TEXT_BOX_TEXT_STYLE_BOLD)
9159 fontStyle |= FONT_STYLE_BOLD;
9162 for (int i = 0; i < fontListCount; i++)
9164 tempFontFaceName = *static_cast<String*>(systemFontList->GetAt(i));
9166 pFont = new (std::nothrow) Font;
9167 SysTryCatch(NID_UI_CTRL, pFont, , r = E_OUT_OF_MEMORY, "Memory allocation failed.");
9168 r = pFont->Construct(tempFontFaceName, fontStyle, textSize);
9169 SysTryCatch(NID_UI_CTRL, !IsFailed(r), , r, "Unable to construct Font.\n");
9171 // check font face name.
9172 if (typefaceName.Equals(pFont->GetFaceName(), true))
9174 isFaceNameAvailable = true;
9182 SysTryCatch(NID_UI_CTRL, isFaceNameAvailable, , r = E_INVALID_ARG, "The unsupported font face name is given.\n");
9184 if (styleMask & TEXT_BOX_TEXT_STYLE_UNDERLINE)
9186 pFont->SetUnderline(true);
9188 if (styleMask & TEXT_BOX_TEXT_STYLE_STRIKEOUT)
9190 pFont->SetStrikeOut(true);
9193 __contentFontStyle = fontStyle;
9194 __contentTextStyle = styleMask;
9198 systemFontList->RemoveAll(true);
9199 delete systemFontList;
9200 systemFontList = null;
9204 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
9205 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
9206 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "Unable to set font.");
9217 systemFontList->RemoveAll(true);
9218 delete systemFontList;
9219 systemFontList = null;
9225 _EditPresenter::GetTextStyle(void) const
9227 return __contentTextStyle;
9231 _EditPresenter::SetTextStyle(unsigned long textStyle)
9233 result r = E_SUCCESS;
9235 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
9236 r = GetLastResult();
9237 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
9239 unsigned long style = FONT_STYLE_PLAIN;
9241 if (textStyle & TEXT_BOX_TEXT_STYLE_BOLD)
9243 style |= FONT_STYLE_BOLD;
9245 if (textStyle & TEXT_BOX_TEXT_STYLE_ITALIC)
9247 style |= FONT_STYLE_ITALIC;
9250 fontImpl->SetStyle(style);
9252 if (textStyle & TEXT_BOX_TEXT_STYLE_UNDERLINE)
9254 fontImpl->SetUnderline(true);
9258 fontImpl->SetUnderline(false);
9261 if (textStyle & TEXT_BOX_TEXT_STYLE_STRIKEOUT)
9263 fontImpl->SetStrikeOut(true);
9267 fontImpl->SetStrikeOut(false);
9272 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
9273 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
9274 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
9277 if (IsGuideTextActivated())
9279 r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
9280 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
9283 __contentTextStyle = textStyle;
9289 _EditPresenter::GetGuideText(void) const
9295 _EditPresenter::SetGuideText(const String& guideText)
9297 result r = E_SUCCESS;
9299 int length = guideText.GetLength();
9301 __guideText = String(guideText);
9302 wchar_t* tempString = const_cast<wchar_t*>(__guideText.GetPointer());
9305 if (__pGuideTextObject != null)
9307 delete __pGuideTextObject;
9308 __pGuideTextObject = null;
9311 __pGuideTextObject = new (std::nothrow) TextObject;
9312 if (__pGuideTextObject == null)
9314 return E_OUT_OF_MEMORY;
9316 __pGuideTextObject->Construct();
9317 TextSimple* pSimpleText = new (std::nothrow)TextSimple(tempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
9318 __pGuideTextObject->AppendElement(*pSimpleText);
9320 __pGuideTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
9321 __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
9323 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_GUIDE);
9325 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
9327 __pGuideTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_CHARACTER);
9331 __pGuideTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
9334 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
9340 _EditPresenter::GetTitleText(void) const
9346 _EditPresenter::SetTitleText(const String& title)
9348 result r = E_SUCCESS;
9350 int length = title.GetLength();
9352 __titleText = String(title);
9353 wchar_t* tempString = const_cast<wchar_t*>(__titleText.GetPointer());
9355 if (__pTitleTextObject != null)
9357 delete __pTitleTextObject;
9358 __pTitleTextObject = null;
9361 __pTitleTextObject = new (std::nothrow) TextObject;
9362 if (__pTitleTextObject == null)
9364 return E_OUT_OF_MEMORY;
9366 __pTitleTextObject->Construct();
9367 TextSimple* pSimpleText = new (std::nothrow)TextSimple(tempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
9368 __pTitleTextObject->AppendElement(*pSimpleText);
9370 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_TITLE);
9371 __pTitleTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
9372 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
9373 __pTitleTextObject->Compose();
9375 float titleFontSize = 0.0f;
9376 GET_SHAPE_CONFIG(EDIT::DEFAULT_TITLE_FONT_SIZE, __pEdit->GetOrientation(), titleFontSize);
9378 __titleFontSize = titleFontSize;
9380 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
9381 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
9383 r = fontImpl->SetSize(__titleFontSize);
9384 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "SetSize is failed.");
9386 __pTitleTextObject->SetFont(__pFont, 0, __pTitleTextObject->GetTextLength());
9388 r = fontImpl->SetSize(__contentFontSize);
9389 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "SetSize is failed.");
9391 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
9397 _EditPresenter::GetTextLineCount(void) const
9399 if (GetTextLength() == 0)
9404 if (__isInitialized == false)
9406 __pTextObject->SetBounds(__textObjectBounds);
9407 __pTextObject->Compose();
9410 return __pTextObject->GetTotalLineCount();
9414 _EditPresenter::GetTextTotalHeight(void) const
9416 if (GetTextLength() == 0)
9421 if (__isInitialized == false)
9423 __pTextObject->SetBounds(__textObjectBounds);
9424 __pTextObject->Compose();
9427 return __pTextObject->GetTotalHeight();
9431 _EditPresenter::GetTextTotalHeightF(void) const
9433 if (GetTextLength() == 0)
9438 if (__isInitialized == false)
9440 __pTextObject->SetBounds(__textObjectBounds);
9441 __pTextObject->Compose();
9444 return __pTextObject->GetTotalHeightF();
9448 _EditPresenter::Resize(void)
9453 __pTextObject->SetBounds(__textObjectBounds);
9454 __pTextObject->Compose();
9455 __isCursorChanged = true;
9456 __pTextObject->ConvertToRowColumn(__cursorPos, __rowCursorIndex, __columnCursorIndex);
9458 __pTextObject->SetFirstDisplayLineIndex(0);
9459 __pTextObject->SetFirstDisplayPositionY(0);
9461 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_NOSCROLL))
9463 if (__pScrollBar == null)
9465 __pScrollBar = _Scroll::CreateScrollN(*__pEdit,
9466 SCROLL_DIRECTION_VERTICAL,
9474 SysTryReturn(NID_UI_CTRL, __pScrollBar != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to create the scroll.");
9475 __pEdit->AttachSystemChild(*__pScrollBar);
9477 __pScrollBar->SetScrollVisibility(false);
9478 __pScrollBar->OnParentBoundsChanged();
9481 __verticalMargin = __pEdit->GetBoundsF().height - __textObjectBounds.height;
9483 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
9485 if (__initialBounds.height > __verticalMargin)
9487 if (__initialBounds.height > __pEdit->GetBoundsF().height)
9489 __prevTotalTextHeight = __initialBounds.height - __verticalMargin;
9493 __prevTotalTextHeight = __pEdit->GetBoundsF().height - __verticalMargin;
9498 if (__isInputConnectionBound)
9500 SysLog(NID_UI_CTRL, "Edit's bounds chagned, scroll position should be recalculated.");
9501 ScrollPanelToCursorPosition();
9509 _EditPresenter::SetClientBounds(void)
9511 int editStyle = __pEdit->GetEditStyle();
9513 __clientBounds = __pEdit->GetBoundsF();
9514 __clientBounds.x = 0.0f;
9515 __clientBounds.y = 0.0f;
9517 if (!(editStyle & EDIT_STYLE_SINGLE_LINE))
9522 float leftBorder = 0.0f;
9523 float rightBorder = 0.0f;
9524 float topBorder = 0.0f;
9525 float bottomBorder = 0.0f;
9526 float leftMargin = 0.0f;
9527 float rightMargin = 0.0f;
9528 float topMargin = 0.0f;
9529 float bottomMargin = 0.0f;
9530 _ControlOrientation orientation = __pEdit->GetOrientation();
9532 GET_SHAPE_CONFIG(EDIT::FIELD_LEFT_MARGIN, orientation, leftMargin);
9533 GET_SHAPE_CONFIG(EDIT::FIELD_RIGHT_MARGIN, orientation, rightMargin);
9534 GET_SHAPE_CONFIG(EDIT::FIELD_TOP_MARGIN, orientation, topMargin);
9535 GET_SHAPE_CONFIG(EDIT::FIELD_BOTTOM_MARGIN, orientation, bottomMargin);
9537 if (editStyle & EDIT_STYLE_TITLE_LEFT)
9539 float titleWidth = 0.0f;
9540 if (__titleWidth != -1.0f)
9542 titleWidth = __titleWidth;
9546 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_RECT_WIDTH, orientation, titleWidth);
9549 leftBorder = titleWidth;
9550 rightBorder = rightMargin;
9551 topBorder = topMargin;
9552 bottomBorder = bottomMargin;
9554 else if (editStyle & EDIT_STYLE_TITLE_TOP)
9556 result r = E_SUCCESS;
9557 float titletHeight = 0.0f;
9558 float titleTextTopMargin = 0.0f;
9559 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_RECT_HEIGHT, orientation, titletHeight);
9560 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_TOP_MARGIN, orientation, titleTextTopMargin);
9562 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
9563 SysTryReturnVoidResult(NID_UI_CTRL, fontImpl != null, E_SYSTEM, "[E_SYSTEM] fontImpl is null.");
9565 float originalSize = fontImpl->GetSizeF();
9566 float titleFontSize = 0.0f;
9567 GET_SHAPE_CONFIG(EDIT::DEFAULT_TITLE_FONT_SIZE, __pEdit->GetOrientation(), titleFontSize);
9569 r = fontImpl->SetSize(titleFontSize);
9570 SysTryReturnVoidResult(NID_UI_CTRL, !(IsFailed(r)), r, "[%s] Propagating.", GetErrorMessage(r));
9572 if (titletHeight < fontImpl->GetMaxHeightF())
9574 titleTextTopMargin -= (fontImpl->GetMaxHeightF()-titletHeight);
9575 titletHeight = fontImpl->GetMaxHeightF();
9578 r = fontImpl->SetSize(originalSize);
9579 SysTryReturnVoidResult(NID_UI_CTRL, !(IsFailed(r)), r, "[%s] Propagating.", GetErrorMessage(r));
9581 leftBorder = leftMargin;
9582 rightBorder = rightMargin;
9583 topBorder = titletHeight + titleTextTopMargin;
9584 bottomBorder = bottomMargin;
9587 __clientBounds.x = leftBorder;
9588 __clientBounds.y = topBorder;
9589 __clientBounds.width -= leftBorder + rightBorder;
9590 __clientBounds.height -= topBorder + bottomBorder;
9596 _EditPresenter::AdjustTextBounds(bool clearIconVisible)
9598 int editStyle = __pEdit->GetEditStyle();
9600 if (!(editStyle & EDIT_STYLE_CLEAR))
9605 float clearIconWidth = 0.0f;
9606 _ControlOrientation orientation = __pEdit->GetOrientation();
9608 GET_SHAPE_CONFIG(EDIT::CLEAR_ICON_WIDTH, orientation, clearIconWidth);
9610 if (__pEdit->GetEditStyle() & EDIT_STYLE_CLEAR)
9612 if (clearIconVisible)
9614 __textObjectBounds.width -= clearIconWidth;
9618 __textObjectBounds.width += clearIconWidth;
9622 float textObectMinimumWidth = 0.0f;
9623 float textObjectMinimumHeight = 0.0f;
9624 GET_SHAPE_CONFIG(EDIT::TEXT_OBJECT_MININMUM_WIDTH, orientation, textObectMinimumWidth);
9625 GET_SHAPE_CONFIG(EDIT::TEXT_OBJECT_MININMUM_HEIGHT, orientation, textObjectMinimumHeight);
9627 if (__textObjectBounds.width < textObectMinimumWidth)
9629 __textObjectBounds.width = textObectMinimumWidth;
9632 __pTextObject->SetBounds(__textObjectBounds);
9633 __pTextObject->Compose();
9634 __isCursorChanged = true;
9640 _EditPresenter::SetInitialEditFieldBounds(void)
9642 result r = E_SUCCESS;
9643 int editStyle = __pEdit->GetEditStyle();
9644 float bottomMargin = 0.0f;
9645 float textLeftMargin = 0.0f;
9646 float textRightMargin =0.0f;
9647 float textTopMargin = 0.0f;
9648 float textBottomMargin = 0.0f;
9649 float titleTextLeftMargin = 0.0f;
9650 float titleTextRightMargin =0.0f;
9651 float titleTextTopMargin = 0.0f;
9652 float titleTextBottomMargin = 0.0f;
9653 float titletHeight = 0.0f;
9654 _ControlOrientation orientation = __pEdit->GetOrientation();
9656 GET_SHAPE_CONFIG(EDIT::FIELD_BOTTOM_MARGIN, orientation, bottomMargin);
9657 GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_LEFT_MARGIN, orientation, textLeftMargin);
9658 GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_RIGHT_MARGIN, orientation, textRightMargin);
9659 GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_TOP_MARGIN, orientation, textTopMargin);
9660 GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_BOTTOM_MARGIN, orientation, textBottomMargin);
9661 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_LEFT_MARGIN, orientation, titleTextLeftMargin);
9662 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_RIGHT_MARGIN, orientation, titleTextRightMargin);
9663 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_TOP_MARGIN, orientation, titleTextTopMargin);
9664 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_BOTTOM_MARGIN, orientation, titleTextBottomMargin);
9665 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_RECT_HEIGHT, orientation, titletHeight);
9667 if (!(editStyle & EDIT_STYLE_SINGLE_LINE))
9672 if (editStyle & EDIT_STYLE_CLEAR)
9674 __isClearIconVisible = false;
9677 FloatRectangle bounds = __pEdit->GetBoundsF();
9678 if (editStyle & EDIT_STYLE_TITLE_LEFT)
9680 __textObjectBounds.x = __clientBounds.x + textLeftMargin;
9681 __textObjectBounds.y = __clientBounds.y + textTopMargin;
9682 __textObjectBounds.width = __clientBounds.width - textLeftMargin
9684 __textObjectBounds.height = __clientBounds.height - textTopMargin
9687 __titleBounds.x = titleTextLeftMargin;
9688 __titleBounds.y = titleTextTopMargin;
9689 __titleBounds.width = bounds.width - __clientBounds.width - __titleBounds.x;
9690 __titleBounds.height = __clientBounds.height - titleTextTopMargin - titleTextBottomMargin;
9692 else if (editStyle & EDIT_STYLE_TITLE_TOP)
9694 __textObjectBounds.x = __clientBounds.x + textLeftMargin;
9695 __textObjectBounds.y = __clientBounds.y;
9696 __textObjectBounds.width = __clientBounds.width - textLeftMargin
9698 __textObjectBounds.height = __clientBounds.height - textBottomMargin;
9700 __titleBounds.x = titleTextLeftMargin;
9702 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
9703 SysTryReturnResult(NID_UI_CTRL, fontImpl != null, E_SYSTEM, "fontImpl is null.");
9705 float originalSize = fontImpl->GetSizeF();
9706 float titleFontSize = 0.0f;
9707 GET_SHAPE_CONFIG(EDIT::DEFAULT_TITLE_FONT_SIZE, __pEdit->GetOrientation(), titleFontSize);
9709 r = fontImpl->SetSize(titleFontSize);
9710 SysTryReturnResult(NID_UI_CTRL, !(IsFailed(r)), r, "SetSize is failed.");
9712 if (titletHeight < fontImpl->GetMaxHeightF())
9714 titleTextTopMargin -= (fontImpl->GetMaxHeightF()-titletHeight);
9717 r = fontImpl->SetSize(originalSize);
9718 SysTryReturnResult(NID_UI_CTRL, !(IsFailed(r)), r, "SetSize is failed.");
9720 __titleBounds.y = titleTextTopMargin;
9721 __titleBounds.width = bounds.width - __titleBounds.x - titleTextRightMargin;
9722 __titleBounds.height = bounds.height - __titleBounds.y - __clientBounds.height - bottomMargin;
9724 else if ((editStyle & EDIT_STYLE_NORMAL) || (editStyle & EDIT_STYLE_CLEAR))
9726 __textObjectBounds = __clientBounds;
9727 float tempLeftMargin = __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
9728 float tempRightMargin = __pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
9730 if (tempLeftMargin != -1.0f)
9732 __textObjectBounds.x = __clientBounds.x + tempLeftMargin;
9733 __textObjectBounds.width = __clientBounds.width - tempLeftMargin;
9737 __textObjectBounds.x = __clientBounds.x + textLeftMargin;
9738 __textObjectBounds.width = __clientBounds.width - textLeftMargin;
9741 if (tempRightMargin != -1.0f)
9743 __textObjectBounds.width -= tempRightMargin;
9747 __textObjectBounds.width -= textRightMargin;
9750 __textObjectBounds.y = __clientBounds.y + textTopMargin;
9751 __textObjectBounds.height = __clientBounds.height - textTopMargin - textBottomMargin;
9755 float tempLeftMargin = __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
9756 float tempRightMargin = __pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
9757 if (tempLeftMargin != -1.0f)
9759 __textObjectBounds.x = __clientBounds.x + tempLeftMargin;
9760 __textObjectBounds.width = __clientBounds.width - tempLeftMargin;
9764 __textObjectBounds.x = __clientBounds.x + textLeftMargin;
9765 __textObjectBounds.width = __clientBounds.width - textLeftMargin;
9768 if (tempRightMargin != -1.0f)
9770 __textObjectBounds.width -= tempRightMargin;
9774 __textObjectBounds.width -= textRightMargin;
9776 __textObjectBounds.y = __clientBounds.y + textTopMargin;
9777 __textObjectBounds.height = __clientBounds.height - textTopMargin - textBottomMargin;
9780 float textObectMinimumWidth = 0.0f;
9781 float textObjectMinimumHeight = 0.0f;
9782 GET_SHAPE_CONFIG(EDIT::TEXT_OBJECT_MININMUM_WIDTH, orientation, textObectMinimumWidth);
9783 GET_SHAPE_CONFIG(EDIT::TEXT_OBJECT_MININMUM_HEIGHT, orientation, textObjectMinimumHeight);
9785 if (__textObjectBounds.width < textObectMinimumWidth)
9787 __textObjectBounds.width = textObectMinimumWidth;
9790 if (__textObjectBounds.height <= textObjectMinimumHeight)
9792 __textObjectBounds.height = __contentFontSize;
9794 else if (__textObjectBounds.height < __contentFontSize)
9796 __textObjectBounds.y -= (__contentFontSize - __textObjectBounds.height)/2.0f;
9797 __textObjectBounds.height = __contentFontSize;
9800 if (editStyle & EDIT_STYLE_TITLE_LEFT)
9803 if (__titleBounds.width < textObectMinimumWidth)
9805 gap = textObectMinimumWidth - __titleBounds.width;
9806 __titleBounds.width = textObectMinimumWidth;
9807 __textObjectBounds.x += gap;
9809 if (__titleBounds.height < __titleFontSize)
9811 __titleBounds.height = __titleFontSize;
9819 _EditPresenter::SetInitialBounds(void)
9821 result r = E_SUCCESS;
9822 FloatRectangle bounds = __pEdit->GetBoundsF();
9823 int editStyle = __pEdit->GetEditStyle();
9825 if (editStyle & EDIT_STYLE_SINGLE_LINE)
9827 r = SetInitialEditFieldBounds();
9828 __textBoxBounds.x = 0.0f;
9829 __textBoxBounds.y = 0.0f;
9830 __textBoxBounds.width = bounds.width;
9831 __textBoxBounds.height = bounds.height;
9836 float leftMargin = 0.0f;
9837 float rightMargin = 0.0f;
9838 float topMargin = 0.0f;
9839 float bottomMargin = 0.0f;
9840 float textLeftMargin = 0.0f;
9841 float textRightMargin =0.0f;
9842 float textTopMargin = 0.0f;
9843 float textBottomMargin = 0.0f;
9844 float titleRectWidth = 0.0f;
9845 float titleRectHeight = 0.0f;
9846 float titleTextLeftMargin = 0.0f;
9847 float titleTextRightMargin = 0.0f;
9848 float titleTextTopMargin = 0.0f;
9849 float titleTextBottomMargin = 0.0f;
9850 float scrollWidth = 0.0f;
9851 _ControlOrientation orientation = __pEdit->GetOrientation();
9853 GET_SHAPE_CONFIG(EDIT::AREA_LEFT_MARGIN, orientation, leftMargin);
9854 GET_SHAPE_CONFIG(EDIT::AREA_RIGHT_MARGIN, orientation, rightMargin);
9855 GET_SHAPE_CONFIG(EDIT::AREA_TOP_MARGIN, orientation, topMargin);
9856 GET_SHAPE_CONFIG(EDIT::AREA_BOTTOM_MARGIN, orientation, bottomMargin);
9857 GET_SHAPE_CONFIG(EDIT::AREA_TEXT_LEFT_MARGIN, orientation, textLeftMargin);
9858 GET_SHAPE_CONFIG(EDIT::AREA_TEXT_RIGHT_MARGIN, orientation, textRightMargin);
9859 GET_SHAPE_CONFIG(EDIT::AREA_TEXT_TOP_MARGIN, orientation, textTopMargin);
9860 GET_SHAPE_CONFIG(EDIT::AREA_TEXT_BOTTOM_MARGIN, orientation, textBottomMargin);
9861 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_RECT_WIDTH, orientation, titleRectWidth);
9862 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_RECT_HEIGHT, orientation, titleRectHeight);
9863 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_LEFT_MARGIN, orientation, titleTextLeftMargin);
9864 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_RIGHT_MARGIN, orientation, titleTextRightMargin);
9865 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_TOP_MARGIN, orientation, titleTextTopMargin);
9866 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_BOTTOM_MARGIN, orientation, titleTextBottomMargin);
9867 GET_SHAPE_CONFIG(EDIT::AREA_SCROLL_WIDTH, orientation, scrollWidth);
9869 if (editStyle & EDIT_STYLE_TITLE_TOP)
9871 __textBoxBounds.x = leftMargin;
9872 __textBoxBounds.y = titleRectHeight + titleTextTopMargin;
9873 __textBoxBounds.width = bounds.width - leftMargin - rightMargin;
9874 __textBoxBounds.height = bounds.height - titleRectHeight - titleTextTopMargin - bottomMargin;
9876 else if (editStyle & EDIT_STYLE_TITLE_LEFT)
9878 float titleWidth = 0.0f;
9880 if (__titleWidth != -1.0f)
9882 titleWidth = __titleWidth;
9886 titleWidth = titleRectWidth;
9888 __textBoxBounds.x = titleWidth;
9889 __textBoxBounds.y = topMargin;
9890 __textBoxBounds.width = bounds.width - titleWidth - leftMargin;
9891 __textBoxBounds.height = bounds.height - topMargin - bottomMargin;
9895 __textBoxBounds.x = 0.0f;
9896 __textBoxBounds.y = 0.0f;
9897 __textBoxBounds.width = bounds.width;
9898 __textBoxBounds.height = bounds.height;
9901 // setting textBounds
9902 if (editStyle & EDIT_STYLE_TITLE_TOP)
9904 if (__pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN) != -1.0f)
9906 __textObjectBounds.x = __textBoxBounds.x + __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
9907 __textObjectBounds.width = __textBoxBounds.width - __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
9911 __textObjectBounds.x = __textBoxBounds.x + textLeftMargin;
9912 __textObjectBounds.width = __textBoxBounds.width - textLeftMargin;
9915 if (__pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN) != -1.0f)
9917 __textObjectBounds.width -= __pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
9921 __textObjectBounds.width -= textRightMargin;
9925 __textObjectBounds.y = __textBoxBounds.y;
9926 __textObjectBounds.height = __textBoxBounds.height - textBottomMargin;
9930 if (__pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN) != -1.0f)
9932 __textObjectBounds.x = __textBoxBounds.x + __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
9933 __textObjectBounds.width = __textBoxBounds.width - __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
9937 __textObjectBounds.x = __textBoxBounds.x + textLeftMargin;
9938 __textObjectBounds.width = __textBoxBounds.width - textLeftMargin;
9941 if (__pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN) != -1.0f)
9943 __textObjectBounds.width -= __pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
9947 __textObjectBounds.width -= textRightMargin;
9951 if (__pEdit->GetVerticalMarginF(EDIT_TEXT_TOP_MARGIN) != -1.0f)
9953 __textObjectBounds.y = __textBoxBounds.y + __pEdit->GetVerticalMarginF(EDIT_TEXT_TOP_MARGIN);
9954 __textObjectBounds.height = __textBoxBounds.height - __pEdit->GetVerticalMarginF(EDIT_TEXT_TOP_MARGIN);
9958 __textObjectBounds.y = __textBoxBounds.y + textTopMargin;
9959 __textObjectBounds.height = __textBoxBounds.height - textTopMargin;
9962 if (__pEdit->GetVerticalMarginF(EDIT_TEXT_BOTTOM_MARGIN) != -1.0f)
9964 __textObjectBounds.height -= __pEdit->GetVerticalMarginF(EDIT_TEXT_BOTTOM_MARGIN);
9968 __textObjectBounds.height -= textBottomMargin;
9972 if (editStyle & EDIT_STYLE_TITLE_TOP)
9974 __titleBounds.x = titleTextLeftMargin;
9975 __titleBounds.y = titleTextTopMargin;
9976 __titleBounds.width = bounds.width - titleTextLeftMargin
9977 - titleTextRightMargin;
9978 __titleBounds.height = bounds.height - __textBoxBounds.height - __titleBounds.y
9982 else if (editStyle & EDIT_STYLE_TITLE_LEFT)
9984 __titleBounds.x = titleTextLeftMargin;
9985 __titleBounds.y = titleTextTopMargin;
9986 __titleBounds.width = bounds.width - __textBoxBounds.width - __titleBounds.x
9987 - titleTextRightMargin;
9988 __titleBounds.height = __textBoxBounds.height - titleTextTopMargin
9989 - titleTextBottomMargin;
9992 if (editStyle & EDIT_STYLE_NOSCROLL)
9994 __isScrollBarVisible = false;
9995 __scrollBarBounds.x = 0.0f;
9996 __scrollBarBounds.y = 0.0f;
9997 __scrollBarBounds.width = 0.0f;
9998 __scrollBarBounds.height = 0.0f;
10002 __scrollBarBounds.width = scrollWidth;
10004 __scrollBarBounds.x = bounds.width - __scrollBarBounds.width;
10005 __scrollBarBounds.y = __textBoxBounds.y + textTopMargin;
10006 __scrollBarBounds.height = __textBoxBounds.height - textTopMargin - textBottomMargin;
10007 if (__scrollBarBounds.height < 0.0f)
10009 __scrollBarBounds.height = 0.0f;
10012 __isScrollBarVisible = true;
10014 if (editStyle & EDIT_STYLE_TITLE_TOP)
10016 __titleBounds.width -= __scrollBarBounds.width;
10020 float textObectMinimumWidth = 0.0f;
10021 GET_SHAPE_CONFIG(EDIT::TEXT_OBJECT_MININMUM_WIDTH, orientation, textObectMinimumWidth);
10023 if (__textObjectBounds.width < textObectMinimumWidth)
10025 __textObjectBounds.width = textObectMinimumWidth;
10028 if (__textObjectBounds.height < __contentFontSize)
10030 __textObjectBounds.height = __contentFontSize;
10037 _EditPresenter::StopTitleSlidingTimer(void)
10039 if (__pTitleSlidingTimer)
10041 __pTitleSlidingTimer->Cancel();
10042 delete __pTitleSlidingTimer;
10043 __pTitleSlidingTimer = null;
10050 _EditPresenter::StartTitleSlidingTimer(void)
10052 result r = E_SUCCESS;
10054 if (__pTitleSlidingTimer == null)
10056 __pTitleSlidingTimer = new (std::nothrow) Timer;
10057 if (__pTitleSlidingTimer == null)
10059 return E_OUT_OF_MEMORY;
10062 r = __pTitleSlidingTimer->Construct(*this);
10068 r = __pTitleSlidingTimer->Start(TITLE_SLIDING_TIME);
10076 StopTitleSlidingTimer();
10081 _EditPresenter::OnTitleSlidingTimerExpired(void)
10083 result r = E_SUCCESS;
10085 if (!IsCurrentFocused())
10087 StopTitleSlidingTimer();
10091 if (__pTitleTextObject->IsChanged())
10093 r = DrawTitleText();
10094 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to draw title text");
10097 Canvas* pTitleTextCanvas = __pTitleTextVisualElement->GetCanvasN();
10098 SysTryReturnResult(NID_UI_CTRL, pTitleTextCanvas, E_SYSTEM, "A system error has occurred. Failed to get canvas of VisualElement");
10100 if (__isTouchPressed)
10102 pTitleTextCanvas->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_PRESSED));
10106 pTitleTextCanvas->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED));
10109 pTitleTextCanvas->Clear();
10110 __pTitleTextObject->DrawWithOffset(*_CanvasImpl::GetInstance(*pTitleTextCanvas));
10111 r = pTitleTextCanvas->Show();
10113 delete pTitleTextCanvas;
10115 r = StartTitleSlidingTimer();
10121 _EditPresenter::ChangePasswordToEchoCharacter(int cursorPos, int textLength)
10123 result r = E_SUCCESS;
10125 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD))
10130 if (__isPasswordVisible)
10135 StartPasswordTimer();
10136 if (IsBlocked() == true)
10138 __pTextObject->SetRange(cursorPos, textLength);
10142 __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), 0);
10149 _EditPresenter::StopPasswordTimer(void)
10151 if (__pPasswordTimer)
10153 __pPasswordTimer->Cancel();
10154 delete __pPasswordTimer;
10155 __pPasswordTimer = null;
10162 _EditPresenter::StartPasswordTimer(void)
10164 result r = E_SUCCESS;
10166 if (__isPasswordVisible)
10171 if (__pPasswordTimer == null)
10173 __pPasswordTimer = new (std::nothrow) Timer;
10174 if (__pPasswordTimer == null)
10176 return E_OUT_OF_MEMORY;
10179 r = __pPasswordTimer->Construct(*this);
10182 StopPasswordTimer();
10187 r = __pPasswordTimer->Start(EDIT_PASSWORD_TIMER_PERIOD);
10190 StopPasswordTimer();
10197 _EditPresenter::OnPasswordTimerExpired(void)
10199 result r = E_SUCCESS;
10201 if (!IsCurrentFocused())
10206 ReplaceTextIntoPasswordHyphenString();
10207 if (__composingTextLength > 0)
10209 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
10210 SysTryReturnResult(NID_UI_CTRL, fontImpl != null, E_SYSTEM, "fontImpl is null.");
10211 fontImpl->SetUnderline(false);
10212 int composingStartPosition = GetCursorPosition()-__composingTextLength;
10213 __pTextObject->SetFont(__pFont, composingStartPosition, composingStartPosition+__composingTextLength);
10216 __isCursorChanged = true;
10218 __pEdit->Invalidate();
10224 _EditPresenter::ReplaceTextIntoPasswordHyphenString(void)
10226 result r = E_SUCCESS;
10228 if (__isPasswordVisible)
10233 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
10235 if (GetTextLength() > 0)
10237 ChangePasswordToEchoCharacter(__pTextBuffer, __echoChar);
10238 __isCursorChanged = true;
10246 _EditPresenter::ChangePasswordToEchoCharacter(wchar_t* dspStrBuffer, wchar_t echoChar)
10248 result r = E_SUCCESS;
10250 if (__isPasswordVisible)
10255 int bufferLength = GetTextLength();
10257 for (int i = 0; i < bufferLength && i < EDIT_PASSWORD_BUFFER_MAX - 1; i++)
10259 dspStrBuffer[i] = echoChar;
10261 dspStrBuffer[bufferLength] = null;
10262 __isCursorChanged = true;
10264 __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), 0);
10265 UpdateComponentInformation();
10271 _EditPresenter::ChangePasswordToPlainText(void)
10273 result r = E_SUCCESS;
10275 if (__isPasswordVisible == false)
10280 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
10282 int textLength = GetTextLength();
10283 if ((textLength > 0) && (textLength <= __limitLength))
10285 wchar_t* tempString = const_cast<wchar_t*>(__pTextString->GetPointer());
10286 for (int i = 0; i < textLength; i++)
10288 __pTextBuffer[i] = tempString[i];
10290 __pTextBuffer[textLength] = 0;
10291 __pTextObject->RemoveAll();
10292 TextSimple* pSimpleText = new (std::nothrow)TextSimple(__pTextBuffer, textLength,TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, __pFont);
10293 __pTextObject->AppendElement(*pSimpleText);
10294 __pTextObject->Compose();
10295 __isCursorChanged = true;
10303 _EditPresenter::SetAutoResizingEnabled(bool enable)
10305 return __pEditModel->SetAutoResizingEnabled(enable);
10309 _EditPresenter::IsAutoResizingEnabled(void) const
10311 return __pEditModel->IsAutoResizingEnabled();
10315 _EditPresenter::CalculateFlexibleHeightF(void)
10317 float height = 0.0f;
10318 float expectedEditHeight = __pTextObject->GetTotalHeightF() + __verticalMargin;
10319 int lineCount = __pTextObject->GetTotalLineCount();
10321 if (__pTextObject->GetTotalHeight())
10323 if ((lineCount >= MAX_LINE_NUMBER) && (GetMaxLineCount() > MAX_LINE_NUMBER))
10325 height = MAX_LINE_NUMBER * __pTextObject->GetLineHeightAtF(0) + __verticalMargin;
10329 float maxHeight = CalculateMaximumFlexibleHeight();
10331 //If InitialBounds is more than expectedEdit height, set flexible height as initial height
10332 if (expectedEditHeight < __initialBounds.height)
10334 height = __initialBounds.height;
10336 else if (expectedEditHeight >= maxHeight)
10338 height = maxHeight;
10342 height = expectedEditHeight;
10347 height = __initialBounds.height;
10350 FloatDimension flexHeightDim = CoordinateSystem::AlignToDevice(FloatDimension(0, height));
10351 return flexHeightDim.height;
10355 _EditPresenter::AdjustFlexibleHeight(void)
10357 result r = E_SUCCESS;
10359 if (__isFlexibleHeightFrozen == true)
10364 __pTextObject->Compose();
10366 if (__prevTotalTextHeight == __pTextObject->GetTotalHeightF()) // if text height has not changed.
10368 __prevTotalTextHeight = __pTextObject->GetTotalHeightF();
10373 FloatRectangle bounds = __pEdit->GetBoundsF();
10374 float calculateHeight = CalculateFlexibleHeightF();
10376 //calculateHeight is being calculated based on AlignToDevice only
10377 if (bounds.height != calculateHeight)
10379 bounds.height = calculateHeight;
10380 __prevTotalTextHeight = __pTextObject->GetTotalHeightF();
10382 return SetFlexBounds(bounds);
10384 __prevTotalTextHeight = __pTextObject->GetTotalHeight();
10389 _EditPresenter::SetFlexBounds(const FloatRectangle& bounds)
10391 result r = E_SUCCESS;
10393 _ExpandableEditAreaEventStatus expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_ADDED;
10394 if (__pEdit->GetBoundsF().height > bounds.height)
10396 expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_REMOVED;
10398 else if (__pEdit->GetBoundsF().height < bounds.height)
10400 expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_ADDED;
10403 _VisualElement* pVisualElement = __pEdit->GetVisualElement();
10404 SysTryReturnResult(NID_UI_CTRL, pVisualElement, E_SYSTEM, "A system error has occurred. Unable to get root visual element.");
10406 //Modify InitialBounds only on User calls and on Orientation change
10407 if (!((__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) == false))
10409 __updateInitialBounds = false;
10412 __pEdit->SetBounds(bounds);
10413 __updateInitialBounds = true;
10417 __pEdit->Invalidate();
10419 __prevTotalTextHeight = __pTextObject->GetTotalHeightF();
10420 __pEdit->SendExpandableEditAreaEvent(expandableEditAreaStatus, __pTextObject->GetTotalLineCount());
10426 _EditPresenter::CalculateMaximumFlexibleHeight(void)
10428 float maxHeight = 0.0f;
10429 int maximumFlexibleLineNumber = GetMaxLineCount();
10431 if (maximumFlexibleLineNumber > 0) // if max line number is set.
10433 maxHeight = maximumFlexibleLineNumber * __pTextObject->GetLineHeightAtF(0) + __verticalMargin;
10435 FloatDimension dim = __pEdit->GetMaximumSizeF();
10436 if (maxHeight > dim.height)
10438 maxHeight = dim.height;
10446 _EditPresenter::GetKeypadBoundsEx(Tizen::Graphics::FloatRectangle& bounds) const
10448 bounds.x = __keypadBounds.x;
10449 bounds.y = __keypadBounds.y;
10450 bounds.width = __keypadBounds.width;
10451 bounds.height = __keypadBounds.height;
10456 _EditPresenter::GetParentForm(void)
10463 if (__pParentForm == null)
10465 result r = E_SUCCESS;
10467 _Form* pForm = null;
10468 _Control* pControlCore = null;
10470 for (pControlCore = __pEdit->GetParent(); pForm == null; pControlCore = pControlCore->GetParent())
10472 if (pControlCore == null)
10478 pForm = dynamic_cast<_Form*>(pControlCore);
10488 _EditPresenter::GetParentPanel(void) const
10490 return __pParentPanel;
10494 _EditPresenter::SetKeypadCommandButtonVisible(bool visible)
10496 __isKeypadCommandButtonVisible = visible;
10501 _EditPresenter::SetKeypadCommandButton(CommandButtonPosition position, const String& text, int actionId)
10503 result r = E_SUCCESS;
10504 FooterItem footerItem;
10505 footerItem.Construct(actionId);
10506 footerItem.SetText(text);
10507 __isKeypadCommandButtonUserSetting = true;
10509 __pEditModel->SetCommandButtonItem(position, actionId, text);
10510 if (__pCommandButton)
10512 _Button* pButton = __pCommandButton->GetItem(static_cast<int>(position));
10515 pButton->SetActionId(actionId);
10516 pButton->SetText(text);
10524 _EditPresenter::GetKeypadCommandButton(void) const
10526 return __pCommandButton;
10530 _EditPresenter::AddActionEventListener(const _IActionEventListener& listener)
10534 if (__pCommandButton)
10536 __pCommandButton->AddActionEventListener(listener);
10539 __pActionEventListener = const_cast<_IActionEventListener*>(&listener);
10545 _EditPresenter::RemoveActionEventListener(const _IActionEventListener& listener)
10549 if (__pCommandButton)
10551 __pCommandButton->RemoveActionEventListener(listener);
10554 __pActionEventListener = null;
10560 _EditPresenter::SetTextBounds(Rectangle& bounds)
10562 __textObjectBounds = _CoordinateSystemUtils::ConvertToFloat(bounds);
10563 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
10565 __pTextObject->SetBounds(__textObjectBounds);
10566 __pTextObject->Compose();
10567 __isCursorChanged = true;
10573 _EditPresenter::SetTextBounds(FloatRectangle& bounds)
10575 __textObjectBounds = bounds;
10576 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
10578 __pTextObject->SetBounds(__textObjectBounds);
10579 __pTextObject->Compose();
10580 __isCursorChanged = true;
10586 _EditPresenter::GetTextBoundsF(void) const
10588 return __textObjectBounds;
10592 _EditPresenter::GetTextBounds(void) const
10594 return _CoordinateSystemUtils::ConvertToInteger(__textObjectBounds);
10598 _EditPresenter::IsKeypadCommandButtonVisible(void) const
10600 return __isKeypadCommandButtonVisible;
10604 _EditPresenter::GetKeypadCommandButtonText(CommandButtonPosition position) const
10606 return __pEditModel->GetKeypadCommandButtonText(position);
10610 _EditPresenter::GetKeypadCommandButtonActionId(CommandButtonPosition position) const
10612 return __pEditModel->GetKeypadCommandButtonActionId(position);
10616 _EditPresenter::DrawScrollBar(void)
10618 result r = E_SUCCESS;
10620 if (__pScrollBar == null)
10625 float totalHeight = __pTextObject->GetTotalHeightF();
10626 float dspHeight = __textObjectBounds.height;
10627 float firstDisplayY = __pTextObject->GetFirstDisplayPositionYF();
10629 if (totalHeight <= dspHeight)
10631 if (__prevTotalTextHeight != 0.0f && __prevTotalTextHeight == totalHeight) // flexible edit's case
10636 __pScrollBar->SetScrollRange(1, 1);
10637 __pScrollBar->SetScrollPosition(0.0f);
10639 __isScrollBarVisible = false;
10640 __previousScrollBarPos = 0.0f;
10641 __previousScrollBarMaxPos = 0.0f;
10645 if (firstDisplayY > 0)
10647 __pScrollBar->SetScrollRange(dspHeight, totalHeight);
10648 __pScrollBar->SetScrollPosition(firstDisplayY);
10649 __previousScrollBarMaxPos = totalHeight - dspHeight;
10653 __pScrollBar->SetScrollRange(dspHeight, totalHeight);
10654 __pScrollBar->SetScrollPosition(0.0f);
10655 __previousScrollBarMaxPos = 0.0f;
10658 if (__pScrollBar->GetScrollVisibility())
10660 __isScrollBarVisible = true;
10663 __previousScrollBarPos = firstDisplayY;
10670 _EditPresenter::FadeOutScrollBar(void)
10674 __pScrollBar->SetScrollVisibility(false);
10676 __isScrollBarVisible = false;
10682 _EditPresenter::InitializeFlickAnimation(void)
10684 result r = E_SUCCESS;
10686 if (__pFlickAnimation == null)
10688 __pFlickAnimation = new (std::nothrow) _FlickAnimation;
10691 // Init Flick Animation Config
10692 if (__pFlickAnimation)
10694 float width = 0.0f;
10695 float height = 0.0f;
10696 Tizen::Graphics::FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
10697 Tizen::Graphics::FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
10698 if (__pEdit->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
10700 width = portraitSize.width;
10701 height = portraitSize.height;
10705 width = landscapeSize.width;
10706 height = landscapeSize.height;
10709 __pFlickAnimation->SetSizeInformation(width, height, DEVICE_SIZE_HORIZONTAL, DEVICE_SIZE_VERTICAL);
10710 __pFlickAnimation->SetSensitivity(FLICK_ANIMATION_FPS_PANEL, FLICK_ANIMATION_SENSITIVITY_PANEL);
10717 if (__pFlickAnimationTimer == null)
10719 __pFlickAnimationTimer = new (std::nothrow) Timer;
10720 if (__pFlickAnimationTimer == null)
10722 r = E_OUT_OF_MEMORY;
10726 r = __pFlickAnimationTimer->Construct(*this);
10729 delete __pFlickAnimationTimer;
10741 _EditPresenter::StartFlickAnimation(const FloatPoint& flickPosition, int flickTime)
10743 // delete Scroll Fadeout Timer
10749 if (__textObjectBounds.height >= __pTextObject->GetTotalHeightF())
10754 if (InitializeFlickAnimation() != E_SUCCESS)
10759 //We must check the flick animation about float conversion work at later
10761 // Initialize flick animation
10765 __pFlickAnimation->CalculateInitializeVelocity(_CoordinateSystemUtils::ConvertToInteger(flickPosition.x), _CoordinateSystemUtils::ConvertToInteger(flickPosition.y), flickTime, &velocityX, &velocityY);
10767 if (Math::Abs(flickPosition.x) > Math::Abs(flickPosition.y))
10769 __pFlickAnimation->InitializeFlickAmount(velocityX);
10773 __pFlickAnimation->InitializeFlickAmount(velocityY);
10776 return StartFlickTimer(velocityY, velocityX);
10780 _EditPresenter::StartFlickTimer(int flickVelocityX, int flickVelocityY)
10782 if (__pFlickAnimation)
10784 if (ScrollContentsOnFlick() != E_SUCCESS)
10793 if (__pFlickAnimationTimer)
10795 if (__pFlickAnimationTimer->Start(EDIT_FLICK_SCROLL_TIMER_INTERVAL) != E_SUCCESS)
10811 _EditPresenter::ScrollContentsOnFlick(void)
10813 //We must check the flick animation about float conversion work at later
10815 if (__pFlickAnimation)
10817 int moveAmountX = 0;
10818 int moveAmountY = 0;
10819 __pFlickAnimation->CalculateNextMove(&moveAmountX, &moveAmountY);
10822 if (ScrollOnFlick(_CoordinateSystemUtils::ConvertToFloat(-moveAmountY*EDIT_FLICK_SCROLL_MOVE_AMOUNT_MULTIPLIER)))
10834 _EditPresenter::ScrollOnFlick(float moveDistanceY)
10836 if (moveDistanceY == 0)
10838 FadeOutScrollBar();
10842 if (!__pScrollBar->GetScrollVisibility())
10844 __pScrollBar->SetScrollVisibility(true);
10847 ScrollContents(moveDistanceY);
10853 _EditPresenter::SetCursorEnabled(bool enable)
10855 __isCursorOpaque = enable;
10861 _EditPresenter::IsCursorEnabled(void) const
10863 return __isCursorOpaque;
10867 _EditPresenter::StopFlickTimer(void)
10869 if (__pFlickAnimationTimer != null)
10871 __pFlickAnimationTimer->Cancel();
10872 delete __pFlickAnimationTimer;
10873 __pFlickAnimationTimer = null;
10880 _EditPresenter::OnFlickTimerExpired(void)
10882 result r = E_SUCCESS;
10884 if (__pFlickAnimationTimer)
10887 if (__pFlickAnimationTimer->Start(EDIT_FLICK_SCROLL_TIMER_INTERVAL) != E_SUCCESS)
10894 if (ScrollContentsOnFlick() != E_SUCCESS)
10899 FadeOutScrollBar();
10913 _EditPresenter::SetScrollBarVisible(bool enable)
10915 __isScrollBarVisible = enable;
10921 _EditPresenter::SetScrollBarBounds(const FloatRectangle& bounds)
10923 __scrollBarBounds = bounds;
10929 _EditPresenter::GetDisplayScrollBoundsF(void) const
10931 return __scrollBarBounds;
10935 _EditPresenter::GetInitialBoundsF(void) const
10937 return __initialBounds;
10941 _EditPresenter::SetPreviousScrollBarPosition(int position)
10943 __previousScrollBarPos = _CoordinateSystemUtils::ConvertToFloat(position);
10949 _EditPresenter::SetPreviousScrollBarPosition(float position)
10951 __previousScrollBarPos = position;
10957 _EditPresenter::GetPreviousScrollPosition(void) const
10959 return _CoordinateSystemUtils::ConvertToInteger(__previousScrollBarPos);
10963 _EditPresenter::GetPreviousScrollPositionF(void) const
10965 return __previousScrollBarPos;
10969 _EditPresenter::SetMaximumPreviousScrollBarPosition(int position)
10971 __previousScrollBarMaxPos = _CoordinateSystemUtils::ConvertToFloat(position);
10977 _EditPresenter::SetMaximumPreviousScrollBarPosition(float position)
10979 __previousScrollBarMaxPos = position;
10985 _EditPresenter::GetScrollBar(void) const
10987 return __pScrollBar;
10991 _EditPresenter::GetTextObject(void) const
10993 return __pTextObject;
10997 _EditPresenter::SetAutoShrinkModeEnabled(bool enable)
10999 __isAutoShrinkEnabled = enable;
11005 _EditPresenter::IsAutoShrinkModeEnabled(void) const
11007 return __isAutoShrinkEnabled;
11011 _EditPresenter::GetEditView(void) const
11017 _EditPresenter::InitializeParentPanel(void)
11019 if (__pParentPanel == null)
11021 _ScrollPanel* pScrollPanel = null;
11022 _Control* pControlCore = null;
11024 for (pControlCore = __pEdit->GetParent(); pScrollPanel == null; pControlCore = pControlCore->GetParent())
11026 if (pControlCore == null)
11031 pScrollPanel = dynamic_cast<_ScrollPanel*>(pControlCore);
11034 __pParentPanel = pScrollPanel;
11035 __pParentPanel->AddScrollEventListener(*__pEdit);
11045 _EditPresenter::ScrollPanelToTop(bool show)
11047 if (!__pParentPanel)
11050 FloatRectangle editAbsoluteBounds = __pEdit->GetAbsoluteBoundsF(true);
11051 FloatRectangle panelAbsoluteBounds = __pParentPanel->GetAbsoluteBoundsF(true);
11052 float scrollPosition = __pParentPanel->GetScrollPosition() + (editAbsoluteBounds.y - panelAbsoluteBounds.y);
11054 __pParentPanel->SetScrollPosition(scrollPosition);
11058 __pParentPanel->Invalidate();
11065 _EditPresenter::ScrollPanelToCursorPosition(bool show)
11067 if (!__pParentPanel)
11070 result r = E_SUCCESS;
11072 UpdateComponentInformation();
11074 FloatRectangle absCursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
11075 r = CalculateAbsoluteCursorBounds(__cursorPos, absCursorBounds);
11077 if (r != E_SUCCESS)
11082 //SysLog(NID_UI_CTRL, "------------------------ScrollPosition recalculation starts~!!!!--------------------------.");
11084 FloatRectangle absPanelRect = __pParentPanel->GetAbsoluteBoundsF(true);
11085 FloatRectangle absEditRect = __pEdit->GetAbsoluteBoundsF(true);
11087 float scrollPosition = __pParentPanel->GetScrollPosition();
11088 float upSideGap = 0.0f;
11089 float newScrollPosition = 0.0f;
11091 if (__textObjectBounds.height < absCursorBounds.height)
11093 absCursorBounds.height = __textObjectBounds.height;
11096 upSideGap = absPanelRect.y - absCursorBounds.y; // absPanelRect.y value is always positive
11098 if (upSideGap > 0.0f)
11100 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
11102 newScrollPosition = scrollPosition -(absPanelRect.y -absEditRect.y);
11103 //SysLog(NID_UI_CTRL, "[single line edit] Move up till top boundary of edit.");
11107 newScrollPosition = scrollPosition -(absPanelRect.y -absCursorBounds.y);
11108 //SysLog(NID_UI_CTRL, "[multi-line edit] Move up till up position of cursor.");
11111 //SysLog(NID_UI_CTRL, "move up scroll position from %f to %f", scrollPosition, newScrollPosition);
11115 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
11117 if ((absPanelRect.y + absPanelRect.height) > (absEditRect.y + absEditRect.height))
11119 //SysLog(NID_UI_CTRL, "[single line edit] already exists in exposed region.");
11124 newScrollPosition = scrollPosition + ((absEditRect.y + absEditRect.height) -(absPanelRect.y + absPanelRect.height));
11125 SysLog(NID_UI_CTRL, "Move down till down boundary of edit.");
11129 if ((absCursorBounds.y + absCursorBounds.height) < (absPanelRect.y + absPanelRect.height))
11131 //SysLog(NID_UI_CTRL, "[multi-line edit]Cursor already exist in exposed region.");
11136 newScrollPosition = scrollPosition + ((absCursorBounds.y + absCursorBounds.height) -(absPanelRect.y + absPanelRect.height));
11137 //SysLog(NID_UI_CTRL, "Move down till down position of cursor.");
11140 //SysLog(NID_UI_CTRL, "move down scroll position from %f to %f", scrollPosition, newScrollPosition);
11143 __pParentPanel->SetScrollPosition(newScrollPosition);
11144 __pParentPanel->Invalidate();
11146 //SysLog(NID_UI_CTRL, "------------------------ScrollPosition recalculation Ends!!!!--------------------------.");
11151 _EditPresenter::SetSearchBarFlag(bool enabled)
11153 __isSearchBar = enabled;
11159 _EditPresenter::GetSearchBarFlag(void) const
11161 return __isSearchBar;
11165 _EditPresenter::SetFocused(void)
11167 bool focused = true;
11168 if (__pParentPanel)
11170 _Window* pTop = __pParentPanel->GetRootWindow();
11173 if ((pTop->GetFocusControl(__pEdit) != __pEdit) && __pEdit->IsFocused() == false)
11179 else if (__pEdit->IsFocused() == false)
11184 if (focused == false)
11186 __pEdit->SetFocused();
11193 _EditPresenter::GetWordPosition(int cursorPos, int& startPos, int& endPos) const
11195 int textLength = GetTextLength();
11196 bool isDetected = false;
11198 if (cursorPos >= textLength && cursorPos > 0)
11204 if (IsDelimiter(__pTextBuffer[cursorPos]) && cursorPos > 0)
11210 for (int i = cursorPos; i >= 0; i--)
11212 if (IsDelimiter(__pTextBuffer[i]))
11220 if (isDetected == false)
11226 isDetected = false;
11229 for (int i = cursorPos; i < textLength; i++)
11231 if (IsDelimiter(__pTextBuffer[i]))
11239 if (isDetected == false)
11241 endPos = textLength;
11244 if (startPos > endPos)
11246 int temp = startPos;
11254 _EditPresenter::GetTextImageRangeAt(int postion, int& startPosition, int& endPosition) const
11256 int length = GetTextLength();
11257 startPosition = -1;
11260 SysTryReturnResult(NID_UI_CTRL, postion >= 0 && postion <= length, E_OUT_OF_RANGE, "The given index is out-of-range.");
11262 _Text::TextElement* pTextElement = __pTextObject->GetElementAtTextIndex(postion);
11263 const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
11264 if (pSimpleText != null && pSimpleText->GetBitmap() != null)
11266 startPosition = pSimpleText->GetTextOffset();
11267 endPosition = startPosition + pSimpleText->GetTextLength();
11271 return E_OBJ_NOT_FOUND;
11275 _EditPresenter::IsDelimiter(wchar_t character) const
11281 case 0x0A: // NLine Feed
11284 case 0x0D: // Carriage Return
11287 case 0x20: // Space
11298 _EditPresenter::InitializeCopyPasteManager(void)
11300 bool releaseBlock = true;
11302 if (__pCopyPasteManager)
11304 releaseBlock = __pCopyPasteManager->GetTextBlockReleaseFlag();
11305 delete __pCopyPasteManager;
11306 __pCopyPasteManager = null;
11309 if (IsBlocked() == true && releaseBlock)
11311 ReleaseTextBlock();
11312 __pEdit->Invalidate();
11315 __isCopyPasteManagerExist = false;
11316 __isCopyPastePopupMoving = false;
11322 _EditPresenter::IsCopyPasteManagerExist(void) const
11324 return __isCopyPasteManagerExist;
11328 _EditPresenter::GetTextAreaBoundsF(void) const
11330 return __textObjectBounds;
11334 _EditPresenter::GetTitleBoundsF(void) const
11336 return __titleBounds;
11340 _EditPresenter::GetClearIconBoundsF(void) const
11342 return __clearIconBounds;
11346 _EditPresenter::FinishTextComposition(void)
11348 if (__isInputConnectionBound && __isTextComposing)
11350 __pEdit->SetTextEventEnabled(false);
11351 __pInputConnection->FinishTextComposition();
11352 __isTextComposing = false;
11353 __composingTextLength = 0;
11354 __pEdit->SetTextEventEnabled(true);
11361 _EditPresenter::GetTextCompositionState(void) const
11363 return __isTextComposing;
11367 _EditPresenter::IsCopyPastePopup(const _Control& control) const
11369 if (__pCopyPasteManager)
11371 return __pCopyPasteManager->IsCopyPastePopup(control);
11378 _EditPresenter::IsCopyPasteHandle(const _Control& control) const
11380 if (__pCopyPasteManager)
11382 return __pCopyPasteManager->IsCopyPasteHandle(control);
11389 _EditPresenter::SetCursorChangedFlag(bool enabled)
11391 __isCursorChanged = enabled;
11397 _EditPresenter::GetCursorChangedFlag(void) const
11399 return __isCursorChanged;
11403 _EditPresenter::SetEditGroupStyle(GroupStyle groupStyle)
11405 __groupStyle = groupStyle;
11411 _EditPresenter::PostInternalEvent(const Tizen::Base::String& type)
11415 ArrayList* pArgs = new (std::nothrow) ArrayList();
11416 SysTryReturnVoidResult(NID_UI_CTRL, pArgs != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
11418 result r = E_SYSTEM;
11419 r = pArgs->Construct();
11420 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to construct pArgs");
11422 String* pType = new (std::nothrow) String(type);
11423 SysTryReturnVoidResult(NID_UI, pType, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
11425 r = pArgs->Add(*pType);
11426 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to add type to pArgs");
11428 _UiNotificationEvent event(__pEdit->GetHandle(), pArgs);
11429 r = _UiEventManager::GetInstance()->PostEvent(event);
11430 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to send event");
11436 _EditPresenter::ReleaseCopyPastePopup(void)
11438 if (__pCopyPasteManager)
11440 return __pCopyPasteManager->ReleaseCopyPastePopup();
11445 _EditPresenter::IsCopyPastePopupExist(void) const
11447 if (__pCopyPasteManager)
11449 if (__pCopyPasteManager->GetCopyPastePopup())
11462 _EditPresenter::IsCopyPasteHandleExist(void) const
11464 if (__pCopyPasteManager)
11466 return __pCopyPasteManager->IsCopyPasteHandleExist();
11472 _EditPresenter::IsUnsupportedChracterExist(const KeypadStyle keypadStyle, const Tizen::Base::String& text)
11474 const int numberOfCharOnNumOnlyStyle = 10;
11475 const int numberOfCharOnPhoneNumStyle = 14;
11476 const int numberOfCharOnIpStyle = 18;
11478 const wchar_t* TempKey = null;
11479 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};
11480 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*/,
11481 0x2a/***/, 0x2b/*+*/, 0x23/*#*/, 0x70/*p*/, 0};
11482 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*/,
11483 0x3a/*:*/, 0x2e/*.*/, 0x61/*a*/, 0x62/*b*/, 0x63/*c*/, 0x64/*d*/, 0x65/*e*/, 0x66/*f*/, 0};
11484 bool isSupportedCharacterExist = false;
11485 int supportedCharacterCount = 0;
11487 switch (keypadStyle)
11489 case KEYPAD_STYLE_NUMBER:
11490 supportedCharacterCount = numberOfCharOnNumOnlyStyle;
11491 TempKey = characterOnNumOnlyStyle;
11493 case KEYPAD_STYLE_PHONE_NUMBER:
11494 supportedCharacterCount = numberOfCharOnPhoneNumStyle;
11495 TempKey = characterOnPhoneNumStyle;
11497 case KEYPAD_STYLE_IP_V4:
11498 supportedCharacterCount = numberOfCharOnIpStyle;
11499 TempKey = characterOnIPStyle;
11505 if (text.GetLength() < 1)
11510 for (int i = 0; i < text.GetLength(); i++)
11512 isSupportedCharacterExist = false;
11513 wchar_t checkChar =0;
11514 if (text.GetCharAt(i, checkChar) != E_SUCCESS)
11518 for (int j = 0; j < supportedCharacterCount ; j++)
11520 if (TempKey[j] == checkChar)
11522 isSupportedCharacterExist = true;
11526 if (!isSupportedCharacterExist)
11536 _EditPresenter::SetBlockRangeWithShiftArrowkey(_KeyCode keyCode)
11540 if (IsBlocked() == true)
11542 GetBlockRange(start, end);
11546 if (__textBlockMoveLeft)
11550 SetBlockRange(--start, end);
11555 if (start < end - 1)
11557 SetBlockRange(start, --end);
11559 else if (start == end - 1)
11561 ReleaseTextBlock();
11562 SetCursorPosition(start);
11567 if (__textBlockMoveLeft)
11569 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(start);
11571 if (curCursorLine > 0)
11573 int offset = start - __pTextObject->GetFirstTextIndexAt(curCursorLine);
11574 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine-1);
11575 start = offset + firstTextIndex;
11576 int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
11577 if (offset > textLength)
11579 start = firstTextIndex+textLength-1;
11581 SetBlockRange(start, end);
11586 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(end);
11588 if (curCursorLine > 0)
11590 int offset = end - __pTextObject->GetFirstTextIndexAt(curCursorLine);
11591 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine-1);
11592 end = offset + firstTextIndex;
11593 int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
11594 if (offset > textLength)
11596 end = firstTextIndex+textLength;
11603 __textBlockMoveLeft = true;
11604 SetBlockRange(start, end);
11606 else if (start == end)
11608 ReleaseTextBlock();
11609 SetCursorPosition(end);
11613 SetBlockRange(start, end);
11619 if (__textBlockMoveLeft)
11621 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(start);
11622 int totalLine = __pTextObject->GetTotalLineCount();
11623 if (curCursorLine < totalLine - 1)
11625 int offset = start - __pTextObject->GetFirstTextIndexAt(curCursorLine);
11626 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
11627 start = offset + firstTextIndex;
11628 int textLength = __pTextObject->GetTextLengthAt(curCursorLine+1);
11629 if (offset > textLength)
11631 start = firstTextIndex+textLength;
11639 __textBlockMoveLeft = false;
11640 SetBlockRange(start, end);
11642 else if (start == end)
11644 ReleaseTextBlock();
11645 SetCursorPosition(end);
11649 SetBlockRange(start, end);
11655 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(end);
11656 int totalLine = __pTextObject->GetTotalLineCount();
11657 if (curCursorLine < totalLine - 1)
11659 int offset = end - __pTextObject->GetFirstTextIndexAt(curCursorLine);
11660 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
11661 end = offset + firstTextIndex;
11662 int textLength = __pTextObject->GetTextLengthAt(curCursorLine+1);
11663 if (offset > textLength)
11665 end = firstTextIndex+textLength;
11667 SetBlockRange(start, end);
11672 if (__textBlockMoveLeft)
11674 if (start + 1 < end)
11676 SetBlockRange(++start, end);
11678 else if (start + 1 == end)
11680 ReleaseTextBlock();
11681 SetCursorPosition(end);
11686 if (end + 1 <= GetTextLength())
11688 SetBlockRange(start, ++end);
11698 if (__textBlockMoveLeft)
11700 __pTextObject->SetFirstDisplayLineIndexFromTextIndex(start);
11702 SetCursorChangedFlag(!__textBlockMoveLeft);
11711 if (__cursorPos > 0)
11713 start = __cursorPos - 1;
11715 SetBlockRange(start, end);
11716 __textBlockMoveLeft = true;
11721 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
11723 if (curCursorLine > 0)
11725 int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
11726 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine-1);
11727 start = offset + firstTextIndex;
11728 int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
11729 if (offset > textLength)
11731 start = firstTextIndex+textLength -1;
11734 SetBlockRange(start, end);
11735 __textBlockMoveLeft = true;
11740 if (GetTextLength() >= __cursorPos + 1)
11742 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
11743 int totalLine = __pTextObject->GetTotalLineCount();
11744 if (curCursorLine < totalLine - 1)
11746 int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
11747 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
11748 end = offset + firstTextIndex;
11749 int textLength = __pTextObject->GetTextLengthAt(curCursorLine+1);
11750 if (offset > textLength)
11752 end = firstTextIndex+textLength;
11755 else if (curCursorLine == totalLine - 1)
11757 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine);
11758 int textLength = __pTextObject->GetTextLengthAt(curCursorLine);
11759 end = firstTextIndex + textLength;
11761 start = __cursorPos;
11762 SetBlockRange(start, end);
11763 __textBlockMoveLeft = false;
11767 if (GetTextLength() >= __cursorPos + 1)
11769 start = __cursorPos;
11770 end = __cursorPos + 1;
11771 SetBlockRange(start, end);
11772 __textBlockMoveLeft = false;
11782 __textBlockMoving = true;
11787 _EditPresenter::SetBlockRangeWithCtrlShiftArrowkey(_KeyCode keyCode)
11791 int originalStart = 0;
11792 int originalEnd = 0;
11793 if (IsBlocked() == true)
11795 GetBlockRange(start, end);
11799 if (__textBlockMoveLeft)
11803 originalStart = start;
11805 GetWordPosition(start-1, start, end);
11806 SetBlockRange(start, originalEnd);
11811 originalStart = start;
11813 GetWordPosition(end, start, end);
11814 if (originalEnd == start)
11816 GetWordPosition(start-1, start, end);
11819 if (originalStart < start)
11821 SetBlockRange(originalStart, start);
11823 else if (originalStart > start)
11825 SetBlockRange(start, originalStart);
11826 __textBlockMoveLeft = true;
11828 else if (originalStart == start)
11830 ReleaseTextBlock();
11831 SetCursorPosition(start);
11832 __textBlockMoveLeft = true;
11837 if (__textBlockMoveLeft)
11839 originalStart = start;
11841 GetWordPosition(start, start, end);
11842 if (originalStart == end)
11844 GetWordPosition(end+1, start, end);
11846 if (originalEnd > end)
11848 SetBlockRange(end, originalEnd);
11850 else if (originalEnd < end)
11852 SetBlockRange(originalEnd, end);
11853 __textBlockMoveLeft = false;
11855 else if (originalEnd == end)
11857 ReleaseTextBlock();
11858 SetCursorPosition(end);
11859 __textBlockMoveLeft = false;
11864 if (end < GetTextLength())
11866 originalStart = start;
11868 GetWordPosition(end+1, start, end);
11869 SetBlockRange(originalStart, end);
11879 if (__textBlockMoveLeft)
11881 __pTextObject->SetFirstDisplayLineIndexFromTextIndex(start);
11883 SetCursorChangedFlag(!__textBlockMoveLeft);
11892 if (__cursorPos > 0)
11894 GetWordPosition(__cursorPos, start, end);
11895 if (__cursorPos != start)
11897 SetBlockRange(start, __cursorPos);
11901 GetWordPosition(start-1, start, end);
11902 SetBlockRange(start, __cursorPos);
11904 __textBlockMoveLeft = true;
11908 if (GetTextLength() >= __cursorPos + 1)
11910 GetWordPosition(__cursorPos, start, end);
11911 if (__cursorPos != end)
11913 SetBlockRange(__cursorPos, end);
11917 GetWordPosition(end+1, start, end);
11918 SetBlockRange(__cursorPos, end);
11920 __textBlockMoveLeft = false;
11930 __textBlockMoving = true;
11935 _EditPresenter::SetEditTextFilter(_IEditTextFilter* pFilter)
11937 __pTextFilter = pFilter;
11943 _EditPresenter::ValidatePastedText(const String& pastedText, String& replacedText)
11945 bool enable = false;
11948 enable = __pTextFilter->ValidatePastedText(pastedText, replacedText);
11955 _EditPresenter::SendOpaqueCommand (const String& command)
11957 if (command.Equals(L"KEYPAD_STYLE: PASSWORD", true))
11959 if (__pInputConnection)
11961 __pInputConnection->SetPasswordMode(true);
11965 if (__pInputConnection)
11967 __pInputConnection->SendOpaqueCommand(command);
11974 _EditPresenter::IsBounded(void) const
11976 return __isInputConnectionBound;
11980 _EditPresenter::AdjustRTLTextAlignment(const _EditTextType textType)
11982 result r = E_SUCCESS;
11986 case EDIT_TEXT_TYPE_INPUT:
11987 if (GetTextAlignment() != ALIGNMENT_LEFT)
11989 if (_BidiUtils::IsRTL(GetText()) == true)
11991 __pTextObject->SetTextBidiHint(TEXT_BIDI_HINT_RTL);
11995 __pTextObject->SetTextBidiHint(TEXT_BIDI_HINT_LTR);
11999 if (_BidiUtils::IsRTL(GetText()) == true)
12001 if (__horizontalAlignmentForBidi == ALIGNMENT_LEFT)
12003 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
12005 r = __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
12009 r = __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_TOP);
12011 __horizontalAlignmentForBidi = ALIGNMENT_RIGHT;
12012 __pTextObject->SetTextBidiHint(TEXT_BIDI_HINT_RTL);
12013 if (r == E_SUCCESS)
12021 if (__horizontalAlignmentForBidi == ALIGNMENT_RIGHT)
12023 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
12025 r = __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
12029 r = __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
12031 __horizontalAlignmentForBidi = ALIGNMENT_LEFT;
12032 __pTextObject->SetTextBidiHint(TEXT_BIDI_HINT_LTR);
12033 if (r == E_SUCCESS)
12040 case EDIT_TEXT_TYPE_GUIDE:
12041 if (__pGuideTextObject == null)
12045 if (_BidiUtils::IsRTL(__guideText) == true)
12047 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
12049 r = __pGuideTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
12053 r = __pGuideTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_TOP);
12055 __pGuideTextObject->SetTextBidiHint(TEXT_BIDI_HINT_RTL);
12056 if (r == E_SUCCESS)
12063 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
12065 r = __pGuideTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
12069 r = __pGuideTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
12071 __pGuideTextObject->SetTextBidiHint(TEXT_BIDI_HINT_LTR);
12072 if (r == E_SUCCESS)
12078 case EDIT_TEXT_TYPE_TITLE:
12079 if (__pTitleTextObject == null)
12083 if (_BidiUtils::IsRTL(__titleText) == true)
12085 r = __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
12086 if (r == E_SUCCESS)
12093 r = __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
12094 if (r == E_SUCCESS)
12108 _EditPresenter::UpdateKeypadCommandString(void)
12110 if (!__isKeypadCommandButtonUserSetting)
12112 __pEditModel->UpdateKeypadCommandButtonText();
12113 if (__pCommandButton)
12115 _Button* pLeftButton = __pCommandButton->GetItem(COMMAND_BUTTON_POSITION_LEFT);
12118 pLeftButton->SetText(__pEditModel->GetKeypadCommandButtonText(COMMAND_BUTTON_POSITION_LEFT));
12120 _Button* pRightButton = __pCommandButton->GetItem(COMMAND_BUTTON_POSITION_RIGHT);
12123 pRightButton->SetText(__pEditModel->GetKeypadCommandButtonText(COMMAND_BUTTON_POSITION_RIGHT));
12130 _EditPresenter::SetPasswordVisible(bool visible)
12132 result r = E_SUCCESS;
12134 SysTryReturnResult(NID_UI_CTRL, (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD), E_INVALID_OPERATION,
12135 "Edit Style is not EDIT_STYLE_PASSWORD.")
12138 if (__isPasswordVisible == visible)
12143 __isPasswordVisible = visible;
12145 if (GetTextLength()== 0)
12150 InitializeCopyPasteManager();
12152 FinishTextComposition();
12154 if (__isPasswordVisible)
12156 StopPasswordTimer();
12157 ChangePasswordToPlainText();
12161 ReplaceTextIntoPasswordHyphenString();
12162 __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), 0);
12169 _EditPresenter::IsPasswordVisible(void) const
12171 return __isPasswordVisible;
12175 _EditPresenter::IsClearIconPressed(void) const
12177 return __isClearIconPressed;
12181 _EditPresenter::DrawFocusRing(Tizen::Graphics::Canvas& canvas)
12183 if (__pEditModel->IsViewModeEnabled() || !__pEdit->IsEnabled())
12188 result r = E_SUCCESS;
12189 Bitmap* pFocusRing = null;
12190 Color color = __pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED);
12192 if (IsCurrentFocused() && color.GetAlpha())
12195 GET_COLOR_CONFIG(FOCUSUI::CONTENT_BG_HIGHLIGHTED, focusColor);
12196 focusColor.SetAlpha(color.GetAlpha());
12198 r = GET_BITMAP_CONFIG_N(EDIT::BG_RING_FOCUSED, BITMAP_PIXEL_FORMAT_ARGB8888, pFocusRing);
12199 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
12201 FloatRectangle editRect(0.0f, 0.0f, __pEdit->GetBoundsF().width, __pEdit->GetBoundsF().height);
12203 Bitmap* pReplacementFocusRing = _BitmapImpl::GetColorReplacedBitmapN(*pFocusRing, Color::GetColor(COLOR_ID_MAGENTA), focusColor);
12204 SysTryCatch(NID_UI_CTRL, pReplacementFocusRing, , r = GetLastResult(), "Unable to allocate text buffer.");
12206 if (pReplacementFocusRing)
12208 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pReplacementFocusRing))
12210 canvas.DrawNinePatchedBitmap(editRect, *pReplacementFocusRing);
12214 delete pReplacementFocusRing;
12226 _EditPresenter::OnScrollPositionChanged(Tizen::Ui::_Control& source, float scrollPosition)
12228 if (__isCopyPasteManagerExist)
12230 __pCopyPasteManager->Show();
12235 _EditPresenter::OnScrollStopped(Tizen::Ui::_Control& source)
12237 if (__pCopyPasteManager)
12239 if (__needToCreateCopyPastePopup && !__pCopyPasteManager->GetCopyPastePopup())
12241 __pCopyPasteManager->CreateCopyPastePopup();
12242 if (__pCopyPasteManager->GetCopyPastePopup())
12244 __needToCreateCopyPastePopup = false;
12247 __pCopyPasteManager->Show();
12252 _EditPresenter::OnDragAndDropBeginning(void)
12254 SysLog(NID_UI_CTRL, "Drag & Drop Callback is called");
12256 result r = E_SUCCESS;
12257 _Label* pLabel = null;
12258 FloatDimension dragWindowDimension;
12259 _ControlOrientation orientation = __pEdit->GetOrientation();
12261 GET_SHAPE_CONFIG(EDIT::DRAG_AND_DROP_WINDOW_WIDTH, orientation, dragWindowDimension.width);
12262 GET_SHAPE_CONFIG(EDIT::DRAG_AND_DROP_WINDOW_HEIGHT, orientation, dragWindowDimension.height);
12264 FloatRectangle bounds(__pressedAbsolutePoint.x-dragWindowDimension.width/2.0f, __pressedAbsolutePoint.y-dragWindowDimension.height/2.0f, dragWindowDimension.width, dragWindowDimension.height);
12266 _EditDragAndDropWindow* pDragWindow = new (std::nothrow) _EditDragAndDropWindow();
12267 SysTryReturn(NID_UI_CTRL, pDragWindow, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
12269 r = pDragWindow->CreateRootVisualElement(_WINDOW_TYPE_SUB);
12270 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
12272 pDragWindow->SetBackgroundColor(Color(0, 0, 0, 0));
12273 pDragWindow->SetActivationEnabled(false);
12274 pDragWindow->SetBounds(bounds);
12276 pLabel = _Label::CreateLabelN();
12277 SysTryCatch(NID_UI_CTRL, pLabel, , E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(r));
12279 pLabel->SetBackgroundColor(Color(0, 0, 0, 0));
12280 pLabel->SetBounds(FloatRectangle(0, 0, bounds.width, bounds.height));
12281 pLabel->SetText(__dragAndDropString);
12282 pLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
12284 pDragWindow->AttachChild(*pLabel);
12285 pDragWindow->SetLabel(pLabel);
12287 pDragWindow->Open();
12289 __isCursorDisabled = true;
12291 DrawDragAndDropVisualCue();
12293 return pDragWindow;
12296 delete pDragWindow;
12302 _EditPresenter::OnDragAndDropDropping(void)
12304 SysLog(NID_UI_CTRL, "Drag & Drop Callback is called");
12306 _Window* pDragWindow = __pEdit->GetDragWindow();
12309 pDragWindow->Close();
12310 delete pDragWindow;
12316 _EditPresenter::OnDragAndDropEntered(void)
12318 SysLog(NID_UI_CTRL, "Drag & Drop Callback is called");
12320 DrawDragAndDropVisualCue();
12326 _EditPresenter::OnDragAndDropMoved(const Tizen::Graphics::FloatPoint& position)
12328 SysLog(NID_UI_CTRL, "Drag & Drop Callback is called");
12330 if (IsViewModeEnabled())
12335 FloatRectangle clientBounds = __pEdit->GetBoundsF();
12336 clientBounds.x = 0.0f;
12337 clientBounds.y = 0.0f;
12338 if (clientBounds.Contains(position))
12342 FloatPoint touchPoint = position;
12344 if(!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
12346 float totalHeight = __pTextObject->GetTotalHeightF();
12347 if (totalHeight < __textObjectBounds.height)
12349 if (totalHeight < touchPoint.y)
12351 touchPoint.y = totalHeight;
12356 int cursorPos = GetCursorPositionAt(touchPoint, rowIndex,columnIndex);
12357 if (cursorPos != -1)
12359 SetCursorPosition(cursorPos, rowIndex, columnIndex);
12363 if ((__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) == false)
12365 SetCursorPosition(GetTextLength());
12368 InitializeCursor();
12369 DrawDragAndDropVisualCue();
12375 _EditPresenter::OnDragAndDropLeft(void)
12377 SysLog(NID_UI_CTRL, "Drag & Drop Callback is called");
12379 __pDragAndDropCueVisualElement->SetShowState(false);
12385 _EditPresenter::OnDragAndDropDropped(const _DragAndDropItem& dragAndDropItem)
12387 SysLog(NID_UI_CTRL, "Drag & Drop Callback is called");
12389 __pDragAndDropCueVisualElement->SetShowState(false);
12391 if (IsViewModeEnabled())
12396 if (IsUnsupportedChracterExist(GetKeypadStyle(), dragAndDropItem.GetData()))
12401 if (!IsCurrentFocused())
12403 _Window* pWindow = null;
12404 _ControlManager* pControlManager = _ControlManager::GetInstance();
12405 SysTryReturnVoidResult(NID_UI, pControlManager, E_SYSTEM, "[E_SYSTEM] System error occurred.");
12407 pWindow = pControlManager->GetCurrentFrame();
12410 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
12411 SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] System error occurred.");
12413 bool visible = pEcoreEvas->IsWindowVisible(*pWindow);
12414 bool activationEnabled = pEcoreEvas->IsWindowActivationEnabled(*pWindow);
12416 if ((visible == true) && (activationEnabled == true))
12418 pEcoreEvas->ActivateWindow(*pWindow);
12421 __pEdit->SetFocused();
12424 InsertTextAt(__cursorPos, dragAndDropItem.GetData());
12430 _EditPresenter::DrawDragAndDropVisualCue(void)
12432 if (IsViewModeEnabled())
12437 FloatRectangle cursorBounds;
12438 if (CalculateCursorBounds(__textObjectBounds, cursorBounds) != E_SUCCESS)
12442 __pDragAndDropCueVisualElement->SetShowState(true);
12443 __pDragAndDropCueVisualElement->SetBounds(cursorBounds);
12445 Canvas* pCanvas = __pDragAndDropCueVisualElement->GetCanvasN();
12446 if (pCanvas == null)
12450 pCanvas->SetBackgroundColor(Color(0));
12453 // Color cursorColor;
12454 // GET_COLOR_CONFIG(EDIT::CURSOR_NORMAL, cursorColor);
12456 cursorBounds.SetPosition(0.0f, 0.0f);
12457 pCanvas->FillRectangle(Color::GetColor(COLOR_ID_RED), cursorBounds);
12465 _EditPresenter::ResetDragAndDrop(void)
12467 __dragAndDropStarted = false;
12468 __pEdit->DragAndDropDrop();
12469 if (!IsViewModeEnabled())
12471 __isCursorDisabled = false;
12472 InitializeCursor();
12474 __pDragAndDropCueVisualElement->SetShowState(false);
12478 _EditPresenter::IsDragAndDropStarted(void) const
12480 return __dragAndDropStarted;
12483 }}} // Tizen::Ui::Controls