2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrl_EditPresenter.cpp
20 * @brief This is the implementation file for the _EditPresenter class.
23 #include <FBaseErrorDefine.h>
24 #include <FBaseInternalTypes.h>
25 #include <FBaseSysLog.h>
26 #include <FBaseUtilMath.h>
27 #include <FGrpFloatRectangle.h>
29 #include <FLclLocale.h>
30 #include <FUiCtrlFooter.h>
31 #include <FUiCtrlFooterItem.h>
32 #include <FUiCtrlForm.h>
33 #include <FUiIActionEventListener.h>
34 #include <FGrp_BitmapImpl.h>
35 #include <FGrp_CoordinateSystem.h>
36 #include <FGrp_FontImpl.h>
37 #include <FGrp_Screen.h>
38 #include <FGrp_TextCommon.h>
39 #include <FGrp_TextElementImpl.h>
40 #include <FGrp_TextTextCutLink.h>
41 #include <FGrp_TextTextCutLinkParser.h>
42 #include <FGrp_TextTextElement.h>
43 #include <FGrp_TextTextImage.h>
44 #include <FGrp_TextTextSimple.h>
45 #include "FUi_Clipboard.h"
46 #include "FUi_ClipboardItem.h"
47 #include "FUi_Control.h"
48 #include "FUi_ControlManager.h"
49 #include "FUi_CoordinateSystemUtils.h"
50 #include "FUi_EcoreEvasMgr.h"
51 #include "FUi_ResourceManager.h"
52 #include "FUi_BidiUtils.h"
53 #include "FUi_UiEventManager.h"
54 #include "FUi_UiNotificationEvent.h"
55 #include "FUiAnim_VisualElement.h"
56 #include "FUiAnim_EflNode.h"
57 #include "FUiCtrl_Button.h"
58 #include "FUiCtrl_ContextMenu.h"
59 #include "FUiCtrl_Edit.h"
60 #include "FUiCtrl_EditCopyPasteManager.h"
61 #include "FUiCtrl_EditPresenter.h"
62 #include "FUiCtrl_TokenEditPresenter.h"
63 #include "FUiCtrl_FlickAnimation.h"
64 #include "FUiCtrl_Frame.h"
65 #include "FUiCtrl_Form.h"
66 #include "FUiCtrl_Scroll.h"
67 #include "FUiCtrl_ScrollPanel.h"
68 #include "FUiCtrl_Toolbar.h"
69 #include "FUiCtrl_TableView.h"
70 #include "FUi_Window.h"
73 using namespace Tizen::Base::Runtime;
74 using namespace Tizen::Base::Utility;
75 using namespace Tizen::Media;
76 using namespace Tizen::Ui::Animations;
77 using namespace Tizen::Graphics;
78 using namespace Tizen::Ui;
79 using namespace Tizen::Ui::Controls;
80 using namespace Tizen::Base;
81 using namespace Tizen::Base::Utility;
82 using namespace Tizen::Base::Collection;
83 using namespace Tizen::Locales;
84 using namespace Tizen::Graphics::_Text;
86 namespace Tizen { namespace Ui { namespace Controls
88 const int EDIT_PASSWORD_TIMER_PERIOD = 1000;
89 const int EDIT_CURSOR_TIMER_PERIOD = 600;
90 const int MAX_LINE_NUMBER = 100;
91 const int MAX_FLEXIBLE_HEIGHT_VERTICAL_MODE = 4000;
92 const int MAX_FLEXIBLE_HEIGHT_HORIZONTAL_MODE = 2500;
93 const int EDIT_FLICK_SCROLL_TIMER_INTERVAL = 10;
94 const int EDIT_FLICK_SCROLL_MOVE_AMOUNT_MULTIPLIER = 2;
95 const float DIRECTION_DECISION_RATIO = 1.3f;
96 const float HORIZONTAL_DECISION_RATIO = 1.5f;
97 const float MOVE_SKIP_DECISION_RANGE = 5.0f;
98 const int TITLE_SLIDING_TIME = 800;
100 const int LANGUAGE_CODE_START = 0;
101 const int LANGUAGE_CODE_MAX = 2;
103 bool _EditPresenter::__isKeypadExist = false;
104 bool _EditPresenter::__isClipboardExist = false;
105 float _EditPresenter::__initialParentHeight = 0.0f;
106 float _EditPresenter::__clipboardHeight = 0.0f;
107 _EditFooterVisibleStatus _EditPresenter::__initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
108 bool _EditPresenter::__footerVisibleChanged = false;
109 unsigned int _EditPresenter::__latestBoundedContext = null;
110 const float _EditPresenter::TOUCH_PRESS_THRESHOLD_IN_CLEAR_AREA = 0.04f;
111 _ScrollPanel* _EditPresenter::__pResizedPanel = null;
113 _EditAnimationProvider::_EditAnimationProvider(void)
117 _EditAnimationProvider::~_EditAnimationProvider(void)
121 VisualElementAnimation*
122 _EditAnimationProvider::CreateAnimationForProperty(VisualElement& source, const String& property)
124 VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(source, property);
125 if (pAnimation != null)
127 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseInOut"));
128 pAnimation->SetDuration(ANIMATION_DURATION);
134 _EditPresenter::_EditPresenter(void)
135 : __pTitleSlidingTimer(null)
137 , __pTextBuffer(null)
138 , __pTextString(null)
141 , __pScrollEffect(null)
143 , __horizontalAlignment(ALIGNMENT_LEFT)
144 , __horizontalAlignmentForBidi(ALIGNMENT_LEFT)
145 , __isScrollBarVisible(false)
146 , __scrollBarBounds()
148 , __previousScrollBarPos(0.0f)
149 , __previousScrollBarMaxPos(0.0f)
150 , __pActionEventListener(null)
151 , __pCursorTimer(null)
152 , __pFlickAnimationTimer(null)
153 , __pPasswordTimer(null)
155 , __pCursorVisualElement(null)
156 , __pTextVisualElement(null)
157 , __pTitleTextVisualElement(null)
158 , __pCopyPasteManager(null)
159 , __pFlickAnimation(null)
160 , __pParentForm(null)
161 , __pFullscreenKeypad(null)
162 , __pParentPanel(null)
163 , __pCommandButton(null)
164 , __pInputConnection(null)
165 , __isInputConnectionBound(false)
170 , __isCopyPastePopupMoving(false)
171 , __pressedAbsolutePoint()
172 , __clearIconBounds()
174 , __textObjectBounds()
177 , __previousCursorBounds()
178 , __keypadBounds(0.0f, 0.0f, 0.0f,0.0f)
179 , __pTextObject(null)
180 , __pGuideTextObject(null)
181 , __pTitleTextObject(null)
182 , __titleSlidingAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT)
183 , __textObjectWrap(TEXT_OBJECT_WRAP_TYPE_WORD)
184 , __isTextBlocked(false)
185 , __isGuideTextColorChanged(false)
186 , __isKeypadCommandButtonVisible(false)
187 , __isKeypadCommandButtonUserSetting(false)
188 , __isTextComposing(false)
189 , __isCopyPasteManagerExist(false)
190 , __isCursorChanged(false)
191 , __isCursorInitialized(false)
192 , __isCursorDisabled(false)
193 , __isInitialized(false)
194 , __isMovingCursorByTouchMove(false)
195 , __isTouchMoving(false)
196 , __isTouchPressed(false)
197 , __isClearIconPressed(false)
198 , __isCursorOpaque(false)
199 , __isTouchReleaseSkipped(false)
200 , __isViewerModeEnabled(false)
201 , __isKeypadNormalNumberStyleEnabled(false)
202 , __isTextCompositionFinished(false)
203 , __isFlexibleHeightFrozen(false)
204 , __isKeypadShowing(false)
205 , __isKeypadHiding(false)
206 , __resizedByKeypadHide(false)
209 , __prevTotalTextHeight(-1.0f)
211 , __composingTextLength(0)
212 , __titleWidth(-1.0f)
213 , __verticalMargin(-1.0f)
214 , __isUSBKeyboardConnected(false)
216 , __isCutLinkParserEnabled(false)
218 , __ContentTextStatus(EDIT_TEXT_STATUS_COMPOSE_NON)
219 , __pEditVEDelegator(null)
220 , __isAutoShrinkEnabled(false)
221 , __groupStyle(GROUP_STYLE_NONE)
222 , __isFontInitialized(false)
223 , __contentFontSize(0.0f)
224 , __titleFontSize(0.0f)
225 , __defaultTouchMoveThreshold(0.16f)
226 , __contentFontStyle(FONT_STYLE_PLAIN)
227 , __contentTextStyle(TEXT_BOX_TEXT_STYLE_NORMAL)
228 , __titleFontFaceName("")
229 , __isSearchBar(false)
230 , __pCurrentFrame(null)
231 , __pTextFilter(null)
232 , __textBlockMoveLeft(false)
233 , __textBlockMoving(false)
234 , __clipboardConnected(false)
235 , __updateInitialBounds(true)
236 , __blockTextColor(Color(0, 0, 0))
237 , __rowCursorIndex(-1)
238 , __columnCursorIndex(-1)
239 , __isPasswordVisible(false)
240 , __needToCreateCopyPastePopup(false)
241 , __calculatedCursorBounds(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
246 _EditPresenter::OnInputConnectionPanelShowStateChanged(InputConnection& source, InputPanelShowState showState)
248 if (showState == INPUT_PANEL_SHOW_STATE_SHOW)// 1. keypad show 2.usb on&predictive window show
250 __isKeypadHiding = false;
251 __isKeypadShowing = false;
252 __isKeypadExist = true;
254 CheckUSBKeyboardStatus();
256 SysLog(NID_UI_CTRL, "INPUT_PANEL_SHOW_STATE_SHOW[Target:%x][Bound:%d][Usb mode:%d]", this, __isInputConnectionBound, __isUSBKeyboardConnected);
258 if (__isInputConnectionBound)
260 if (__isKeypadCommandButtonVisible && __pCommandButton)
262 SetFooterVisible(false);
265 ChangeLayoutInternal(__pEdit->GetOrientation());
266 AdjustParentPanelHeight(false);
268 ScrollPanelToCursorPosition();
270 if (__isCopyPasteManagerExist)
272 __pCopyPasteManager->CreateCopyPastePopup();
273 __pCopyPasteManager->Show();
277 if (!__pEdit->IsFullScreenKeypadEdit())
281 __pParentForm->Draw();
285 if (__isUSBKeyboardConnected && (__isKeypadCommandButtonVisible && __pCommandButton))
287 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
289 else if (__isKeypadCommandButtonVisible && __pCommandButton && __pCommandButton->GetVisibleState())//already command exist in usb mode
291 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
295 if (!__isClipboardExist)
297 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
299 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
302 else if (showState == INPUT_PANEL_SHOW_STATE_HIDE)// 1.unbound 2.bounded&usb off -> usb on 3.Flick keypad hide
304 __isKeypadHiding = false;
306 CheckUSBKeyboardStatus();
307 SysLog(NID_UI_CTRL, "INPUT_PANEL_SHOW_STATE_HIDE[Target:%x][Bound:%d][Usb mode:%d]", this, __isInputConnectionBound, __isUSBKeyboardConnected);
309 __isKeypadExist = false;
311 if (__resizedByKeypadHide)
313 __resizedByKeypadHide = false;
317 if (__isCopyPasteManagerExist)
319 InitializeCopyPasteManager();
320 __pTextObject->SetBlock(false);
321 __isTextBlocked = false;
324 if (__isInputConnectionBound && __isUSBKeyboardConnected) // hide callback from external condition(usb mode off->on), focus remaining
326 if (!__isKeypadCommandButtonVisible && !__isClipboardExist)
328 if (__footerVisibleChanged)
330 SetFooterVisible(true);// must be called ahead of DeflateClientRectHeight
334 ChangeLayoutInternal(__pEdit->GetOrientation());
336 if (__isClipboardExist)
338 AdjustParentPanelHeight(false);
342 AdjustParentPanelHeight(true);
345 if (!__pEdit->IsFullScreenKeypadEdit())
349 __pParentForm->Draw();
355 if (__isInputConnectionBound)// keypad drag down
357 if (!__isKeypadCommandButtonVisible && !__isClipboardExist)
359 if (__footerVisibleChanged)
361 SetFooterVisible(true);// must be called ahead of DeflateClientRectHeight
365 FinishTextComposition();
367 ChangeLayoutInternal(__pEdit->GetOrientation());
369 if (__isClipboardExist)
371 AdjustParentPanelHeight(false);
375 AdjustParentPanelHeight(true);
378 if (!__pEdit->IsFullScreenKeypadEdit())
382 __pParentForm->Draw();
386 else// called by focus move or HideKeypad() api call
388 if (__pCommandButton && __isKeypadCommandButtonVisible)
390 SetFooterVisible(true);// must be called ahead of DeflateClientRectHeight
391 __pCommandButton->SetVisibleState(false);
392 __pCommandButton->Invalidate();
395 __isInputConnectionBound = false;
397 AdjustParentPanelHeight(true);
401 SysLog(NID_UI_CTRL, "Form deflate RESET!!!!!!!!!!");
402 __pParentForm->DeflateClientRectHeight(0.0f);
405 if (!__pEdit->IsFullScreenKeypadEdit())
409 __pParentForm->Draw();
415 if ((__isKeypadCommandButtonVisible && __pCommandButton) && __isInputConnectionBound)
417 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
419 else if((__isUSBKeyboardConnected && (__isKeypadCommandButtonVisible &&__pCommandButton) && !__isInputConnectionBound) ||
420 (__isUSBKeyboardConnected && __isClipboardExist))
426 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CLOSED);
427 __pEdit->DetachScrollPanelEvent();
429 if (!__isClipboardExist)
431 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
440 _EditPresenter::OnInputConnectionPanelLanguageChanged(InputConnection& source, LanguageCode language)
442 LanguageCode oldLanguageCode;
443 __pEditModel->GetCurrentLanguage(oldLanguageCode);
445 __pEditModel->SetCurrentLanguage(language);
446 __pEdit->SendLanguageEvent(oldLanguageCode, language);
452 _EditPresenter::OnInputConnectionPanelBoundsChanged(InputConnection& source, const Rectangle& bounds)
454 float previousHeight = __keypadBounds.height;
456 CheckUSBKeyboardStatus();
458 if ((__isUSBKeyboardConnected == false) && __isKeypadExist == false)
460 SysLog(NID_UI_CTRL, "OnInputConnectionPanelBoundsChanged skipped - __isUSBKeyboardConnected:(%), __isKeypadExist:(%d)", __isUSBKeyboardConnected, __isKeypadExist);
464 if (CheckKeypadExist(__pEdit->GetOrientation()) == false)//double check keypad Exist
466 SysLog(NID_UI_CTRL, "OnInputConnectionPanelBoundsChanged skipped - Keypad doesn't exist!!");
471 if (IsKeypadRotating(__pEdit->GetOrientation()))
473 SysLog(NID_UI_CTRL, "OnInputConnectionPanelBoundsChanged skipped - Keypad is rotating!!");
474 AdjustParentPanelHeight(true);
479 SysLog(NID_UI_CTRL, "OnInputConnectionPanelBoundsChanged");
480 ChangeLayoutInternal(__pEdit->GetOrientation());
481 AdjustParentPanelHeight(false);
482 ScrollPanelToCursorPosition();
486 __pParentForm->Draw();
489 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
491 if (__isCopyPasteManagerExist)
494 if (__pCopyPasteManager->GetCopyPastePopup())
496 if (previousHeight != bounds.height)
498 __pCopyPasteManager->CreateCopyPastePopup();
501 __pCopyPasteManager->Show();
508 _EditPresenter::OnInputConnectionTextPredictionShowStateChanged(InputConnection& source, bool isShown)
514 _EditPresenter::OnInputConnectionTextPredictionBoundsChanged(InputConnection& source, const Rectangle& bounds)
520 _EditPresenter::OnInputConnectionTextCommitted(InputConnection& source, const String& committedText)
522 OnTextCommitted(committedText);
528 _EditPresenter::OnTextCommitted(const String& commitText)
530 bool isTextComposingFinished = false;
531 char enterText1[2] = {'\n', };
532 char enterText2[2] = {'\r', };
534 if (IsViewModeEnabled() == true)
539 if (IsBlocked() == true)
541 CoreKeypadAction keypadaction = GetKeypadAction();
542 if (keypadaction == CORE_KEYPAD_ACTION_ENTER || !(commitText == enterText1 || commitText == enterText2))
546 GetBlockRange(start, end);
547 __isFlexibleHeightFrozen = true;
548 DeleteText(start, end);
549 __isFlexibleHeightFrozen = false;
554 if (__isCopyPasteManagerExist)
556 InitializeCopyPasteManager();
559 int textLength = commitText.GetLength();
560 int compositionStart = __cursorPos - textLength;
562 if (__isTextComposing == true)
564 __isFlexibleHeightFrozen = true;
565 DeleteText(__cursorPos-__composingTextLength, __cursorPos);
566 __isFlexibleHeightFrozen = false;
568 __isTextComposing = false;
569 __composingTextLength = 0;
570 isTextComposingFinished = true;
573 if (__ContentTextStatus != EDIT_TEXT_STATUS_COMPOSE_NON)
575 __pTextObject->SetFont(__pFont, __cursorPos, __cursorPos+textLength);
576 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
579 if (__pPasswordTimer)
581 ChangePasswordToEchoCharacter(__pTextBuffer, __echoChar);
585 if (commitText == enterText1 || commitText == enterText2)
587 CoreKeypadAction keypadaction = GetKeypadAction();
589 __pEdit->SendKeypadEvent(keypadaction, CORE_KEYPAD_EVENT_STATUS_ENTERACTION);
590 if (keypadaction != CORE_KEYPAD_ACTION_ENTER)
595 if(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
601 char tapText[2] = {'\t', };
602 if (commitText == tapText)
607 // Limitation Protect
608 String insetText = commitText;
609 int currentLength = GetTextLength();
610 int totalLength = currentLength + textLength;
611 int excessCharacterLength = totalLength - __limitLength;
613 if (excessCharacterLength >= 0)
615 textLength -= excessCharacterLength;
618 insetText.Remove(textLength, excessCharacterLength);
626 InsertTextAt(__cursorPos, insetText);
628 ScrollPanelToCursorPosition();
630 if ((__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) && isTextComposingFinished)
632 ReplaceTextIntoPasswordHyphenString();
635 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
640 ChangePasswordToEchoCharacter((compositionStart + textLength), textLength);
642 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
648 _EditPresenter::OnInputConnectionComposingTextChanged(InputConnection& source, const String& composingText, int cursorPosition)
650 OnComposingTextChanged(composingText, cursorPosition);
656 _EditPresenter::OnComposingTextChanged(const String& composingText, int cursorPosition)
658 if (IsViewModeEnabled() == true)
663 if (IsBlocked() == true)
667 GetBlockRange(start, end);
668 __isFlexibleHeightFrozen = true;
669 DeleteText(start, end);
670 __isFlexibleHeightFrozen = false;
674 if (__isCopyPasteManagerExist)
676 InitializeCopyPasteManager();
679 int textLength = composingText.GetLength();
681 if (__isTextComposing == false)
690 int compositionStart = GetCursorPosition();
694 __isTextComposing = false;
696 // FirstText Check Logic
697 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
698 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine);
699 bool isFirstText = false;
700 if (firstTextIndex + 1 == __pTextObject->GetCursorIndex())
705 DeleteText(compositionStart-__composingTextLength, compositionStart);
709 __isCursorChanged = false;
710 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT);
713 __composingTextLength = 0;
717 if (!__isCursorChanged)
719 __isCursorChanged = true;
721 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
727 __isFlexibleHeightFrozen = true;
728 DeleteText(compositionStart-__composingTextLength, compositionStart);
729 __isFlexibleHeightFrozen = false;
733 __composingTextLength = textLength;
734 if (__composingTextLength > 0)
736 __isTextComposing = true;
739 if (__pPasswordTimer)
741 ChangePasswordToEchoCharacter(__pTextBuffer, __echoChar);
745 // Limitation Protect
746 String insetText = composingText;
747 int currentLength = GetTextLength();
748 int totalLength = currentLength + textLength;
749 int excessCharacterLength = totalLength - __limitLength;
751 if (excessCharacterLength >= 0)
753 __composingTextLength -= excessCharacterLength;
754 if (__composingTextLength > 0)
756 insetText.Remove(__composingTextLength, excessCharacterLength);
760 __composingTextLength = 0;
764 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
765 SysTryReturnVoidResult(NID_UI_CTRL, fontImpl != null, E_SYSTEM, "[E_SYSTEM] fontImpl is null.");
766 fontImpl->SetUnderline(true);
767 __pTextObject->SetFont(__pFont, 0, 0);
769 if (__composingTextLength > 0)
771 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE;
774 InsertTextAt(GetCursorPosition(), insetText);
776 fontImpl->SetUnderline(false);// rollback to default content font
777 __pTextObject->SetFont(__pFont, 0, 0);
779 ScrollPanelToCursorPosition();
782 if (__composingTextLength > 0)
784 ChangePasswordToEchoCharacter((GetCursorPosition() - __composingTextLength), __composingTextLength);
787 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
793 _EditPresenter::DeleteSurroundingText(InputConnection& source, int offset, int charCount)
795 OnSurroundingTextDeleted(offset, charCount);
801 _EditPresenter::OnSurroundingTextDeleted(int offset, int charCount)
806 if (IsBlocked() == true)
808 GetBlockRange(start, end);
812 start = __cursorPos + offset;
817 end = start + charCount;
818 if (end > __cursorPos)
824 DeleteText(start, end);
826 if (__isCopyPasteManagerExist)
828 InitializeCopyPasteManager();
831 if (IsBlocked() == true)
838 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
844 _EditPresenter::GetPreviousText(InputConnection& source, String& text, int& cursorPosition)
846 const int SURRONDING_TEXT_SIZE = 5;
847 int stringLength = 0;
850 if (__cursorPos == 0)
857 if (__cursorPos < SURRONDING_TEXT_SIZE)
859 text = GetText(0, __cursorPos - 1);
863 int previousTextSize = 0;
865 for( int index = 0; index < __cursorPos; index++)
868 if ( __pTextBuffer[__cursorPos-index-1] != 0x20)
874 if (previousTextSize < SURRONDING_TEXT_SIZE)
876 previousTextSize = SURRONDING_TEXT_SIZE;
879 text = GetText(__cursorPos - previousTextSize, __cursorPos - 1);
882 stringLength = text.GetLength();
883 cursorPosition = stringLength;
890 _EditPresenter::OnClipboardPopupOpened(Tizen::Graphics::Dimension& clipboardPopupSize)
892 FloatDimension floatClipboardPopupSize = _CoordinateSystemUtils::ConvertToFloat(clipboardPopupSize);
894 if (__clipboardConnected)
896 __isClipboardExist = true;
897 FloatRectangle absKeypadBounds;
898 GetKeypadBounds(absKeypadBounds);
899 CheckUSBKeyboardStatus();
901 __clipboardHeight = floatClipboardPopupSize.height;
903 SysLog(NID_UI_CTRL, "clipboard height = %f, [KeypadExist:%d]keypad height = %f", floatClipboardPopupSize.height, __isKeypadExist, absKeypadBounds.height);
905 if (__isKeypadExist) //resize as difference between clipboard height vs keypad height
907 if (floatClipboardPopupSize.height > absKeypadBounds.height)
909 ChangeLayoutInternal(__pEdit->GetOrientation());
910 AdjustParentPanelHeight(false);
911 ScrollPanelToCursorPosition();
915 __pParentForm->Draw();
918 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
923 if (!__isKeypadCommandButtonVisible)
925 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
927 ChangeLayoutInternal(__pEdit->GetOrientation());
928 AdjustParentPanelHeight(false);
929 ScrollPanelToCursorPosition();
933 __pParentForm->Draw();
936 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
940 ChangeLayoutInternal(__pEdit->GetOrientation());
941 AdjustParentPanelHeight(false);
942 ScrollPanelToCursorPosition();
946 __pParentForm->Draw();
949 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
952 if (__isCopyPasteManagerExist)
954 __pCopyPasteManager->AdjustBounds();
962 _EditPresenter::OnClipboardPopupBoundsChanged(Tizen::Graphics::Dimension& clipboardPopupSize)
964 FloatDimension floatClipboardPopupSize = _CoordinateSystemUtils::ConvertToFloat(clipboardPopupSize);
966 if (__clipboardConnected)
968 FloatRectangle absKeypadBounds;
969 GetKeypadBounds(absKeypadBounds);
970 CheckUSBKeyboardStatus();
972 __clipboardHeight = floatClipboardPopupSize.height;
974 SysLog(NID_UI_CTRL, "clipboard height = %f, [KeypadExist:%d]keypad height = %f", floatClipboardPopupSize.height, __isKeypadExist, absKeypadBounds.height);
978 if (floatClipboardPopupSize.height >= absKeypadBounds.height)
980 ChangeLayoutInternal(__pEdit->GetOrientation());
981 AdjustParentPanelHeight(false);
982 ScrollPanelToCursorPosition();
986 __pParentForm->Draw();
989 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
993 ChangeLayoutInternal(__pEdit->GetOrientation());
994 AdjustParentPanelHeight(false);
995 ScrollPanelToCursorPosition();
999 __pParentForm->Draw();
1002 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1007 ChangeLayoutInternal(__pEdit->GetOrientation());
1008 AdjustParentPanelHeight(false);
1009 ScrollPanelToCursorPosition();
1013 __pParentForm->Draw();
1016 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1019 if (__rotated) // Command button should be relocated after rotation in case of no keypad.
1021 if (__isCopyPasteManagerExist)
1023 PostInternalEvent(String(L"ShowCopyPaste"));
1027 else if (__isCopyPasteManagerExist)
1029 __pCopyPasteManager->AdjustBounds();
1037 _EditPresenter::OnClipboardPopupClosed(void)
1039 if (__clipboardConnected)
1041 if (__isCopyPasteManagerExist)
1043 InitializeCopyPasteManager();
1044 __pTextObject->SetBlock(false);
1045 __isTextBlocked = false;
1050 __pClipboard->HidePopup();
1053 __isClipboardExist = false;
1054 FloatRectangle absKeypadBounds;
1055 GetKeypadBounds(absKeypadBounds);
1056 CheckUSBKeyboardStatus();
1058 __clipboardHeight = 0.0f;
1060 SysLog(NID_UI_CTRL, "clipboard closed! [KeypadExist:%d]keypad height = %f", __isKeypadExist, absKeypadBounds.height);
1062 if (__isInputConnectionBound)
1064 ChangeLayoutInternal(__pEdit->GetOrientation());
1067 if (__isKeypadExist)
1069 AdjustParentPanelHeight(false);
1073 __pParentForm->Draw();
1076 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1080 if (__footerVisibleChanged)
1082 SetFooterVisible(true);
1085 AdjustParentPanelHeight(true);
1088 SysLog(NID_UI_CTRL, "Form deflate RESET!!!!!!!!!!");
1089 __pParentForm->DeflateClientRectHeight(0.0f);
1090 __pParentForm->Draw();
1093 if (!__isKeypadCommandButtonVisible)
1095 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
1099 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1103 __clipboardConnected = false;
1109 _EditPresenter::~_EditPresenter(void)
1115 _EditPresenter::Dispose(void)
1117 if (__pCurrentFrame)
1119 __pCurrentFrame->RemoveFrameEventListener(*this);
1120 __pCurrentFrame = null;
1123 CheckUSBKeyboardStatus();
1125 if(__latestBoundedContext != (unsigned int)this)//context is already chagned.
1127 __isKeypadHiding = false;
1130 if (__isInputConnectionBound || __isKeypadHiding || __clipboardConnected) //Edit control removed without FocusLost callback or HideKeypad.
1132 if (__clipboardConnected) //Edit control removed after FocusLost or without FocusLost callback.
1134 __pClipboard->HidePopup();
1135 __isClipboardExist = false;
1138 if (__pCommandButton && __isKeypadCommandButtonVisible)
1140 __pCommandButton->SetVisibleState(false);
1142 SetFooterVisible(true);
1144 delete __pCommandButton;
1145 __pCommandButton = null;
1150 SysLog(NID_UI_CTRL, "Form deflate RESET!!!!!!!!!!");
1151 __pParentForm->DeflateClientRectHeight(0.0f);
1154 AdjustParentPanelHeight(true);
1156 __isKeypadExist = false;
1158 __latestBoundedContext = null;
1161 __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
1162 __footerVisibleChanged = false;
1167 __pClipboard->RemoveClipboardPopupEventListener(*this);
1170 if (__pFullscreenKeypad)
1172 __pFullscreenKeypad->Close();
1173 delete __pFullscreenKeypad;
1174 __pFullscreenKeypad = null;
1177 delete __pScrollEffect;
1178 __pScrollEffect = null;
1182 delete[] __pTextBuffer;
1183 __pTextBuffer = null;
1186 delete __pTextString;
1187 __pTextString = null;
1189 delete __pEditModel;
1190 __pEditModel = null;
1194 __pCursorTimer->Cancel();
1195 delete __pCursorTimer;
1196 __pCursorTimer = null;
1199 if (__pInputConnection)
1201 delete __pInputConnection;
1202 __pInputConnection = null;
1205 delete __pTextObject;
1206 __pTextObject = null;
1208 delete __pGuideTextObject;
1209 __pGuideTextObject = null;
1211 delete __pTitleTextObject;
1212 __pTitleTextObject = null;
1214 if (__pPasswordTimer)
1216 __pPasswordTimer->Cancel();
1217 delete __pPasswordTimer;
1218 __pPasswordTimer = null;
1221 if (__pScrollBar != null && __pEdit != null)
1223 __pEdit->DetachSystemChild(*__pScrollBar);
1224 delete __pScrollBar;
1225 __pScrollBar = null;
1228 if (__pFlickAnimationTimer)
1230 __pFlickAnimationTimer->Cancel();
1231 delete __pFlickAnimationTimer;
1232 __pFlickAnimationTimer = null;
1235 if (__pTitleSlidingTimer)
1237 __pTitleSlidingTimer->Cancel();
1238 delete __pTitleSlidingTimer;
1239 __pTitleSlidingTimer = null;
1242 delete __pFlickAnimation;
1243 __pFlickAnimation = null;
1245 if (__pCopyPasteManager != null)
1247 delete __pCopyPasteManager;
1248 __pCopyPasteManager = null;
1251 if (__pTextVisualElement)
1253 __pTextVisualElement->Destroy();
1254 __pTextVisualElement = null;
1257 if (__pCursorVisualElement)
1259 __pCursorVisualElement->Destroy();
1260 __pCursorVisualElement = null;
1263 if (__pTitleTextVisualElement)
1265 __pTitleTextVisualElement->Destroy();
1266 __pTitleTextVisualElement = null;
1269 if (__pEditVEDelegator)
1271 delete __pEditVEDelegator;
1272 __pEditVEDelegator = null;
1279 _EditPresenter::IsKeypadExist(void) const
1281 return __isKeypadExist;
1285 _EditPresenter::IsClipboardExist(void) const
1287 return __isClipboardExist;
1291 _EditPresenter::CheckUSBKeyboardStatus(void)
1293 if (__pInputConnection->CheckUSBKeyboardStatus())
1295 __isUSBKeyboardConnected = true;
1299 __isUSBKeyboardConnected = false;
1306 _EditPresenter::IsUsbKeyboardConnected(void) const
1308 if (__pInputConnection->CheckUSBKeyboardStatus())
1319 _EditPresenter::IsCurrentFocused(void) const
1321 _ControlManager* pControlManager = _ControlManager::GetInstance();
1322 if (pControlManager)
1324 _Control* pControl = pControlManager->GetFocusControl();
1325 if (pControl != __pEdit)
1336 return __pEdit->IsInternalFocused();
1341 _EditPresenter::CreateInstanceN(void)
1343 _EditPresenter* pPresenter = new (std::nothrow) _EditPresenter;
1344 if (pPresenter == null)
1346 SetLastResult(E_OUT_OF_MEMORY);
1354 _EditPresenter::Initialize(const _Control& control)
1356 result r = E_SUCCESS;
1357 _EditModel* pEditModel = null;
1358 _VisualElement* pEditVisualElement = null;
1359 TextSimple* pSimpleText = null;
1360 _ControlManager* pControlManager = _ControlManager::GetInstance();
1361 _Window* pWindow = null;
1363 __pEdit = dynamic_cast<_Edit*>(const_cast<_Control*>(&control));
1364 SysAssertf(__pEdit != null, "__pEdit is null");
1366 __pTextObject = new (std::nothrow) TextObject;
1367 if (__pTextObject == null)
1369 r = E_OUT_OF_MEMORY;
1373 __pTextObject->Construct();
1374 pSimpleText = new (std::nothrow)TextSimple(null, 0, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1375 __pTextObject->AppendElement(*pSimpleText);
1377 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
1379 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1380 if (__pEdit->IsFullScreenKeypadEdit())
1382 __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
1386 __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
1388 __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
1389 __textObjectWrap = TEXT_OBJECT_WRAP_TYPE_NONE;
1393 __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
1394 __pTextObject->SetWrap(__textObjectWrap);
1397 __pTextString = new (std::nothrow) String;
1398 SysTryCatch(NID_UI_CTRL, __pTextString, , r = E_OUT_OF_MEMORY, "Unable to allocate text buffer.");
1401 if (__pFont == null)
1403 _ControlOrientation orientation = __pEdit->GetOrientation();
1404 float defaultFontSize = 0.0f;
1405 GET_SHAPE_CONFIG(EDIT::DEFAULT_FONT_SIZE, orientation, defaultFontSize);
1407 __contentFontSize = defaultFontSize;
1408 __contentFontStyle = FONT_STYLE_PLAIN;
1410 __pFont = __pEdit->GetFallbackFont();
1412 r = GetLastResult();
1413 SysTryReturn(NID_UI_CTRL, __pFont, r, r, "[%s] Propagating.", GetErrorMessage(r));
1415 __titleFontFaceName = __pFont->GetFaceName();
1417 __isFontInitialized = true;
1418 __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
1419 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
1422 __pScrollEffect = new (std::nothrow) _EditScrollEffectInfo;
1423 SysTryCatch(NID_UI_CTRL, __pScrollEffect, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create EditScrollEffectInfo");
1425 for (int i = 0; i < EDIT_SCROLLFRAME_MAX; i++)
1427 __pScrollEffect->touchScrollFrameLevel[i] = 2 + i;
1430 __pScrollEffect->previousY = -1.0f;
1431 __pScrollEffect->currentY = -1.0f;
1432 __pScrollEffect->previousX = -1.0f;
1433 __pScrollEffect->currentX = -1.0f;
1434 __pScrollEffect->cursorPosition = -1;
1436 pEditModel = new (std::nothrow) _EditModel;
1437 SysTryCatch(NID_UI_CTRL, pEditModel, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance");
1439 SetModel(*pEditModel);
1444 if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)
1446 SetViewModeEnabled(true);
1447 __isCutLinkParserEnabled = true;
1451 SetKeypadEnabled(true);
1452 __isCutLinkParserEnabled = false;
1455 if (__pEdit->GetInputStyle() == INPUT_STYLE_FULLSCREEN)
1457 SetCursorDisabled(true);
1460 __initialBounds = __pEdit->GetBoundsF();
1462 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
1464 __pCursorVisualElement = new (std::nothrow) _VisualElement;
1465 SysTryCatch(NID_UI_CTRL, __pCursorVisualElement, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance");
1467 r = __pCursorVisualElement->Construct();
1468 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r));
1470 __pCursorVisualElement->SetSurfaceOpaque(false);
1471 __pCursorVisualElement->SetImplicitAnimationEnabled(false);
1473 pEditVisualElement = __pEdit->GetVisualElement();
1474 SysTryCatch(NID_UI_CTRL, pEditVisualElement, , r = E_SYSTEM, "[E_SYSTEM] Unable to get root visual element.");
1476 __pCursorVisualElement->SetShowState(true);
1478 r = pEditVisualElement->AttachChild(*__pCursorVisualElement);
1479 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r));
1481 __pInputConnection = _InputConnectionImpl::CreateInputConnectionImplN(null);
1482 SysTryCatch(NID_UI_CTRL, __pInputConnection, , r = E_SYSTEM, "[E_SYSTEM] Unable to create an instance .");
1484 __pInputConnection->Initialize(*__pEdit, *this, *this);
1486 __pTextObject->SetBounds(__textObjectBounds);
1487 __pTextObject->HideRearSpace(TEXT_OBJECT_SPACE_HIDE_TYPE_NONE);
1489 __pEditVEDelegator = new (std::nothrow) _EditAnimationProvider();
1490 SysTryCatch(NID_UI_CTRL, __pEditVEDelegator, , E_OUT_OF_MEMORY, "Memory allocation failed.");
1492 pWindow = pControlManager->GetCurrentFrame();
1495 __pCurrentFrame = dynamic_cast<_Frame*>(pWindow);
1496 if (__pCurrentFrame)
1498 __pCurrentFrame->AddFrameEventListener(*this);
1502 __pClipboard = _Clipboard::GetInstance();
1506 __pClipboard->AddClipboardPopupEventListener(*this);
1517 _EditPresenter::InitializeAtFirstDrawing(void)
1519 result r = E_SUCCESS;
1523 InitializeParentPanel();
1525 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT);
1527 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false && (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE))
1529 AdjustFlexibleHeight();
1532 ReplaceTextIntoPasswordHyphenString();
1534 if (__pEdit->IsViewModeEnabled())
1536 __pEdit->SetCursorPosition(0);
1539 __isInitialized = true;
1545 _EditPresenter::DrawBackgroundBitmap(Canvas& canvas, bool focused)
1547 if (!DrawChangeableBackground(canvas, focused, 0, 0))
1556 _EditPresenter::DrawChangeableBackground(Canvas& canvas, bool focused, int bitmapId, int effectBitmapId, bool outLine, int outlineBitmapId)
1558 result r = E_SUCCESS;
1559 FloatRectangle editRect(0.0f, 0.0f, __pEdit->GetBoundsF().width, __pEdit->GetBoundsF().height);
1561 Bitmap* pEditBgBitmap = null;
1562 Bitmap* pEditBgEffectBitmap = null;
1563 Bitmap* pReplacementColorBackgroundBitmap = null;
1564 bool borderRoundEnable = __pEdit->IsBorderRoundStyleEnabled();
1565 EditStatus editStatus = GetCurrentStatus();
1567 pEditBgBitmap = __pEdit->GetDefaultBackgroundBitmap(editStatus);
1569 if (borderRoundEnable)
1571 pEditBgBitmap = null;
1572 r = GET_BITMAP_CONFIG_N(EDIT::BG_ROUND_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pEditBgBitmap);
1573 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap");
1576 bitmapColor = __pEdit->GetColor(editStatus);
1577 if (__groupStyle != GROUP_STYLE_NONE)
1579 GET_COLOR_CONFIG(PANEL::GROUPED_STYLE_BG_NORMAL, bitmapColor);
1582 pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pEditBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), bitmapColor);
1583 if (pReplacementColorBackgroundBitmap)
1585 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pReplacementColorBackgroundBitmap))
1587 canvas.DrawNinePatchedBitmap(editRect, *pReplacementColorBackgroundBitmap);
1591 canvas.DrawBitmap(editRect, *pReplacementColorBackgroundBitmap);
1595 if ((!__pEdit->IsFullScreenKeypadEdit() && __groupStyle != GROUP_STYLE_NONE) || GetSearchBarFlag())
1597 pEditBgEffectBitmap = __pEdit->GetDefaultBackgroundEffectBitmap();
1599 if (pEditBgEffectBitmap)
1601 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pEditBgEffectBitmap))
1603 canvas.DrawNinePatchedBitmap(editRect, *pEditBgEffectBitmap);
1607 canvas.DrawBitmap(editRect, *pEditBgEffectBitmap);
1612 if (borderRoundEnable)
1616 delete pEditBgBitmap;
1617 pEditBgBitmap = null;
1620 if (pEditBgEffectBitmap)
1622 delete pEditBgEffectBitmap;
1623 pEditBgEffectBitmap = null;
1626 delete pReplacementColorBackgroundBitmap;
1627 pReplacementColorBackgroundBitmap = null;
1631 delete pEditBgBitmap;
1637 _EditPresenter::DrawBackground(Canvas& canvas, bool drawTitleText)
1639 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
1641 return DrawSingleLineBackground(canvas, drawTitleText);
1644 FloatRectangle editRect(0.0f, 0.0f, __pEdit->GetBoundsF().width, __pEdit->GetBoundsF().height);
1646 EditStatus editStatus = GetCurrentStatus();
1648 Bitmap* pEditBgBitmap = __pEdit->GetBackgroundBitmap(editStatus);
1652 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pEditBgBitmap))
1654 canvas.DrawNinePatchedBitmap(editRect, *pEditBgBitmap);
1658 canvas.DrawBitmap(editRect, *pEditBgBitmap);
1663 DrawBackgroundBitmap(canvas, IsCurrentFocused());
1666 DrawFocusRing(canvas);
1670 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_TOP) || (__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_LEFT))
1680 _EditPresenter::DrawTitleText()
1682 result r = E_SUCCESS;
1683 if (__titleText == -1)
1689 TextObjectActionType titleAction;
1690 Canvas* pTitleTextCanvas = null;
1691 _VisualElement* pRootElement = __pEdit->GetVisualElement();
1692 SysTryReturn(NID_UI_CTRL, pRootElement, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get root visual element.");
1694 if (!__pTitleTextVisualElement)
1696 __pTitleTextVisualElement = new (std::nothrow) _VisualElement();
1697 SysTryReturnResult(NID_UI_CTRL, __pTitleTextVisualElement, E_OUT_OF_MEMORY, "Memory allocation failed.");
1699 r = __pTitleTextVisualElement->Construct();
1700 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r = E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to construct _VisualElement.");
1702 __pTitleTextVisualElement->SetImplicitAnimationEnabled(false);
1703 __pTitleTextVisualElement->SetShowState(true);
1705 r = pRootElement->AttachChild(*__pTitleTextVisualElement);
1706 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1709 __pTitleTextVisualElement->SetBounds(__titleBounds);
1711 pTitleTextCanvas = __pTitleTextVisualElement->GetCanvasN();
1712 SysTryCatch(NID_UI_CTRL, pTitleTextCanvas, , r, "[%s] Propagating.", GetErrorMessage(r));
1714 pTitleTextCanvas->SetBackgroundColor(Color(0));
1715 pTitleTextCanvas->Clear();
1717 titleAction = __pTitleTextObject->GetAction();
1718 if (IsCurrentFocused() == true)
1720 __pTitleTextObject->SetForegroundColor(__pEdit->GetTitleTextColor(EDIT_STATUS_HIGHLIGHTED), 0, __pTitleTextObject->GetTextLength());
1722 if (titleAction != __titleSlidingAction)
1724 __pTitleTextObject->SetAction(__titleSlidingAction);
1725 __pTitleTextObject->Compose();
1728 __pTitleTextObject->SetBounds(FloatRectangle(0.0f, 0.0f, __titleBounds.width, __titleBounds.height));
1729 __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pTitleTextCanvas));
1731 StopTitleSlidingTimer();
1732 if (__pTitleTextObject->IsActionOn() == true)
1734 StartTitleSlidingTimer();
1739 __pTitleTextObject->SetForegroundColor(__pEdit->GetTitleTextColor(GetCurrentStatus()), 0, __pTitleTextObject->GetTextLength());
1741 if (titleAction != TEXT_OBJECT_ACTION_TYPE_ABBREV)
1743 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1746 __pTitleTextObject->SetBounds(FloatRectangle(0.0f, 0.0f, __titleBounds.width, __titleBounds.height));
1747 __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pTitleTextCanvas));
1750 delete pTitleTextCanvas;
1755 __pTitleTextVisualElement->Destroy();
1756 __pTitleTextVisualElement = null;
1762 _EditPresenter::DrawText(void)
1764 Canvas* pCanvas = null;
1766 // In case of unfocused and touch moving
1767 if (__isTouchMoving && !__pTextVisualElement)
1769 result r = E_SUCCESS;
1770 __pTextVisualElement = new (std::nothrow) _VisualElement;
1771 SysTryReturnVoidResult(NID_UI_CTRL, __pTextVisualElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create __pTextVisualElement instance.");
1773 r = __pTextVisualElement->Construct();
1774 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r));
1776 __pTextVisualElement->SetSurfaceOpaque(false);
1777 __pTextVisualElement->SetImplicitAnimationEnabled(false);
1779 __pTextVisualElement->SetShowState(true);
1781 _VisualElement* pEditVisualElement = __pEdit->GetVisualElement();
1782 SysTryCatch(NID_UI_CTRL, pEditVisualElement, , r = E_SYSTEM, "[E_SYSTEM] Unable to get root visual element.");
1784 pEditVisualElement->AttachChild(*__pTextVisualElement);
1785 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r));
1787 pCanvas = __pEdit->GetCanvasN();
1788 SysTryCatch(NID_UI_CTRL, pCanvas, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance.");
1790 pCanvas->SetBackgroundColor(Color(0));
1791 r = pCanvas->Clear();
1792 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1794 DrawBackground(*pCanvas);
1800 if (__pTextVisualElement)
1802 FloatRectangle editBounds = __pEdit->GetBoundsF();
1803 __pTextVisualElement->SetOpacity(1.0f);
1804 __pTextVisualElement->SetBounds(FloatRectangle(0.0f, 0.0f, editBounds.width, editBounds.height));
1805 pCanvas = __pTextVisualElement->GetCanvasN();
1806 if (pCanvas == null)
1810 pCanvas->SetBackgroundColor(Color(0));
1815 if (__pEdit->GetEditStyle() & EDIT_STYLE_CLEAR)
1817 DrawClearIcon(*pCanvas);
1827 __pTextVisualElement->Destroy();
1828 __pTextVisualElement = null;
1840 _EditPresenter::DrawText(Canvas& canvas)
1842 result r = E_SUCCESS;
1844 if (__pEdit->GetEnableState() == false)
1846 __pTextObject->SetAlternateLookEnabled(true);
1847 Color tempColor = __pEdit->GetTextColor(EDIT_STATUS_DISABLED);
1848 __pTextObject->SetAlternativeForegroundColor(tempColor);
1852 __pTextObject->SetAlternateLookEnabled(false);
1856 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
1858 return DrawTextForEntireFontSetting(canvas);
1861 // initital guide text
1862 if (IsGuideTextActivated())
1864 __pGuideTextObject->SetForegroundColor(__pEdit->GetGuideTextColor(), 0, __pGuideTextObject->GetTextLength());
1866 if (__isGuideTextColorChanged == true && __pEdit->IsSettingGuideTextColor() == false)
1868 __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_NORMAL), 0, __pGuideTextObject->GetTextLength());
1869 __pGuideTextObject->SetBounds(__textObjectBounds);
1870 __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
1871 __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_DISABLED), 0, __pGuideTextObject->GetTextLength());
1872 __isGuideTextColorChanged = false;
1876 __pGuideTextObject->SetBounds(__textObjectBounds);
1877 __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
1881 if (GetTextLength() <= 0)
1887 EditStatus editStatus = GetCurrentStatus();
1889 __pTextObject->SetForegroundColor(__pEdit->GetTextColor(editStatus), 0, __pTextObject->GetTextLength());
1890 if (__isTextBlocked)
1892 __pTextObject->SetForegroundColor(__blockTextColor, __blockStartPos, __cursorPos - __blockStartPos);
1895 if (__isTextBlocked == true && editStatus == EDIT_STATUS_HIGHLIGHTED)
1897 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED), 0, __pTextObject->GetTextLength());
1898 __pTextObject->SetBlock(true);
1899 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
1901 else if (__isTextBlocked == true && editStatus == EDIT_STATUS_PRESSED)
1903 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_PRESSED), 0, __pTextObject->GetTextLength());
1904 __pTextObject->SetBlock(true);
1905 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
1907 else if (__isTextBlocked == true && editStatus == EDIT_STATUS_NORMAL)
1909 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_NORMAL), 0, __pTextObject->GetTextLength());
1910 __pTextObject->SetBlock(true);
1911 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
1915 __pTextObject->SetBlock(false);
1916 __isTextBlocked = false;
1919 UpdateComponentInformation();
1921 __pTextObject->SetBounds(__textObjectBounds);
1922 __pTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
1924 if (__isTextBlocked == true && editStatus == EDIT_STATUS_HIGHLIGHTED)
1926 __pTextObject->SetBackgroundColor(Color::GetColor(COLOR_ID_BLACK), 0, __pTextObject->GetTextLength());
1929 DrawTextBlockLine(canvas);
1931 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
1937 _EditPresenter::DrawTextBlockLine(Canvas& canvas)
1939 if (!__isTextBlocked)
1944 int lengthRange = 0;
1946 int columnIndex = -1;
1948 Color textBlockLineColor;
1949 GET_COLOR_CONFIG(EDIT::CURSOR_NORMAL, textBlockLineColor);
1951 GetBlockRange(startRange, lengthRange);
1953 FloatRectangle cursorBounds;
1954 FloatRectangle textObjectBounds = __textObjectBounds;
1955 textObjectBounds.x -= 1;
1956 textObjectBounds.width = textObjectBounds.width + 2;
1958 if (__pCopyPasteManager)
1960 __pCopyPasteManager->GetHandlerRowColumnIndex(false, true, rowIndex, columnIndex);
1963 if (rowIndex != -1 && columnIndex != -1)
1965 CalculateCursorBounds(__textObjectBounds, cursorBounds, rowIndex, columnIndex);
1969 CalculateCursorBounds(__textObjectBounds, cursorBounds, startRange);
1972 if (cursorBounds.x != -1)
1974 cursorBounds.x -= 1;
1975 cursorBounds = cursorBounds.GetIntersection(textObjectBounds);
1976 canvas.FillRectangle(textBlockLineColor, cursorBounds);
1982 if (__pCopyPasteManager)
1984 __pCopyPasteManager->GetHandlerRowColumnIndex(false, false, rowIndex, columnIndex);
1986 if (rowIndex != -1 && columnIndex != -1)
1988 CalculateCursorBounds(__textObjectBounds, cursorBounds, rowIndex, columnIndex);
1992 CalculateCursorBounds(__textObjectBounds, cursorBounds, lengthRange);
1995 if (cursorBounds.x != -1 && cursorBounds.x <= __textObjectBounds.x + __textObjectBounds.width)
1997 cursorBounds.x -= 1;
1998 cursorBounds = cursorBounds.GetIntersection(textObjectBounds);
1999 canvas.FillRectangle(textBlockLineColor, cursorBounds);
2004 _EditPresenter::DrawTextForEntireFontSetting(Canvas& canvas)
2006 result r = E_SUCCESS;
2008 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) && IsCurrentFocused() == false)
2010 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
2014 if (__pTextObject->GetAction() != TEXT_OBJECT_ACTION_TYPE_NONE)
2016 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE);
2017 __isCursorChanged = true;
2021 // initital guide text
2022 if (IsGuideTextActivated())
2024 __pGuideTextObject->SetForegroundColor(__pEdit->GetGuideTextColor(), 0, __pGuideTextObject->GetTextLength());
2026 if (__isGuideTextColorChanged == true && __pEdit->IsSettingGuideTextColor() == false)
2028 __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_NORMAL), 0, __pGuideTextObject->GetTextLength());
2029 __pGuideTextObject->SetBounds(__textObjectBounds);
2030 __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
2031 __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_DISABLED), 0, __pGuideTextObject->GetTextLength());
2032 __isGuideTextColorChanged = false;
2036 __pGuideTextObject->SetBounds(__textObjectBounds);
2037 __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
2041 if (GetTextLength() <= 0)
2047 EditStatus editStatus = GetCurrentStatus();
2049 if (IsCurrentFocused() == false)
2051 if (__isCursorChanged == true)
2053 if (AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT) == true)
2055 __pTextObject->Compose();
2058 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD))
2060 __pTextObject->SetFirstDisplayLineIndexFromTextIndex(0);
2062 __pTextObject->SetForegroundColor(__pEdit->GetTextColor(editStatus), 0, __pTextObject->GetTextLength());
2063 __pTextObject->SetBlock(false);
2068 int lengthRange = 0;
2070 __pTextObject->GetRange(startRange, lengthRange);
2071 __pTextObject->SetRange(0, GetTextLength());
2072 __pTextObject->SetForegroundColor(__pEdit->GetTextColor(editStatus), 0, __pTextObject->GetTextLength());
2073 if (__isTextBlocked)
2075 __pTextObject->SetForegroundColor(__blockTextColor, __blockStartPos, __cursorPos - __blockStartPos);
2078 if (IsBlocked() == true && editStatus == EDIT_STATUS_HIGHLIGHTED)
2080 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED), 0, __pTextObject->GetTextLength());
2081 __pTextObject->SetBlock(true);
2082 __pTextObject->SetRange(__blockStartPos, __cursorPos - __blockStartPos);
2084 else if (__isTextBlocked == true && editStatus == EDIT_STATUS_PRESSED)
2086 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_PRESSED), 0, __pTextObject->GetTextLength());
2087 __pTextObject->SetBlock(true);
2088 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
2090 else if (__isTextBlocked == true && editStatus == EDIT_STATUS_NORMAL)
2092 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_NORMAL), 0, __pTextObject->GetTextLength());
2093 __pTextObject->SetBlock(true);
2094 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
2098 __pTextObject->SetBlock(false);
2099 __isTextBlocked = false;
2102 UpdateComponentInformation();
2105 __pTextObject->SetBounds(__textObjectBounds);
2106 __pTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
2108 DrawTextBlockLine(canvas);
2114 _EditPresenter::DrawSingleLineBackground(Canvas& canvas, bool drawTitleText)
2116 FloatRectangle editField(0.0f, 0.0f, __pEdit->GetBoundsF().width, __pEdit->GetBoundsF().height);
2117 EditStatus editStatus = GetCurrentStatus();
2119 Bitmap* pEditBgBitmap = __pEdit->GetBackgroundBitmap(editStatus);
2123 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pEditBgBitmap))
2125 canvas.DrawNinePatchedBitmap(editField, *pEditBgBitmap);
2129 canvas.DrawBitmap(editField, *pEditBgBitmap);
2134 DrawSingleLineBackgroundBitmap(canvas, IsCurrentFocused());
2137 DrawFocusRing(canvas);
2141 if (((__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_LEFT) && !(__titleText.GetLength() == 0)) || (__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_TOP))
2152 _EditPresenter::DrawSingleLineBackgroundBitmap(Canvas& canvas, bool focused)
2154 if (__isTouchPressed)
2156 DrawChangeableBackground(canvas, focused, 0, 0);
2162 DrawChangeableBackground(canvas, focused, 0, 0, true, 0);
2166 bool tmpFocused = focused;
2167 DrawChangeableBackground(canvas, tmpFocused, 0, 0);
2175 _EditPresenter::DrawClearIcon(Canvas& canvas)
2177 result r = E_SUCCESS;
2179 float clearIconWidth = 0;
2180 float clearIconHeight = 0;
2182 _ControlOrientation orientation = __pEdit->GetOrientation();
2183 GET_SHAPE_CONFIG(EDIT::CLEAR_ICON_WIDTH, orientation, clearIconWidth);
2184 GET_SHAPE_CONFIG(EDIT::CLEAR_ICON_HEIGHT, orientation, clearIconHeight);
2186 if (__pTextString->GetLength() == 0)
2191 Bitmap* pEditBitmapClear = null;
2192 Bitmap* pEditReplacedBitmapClear = null;
2193 Color editClearIconColor;
2195 if (!__pEdit->IsEnabled())
2197 r = GET_BITMAP_CONFIG_N(EDIT::CLEAR_ICON_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pEditBitmapClear);
2199 if (pEditBitmapClear == null)
2204 GET_COLOR_CONFIG(EDIT::CLEAR_ICON_DISABLED, editClearIconColor);
2206 else if (__isClearIconPressed)
2208 r = GET_BITMAP_CONFIG_N(EDIT::CLEAR_ICON_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pEditBitmapClear);
2210 if (pEditBitmapClear == null)
2215 GET_COLOR_CONFIG(EDIT::CLEAR_ICON_PRESSED, editClearIconColor);
2219 r = GET_BITMAP_CONFIG_N(EDIT::CLEAR_ICON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pEditBitmapClear);
2220 if (pEditBitmapClear == null)
2225 GET_COLOR_CONFIG(EDIT::CLEAR_ICON_NORMAL, editClearIconColor);
2228 FloatRectangle textRect = __textObjectBounds;
2229 FloatRectangle afterClearIconRect(textRect.x + textRect.width, textRect.y + (textRect.height - clearIconHeight) / 2.0f, clearIconWidth, clearIconHeight);
2230 FloatRectangle editBounds = __pEdit->GetBoundsF();
2232 pEditReplacedBitmapClear = _BitmapImpl::GetColorReplacedBitmapN(*pEditBitmapClear, Color::GetColor(COLOR_ID_MAGENTA),
2233 editClearIconColor);
2234 SysTryCatch(NID_UI_CTRL, pEditReplacedBitmapClear, , r = E_SYSTEM, "[E_SYSTEM] Unable to create an instance .");
2236 if (__clearIconBounds != afterClearIconRect)
2238 __clearIconBounds = afterClearIconRect;
2239 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_CLEAR_ICON);
2242 if (editBounds.height < clearIconHeight)
2244 __clearIconBounds.y = textRect.y;
2247 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pEditReplacedBitmapClear))
2249 r = canvas.DrawNinePatchedBitmap(__clearIconBounds, *pEditReplacedBitmapClear);
2253 r = canvas.DrawBitmap(__clearIconBounds, *pEditReplacedBitmapClear);
2256 if (pEditBitmapClear)
2258 delete pEditBitmapClear;
2259 pEditBitmapClear = null;
2262 if (pEditReplacedBitmapClear)
2264 delete pEditReplacedBitmapClear;
2265 pEditReplacedBitmapClear = null;
2271 delete pEditBitmapClear;
2277 _EditPresenter::Draw(Canvas& canvas)
2279 result r = E_SUCCESS;
2281 if (__isInitialized == false)
2283 r = InitializeAtFirstDrawing();
2284 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Faild to initialize.");
2286 if (IsCurrentFocused() == true && __isInputConnectionBound == false)
2288 if (IsViewModeEnabled() == false)
2290 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
2296 ShowFullscreenKeypad();
2302 __isCursorOpaque = true;
2304 canvas.SetBackgroundColor(Color(0));
2306 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2308 DrawBackground(canvas);
2310 if (__pTextVisualElement)
2318 if (__pEdit->GetEditStyle() & EDIT_STYLE_CLEAR)
2320 DrawClearIcon(canvas);
2324 if (__rotated && !__clipboardConnected) // Command button should be relocated after rotation in case of no keypad.
2326 if (__isCopyPasteManagerExist)
2328 PostInternalEvent(String(L"ShowCopyPaste"));
2338 //To avoid resizing to Flexible bounds on User SetBounds in Non-focussed mode
2339 if (IsFocused() || (!__isAutoShrinkEnabled))
2341 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
2343 AdjustFlexibleHeight();
2345 if (__pEdit->HasFocusRing())
2347 __pEdit->RemoveFocusRing();
2348 __pEdit->OnDrawFocus();
2357 _EditPresenter::ConvertLinkType(void)
2359 if (__isCutLinkParserEnabled == false || IsViewModeEnabled() == false)
2364 unsigned long autoLinkMask = GetAutoLinkMask();
2365 bool isChangingCutLink = false;
2366 EditCutLinkType editLinkType = EDIT_LINK_TYPE_INVALID;
2367 TextCutLinkParser cutlinkParser;
2368 cutlinkParser.SetCutLinkMask(autoLinkMask);
2369 TextLinkInfo* pLinkInfo = cutlinkParser.Parse(__pTextBuffer, wcslen(__pTextBuffer), 0);
2370 TextLinkInfo* pNextLinkInfo = null;
2371 int cursorPos = __cursorPos;
2373 __isCutLinkParserEnabled = false;
2375 while (pLinkInfo != null)
2377 if (IsViewModeEnabled() == true)
2379 switch (pLinkInfo->linkType)
2382 if (autoLinkMask & LINK_TYPE_URL)
2384 isChangingCutLink = true;
2385 editLinkType = EDIT_LINK_TYPE_URL;
2389 case LINK_TYPE_EMAIL:
2390 if (autoLinkMask & LINK_TYPE_EMAIL)
2392 isChangingCutLink = true;
2393 editLinkType = EDIT_LINK_TYPE_URL;
2397 case LINK_TYPE_TEL_NUM:
2398 if (autoLinkMask & LINK_TYPE_TEL_NUM)
2400 isChangingCutLink = true;
2401 editLinkType = EDIT_LINK_TYPE_PHONE_NUM;
2406 editLinkType = EDIT_LINK_TYPE_INVALID;
2412 _Text::TextElement* pTextElement = __pTextObject->GetElementAtTextIndex(pLinkInfo->srcOffset);
2413 if (pTextElement != null && pTextElement->GetType() != TEXT_ELEMENT_TYPE_CUTLINK)
2415 pNextLinkInfo = pLinkInfo->pNextLinkInfo;
2417 pLinkInfo = pNextLinkInfo;
2422 wchar_t* pCutLinkString = null;
2423 result r = E_SUCCESS;
2425 pCutLinkString = new(std::nothrow) wchar_t[(pLinkInfo->length + 1) * sizeof(wchar_t)];
2427 if (!pCutLinkString)
2429 while (pLinkInfo != null)
2431 pNextLinkInfo = pLinkInfo->pNextLinkInfo;
2433 pLinkInfo = pNextLinkInfo;
2435 SysLog(NID_UI_CTRL, "[E_SYSTEM] Unable to allocate cutlink text buffer.");
2439 for (int i = 0; i < pLinkInfo->length; i++)
2441 pCutLinkString[i] = __pTextBuffer[pLinkInfo->srcOffset + i];
2443 pCutLinkString[pLinkInfo->length] = null;
2445 r = DeleteText(pLinkInfo->srcOffset, pLinkInfo->srcOffset + pLinkInfo->length);
2449 int currentLength = __pTextString->GetLength();
2450 int fullLength = currentLength + pLinkInfo->length;
2452 r = __pTextString->Insert(String(pCutLinkString), pLinkInfo->srcOffset);
2453 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2455 wchar_t pOriginalString[currentLength - pLinkInfo->srcOffset];
2457 // Save original text.
2458 for (int i = 0; i < currentLength - pLinkInfo->srcOffset; i++)
2460 pOriginalString[i] = __pTextBuffer[pLinkInfo->srcOffset + i];
2462 pOriginalString[currentLength - pLinkInfo->srcOffset] = 0;
2465 for (int i = 0; i < pLinkInfo->length; i++)
2467 __pTextBuffer[i + pLinkInfo->srcOffset] = pCutLinkString[i];
2470 // Append origianal text.
2471 for (int i = 0; i < currentLength - pLinkInfo->srcOffset; i++)
2473 __pTextBuffer[i + pLinkInfo->srcOffset + pLinkInfo->length] = pOriginalString[i];
2475 __pTextBuffer[fullLength] = 0;
2478 if (isChangingCutLink)
2480 TextCutLink* pCutLinkObject = null;
2481 EditCutlinkColor cutlinkColor;
2483 Font* pFont = _FontImpl::CloneN(const_cast <Font&>(*__pFont));
2484 SysTryReturnResult(NID_UI_CTRL, pFont, GetLastResult(), "Unable to get font.");
2486 _FontImpl* fontImpl = _FontImpl::GetInstance(*pFont);
2487 SysTryReturnResult(NID_UI_CTRL, fontImpl, GetLastResult(), "[E_SYSTEM] fontImpl is null.");
2488 fontImpl->SetUnderline(true);
2490 __pEdit->GetCutlinkColorInfo(editLinkType, &cutlinkColor);
2491 pCutLinkObject = new (std::nothrow) TextCutLink(false, pLinkInfo->linkType, pCutLinkString, pLinkInfo->length, TEXT_ELEMENT_SOURCE_TYPE_INTERNAL, pFont,
2492 cutlinkColor.cutlinkFgColor, cutlinkColor.cutlinkBgColor, 0);
2496 if (pCutLinkObject == null)
2498 SysLog(NID_UI_CTRL, "Unable to allocate cutlink object.");
2502 pCutLinkObject->SetEditModeEnable(true);
2503 __pTextObject->InsertElementAt(pLinkInfo->srcOffset, *pCutLinkObject);
2504 __pTextObject->ChangeTextOffset(__pTextBuffer, pLinkInfo->srcOffset, pLinkInfo->length);
2509 TextSimple* pSimpleText = null;
2510 pSimpleText = new (std::nothrow) TextSimple(pCutLinkString, pLinkInfo->length, TEXT_ELEMENT_SOURCE_TYPE_INTERNAL, GetFont());
2512 if (pSimpleText == null)
2514 SysLog(NID_UI_CTRL, "Unable to allocate text object.");
2519 __pTextObject->InsertElementAt(pLinkInfo->srcOffset, *pSimpleText);
2520 __pTextObject->ChangeTextOffset(__pTextBuffer, pLinkInfo->srcOffset, pSimpleText->GetTextLength());
2524 pNextLinkInfo = pLinkInfo->pNextLinkInfo;
2526 pLinkInfo = pNextLinkInfo;
2528 if (pCutLinkString != null)
2530 delete[] pCutLinkString;
2531 pCutLinkString = null;
2535 __pTextObject->Compose();
2537 bool isCursorChanged = __isCursorChanged;
2538 SetCursorPosition(cursorPos);
2539 __isCursorChanged = isCursorChanged;
2545 _EditPresenter::GetLinkElementOffsetInTextBuffer(int elementIndex) const
2547 const int textElementCount = __pTextObject->GetElementCount();
2548 SysTryReturn(NID_UI_CTRL, elementIndex >= 0 && elementIndex <= textElementCount, -1, E_OUT_OF_RANGE, "The Invalid argument is given.");
2550 _Text::TextElement* pTextElement = null;
2551 int elementOffset = -1;
2552 int elementLength = 0;
2556 for (int index = 0; index <= elementIndex; index++)
2558 pTextElement = __pTextObject->GetElementAtElementIndex(index);
2559 if (pTextElement == null)
2564 elementOffset = static_cast<int>(pTextElement->GetValue(SET_TEXT_OFFSET));
2565 elementLength = pTextElement->GetTextLength();
2567 if (pTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)
2569 elementOffset = prevOffset + prevLength;
2572 prevOffset = elementOffset;
2573 prevLength = elementLength;
2574 pTextElement = null;
2577 return elementOffset;
2581 _EditPresenter::IsTextBlockedInTokenEdit(void) const
2587 _EditPresenter::GetCursorPositionAt(const FloatPoint& touchPoint) const
2589 FloatPoint cursorPoint;
2592 FloatRectangle textObjectBounds = __textObjectBounds;
2594 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
2596 if (IsTextBlockedInTokenEdit())
2598 textObjectBounds = GetTextBoundsF();
2602 if (textObjectBounds.Contains(touchPoint))
2604 cursorPoint.x = touchPoint.x - textObjectBounds.x;
2605 cursorPoint.y = touchPoint.y - textObjectBounds.y;
2607 else if (__textBoxBounds.Contains(touchPoint))
2609 if (touchPoint.y <= textObjectBounds.y)
2611 cursorPoint.y = textObjectBounds.y + 1.0f;
2613 else if (touchPoint.y >= (textObjectBounds.y + textObjectBounds.height))
2615 cursorPoint.y = textObjectBounds.y + textObjectBounds.height - 1.0f;
2619 cursorPoint.y = touchPoint.y;
2622 if (touchPoint.x <= textObjectBounds.x)
2624 cursorPoint.x = textObjectBounds.x + 1.0f;
2626 else if (touchPoint.x >= (textObjectBounds.x + textObjectBounds.width))
2628 cursorPoint.x = textObjectBounds.x + textObjectBounds.width - 1.0f;
2632 cursorPoint.x = touchPoint.x;
2634 cursorPoint.y -= textObjectBounds.y;
2635 cursorPoint.x -= textObjectBounds.x;
2642 cursorPos = __pTextObject->GetTextIndexFromPosition(cursorPoint.x, cursorPoint.y);
2647 _EditPresenter::GetCursorPositionAt(const FloatPoint& touchPoint, int& rowIndex, int& columnIndex, bool isMoving)
2649 FloatPoint cursorPoint;
2652 FloatRectangle textObjectBounds = __textObjectBounds;
2654 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
2656 if (IsTextBlockedInTokenEdit())
2658 textObjectBounds = GetTextBoundsF();
2662 if (textObjectBounds.Contains(touchPoint))
2664 cursorPoint.x = touchPoint.x - textObjectBounds.x;
2665 cursorPoint.y = touchPoint.y - textObjectBounds.y;
2667 else if (__textBoxBounds.Contains(touchPoint) && !isMoving)
2669 if (touchPoint.y <= textObjectBounds.y)
2671 cursorPoint.y = textObjectBounds.y + 1.0f;
2673 else if (touchPoint.y >= (textObjectBounds.y + textObjectBounds.height))
2675 cursorPoint.y = textObjectBounds.y + textObjectBounds.height - 1.0f;
2679 cursorPoint.y = touchPoint.y;
2682 if (touchPoint.x <= textObjectBounds.x)
2684 cursorPoint.x = textObjectBounds.x + 1.0f;
2686 else if (touchPoint.x >= (textObjectBounds.x + textObjectBounds.width))
2688 cursorPoint.x = textObjectBounds.x + textObjectBounds.width - 1.0f;
2692 cursorPoint.x = touchPoint.x;
2694 cursorPoint.y -= textObjectBounds.y;
2695 cursorPoint.x -= textObjectBounds.x;
2702 cursorPos = __pTextObject->GetTextIndexFromPosition(cursorPoint.x, cursorPoint.y, rowIndex, columnIndex, true);
2708 _EditPresenter::IsHorizontalDirection(const _TouchInfo& touchInfo)
2710 if (touchInfo.GetTouchStatus() != _TOUCH_MOVED)
2715 if (__isMovingCursorByTouchMove)
2720 FloatRectangle absoluteEditRect = __pEdit->GetAbsoluteBoundsF();
2721 FloatPoint touchStartPoint = __pressedAbsolutePoint;
2722 //After internal touch core complete the float conversion, we need to change the code here
2723 FloatPoint touchPoint = touchInfo.GetCurrentPosition();
2725 float movedWidth = touchStartPoint.x - touchPoint.x - absoluteEditRect.x;
2726 float movedHeight = touchStartPoint.y - touchPoint.y - absoluteEditRect.y;
2727 movedWidth = (movedWidth >= 0.0f) ? movedWidth : -(movedWidth);
2728 movedHeight = (movedHeight >= 0.0f) ? movedHeight : -(movedHeight);
2730 if (movedWidth >= movedHeight * DIRECTION_DECISION_RATIO)
2739 _EditPresenter::IsInitialized(void) const
2741 return __isInitialized;
2745 _EditPresenter::CalculateCursorBounds(const FloatRectangle& textBounds, FloatRectangle& cursorBounds, int cursorPos)
2747 float cursorWidth = 0.0f;
2748 float cursorHeight = 0.0f;
2749 float cursorAbsX = 0.0f;
2750 float cursorAbsY = 0.0f;
2751 float cursorRelativeX = 0.0f;
2752 float cursorRelativeY = 0.0f;
2754 __pTextObject->SetBounds(textBounds);
2756 if (cursorPos == -1)
2758 cursorPos = __pTextObject->GetCursorIndex();
2761 if (cursorPos != __cursorPos)
2763 if (__pTextObject->GetTextPositionInfoAt(cursorPos, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
2770 if (__pTextObject->GetTextPositionInfoAt(__rowCursorIndex, __columnCursorIndex, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
2776 cursorBounds.x = cursorRelativeX;
2777 cursorBounds.y = cursorRelativeY;
2778 float cursorWidthValue = 0.0f;
2779 GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorWidthValue);
2780 cursorBounds.width = cursorWidthValue;
2781 cursorBounds.height = cursorHeight;
2783 if (cursorBounds.y == 0.0f)
2785 cursorBounds.y = __textObjectBounds.y;
2788 if (cursorBounds.height == 0.0f)
2790 cursorBounds.height = __textObjectBounds.height;
2793 if (cursorBounds.height == 0.0f)
2798 if (cursorBounds.y < textBounds.y)
2800 float cursorHeightDiff = textBounds.y - cursorBounds.y;
2801 cursorBounds.y = textBounds.y;
2802 cursorBounds.height -= cursorHeightDiff;
2805 if ((cursorBounds.y + cursorBounds.height > textBounds.y + textBounds.height) &&
2806 (cursorBounds.y < textBounds.y + textBounds.height))
2808 float cursorHeightDiff = cursorBounds.y + cursorBounds.height - textBounds.y - textBounds.height - 1.0f;
2809 if (cursorHeightDiff > 0.0f)
2811 cursorBounds.height -= cursorHeightDiff;
2815 cursorBounds.height += cursorHeightDiff;
2819 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
2821 if (__pTextObject->GetBlock() == false)
2823 cursorBounds.x -= 1.0f;
2826 if (cursorBounds.x > textBounds.x + textBounds.width)
2828 if (cursorBounds.x <= textBounds.x + textBounds.width + cursorBounds.width)
2830 cursorBounds.x = textBounds.x + textBounds.width;
2838 if (cursorBounds.x < textBounds.x)
2840 if (cursorBounds.x > textBounds.x - cursorBounds.width)
2842 cursorBounds.x = textBounds.x;
2852 if (cursorBounds.x == textBounds.x + textBounds.width)
2854 cursorBounds.x -= 1.0f;
2856 else if (cursorBounds.x > textBounds.x + textBounds.width)
2858 cursorBounds.x = textBounds.x + textBounds.width;
2862 if (__pTextObject->GetBlock() == false)
2864 cursorBounds.x -= 1.0f;
2865 if (cursorBounds.x < textBounds.x)
2867 cursorBounds.x = textBounds.x;
2871 __calculatedCursorBounds = cursorBounds;
2876 _EditPresenter::CalculateCursorBounds(const FloatRectangle& textBounds, FloatRectangle& cursorBounds, int rowIndex, int columnIndex)
2878 float cursorWidth = 0.0f;
2879 float cursorHeight = 0.0f;
2880 float cursorAbsX = 0.0f;
2881 float cursorAbsY = 0.0f;
2882 float cursorRelativeX = 0.0f;
2883 float cursorRelativeY = 0.0f;
2885 __pTextObject->SetBounds(textBounds);
2887 if (__pTextObject->GetTextPositionInfoAt(rowIndex, columnIndex, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
2892 cursorBounds.x = cursorRelativeX;
2893 cursorBounds.y = cursorRelativeY;
2894 float cursorWidthValue = 0.0f;
2895 GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorWidthValue);
2896 cursorBounds.width = cursorWidthValue;
2897 cursorBounds.height = cursorHeight;
2899 if (cursorBounds.y == 0.0f)
2901 cursorBounds.y = __textObjectBounds.y;
2904 if (cursorBounds.height == 0.0f)
2906 cursorBounds.height = __textObjectBounds.height;
2909 if (cursorBounds.height == 0.0f)
2914 if (cursorBounds.y < textBounds.y)
2916 float cursorHeightDiff = textBounds.y - cursorBounds.y;
2917 cursorBounds.y = textBounds.y;
2918 cursorBounds.height -= cursorHeightDiff;
2921 if ((cursorBounds.y + cursorBounds.height > textBounds.y + textBounds.height) &&
2922 (cursorBounds.y < textBounds.y + textBounds.height))
2924 float cursorHeightDiff = cursorBounds.y + cursorBounds.height - textBounds.y - textBounds.height - 1.0f;
2925 if (cursorHeightDiff > 0.0f)
2927 cursorBounds.height -= cursorHeightDiff;
2931 cursorBounds.height += cursorHeightDiff;
2935 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
2937 if (__pTextObject->GetBlock() == false)
2939 cursorBounds.x -= 1.0f;
2942 if (cursorBounds.x > textBounds.x + textBounds.width)
2944 if (cursorBounds.x <= textBounds.x + textBounds.width + cursorBounds.width)
2946 cursorBounds.x = textBounds.x + textBounds.width;
2954 if (cursorBounds.x < textBounds.x)
2956 if (cursorBounds.x > textBounds.x - cursorBounds.width)
2958 cursorBounds.x = textBounds.x;
2968 if (cursorBounds.x == textBounds.x + textBounds.width)
2970 cursorBounds.x -= 1.0f;
2972 else if (cursorBounds.x > textBounds.x + textBounds.width)
2974 cursorBounds.x = textBounds.x + textBounds.width;
2978 if (__pTextObject->GetBlock() == false)
2980 cursorBounds.x -= 1.0f;
2981 if (cursorBounds.x < textBounds.x)
2983 cursorBounds.x = textBounds.x;
2987 __calculatedCursorBounds = cursorBounds;
2992 _EditPresenter::ScrollContents(float moveY)
2995 float firstDisplayY = 0.0f;
2996 float effectDistance = moveY;
2998 float totalHeight = __pTextObject->GetTotalHeightF();
2999 float newFirstDisplayY = firstDisplayY = __pTextObject->GetFirstDisplayPositionYF();
3000 int currentCursorLine = 0;
3002 if (__pTextObject->GetTextLength() < 1)
3007 if (__pScrollBar && __pScrollBar->GetScrollPosition() == 0 && effectDistance < 0.0f)
3009 if (__pFlickAnimationTimer)
3014 __pScrollBar->SetScrollVisibility(false);
3018 else if (__pScrollBar && __pScrollBar->GetScrollPosition() != 0 && __pScrollBar->GetScrollPosition() == __previousScrollBarMaxPos && effectDistance > 0.0f)
3020 if (__pFlickAnimationTimer)
3025 __pScrollBar->SetScrollVisibility(false);
3030 if (__pTextObject->GetCursorIndex() == __pTextObject->GetTextLength())
3032 currentCursorLine = __pTextObject->GetTotalLineCount() - 1;
3036 currentCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
3039 if (currentCursorLine == -1)
3044 if (currentCursorLine < 0)
3046 currentCursorLine = 0;
3049 newFirstDisplayY += moveY;
3051 if (newFirstDisplayY > (totalHeight - __textObjectBounds.height))
3053 newFirstDisplayY = totalHeight - __textObjectBounds.height;
3056 if (newFirstDisplayY < 0.0f)
3058 newFirstDisplayY = 0.0f;
3061 moveLine = __pTextObject->GetLineIndexAtPositionY(newFirstDisplayY);
3063 __pTextObject->SetFirstDisplayLineIndex(moveLine);
3064 __pTextObject->SetFirstDisplayPositionY(newFirstDisplayY);
3066 __isCursorOpaque = false;
3067 if (__isCopyPasteManagerExist)
3069 __pCopyPasteManager->AdjustBounds();
3076 _EditPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
3078 if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
3083 if (__isCopyPasteManagerExist)
3085 __pCopyPasteManager->ReleaseCopyPastePopup();
3088 __isTouchPressed = true;
3089 __isTouchReleaseSkipped = false;
3091 __pScrollEffect->previousY = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().y);
3092 __pScrollEffect->currentY = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().y);
3093 __pScrollEffect->previousX = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().x);
3094 __pScrollEffect->currentX = _CoordinateSystemUtils::ConvertToFloat(touchInfo.GetCurrentPosition().x);
3095 __pScrollEffect->cursorPosition = GetCursorPosition();
3097 FloatRectangle absoluteEditRect = __pEdit->GetAbsoluteBoundsF();
3099 __pressedPoint = touchInfo.GetCurrentPosition();
3100 __pressedAbsolutePoint.x = __pressedPoint.x + absoluteEditRect.x;
3101 __pressedAbsolutePoint.y = __pressedPoint.y + absoluteEditRect.y;
3103 if (IsViewModeEnabled())
3105 int cutLinkIndex = -1;
3107 __pTextObject->ResetAllCutLinkElementsState();
3109 cutLinkIndex = __pTextObject->GetCutLinkIndexFromPositionData(__pressedPoint.x - __textObjectBounds.x, __pressedPoint.y - __textObjectBounds.y);
3111 if (cutLinkIndex != -1)
3113 __pTextObject->ChangeCutLinkState(cutLinkIndex, true);
3117 if (__pEdit->GetEditStyle() & EDIT_STYLE_CLEAR && __pTextString->GetLength() > 0)
3119 if ((__pressedPoint.x >= __clearIconBounds.x) && (__pressedPoint.x <= __clearIconBounds.x + __clearIconBounds.width)
3120 && (__pressedPoint.y >= __clearIconBounds.y) && (__pressedPoint.y <= __clearIconBounds.y + __clearIconBounds.height)) // Clear Icon Pressed
3122 __isClearIconPressed = true;
3123 __pEdit->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_IN_CLEAR_AREA);
3128 __pEdit->Invalidate();
3134 _EditPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
3136 if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
3141 if (__isClearIconPressed)
3143 __isClearIconPressed = false;
3144 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
3147 __isTouchPressed = false;
3148 __isMovingCursorByTouchMove = false;
3150 if (__isTouchReleaseSkipped || __isTouchMoving)
3152 __isTouchReleaseSkipped = false;
3154 __isTouchMoving = false;
3157 if (__isScrollBarVisible && __pScrollBar)
3159 if (__pScrollBar->IsVisible())
3161 __pScrollBar->SetScrollVisibility(false);
3163 __isScrollBarVisible = false;
3166 __isTouchMoving = false;
3167 __pEdit->Invalidate();
3173 _EditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
3175 if (__isCopyPasteManagerExist)
3177 if (__isTouchPressed && !__isCopyPastePopupMoving)
3179 InitializeCopyPasteManager();
3180 if (__isClearIconPressed)
3182 FloatPoint touchPoint = touchInfo.GetCurrentPosition();
3183 __isClearIconPressed = false;
3184 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
3185 if ((touchPoint.x >= __clearIconBounds.x) && (touchPoint.x <= __clearIconBounds.x + __clearIconBounds.width)
3186 && (touchPoint.y >= __clearIconBounds.y) && (touchPoint.y <= __clearIconBounds.y + __clearIconBounds.height))
3189 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
3190 __isMovingCursorByTouchMove = false;
3191 __pEdit->Invalidate();
3197 if (!IsCurrentFocused())
3199 __pEdit->SetFocused();
3201 __pCopyPasteManager->CreateCopyPastePopup();
3202 __pCopyPasteManager->Show();
3204 __isTouchPressed = false;
3205 __isCopyPastePopupMoving = false;
3210 if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
3215 int cutLinkIndex = -1;
3216 FloatRectangle clientBounds;
3217 FloatPoint touchPoint = touchInfo.GetCurrentPosition();
3219 if (__isClearIconPressed)
3221 __isClearIconPressed = false;
3222 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
3224 if ((touchPoint.x >= __clearIconBounds.x) && (touchPoint.x <= __clearIconBounds.x + __clearIconBounds.width)
3225 && (touchPoint.y >= __clearIconBounds.y) && (touchPoint.y <= __clearIconBounds.y + __clearIconBounds.height))
3228 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
3229 __isTouchPressed = false;
3230 __isMovingCursorByTouchMove = false;
3231 __pEdit->Invalidate();
3237 if (!__isCopyPasteManagerExist)
3239 __isTextBlocked = false;
3241 __isTouchPressed = false;
3242 __isMovingCursorByTouchMove = false;
3244 if (__isTouchReleaseSkipped)
3246 __isTouchReleaseSkipped = false;
3248 __isTouchMoving = false;
3249 __pEdit->Invalidate();
3254 if (__isTouchMoving && __isInputConnectionBound == false)
3257 __isTouchMoving = false;
3258 __isTouchReleaseSkipped = false;
3259 __pEdit->Invalidate();
3264 if (IsViewModeEnabled())
3266 __pEdit->SetFocused();
3268 __pTextObject->ResetAllCutLinkElementsState();
3270 cutLinkIndex = __pTextObject->GetCutLinkIndexFromPositionData(touchPoint.x - __textObjectBounds.x, touchPoint.y - __textObjectBounds.y);
3272 if (cutLinkIndex != -1)
3274 TextCutLink* pCutLinkObject = dynamic_cast<TextCutLink*>(__pTextObject->GetCutLinkElementAtCutLinkElementIndex(cutLinkIndex));
3275 if (pCutLinkObject == null)
3280 String cutLinkString(pCutLinkObject->GetText());
3281 LinkType baseLinkType = pCutLinkObject->GetCutLinkType();
3283 // Send Ui Link Event
3284 __pEdit->SendLinkEvent(cutLinkString, baseLinkType, cutLinkString);
3288 clientBounds = __pEdit->GetBoundsF();
3289 clientBounds.x = 0.0f;
3290 clientBounds.y = 0.0f;
3291 touchPoint = touchInfo.GetCurrentPosition();
3292 if (clientBounds.Contains(touchPoint))
3296 int cursorPos = GetCursorPositionAt(touchPoint, rowIndex,columnIndex);
3297 if (cursorPos != -1)
3299 if (__isInputConnectionBound == true && __isTextComposing == true)
3301 __pInputConnection->FinishTextComposition();
3303 if (!__isCopyPasteManagerExist) // Copy&Paste
3305 if ((__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) == true && IsCurrentFocused() == false)
3307 __isCursorChanged = true;
3311 SetCursorPosition(cursorPos, rowIndex, columnIndex);
3316 if (!__isCopyPasteManagerExist && !__pFlickAnimationTimer)
3318 bool tokenEditting = false;
3319 bool needToCreatePopup = true;
3320 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
3322 _TokenEditPresenter* pTokenEditPresenter = dynamic_cast < _TokenEditPresenter* >(this);
3323 if (pTokenEditPresenter)
3325 if (pTokenEditPresenter->GetSelectedTokenIndex() != -1)
3327 tokenEditting = true;
3332 if (!__isUSBKeyboardConnected && !__isKeypadExist && !IsViewModeEnabled())
3334 needToCreatePopup = false;
3337 if (IsViewModeEnabled() && GetTextLength() == 0)
3339 needToCreatePopup = false;
3341 _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance();
3342 SysTryReturn(NID_UI_CTRL, pAccessibilityManager, false, E_SYSTEM, "pAccessibilityManager is null");
3343 if (pAccessibilityManager->IsActivated())
3345 needToCreatePopup = false;
3348 if (IsCurrentFocused() && !tokenEditting && needToCreatePopup)
3350 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
3351 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, false, E_SYSTEM, "Unable to create _EditCopyPasteManager instance.");
3352 __pCopyPasteManager->AddCopyPasteEventListener(*this);
3353 __pCopyPasteManager->Show();
3354 __isCopyPasteManagerExist = true;
3358 if (cutLinkIndex < 0)
3360 CheckUSBKeyboardStatus();
3362 if (__isUSBKeyboardConnected)
3364 if (!__isInputConnectionBound)
3366 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
3368 if (IsViewModeEnabled() == false)
3370 if (IsCurrentFocused())
3376 __pEdit->SetFocused();
3382 if (__pEditModel->IsViewModeEnabled() == false) //in case of fullscreen style, should check editModel's viewMode
3384 ShowFullscreenKeypad();
3391 if (!__isKeypadExist || !__isInputConnectionBound)
3393 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
3395 if (IsViewModeEnabled() == false)
3397 if (IsCurrentFocused())
3403 __pEdit->SetFocused();
3409 if (__pEditModel->IsViewModeEnabled() == false) //in case of fullscreen style, should check editModel's viewMode
3411 ShowFullscreenKeypad();
3419 if (__isScrollBarVisible && __pScrollBar)
3421 if (__pScrollBar->IsVisible())
3423 __pScrollBar->SetScrollVisibility(false);
3425 __isScrollBarVisible = false;
3428 __isTouchMoving = false;
3429 __pEdit->Invalidate();
3435 _EditPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
3437 if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
3442 FloatPoint touchPoint = touchInfo.GetCurrentPosition();
3444 if (__isClearIconPressed)
3446 if ((touchPoint.x < __clearIconBounds.x) || (touchPoint.x > __clearIconBounds.x + __clearIconBounds.width)
3447 || (touchPoint.y < __clearIconBounds.y) || (touchPoint.y > __clearIconBounds.y + __clearIconBounds.height))
3449 __isClearIconPressed = false;
3450 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
3451 __pEdit->Invalidate();
3455 if (__isCopyPasteManagerExist)
3457 __pCopyPasteManager->Show();
3458 if (!__isClearIconPressed)
3460 __isCopyPastePopupMoving = true;
3464 if (__isTouchMoving == false && IsHorizontalDirection(touchInfo))
3466 if (__isCopyPasteManagerExist && IsBlocked())
3471 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
3473 float horizontalGap = touchInfo.GetCurrentPosition().x - __pScrollEffect->currentX;
3474 FloatRectangle lineBounds = __pTextObject->GetBoundsAtLineF(0);
3475 float textDisplayPositionX = __pTextObject->GetFirstDisplayPositionXF();
3476 float newTextDisplayPositionX = 0;
3478 if (horizontalGap < 0.0f && lineBounds.width - textDisplayPositionX > __textObjectBounds.width)
3480 newTextDisplayPositionX = textDisplayPositionX - horizontalGap;
3482 if (newTextDisplayPositionX > lineBounds.width - __textObjectBounds.width)
3484 newTextDisplayPositionX = lineBounds.width - __textObjectBounds.width;
3487 __pScrollEffect->previousX = __pScrollEffect->currentX;
3488 __pScrollEffect->currentX = touchInfo.GetCurrentPosition().x;
3489 __isMovingCursorByTouchMove = true;
3490 __isTouchReleaseSkipped = true;
3493 __pTextObject->SetFirstDisplayPositionX(newTextDisplayPositionX);
3494 __pEdit->Invalidate();
3497 if (horizontalGap > 0.0f && textDisplayPositionX > 0)
3499 newTextDisplayPositionX = textDisplayPositionX - horizontalGap;
3500 if (newTextDisplayPositionX < 0)
3502 newTextDisplayPositionX = 0;
3505 __pScrollEffect->previousX = __pScrollEffect->currentX;
3506 __pScrollEffect->currentX = touchInfo.GetCurrentPosition().x;
3507 __isMovingCursorByTouchMove = true;
3508 __isTouchReleaseSkipped = true;
3511 __pTextObject->SetFirstDisplayPositionX(newTextDisplayPositionX);
3512 __pEdit->Invalidate();
3519 FloatRectangle fromBounds;
3520 FloatRectangle toBounds;
3521 CalculateCursorBounds(__textObjectBounds, fromBounds);
3522 newIndex = GetCursorPositionAt(touchInfo.GetCurrentPosition());
3525 if (Math::Abs(newIndex - __cursorPos) > 3)
3530 CalculateCursorBounds(__textObjectBounds, toBounds, newIndex);
3531 __isCursorChanged = true;
3532 SetCursorPosition(newIndex);
3534 __isMovingCursorByTouchMove = true;
3535 __isTouchReleaseSkipped = true;
3538 MoveCursor(fromBounds, toBounds);
3539 __pEdit->Invalidate();
3544 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
3546 float horizontalGap = touchInfo.GetCurrentPosition().x - fromBounds.x;
3547 FloatDimension currentCharacterDimension;
3548 if (horizontalGap > 0.0f && __cursorPos < GetTextLength())
3550 currentCharacterDimension = __pTextObject->GetTextExtentF(__cursorPos, 1);
3551 if (horizontalGap >= currentCharacterDimension.width)
3553 SetCursorPosition(__cursorPos+1);
3554 __pEdit->Invalidate();
3558 if (horizontalGap < 0.0f && __cursorPos > 0)
3560 currentCharacterDimension = __pTextObject->GetTextExtentF(__cursorPos-1, 1);
3561 if (Math::Abs(horizontalGap) >= currentCharacterDimension.width)
3563 SetCursorPosition(__cursorPos-1);
3564 __pEdit->Invalidate();
3570 if (__isMovingCursorByTouchMove)
3576 float totalHeight = __pTextObject->GetTotalHeightF();
3580 if (__textObjectBounds.height >= totalHeight)
3582 __isTouchMoving = true;
3583 __isTouchReleaseSkipped = true;
3588 if ((touchInfo.GetCurrentPosition().y == __pScrollEffect->currentY) ||
3589 (Math::Abs(touchInfo.GetCurrentPosition().y - __pScrollEffect->previousY) < MOVE_SKIP_DECISION_RANGE))
3594 __pScrollEffect->previousY = __pScrollEffect->currentY;
3595 __pScrollEffect->currentY = touchInfo.GetCurrentPosition().y;
3597 float moveGap = __pScrollEffect->previousY - __pScrollEffect->currentY;
3599 if (__isMovingCursorByTouchMove)
3601 __isMovingCursorByTouchMove = false;
3604 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_NOSCROLL))
3608 if (totalHeight > __textObjectBounds.height)
3610 __pScrollBar->SetScrollVisibility(true);
3614 __pScrollBar->SetScrollVisibility(false);
3619 result returnResult = ScrollContents(moveGap);
3621 __isCursorChanged = false;
3622 __isTouchMoving = true;
3626 if (returnResult == E_SUCCESS)
3632 __isTouchReleaseSkipped = true;
3638 _EditPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
3640 result r = E_SUCCESS;
3641 _KeyCode keyCode = keyInfo.GetKeyCode();
3645 FloatRectangle panelAbsBounds(0.0f, 0.0f, 0.0f, 0.0f);
3646 FloatRectangle absCursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
3648 _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance();
3649 SysTryReturn(NID_UI_CTRL, pAccessibilityManager, false, E_SYSTEM, "pAccessibilityManager is null");
3651 if (__pEditModel->IsViewModeEnabled() == false)
3653 if (__pEdit->GetInputStyle() == INPUT_STYLE_FULLSCREEN)
3655 if (_KEY_ENTER == keyCode)
3657 CheckUSBKeyboardStatus();
3658 if (__isUSBKeyboardConnected)
3660 ShowFullscreenKeypad();
3672 if (__isUSBKeyboardConnected && (keyInfo.GetKeyModifier() & _KEY_MODIFIER_CTRL) && (keyInfo.GetKeyModifier() & _KEY_MODIFIER_SHIFT))
3674 if ((keyCode == _KEY_LEFT) || (keyCode == _KEY_RIGHT))
3676 if (!__isCopyPasteManagerExist)
3678 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
3680 _TokenEditPresenter* pTokenEditPresenter = dynamic_cast < _TokenEditPresenter* >(this);
3681 if (pTokenEditPresenter)
3683 if (pTokenEditPresenter->GetSelectedTokenIndex() != -1)
3689 SetBlockRangeWithCtrlShiftArrowkey(keyCode);
3694 if (__pCopyPasteManager->IsCopyPasteSingleHandleExist())
3696 InitializeCopyPasteManager();
3697 SetBlockRangeWithShiftArrowkey(keyCode);
3703 else if (__isUSBKeyboardConnected && (keyInfo.GetKeyModifier() & _KEY_MODIFIER_CTRL))
3708 FinishTextComposition();
3710 if (__isCopyPasteManagerExist)
3712 InitializeCopyPasteManager();
3715 textLength = __pEdit->GetTextLength();
3720 __pEdit->SetBlockRange(0, textLength);
3721 r = __pEdit->SendTextBlockEvent(0, textLength);
3722 UpdateComponentInformation();
3723 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r));
3725 if (!pAccessibilityManager->IsActivated())
3727 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
3728 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, true, E_OUT_OF_MEMORY, "Unable to create _EditCopyPasteManager instance.");
3729 __pCopyPasteManager->AddCopyPasteEventListener(*this);
3730 __pCopyPasteManager->CreateCopyPastePopup();
3731 __pCopyPasteManager->Show();
3732 __isCopyPasteManagerExist = true;
3737 textLength = __pEdit->GetTextLength();
3743 if (__isCopyPasteManagerExist)
3745 InitializeCopyPasteManager();
3749 textLength = __pEdit->GetTextLength();
3755 if (__isCopyPasteManagerExist)
3757 InitializeCopyPasteManager();
3762 if (__isCopyPasteManagerExist)
3764 InitializeCopyPasteManager();
3767 case _KEY_HOME_BUTTON:
3768 if (__isCopyPasteManagerExist)
3770 InitializeCopyPasteManager();
3772 if (__cursorPos != 0)
3774 SetCursorPosition(0);
3781 case _KEY_END_BUTTON:
3782 if (__isCopyPasteManagerExist)
3784 InitializeCopyPasteManager();
3786 if (__cursorPos != GetTextLength())
3788 SetCursorPosition(GetTextLength());
3796 if (__isCopyPasteManagerExist)
3798 InitializeCopyPasteManager();
3800 if (__cursorPos == 0)
3804 GetWordPosition(__cursorPos, start, end);
3805 if (__cursorPos != start)
3807 SetCursorPosition(start);
3811 GetWordPosition(start-1, start, end);
3812 SetCursorPosition(start);
3816 if (__isCopyPasteManagerExist)
3818 InitializeCopyPasteManager();
3820 if (__cursorPos == GetTextLength())
3824 GetWordPosition(__cursorPos, start, end);
3825 if (__cursorPos != end)
3827 SetCursorPosition(end);
3831 GetWordPosition(end+1, start, end);
3832 SetCursorPosition(end);
3838 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
3844 __pEdit->Invalidate();
3849 else if (__isUSBKeyboardConnected && keyInfo.GetKeyModifier() & _KEY_MODIFIER_SHIFT)
3851 if (!__isCopyPasteManagerExist)
3853 if ( (keyCode == _KEY_LEFT) || (keyCode == _KEY_UP) || (keyCode == _KEY_DOWN) || (keyCode == _KEY_RIGHT) )
3855 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
3857 _TokenEditPresenter* pTokenEditPresenter = dynamic_cast < _TokenEditPresenter* >(this);
3858 if (pTokenEditPresenter)
3860 if (pTokenEditPresenter->GetSelectedTokenIndex() != -1)
3866 SetBlockRangeWithShiftArrowkey(keyCode);
3876 if (__pCopyPasteManager->IsCopyPasteSingleHandleExist())
3878 InitializeCopyPasteManager();
3879 SetBlockRangeWithShiftArrowkey(keyCode);
3887 __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_LEFT);
3890 __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_UP);
3893 __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_DOWN);
3896 __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_RIGHT);
3903 else if (_KEY_END_BUTTON == keyCode || _KEY_HOME_BUTTON == keyCode)
3905 if (__isCopyPasteManagerExist)
3907 InitializeCopyPasteManager();
3910 FinishTextComposition();
3912 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
3913 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine);
3915 if (_KEY_HOME_BUTTON == keyCode)
3917 if(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
3919 if (__cursorPos != 0)
3921 SetCursorPosition(0);
3930 SetCursorPosition(firstTextIndex);
3933 else if (_KEY_END_BUTTON == keyCode)
3935 if(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
3937 if (__cursorPos != GetTextLength())
3939 SetCursorPosition(GetTextLength());
3948 int totalLine = __pTextObject->GetTotalLineCount();
3949 if (curCursorLine < totalLine - 1)
3951 int nextLinefirstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
3952 SetCursorPosition(nextLinefirstTextIndex-1);
3956 if (__cursorPos != GetTextLength())
3958 SetCursorPosition(GetTextLength());
3969 else if (_KEY_ENTER == keyCode || _KEY_NUMPAD_ENTER == keyCode)
3971 if (__isInputConnectionBound != false && __isTextComposing != false)
3977 if (IsKeypadActionEnabled())
3979 char enterText[2] = {'\n', };
3980 OnTextCommitted(String(enterText));
3986 else if (_KEY_BACKSPACE == keyCode)
3988 if (__isTextComposing == false)
3990 if (__isCopyPasteManagerExist)
3994 __pCopyPasteManager->SetTextBlockReleaseFlag(false);
3996 InitializeCopyPasteManager();
3999 OnSurroundingTextDeleted(-1, 1);
4000 if (AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT) == true)
4002 __pTextObject->Compose();
4003 __pEdit->Invalidate();
4005 ScrollPanelToCursorPosition();
4009 else if ((keyInfo.GetKeyModifier() & _KEY_LOCK_NUM) && (_KEY_NUMPAD_4 == keyCode || _KEY_NUMPAD_6 == keyCode || _KEY_NUMPAD_8 == keyCode || _KEY_NUMPAD_2 == keyCode))
4013 else if (_KEY_LEFT == keyCode || _KEY_NUMPAD_4 == keyCode)
4015 if (__isCopyPasteManagerExist)
4017 InitializeCopyPasteManager();
4020 FinishTextComposition();
4022 if (__cursorPos != 0)
4024 int startPosition = -1;
4025 int endPosition = -1;
4026 GetTextImageRangeAt(__cursorPos-1, startPosition, endPosition);
4027 if (endPosition > -1 && startPosition >= 0 && startPosition < __cursorPos-1)
4029 SetCursorPosition(startPosition);
4033 SetCursorPosition(__cursorPos-1);
4038 panelAbsBounds = __pParentPanel->GetAbsoluteBoundsF();
4039 GetCursorBounds(true, absCursorBounds);
4041 if (!panelAbsBounds.Contains(FloatPoint(absCursorBounds.x, absCursorBounds.y + absCursorBounds.height)))
4043 ScrollPanelToCursorPosition();
4047 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4053 __pEdit->Invalidate();
4062 else if (_KEY_UP == keyCode || _KEY_NUMPAD_8 == keyCode)
4064 if (__isCopyPasteManagerExist)
4066 InitializeCopyPasteManager();
4069 FinishTextComposition();
4071 if (GetTextLength() == 0)
4076 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
4077 if (curCursorLine !=0 )
4079 int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
4080 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine-1);
4081 int newCursorPosition = offset + firstTextIndex;
4082 int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
4083 if (offset<textLength)
4085 int startPosition = -1;
4086 int endPosition = -1;
4087 GetTextImageRangeAt(newCursorPosition, startPosition, endPosition);
4088 if (endPosition > newCursorPosition && startPosition < newCursorPosition)
4090 newCursorPosition = endPosition;
4092 SetCursorPosition(newCursorPosition);
4097 __pTextString->GetCharAt(firstTextIndex+textLength - 1, ch);
4100 SetCursorPosition(firstTextIndex+textLength - 1);
4104 SetCursorPosition(firstTextIndex+textLength);
4110 panelAbsBounds = __pParentPanel->GetAbsoluteBoundsF();
4111 GetCursorBounds(true, absCursorBounds);
4112 if (!panelAbsBounds.Contains(FloatPoint(absCursorBounds.x, absCursorBounds.y)))
4114 ScrollPanelToCursorPosition();
4117 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4128 else if (_KEY_DOWN == keyCode || _KEY_NUMPAD_2 == keyCode)
4130 if (__isCopyPasteManagerExist)
4132 InitializeCopyPasteManager();
4135 FinishTextComposition();
4137 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
4138 int totalLine = __pTextObject->GetTotalLineCount();
4139 if (curCursorLine < totalLine - 1)
4141 int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
4142 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
4143 int newCursorPosition = offset + firstTextIndex;
4144 int textLength = __pTextObject->GetTextLengthAt(curCursorLine+1);
4146 if (offset<textLength)
4148 int startPosition = -1;
4149 int endPosition = -1;
4150 GetTextImageRangeAt(newCursorPosition, startPosition, endPosition);
4151 if (endPosition > newCursorPosition && startPosition < newCursorPosition)
4153 newCursorPosition = endPosition;
4155 SetCursorPosition(newCursorPosition);
4160 __pTextString->GetCharAt(firstTextIndex+textLength - 1, ch);
4163 if (textLength == 0)
4165 SetCursorPosition(firstTextIndex);
4169 SetCursorPosition(firstTextIndex+textLength - 1);
4174 SetCursorPosition(firstTextIndex+textLength);
4180 panelAbsBounds = __pParentPanel->GetAbsoluteBoundsF();
4181 GetCursorBounds(true, absCursorBounds);
4183 if (!panelAbsBounds.Contains(FloatPoint(absCursorBounds.x, absCursorBounds.y + absCursorBounds.height)))
4185 ScrollPanelToCursorPosition();
4188 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4199 else if (_KEY_RIGHT == keyCode || _KEY_NUMPAD_6 == keyCode)
4201 if (__isCopyPasteManagerExist)
4203 InitializeCopyPasteManager();
4206 FinishTextComposition();
4208 if (__cursorPos == GetTextLength())
4213 if (__cursorPos < GetTextLength())
4215 int startPosition = -1;
4216 int endPosition = -1;
4217 GetTextImageRangeAt(__cursorPos, startPosition, endPosition);
4218 if (endPosition > __cursorPos+1 && startPosition > -1)
4220 SetCursorPosition(endPosition);
4224 SetCursorPosition(__cursorPos+1);
4229 panelAbsBounds = __pParentPanel->GetAbsoluteBoundsF();
4230 GetCursorBounds(true, absCursorBounds);
4232 if (!panelAbsBounds.Contains(FloatPoint(absCursorBounds.x, absCursorBounds.y + absCursorBounds.height)))
4234 ScrollPanelToCursorPosition();
4238 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4244 __pEdit->Invalidate();
4249 else if (_KEY_DELETE == keyCode)
4251 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4253 if (!GetTextLength())
4259 if (__isCopyPasteManagerExist)
4261 if (IsBlocked() == true)
4265 GetBlockRange(start, end);
4266 DeleteText(start, end);
4271 int cursorPosition = GetCursorPosition();
4272 DeleteText(cursorPosition, cursorPosition+1);
4275 InitializeCopyPasteManager();
4279 FinishTextComposition();
4281 int cursorPosition = GetCursorPosition();
4282 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4284 DeleteText(cursorPosition, cursorPosition+1);
4288 OnSurroundingTextDeleted(0, 1);
4291 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
4297 __pEdit->Invalidate();
4299 ScrollPanelToCursorPosition();
4303 else if (_KEY_OEM_1 == keyCode)
4305 __pClipboard->ShowPopup(CLIPBOARD_DATA_TYPE_TEXT, *__pEdit);
4306 __clipboardConnected = true;
4309 else if (__composingTextLength > 0 && GetTextLength() >= __limitLength)
4318 _EditPresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
4320 _KeyCode keyCode = keyInfo.GetKeyCode();
4322 if (__isUSBKeyboardConnected && (keyCode == _KEY_SHIFT_L || keyCode == _KEY_SHIFT_R))
4324 if (__pCopyPasteManager && __pCopyPasteManager->IsHandlerMovingEnabled())
4326 __pCopyPasteManager->SetHandlerMovingEnabled(false);
4327 __pCopyPasteManager->CreateCopyPastePopup();
4328 __pCopyPasteManager->Show();
4330 else if (__textBlockMoving)
4332 _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance();
4333 SysTryReturn(NID_UI_CTRL, pAccessibilityManager, false, E_SYSTEM, "pAccessibilityManager is null");
4334 if (!pAccessibilityManager->IsActivated())
4336 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
4337 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, true, E_OUT_OF_MEMORY, "Unable to create _EditCopyPasteManager instance.");
4338 __pCopyPasteManager->AddCopyPasteEventListener(*this);
4339 __pCopyPasteManager->CreateCopyPastePopup();
4340 __pCopyPasteManager->Show();
4341 __isCopyPasteManagerExist = true;
4343 __textBlockMoving = false;
4352 _EditPresenter::OnClipboardPopupClosed(const ClipboardItem* pClipboardItem)
4358 String filteredString;
4360 if (!pClipboardItem && IsBlocked())
4365 if (__isCopyPasteManagerExist)
4369 __pCopyPasteManager->SetTextBlockReleaseFlag(false);
4371 InitializeCopyPasteManager();
4374 SysTryReturnVoidResult(NID_UI_CTRL, pClipboardItem != null, E_SYSTEM, "[E_SYSTEM] _EditPresenter::OnClipboardPopupClosed: Unable to get the clipboarditem instance.");
4376 String* pClipString = dynamic_cast<String*>(pClipboardItem->GetData());
4377 SysTryReturnVoidResult(NID_UI_CTRL, pClipString != null, E_SYSTEM, "[E_SYSTEM] _EditPresenter::OnClipboardPopupClosed: Unable to get the clipboarditem instance.");
4380 if (pClipboardItem->GetDataType() == CLIPBOARD_DATA_TYPE_HTML)
4382 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
4385 str = pEcoreEvas->ConvertMarkupToUtf8(*pClipString);
4390 int currentLength = GetTextLength();
4391 String* pSubString = null;
4392 result r = E_SUCCESS;
4394 filteredString = *pClipString;
4398 if(__pTextFilter->ValidatePastedText(*pClipString, userString))
4400 filteredString = userString;
4401 SysLog(NID_UI_CTRL, "ClipString was changed by User");
4404 else if (IsUnsupportedChracterExist(GetKeypadStyle(), *pClipString) == true)
4411 GetBlockRange(start, end);
4412 total = currentLength - (end - start) + filteredString.GetLength();
4413 if (total > __limitLength)
4415 DeleteText(start, end);
4417 pSubString = new String(__limitLength - currentLength + (end - start));
4418 SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "Unable to allocate text buffer.");
4420 filteredString.SubString(0, __limitLength - currentLength + (end - start), *pSubString);
4421 r = InsertTextAt(__cursorPos, pSubString->GetPointer());
4422 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4427 DeleteText(start, end);
4429 r = InsertTextAt(__cursorPos, filteredString.GetPointer());
4430 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4433 else if (currentLength + filteredString.GetLength() > __limitLength)
4435 if (__limitLength == currentLength)
4437 delete pClipboardItem;
4441 pSubString = new String(__limitLength - currentLength);
4442 SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "Unable to allocate text buffer.");
4444 filteredString.SubString(0, __limitLength - currentLength, *pSubString);
4445 r = InsertTextAt(__cursorPos, pSubString->GetPointer());
4446 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4451 r = InsertTextAt(__cursorPos, filteredString.GetPointer());
4452 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4455 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
4457 __pEdit->Invalidate();
4459 delete pClipboardItem;
4464 delete pClipboardItem;
4470 _EditPresenter::OnLongPressGestureDetected(void)
4472 SysLog(NID_UI_CTRL, "OnLongPressGestureDetected");
4474 if (__isClearIconPressed)
4479 __isTouchPressed = false;
4481 _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance();
4482 SysTryReturn(NID_UI_CTRL, pAccessibilityManager, false, E_SYSTEM, "pAccessibilityManager is null");
4483 if (pAccessibilityManager->IsActivated())
4485 SysLog(NID_UI_CTRL, "Copy&Paste is not created (ScreenReader is activated)");
4489 if (__isCopyPasteManagerExist)
4493 else if (IsCurrentFocused() == false && !IsViewModeEnabled())
4498 FloatRectangle cursorBounds;
4499 InitializeCopyPasteManager();
4500 if (IsClipped() || GetTextLength())
4502 if (IsClipped() && !GetTextLength() && (__pEdit->IsViewModeEnabled()))
4507 if (!IsClipped() && (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD))
4512 FinishTextComposition();
4514 int cursorPos = GetCursorPositionAt(__pressedPoint);
4515 if (cursorPos != -1)
4517 SetCursorPosition(cursorPos);
4521 cursorPos = GetTextLength();
4522 SetCursorPosition(cursorPos);
4524 ScrollPanelToCursorPosition();
4525 GetCursorBounds(true, cursorBounds);
4527 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
4528 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, false, E_SYSTEM, "Unable to create _EditCopyPasteManager instance.");
4529 __pCopyPasteManager->AddCopyPasteEventListener(*this);
4530 __pCopyPasteManager->Show();
4531 __isCopyPasteManagerExist = true;
4539 _EditPresenter::OnTapGestureDetected(void)
4541 SysLog(NID_UI_CTRL, "OnTapGestureDetected");
4543 _AccessibilityManager* pAccessibilityManager = _AccessibilityManager::GetInstance();
4544 SysTryReturn(NID_UI_CTRL, pAccessibilityManager, false, E_SYSTEM, "pAccessibilityManager is null");
4545 if (pAccessibilityManager->IsActivated())
4547 SysLog(NID_UI_CTRL, "Copy&Paste is not created (ScreenReader is activated)");
4551 if (IsCurrentFocused() == false)
4556 if (!__isUSBKeyboardConnected)
4558 if (__isKeypadShowing)
4562 __isTouchPressed = false;
4563 InitializeCopyPasteManager();
4565 if (GetTextLength() > 0)
4567 FloatRectangle cursorBounds;
4570 int cursorPos = GetCursorPositionAt(__pressedPoint);
4572 if (cursorPos == -1)
4574 cursorPos = GetTextLength();
4578 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(cursorPos);
4579 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine);
4580 if (cursorPos != 0 && cursorPos == firstTextIndex && __rowCursorIndex != curCursorLine)
4586 FinishTextComposition();
4588 GetWordPosition(cursorPos, start, end);
4589 SetBlockRange(start, end);
4590 ScrollPanelToCursorPosition();
4591 GetCursorBounds(true, cursorBounds);
4593 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
4594 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, false, E_SYSTEM, "Unable to create _EditCopyPasteManager instance.");
4595 __pCopyPasteManager->AddCopyPasteEventListener(*this);
4596 __pCopyPasteManager->Show();
4597 __isCopyPasteManagerExist = true;
4606 _EditPresenter::GetTextAlignment(void) const
4608 return __horizontalAlignment;
4612 _EditPresenter::GetLineSpacing(void) const
4614 int linePixelGap = -1;
4616 linePixelGap = __pTextObject->GetLineSpace();
4618 return linePixelGap;
4622 _EditPresenter::GetLineSpacingF(void) const
4624 float linePixelGap = -1.0;
4626 linePixelGap = __pTextObject->GetLineSpaceF();
4628 return linePixelGap;
4632 _EditPresenter::GetBlockRange(int& start, int& end) const
4634 if (__isTextBlocked == false || __cursorPos == __blockStartPos)
4639 if (__cursorPos > __blockStartPos)
4641 start = __blockStartPos;
4646 start = __cursorPos;
4647 end = __blockStartPos;
4654 _EditPresenter::SetBlockRange(int start, int end)
4656 result r = E_SUCCESS;
4658 r = SetCursorPosition(start);
4659 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4661 r = BeginTextBlock();
4662 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4664 r = SetCursorPosition(end);
4665 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4671 _EditPresenter::SetBlockRange(int start, int end, int leftRowIndex, int leftColumnIndex, int rightRowIndex, int rightColumnIndex)
4673 result r = E_SUCCESS;
4675 if (leftRowIndex == -1 && leftColumnIndex == -1)
4677 r = SetCursorPosition(start);
4681 r = SetCursorPosition(start, leftRowIndex, leftColumnIndex);
4683 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4685 r = BeginTextBlock();
4686 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4688 if (rightRowIndex == -1 && rightColumnIndex == -1)
4690 r = SetCursorPosition(end);
4694 r = SetCursorPosition(end, rightRowIndex, rightColumnIndex);
4696 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4702 _EditPresenter::BeginTextBlock(void)
4704 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
4707 __isTextBlocked = true;
4708 __blockStartPos = __cursorPos;
4714 _EditPresenter::ReleaseTextBlock(void)
4716 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
4720 if (__isTextBlocked == false)
4725 __isTextBlocked = false;
4731 _EditPresenter::IsBlocked(void) const
4733 return __isTextBlocked;
4737 _EditPresenter::CopyText(void)
4739 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
4742 result r = E_SUCCESS;
4744 _Clipboard* pClipBoard = _Clipboard::GetInstance();
4745 SysTryReturnResult(NID_UI_CTRL, pClipBoard != null, E_SYSTEM, "Unable to get the clipboard instance.");
4749 GetBlockRange(start, end);
4751 String blockString(GetText(start, end - 1));
4753 _ClipboardItem* pClipboardItem = _ClipboardItem::CreateInstanceN(CLIPBOARD_DATA_TYPE_TEXT, blockString);
4754 SysTryReturnResult(NID_UI_CTRL, pClipboardItem != null, E_SYSTEM, "Unable to get the clipboarditem instance.");
4756 r = pClipBoard->CopyItem(*pClipboardItem);
4758 delete pClipboardItem;
4760 _Text::TextElement* pStartTextElement = __pTextObject->GetElementAtTextIndex(start);
4761 _Text::TextElement* pEndTextElement = __pTextObject->GetElementAtTextIndex(end-1);
4763 if (pStartTextElement == null || pEndTextElement == null)
4768 const int startIndex = __pTextObject->GetElementIndexOf(*pStartTextElement);
4769 const int endIndex = __pTextObject->GetElementIndexOf(*pEndTextElement);
4771 for (int index = startIndex; index <= endIndex; index++)
4773 _Text::TextElement* pTextElement = __pTextObject->GetElementAtElementIndex(index);
4774 TextElementType objectType = pTextElement->GetType();
4775 if (objectType != TEXT_ELEMENT_TYPE_IMAGE)
4779 TextImage* pImageText = null;
4780 pImageText = dynamic_cast < TextImage* >(pTextElement);
4781 if ( pImageText == null)
4785 const Bitmap * pImage = pImageText->GetBitmap();
4786 SysTryReturnResult(NID_UI_CTRL, pImage != null, E_SYSTEM, "Unable to get the bitmap from textobject.");
4788 _ClipboardItem* pClipboardImageItem = _ClipboardItem::CreateInstanceN(CLIPBOARD_DATA_TYPE_IMAGE, *pImage);
4789 SysTryReturnResult(NID_UI_CTRL, pClipboardImageItem != null, E_SYSTEM, "Unable to get the clipboardImageitem instance.");
4791 r = pClipBoard->CopyItem(*pClipboardImageItem);
4793 delete pClipboardImageItem;
4800 _EditPresenter::CutText(void)
4802 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
4805 result r = E_SUCCESS;
4808 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4812 GetBlockRange(start, end);
4813 DeleteText(start, end);
4816 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
4822 _EditPresenter::PasteText(void)
4824 result r = E_SUCCESS;
4825 int currentLength = GetTextLength();
4826 String* pSubString = null;
4831 String filteredString;
4833 _Clipboard* pClipBoard = _Clipboard::GetInstance();
4834 SysTryReturnResult(NID_UI_CTRL, pClipBoard != null, E_SYSTEM, "Unable to get the clipboard instance.");
4836 const _ClipboardItem* pClipboardItem = pClipBoard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT|CLIPBOARD_DATA_TYPE_AUDIO | CLIPBOARD_DATA_TYPE_VIDEO);
4837 SysTryReturnResult(NID_UI_CTRL, pClipboardItem != null, E_SYSTEM, "Unable to get the clipboarditem instance.");
4839 const String* pClipString = dynamic_cast<const String*>(pClipboardItem->GetData());
4840 SysTryCatch(NID_UI_CTRL, pClipString, r = E_SYSTEM, E_SYSTEM, "Unable to get the clipboarditem instance.");
4842 filteredString = *pClipString;
4846 if(__pTextFilter->ValidatePastedText(*pClipString, userString))
4848 filteredString = userString;
4849 SysLog(NID_UI_CTRL, "ClipString was changed by User");
4852 else if (IsUnsupportedChracterExist(GetKeypadStyle(), *pClipString) == true)
4859 GetBlockRange(start, end);
4860 total = currentLength - (end - start) + filteredString.GetLength();
4861 if (total > __limitLength)
4863 DeleteText(start, end);
4865 pSubString = new String(__limitLength - currentLength + (end - start));
4866 SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "Unable to allocate text buffer.");
4868 filteredString.SubString(0, __limitLength - currentLength + (end - start), *pSubString);
4869 r = InsertTextAt(__cursorPos, pSubString->GetPointer());
4870 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4875 DeleteText(start, end);
4877 r = InsertTextAt(__cursorPos, filteredString.GetPointer());
4878 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4881 else if (currentLength + filteredString.GetLength() > __limitLength)
4883 if (__limitLength == currentLength)
4885 delete pClipboardItem;
4889 pSubString = new String(__limitLength - currentLength);
4890 SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "Unable to allocate text buffer.");
4892 filteredString.SubString(0, __limitLength - currentLength, *pSubString);
4893 r = InsertTextAt(__cursorPos, pSubString->GetPointer());
4894 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4899 r = InsertTextAt(__cursorPos, filteredString.GetPointer());
4900 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4903 delete pClipboardItem;
4905 ReplaceTextIntoPasswordHyphenString();
4907 ScrollPanelToCursorPosition();
4909 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
4914 delete pClipboardItem;
4920 _EditPresenter::RemoveTextBlock(void)
4922 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
4926 if (!__isTextBlocked)
4928 return E_OBJ_NOT_FOUND;
4934 GetBlockRange(start, end);
4937 return E_OBJ_NOT_FOUND;
4940 result r = DeleteText(start, end);
4941 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4943 __isTextBlocked = false;
4945 InitializeCopyPasteManager();
4951 _EditPresenter::IsClipped(void) const
4953 _Clipboard* pClipBoard = _Clipboard::GetInstance();
4954 SysTryReturn(NID_UI_CTRL, pClipBoard != null, false, E_SYSTEM, "Unable to get the clipboard instance.");
4956 const _ClipboardItem* pClipboardItem = pClipBoard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT|CLIPBOARD_DATA_TYPE_AUDIO | CLIPBOARD_DATA_TYPE_VIDEO);
4957 if (pClipboardItem == null)
4959 SetLastResult(E_SUCCESS);
4962 delete pClipboardItem;
4968 _EditPresenter::SetTextAlignment(HorizontalAlignment alignment)
4970 result r = E_SUCCESS;
4972 int textAlign = TEXT_OBJECT_ALIGNMENT_LEFT;
4974 if (alignment == ALIGNMENT_CENTER)
4976 textAlign = TEXT_OBJECT_ALIGNMENT_CENTER;
4978 else if (alignment == ALIGNMENT_RIGHT)
4980 textAlign = TEXT_OBJECT_ALIGNMENT_RIGHT;
4983 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
4985 r = __pTextObject->SetAlignment(textAlign | TEXT_OBJECT_ALIGNMENT_MIDDLE);
4989 r = __pTextObject->SetAlignment(textAlign | TEXT_OBJECT_ALIGNMENT_TOP);
4991 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Unable to set text alignment.");
4992 __horizontalAlignment = alignment;
4998 _EditPresenter::SetLineSpacing(int linePixelGap)
5000 result r = E_SUCCESS;
5002 __pTextObject->SetLineSpace(linePixelGap);
5008 _EditPresenter::SetLineSpacing(float linePixelGap)
5010 result r = E_SUCCESS;
5012 __pTextObject->SetLineSpace(linePixelGap);
5018 _EditPresenter::GetText(int start, int end) const
5022 if (start != 0 && end != -1)
5024 SysTryReturn(NID_UI_CTRL, (start <= end), tempString, E_SYSTEM, "[E_SYSTEM] The invalid argument(start = %d, end = %d) is given.", start, end);
5025 int textLength = GetTextLength();
5026 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);
5029 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
5031 int length = end - start + 1;
5032 __pTextString->SubString(start, length, tempString);
5037 String resultString;
5038 String elementString;
5039 const int textElementCount = __pTextObject->GetElementCount();
5040 _Text::TextElement* pTextElement = __pTextObject->GetElementAtTextIndex(start);
5042 if (pTextElement == null)
5044 return resultString;
5046 const int startIndex = __pTextObject->GetElementIndexOf(*pTextElement);
5048 for (int index = startIndex; index < textElementCount; index++)
5050 _Text::TextElement* pTextElement = __pTextObject->GetElementAtElementIndex(index);
5051 TextSimple* pSimpleText = null;
5052 if (pTextElement == null)
5057 TextElementType objectType = pTextElement->GetType();
5058 if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK)
5060 pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
5061 if ( pSimpleText == null)
5072 int elementOffset = static_cast < int >(pTextElement->GetValue(SET_TEXT_OFFSET));
5073 int elementLength = pTextElement->GetTextLength();
5075 if (objectType == TEXT_ELEMENT_TYPE_CUTLINK)
5077 elementOffset = GetLinkElementOffsetInTextBuffer(index);
5078 if (elementOffset < 0)
5084 if (end < elementOffset)
5088 if (start >= elementOffset + elementLength)
5093 if (elementLength == 0)
5097 elementString.Clear();
5098 elementString.Append(pSimpleText->GetText());
5099 elementString.SetLength(elementLength);
5100 if (end < elementOffset + elementLength - 1)
5102 int removingStartIndex = end + 1;
5103 elementString.Remove(removingStartIndex - elementOffset, elementOffset + elementLength - removingStartIndex);
5105 if (start > elementOffset)
5107 elementString.Remove(0, start - elementOffset);
5109 resultString.Append(elementString);
5112 return resultString;
5116 _EditPresenter::GetText(void) const
5118 return GetText(0, GetTextLength()-1);
5122 _EditPresenter::SetText(const String& text)
5124 result r = E_SUCCESS;
5126 InitializeCopyPasteManager();
5128 int length = text.GetLength();
5130 if (__pEdit->IsViewModeEnabled())
5132 if (__limitLength <= length)
5134 String tempString = GetText();
5135 SetTextLimitLength(length * 2);
5140 SysTryReturnResult(NID_UI_CTRL, length <= __limitLength, E_INVALID_ARG, "The Invalid argument is given.");
5143 FinishTextComposition();
5145 __pTextString->Clear();
5146 __pTextString->Append(text);
5148 wchar_t* tempString = const_cast<wchar_t*>(text.GetPointer());
5149 for (int i = 0; i < length; i++)
5151 __pTextBuffer[i] = tempString[i];
5153 __pTextBuffer[length] = 0;
5155 if (__isInitialized == true)
5157 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT);
5160 __pTextObject->RemoveAll();
5161 TextSimple* pSimpleText = new (std::nothrow)TextSimple(__pTextBuffer, length,TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, __pFont);
5162 __pTextObject->AppendElement(*pSimpleText);
5163 __pTextObject->Compose();
5165 ReplaceTextIntoPasswordHyphenString();
5167 __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), 0);
5169 SetCursorPosition(length);
5171 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
5173 AdjustFlexibleHeight();
5176 if (__pEdit->IsViewModeEnabled())
5178 __isCutLinkParserEnabled = true;
5181 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
5187 _EditPresenter::GetRemainingLength(void) const
5189 return __limitLength - __pTextObject->GetTextLength();
5193 _EditPresenter::SetCursorPosition(int position)
5195 result r = E_SUCCESS;
5196 int length = GetTextLength();
5198 SysTryReturnResult(NID_UI_CTRL, -1 < position && position <= length, E_INVALID_ARG, "Invalid argument is given.");
5200 if (__isTouchMoving == false)
5202 __isCursorChanged = true;
5205 r = __pTextObject->SetCursorIndex(position);
5206 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Failed to set cursor position");
5208 if (__cursorPos != position)
5210 __pTextObject->ConvertToRowColumn(position, __rowCursorIndex, __columnCursorIndex);
5211 __cursorPos = position;
5218 _EditPresenter::SetCursorPosition(int position,int rowIndex, int columnIndex)
5220 result r = E_SUCCESS;
5221 int length = GetTextLength();
5223 SysTryReturnResult(NID_UI_CTRL, -1 < position && position <= length, E_INVALID_ARG, "Invalid argument is given.");
5225 if (__isTouchMoving == false)
5227 __isCursorChanged = true;
5230 r = __pTextObject->SetCursorIndex(position);
5231 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Failed to set cursor position");
5233 __rowCursorIndex = rowIndex;
5234 __columnCursorIndex = columnIndex;
5236 __cursorPos = position;
5242 _EditPresenter::GetCursorPosition(void) const
5248 _EditPresenter::GetTextLength(void) const
5250 return __pTextObject->GetTextLength();
5254 _EditPresenter::InsertTextAt(int index, const String& text)
5256 result r = E_SUCCESS;
5258 int currentLength = GetTextLength();
5259 int length = text.GetLength();
5260 int totalLength = currentLength + length;
5261 String insertText = text;
5264 SysTryReturnResult(NID_UI_CTRL, index >= 0 && index <= currentLength, E_OUT_OF_RANGE, "The Invalid argument is given.");
5266 if (__pEdit->IsViewModeEnabled())
5268 if (__limitLength <= totalLength)
5270 String tempString = GetText();
5271 SetTextLimitLength(totalLength * 2);
5272 SetText(tempString);
5277 SysTryReturnResult(NID_UI_CTRL, totalLength <= __limitLength, E_MAX_EXCEEDED, "The Invalid argument is given.");
5280 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE || __pEdit->GetEditStyle() & EDIT_STYLE_TOKEN )
5282 while (insertText.Contains(String(L"\n")))
5284 for (i = 0; i < length; i++)
5287 insertText.GetCharAt(i, ch);
5290 insertText.Remove(i, 1);
5291 length = insertText.GetLength();
5304 r = __pTextString->Insert(insertText, index);
5305 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5307 wchar_t* pTempString = const_cast<wchar_t*>(insertText.GetPointer());
5308 wchar_t pOriginalString[currentLength - index];
5310 for (int i = 0; i < currentLength - index; i++)
5312 pOriginalString[i] = __pTextBuffer[index + i];
5314 pOriginalString[currentLength - index] = 0;
5316 for (int i = 0; i < length; i++)
5318 __pTextBuffer[i + index] = pTempString[i];
5321 for (int i = 0; i < currentLength - index; i++)
5323 __pTextBuffer[i + index + length] = pOriginalString[i];
5325 __pTextBuffer[totalLength] = 0;
5327 __pTextObject->InputText(index);
5328 __pTextObject->SetRange(index, length);
5329 r = __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), length);
5330 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Failed to set length");
5332 __pTextObject->Compose();
5334 if (__isTextBlocked == true)
5336 DeleteText(__blockStartPos, __cursorPos);
5339 SetCursorPosition(__cursorPos + length);
5343 SetCursorPosition(index + length);
5346 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
5348 AdjustFlexibleHeight();
5351 __isCursorChanged = true;
5353 if (__pEdit->IsViewModeEnabled())
5355 __isCutLinkParserEnabled = true;
5358 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
5364 _EditPresenter::AppendText(const String& text)
5366 result r = E_SUCCESS;
5368 int currentLength = GetTextLength();
5369 int length = text.GetLength();
5370 int totalLength = currentLength + length;
5372 if (__pEdit->IsViewModeEnabled())
5374 if (__limitLength <= totalLength)
5376 String tempString = GetText();
5377 SetTextLimitLength(totalLength * 2);
5378 SetText(tempString);
5383 SysTryReturnResult(NID_UI_CTRL, totalLength <= __limitLength, E_MAX_EXCEEDED, "The Invalid argument is given.");
5386 r = __pTextString->Append(text);
5387 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5389 wchar_t* pTempString = const_cast<wchar_t*>(text.GetPointer());
5391 for (int i = 0; i < length; i++)
5393 __pTextBuffer[i + currentLength] = pTempString[i];
5395 __pTextBuffer[totalLength] = 0;
5397 __pTextObject->SetRange(currentLength, length);
5398 r = __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), length);
5399 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Failed to set length");
5401 __pTextObject->Compose();
5403 if (!__isTextBlocked)
5405 SetCursorPosition(totalLength);
5408 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
5410 AdjustFlexibleHeight();
5413 if (__pEdit->IsViewModeEnabled())
5415 __isCutLinkParserEnabled = true;
5418 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
5424 _EditPresenter::AppendCharacter(const Character& character)
5426 result r = E_SUCCESS;
5428 r = AppendText(character.ToString());
5434 _EditPresenter::ClearText(void)
5436 InitializeCopyPasteManager();
5438 result r = E_SUCCESS;
5440 FinishTextComposition();
5442 int textLength = GetTextLength();
5444 if (textLength == 0)
5449 r = DeleteText(0, textLength);
5450 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5452 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_CLEAR_ICON);
5458 _EditPresenter::DeleteCharacterAt(int index)
5460 result r = E_SUCCESS;
5463 length = GetTextLength();
5465 SysTryReturnResult(NID_UI_CTRL, index >= 0, E_INVALID_ARG, "Specified index is negative.");
5466 SysTryReturnResult(NID_UI_CTRL, index < length, E_OUT_OF_RANGE, "Specified index is outside the range.");
5468 r = DeleteText(index, index+1);
5473 _EditPresenter::DeleteText(int startCursorPosition, int endCursorPosition)
5475 result r = E_SUCCESS;
5477 int length = GetTextLength();
5479 SysTryReturnResult(NID_UI_CTRL, -1 < startCursorPosition && startCursorPosition < endCursorPosition, E_INVALID_ARG, "Invalid argument is given.");
5480 SysTryReturnResult(NID_UI_CTRL, startCursorPosition < endCursorPosition && endCursorPosition <= length, E_INVALID_ARG, "Invalid argument is given.");
5482 _Text::TextElement* pFirstTextElement = __pTextObject->GetElementAtTextIndex(startCursorPosition);
5483 const TextSimple* pFirstSimpleText = dynamic_cast <const TextSimple*>(pFirstTextElement);
5484 if (pFirstSimpleText != null && pFirstSimpleText->GetBitmap() != null)
5486 if (pFirstSimpleText->GetTextOffset() < startCursorPosition)
5488 startCursorPosition = pFirstSimpleText->GetTextOffset();
5491 _Text::TextElement* pLastTextElement = __pTextObject->GetElementAtTextIndex(endCursorPosition - 1);
5492 const TextSimple* pLastSimpleText = dynamic_cast <const TextSimple*>(pLastTextElement);
5493 if (pLastSimpleText != null && pLastSimpleText->GetBitmap() != null)
5495 if( (pLastSimpleText->GetTextOffset() + pLastSimpleText->GetTextLength()) > endCursorPosition)
5497 endCursorPosition = pLastSimpleText->GetTextOffset() + pLastSimpleText->GetTextLength();
5501 r = __pTextString->Remove(startCursorPosition, endCursorPosition - startCursorPosition);
5502 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5504 int currentLength = __pTextString->GetLength();
5506 for (int i = startCursorPosition; i < length; i++)
5508 if ((i + length - currentLength) >= length)
5512 __pTextBuffer[i] = __pTextBuffer[i + (length - currentLength)];
5515 for (int i = currentLength; i < length; i++)
5517 __pTextBuffer[i] = 0;
5520 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT);
5522 __pTextObject->RemoveText(startCursorPosition);
5523 __pTextObject->SetRange(startCursorPosition, endCursorPosition - startCursorPosition);
5524 r = __pTextObject->NotifyTextChanged(__pTextBuffer, 0, currentLength, -(endCursorPosition - startCursorPosition));
5525 r = __pTextObject->Compose();
5527 SetCursorPosition(startCursorPosition);
5529 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
5531 AdjustFlexibleHeight();
5534 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
5540 _EditPresenter::GetCurrentTextRange(int& start, int& end) const
5542 int currentLength = __pTextString->GetLength();
5544 start = __cursorPos;
5547 if (__pTextBuffer[--start] == TEXT_OBJ_CHARACTER)
5555 while (end < currentLength && __pTextBuffer[end] != TEXT_OBJ_CHARACTER)
5564 _EditPresenter::GetTextLimitLength(void) const
5566 return __limitLength;
5570 _EditPresenter::SetTextLimitLength(int limitLength)
5572 result r = E_SUCCESS;
5574 SysTryReturnResult(NID_UI_CTRL, (limitLength > 0), E_INVALID_ARG, "The invalid limit length is given.");
5576 String tempString = GetText();
5578 int textLength = tempString.GetLength();
5579 SysTryReturnResult(NID_UI_CTRL, (limitLength >= textLength), E_INVALID_ARG, "The invalid argument is given.");
5581 TextSimple* pSimpleText = null;
5583 if (limitLength == GetTextLimitLength())
5588 wchar_t* pTempBuffer = new (std::nothrow) wchar_t[limitLength + 1];
5589 SysTryReturnResult(NID_UI_CTRL, pTempBuffer, E_OUT_OF_MEMORY, "Unable to allocate buffer.");
5591 for (int i = 0; i < textLength; i++)
5593 pTempBuffer[i] = __pTextBuffer[i];
5596 for (int i = textLength; i < limitLength; i++)
5601 pTempBuffer[limitLength] = '\0';
5603 __pTextString->Clear();
5604 __pTextString->Append(tempString);
5607 delete[] __pTextBuffer;
5608 __pTextBuffer = null;
5610 __pTextBuffer = pTempBuffer;
5612 __pTextObject->RemoveAll();
5613 pSimpleText = new (std::nothrow)TextSimple(__pTextBuffer, textLength, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, __pFont);
5614 SysTryReturnResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "Insufficient memory.");
5616 r = __pTextObject->AppendElement(*pSimpleText);
5617 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5619 SetCursorPosition(textLength);
5621 __limitLength = limitLength;
5632 _EditPresenter::InsertCharacterAt(int index, const Character& character)
5634 result r = E_SUCCESS;
5636 r = InsertTextAt(index, character.ToString());
5642 _EditPresenter::SetModel(const _EditModel& editModel)
5646 delete __pEditModel;
5647 __pEditModel = null;
5650 __pEditModel = const_cast<_EditModel*>(&editModel);
5656 _EditPresenter::SetAutoLinkMask(unsigned long autoLinks)
5658 __isCutLinkParserEnabled = true;
5659 return __pEditModel->SetAutoLinkMask(autoLinks);
5663 _EditPresenter::GetAutoLinkMask(void) const
5665 return __pEditModel->GetAutoLinkMask();
5669 _EditPresenter::IsViewModeEnabled(bool internal) const
5671 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
5673 return __pEditModel->IsViewModeEnabled();
5683 return __pEditModel->IsViewModeEnabled();
5689 _EditPresenter::SetViewModeEnabled(bool enable)
5691 if (!enable && __pEditModel->IsViewModeEnabled() && IsCurrentFocused() && (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY))
5693 __pEdit->SetFocused(false);
5696 int editStyle = __pEdit->GetEditStyle();
5700 editStyle = editStyle | EDIT_STYLE_VIEWER;
5704 editStyle = editStyle & (~EDIT_STYLE_VIEWER);
5706 __pEdit->SetEditStyle(editStyle);
5710 __pEdit->SetCursorPosition(0);
5712 if (__pInputConnection && __isInputConnectionBound)
5718 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
5720 __isCursorDisabled = enable;
5721 __pTextObject->SetCutLinkViewMode(enable);
5724 if (__pInputConnection)
5728 __pInputConnection->SetKeyEventSkipped(true);
5732 if (IsKeypadEnabled())
5734 __pInputConnection->SetKeyEventSkipped(false);
5739 return __pEditModel->SetViewModeEnabled(enable);
5743 _EditPresenter::SetKeypadActionEnabled(bool enable)
5746 result r = E_SUCCESS;
5748 r = __pInputConnection->SetInputPanelActionEnabled(enable);
5751 __pEditModel->SetKeypadActionEnabled(enable);
5757 _EditPresenter::IsKeypadActionEnabled(void)
5760 bool enableIc = true;
5762 enable = __pEditModel->IsKeypadActionEnabled();
5763 enableIc = __pInputConnection->IsInputPanelActionEnabled();
5769 _EditPresenter::GetKeypadAction(void) const
5771 return __pEditModel->GetKeypadAction();
5775 _EditPresenter::ConvertKeypadAction(CoreKeypadAction keypadAction)
5777 InputPanelAction inputPanelAction = INPUT_PANEL_ACTION_ENTER;
5779 switch (keypadAction)
5781 case CORE_KEYPAD_ACTION_ENTER:
5782 inputPanelAction = INPUT_PANEL_ACTION_ENTER;
5784 case CORE_KEYPAD_ACTION_GO:
5785 inputPanelAction = INPUT_PANEL_ACTION_GO;
5787 case CORE_KEYPAD_ACTION_NEXT:
5788 inputPanelAction = INPUT_PANEL_ACTION_NEXT;
5790 case CORE_KEYPAD_ACTION_SEND:
5791 inputPanelAction = INPUT_PANEL_ACTION_SEND;
5793 case CORE_KEYPAD_ACTION_SEARCH:
5794 inputPanelAction = INPUT_PANEL_ACTION_SEARCH;
5796 case CORE_KEYPAD_ACTION_LOGIN:
5797 inputPanelAction = INPUT_PANEL_ACTION_LOGIN;
5799 case CORE_KEYPAD_ACTION_SIGN_IN:
5800 inputPanelAction = INPUT_PANEL_ACTION_SIGN_IN;
5802 case CORE_KEYPAD_ACTION_JOIN:
5803 inputPanelAction = INPUT_PANEL_ACTION_JOIN;
5805 case CORE_KEYPAD_ACTION_DONE:
5806 inputPanelAction = INPUT_PANEL_ACTION_DONE;
5812 return inputPanelAction;
5817 _EditPresenter::SetKeypadAction(CoreKeypadAction keypadAction)
5819 return __pEditModel->SetKeypadAction(keypadAction);
5823 _EditPresenter::SetKeypadEnabled(bool enable)
5825 if (!enable && IsKeypadEnabled())
5827 CheckUSBKeyboardStatus();
5829 if (!__isUSBKeyboardConnected && __isInputConnectionBound)
5835 __pEditModel->SetKeypadEnabled(enable);
5837 if (__pInputConnection)
5841 __pInputConnection->SetKeyEventSkipped(true);
5845 if (!__pEditModel->IsViewModeEnabled())
5847 __pInputConnection->SetKeyEventSkipped(false);
5856 _EditPresenter::SetKeypadEventSkipped(bool skip)
5860 __pInputConnection->SetKeyEventSkipped(true);
5864 if (__pEdit->IsEnabled() && !__pEditModel->IsViewModeEnabled() && IsKeypadEnabled())
5866 __pInputConnection->SetKeyEventSkipped(false);
5872 _EditPresenter::IsKeypadEnabled(void)
5876 if (__pEdit->IsEnabled())
5878 enable = __pEditModel->IsKeypadEnabled();
5889 _EditPresenter::SetCurrentLanguage(LanguageCode languageCode)
5891 result r = E_SUCCESS;
5893 if (__pInputConnection && __isInputConnectionBound)
5895 r = __pInputConnection->SetInputPanelLanguage(languageCode);
5896 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5897 r = __pEditModel->SetInitialKeypadLanguage(LANGUAGE_INVALID);
5898 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5902 r = __pEditModel->SetInitialKeypadLanguage(languageCode);
5903 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5906 r = __pEditModel->SetCurrentLanguage(languageCode);
5912 _EditPresenter::GetCurrentLanguage(LanguageCode& language) const
5914 result r = E_SUCCESS;
5915 if (__pInputConnection && __isInputConnectionBound)
5917 language = __pInputConnection->GetInputPanelLanguage();
5918 r = __pEditModel->SetCurrentLanguage(language);
5919 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5922 return __pEditModel->GetCurrentLanguage(language);
5926 _EditPresenter::SetLowerCaseModeEnabled(bool enable)
5928 __pEditModel->SetLowerCaseModeEnabled(enable);
5934 _EditPresenter::IsLowerCaseModeEnabled(void) const
5936 return __pEditModel->IsLowerCaseModeEnabled();
5940 _EditPresenter::GetKeypadStyle(void) const
5942 return __pEditModel->GetKeypadStyle();
5946 _EditPresenter::SetKeypadStyle(KeypadStyle keypadStyle)
5949 bool textPredictionEnabled = __pEditModel->IsTextPredictionEnabled();
5951 InputPanelStyle inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
5953 switch (keypadStyle)
5955 case KEYPAD_STYLE_NORMAL:
5956 if (__isKeypadNormalNumberStyleEnabled)
5958 inputPanelStyle = INPUT_PANEL_STYLE_NUMBER;
5962 inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
5965 case KEYPAD_STYLE_PASSWORD:
5966 inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
5967 if (__pInputConnection)
5969 __pInputConnection->SetPasswordMode(true);
5972 case KEYPAD_STYLE_EMAIL:
5973 inputPanelStyle = INPUT_PANEL_STYLE_EMAIL;
5975 case KEYPAD_STYLE_URL:
5976 inputPanelStyle = INPUT_PANEL_STYLE_URL;
5978 case KEYPAD_STYLE_NUMBER:
5979 inputPanelStyle = INPUT_PANEL_STYLE_NUMBER_ONLY;
5980 textPredictionEnabled = false;
5982 case KEYPAD_STYLE_PHONE_NUMBER:
5983 inputPanelStyle = INPUT_PANEL_STYLE_PHONE_NUMBER;
5984 textPredictionEnabled = false;
5986 case KEYPAD_STYLE_IP_V4:
5987 inputPanelStyle = INPUT_PANEL_STYLE_IP;
5988 textPredictionEnabled = false;
5994 if (__pInputConnection && __isInputConnectionBound)
5996 __pInputConnection->SetTextPredictionEnabled(textPredictionEnabled);
5997 __pInputConnection->SetInputPanelStyle(inputPanelStyle);
6000 __pEditModel->SetTextPredictionEnabled(textPredictionEnabled);
6002 return __pEditModel->SetKeypadStyle(keypadStyle);
6006 _EditPresenter::SetKeypadNormalNumberStyle(bool enable)
6008 __isKeypadNormalNumberStyleEnabled = enable;
6009 return SetKeypadStyle(__pEditModel->GetKeypadStyle());
6013 _EditPresenter::IsTextPredictionEnabled(void) const
6015 return __pEditModel->IsTextPredictionEnabled();
6019 _EditPresenter::SetTextPredictionEnabled(bool enable)
6021 KeypadStyle keypadStyle = __pEditModel->GetKeypadStyle();
6023 if (keypadStyle == KEYPAD_STYLE_NUMBER ||keypadStyle == KEYPAD_STYLE_PHONE_NUMBER ||
6024 keypadStyle == KEYPAD_STYLE_IP_V4)
6025 return E_UNSUPPORTED_OPERATION;
6027 if (__pInputConnection && __isInputConnectionBound)
6029 __pInputConnection->SetTextPredictionEnabled(enable);
6032 return __pEditModel->SetTextPredictionEnabled(enable);
6036 _EditPresenter::InsertTextAtCursorPosition(const String& text)
6038 return InsertTextAt(__cursorPos, text);
6042 _EditPresenter::InsertTextAt(int position, const String& text, const Bitmap& textImage)
6044 result r = E_SUCCESS;
6046 int currentLength = GetTextLength();
6047 int length = text.GetLength();
6048 int totalLength = currentLength + length;
6050 SysTryReturnResult(NID_UI_CTRL, position >= 0 && position <= currentLength, E_OUT_OF_RANGE, "The given position is out-of-range.");
6052 if ((__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) || (__pEdit->IsViewModeEnabled()))
6054 if (__limitLength <= totalLength)
6056 String backupString = GetText();
6057 SetTextLimitLength(totalLength * 2);
6058 SetText(backupString);
6063 SysTryReturnResult(NID_UI_CTRL, totalLength <= __limitLength, E_MAX_EXCEEDED, "The text exceeds the limitation length.");
6066 FinishTextComposition();
6068 r = __pTextString->Insert(text, position);
6069 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
6071 wchar_t* pInsertString = const_cast<wchar_t*>(text.GetPointer());
6073 if (currentLength > position)
6075 wchar_t pOriginalString[currentLength - position];
6077 for (int i = 0; i < currentLength - position; i++)
6079 pOriginalString[i] = __pTextBuffer[position + i];
6081 pOriginalString[currentLength - position] = 0;
6083 for (int i = 0; i < length; i++)
6085 __pTextBuffer[i + position] = pInsertString[i];
6088 for (int i = 0; i < currentLength - position; i++)
6090 __pTextBuffer[i + position + length] = pOriginalString[i];
6095 for (int i = 0; i < length; i++)
6097 __pTextBuffer[i + position] = pInsertString[i];
6101 __pTextBuffer[totalLength] = 0;
6103 TextSimple* pSimpleText = null;
6104 pSimpleText = new (std::nothrow) TextSimple(__pTextBuffer, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, GetFont());
6105 SysTryReturnResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "Unable to allocate text simple element.");
6107 pSimpleText->ChangeTextOffset(__pTextBuffer, position);
6108 pSimpleText->SetBitmap((Bitmap&)textImage);
6109 __pTextObject->InsertElementAt(position, *pSimpleText);
6110 __pTextObject->ChangeTextOffset(__pTextBuffer, position+pSimpleText->GetTextLength(), pSimpleText->GetTextLength());
6111 __pTextObject->Compose();
6113 if (__isTextBlocked == true)
6115 DeleteText(__blockStartPos, __cursorPos);
6118 SetCursorPosition(__cursorPos + length);
6122 SetCursorPosition(position + length);
6125 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
6127 AdjustFlexibleHeight();
6130 __isCursorChanged = true;
6131 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
6136 _EditPresenter::DeleteCharacterAtCursorPosition(void)
6138 return DeleteCharacterAt(__cursorPos);
6142 _EditPresenter::IsFocused(void) const
6144 return __pEdit->IsFocused();
6148 _EditPresenter::IsInternalFocused(void) const
6150 return __pEdit->IsInternalFocused();
6154 _EditPresenter::GetTextVisualElement(void)
6156 return __pTextVisualElement;
6160 _EditPresenter::SetControlInitialBounds(FloatRectangle initBounds)
6162 __initialBounds = initBounds;
6166 _EditPresenter::SetControlInitialPosition(FloatPoint initPosition)
6168 __initialBounds.x = initPosition.x;
6169 __initialBounds.y = initPosition.y;
6173 _EditPresenter::IsUpdateInitialBounds(void)
6175 return __updateInitialBounds;
6179 _EditPresenter::OnFocusGained(void)
6181 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
6185 __pParentForm = GetParentForm();
6187 if (!__pParentForm && __isKeypadCommandButtonVisible)
6189 __isKeypadCommandButtonVisible = false;
6193 if (__isAutoShrinkEnabled)
6195 float flexibleHeight = CalculateFlexibleHeightF();
6196 FloatRectangle initialRect = GetInitialBoundsF();
6197 initialRect.height = flexibleHeight;
6199 SetFlexBounds(initialRect);
6202 if (!__pTextVisualElement)
6204 result r = E_SUCCESS;
6205 __pTextVisualElement = new (std::nothrow) _VisualElement;
6206 SysTryReturn(NID_UI_CTRL, __pTextVisualElement != null, false, E_OUT_OF_MEMORY, "Unable to create __pTextVisualElement instance.");
6208 r = __pTextVisualElement->Construct();
6209 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r));
6211 __pTextVisualElement->SetSurfaceOpaque(false);
6212 __pTextVisualElement->SetImplicitAnimationEnabled(false);
6214 __pTextVisualElement->SetShowState(true);
6216 _VisualElement* pEditVisualElement = __pEdit->GetVisualElement();
6217 SysTryCatch(NID_UI_CTRL, pEditVisualElement, , r = E_SYSTEM, "[E_SYSTEM] Unable to get root visual element.");
6219 pEditVisualElement->AttachChild(*__pTextVisualElement);
6220 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r));
6223 if (__pEdit->GetEnableState() == false)
6228 __isCursorOpaque = true;
6230 if (__isInputConnectionBound == false && __isInitialized)
6232 if (IsViewModeEnabled() == false)
6234 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
6240 ShowFullscreenKeypad();
6244 __pEdit->Invalidate();
6249 __pTextVisualElement->Destroy();
6250 __pTextVisualElement = null;
6256 _EditPresenter::OnNotifiedN(IList* pArgs)
6258 String showKeypad(L"ShowKeypad");
6259 String showCopyPaste(L"ShowCopyPaste");
6261 String* pType = dynamic_cast <String*>(pArgs->GetAt(0));
6265 if (*pType == showKeypad)
6267 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
6273 ShowFullscreenKeypad();
6276 else if (*pType == showCopyPaste)
6278 if (__pCopyPasteManager)
6280 __pCopyPasteManager->CreateHandle();
6281 if (__needToCreateCopyPastePopup)
6283 __pCopyPasteManager->CreateCopyPastePopup();
6284 __needToCreateCopyPastePopup = false;
6286 __pCopyPasteManager->Show();
6289 pArgs->RemoveAll(true);
6299 _EditPresenter::OnFrameActivated(const _Frame& source)
6301 _ControlManager* pControlManager = _ControlManager::GetInstance();
6302 if (pControlManager)
6304 _Control* pControl = pControlManager->GetFocusControl();
6305 if (pControl != __pEdit)
6311 if (__isInputConnectionBound == false && __isInitialized)
6313 if (IsViewModeEnabled() == false)
6315 CheckUSBKeyboardStatus();
6317 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
6328 _EditPresenter::OnFrameDeactivated(const _Frame& source)
6334 _EditPresenter::OnFrameMinimized(const _Frame& source)
6340 _EditPresenter::OnFrameRestored(const _Frame& source)
6346 _EditPresenter::ChangeToUnbindState(bool removeFocus)
6348 if(__latestBoundedContext != (unsigned int)this)//context is already changed.
6350 __isKeypadHiding = false;
6353 if (IsCopyPasteManagerExist())
6355 InitializeCopyPasteManager();
6358 if (__isInputConnectionBound)
6360 HideKeypad(removeFocus);
6362 if (__isClipboardExist)
6366 __pClipboard->HidePopup();
6367 OnClipboardPopupClosed();
6372 if (__isKeypadHiding)
6374 if (__pParentForm && !__pParentForm->IsVisible()) //Unbind by Scene Change
6376 if (__isCopyPasteManagerExist)
6378 InitializeCopyPasteManager();
6379 __pTextObject->SetBlock(false);
6380 __isTextBlocked = false;
6383 if (__pCommandButton && __isKeypadCommandButtonVisible)
6385 SetFooterVisible(true);
6386 __pCommandButton->SetVisibleState(false);
6387 __pCommandButton->Invalidate();
6390 __isInputConnectionBound = false;
6392 AdjustParentPanelHeight(true);
6393 SysLog(NID_UI_CTRL, "Form deflate RESET!!!!!!!!!!");
6394 __pParentForm->DeflateClientRectHeight(0);
6396 if (!__pEdit->IsFullScreenKeypadEdit())
6400 __pParentForm->Draw();
6404 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CLOSED);
6405 __pEdit->DetachScrollPanelEvent();
6407 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
6408 __resizedByKeypadHide = true;
6409 __latestBoundedContext = null;
6417 _EditPresenter::OnFocusLost(void)
6419 if (!__pEdit->IsDestroyed())
6421 InitializeCopyPasteManager();
6422 __pEdit->SetTouchPressThreshold(__defaultTouchMoveThreshold);
6425 if (__isAutoShrinkEnabled)
6427 FloatRectangle intialWindowBounds = GetInitialBoundsF();
6428 SetFlexBounds(intialWindowBounds);
6431 if (__pTextVisualElement)
6433 __pTextVisualElement->Destroy();
6434 __pTextVisualElement = null;
6437 if (__pEdit == null)
6442 if (__isClipboardExist)
6446 __pClipboard->HidePopup();
6447 OnClipboardPopupClosed();
6451 if (__isInputConnectionBound)
6454 if (__pScrollBar && !(__pEdit->GetEditStyle() & EDIT_STYLE_NOSCROLL))
6456 __pScrollBar->SetScrollVisibility(false);
6459 __isCursorOpaque = false;
6460 __isTouchMoving = false;
6461 __isTouchReleaseSkipped = false;
6466 ReplaceTextIntoPasswordHyphenString();
6468 __pEdit->Invalidate();
6474 _EditPresenter::GetCurrentStatus(void) const
6476 EditStatus editState = EDIT_STATUS_NORMAL;
6478 if (__pEdit->IsEnabled())
6480 if (IsCurrentFocused())
6482 editState = EDIT_STATUS_HIGHLIGHTED;
6484 else if (__isTouchPressed)
6486 editState = EDIT_STATUS_PRESSED;
6491 editState = EDIT_STATUS_DISABLED;
6498 _EditPresenter::GetCursorVisualElement(void) const
6500 return __pCursorVisualElement;
6504 _EditPresenter::SetMaxLineCount(int maxLineCount)
6506 __pEditModel->SetMaxLineCount(maxLineCount);
6512 _EditPresenter::GetMaxLineCount(void) const
6514 return __pEditModel->GetMaxLineCount();
6518 _EditPresenter::UpdateComponentInformation(void)
6520 result r = E_SUCCESS;
6522 if (__isCursorChanged == false)
6527 bool IsTextAlignmentChanged = AdjustRTLTextAlignment(EDIT_TEXT_TYPE_INPUT);
6528 bool setFirstDisplayLine = true;
6529 if (!((__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) || (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)))
6531 float firstDisplayY = __pTextObject->GetFirstDisplayPositionYF();
6532 float totalHeight = __pTextObject->GetTotalHeightF();
6533 FloatRectangle displayBounds = __pTextObject->GetBoundsF();
6534 if (totalHeight >= displayBounds.height)
6536 float textGapFromBottom = displayBounds.height - (totalHeight - firstDisplayY);
6537 if (textGapFromBottom > 0)
6539 ScrollText(-textGapFromBottom);
6544 if (firstDisplayY > 0)
6546 ScrollText(-firstDisplayY);
6550 FloatRectangle absCursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
6551 CalculateAbsoluteCursorBounds(__cursorPos, absCursorBounds);
6552 setFirstDisplayLine = (IsContained(absCursorBounds) == false);
6555 if (setFirstDisplayLine || IsTextAlignmentChanged)
6557 if (__pTextObject->IsChanged())
6559 __pTextObject->Compose();
6561 __pTextObject->SetFirstDisplayLineIndexFromTextIndex(__cursorPos);
6564 __pTextObject->SetCursorIndex(__cursorPos);
6566 __isCursorChanged = false;
6572 _EditPresenter::ScrollText(float distance)
6574 float newFirstDisplayY = __pTextObject->GetFirstDisplayPositionYF();
6575 newFirstDisplayY += distance;
6577 int moveLine = __pTextObject->GetLineIndexAtPositionY(newFirstDisplayY);
6579 __pTextObject->SetFirstDisplayLineIndex(moveLine);
6580 __pTextObject->SetFirstDisplayPositionY(newFirstDisplayY);
6586 _EditPresenter::IsContained(FloatRectangle& paramRect) const
6588 FloatRectangle absBounds = __pEdit->GetAbsoluteBoundsF();
6590 if ((paramRect.x < absBounds.x) ||
6591 (paramRect.y < absBounds.y) ||
6592 ((paramRect.x + paramRect.width) > (absBounds.x + absBounds.width)) ||
6593 ((paramRect.y + paramRect.height) > (absBounds.y + absBounds.height)))
6602 _EditPresenter::CalculateAbsoluteCursorBounds(int index, FloatRectangle& absCursorBounds)
6604 float cursorAbsX = 0.0f;
6605 float cursorAbsY = 0.0f;
6606 float cursorWidth = 0.0f;
6607 float cursorHeight = 0.0f;
6608 float cursorRelativeX = 0.0f;
6609 float cursorRelativeY = 0.0f;
6611 FloatRectangle absBounds = __pEdit->GetAbsoluteBoundsF();
6613 __pTextObject->SetBounds(GetTextBoundsF());
6614 if (index != __cursorPos)
6616 if (__pTextObject->GetTextPositionInfoAt(index, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
6623 if (__pTextObject->GetTextPositionInfoAt(__rowCursorIndex, __columnCursorIndex, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
6629 absCursorBounds.x = absBounds.x + cursorRelativeX;
6631 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
6633 FloatRectangle tempBounds;
6634 GetCursorBounds(true, tempBounds);
6635 absCursorBounds.y = tempBounds.y;
6639 absCursorBounds.y = absBounds.y + cursorRelativeY;
6642 GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorWidth);
6644 absCursorBounds.width = cursorWidth;
6646 if (cursorHeight > 0.0f)
6648 if (cursorHeight <= __calculatedCursorBounds.height)
6650 absCursorBounds.height = cursorHeight;
6654 absCursorBounds.height = __calculatedCursorBounds.height;
6659 absCursorBounds.height = __pTextObject->GetLineHeightAtF(0);
6666 _EditPresenter::CalculateAbsoluteCursorBounds(int rowIndex, int columnIndex, FloatRectangle& absCursorBounds)
6668 float cursorAbsX = 0.0f;
6669 float cursorAbsY = 0.0f;
6670 float cursorWidth = 0.0f;
6671 float cursorHeight = 0.0f;
6672 float cursorRelativeX = 0.0f;
6673 float cursorRelativeY = 0.0f;
6675 FloatRectangle absBounds = __pEdit->GetAbsoluteBoundsF();
6677 __pTextObject->SetBounds(GetTextBoundsF());
6679 if (__pTextObject->GetTextPositionInfoAt(rowIndex, columnIndex, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
6684 absCursorBounds.x = absBounds.x + cursorRelativeX;
6686 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
6688 FloatRectangle tempBounds;
6689 GetCursorBounds(true, tempBounds);
6690 absCursorBounds.y = tempBounds.y;
6694 absCursorBounds.y = absBounds.y + cursorRelativeY;
6697 GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorWidth);
6699 absCursorBounds.width = cursorWidth;
6701 if (cursorHeight > 0.0f)
6703 if (cursorHeight <= __calculatedCursorBounds.height)
6705 absCursorBounds.height = cursorHeight;
6709 absCursorBounds.height = __calculatedCursorBounds.height;
6714 absCursorBounds.height = __pTextObject->GetLineHeightAtF(0);
6721 _EditPresenter::GetCursorBounds(bool isAbsRect, FloatRectangle& cursorBounds)
6723 if (__isInitialized == false)
6728 CalculateCursorBounds(GetTextBoundsF(), cursorBounds);
6732 FloatRectangle absBounds = __pEdit->GetAbsoluteBoundsF();
6733 cursorBounds.x += absBounds.x;
6734 cursorBounds.y += absBounds.y;
6742 _EditPresenter::SetCursorDisabled(bool disabled)
6744 __isCursorDisabled = disabled;
6750 _EditPresenter::IsGuideTextActivated(void) const
6752 if (__pGuideTextObject == null)
6757 if (GetGuideText().IsEmpty())
6762 if (__pTextObject && GetTextLength() > 0)
6771 _EditPresenter::CreateCommandButtonItemN(int actionId, const String& text)
6773 result r = E_SUCCESS;
6774 _Button* pButton = _Button::CreateButtonN();
6775 SysTryReturn(NID_UI_CTRL, pButton, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance.");
6777 float textSize = 0.0f;
6779 r = pButton->SetActionId(actionId);
6780 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6782 r = pButton->SetText(text);
6783 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6785 r = GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_FONT_SIZE, __pEdit->GetOrientation(), textSize);
6788 r = pButton->SetTextSize(textSize);
6789 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6801 _EditPresenter::SetKeypadCommandButton(const FloatRectangle& bounds)
6803 // This function must be changed after _ toolbar completes their float conversion works
6804 result r = E_SUCCESS;
6805 Bitmap* pNormalBackgroundBitmap = null;
6806 Bitmap* pReplacementColorBackgroundBitmap = null;
6807 String leftButtonText;
6808 String rightButtonText;
6809 _Control* pParent = null;
6810 Color commandBackgroundColor;
6812 if (__pCommandButton)
6814 __pCommandButton->SetResizable(true);
6815 __pCommandButton->SetMovable(true);
6816 SysLog(NID_UI_CTRL, "Command position changed!!!! bounds(%f, %f, %f, %f)", bounds.x, bounds.y, bounds.width, bounds.height);
6817 r = __pCommandButton->SetBounds(bounds);
6819 __pCommandButton->SetResizable(false);
6820 __pCommandButton->SetMovable(false);
6825 if (__pParentForm == false)
6827 __isKeypadCommandButtonVisible = false;
6831 __pCommandButton = _Toolbar::CreateToolbarN(false);
6832 SysTryReturn(NID_UI_CTRL, __pCommandButton, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance.");
6834 r = __pCommandButton->Construct();
6835 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6837 GET_BITMAP_CONFIG_N(FOOTER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundBitmap);
6838 if (pNormalBackgroundBitmap)
6840 GET_COLOR_CONFIG(FOOTER::BG_NORMAL, commandBackgroundColor);
6841 pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), commandBackgroundColor);
6843 if (pReplacementColorBackgroundBitmap)
6845 r = __pCommandButton->SetBackgroundBitmap(*pReplacementColorBackgroundBitmap);
6846 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6848 delete pReplacementColorBackgroundBitmap;
6849 pReplacementColorBackgroundBitmap = null;
6851 delete pNormalBackgroundBitmap;
6852 pNormalBackgroundBitmap = null;
6855 r = __pCommandButton->SetStyle(TOOLBAR_COMMAND);
6856 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6858 __pCommandButton->SetResizable(true);
6859 __pCommandButton->SetMovable(true);
6860 SysLog(NID_UI_CTRL, "Command created!!!! bounds(%f, %f, %f, %f)", bounds.x, bounds.y, bounds.width, bounds.height);
6861 r = __pCommandButton->SetBounds(bounds);
6862 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6864 __pCommandButton->SetResizable(false);
6865 __pCommandButton->SetMovable(false);
6867 leftButtonText = __pEditModel->GetKeypadCommandButtonText(COMMAND_BUTTON_POSITION_LEFT);
6868 r = __pCommandButton->AddItem(CreateCommandButtonItemN(__pEditModel->GetKeypadCommandButtonActionId(COMMAND_BUTTON_POSITION_LEFT), leftButtonText));
6869 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6871 rightButtonText = __pEditModel->GetKeypadCommandButtonText(COMMAND_BUTTON_POSITION_RIGHT);
6872 r = __pCommandButton->AddItem(CreateCommandButtonItemN(__pEditModel->GetKeypadCommandButtonActionId(COMMAND_BUTTON_POSITION_RIGHT), rightButtonText));
6873 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6875 if (__pActionEventListener)
6877 __pCommandButton->AddActionEventListener(*__pActionEventListener);
6882 r = __pParentForm->AttachChild(*__pCommandButton);
6883 __pParentForm->MoveChildToTop(*__pCommandButton);
6887 pParent = __pEdit->GetParent();
6888 SysTryCatch(NID_UI_CTRL, pParent, r = E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
6889 r = pParent->AttachChild(*__pCommandButton);
6891 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
6896 delete pNormalBackgroundBitmap;
6898 delete __pCommandButton;
6899 __pCommandButton = null;
6901 delete pReplacementColorBackgroundBitmap;
6907 _EditPresenter::CheckInitialFooterVisibleState(void)
6909 if (__pParentForm == null)
6914 _Toolbar* pFooter = __pParentForm->GetFooter();
6917 if (pFooter->GetVisibleState() == false)
6919 __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_HIDE;
6920 SysLog(NID_UI_CTRL, "EDIT_FOOTER_VISIBLE_STATUS_HIDE");
6924 __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_SHOW;
6925 SysLog(NID_UI_CTRL, "EDIT_FOOTER_VISIBLE_STATUS_SHOW");
6930 __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
6931 SysLog(NID_UI_CTRL, "EDIT_FOOTER_VISIBLE_STATUS_NONE");
6938 _EditPresenter::SetFooterVisible(bool isVisible)
6940 if (__pParentForm == null)
6945 _Toolbar* pFooter = __pParentForm->GetFooter();
6946 if (pFooter && __initialFooterVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_SHOW)
6948 if ((isVisible == true && pFooter->GetVisibleState() == false) ||
6949 (isVisible == false && pFooter->GetVisibleState() == true))
6953 SysLog(NID_UI_CTRL, "SetFooterVisible TRUE!!!!!");
6957 SysLog(NID_UI_CTRL, "SetFooterVisible FALSE!!!!!");
6960 __footerVisibleChanged = true;
6961 pFooter->SetVisibleState(isVisible);
6962 pFooter->Invalidate();
6966 __initialFooterVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
6975 _EditPresenter::ShowFullscreenKeypad(void)
6977 result r = E_SUCCESS;
6979 if (__isCopyPasteManagerExist)
6981 InitializeCopyPasteManager();
6984 if (IsKeypadEnabled() == false)
6986 __pEdit->SetFocused();
6990 if (__pFullscreenKeypad)
6992 __pFullscreenKeypad->Close();
6993 delete __pFullscreenKeypad;
6994 __pFullscreenKeypad = null;
6997 __isKeypadExist = CheckKeypadExist(__pEdit->GetOrientation());
6998 if (__isKeypadExist) //overlay style keypad exist before create fullscreen edit.
7000 AdjustParentPanelHeight(true);
7004 SysLog(NID_UI_CTRL, "Form deflate RESET!!!!!!!!!!");
7005 __pParentForm->DeflateClientRectHeight(0);
7006 __pParentForm->Draw();
7010 int editStyle = __pEdit->GetEditStyle();
7012 _KeypadStyleInfo keypadStyleInfo;
7013 keypadStyleInfo.keypadStyle = __pEditModel->GetKeypadStyle();
7014 keypadStyleInfo.textPredictionEnabled = __pEditModel->IsTextPredictionEnabled();
7015 keypadStyleInfo.isNormalNumberStyle = __isKeypadNormalNumberStyleEnabled;
7016 keypadStyleInfo.enterActionEnabled = true;
7017 keypadStyleInfo.isLowerCaseModeEnabled = __pEditModel->IsLowerCaseModeEnabled();
7019 bool inputConnectionBoundState = __isInputConnectionBound;
7020 __isInputConnectionBound = true;
7021 SetKeypadStyle(__pEditModel->GetKeypadStyle());
7022 __isInputConnectionBound = inputConnectionBoundState;
7024 if (editStyle & EDIT_STYLE_SINGLE_LINE)
7026 keypadStyleInfo.enterActionEnabled = false;
7029 if (editStyle & EDIT_STYLE_PASSWORD)
7031 editStyle = EDIT_STYLE_NORMAL | EDIT_STYLE_SINGLE_LINE | EDIT_STYLE_PASSWORD;
7035 editStyle = EDIT_STYLE_NORMAL;
7038 __pFullscreenKeypad = _Keypad::CreateKeypadN();
7039 SysTryReturn(NID_UI_CTRL, __pFullscreenKeypad, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance.");
7040 r = __pFullscreenKeypad->Initialize(editStyle, keypadStyleInfo, GetTextLimitLength(), __pEdit);
7041 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
7043 __pFullscreenKeypad->SetText(GetText());
7045 r = __pFullscreenKeypad->Open();
7046 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
7048 if (__pEdit->IsInputEventEnabled())
7050 __pEdit->LockInputEvent();
7055 __pFullscreenKeypad->SetEditTextFilter(this);
7061 _EditPresenter::DeleteFullscreenKeypad(void)
7063 if (__pFullscreenKeypad)
7065 __pFullscreenKeypad->Close();
7066 delete __pFullscreenKeypad;
7067 __pFullscreenKeypad = null;
7074 _EditPresenter::GetKeypadBounds(FloatRectangle& bounds)
7076 if (__pInputConnection == null)
7081 bounds = __pInputConnection->GetInputPanelBoundsF();
7083 _CoordinateSystem* pCoordSystem = _CoordinateSystem::GetInstance();
7084 SysTryReturnResult(NID_UI_CTRL, pCoordSystem, E_SYSTEM, "Coordinate system load failed.");
7086 _ICoordinateSystemTransformer* pXformer = pCoordSystem->GetInverseTransformer();
7087 SysTryReturnResult(NID_UI_CTRL, pXformer, E_SYSTEM, "Coordinate system load failed.");
7089 bounds = pXformer->Transform(bounds);
7090 __keypadBounds = bounds;
7096 _EditPresenter::GetClipboardHeight(void) const
7098 return __clipboardHeight;
7102 _EditPresenter::IsKeypadRotating(_ControlOrientation orientation)
7104 FloatDimension screenSize;
7105 FloatRectangle absKeypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
7106 _ControlManager* pControlManager = _ControlManager::GetInstance();
7108 GetKeypadBounds(absKeypadBounds);
7110 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
7112 screenSize.height = pControlManager->GetScreenSizeF().height;
7113 screenSize.width = pControlManager->GetScreenSizeF().width;
7117 screenSize.height = pControlManager->GetScreenSizeF().width;
7118 screenSize.width = pControlManager->GetScreenSizeF().height;
7121 if (absKeypadBounds.width == screenSize.width)
7132 _EditPresenter::CheckKeypadExist(_ControlOrientation orientation)
7134 FloatDimension screenSize;
7135 FloatRectangle absKeypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
7136 _ControlManager* pControlManager = _ControlManager::GetInstance();
7138 GetKeypadBounds(absKeypadBounds);
7140 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
7142 screenSize.height = pControlManager->GetScreenSizeF().height;
7143 screenSize.width = pControlManager->GetScreenSizeF().width;
7147 screenSize.height = pControlManager->GetScreenSizeF().width;
7148 screenSize.width = pControlManager->GetScreenSizeF().height;
7151 if (absKeypadBounds.width != 0 && absKeypadBounds.height != 0)
7153 if ((absKeypadBounds.y != screenSize.height))
7155 SysLog(NID_UI_CTRL, "KEYPAD EXIST!!!!Keypad(y: %f, w: %f, h: %f)", absKeypadBounds.y, absKeypadBounds.width, absKeypadBounds.height);
7160 SysLog(NID_UI_CTRL, "NO KEYPAD!!!!Keypad(y: %f, w: %f, h: %f)", absKeypadBounds.y, absKeypadBounds.width, absKeypadBounds.height);
7166 SysLog(NID_UI_CTRL, "NO KEYPAD!!!!Keypad(y: %f, w: %f, h: %f)", absKeypadBounds.y, absKeypadBounds.width, absKeypadBounds.height);
7172 _EditPresenter::ShowKeypad(bool focus)
7174 if (!__pEdit->IsVisible())
7179 if (IsKeypadEnabled() == false)
7186 __pEdit->SetFocused();
7190 if (!__isInitialized)
7195 _ControlManager* pControlManager = _ControlManager::GetInstance();
7197 if (!pControlManager->IsFrameActivated())
7202 bool sendKeypadEventForcely = false;
7204 CheckUSBKeyboardStatus();
7206 __isInputConnectionBound = true;
7208 SetKeypadStyle(__pEditModel->GetKeypadStyle());
7210 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE && GetKeypadAction() == CORE_KEYPAD_ACTION_ENTER)
7212 __pInputConnection->SetInputPanelActionEnabled(false);
7216 __pInputConnection->SetInputPanelAction(ConvertKeypadAction(GetKeypadAction()));
7219 //Need to complete AutoCapitalization functionality
7220 if (__pEditModel->IsLowerCaseModeEnabled())
7222 __pInputConnection->SetAutoCapitalizationMode(AUTO_CAPITALIZATION_MODE_NONE);
7226 __pInputConnection->SetAutoCapitalizationMode(AUTO_CAPITALIZATION_MODE_SENTENCE);
7229 __pInputConnection->BindInputMethod();
7230 __isKeypadShowing = true;
7231 __isKeypadHiding = false;
7232 __resizedByKeypadHide = false;
7233 __latestBoundedContext = (unsigned int)this;
7235 LanguageCode initialKeypadLanguage = LANGUAGE_INVALID;
7236 __pEditModel->GetInitialKeypadLanguage(initialKeypadLanguage);
7237 if (initialKeypadLanguage != LANGUAGE_INVALID)
7239 SetCurrentLanguage(initialKeypadLanguage);
7242 if (__isUSBKeyboardConnected)
7244 SysLog(NID_UI_CTRL, "ShowKeypad called in USB ON mode!!!!");
7246 __isKeypadExist = CheckKeypadExist(__pEdit->GetOrientation()); //prediction alreaedy exists
7248 if (__isKeypadCommandButtonVisible)
7250 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
7251 __pEdit->AttachScrollPanelEvent();
7252 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
7254 if (__initialFooterVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_NONE)
7256 CheckInitialFooterVisibleState();
7259 SetFooterVisible(false);
7260 ChangeLayoutInternal(__pEdit->GetOrientation());
7261 AdjustParentPanelHeight(false);
7263 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
7264 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
7268 if (__initialFooterVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_NONE)
7270 CheckInitialFooterVisibleState();
7273 if (__isKeypadExist)
7275 ChangeLayoutInternal(__pEdit->GetOrientation());
7276 AdjustParentPanelHeight(false);
7280 ScrollPanelToCursorPosition();
7284 SysLog(NID_UI_CTRL, "ShowKeypad called in USB OFF mode!!!!");
7286 __isKeypadExist = CheckKeypadExist(__pEdit->GetOrientation()); //call once only from here.
7288 if (!__isKeypadExist)
7290 if (__isKeypadCommandButtonVisible)
7292 if (!__pCommandButton || (__pCommandButton && !__pCommandButton->GetVisibleState()))
7294 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
7295 __pEdit->AttachScrollPanelEvent();
7296 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
7297 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
7298 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
7303 if (!__isClipboardExist)
7305 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
7307 __pEdit->AttachScrollPanelEvent();
7308 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
7311 if (__initialFooterVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_NONE)
7313 CheckInitialFooterVisibleState();
7318 if (__footerVisibleChanged)
7320 SetFooterVisible(true);
7323 if (__initialFooterVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_NONE)
7325 CheckInitialFooterVisibleState();
7329 if (__isKeypadCommandButtonVisible)
7331 SetFooterVisible(false);
7334 if (__isKeypadExist) //edit switiching
7338 sendKeypadEventForcely = !__pParentForm->IsDeflated();
7341 if (sendKeypadEventForcely)
7343 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
7344 __pEdit->AttachScrollPanelEvent();
7345 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
7348 ChangeLayoutInternal(__pEdit->GetOrientation());
7349 AdjustParentPanelHeight(false);
7350 ScrollPanelToCursorPosition();
7354 __pParentForm->Draw();
7356 __isKeypadShowing = false;
7358 if (sendKeypadEventForcely)
7360 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
7361 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
7366 if(!__isClipboardExist && __pParentPanel)
7368 __initialParentHeight = 0.0f;
7370 ScrollPanelToCursorPosition();
7373 __pInputConnection->ShowInputPanel();
7380 _EditPresenter::ChangeLayout(_ControlOrientation orientation)
7382 result r = E_SUCCESS;
7384 if (__pCopyPasteManager)
7386 if (__pCopyPasteManager->GetCopyPastePopup())
7388 __needToCreateCopyPastePopup = true;
7390 __pCopyPasteManager->Release();
7393 bool isScrollPanelBoundsReloaded = false;
7397 _ControlImpl* pParentPanelImpl = static_cast <_ControlImpl* >(__pParentPanel->GetUserData());
7398 Rectangle builderBounds;
7399 isScrollPanelBoundsReloaded= pParentPanelImpl->GetBuilderBounds(orientation, builderBounds);
7404 CheckUSBKeyboardStatus();
7406 if (__isInputConnectionBound || __clipboardConnected)
7408 SysLog(NID_UI_CTRL, "-------------------ChangeLayout------------------------");
7410 if (!isScrollPanelBoundsReloaded)
7412 SysLog(NID_UI_CTRL, "ScrollPanel bounds is not changed by UIBuilder, so forcely reset ScrollPanel's height");
7413 AdjustParentPanelHeight(true);
7417 SysLog(NID_UI_CTRL, "ScrollPanel bounds is changed by UIBuilder");
7422 SysLog(NID_UI_CTRL, "Form deflate RESET!!!!!!!!!!");
7423 __pParentForm->DeflateClientRectHeight(0.0f);
7426 if (__pCommandButton && __isKeypadCommandButtonVisible)
7428 __pCommandButton->SetVisibleState(false);
7431 if (__isKeypadExist && ! __isClipboardExist) //only keypad exists, already get keypadbounds before callback [Causion]this timing clipboard height is still previous height
7433 if (isScrollPanelBoundsReloaded)
7435 __initialParentHeight = 0.0f;
7438 ChangeLayoutInternal(orientation);
7439 AdjustParentPanelHeight(false);
7440 ScrollPanelToCursorPosition();
7442 else // if clipboard exists, boundsChanged callback will delivered after rotate callback
7445 if (__isClipboardExist)
7447 __initialParentHeight = 0.0f;
7449 else //no keypad, no clipboard
7451 if (__isKeypadCommandButtonVisible)
7453 __initialParentHeight = 0.0f;
7454 ChangeLayoutInternal(orientation);
7455 AdjustParentPanelHeight(false);
7456 ScrollPanelToCursorPosition();
7460 if (!__isClipboardExist)
7462 if (__isKeypadCommandButtonVisible)
7464 __initialParentHeight = 0.0f;
7465 ChangeLayoutInternal(orientation);
7466 AdjustParentPanelHeight(false);
7467 ScrollPanelToCursorPosition();
7473 if ((__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) == false)
7475 __initialBounds = __pEdit->GetBoundsF();
7478 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to change layout.", GetErrorMessage(r));
7484 _EditPresenter::ChangeLayout(_ControlRotation rotation)
7486 _ControlOrientation orientation = _CONTROL_ORIENTATION_PORTRAIT;
7488 if (rotation == _CONTROL_ROTATION_0 || rotation == _CONTROL_ROTATION_180)
7490 orientation = _CONTROL_ORIENTATION_PORTRAIT;
7494 orientation = _CONTROL_ORIENTATION_LANDSCAPE;
7497 return ChangeLayout(orientation);
7501 _EditPresenter::ChangeLayoutInternal(_ControlOrientation orientation, bool deflateForm)
7503 result r = E_SUCCESS;
7505 FloatRectangle keypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
7507 _ControlManager* pControlManager = _ControlManager::GetInstance();
7508 SysTryReturnResult(NID_UI_CTRL, pControlManager, E_SYSTEM, "Failed to get root.");
7509 FloatDimension screenSize;
7510 FloatRectangle commandButtonBounds(0.0f, 0.0f, 0.0f, 0.0f);
7512 float formDeflateHeight = 0.0f;
7513 float shrinkedHeight = 0.0f;
7515 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
7517 screenSize.width = pControlManager->GetScreenSizeF().width;
7518 screenSize.height = pControlManager->GetScreenSizeF().height;
7522 screenSize.width = pControlManager->GetScreenSizeF().height;
7523 screenSize.height = pControlManager->GetScreenSizeF().width;
7526 if (__isInputConnectionBound || __clipboardConnected)
7528 GetKeypadBounds(keypadBounds);
7530 if (__isKeypadExist)
7532 if (__isClipboardExist)
7534 if (__clipboardHeight > keypadBounds.height)
7536 shrinkedHeight = __clipboardHeight;
7540 shrinkedHeight = keypadBounds.height;
7545 shrinkedHeight = keypadBounds.height;
7550 if (__isClipboardExist)
7552 shrinkedHeight = __clipboardHeight;
7556 if (__isKeypadCommandButtonVisible)
7558 commandButtonBounds.width = screenSize.width;
7559 float commandButtonHeight = 0.0f;
7563 GET_SHAPE_CONFIG(FOOTER::HEIGHT, orientation, commandButtonHeight);
7564 commandButtonBounds.height = commandButtonHeight;
7565 formDeflateHeight += commandButtonBounds.height;
7567 if (__isKeypadExist || __isClipboardExist)
7569 formDeflateHeight += shrinkedHeight;
7570 commandButtonBounds.y = screenSize.height - shrinkedHeight - commandButtonBounds.height - __pParentForm->GetClientBoundsF().y;
7574 commandButtonBounds.y = screenSize.height - commandButtonBounds.height - __pParentForm->GetClientBoundsF().y;
7577 SetKeypadCommandButton(commandButtonBounds);
7579 if (__pCommandButton)
7581 __pCommandButton->SetVisibleState(true);
7582 __pCommandButton->Invalidate();
7590 if (__isKeypadExist || __isClipboardExist)
7592 formDeflateHeight += shrinkedHeight;
7598 if (__pParentForm && deflateForm)
7600 SysLog(NID_UI_CTRL, "FormDeflateHeight:%f, KeypadExist(%d), ClipboardExist(%d), CommandButtonVisible(%d)",
7601 formDeflateHeight, __isKeypadExist, __isClipboardExist, __isKeypadCommandButtonVisible);
7602 __pParentForm->DeflateClientRectHeight(formDeflateHeight);
7609 _EditPresenter::OnScrollPanelBoundsChanged(void)
7615 _EditPresenter::AdjustParentPanelHeight(bool restore)
7617 if (__pParentPanel == null)
7622 float initialParentHeight = __initialParentHeight;
7623 if (__pResizedPanel != __pParentPanel)
7625 initialParentHeight = 0.0f;
7628 _ControlOrientation orientation;
7629 float commandButtonHeight = 0.0f;
7631 FloatRectangle absKeypadBounds(0.0f, 0.0f, 0.0f, 0.0f);
7633 _Toolbar* pFooter = null;
7637 pFooter = __pParentForm->GetFooter();
7640 FloatRectangle absScrollPanelBounds(0.0f, 0.0f, 0.0f, 0.0f);
7641 FloatRectangle scrollPanelBounds = __pParentPanel->GetBoundsF();
7644 _ControlManager* pControlManager = _ControlManager::GetInstance();
7645 float displayedPanelHeight = 0.0f;
7646 FloatDimension screenSize;
7648 if (__pEdit->GetOrientation()== _CONTROL_ORIENTATION_PORTRAIT)
7650 screenSize.width = pControlManager->GetScreenSizeF().width;
7651 screenSize.height = pControlManager->GetScreenSizeF().height;
7655 screenSize.width = pControlManager->GetScreenSizeF().height;
7656 screenSize.height = pControlManager->GetScreenSizeF().width;
7661 if (initialParentHeight)
7663 scrollPanelBounds.height = __initialParentHeight;
7664 SysLog(NID_UI_CTRL, "Rollback ScrollPanel's height to %f and Set __initialParentHeight to 'Zero' ", __initialParentHeight);
7665 __initialParentHeight = 0.0f;
7666 __pResizedPanel = null;
7667 __pParentPanel->SetBounds(scrollPanelBounds);
7668 __pParentPanel->Invalidate();
7673 if (__isKeypadExist)
7675 GetKeypadBounds(absKeypadBounds);
7677 if (__isClipboardExist)
7679 if (__clipboardHeight > absKeypadBounds.height)
7681 absKeypadBounds.y = screenSize.height - __clipboardHeight;
7686 if (__isUSBKeyboardConnected)//predictive window shown
7688 absKeypadBounds.y = screenSize.height - absKeypadBounds.height;//only absKeypadBounds.height is meaningful in USB on.
7694 if (__isClipboardExist)
7696 absKeypadBounds.y = screenSize.height - __clipboardHeight;
7700 absKeypadBounds.y = screenSize.height;
7704 if ((__pParentForm && __isKeypadCommandButtonVisible) || (pFooter && (pFooter->GetVisibleState() == true)))
7706 orientation = __pEdit->GetOrientation();
7707 GET_SHAPE_CONFIG(FOOTER::HEIGHT, orientation, commandButtonHeight);
7710 absScrollPanelBounds = __pParentPanel->GetAbsoluteBoundsF();
7711 displayedPanelHeight = screenSize.height - commandButtonHeight - absScrollPanelBounds.y;
7712 gapY = (absKeypadBounds.y - commandButtonHeight)- absScrollPanelBounds.y;
7714 bool isOverlapped = true;
7716 if (((absKeypadBounds.y - commandButtonHeight) >= (absScrollPanelBounds.y + absScrollPanelBounds.height)) || ( absScrollPanelBounds.y > absKeypadBounds.y))
7718 isOverlapped = false;
7721 SysLog(NID_UI_CTRL, "IsOverlapped:(%d), __initialParentHeight:(%f), gapY:(%f)", isOverlapped, __initialParentHeight, gapY);
7723 if (!initialParentHeight)
7732 initialParentHeight = scrollPanelBounds.height;
7733 __initialParentHeight = initialParentHeight;
7734 __pResizedPanel = __pParentPanel;
7736 SysLog(NID_UI_CTRL, "Set ScrollPanel's height to %f and Set __initialParentHeight:(%f)", gapY, __initialParentHeight);
7738 scrollPanelBounds.height = gapY;
7739 __pParentPanel->SetBounds(scrollPanelBounds);
7740 __pParentPanel->Invalidate();
7747 if ((gapY < initialParentHeight) && (gapY > 0.0f))
7749 SysLog(NID_UI_CTRL, "Set ScrollPanel's height to %f", gapY);
7751 scrollPanelBounds.height = gapY;
7752 __pParentPanel->SetBounds(scrollPanelBounds);
7753 __pParentPanel->Invalidate();
7758 if (gapY > initialParentHeight)
7760 if (scrollPanelBounds.height > initialParentHeight)
7762 __initialParentHeight = scrollPanelBounds.height ;
7766 SysLog(NID_UI_CTRL, "Set ScrollPanel's height to %f", __initialParentHeight);
7768 scrollPanelBounds.height = initialParentHeight;
7769 __pParentPanel->SetBounds(scrollPanelBounds);
7770 __pParentPanel->Invalidate();
7778 if (scrollPanelBounds.height > initialParentHeight)
7780 __initialParentHeight = scrollPanelBounds.height ;
7783 SysLog(NID_UI_CTRL, "Set ScrollPanel's height to %f", gapY);
7784 scrollPanelBounds.height = gapY;
7785 __pParentPanel->SetBounds(scrollPanelBounds);
7786 __pParentPanel->Invalidate();
7793 _EditPresenter::HideKeypad(bool focus)
7795 InitializeCopyPasteManager();
7797 __isKeypadShowing = false;
7798 __resizedByKeypadHide = false;
7800 if (__isInitialized == false || !__isInputConnectionBound)
7805 CheckUSBKeyboardStatus();
7807 if (__isUSBKeyboardConnected)
7809 SysLog(NID_UI_CTRL, "HideKeypad called in USB ON mode!!!!");
7810 if (__pCommandButton && __isKeypadCommandButtonVisible)
7812 SetFooterVisible(true);
7814 __pCommandButton->SetVisibleState(false);
7818 SysLog(NID_UI_CTRL, "Form deflate RESET!!!!!!!!!!");
7819 __pParentForm->DeflateClientRectHeight(0.0f);
7822 AdjustParentPanelHeight(true);
7824 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
7829 SysLog(NID_UI_CTRL, "HideKeypad called in USB OFF mode!!!!");
7830 if (__pCommandButton && __isKeypadCommandButtonVisible)
7832 if (!__isKeypadExist)
7834 SetFooterVisible(true);//must be called ahead of DeflateClientRectHeights
7838 SysLog(NID_UI_CTRL, "Form deflate RESET!!!!!!!!!!");
7839 __pParentForm->DeflateClientRectHeight(0.0f);
7841 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
7843 __pCommandButton->SetVisibleState(false);
7847 FinishTextComposition();
7848 __pInputConnection->HideInputPanel();
7849 __pInputConnection->UnbindInputMethod();
7851 if (__isKeypadExist)
7853 __isKeypadHiding = true;
7856 __isInputConnectionBound = false;
7858 if (focus && __pEdit->IsFocused())
7860 __pEdit->SetFocused(false);
7867 _EditPresenter::ChangeKeypadStatus(void)
7869 InitializeCopyPasteManager();
7871 if (__isInputConnectionBound)
7873 __isInputConnectionBound = false;
7880 _EditPresenter::OnTimerExpired(Timer& timer)
7882 Timer* onTimer = &timer;
7884 if (onTimer == __pCursorTimer)
7886 OnCursorTimerExpired();
7888 else if (onTimer == __pTitleSlidingTimer)
7890 OnTitleSlidingTimerExpired();
7892 else if (onTimer == __pPasswordTimer)
7894 OnPasswordTimerExpired();
7896 else if (onTimer == __pFlickAnimationTimer)
7898 OnFlickTimerExpired();
7905 _EditPresenter::OnEditCopyPasteStatusChanged(CoreCopyPasteStatus status, CoreCopyPasteAction action)
7909 case CORE_COPY_PASTE_ACTION_COPY:
7910 __pEdit->CopyText();
7912 case CORE_COPY_PASTE_ACTION_CUT:
7914 InitializeCopyPasteManager();
7916 case CORE_COPY_PASTE_ACTION_PASTE:
7917 __pEdit->PasteText();
7918 InitializeCopyPasteManager();
7920 case CORE_COPY_PASTE_ACTION_SEARCH:
7921 InitializeCopyPasteManager();
7923 case CORE_COPY_PASTE_ACTION_CLIPBOARD:
7924 __clipboardConnected = true;
7929 __pEdit->Invalidate();
7935 _EditPresenter::InitializeCursor(void)
7939 if (__isCursorDisabled == false && IsCurrentFocused() && __isTextBlocked == false)
7941 FloatRectangle cursorBounds;
7942 CalculateCursorBounds(__textObjectBounds, cursorBounds);
7944 __pCursorVisualElement->SetOpacity(1.0f);
7945 __pCursorVisualElement->SetBounds(cursorBounds);
7947 Canvas* pCanvas = __pCursorVisualElement->GetCanvasN();
7948 if (pCanvas == null)
7952 __isCursorInitialized = false;
7953 DrawCursor(*pCanvas, cursorBounds, __isCursorOpaque);
7955 if (__pInputConnection)
7957 FloatRectangle absoluteEditRectangle;
7958 if (GetCursorBounds(false, absoluteEditRectangle) == E_SUCCESS)
7960 __pInputConnection->SetCursorBounds(absoluteEditRectangle);
7963 __isCursorOpaque = __isCursorOpaque ? false : true;
7967 __previousCursorBounds = cursorBounds;
7972 __pCursorVisualElement->SetOpacity(0);
7975 if (__pInputConnection != null && __isInputConnectionBound == true && !__isCopyPasteManagerExist)
7977 __pInputConnection->SetCursorPosition(__cursorPos);
7984 _EditPresenter::StopCursorTimer(void)
7988 __pCursorTimer->Cancel();
7994 _EditPresenter::StartCursorTimer(void)
7996 result r = E_SUCCESS;
7998 if (__pCursorTimer == null)
8000 __pCursorTimer = new (std::nothrow) Timer;
8001 if (__pCursorTimer == null)
8003 return E_OUT_OF_MEMORY;
8006 r = __pCursorTimer->Construct(*this);
8013 r = __pCursorTimer->Start(EDIT_CURSOR_TIMER_PERIOD);
8024 delete __pCursorTimer;
8025 __pCursorTimer = null;
8031 _EditPresenter::DrawCursor(Canvas& canvas, FloatRectangle& cursorBounds, bool isCursorOpaque)
8033 result r = E_SUCCESS;
8035 if (__isCursorDisabled == false)
8038 GET_COLOR_CONFIG(EDIT::CURSOR_NORMAL, cursorColor);
8040 if (__isCursorInitialized)
8042 cursorBounds.SetPosition(0.0f, 0.0f);
8044 if (canvas.GetBackgroundColor() != cursorColor)
8046 canvas.FillRectangle(cursorColor, cursorBounds);
8051 __pCursorVisualElement->SetOpacity(1.0f);
8055 __pCursorVisualElement->SetOpacity(0);
8060 cursorBounds.SetPosition(0.0f, 0.0f);
8062 canvas.FillRectangle(cursorColor, cursorBounds);
8063 __isCursorInitialized = true;
8069 __pCursorVisualElement->SetOpacity(0);
8076 _EditPresenter::MoveCursor(const FloatRectangle& fromRect, const FloatRectangle& toRect)
8078 if ((__previousCursorBounds.x != fromRect.x) || (__previousCursorBounds.y != fromRect.y) || (__previousCursorBounds.width != fromRect.width) || (__previousCursorBounds.height != fromRect.height))
8083 __pCursorVisualElement->SetOpacity(0);
8085 __pCursorVisualElement->SetBounds(toRect);
8086 Canvas* pCanvas = __pCursorVisualElement->GetCanvasN();
8088 if (pCanvas == null)
8093 if (toRect.y < 0.0f || toRect.y >= __clientBounds.height ||
8094 toRect.x < 0.0f || toRect.x >= __clientBounds.width)
8100 __pCursorVisualElement->SetOpacity(1.0f);
8104 GET_COLOR_CONFIG(EDIT::CURSOR_NORMAL, cursorColor);
8106 pCanvas->FillRectangle(cursorColor, toRect);
8108 __previousCursorBounds = toRect;
8115 _EditPresenter::OnCursorTimerExpired(void)
8117 if (!IsCurrentFocused() && __isCursorDisabled)
8123 FloatRectangle cursorBounds;
8125 if (CalculateCursorBounds(__textObjectBounds, cursorBounds) != E_SUCCESS)
8130 if ((__previousCursorBounds.x != cursorBounds.x) || (__previousCursorBounds.y != cursorBounds.y) || (__previousCursorBounds.width != cursorBounds.width) || (__previousCursorBounds.height != cursorBounds.height))
8132 __previousCursorBounds = cursorBounds;
8135 if (__pCursorVisualElement)
8137 __pCursorVisualElement->SetBounds(cursorBounds);
8138 Canvas* pCanvas = __pCursorVisualElement->GetCanvasN();
8139 if (pCanvas == null)
8144 DrawCursor(*pCanvas, cursorBounds, __isCursorOpaque);
8149 __isCursorOpaque = __isCursorOpaque ? false : true;
8152 if (__pCopyPasteManager)
8154 __pCopyPasteManager->UpdateCopyPasteMagnifier();
8161 _EditPresenter::GetEllipsisPosition(void) const
8163 return __pEdit->GetEllipsisPosition();
8167 _EditPresenter::SetEllipsisPosition(EllipsisPosition position)
8169 result r = E_SUCCESS;
8170 TextObjectEllipsisType ellipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_TAIL;
8171 if (position == ELLIPSIS_POSITION_START)
8173 ellipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_HEAD;
8175 else if (position == ELLIPSIS_POSITION_MIDDLE)
8177 ellipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_MIDDLE;
8180 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
8182 r = __pTextObject->SetTextObjectEllipsisType(ellipsisType);
8183 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Unable to Set ellipsis position.");
8189 _EditPresenter::OnFontInfoRequested(unsigned long& style, float& size)
8191 style = __contentFontStyle;
8192 size = __contentFontSize;
8198 _EditPresenter::OnFontChanged(Font* pFont)
8200 if (!__isFontInitialized)
8205 result r = E_SUCCESS;
8207 r = AdjustFont(*pFont, EDIT_FONT_CHANGE_ALL);
8208 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "Unable to set font.");
8210 __titleFontFaceName = pFont->GetFaceName();
8216 _EditPresenter::GetFont(void) const
8222 _EditPresenter::GetTextSize(void) const
8224 return _CoordinateSystemUtils::ConvertToInteger(__contentFontSize);
8228 _EditPresenter::GetTextSizeF(void) const
8230 return __contentFontSize;
8234 _EditPresenter::GetFontStyle(const Font* pBaseFont) const
8236 unsigned long style = FONT_STYLE_MIN;
8238 if (pBaseFont->IsPlain())
8240 style |= FONT_STYLE_PLAIN;
8242 if (pBaseFont->IsItalic())
8244 style |= FONT_STYLE_ITALIC;
8246 if (pBaseFont->IsBold())
8248 style |= FONT_STYLE_BOLD;
8255 _EditPresenter::SetTextSize(const int size)
8257 result r = E_SUCCESS;
8258 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
8259 r = GetLastResult();
8260 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
8262 r = fontImpl->SetSize(size);
8263 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "SetSize is failed.");
8267 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
8268 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
8269 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
8272 if (IsGuideTextActivated())
8274 r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
8275 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
8278 __contentFontSize = _CoordinateSystemUtils::ConvertToFloat(size);
8283 _EditPresenter::SetTextSize(const float size)
8285 result r = E_SUCCESS;
8286 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
8287 r = GetLastResult();
8288 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
8290 r = fontImpl->SetSize(size);
8291 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "SetSize is failed.");
8295 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
8296 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
8297 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
8300 if (IsGuideTextActivated())
8302 r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
8303 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
8306 __contentFontSize = size;
8311 _EditPresenter::SetFont(const Font& font)
8313 result r = E_SUCCESS;
8315 Font* pFont = _FontImpl::CloneN(const_cast <Font&>(font));
8316 SysTryReturnResult(NID_UI_CTRL, pFont, GetLastResult(), "Unable to create font.");
8322 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
8323 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
8324 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "Unable to set font.");
8327 if (IsGuideTextActivated())
8329 r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
8330 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "Unable to set font.");
8337 _EditPresenter::AdjustFont(Font& font, _EditFontChange fontChange)
8339 result r = E_SUCCESS;
8340 Font* pFont = &font;
8342 _FontImpl* fontImpl = _FontImpl::GetInstance(*pFont);
8343 r = GetLastResult();
8344 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
8346 if (fontChange == EDIT_FONT_CHANGE_TITLE || fontChange == EDIT_FONT_CHANGE_ALL)
8348 if (__pTitleTextObject)
8350 r = fontImpl->SetSize(__titleFontSize);
8351 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "SetSize is failed.");
8353 r = __pTitleTextObject->SetFont(pFont, 0, __pTitleTextObject->GetTextLength());
8354 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
8358 if (fontChange == EDIT_FONT_CHANGE_CONTENT || fontChange == EDIT_FONT_CHANGE_ALL)
8360 r = fontImpl->SetSize(__contentFontSize);
8361 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "SetSize is failed.");
8363 unsigned long style = FONT_STYLE_PLAIN;
8365 if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_BOLD)
8367 style |= FONT_STYLE_BOLD;
8369 if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_ITALIC)
8371 style |= FONT_STYLE_ITALIC;
8374 fontImpl->SetStyle(style);
8376 if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_UNDERLINE)
8378 fontImpl->SetUnderline(true);
8380 if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_STRIKEOUT)
8382 fontImpl->SetStrikeOut(true);
8387 r = __pTextObject->SetFont(pFont, 0, __pTextObject->GetTextLength());
8388 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
8389 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
8392 if (__pGuideTextObject)
8394 r = __pGuideTextObject->SetFont(pFont, 0, __pGuideTextObject->GetTextLength());
8395 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
8401 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
8410 _EditPresenter::GetTitleFontFaceName(void)
8412 return __titleFontFaceName;
8416 _EditPresenter::GetFontType(String& typefaceName, unsigned long& styleMask) const
8418 result r = E_SUCCESS;
8422 typefaceName = __pFont->GetFaceName();
8425 styleMask = __contentTextStyle;
8431 _EditPresenter::SetFontType(const String& typefaceName, unsigned long styleMask)
8433 result r = E_SUCCESS;
8436 IList* systemFontList = Font::GetSystemFontListN();
8437 SysTryReturnResult(NID_UI_CTRL, systemFontList, E_SYSTEM, "Unable to get system font list.\n");
8439 int fontListCount = systemFontList->GetCount();
8440 String tempFontFaceName;
8441 bool isFaceNameAvailable = false;
8443 float textSize = __pFont->GetSizeF();
8444 unsigned long fontStyle = FONT_STYLE_PLAIN;
8446 if (styleMask & TEXT_BOX_TEXT_STYLE_ITALIC)
8448 fontStyle |= FONT_STYLE_ITALIC;
8450 if (styleMask & TEXT_BOX_TEXT_STYLE_BOLD)
8452 fontStyle |= FONT_STYLE_BOLD;
8455 for (int i = 0; i < fontListCount; i++)
8457 tempFontFaceName = *static_cast<String*>(systemFontList->GetAt(i));
8459 pFont = new (std::nothrow) Font;
8460 SysTryCatch(NID_UI_CTRL, pFont, , r = E_OUT_OF_MEMORY, "Unable to get text information.\n");
8461 r = pFont->Construct(tempFontFaceName, fontStyle, textSize);
8462 SysTryCatch(NID_UI_CTRL, !IsFailed(r), , r, "Unable to construct Font.\n");
8464 // check font face name.
8465 if (typefaceName.Equals(pFont->GetFaceName(), true))
8467 isFaceNameAvailable = true;
8475 SysTryCatch(NID_UI_CTRL, isFaceNameAvailable, , r = E_INVALID_ARG, "The unsupported font face name is given.\n");
8477 if (styleMask & TEXT_BOX_TEXT_STYLE_UNDERLINE)
8479 pFont->SetUnderline(true);
8481 if (styleMask & TEXT_BOX_TEXT_STYLE_STRIKEOUT)
8483 pFont->SetStrikeOut(true);
8486 __contentFontStyle = fontStyle;
8487 __contentTextStyle = styleMask;
8491 systemFontList->RemoveAll(true);
8492 delete systemFontList;
8493 systemFontList = null;
8497 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
8498 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
8499 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "Unable to set font.");
8510 systemFontList->RemoveAll(true);
8511 delete systemFontList;
8512 systemFontList = null;
8518 _EditPresenter::GetTextStyle(void) const
8520 return __contentTextStyle;
8524 _EditPresenter::SetTextStyle(unsigned long textStyle)
8526 result r = E_SUCCESS;
8528 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
8529 r = GetLastResult();
8530 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
8532 unsigned long style = FONT_STYLE_PLAIN;
8534 if (textStyle & TEXT_BOX_TEXT_STYLE_BOLD)
8536 style |= FONT_STYLE_BOLD;
8538 if (textStyle & TEXT_BOX_TEXT_STYLE_ITALIC)
8540 style |= FONT_STYLE_ITALIC;
8543 fontImpl->SetStyle(style);
8545 if (textStyle & TEXT_BOX_TEXT_STYLE_UNDERLINE)
8547 fontImpl->SetUnderline(true);
8551 fontImpl->SetUnderline(false);
8554 if (textStyle & TEXT_BOX_TEXT_STYLE_STRIKEOUT)
8556 fontImpl->SetStrikeOut(true);
8560 fontImpl->SetStrikeOut(false);
8565 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
8566 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
8567 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
8570 if (IsGuideTextActivated())
8572 r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
8573 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Unable to set font.");
8576 __contentTextStyle = textStyle;
8582 _EditPresenter::GetGuideText(void) const
8588 _EditPresenter::SetGuideText(const String& guideText)
8590 result r = E_SUCCESS;
8592 int length = guideText.GetLength();
8594 __guideText = String(guideText);
8595 wchar_t* tempString = const_cast<wchar_t*>(__guideText.GetPointer());
8598 if (__pGuideTextObject != null)
8600 delete __pGuideTextObject;
8601 __pGuideTextObject = null;
8604 __pGuideTextObject = new (std::nothrow) TextObject;
8605 if (__pGuideTextObject == null)
8607 return E_OUT_OF_MEMORY;
8609 __pGuideTextObject->Construct();
8610 TextSimple* pSimpleText = new (std::nothrow)TextSimple(tempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
8611 __pGuideTextObject->AppendElement(*pSimpleText);
8613 __pGuideTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
8614 __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
8616 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_GUIDE);
8618 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
8620 __pGuideTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_CHARACTER);
8624 __pGuideTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
8627 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
8633 _EditPresenter::GetTitleText(void) const
8639 _EditPresenter::SetTitleText(const String& title)
8641 result r = E_SUCCESS;
8643 int length = title.GetLength();
8645 __titleText = String(title);
8646 wchar_t* tempString = const_cast<wchar_t*>(__titleText.GetPointer());
8648 if (__pTitleTextObject != null)
8650 delete __pTitleTextObject;
8651 __pTitleTextObject = null;
8654 __pTitleTextObject = new (std::nothrow) TextObject;
8655 if (__pTitleTextObject == null)
8657 return E_OUT_OF_MEMORY;
8659 __pTitleTextObject->Construct();
8660 TextSimple* pSimpleText = new (std::nothrow)TextSimple(tempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
8661 __pTitleTextObject->AppendElement(*pSimpleText);
8663 AdjustRTLTextAlignment(EDIT_TEXT_TYPE_TITLE);
8664 __pTitleTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
8665 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
8666 __pTitleTextObject->Compose();
8668 float titleFontSize = 0.0f;
8669 GET_SHAPE_CONFIG(EDIT::DEFAULT_TITLE_FONT_SIZE, __pEdit->GetOrientation(), titleFontSize);
8671 __titleFontSize = titleFontSize;
8673 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
8677 r = fontImpl->SetSize(__titleFontSize);
8678 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "SetSize is failed.");
8682 r = GetLastResult();
8683 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
8686 __pTitleTextObject->SetFont(__pFont, 0, __pTitleTextObject->GetTextLength());
8688 r = fontImpl->SetSize(__contentFontSize);
8689 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "SetSize is failed.");
8691 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
8697 _EditPresenter::GetTextLineCount(void) const
8699 if (GetTextLength() == 0)
8704 if (__isInitialized == false)
8706 __pTextObject->SetBounds(__textObjectBounds);
8707 __pTextObject->Compose();
8710 return __pTextObject->GetTotalLineCount();
8714 _EditPresenter::GetTextTotalHeight(void) const
8716 if (GetTextLength() == 0)
8721 if (__isInitialized == false)
8723 __pTextObject->SetBounds(__textObjectBounds);
8724 __pTextObject->Compose();
8727 return __pTextObject->GetTotalHeight();
8731 _EditPresenter::GetTextTotalHeightF(void) const
8733 if (GetTextLength() == 0)
8738 if (__isInitialized == false)
8740 __pTextObject->SetBounds(__textObjectBounds);
8741 __pTextObject->Compose();
8744 return __pTextObject->GetTotalHeightF();
8748 _EditPresenter::Resize(void)
8753 __pTextObject->SetBounds(__textObjectBounds);
8754 __pTextObject->Compose();
8755 __isCursorChanged = true;
8756 __pTextObject->ConvertToRowColumn(__cursorPos, __rowCursorIndex, __columnCursorIndex);
8758 __pTextObject->SetFirstDisplayLineIndex(0);
8759 __pTextObject->SetFirstDisplayPositionY(0);
8761 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_NOSCROLL))
8763 if (__pScrollBar == null)
8765 __pScrollBar = _Scroll::CreateScrollN(*__pEdit,
8766 SCROLL_DIRECTION_VERTICAL,
8774 SysTryReturn(NID_UI_CTRL, __pScrollBar != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to create the scroll.");
8775 __pEdit->AttachSystemChild(*__pScrollBar);
8777 __pScrollBar->SetScrollVisibility(false);
8778 __pScrollBar->OnParentBoundsChanged();
8781 __verticalMargin = __pEdit->GetBoundsF().height - __textObjectBounds.height;
8783 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
8785 if (__initialBounds.height > __verticalMargin)
8787 if (__initialBounds.height > __pEdit->GetBoundsF().height)
8789 __prevTotalTextHeight = __initialBounds.height - __verticalMargin;
8793 __prevTotalTextHeight = __pEdit->GetBoundsF().height - __verticalMargin;
8803 _EditPresenter::SetClientBounds(void)
8805 int editStyle = __pEdit->GetEditStyle();
8807 __clientBounds = __pEdit->GetBoundsF();
8808 __clientBounds.x = 0.0f;
8809 __clientBounds.y = 0.0f;
8811 if (!(editStyle & EDIT_STYLE_SINGLE_LINE))
8816 float leftBorder = 0.0f;
8817 float rightBorder = 0.0f;
8818 float topBorder = 0.0f;
8819 float bottomBorder = 0.0f;
8820 float leftMargin = 0.0f;
8821 float rightMargin = 0.0f;
8822 float topMargin = 0.0f;
8823 float bottomMargin = 0.0f;
8824 _ControlOrientation orientation = __pEdit->GetOrientation();
8826 GET_SHAPE_CONFIG(EDIT::FIELD_LEFT_MARGIN, orientation, leftMargin);
8827 GET_SHAPE_CONFIG(EDIT::FIELD_RIGHT_MARGIN, orientation, rightMargin);
8828 GET_SHAPE_CONFIG(EDIT::FIELD_TOP_MARGIN, orientation, topMargin);
8829 GET_SHAPE_CONFIG(EDIT::FIELD_BOTTOM_MARGIN, orientation, bottomMargin);
8831 if (editStyle & EDIT_STYLE_TITLE_LEFT)
8833 float titleWidth = 0.0f;
8834 if (__titleWidth != -1.0f)
8836 titleWidth = __titleWidth;
8840 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_RECT_WIDTH, orientation, titleWidth);
8843 leftBorder = titleWidth;
8844 rightBorder = rightMargin;
8845 topBorder = topMargin;
8846 bottomBorder = bottomMargin;
8848 else if (editStyle & EDIT_STYLE_TITLE_TOP)
8850 result r = E_SUCCESS;
8851 float titletHeight = 0.0f;
8852 float titleTextTopMargin = 0.0f;
8853 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_RECT_HEIGHT, orientation, titletHeight);
8854 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_TOP_MARGIN, orientation, titleTextTopMargin);
8856 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
8857 SysTryReturnVoidResult(NID_UI_CTRL, fontImpl != null, E_SYSTEM, "[E_SYSTEM] fontImpl is null.");
8859 float originalSize = fontImpl->GetSizeF();
8860 float titleFontSize = 0.0f;
8861 GET_SHAPE_CONFIG(EDIT::DEFAULT_TITLE_FONT_SIZE, __pEdit->GetOrientation(), titleFontSize);
8863 r = fontImpl->SetSize(titleFontSize);
8864 SysTryReturnVoidResult(NID_UI_CTRL, !(IsFailed(r)), r, "SetSize is failed.");
8866 if (titletHeight < fontImpl->GetMaxHeightF())
8868 titleTextTopMargin -= (fontImpl->GetMaxHeightF()-titletHeight);
8869 titletHeight = fontImpl->GetMaxHeightF();
8872 r = fontImpl->SetSize(originalSize);
8873 SysTryReturnVoidResult(NID_UI_CTRL, !(IsFailed(r)), r, "SetSize is failed.");
8875 leftBorder = leftMargin;
8876 rightBorder = rightMargin;
8877 topBorder = titletHeight + titleTextTopMargin;
8878 bottomBorder = bottomMargin;
8881 __clientBounds.x = leftBorder;
8882 __clientBounds.y = topBorder;
8883 __clientBounds.width -= leftBorder + rightBorder;
8884 __clientBounds.height -= topBorder + bottomBorder;
8890 _EditPresenter::SetInitialEditFieldBounds(void)
8892 result r = E_SUCCESS;
8893 int editStyle = __pEdit->GetEditStyle();
8894 float bottomMargin = 0.0f;
8895 float textLeftMargin = 0.0f;
8896 float textRightMargin =0.0f;
8897 float textTopMargin = 0.0f;
8898 float textBottomMargin = 0.0f;
8899 float titleTextLeftMargin = 0.0f;
8900 float titleTextRightMargin =0.0f;
8901 float titleTextTopMargin = 0.0f;
8902 float titleTextBottomMargin = 0.0f;
8903 float clearIconWidth = 0.0f;
8904 float titletHeight = 0.0f;
8905 _ControlOrientation orientation = __pEdit->GetOrientation();
8907 GET_SHAPE_CONFIG(EDIT::FIELD_BOTTOM_MARGIN, orientation, bottomMargin);
8908 GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_LEFT_MARGIN, orientation, textLeftMargin);
8909 GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_RIGHT_MARGIN, orientation, textRightMargin);
8910 GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_TOP_MARGIN, orientation, textTopMargin);
8911 GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_BOTTOM_MARGIN, orientation, textBottomMargin);
8912 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_LEFT_MARGIN, orientation, titleTextLeftMargin);
8913 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_RIGHT_MARGIN, orientation, titleTextRightMargin);
8914 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_TOP_MARGIN, orientation, titleTextTopMargin);
8915 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_BOTTOM_MARGIN, orientation, titleTextBottomMargin);
8916 GET_SHAPE_CONFIG(EDIT::CLEAR_ICON_WIDTH, orientation, clearIconWidth);
8917 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_RECT_HEIGHT, orientation, titletHeight);
8919 if (!(editStyle & EDIT_STYLE_SINGLE_LINE))
8924 FloatRectangle bounds = __pEdit->GetBoundsF();
8925 if (editStyle & EDIT_STYLE_TITLE_LEFT)
8927 __textObjectBounds.x = __clientBounds.x + textLeftMargin;
8928 __textObjectBounds.y = __clientBounds.y + textTopMargin;
8929 __textObjectBounds.width = __clientBounds.width - textLeftMargin
8931 __textObjectBounds.height = __clientBounds.height - textTopMargin
8934 __titleBounds.x = titleTextLeftMargin;
8935 __titleBounds.y = titleTextTopMargin;
8936 __titleBounds.width = bounds.width - __clientBounds.width - __titleBounds.x;
8937 __titleBounds.height = __clientBounds.height - titleTextTopMargin
8938 - titleTextBottomMargin;
8940 if (editStyle & EDIT_STYLE_CLEAR)
8942 __textObjectBounds.width -= clearIconWidth;
8945 else if (editStyle & EDIT_STYLE_TITLE_TOP)
8947 __textObjectBounds.x = __clientBounds.x + textLeftMargin;
8948 __textObjectBounds.y = __clientBounds.y;
8949 __textObjectBounds.width = __clientBounds.width - textLeftMargin
8951 __textObjectBounds.height = __clientBounds.height - textBottomMargin;
8953 __titleBounds.x = titleTextLeftMargin;
8955 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
8956 SysTryReturnResult(NID_UI_CTRL, fontImpl != null, E_SYSTEM, "fontImpl is null.");
8958 float originalSize = fontImpl->GetSizeF();
8959 float titleFontSize = 0.0f;
8960 GET_SHAPE_CONFIG(EDIT::DEFAULT_TITLE_FONT_SIZE, __pEdit->GetOrientation(), titleFontSize);
8962 r = fontImpl->SetSize(titleFontSize);
8963 SysTryReturnResult(NID_UI_CTRL, !(IsFailed(r)), r, "SetSize is failed.");
8965 if (titletHeight < fontImpl->GetMaxHeightF())
8967 titleTextTopMargin -= (fontImpl->GetMaxHeightF()-titletHeight);
8970 r = fontImpl->SetSize(originalSize);
8971 SysTryReturnResult(NID_UI_CTRL, !(IsFailed(r)), r, "SetSize is failed.");
8973 __titleBounds.y = titleTextTopMargin;
8974 __titleBounds.width = bounds.width - __titleBounds.x - titleTextRightMargin;
8975 __titleBounds.height = bounds.height - __titleBounds.y - __clientBounds.height
8978 if (editStyle & EDIT_STYLE_CLEAR)
8980 __textObjectBounds.width -= clearIconWidth;
8983 else if ((editStyle & EDIT_STYLE_NORMAL) || (editStyle & EDIT_STYLE_CLEAR))
8985 __textObjectBounds = __clientBounds;
8986 float tempLeftMargin = __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
8987 float tempRightMargin = __pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
8989 if (tempLeftMargin != -1.0f)
8991 __textObjectBounds.x = __clientBounds.x + tempLeftMargin;
8992 __textObjectBounds.width = __clientBounds.width - tempLeftMargin;
8996 __textObjectBounds.x = __clientBounds.x + textLeftMargin;
8997 __textObjectBounds.width = __clientBounds.width - textLeftMargin;
9000 if (tempRightMargin != -1.0f)
9002 __textObjectBounds.width -= tempRightMargin;
9006 __textObjectBounds.width -= textRightMargin;
9009 if (editStyle & EDIT_STYLE_CLEAR)
9011 __textObjectBounds.width -= clearIconWidth;
9013 __textObjectBounds.y = __clientBounds.y + textTopMargin;
9014 __textObjectBounds.height = __clientBounds.height - textTopMargin
9019 float tempLeftMargin = __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
9020 float tempRightMargin = __pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
9021 if (tempLeftMargin != -1.0f)
9023 __textObjectBounds.x = __clientBounds.x + tempLeftMargin;
9024 __textObjectBounds.width = __clientBounds.width - tempLeftMargin;
9028 __textObjectBounds.x = __clientBounds.x + textLeftMargin;
9029 __textObjectBounds.width = __clientBounds.width - textLeftMargin;
9032 if (tempRightMargin != -1.0f)
9034 __textObjectBounds.width -= tempRightMargin;
9038 __textObjectBounds.width -= textRightMargin;
9040 __textObjectBounds.y = __clientBounds.y + textTopMargin;
9041 __textObjectBounds.height = __clientBounds.height - textTopMargin
9045 float textObectMinimumWidth = 0.0f;
9046 float textObjectMinimumHeight = 0.0f;
9047 GET_SHAPE_CONFIG(EDIT::TEXT_OBJECT_MININMUM_WIDTH, orientation, textObectMinimumWidth);
9048 GET_SHAPE_CONFIG(EDIT::TEXT_OBJECT_MININMUM_HEIGHT, orientation, textObjectMinimumHeight);
9050 if (__textObjectBounds.width < textObectMinimumWidth)
9052 __textObjectBounds.width = textObectMinimumWidth;
9055 if (__textObjectBounds.height <= textObjectMinimumHeight)
9057 __textObjectBounds.height = __contentFontSize;
9059 else if (__textObjectBounds.height < __contentFontSize)
9061 __textObjectBounds.y -= (__contentFontSize - __textObjectBounds.height)/2.0f;
9062 __textObjectBounds.height = __contentFontSize;
9065 if (editStyle & EDIT_STYLE_TITLE_LEFT)
9068 if (__titleBounds.width < textObectMinimumWidth)
9070 gap = textObectMinimumWidth - __titleBounds.width;
9071 __titleBounds.width = textObectMinimumWidth;
9072 __textObjectBounds.x += gap;
9074 if (__titleBounds.height < __titleFontSize)
9076 __titleBounds.height = __titleFontSize;
9084 _EditPresenter::SetInitialBounds(void)
9086 result r = E_SUCCESS;
9087 FloatRectangle bounds = __pEdit->GetBoundsF();
9088 int editStyle = __pEdit->GetEditStyle();
9090 if (editStyle & EDIT_STYLE_SINGLE_LINE)
9092 r = SetInitialEditFieldBounds();
9093 __textBoxBounds.x = 0.0f;
9094 __textBoxBounds.y = 0.0f;
9095 __textBoxBounds.width = bounds.width;
9096 __textBoxBounds.height = bounds.height;
9101 float leftMargin = 0.0f;
9102 float rightMargin = 0.0f;
9103 float topMargin = 0.0f;
9104 float bottomMargin = 0.0f;
9105 float textLeftMargin = 0.0f;
9106 float textRightMargin =0.0f;
9107 float textTopMargin = 0.0f;
9108 float textBottomMargin = 0.0f;
9109 float titleRectWidth = 0.0f;
9110 float titleRectHeight = 0.0f;
9111 float titleTextLeftMargin = 0.0f;
9112 float titleTextRightMargin = 0.0f;
9113 float titleTextTopMargin = 0.0f;
9114 float titleTextBottomMargin = 0.0f;
9115 float scrollWidth = 0.0f;
9116 _ControlOrientation orientation = __pEdit->GetOrientation();
9118 GET_SHAPE_CONFIG(EDIT::AREA_LEFT_MARGIN, orientation, leftMargin);
9119 GET_SHAPE_CONFIG(EDIT::AREA_RIGHT_MARGIN, orientation, rightMargin);
9120 GET_SHAPE_CONFIG(EDIT::AREA_TOP_MARGIN, orientation, topMargin);
9121 GET_SHAPE_CONFIG(EDIT::AREA_BOTTOM_MARGIN, orientation, bottomMargin);
9122 GET_SHAPE_CONFIG(EDIT::AREA_TEXT_LEFT_MARGIN, orientation, textLeftMargin);
9123 GET_SHAPE_CONFIG(EDIT::AREA_TEXT_RIGHT_MARGIN, orientation, textRightMargin);
9124 GET_SHAPE_CONFIG(EDIT::AREA_TEXT_TOP_MARGIN, orientation, textTopMargin);
9125 GET_SHAPE_CONFIG(EDIT::AREA_TEXT_BOTTOM_MARGIN, orientation, textBottomMargin);
9126 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_RECT_WIDTH, orientation, titleRectWidth);
9127 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_RECT_HEIGHT, orientation, titleRectHeight);
9128 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_LEFT_MARGIN, orientation, titleTextLeftMargin);
9129 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_RIGHT_MARGIN, orientation, titleTextRightMargin);
9130 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_TOP_MARGIN, orientation, titleTextTopMargin);
9131 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_BOTTOM_MARGIN, orientation, titleTextBottomMargin);
9132 GET_SHAPE_CONFIG(EDIT::AREA_SCROLL_WIDTH, orientation, scrollWidth);
9134 if (editStyle & EDIT_STYLE_TITLE_TOP)
9136 __textBoxBounds.x = leftMargin;
9137 __textBoxBounds.y = titleRectHeight + titleTextTopMargin;
9138 __textBoxBounds.width = bounds.width - leftMargin - rightMargin;
9139 __textBoxBounds.height = bounds.height - titleRectHeight - titleTextTopMargin - bottomMargin;
9141 else if (editStyle & EDIT_STYLE_TITLE_LEFT)
9143 float titleWidth = 0.0f;
9145 if (__titleWidth != -1.0f)
9147 titleWidth = __titleWidth;
9151 titleWidth = titleRectWidth;
9153 __textBoxBounds.x = titleWidth;
9154 __textBoxBounds.y = topMargin;
9155 __textBoxBounds.width = bounds.width - titleWidth - leftMargin;
9156 __textBoxBounds.height = bounds.height - topMargin - bottomMargin;
9160 __textBoxBounds.x = 0.0f;
9161 __textBoxBounds.y = 0.0f;
9162 __textBoxBounds.width = bounds.width;
9163 __textBoxBounds.height = bounds.height;
9166 // setting textBounds
9167 if (editStyle & EDIT_STYLE_TITLE_TOP)
9169 if (__pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN) != -1.0f)
9171 __textObjectBounds.x = __textBoxBounds.x + __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
9172 __textObjectBounds.width = __textBoxBounds.width - __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
9176 __textObjectBounds.x = __textBoxBounds.x + textLeftMargin;
9177 __textObjectBounds.width = __textBoxBounds.width - textLeftMargin;
9180 if (__pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN) != -1.0f)
9182 __textObjectBounds.width -= __pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
9186 __textObjectBounds.width -= textRightMargin;
9190 __textObjectBounds.y = __textBoxBounds.y;
9191 __textObjectBounds.height = __textBoxBounds.height - textBottomMargin;
9195 if (__pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN) != -1.0f)
9197 __textObjectBounds.x = __textBoxBounds.x + __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
9198 __textObjectBounds.width = __textBoxBounds.width - __pEdit->GetHorizontalMarginF(EDIT_TEXT_LEFT_MARGIN);
9202 __textObjectBounds.x = __textBoxBounds.x + textLeftMargin;
9203 __textObjectBounds.width = __textBoxBounds.width - textLeftMargin;
9206 if (__pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN) != -1.0f)
9208 __textObjectBounds.width -= __pEdit->GetHorizontalMarginF(EDIT_TEXT_RIGHT_MARGIN);
9212 __textObjectBounds.width -= textRightMargin;
9216 if (__pEdit->GetVerticalMarginF(EDIT_TEXT_TOP_MARGIN) != -1.0f)
9218 __textObjectBounds.y = __textBoxBounds.y + __pEdit->GetVerticalMarginF(EDIT_TEXT_TOP_MARGIN);
9219 __textObjectBounds.height = __textBoxBounds.height - __pEdit->GetVerticalMarginF(EDIT_TEXT_TOP_MARGIN);
9223 __textObjectBounds.y = __textBoxBounds.y + textTopMargin;
9224 __textObjectBounds.height = __textBoxBounds.height - textTopMargin;
9227 if (__pEdit->GetVerticalMarginF(EDIT_TEXT_BOTTOM_MARGIN) != -1.0f)
9229 __textObjectBounds.height -= __pEdit->GetVerticalMarginF(EDIT_TEXT_BOTTOM_MARGIN);
9233 __textObjectBounds.height -= textBottomMargin;
9237 if (editStyle & EDIT_STYLE_TITLE_TOP)
9239 __titleBounds.x = titleTextLeftMargin;
9240 __titleBounds.y = titleTextTopMargin;
9241 __titleBounds.width = bounds.width - titleTextLeftMargin
9242 - titleTextRightMargin;
9243 __titleBounds.height = bounds.height - __textBoxBounds.height - __titleBounds.y
9247 else if (editStyle & EDIT_STYLE_TITLE_LEFT)
9249 __titleBounds.x = titleTextLeftMargin;
9250 __titleBounds.y = titleTextTopMargin;
9251 __titleBounds.width = bounds.width - __textBoxBounds.width - __titleBounds.x
9252 - titleTextRightMargin;
9253 __titleBounds.height = __textBoxBounds.height - titleTextTopMargin
9254 - titleTextBottomMargin;
9257 if (editStyle & EDIT_STYLE_NOSCROLL)
9259 __isScrollBarVisible = false;
9260 __scrollBarBounds.x = 0.0f;
9261 __scrollBarBounds.y = 0.0f;
9262 __scrollBarBounds.width = 0.0f;
9263 __scrollBarBounds.height = 0.0f;
9267 __scrollBarBounds.width = scrollWidth;
9269 __scrollBarBounds.x = bounds.width - __scrollBarBounds.width;
9270 __scrollBarBounds.y = __textBoxBounds.y + textTopMargin;
9271 __scrollBarBounds.height = __textBoxBounds.height - textTopMargin - textBottomMargin;
9272 if (__scrollBarBounds.height < 0.0f)
9274 __scrollBarBounds.height = 0.0f;
9277 __isScrollBarVisible = true;
9279 if (editStyle & EDIT_STYLE_TITLE_TOP)
9281 __titleBounds.width -= __scrollBarBounds.width;
9285 float textObectMinimumWidth = 0.0f;
9286 GET_SHAPE_CONFIG(EDIT::TEXT_OBJECT_MININMUM_WIDTH, orientation, textObectMinimumWidth);
9288 if (__textObjectBounds.width < textObectMinimumWidth)
9290 __textObjectBounds.width = textObectMinimumWidth;
9293 if (__textObjectBounds.height < __contentFontSize)
9295 __textObjectBounds.height = __contentFontSize;
9302 _EditPresenter::StopTitleSlidingTimer(void)
9304 if (__pTitleSlidingTimer)
9306 __pTitleSlidingTimer->Cancel();
9307 delete __pTitleSlidingTimer;
9308 __pTitleSlidingTimer = null;
9315 _EditPresenter::StartTitleSlidingTimer(void)
9317 result r = E_SUCCESS;
9319 if (__pTitleSlidingTimer == null)
9321 __pTitleSlidingTimer = new (std::nothrow) Timer;
9322 if (__pTitleSlidingTimer == null)
9324 return E_OUT_OF_MEMORY;
9327 r = __pTitleSlidingTimer->Construct(*this);
9333 r = __pTitleSlidingTimer->Start(TITLE_SLIDING_TIME);
9341 StopTitleSlidingTimer();
9346 _EditPresenter::OnTitleSlidingTimerExpired(void)
9348 result r = E_SUCCESS;
9350 if (!IsCurrentFocused())
9352 StopTitleSlidingTimer();
9356 if (__pTitleTextObject->IsChanged())
9358 r = DrawTitleText();
9359 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to draw title text");
9362 Canvas *pTitleTextCanvas = __pTitleTextVisualElement->GetCanvasN();
9363 SysTryReturnResult(NID_UI_CTRL, pTitleTextCanvas, E_SYSTEM, "A system error has occurred. Failed to get canvas of VisualElement");
9365 if (__isTouchPressed)
9367 pTitleTextCanvas->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_PRESSED));
9371 pTitleTextCanvas->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED));
9374 pTitleTextCanvas->Clear();
9375 __pTitleTextObject->DrawWithOffset(*_CanvasImpl::GetInstance(*pTitleTextCanvas));
9376 r = pTitleTextCanvas->Show();
9378 delete pTitleTextCanvas;
9380 r = StartTitleSlidingTimer();
9386 _EditPresenter::ChangePasswordToEchoCharacter(int cursorPos, int textLength)
9388 result r = E_SUCCESS;
9390 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD))
9395 if (__isPasswordVisible)
9400 StartPasswordTimer();
9401 if (IsBlocked() == true)
9403 __pTextObject->SetRange(cursorPos, textLength);
9407 __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), 0);
9414 _EditPresenter::StopPasswordTimer(void)
9416 if (__pPasswordTimer)
9418 __pPasswordTimer->Cancel();
9419 delete __pPasswordTimer;
9420 __pPasswordTimer = null;
9427 _EditPresenter::StartPasswordTimer(void)
9429 result r = E_SUCCESS;
9431 if (__isPasswordVisible)
9436 if (__pPasswordTimer == null)
9438 __pPasswordTimer = new (std::nothrow) Timer;
9439 if (__pPasswordTimer == null)
9441 return E_OUT_OF_MEMORY;
9444 r = __pPasswordTimer->Construct(*this);
9447 StopPasswordTimer();
9452 r = __pPasswordTimer->Start(EDIT_PASSWORD_TIMER_PERIOD);
9455 StopPasswordTimer();
9462 _EditPresenter::OnPasswordTimerExpired(void)
9464 result r = E_SUCCESS;
9466 if (!IsCurrentFocused())
9471 ReplaceTextIntoPasswordHyphenString();
9472 if (__composingTextLength > 0)
9474 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
9475 SysTryReturnResult(NID_UI_CTRL, fontImpl != null, E_SYSTEM, "[E_SYSTEM] fontImpl is null.");
9476 fontImpl->SetUnderline(false);
9477 int composingStartPosition = GetCursorPosition()-__composingTextLength;
9478 __pTextObject->SetFont(__pFont, composingStartPosition, composingStartPosition+__composingTextLength);
9481 __isCursorChanged = true;
9483 __pEdit->Invalidate();
9489 _EditPresenter::ReplaceTextIntoPasswordHyphenString(void)
9491 result r = E_SUCCESS;
9493 if (__isPasswordVisible)
9498 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
9500 if (GetTextLength() > 0)
9502 ChangePasswordToEchoCharacter(__pTextBuffer, __echoChar);
9503 __isCursorChanged = true;
9511 _EditPresenter::ChangePasswordToEchoCharacter(wchar_t* dspStrBuffer, wchar_t echoChar)
9513 result r = E_SUCCESS;
9515 if (__isPasswordVisible)
9520 int bufferLength = GetTextLength();
9522 for (int i = 0; i < bufferLength && i < EDIT_PASSWORD_BUFFER_MAX - 1; i++)
9524 dspStrBuffer[i] = echoChar;
9526 dspStrBuffer[bufferLength] = null;
9527 __isCursorChanged = true;
9533 _EditPresenter::ChangePasswordToPlainText(void)
9535 result r = E_SUCCESS;
9537 if (__isPasswordVisible == false)
9542 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
9544 int textLength = GetTextLength();
9545 if ((textLength > 0) && (textLength <= __limitLength))
9547 wchar_t* tempString = const_cast<wchar_t*>(__pTextString->GetPointer());
9548 for (int i = 0; i < textLength; i++)
9550 __pTextBuffer[i] = tempString[i];
9552 __pTextBuffer[textLength] = 0;
9553 __pTextObject->RemoveAll();
9554 TextSimple* pSimpleText = new (std::nothrow)TextSimple(__pTextBuffer, textLength,TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, __pFont);
9555 __pTextObject->AppendElement(*pSimpleText);
9556 __pTextObject->Compose();
9557 __isCursorChanged = true;
9565 _EditPresenter::SetAutoResizingEnabled(bool enable)
9567 return __pEditModel->SetAutoResizingEnabled(enable);
9571 _EditPresenter::IsAutoResizingEnabled(void) const
9573 return __pEditModel->IsAutoResizingEnabled();
9577 _EditPresenter::CalculateFlexibleHeightF(void)
9579 float height = 0.0f;
9580 float expectedEditHeight = __pTextObject->GetTotalHeightF() + __verticalMargin;
9581 int lineCount = __pTextObject->GetTotalLineCount();
9583 if (__pTextObject->GetTotalHeight())
9585 if ((lineCount >= MAX_LINE_NUMBER) && (GetMaxLineCount() > MAX_LINE_NUMBER))
9587 height = MAX_LINE_NUMBER * __pTextObject->GetLineHeightAtF(0) + __verticalMargin;
9591 float maxHeight = CalculateMaximumFlexibleHeight();
9593 //If InitialBounds is more than expectedEdit height, set flexible height as initial height
9594 if (expectedEditHeight < __initialBounds.height)
9596 height = __initialBounds.height;
9598 else if (expectedEditHeight >= maxHeight)
9604 height = expectedEditHeight;
9609 height = __initialBounds.height;
9616 _EditPresenter::AdjustFlexibleHeight(void)
9618 result r = E_SUCCESS;
9620 if (__isFlexibleHeightFrozen == true)
9625 __pTextObject->Compose();
9627 if (__prevTotalTextHeight == __pTextObject->GetTotalHeightF()) // if text height has not changed.
9629 __prevTotalTextHeight = __pTextObject->GetTotalHeightF();
9634 FloatRectangle bounds = __pEdit->GetBoundsF();
9635 float calculateHeight = CalculateFlexibleHeightF();
9637 FloatDimension flexHeightDim = CoordinateSystem::AlignToDevice(FloatDimension(0, calculateHeight));
9638 if (bounds.height != flexHeightDim.height)
9640 bounds.height = flexHeightDim.height;
9641 __prevTotalTextHeight = __pTextObject->GetTotalHeightF();
9643 FloatRectangle editBounds = CoordinateSystem::AlignToDevice(bounds);
9644 return SetFlexBounds(editBounds);
9646 __prevTotalTextHeight = __pTextObject->GetTotalHeight();
9651 _EditPresenter::SetFlexBounds(const FloatRectangle& bounds)
9653 result r = E_SUCCESS;
9655 _ExpandableEditAreaEventStatus expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_ADDED;
9656 if (__pEdit->GetBoundsF().height > bounds.height)
9658 expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_REMOVED;
9660 else if (__pEdit->GetBoundsF().height < bounds.height)
9662 expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_ADDED;
9665 _VisualElement* pVisualElement = __pEdit->GetVisualElement();
9666 SysTryReturnResult(NID_UI_CTRL, pVisualElement, E_SYSTEM, "A system error has occurred. Unable to get root visual element.");
9668 pVisualElement->SetAnimationProvider(__pEditVEDelegator);
9669 pVisualElement->SetImplicitAnimationEnabled(true);
9671 //Modify InitialBounds only on User calls and on Orientation change
9672 if (!((__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) == false))
9674 __updateInitialBounds = false;
9677 __pEdit->SetBounds(bounds);
9678 __updateInitialBounds = true;
9682 __pEdit->Invalidate();
9684 pVisualElement->SetImplicitAnimationEnabled(false);
9686 __prevTotalTextHeight = __pTextObject->GetTotalHeightF();
9687 __pEdit->SendExpandableEditAreaEvent(expandableEditAreaStatus, __pTextObject->GetTotalLineCount());
9693 _EditPresenter::CalculateMaximumFlexibleHeight(void)
9695 float maxHeight = 0.0f;
9696 int maximumFlexibleLineNumber = GetMaxLineCount();
9698 if (maximumFlexibleLineNumber > 0) // if max line number is set.
9700 maxHeight = maximumFlexibleLineNumber * __pTextObject->GetLineHeightAtF(0) + __verticalMargin;
9702 FloatDimension dim = __pEdit->GetMaximumSizeF();
9703 if (maxHeight > dim.height)
9705 maxHeight = dim.height;
9713 _EditPresenter::GetKeypadBoundsEx(Tizen::Graphics::FloatRectangle& bounds) const
9715 bounds.x = __keypadBounds.x;
9716 bounds.y = __keypadBounds.y;
9717 bounds.width = __keypadBounds.width;
9718 bounds.height = __keypadBounds.height;
9723 _EditPresenter::GetParentForm(void)
9730 if (__pParentForm == null)
9732 result r = E_SUCCESS;
9734 _Form* pForm = null;
9735 _Control* pControlCore = null;
9737 for (pControlCore = __pEdit->GetParent(); pForm == null; pControlCore = pControlCore->GetParent())
9739 if (pControlCore == null)
9745 pForm = dynamic_cast<_Form*>(pControlCore);
9755 _EditPresenter::GetParentPanel(void) const
9757 return __pParentPanel;
9761 _EditPresenter::SetKeypadCommandButtonVisible(bool visible)
9763 __isKeypadCommandButtonVisible = visible;
9768 _EditPresenter::SetKeypadCommandButton(CommandButtonPosition position, const String& text, int actionId)
9770 result r = E_SUCCESS;
9771 FooterItem footerItem;
9772 footerItem.Construct(actionId);
9773 footerItem.SetText(text);
9774 __isKeypadCommandButtonUserSetting = true;
9776 __pEditModel->SetCommandButtonItem(position, actionId, text);
9777 if (__pCommandButton)
9779 _Button* pButton = __pCommandButton->GetItem(static_cast<int>(position));
9782 pButton->SetActionId(actionId);
9783 pButton->SetText(text);
9791 _EditPresenter::GetKeypadCommandButton(void) const
9793 return __pCommandButton;
9797 _EditPresenter::AddActionEventListener(const _IActionEventListener& listener)
9801 if (__pCommandButton)
9803 __pCommandButton->AddActionEventListener(listener);
9806 __pActionEventListener = const_cast<_IActionEventListener*>(&listener);
9812 _EditPresenter::RemoveActionEventListener(const _IActionEventListener& listener)
9816 if (__pCommandButton)
9818 __pCommandButton->RemoveActionEventListener(listener);
9821 __pActionEventListener = null;
9827 _EditPresenter::SetTextBounds(Rectangle& bounds)
9829 __textObjectBounds = _CoordinateSystemUtils::ConvertToFloat(bounds);
9830 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
9832 __pTextObject->SetBounds(__textObjectBounds);
9833 __pTextObject->Compose();
9839 _EditPresenter::SetTextBounds(FloatRectangle& bounds)
9841 __textObjectBounds = bounds;
9842 if (__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN)
9844 __pTextObject->SetBounds(__textObjectBounds);
9845 __pTextObject->Compose();
9851 _EditPresenter::GetTextBoundsF(void) const
9853 return __textObjectBounds;
9857 _EditPresenter::GetTextBounds(void) const
9859 return _CoordinateSystemUtils::ConvertToInteger(__textObjectBounds);
9863 _EditPresenter::IsKeypadCommandButtonVisible(void) const
9865 return __isKeypadCommandButtonVisible;
9869 _EditPresenter::GetKeypadCommandButtonText(CommandButtonPosition position) const
9871 return __pEditModel->GetKeypadCommandButtonText(position);
9875 _EditPresenter::GetKeypadCommandButtonActionId(CommandButtonPosition position) const
9877 return __pEditModel->GetKeypadCommandButtonActionId(position);
9881 _EditPresenter::DrawScrollBar(void)
9883 result r = E_SUCCESS;
9885 if (__pScrollBar == null)
9890 float totalHeight = __pTextObject->GetTotalHeightF();
9891 float dspHeight = __textObjectBounds.height;
9892 float firstDisplayY = __pTextObject->GetFirstDisplayPositionYF();
9894 if (totalHeight <= dspHeight)
9896 if (__prevTotalTextHeight != 0.0f && __prevTotalTextHeight == totalHeight) // flexible edit's case
9901 __pScrollBar->SetScrollRange(1, 1);
9902 __pScrollBar->SetScrollPosition(0.0f);
9904 __isScrollBarVisible = false;
9905 __previousScrollBarPos = 0.0f;
9906 __previousScrollBarMaxPos = 0.0f;
9910 if (firstDisplayY > 0)
9912 __pScrollBar->SetScrollRange(dspHeight, totalHeight);
9913 __pScrollBar->SetScrollPosition(firstDisplayY);
9914 __previousScrollBarMaxPos = totalHeight - dspHeight;
9918 __pScrollBar->SetScrollRange(dspHeight, totalHeight);
9919 __pScrollBar->SetScrollPosition(0.0f);
9920 __previousScrollBarMaxPos = 0.0f;
9923 if (__pScrollBar->GetScrollVisibility())
9925 __isScrollBarVisible = true;
9928 __previousScrollBarPos = firstDisplayY;
9935 _EditPresenter::FadeOutScrollBar(void)
9939 __pScrollBar->SetScrollVisibility(false);
9941 __isScrollBarVisible = false;
9947 _EditPresenter::InitializeFlickAnimation(void)
9949 result r = E_SUCCESS;
9951 if (__pFlickAnimation == null)
9953 __pFlickAnimation = new (std::nothrow) _FlickAnimation;
9956 // Init Flick Animation Config
9957 if (__pFlickAnimation)
9960 float height = 0.0f;
9961 Tizen::Graphics::FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
9962 Tizen::Graphics::FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
9963 if (__pEdit->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
9965 width = portraitSize.width;
9966 height = portraitSize.height;
9970 width = landscapeSize.width;
9971 height = landscapeSize.height;
9974 __pFlickAnimation->SetSizeInformation(width, height, DEVICE_SIZE_HORIZONTAL, DEVICE_SIZE_VERTICAL);
9975 __pFlickAnimation->SetSensitivity(FLICK_ANIMATION_FPS_PANEL, FLICK_ANIMATION_SENSITIVITY_PANEL);
9982 if (__pFlickAnimationTimer == null)
9984 __pFlickAnimationTimer = new (std::nothrow) Timer;
9985 if (__pFlickAnimationTimer == null)
9987 r = E_OUT_OF_MEMORY;
9991 r = __pFlickAnimationTimer->Construct(*this);
9994 delete __pFlickAnimationTimer;
10006 _EditPresenter::StartFlickAnimation(const FloatPoint& flickPosition, int flickTime)
10008 // delete Scroll Fadeout Timer
10014 if (__textObjectBounds.height >= __pTextObject->GetTotalHeightF())
10019 if (InitializeFlickAnimation() != E_SUCCESS)
10024 //We must check the flick animation about float conversion work at later
10026 // Initialize flick animation
10030 __pFlickAnimation->CalculateInitializeVelocity(_CoordinateSystemUtils::ConvertToInteger(flickPosition.x), _CoordinateSystemUtils::ConvertToInteger(flickPosition.y), flickTime, &velocityX, &velocityY);
10032 if (Math::Abs(flickPosition.x) > Math::Abs(flickPosition.y))
10034 __pFlickAnimation->InitializeFlickAmount(velocityX);
10038 __pFlickAnimation->InitializeFlickAmount(velocityY);
10041 return StartFlickTimer(velocityY, velocityX);
10045 _EditPresenter::StartFlickTimer(int flickVelocityX, int flickVelocityY)
10047 if (__pFlickAnimation)
10049 if (ScrollContentsOnFlick() != E_SUCCESS)
10058 if (__pFlickAnimationTimer)
10060 if (__pFlickAnimationTimer->Start(EDIT_FLICK_SCROLL_TIMER_INTERVAL) != E_SUCCESS)
10076 _EditPresenter::ScrollContentsOnFlick(void)
10078 //We must check the flick animation about float conversion work at later
10080 if (__pFlickAnimation)
10082 int moveAmountX = 0;
10083 int moveAmountY = 0;
10084 __pFlickAnimation->CalculateNextMove(&moveAmountX, &moveAmountY);
10087 if (ScrollOnFlick(_CoordinateSystemUtils::ConvertToFloat(-moveAmountY*EDIT_FLICK_SCROLL_MOVE_AMOUNT_MULTIPLIER)))
10099 _EditPresenter::ScrollOnFlick(float moveDistanceY)
10101 if (moveDistanceY == 0)
10103 FadeOutScrollBar();
10107 if (!__pScrollBar->GetScrollVisibility())
10109 __pScrollBar->SetScrollVisibility(true);
10112 ScrollContents(moveDistanceY);
10118 _EditPresenter::SetCursorEnabled(bool enable)
10120 __isCursorOpaque = enable;
10126 _EditPresenter::IsCursorEnabled(void) const
10128 return __isCursorOpaque;
10132 _EditPresenter::StopFlickTimer(void)
10134 if (__pFlickAnimationTimer != null)
10136 __pFlickAnimationTimer->Cancel();
10137 delete __pFlickAnimationTimer;
10138 __pFlickAnimationTimer = null;
10145 _EditPresenter::OnFlickTimerExpired(void)
10147 result r = E_SUCCESS;
10149 if (__pFlickAnimationTimer)
10152 if (__pFlickAnimationTimer->Start(EDIT_FLICK_SCROLL_TIMER_INTERVAL) != E_SUCCESS)
10159 if (ScrollContentsOnFlick() != E_SUCCESS)
10164 FadeOutScrollBar();
10178 _EditPresenter::SetScrollBarVisible(bool enable)
10180 __isScrollBarVisible = enable;
10186 _EditPresenter::SetScrollBarBounds(const FloatRectangle& bounds)
10188 __scrollBarBounds = bounds;
10194 _EditPresenter::GetDisplayScrollBoundsF(void) const
10196 return __scrollBarBounds;
10200 _EditPresenter::GetInitialBoundsF(void) const
10202 return __initialBounds;
10206 _EditPresenter::SetPreviousScrollBarPosition(int position)
10208 __previousScrollBarPos = _CoordinateSystemUtils::ConvertToFloat(position);
10214 _EditPresenter::SetPreviousScrollBarPosition(float position)
10216 __previousScrollBarPos = position;
10222 _EditPresenter::GetPreviousScrollPosition(void) const
10224 return _CoordinateSystemUtils::ConvertToInteger(__previousScrollBarPos);
10228 _EditPresenter::GetPreviousScrollPositionF(void) const
10230 return __previousScrollBarPos;
10234 _EditPresenter::SetMaximumPreviousScrollBarPosition(int position)
10236 __previousScrollBarMaxPos = _CoordinateSystemUtils::ConvertToFloat(position);
10242 _EditPresenter::SetMaximumPreviousScrollBarPosition(float position)
10244 __previousScrollBarMaxPos = position;
10250 _EditPresenter::GetScrollBar(void) const
10252 return __pScrollBar;
10256 _EditPresenter::GetTextObject(void) const
10258 return __pTextObject;
10262 _EditPresenter::SetAutoShrinkModeEnabled(bool enable)
10264 __isAutoShrinkEnabled = enable;
10270 _EditPresenter::IsAutoShrinkModeEnabled(void) const
10272 return __isAutoShrinkEnabled;
10276 _EditPresenter::GetEditView(void) const
10282 _EditPresenter::InitializeParentPanel(void)
10284 if (__pParentPanel == null)
10286 _ScrollPanel* pScrollPanel = null;
10287 _Control* pControlCore = null;
10289 for (pControlCore = __pEdit->GetParent(); pScrollPanel == null; pControlCore = pControlCore->GetParent())
10291 if (pControlCore == null)
10296 pScrollPanel = dynamic_cast<_ScrollPanel*>(pControlCore);
10299 __pParentPanel = pScrollPanel;
10309 _EditPresenter::ScrollPanelToTop(bool show)
10311 if (!__pParentPanel)
10314 FloatRectangle editAbsoluteBounds = __pEdit->GetAbsoluteBoundsF();
10315 FloatRectangle panelAbsoluteBounds = __pParentPanel->GetAbsoluteBoundsF();
10316 float scrollPosition = __pParentPanel->GetScrollPosition() + (editAbsoluteBounds.y - panelAbsoluteBounds.y);
10318 __pParentPanel->SetScrollPosition(scrollPosition);
10322 __pParentPanel->Invalidate();
10329 _EditPresenter::ScrollPanelToCursorPosition(bool show)
10331 if (!__pParentPanel)
10334 result r = E_SUCCESS;
10336 FloatRectangle absCursorBounds(0.0f, 0.0f, 0.0f, 0.0f);
10337 r = CalculateAbsoluteCursorBounds(__cursorPos, absCursorBounds);
10339 if (r != E_SUCCESS)
10344 FloatRectangle absPanelRect = __pParentPanel->GetAbsoluteBoundsF();
10345 float panelHeight = __pParentPanel->GetBoundsF().height;
10347 float scrollPosition = __pParentPanel->GetScrollPosition();
10348 float cursorBoundsY = absCursorBounds.y - absPanelRect.y;
10350 float topYCompared = 0.0f;
10351 float bottomYCompared = panelHeight;
10353 if (__textObjectBounds.height < absCursorBounds.height)
10355 absCursorBounds.height = __textObjectBounds.height;
10358 float upSideGap = topYCompared - cursorBoundsY;
10359 float downSideGap = (upSideGap > 0.0f) ? 0.0f : cursorBoundsY + absCursorBounds.height - bottomYCompared;
10361 if (upSideGap > 0.0f || downSideGap > 0.0f)
10364 float topTextMargin = __textObjectBounds.y;
10365 float bottomTextMargin = __pEdit->GetBoundsF().height - __textObjectBounds.y - __textObjectBounds.height;
10367 if (upSideGap > 0.0f)
10369 gap = scrollPosition - (upSideGap + topTextMargin);
10373 gap = scrollPosition + (downSideGap + bottomTextMargin);
10376 __pParentPanel->SetScrollPosition(gap);
10378 __pParentPanel->Invalidate();
10385 _EditPresenter::SetSearchBarFlag(bool enabled)
10387 __isSearchBar = enabled;
10393 _EditPresenter::GetSearchBarFlag(void) const
10395 return __isSearchBar;
10399 _EditPresenter::SetFocused(void)
10401 bool focused = true;
10402 if (__pParentPanel)
10404 _Window* pTop = __pParentPanel->GetRootWindow();
10407 if ((pTop->GetFocusControl(__pEdit) != __pEdit) && __pEdit->IsFocused() == false)
10413 else if (__pEdit->IsFocused() == false)
10418 if (focused == false)
10420 __pEdit->SetFocused();
10427 _EditPresenter::GetWordPosition(int cursorPos, int& startPos, int& endPos) const
10429 int textLength = GetTextLength();
10430 bool isDetected = false;
10432 if (cursorPos >= textLength && cursorPos > 0)
10438 if (IsDelimiter(__pTextBuffer[cursorPos]) && cursorPos > 0)
10444 for (int i = cursorPos; i >= 0; i--)
10446 if (IsDelimiter(__pTextBuffer[i]))
10454 if (isDetected == false)
10460 isDetected = false;
10463 for (int i = cursorPos; i < textLength; i++)
10465 if (IsDelimiter(__pTextBuffer[i]))
10473 if (isDetected == false)
10475 endPos = textLength;
10478 if (startPos > endPos)
10480 int temp = startPos;
10488 _EditPresenter::GetTextImageRangeAt(int postion, int& startPosition, int& endPosition) const
10490 int length = GetTextLength();
10491 startPosition = -1;
10494 SysTryReturnResult(NID_UI_CTRL, postion >= 0 && postion <= length, E_OUT_OF_RANGE, "The given index is out-of-range.");
10496 _Text::TextElement* pTextElement = __pTextObject->GetElementAtTextIndex(postion);
10497 const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
10498 if (pSimpleText != null && pSimpleText->GetBitmap() != null)
10500 startPosition = pSimpleText->GetTextOffset();
10501 endPosition = startPosition + pSimpleText->GetTextLength();
10505 return E_OBJ_NOT_FOUND;
10509 _EditPresenter::IsDelimiter(wchar_t character) const
10515 case 0x0A: // NLine Feed
10518 case 0x0D: // Carriage Return
10521 case 0x20: // Space
10532 _EditPresenter::InitializeCopyPasteManager(void)
10534 bool releaseBlock = true;
10536 if (__pCopyPasteManager)
10538 releaseBlock = __pCopyPasteManager->GetTextBlockReleaseFlag();
10539 delete __pCopyPasteManager;
10540 __pCopyPasteManager = null;
10543 if (IsBlocked() == true && releaseBlock)
10545 ReleaseTextBlock();
10546 __pEdit->Invalidate();
10549 __isCopyPasteManagerExist = false;
10550 __isCopyPastePopupMoving = false;
10556 _EditPresenter::IsCopyPasteManagerExist(void) const
10558 return __isCopyPasteManagerExist;
10562 _EditPresenter::GetTextAreaBoundsF(void) const
10564 return __textObjectBounds;
10568 _EditPresenter::GetTitleBoundsF(void) const
10570 return __titleBounds;
10574 _EditPresenter::GetClearIconBoundsF(void) const
10576 return __clearIconBounds;
10580 _EditPresenter::FinishTextComposition(void)
10582 if (__isInputConnectionBound && __isTextComposing)
10584 __pEdit->SetTextEventEnabled(false);
10585 __pInputConnection->FinishTextComposition();
10586 __isTextComposing = false;
10587 __composingTextLength = 0;
10588 __pEdit->SetTextEventEnabled(true);
10595 _EditPresenter::GetTextCompositionState(void) const
10597 return __isTextComposing;
10601 _EditPresenter::IsCopyPastePopup(const _Control& control) const
10603 if (__pCopyPasteManager)
10605 return __pCopyPasteManager->IsCopyPastePopup(control);
10612 _EditPresenter::IsCopyPasteHandle(const _Control& control) const
10614 if (__pCopyPasteManager)
10616 return __pCopyPasteManager->IsCopyPasteHandle(control);
10623 _EditPresenter::SetCursorChangedFlag(bool enabled)
10625 __isCursorChanged = enabled;
10631 _EditPresenter::GetCursorChangedFlag(void) const
10633 return __isCursorChanged;
10637 _EditPresenter::SetEditGroupStyle(GroupStyle groupStyle)
10639 __groupStyle = groupStyle;
10645 _EditPresenter::PostInternalEvent(const Tizen::Base::String& type)
10649 ArrayList* pArgs = new (std::nothrow) ArrayList();
10650 SysTryReturnVoidResult(NID_UI_CTRL, pArgs != null, E_SYSTEM, "[E_SYSTEM] pArgs is null.");
10652 result r = E_SYSTEM;
10653 r = pArgs->Construct();
10654 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to construct pArgs");
10656 String* pType = new (std::nothrow) String(type);
10657 SysTryReturnVoidResult(NID_UI, pType, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
10659 r = pArgs->Add(*pType);
10660 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to add type to pArgs");
10662 _UiNotificationEvent event(__pEdit->GetHandle(), pArgs);
10663 r = _UiEventManager::GetInstance()->PostEvent(event);
10664 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to send event");
10670 _EditPresenter::ReleaseCopyPastePopup(void)
10672 if (__pCopyPasteManager)
10674 return __pCopyPasteManager->ReleaseCopyPastePopup();
10679 _EditPresenter::IsCopyPastePopupExist(void) const
10681 if (__pCopyPasteManager)
10683 if (__pCopyPasteManager->GetCopyPastePopup())
10696 _EditPresenter::IsCopyPasteHandleExist(void) const
10698 if (__pCopyPasteManager)
10700 return __pCopyPasteManager->IsCopyPasteHandleExist();
10706 _EditPresenter::IsUnsupportedChracterExist(const KeypadStyle keypadStyle, const Tizen::Base::String& text)
10708 const int numberOfCharOnNumOnlyStyle = 10;
10709 const int numberOfCharOnPhoneNumStyle = 13;
10710 const int numberOfCharOnIpStyle = 18;
10712 const wchar_t* TempKey = null;
10713 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};
10714 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*/,
10715 0x2a/***/, 0x2b/*+*/, 0x23/*#*/, 0};
10716 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*/,
10717 0x3a/*:*/, 0x2e/*.*/, 0x61/*a*/, 0x62/*b*/, 0x63/*c*/, 0x64/*d*/, 0x65/*e*/, 0x66/*f*/, 0};
10718 bool isSupportedCharacterExist = false;
10719 int supportedCharacterCount = 0;
10721 switch (keypadStyle)
10723 case KEYPAD_STYLE_NUMBER:
10724 supportedCharacterCount = numberOfCharOnNumOnlyStyle;
10725 TempKey = characterOnNumOnlyStyle;
10727 case KEYPAD_STYLE_PHONE_NUMBER:
10728 supportedCharacterCount = numberOfCharOnPhoneNumStyle;
10729 TempKey = characterOnPhoneNumStyle;
10731 case KEYPAD_STYLE_IP_V4:
10732 supportedCharacterCount = numberOfCharOnIpStyle;
10733 TempKey = characterOnIPStyle;
10739 if (text.GetLength() < 1)
10744 for (int i = 0; i < text.GetLength(); i++)
10746 isSupportedCharacterExist = false;
10747 wchar_t checkChar =0;
10748 if ( text.GetCharAt(i, checkChar) != E_SUCCESS)
10752 for (int j = 0; j < supportedCharacterCount ; j++)
10754 if (TempKey[j] == checkChar)
10756 isSupportedCharacterExist = true;
10760 if (!isSupportedCharacterExist)
10770 _EditPresenter::SetBlockRangeWithShiftArrowkey(_KeyCode keyCode)
10774 if (IsBlocked() == true)
10776 GetBlockRange(start, end);
10780 if (__textBlockMoveLeft)
10784 SetBlockRange(--start, end);
10789 if (start < end - 1)
10791 SetBlockRange(start, --end);
10793 else if (start == end - 1)
10795 ReleaseTextBlock();
10796 SetCursorPosition(start);
10801 if (__textBlockMoveLeft)
10803 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(start);
10805 if (curCursorLine > 0)
10807 int offset = start - __pTextObject->GetFirstTextIndexAt(curCursorLine);
10808 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine-1);
10809 start = offset + firstTextIndex;
10810 int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
10811 if (offset > textLength)
10813 start = firstTextIndex+textLength-1;
10815 SetBlockRange(start, end);
10820 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(end);
10822 if (curCursorLine > 0)
10824 int offset = end - __pTextObject->GetFirstTextIndexAt(curCursorLine);
10825 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine-1);
10826 end = offset + firstTextIndex;
10827 int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
10828 if (offset > textLength)
10830 end = firstTextIndex+textLength;
10837 __textBlockMoveLeft = true;
10838 SetBlockRange(start, end);
10840 else if (start == end)
10842 ReleaseTextBlock();
10843 SetCursorPosition(end);
10847 SetBlockRange(start, end);
10853 if (__textBlockMoveLeft)
10855 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(start);
10856 int totalLine = __pTextObject->GetTotalLineCount();
10857 if (curCursorLine < totalLine - 1)
10859 int offset = start - __pTextObject->GetFirstTextIndexAt(curCursorLine);
10860 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
10861 start = offset + firstTextIndex;
10862 int textLength = __pTextObject->GetTextLengthAt(curCursorLine+1);
10863 if (offset > textLength)
10865 start = firstTextIndex+textLength;
10873 __textBlockMoveLeft = false;
10874 SetBlockRange(start, end);
10876 else if (start == end)
10878 ReleaseTextBlock();
10879 SetCursorPosition(end);
10883 SetBlockRange(start, end);
10889 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(end);
10890 int totalLine = __pTextObject->GetTotalLineCount();
10891 if (curCursorLine < totalLine - 1)
10893 int offset = end - __pTextObject->GetFirstTextIndexAt(curCursorLine);
10894 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
10895 end = offset + firstTextIndex;
10896 int textLength = __pTextObject->GetTextLengthAt(curCursorLine+1);
10897 if (offset > textLength)
10899 end = firstTextIndex+textLength;
10901 SetBlockRange(start, end);
10906 if (__textBlockMoveLeft)
10908 if (start + 1 < end)
10910 SetBlockRange(++start, end);
10912 else if (start + 1 == end)
10914 ReleaseTextBlock();
10915 SetCursorPosition(end);
10920 if (end + 1 <= GetTextLength())
10922 SetBlockRange(start, ++end);
10932 if (__textBlockMoveLeft)
10934 __pTextObject->SetFirstDisplayLineIndexFromTextIndex(start);
10936 SetCursorChangedFlag(!__textBlockMoveLeft);
10945 if (__cursorPos > 0)
10947 start = __cursorPos - 1;
10949 SetBlockRange(start, end);
10950 __textBlockMoveLeft = true;
10955 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
10957 if (curCursorLine > 0)
10959 int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
10960 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine-1);
10961 start = offset + firstTextIndex;
10962 int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
10963 if (offset > textLength)
10965 start = firstTextIndex+textLength -1;
10968 SetBlockRange(start, end);
10969 __textBlockMoveLeft = true;
10974 if (GetTextLength() >= __cursorPos + 1)
10976 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
10977 int totalLine = __pTextObject->GetTotalLineCount();
10978 if (curCursorLine < totalLine - 1)
10980 int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
10981 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
10982 end = offset + firstTextIndex;
10983 int textLength = __pTextObject->GetTextLengthAt(curCursorLine+1);
10984 if (offset > textLength)
10986 end = firstTextIndex+textLength;
10989 else if (curCursorLine == totalLine - 1)
10991 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine);
10992 int textLength = __pTextObject->GetTextLengthAt(curCursorLine);
10993 end = firstTextIndex + textLength;
10995 start = __cursorPos;
10996 SetBlockRange(start, end);
10997 __textBlockMoveLeft = false;
11001 if (GetTextLength() >= __cursorPos + 1)
11003 start = __cursorPos;
11004 end = __cursorPos + 1;
11005 SetBlockRange(start, end);
11006 __textBlockMoveLeft = false;
11016 __textBlockMoving = true;
11021 _EditPresenter::SetBlockRangeWithCtrlShiftArrowkey(_KeyCode keyCode)
11025 int originalStart = 0;
11026 int originalEnd = 0;
11027 if (IsBlocked() == true)
11029 GetBlockRange(start, end);
11033 if (__textBlockMoveLeft)
11037 originalStart = start;
11039 GetWordPosition(start-1, start, end);
11040 SetBlockRange(start, originalEnd);
11045 originalStart = start;
11047 GetWordPosition(end, start, end);
11048 if (originalEnd == start)
11050 GetWordPosition(start-1, start, end);
11053 if (originalStart < start)
11055 SetBlockRange(originalStart, start);
11057 else if (originalStart > start)
11059 SetBlockRange(start, originalStart);
11060 __textBlockMoveLeft = true;
11062 else if (originalStart == start)
11064 ReleaseTextBlock();
11065 SetCursorPosition(start);
11066 __textBlockMoveLeft = true;
11071 if (__textBlockMoveLeft)
11073 originalStart = start;
11075 GetWordPosition(start, start, end);
11076 if (originalStart == end)
11078 GetWordPosition(end+1, start, end);
11080 if (originalEnd > end)
11082 SetBlockRange(end, originalEnd);
11084 else if (originalEnd < end)
11086 SetBlockRange(originalEnd, end);
11087 __textBlockMoveLeft = false;
11089 else if (originalEnd == end)
11091 ReleaseTextBlock();
11092 SetCursorPosition(end);
11093 __textBlockMoveLeft = false;
11098 if (end < GetTextLength())
11100 originalStart = start;
11102 GetWordPosition(end+1, start, end);
11103 SetBlockRange(originalStart, end);
11113 if (__textBlockMoveLeft)
11115 __pTextObject->SetFirstDisplayLineIndexFromTextIndex(start);
11117 SetCursorChangedFlag(!__textBlockMoveLeft);
11126 if (__cursorPos > 0)
11128 GetWordPosition(__cursorPos, start, end);
11129 if (__cursorPos != start)
11131 SetBlockRange(start, __cursorPos);
11135 GetWordPosition(start-1, start, end);
11136 SetBlockRange(start, __cursorPos);
11138 __textBlockMoveLeft = true;
11142 if (GetTextLength() >= __cursorPos + 1)
11144 GetWordPosition(__cursorPos, start, end);
11145 if (__cursorPos != end)
11147 SetBlockRange(__cursorPos, end);
11151 GetWordPosition(end+1, start, end);
11152 SetBlockRange(__cursorPos, end);
11154 __textBlockMoveLeft = false;
11164 __textBlockMoving = true;
11169 _EditPresenter::SetEditTextFilter(_IEditTextFilter* pFilter)
11171 __pTextFilter = pFilter;
11177 _EditPresenter::ValidatePastedText(const String& pastedText, String& replacedText)
11179 bool enable = false;
11182 enable = __pTextFilter->ValidatePastedText(pastedText, replacedText);
11189 _EditPresenter::SendOpaqueCommand (const String& command)
11191 if (command.Equals(L"KEYPAD_STYLE: PASSWORD", true))
11193 if (__pInputConnection)
11195 __pInputConnection->SetPasswordMode(true);
11199 if (__pInputConnection)
11201 __pInputConnection->SendOpaqueCommand(command);
11208 _EditPresenter::IsBounded(void) const
11210 return __isInputConnectionBound;
11214 _EditPresenter::AdjustRTLTextAlignment(const _EditTextType textType)
11216 result r = E_SUCCESS;
11220 case EDIT_TEXT_TYPE_INPUT:
11221 if (GetTextAlignment() != ALIGNMENT_LEFT)
11223 if (_BidiUtils::IsRTL(GetText()) == true)
11225 __pTextObject->SetTextBidiHint(TEXT_BIDI_HINT_RTL);
11229 __pTextObject->SetTextBidiHint(TEXT_BIDI_HINT_LTR);
11233 if (_BidiUtils::IsRTL(GetText()) == true)
11235 if (__horizontalAlignmentForBidi == ALIGNMENT_LEFT)
11237 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
11239 r = __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
11243 r = __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_TOP);
11245 __horizontalAlignmentForBidi = ALIGNMENT_RIGHT;
11246 __pTextObject->SetTextBidiHint(TEXT_BIDI_HINT_RTL);
11247 if (r == E_SUCCESS)
11255 if (__horizontalAlignmentForBidi == ALIGNMENT_RIGHT)
11257 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
11259 r = __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
11263 r = __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
11265 __horizontalAlignmentForBidi = ALIGNMENT_LEFT;
11266 __pTextObject->SetTextBidiHint(TEXT_BIDI_HINT_LTR);
11267 if (r == E_SUCCESS)
11274 case EDIT_TEXT_TYPE_GUIDE:
11275 if (__pGuideTextObject == null)
11279 if (_BidiUtils::IsRTL(__guideText) == true)
11281 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
11283 r = __pGuideTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
11287 r = __pGuideTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_TOP);
11289 __pGuideTextObject->SetTextBidiHint(TEXT_BIDI_HINT_RTL);
11290 if (r == E_SUCCESS)
11297 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
11299 r = __pGuideTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
11303 r = __pGuideTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
11305 __pGuideTextObject->SetTextBidiHint(TEXT_BIDI_HINT_LTR);
11306 if (r == E_SUCCESS)
11312 case EDIT_TEXT_TYPE_TITLE:
11313 if (__pTitleTextObject == null)
11317 if (_BidiUtils::IsRTL(__titleText) == true)
11319 r = __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
11320 if (r == E_SUCCESS)
11327 r = __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
11328 if (r == E_SUCCESS)
11342 _EditPresenter::UpdateKeypadCommandString(void)
11344 if (!__isKeypadCommandButtonUserSetting)
11346 __pEditModel->UpdateKeypadCommandButtonText();
11347 if (__pCommandButton)
11349 _Button* pLeftButton = __pCommandButton->GetItem(COMMAND_BUTTON_POSITION_LEFT);
11352 pLeftButton->SetText(__pEditModel->GetKeypadCommandButtonText(COMMAND_BUTTON_POSITION_LEFT));
11354 _Button* pRightButton = __pCommandButton->GetItem(COMMAND_BUTTON_POSITION_RIGHT);
11357 pRightButton->SetText(__pEditModel->GetKeypadCommandButtonText(COMMAND_BUTTON_POSITION_RIGHT));
11364 _EditPresenter::SetPasswordVisible(bool visible)
11366 result r = E_SUCCESS;
11368 SysTryReturnResult(NID_UI_CTRL, (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD), E_INVALID_OPERATION,
11369 "Edit Style is not EDIT_STYLE_PASSWORD.\n")
11372 if (__isPasswordVisible == visible)
11377 __isPasswordVisible = visible;
11379 if (GetTextLength()== 0)
11384 InitializeCopyPasteManager();
11386 FinishTextComposition();
11388 if (__isPasswordVisible)
11390 StopPasswordTimer();
11391 ChangePasswordToPlainText();
11395 ReplaceTextIntoPasswordHyphenString();
11396 __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), 0);
11403 _EditPresenter::IsPasswordVisible(void) const
11405 return __isPasswordVisible;
11409 _EditPresenter::IsClearIconPressed(void) const
11411 return __isClearIconPressed;
11415 _EditPresenter::DrawFocusRing(Tizen::Graphics::Canvas& canvas)
11417 if (__pEditModel->IsViewModeEnabled() || !__pEdit->IsEnabled())
11422 result r = E_SUCCESS;
11423 Bitmap* pFocusRing = null;
11424 Color color = __pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED);
11426 if (IsCurrentFocused() && color.GetAlpha())
11429 GET_COLOR_CONFIG(FOCUSUI::CONTENT_BG_HIGHLIGHTED, focusColor);
11430 focusColor.SetAlpha(color.GetAlpha());
11432 r = GET_BITMAP_CONFIG_N(EDIT::BG_RING_FOCUSED, BITMAP_PIXEL_FORMAT_ARGB8888, pFocusRing);
11433 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
11435 FloatRectangle editRect(0.0f, 0.0f, __pEdit->GetBoundsF().width, __pEdit->GetBoundsF().height);
11437 Bitmap* pReplacementFocusRing = _BitmapImpl::GetColorReplacedBitmapN(*pFocusRing, Color::GetColor(COLOR_ID_MAGENTA), focusColor);
11438 SysTryCatch(NID_UI_CTRL, pReplacementFocusRing, , r = GetLastResult(), "Unable to allocate text buffer.");
11440 if (pReplacementFocusRing)
11442 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pReplacementFocusRing))
11444 canvas.DrawNinePatchedBitmap(editRect, *pReplacementFocusRing);
11448 delete pReplacementFocusRing;
11459 }}} // Tizen::Ui::Controls