2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrl_EditPresenter.cpp
20 * @brief This is the implementation file for the _EditPresenter class.
23 #include <FBaseErrorDefine.h>
24 #include <FBaseInternalTypes.h>
25 #include <FBaseSysLog.h>
26 #include <FBaseUtilMath.h>
27 #include <FGrpFloatRectangle.h>
29 #include <FLclLocale.h>
30 #include <FUiCtrlFooter.h>
31 #include <FUiCtrlFooterItem.h>
32 #include <FUiCtrlForm.h>
33 #include <FUiIActionEventListener.h>
34 #include <FGrp_BitmapImpl.h>
35 #include <FGrp_CoordinateSystem.h>
36 #include <FGrp_FontImpl.h>
37 #include <FGrp_Screen.h>
38 #include <FGrp_TextCommon.h>
39 #include <FGrp_TextElementImpl.h>
40 #include <FGrp_TextTextCutLink.h>
41 #include <FGrp_TextTextCutLinkParser.h>
42 #include <FGrp_TextTextElement.h>
43 #include <FGrp_TextTextImage.h>
44 #include <FGrp_TextTextSimple.h>
45 #include "FUi_Clipboard.h"
46 #include "FUi_ClipboardItem.h"
47 #include "FUi_Control.h"
48 #include "FUi_ControlImpl.h"
49 #include "FUi_ControlManager.h"
50 #include "FUi_ResourceManager.h"
51 #include "FUi_UiEventManager.h"
52 #include "FUi_UiNotificationEvent.h"
53 #include "FUiAnim_VisualElement.h"
54 #include "FUiAnim_EflNode.h"
55 #include "FUiCtrl_Button.h"
56 #include "FUiCtrl_ContextMenu.h"
57 #include "FUiCtrl_Edit.h"
58 #include "FUiCtrl_EditCopyPasteManager.h"
59 #include "FUiCtrl_EditPresenter.h"
60 #include "FUiCtrl_FlickAnimation.h"
61 #include "FUiCtrl_Frame.h"
62 #include "FUiCtrl_Form.h"
63 #include "FUiCtrl_Scroll.h"
64 #include "FUiCtrl_ScrollPanel.h"
65 #include "FUiCtrl_Toolbar.h"
66 #include "FUiCtrl_TableView.h"
69 using namespace Tizen::Base::Runtime;
70 using namespace Tizen::Base::Utility;
71 using namespace Tizen::Media;
72 using namespace Tizen::Ui::Animations;
73 using namespace Tizen::Graphics;
74 using namespace Tizen::Ui;
75 using namespace Tizen::Ui::Controls;
76 using namespace Tizen::Base;
77 using namespace Tizen::Base::Utility;
78 using namespace Tizen::Base::Collection;
79 using namespace Tizen::Locales;
80 using namespace Tizen::Graphics::_Text;
82 namespace Tizen { namespace Ui { namespace Controls
84 const int EDIT_PASSWORD_TIMER_PERIOD = 1000;
85 const int EDIT_CURSOR_TIMER_PERIOD = 600;
86 const int MAX_LINE_NUMBER = 100;
87 const int MAX_FLEXIBLE_HEIGHT_VERTICAL_MODE = 4000;
88 const int MAX_FLEXIBLE_HEIGHT_HORIZONTAL_MODE = 2500;
89 const int EDIT_FLICK_SCROLL_TIMER_INTERVAL = 10;
90 const float DIRECTION_DECISION_RATIO = 1.3;
91 const float HORIZONTAL_DECISION_RATIO = 1.5;
92 const int MOVE_SKIP_DECISION_RANGE = 5;
93 const int TITLE_SLIDING_TIME = 800;
95 const int LANGUAGE_CODE_START = 0;
96 const int LANGUAGE_CODE_MAX = 2;
98 bool _EditPresenter::__isKeypadExist = false;
99 int _EditPresenter::__initialParentHeight = 0;
100 bool _EditPresenter::__isPanelBoundsChanging = false;
102 _EditAnimationProvider::_EditAnimationProvider(void)
106 _EditAnimationProvider::~_EditAnimationProvider(void)
110 VisualElementAnimation*
111 _EditAnimationProvider::CreateAnimationForProperty(VisualElement& source, const String& property)
113 VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(source, property);
114 if (pAnimation != null)
116 pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseInOut"));
117 pAnimation->SetDuration(ANIMATION_DURATION);
123 _EditPresenter::_EditPresenter(void)
125 , __pTextBuffer(null)
126 , __pTextString(null)
129 , __pScrollEffect(null)
131 , __horizontalAlignment(ALIGNMENT_LEFT)
132 , __isScrollBarVisible(false)
133 , __scrollBarBounds()
135 , __previousScrollBarPos(0)
136 , __previousScrollBarMaxPos(0)
137 , __pActionEventListener(null)
138 , __pCursorTimer(null)
139 , __pFlickAnimationTimer(null)
140 , __pPasswordTimer(null)
141 , __pTitleSlidingTimer(null)
143 , __pCursorVisualElement(null)
144 , __pTextVisualElement(null)
145 , __pCopyPasteManager(null)
146 , __pFlickAnimation(null)
147 , __pParentForm(null)
148 , __pFullscreenKeypad(null)
149 , __pParentPanel(null)
150 , __pCommandButton(null)
151 , __pInputConnection(null)
152 , __isInputConnectionBound(false)
156 , __isCopyPastePopupMoving(false)
157 , __pressedAbsolutePoint()
158 , __clearIconBounds()
160 , __textObjectBounds()
163 , __previousCursorBounds()
165 , __pTextObject(null)
166 , __pGuideTextObject(null)
167 , __pTitleTextObject(null)
168 , __titleSlidingAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT)
169 , __textObjectWrap(TEXT_OBJECT_WRAP_TYPE_WORD)
170 , __isTextBlocked(false)
171 , __isGuideTextColorChanged(false)
172 , __isKeypadCommandButtonVisible(false)
173 , __isKeypadHiding(false)
174 , __isTextComposing(false)
175 , __isCopyPastePopupVisible(false)
176 , __isCursorChanged(false)
177 , __isCursorInitialized(false)
178 , __isCursorDisabled(false)
179 , __isInitialized(false)
180 , __isMovingCursorByTouchMove(false)
181 , __isTouchMoving(false)
182 , __isTouchPressed(false)
183 , __isClearIconPressed(false)
184 , __isCursorOpaque(false)
185 , __isTouchReleaseSkipped(false)
186 , __isViewerModeEnabled(false)
187 , __isKeypadNormalNumberStyleEnabled(false)
188 , __isTextCompositionFinished(false)
189 , __isFlexibleHeightFrozen(false)
190 , __isKeypadShowing(false)
193 , __maximumFlexibleHeight(-1)
194 , __prevTotalTextHeight(-1)
196 , __composingTextLength(0)
198 , __verticalMargin(-1)
199 , __isUSBKeyboardConnected(false)
201 , __isCutLinkParserEnabled(false)
203 , __footerVisibleStatus(EDIT_FOOTER_VISIBLE_STATUS_NONE)
204 , __ContentTextStatus(EDIT_TEXT_STATUS_COMPOSE_NON)
205 , __pEditVEDelegator(null)
206 , __isAutoShrinkEnabled(false)
207 , __groupStyle(GROUP_STYLE_NONE)
208 , __isFontInitialized(false)
209 , __contentFontSize(0)
211 , __contentFontStyle(FONT_STYLE_PLAIN)
212 , __contentTextStyle(TEXT_BOX_TEXT_STYLE_NORMAL)
213 , __titleFontFaceName("")
214 , __isSearchBar(false)
215 , __isKeypadClosedEventSkipped(false)
216 , __pCurrentFrame(null)
221 _EditPresenter::OnInputConnectionPanelShowStateChanged(InputConnection& source, InputPanelShowState showState)
223 if (showState == INPUT_PANEL_SHOW_STATE_SHOW)// 1. bounded 2.bounded&rotate
225 __isKeypadShowing = false;
227 CheckUSBKeyboardStatus();
230 if (__isInputConnectionBound)
232 if (__isKeypadCommandButtonVisible)
234 SetFooterVisible(false);
237 ChangeLayoutInternal(__pEdit->GetOrientation());
238 AdjustParentPanelHeight(false);
240 if (__pCommandButton)
242 __pCommandButton->Invalidate();
247 ScrollPanelToTop(true);
248 ScrollPanelToCursorPosition();
249 __pParentForm->Draw();
253 if (__isUSBKeyboardConnected && !__isKeypadCommandButtonVisible)
255 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
258 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
259 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED);
261 else if (showState == INPUT_PANEL_SHOW_STATE_HIDE)// 1.unbound 2.bounded&usb off -> usb on 3.Flick keypad hide
263 CheckUSBKeyboardStatus();
266 if (__isCopyPastePopupVisible)
268 InitializeCopyPasteManager();
269 __pTextObject->SetBlock(false);
270 __isTextBlocked = false;
273 if (__isInputConnectionBound && __isUSBKeyboardConnected) // hide callback from external condition(usb mode off->on)
275 ChangeLayoutInternal(__pEdit->GetOrientation());
276 AdjustParentPanelHeight(true);
278 if (__pCommandButton)
280 __pCommandButton->Invalidate();
283 _Form* pParentForm = GetParentForm();
286 __pParentForm->Draw();
291 _Form* pParentForm = GetParentForm();
292 if (__isInputConnectionBound)// keypad drag down, auto keypad hide by clipboard switch
294 if (__pCommandButton && __pCommandButton->GetVisibleState() == true)
296 SetFooterVisible(true);// must be called ahead of DeflateClientRectHeight
297 __pCommandButton->SetVisibleState(false);
300 if ( IsFocused() && pParentForm && __pEdit->IsFullScreenKeypadEdit() == false)
302 pParentForm->SetFocused();
305 else// called by focus move or HideKeypad() api call
307 SetKeypadClosedEventSkipped(true);//it will adjust only fullscreen keypad edit.
310 AdjustParentPanelHeight(true);
312 __isInputConnectionBound = false;
314 __pEdit->DetachScrollPanelEvent();
318 pParentForm->DeflateClientRectHeight(0);
319 __pParentForm->Draw();
323 __isKeypadHiding = false;
325 SetKeypadBounds(Rectangle());
327 if (!__isKeypadClosedEventSkipped)
329 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
330 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CLOSED);
332 __isKeypadClosedEventSkipped = false;
339 _EditPresenter::OnInputConnectionPanelLanguageChanged(InputConnection& source, LanguageCode language)
341 LanguageCode oldLanguageCode;
342 __pEditModel->GetCurrentLanguage(oldLanguageCode);
344 __pEditModel->SetCurrentLanguage(language);
345 __pEdit->SendLanguageEvent(oldLanguageCode, language);
351 _EditPresenter::OnInputConnectionPanelBoundsChanged(InputConnection& source, const Rectangle& bounds)
353 CheckUSBKeyboardStatus();
356 if ((__isUSBKeyboardConnected == false) && (IsKeypadExist() == false))
361 ChangeLayoutInternal(__pEdit->GetOrientation());
362 AdjustParentPanelHeight(false, true);
365 __pParentForm->Draw();
366 ScrollPanelToCursorPosition();
369 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
375 _EditPresenter::OnInputConnectionTextPredictionShowStateChanged(InputConnection& source, bool isShown)
377 CheckUSBKeyboardStatus();
380 if ((__isUSBKeyboardConnected == false) && (IsKeypadExist() == false))
385 ChangeLayoutInternal(__pEdit->GetOrientation());
386 AdjustParentPanelHeight(false, true);
389 __pParentForm->Draw();
390 ScrollPanelToCursorPosition();
393 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
399 _EditPresenter::OnInputConnectionTextPredictionBoundsChanged(InputConnection& source, const Rectangle& bounds)
405 _EditPresenter::OnInputConnectionTextCommitted(InputConnection& source, const String& committedText)
407 OnTextCommitted(committedText);
413 _EditPresenter::OnTextCommitted(const String& commitText)
415 bool isTextComposingFinished = false;
417 if (IsViewModeEnabled() == true)
422 if (IsBlocked() == true)
426 GetBlockRange(start, end);
427 __isFlexibleHeightFrozen = true;
428 DeleteText(start, end);
429 __isFlexibleHeightFrozen = false;
433 if (__isCopyPastePopupVisible)
435 InitializeCopyPasteManager();
438 int textLength = commitText.GetLength();
439 int compositionStart = __cursorPos - textLength;
441 if (__isTextComposing == true)
443 __isFlexibleHeightFrozen = true;
444 DeleteText(__cursorPos-__composingTextLength, __cursorPos);
445 __isFlexibleHeightFrozen = false;
447 __isTextComposing = false;
448 __composingTextLength = 0;
449 isTextComposingFinished = true;
452 if (__ContentTextStatus != EDIT_TEXT_STATUS_COMPOSE_NON)
454 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
457 if (__pPasswordTimer)
459 ChangePasswordToEchoCharacter(__pTextBuffer, __echoChar);
463 char enterText1[2] = {'\n', };
464 char enterText2[2] = {'\r', };
466 if (commitText == enterText1 || commitText == enterText2)
468 CoreKeypadAction keypadaction = GetKeypadAction();
470 __pEdit->SendKeypadEvent(keypadaction, CORE_KEYPAD_EVENT_STATUS_ENTERACTION);
471 if (keypadaction != CORE_KEYPAD_ACTION_ENTER)
476 if(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
482 char tapText[2] = {'\t', };
483 if (commitText == tapText)
488 // Limitation Protect
489 String insetText = commitText;
490 int currentLength = GetTextLength();
491 int totalLength = currentLength + textLength;
492 int excessCharacterLength = totalLength - __limitLength;
494 if (excessCharacterLength >= 0)
496 textLength -= excessCharacterLength;
499 insetText.Remove(textLength, excessCharacterLength);
507 InsertTextAt(__cursorPos, insetText);
509 ScrollPanelToCursorPosition();
511 if ((__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) && isTextComposingFinished)
513 ReplaceTextIntoPasswordHyphenString();
516 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
521 ChangePasswordToEchoCharacter((compositionStart + textLength), textLength);
523 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
529 _EditPresenter::OnInputConnectionComposingTextChanged(InputConnection& source, const String& composingText, int cursorPosition)
531 OnComposingTextChanged(composingText, cursorPosition);
537 _EditPresenter::OnComposingTextChanged(const String& composingText, int cursorPosition)
539 if (IsViewModeEnabled() == true)
544 if (IsBlocked() == true)
548 GetBlockRange(start, end);
549 __isFlexibleHeightFrozen = true;
550 DeleteText(start, end);
551 __isFlexibleHeightFrozen = false;
555 if (__isCopyPastePopupVisible)
557 InitializeCopyPasteManager();
560 int textLength = composingText.GetLength();
562 if (__isTextComposing == true)
564 int compositionStart = GetCursorPosition();
568 __isTextComposing = false;
570 // FirstText Check Logic
571 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
572 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine);
573 bool isFirstText = false;
574 if (firstTextIndex + 1 == __pTextObject->GetCursorIndex())
579 DeleteText(compositionStart-__composingTextLength, compositionStart);
583 __isCursorChanged = false;
586 __composingTextLength = 0;
590 if (!__isCursorChanged)
592 __isCursorChanged = true;
594 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
600 __isFlexibleHeightFrozen = true;
601 DeleteText(compositionStart-__composingTextLength, compositionStart);
602 __isFlexibleHeightFrozen = false;
606 __composingTextLength = textLength;
607 if (__composingTextLength > 0)
609 __isTextComposing = true;
612 // Limitation Protect
613 String insetText = composingText;
614 int currentLength = GetTextLength();
615 int totalLength = currentLength + textLength;
616 int excessCharacterLength = totalLength - __limitLength;
618 if (excessCharacterLength >= 0)
620 __composingTextLength -= excessCharacterLength;
621 if (__composingTextLength > 0)
623 insetText.Remove(__composingTextLength, excessCharacterLength);
627 __composingTextLength = 0;
631 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
632 SysTryReturnVoidResult(NID_UI_CTRL, fontImpl != null, E_SYSTEM, "[E_SYSTEM] fontImpl is null.");
633 fontImpl->SetUnderline(true);
634 __pTextObject->SetFont(__pFont, 0, 0);
636 if (__composingTextLength > 0)
638 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE;
641 InsertTextAt(GetCursorPosition(), insetText);
643 fontImpl->SetUnderline(false);// rollback to default content font
644 __pTextObject->SetFont(__pFont, 0, 0);
646 ScrollPanelToCursorPosition();
650 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
656 _EditPresenter::DeleteSurroundingText(InputConnection& source, int offset, int charCount)
658 OnSurroundingTextDeleted(offset, charCount);
664 _EditPresenter::OnSurroundingTextDeleted(int offset, int charCount)
669 if (IsBlocked() == true)
671 GetBlockRange(start, end);
675 start = __cursorPos + offset;
680 end = start + charCount;
681 if (end > __cursorPos)
687 DeleteText(start, end);
689 if (__isCopyPastePopupVisible)
691 InitializeCopyPasteManager();
694 if (IsBlocked() == true)
701 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
707 _EditPresenter::GetPreviousText(InputConnection& source, String& text, int& cursorPosition)
709 const int SURRONDING_TEXT_SIZE = 5;
710 int stringLength = 0;
713 if (__cursorPos == 0)
720 if (__cursorPos < SURRONDING_TEXT_SIZE)
722 text = GetText(0, __cursorPos - 1);
726 text = GetText(__cursorPos-SURRONDING_TEXT_SIZE, __cursorPos - 1);
728 stringLength = text.GetLength();
729 cursorPosition = stringLength;
735 _EditPresenter::~_EditPresenter(void)
741 _EditPresenter::Dispose(void)
745 __pCurrentFrame->RemoveFrameEventListener(*this);
746 __pCurrentFrame = null;
749 if (__pCommandButton && __pCommandButton->GetVisibleState() == true)
751 __pCommandButton->SetVisibleState(false);
752 if (__isKeypadCommandButtonVisible)
754 SetFooterVisible(true);
757 delete __pCommandButton;
758 __pCommandButton = null;
761 _Form* pParentForm = GetParentForm();
764 pParentForm->DeflateClientRectHeight(0);
767 AdjustParentPanelHeight(true);
769 delete __pFullscreenKeypad;
770 __pFullscreenKeypad = null;
772 delete __pScrollEffect;
773 __pScrollEffect = null;
777 delete[] __pTextBuffer;
778 __pTextBuffer = null;
781 delete __pTextString;
782 __pTextString = null;
789 __pCursorTimer->Cancel();
790 delete __pCursorTimer;
791 __pCursorTimer = null;
794 if (__pInputConnection)
796 delete __pInputConnection;
797 __pInputConnection = null;
801 __pEdit->DetachScrollPanelEvent();
805 delete __pTextObject;
806 __pTextObject = null;
808 delete __pGuideTextObject;
809 __pGuideTextObject = null;
811 delete __pTitleTextObject;
812 __pTitleTextObject = null;
814 if (__pPasswordTimer)
816 __pPasswordTimer->Cancel();
817 delete __pPasswordTimer;
818 __pPasswordTimer = null;
821 if (__pScrollBar != null && __pEdit != null)
823 result r = __pEdit->DetachSystemChild(*__pScrollBar);
832 if (__pFlickAnimationTimer)
834 __pFlickAnimationTimer->Cancel();
835 delete __pFlickAnimationTimer;
836 __pFlickAnimationTimer = null;
839 if (__pTitleSlidingTimer)
841 __pTitleSlidingTimer->Cancel();
842 delete __pTitleSlidingTimer;
843 __pTitleSlidingTimer = null;
846 delete __pFlickAnimation;
847 __pFlickAnimation = null;
849 if (__pCopyPasteManager != null)
851 __pCopyPasteManager->HideHandle();
852 delete __pCopyPasteManager;
853 __pCopyPasteManager = null;
856 if (__pTextVisualElement)
858 __pTextVisualElement->Destroy();
859 __pTextVisualElement = null;
862 if (__pCursorVisualElement)
864 __pCursorVisualElement->Destroy();
865 __pCursorVisualElement = null;
868 if (__pEditVEDelegator)
870 delete __pEditVEDelegator;
871 __pEditVEDelegator = null;
878 _EditPresenter::CheckKeypadStatus(void)
885 Dimension screenSize;
886 Rectangle absKeypadBounds;
887 _ControlManager* pControlManager = _ControlManager::GetInstance();
889 GetKeypadBounds(absKeypadBounds);
891 _ControlOrientation orientation = __pEdit->GetOrientation();
893 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
895 screenSize.height = pControlManager->GetScreenSize().height;
899 screenSize.height = pControlManager->GetScreenSize().width;
902 if (absKeypadBounds.y != screenSize.height)
904 __isKeypadExist = true;
908 __isKeypadExist = false;
915 _EditPresenter::IsKeypadExist(void) const
917 return __isKeypadExist;
921 _EditPresenter::CheckUSBKeyboardStatus(void)
923 if (__pInputConnection->CheckUSBKeyboardStatus())
925 __isUSBKeyboardConnected = true;
929 __isUSBKeyboardConnected = false;
936 _EditPresenter::IsUsbKeyboardConnected(void) const
938 if (__pInputConnection->CheckUSBKeyboardStatus())
949 _EditPresenter::CreateInstanceN(void)
951 _EditPresenter* pPresenter = new (std::nothrow) _EditPresenter;
952 if (pPresenter == null)
954 SetLastResult(E_OUT_OF_MEMORY);
962 _EditPresenter::Initialize(const _Control& control)
964 result r = E_SUCCESS;
965 _EditModel* pEditModel = null;
966 _VisualElement* pEditVisualElement = null;
967 TextSimple* pSimpleText = null;
968 _ControlManager* pControlManager = _ControlManager::GetInstance();
969 _Window* pWindow = null;
971 __pEdit = dynamic_cast<_Edit*>(const_cast<_Control*>(&control));
972 SysAssertf(__pEdit != null, "__pEdit is null");
974 __pTextObject = new (std::nothrow) TextObject;
975 if (__pTextObject == null)
981 __pTextObject->Construct();
982 pSimpleText = new (std::nothrow)TextSimple(null, 0, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
983 __pTextObject->AppendElement(*pSimpleText);
985 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
987 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
988 if (__pEdit->IsFullScreenKeypadEdit())
990 __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
994 __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
996 __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
997 __textObjectWrap = TEXT_OBJECT_WRAP_TYPE_NONE;
1001 __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
1002 __pTextObject->SetWrap(__textObjectWrap);
1005 __pTextString = new (std::nothrow) String;
1006 SysTryCatch(NID_UI_CTRL, __pTextString, , r = E_OUT_OF_MEMORY, "[EDIT] Unable to allocate text buffer.");
1009 if (__pFont == null)
1011 _ControlOrientation orientation = __pEdit->GetOrientation();
1012 int defaultFontSize = 0;
1013 GET_SHAPE_CONFIG(EDIT::DEFAULT_FONT_SIZE, orientation, defaultFontSize);
1015 __contentFontSize = defaultFontSize;
1016 __contentFontStyle = FONT_STYLE_PLAIN;
1018 __pFont = __pEdit->GetFallbackFont();
1020 r = GetLastResult();
1021 SysTryReturn(NID_UI_CTRL, __pFont, r, r, "[%s] Propagating.", GetErrorMessage(r));
1023 __titleFontFaceName = __pFont->GetFaceName();
1025 __isFontInitialized = true;
1026 __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
1027 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
1030 __pScrollEffect = new (std::nothrow) _EditScrollEffectInfo;
1031 SysTryCatch(NID_UI_CTRL, __pScrollEffect, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create EditScrollEffectInfo");
1033 for (int i = 0; i < EDIT_SCROLLFRAME_MAX; i++)
1035 __pScrollEffect->touchScrollFrameLevel[i] = 2 + i;
1038 __pScrollEffect->previousY = -1;
1039 __pScrollEffect->currentY = -1;
1041 pEditModel = new (std::nothrow) _EditModel;
1042 SysTryCatch(NID_UI_CTRL, pEditModel, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance");
1044 SetModel(*pEditModel);
1049 if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)
1051 SetViewModeEnabled(true);
1052 __isCutLinkParserEnabled = true;
1056 SetKeypadEnabled(true);
1057 __isCutLinkParserEnabled = false;
1060 __initialBounds = __pEdit->GetBounds();
1062 __pCursorVisualElement = new (std::nothrow) _VisualElement;
1063 SysTryCatch(NID_UI_CTRL, __pCursorVisualElement, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance");
1065 r = __pCursorVisualElement->Construct();
1066 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r));
1068 __pCursorVisualElement->SetSurfaceOpaque(false);
1069 __pCursorVisualElement->SetImplicitAnimationEnabled(false);
1071 pEditVisualElement = __pEdit->GetVisualElement();
1072 SysTryCatch(NID_UI_CTRL, pEditVisualElement, , r = E_SYSTEM, "[E_SYSTEM] Unable to get root visual element.");
1074 __pCursorVisualElement->SetShowState(true);
1076 r = pEditVisualElement->AttachChild(*__pCursorVisualElement);
1077 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r));
1079 __pInputConnection = _InputConnectionImpl::CreateInputConnectionImplN(null);
1080 SysTryCatch(NID_UI_CTRL, __pInputConnection, , r = E_SYSTEM, "[E_SYSTEM] Unable to create an instance .");
1082 __pInputConnection->Initialize(*__pEdit, *this, *this);
1084 __pTextObject->SetBounds(__textObjectBounds);
1086 __maximumFlexibleHeight = GetMaxLineCount() * __pFont->GetMaxHeight() + __verticalMargin;
1088 __pEditVEDelegator = new (std::nothrow) _EditAnimationProvider();
1089 SysTryCatch(NID_UI_CTRL, __pEditVEDelegator, , E_OUT_OF_MEMORY, "Memory allocation failed.");
1091 pWindow = pControlManager->GetCurrentFrame();
1094 __pCurrentFrame = dynamic_cast<_Frame*>(pWindow);
1095 if (__pCurrentFrame)
1097 __pCurrentFrame->AddFrameEventListener(*this);
1109 _EditPresenter::InitializeAtFirstDrawing(void)
1111 result r = E_SUCCESS;
1115 InitializeParentPanel();
1117 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false && (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE))
1119 r = AdjustFlexibleHeight();
1120 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Faild to adjust flexible height.");
1123 ReplaceTextIntoPasswordHyphenString();
1125 if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)
1127 __pEdit->SetCursorPosition(0);
1130 __isInitialized = true;
1136 _EditPresenter::DrawBackgroundBitmap(Canvas& canvas, bool focused)
1138 if (!DrawChangeableBackground(canvas, focused, 0, 0))
1147 _EditPresenter::DrawChangeableBackground(Canvas& canvas, bool focused, int bitmapId, int effectBitmapId, bool outLine, int outlineBitmapId)
1149 result r = E_SUCCESS;
1150 Rectangle editRect(0, 0, __pEdit->GetBounds().width, __pEdit->GetBounds().height);
1152 Bitmap* pEditBgBitmap = null;
1153 Bitmap* pEditBgEffectBitmap = null;
1154 Bitmap* pReplacementColorBackgroundBitmap = null;
1155 bool borderRoundEnable = __pEdit->IsBorderRoundStyleEnabled();
1156 EditStatus editStatus = GetCurrentStatus();
1158 pEditBgBitmap = __pEdit->GetDefaultBackgroundBitmap(editStatus);
1160 if (__pEdit->IsCustomDefaultBackgroundBitmap(editStatus))
1162 canvas.DrawBitmap(editRect, *pEditBgBitmap);
1166 if (borderRoundEnable)
1168 pEditBgBitmap = null;
1169 r = GET_BITMAP_CONFIG_N(EDIT::BG_ROUND_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pEditBgBitmap)
1170 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap");
1173 bitmapColor = __pEdit->GetColor(editStatus);
1175 pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pEditBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), bitmapColor);
1176 if (pReplacementColorBackgroundBitmap)
1178 if (pReplacementColorBackgroundBitmap->IsNinePatchedBitmap())
1180 canvas.DrawNinePatchedBitmap(editRect, *pReplacementColorBackgroundBitmap);
1184 canvas.DrawBitmap(editRect, *pReplacementColorBackgroundBitmap);
1188 if ((!__pEdit->IsFullScreenKeypadEdit() && __groupStyle != GROUP_STYLE_NONE) || GetSearchBarFlag())
1190 pEditBgEffectBitmap = __pEdit->GetDefaultBackgroundEffectBitmap();
1192 if (borderRoundEnable)
1194 pEditBgEffectBitmap = null;
1195 r = GET_BITMAP_CONFIG_N(EDIT::BG_ROUND_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pEditBgEffectBitmap)
1196 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap");
1199 if (pEditBgEffectBitmap)
1201 if (pEditBgEffectBitmap->IsNinePatchedBitmap())
1203 canvas.DrawNinePatchedBitmap(editRect, *pEditBgEffectBitmap);
1207 canvas.DrawBitmap(editRect, *pEditBgEffectBitmap);
1212 if (borderRoundEnable)
1216 delete pEditBgBitmap;
1217 pEditBgBitmap = null;
1220 if (pEditBgEffectBitmap)
1222 delete pEditBgEffectBitmap;
1223 pEditBgEffectBitmap = null;
1226 delete pReplacementColorBackgroundBitmap;
1227 pReplacementColorBackgroundBitmap = null;
1231 delete pEditBgBitmap;
1232 delete pEditBgEffectBitmap;
1238 _EditPresenter::DrawBackground(Canvas& canvas, bool drawTitleText)
1240 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
1242 return DrawSingleLineBackground(canvas, drawTitleText);
1245 Rectangle editRect(0, 0, __pEdit->GetBounds().width, __pEdit->GetBounds().height);
1247 EditStatus editStatus = GetCurrentStatus();
1249 Bitmap* pEditBgBitmap = __pEdit->GetBackgroundBitmap(editStatus);
1253 if (pEditBgBitmap->IsNinePatchedBitmap())
1255 canvas.DrawNinePatchedBitmap(editRect, *pEditBgBitmap);
1259 canvas.DrawBitmap(editRect, *pEditBgBitmap);
1264 DrawBackgroundBitmap(canvas, IsFocused());
1269 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_TOP) || (__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_LEFT))
1271 DrawTitleText(canvas);
1279 _EditPresenter::DrawTitleText(Canvas& canvas)
1281 if (__titleText == -1)
1287 TextObjectActionType titleAction;
1288 titleAction = __pTitleTextObject->GetAction();
1289 if (IsFocused() == true)
1291 __pTitleTextObject->SetForegroundColor(__pEdit->GetTitleTextColor(EDIT_STATUS_HIGHLIGHTED), 0, __pTitleTextObject->GetTextLength());
1293 if (titleAction != __titleSlidingAction)
1295 __pTitleTextObject->SetAction(__titleSlidingAction);
1296 __pTitleTextObject->Compose();
1299 __pTitleTextObject->SetBounds(__titleBounds);
1300 __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
1302 StopTitleSlidingTimer();
1303 if (__pTitleTextObject->IsActionOn() == true)
1305 StartTitleSlidingTimer();
1310 __pTitleTextObject->SetForegroundColor(__pEdit->GetTitleTextColor(GetCurrentStatus()), 0, __pTitleTextObject->GetTextLength());
1312 if (titleAction != TEXT_OBJECT_ACTION_TYPE_ABBREV)
1314 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1317 __pTitleTextObject->SetBounds(__titleBounds);
1318 __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
1325 _EditPresenter::DrawText(void)
1327 Canvas* pCanvas = null;
1329 // In case of unfocused and touch moving
1330 if (__isTouchMoving && !__pTextVisualElement)
1332 result r = E_SUCCESS;
1333 __pTextVisualElement = new (std::nothrow) _VisualElement;
1334 SysTryReturnVoidResult(NID_UI_CTRL, __pTextVisualElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create __pTextVisualElement instance.");
1336 r = __pTextVisualElement->Construct();
1337 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r));
1339 __pTextVisualElement->SetSurfaceOpaque(false);
1340 __pTextVisualElement->SetImplicitAnimationEnabled(false);
1342 __pTextVisualElement->SetShowState(true);
1344 _VisualElement* pEditVisualElement = __pEdit->GetVisualElement();
1345 SysTryCatch(NID_UI_CTRL, pEditVisualElement, , r = E_SYSTEM, "[E_SYSTEM] Unable to get root visual element.");
1347 pEditVisualElement->AttachChild(*__pTextVisualElement);
1348 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r));
1350 pCanvas = __pEdit->GetCanvasN();
1351 SysTryCatch(NID_UI_CTRL, pCanvas, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance.");
1353 pCanvas->SetBackgroundColor(Color(0));
1354 r = pCanvas->Clear();
1355 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1357 DrawBackground(*pCanvas);
1363 if (__pTextVisualElement)
1365 Rectangle editBounds = __pEdit->GetBounds();
1366 __pTextVisualElement->SetOpacity(1.0f);
1367 __pTextVisualElement->SetBounds(FloatRectangle(0, 0, editBounds.width, editBounds.height));
1368 pCanvas = __pTextVisualElement->GetCanvasN();
1369 if (pCanvas == null)
1373 pCanvas->SetBackgroundColor(Color(0));
1378 if (__pEdit->GetEditStyle() & EDIT_STYLE_CLEAR)
1380 DrawClearIcon(*pCanvas);
1390 __pTextVisualElement->Destroy();
1391 __pTextVisualElement = null;
1403 _EditPresenter::DrawText(Canvas& canvas)
1405 result r = E_SUCCESS;
1407 if (__pEdit->GetEnableState() == false)
1409 __pTextObject->SetAlternateLookEnabled(true);
1410 Color tempColor = __pEdit->GetTextColor(EDIT_STATUS_DISABLED);
1411 __pTextObject->SetAlternativeForegroundColor(tempColor);
1415 __pTextObject->SetAlternateLookEnabled(false);
1419 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
1421 return DrawTextForEntireFontSetting(canvas);
1424 // initital guide text
1425 if (IsGuideTextActivated())
1427 __pGuideTextObject->SetForegroundColor(__pEdit->GetGuideTextColor(), 0, __pGuideTextObject->GetTextLength());
1429 if (__isGuideTextColorChanged == true && __pEdit->IsSettingGuideTextColor() == false)
1431 __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_NORMAL), 0, __pGuideTextObject->GetTextLength());
1432 __pGuideTextObject->SetBounds(__textObjectBounds);
1433 __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
1434 __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_DISABLED), 0, __pGuideTextObject->GetTextLength());
1435 __isGuideTextColorChanged = false;
1439 __pGuideTextObject->SetBounds(__textObjectBounds);
1440 __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
1444 if (GetTextLength() <= 0)
1450 EditStatus editStatus = GetCurrentStatus();
1452 __pTextObject->SetForegroundColor(__pEdit->GetTextColor(editStatus), 0, __pTextObject->GetTextLength());
1454 if (__isTextBlocked == true && editStatus == EDIT_STATUS_HIGHLIGHTED)
1456 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED), 0, __pTextObject->GetTextLength());
1457 __pTextObject->SetBlock(true);
1458 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
1460 else if (__isTextBlocked == true && editStatus == EDIT_STATUS_PRESSED)
1462 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_PRESSED), 0, __pTextObject->GetTextLength());
1463 __pTextObject->SetBlock(true);
1464 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
1466 else if (__isTextBlocked == true && editStatus == EDIT_STATUS_NORMAL)
1468 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_NORMAL), 0, __pTextObject->GetTextLength());
1469 __pTextObject->SetBlock(true);
1470 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
1474 __pTextObject->SetBlock(false);
1475 __isTextBlocked = false;
1478 UpdateComponentInformation();
1480 __pTextObject->SetBounds(__textObjectBounds);
1481 __pTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
1483 if (__isTextBlocked == true && editStatus == EDIT_STATUS_HIGHLIGHTED)
1485 __pTextObject->SetBackgroundColor(Color::GetColor(COLOR_ID_BLACK), 0, __pTextObject->GetTextLength());
1488 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
1494 _EditPresenter::DrawTextForEntireFontSetting(Canvas& canvas)
1496 result r = E_SUCCESS;
1498 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) && IsFocused() == false)
1500 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1504 if (__pTextObject->GetAction() != TEXT_OBJECT_ACTION_TYPE_NONE)
1506 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE);
1507 __isCursorChanged = true;
1511 // initital guide text
1512 if (IsGuideTextActivated())
1514 __pGuideTextObject->SetForegroundColor(__pEdit->GetGuideTextColor(), 0, __pGuideTextObject->GetTextLength());
1516 if (__isGuideTextColorChanged == true && __pEdit->IsSettingGuideTextColor() == false)
1518 __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_NORMAL), 0, __pGuideTextObject->GetTextLength());
1519 __pGuideTextObject->SetBounds(__textObjectBounds);
1520 __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
1521 __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_DISABLED), 0, __pGuideTextObject->GetTextLength());
1522 __isGuideTextColorChanged = false;
1526 __pGuideTextObject->SetBounds(__textObjectBounds);
1527 __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
1531 if (GetTextLength() <= 0)
1537 EditStatus editStatus = GetCurrentStatus();
1539 if (IsFocused() == false)
1541 __pTextObject->SetFirstDisplayLineIndexFromTextIndex(0);
1542 __pTextObject->SetForegroundColor(__pEdit->GetTextColor(editStatus), 0, __pTextObject->GetTextLength());
1544 if (IsBlocked() == true)
1546 __pTextObject->SetBlock(false);
1552 int lengthRange = 0;
1554 __pTextObject->GetRange(startRange, lengthRange);
1555 __pTextObject->SetRange(0, GetTextLength());
1556 __pTextObject->SetForegroundColor(__pEdit->GetTextColor(editStatus), 0, __pTextObject->GetTextLength());
1558 if (IsBlocked() == true && editStatus == EDIT_STATUS_HIGHLIGHTED)
1560 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED), 0, __pTextObject->GetTextLength());
1561 __pTextObject->SetForegroundColor(__pEdit->GetTextColor(editStatus), 0, __pTextObject->GetTextLength());
1562 __pTextObject->SetBlock(true);
1563 __pTextObject->SetRange(__blockStartPos, __cursorPos - __blockStartPos);
1565 else if (__isTextBlocked == true && editStatus == EDIT_STATUS_PRESSED)
1567 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_PRESSED), 0, __pTextObject->GetTextLength());
1568 __pTextObject->SetBlock(true);
1569 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
1571 else if (__isTextBlocked == true && editStatus == EDIT_STATUS_NORMAL)
1573 __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_NORMAL), 0, __pTextObject->GetTextLength());
1574 __pTextObject->SetBlock(true);
1575 __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos);
1579 __pTextObject->SetBlock(false);
1580 __isTextBlocked = false;
1583 UpdateComponentInformation();
1586 __pTextObject->SetBounds(__textObjectBounds);
1587 __pTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
1593 _EditPresenter::DrawSingleLineBackground(Canvas& canvas, bool drawTitleText)
1595 Rectangle editField(0, 0, __pEdit->GetBounds().width, __pEdit->GetBounds().height);
1596 EditStatus editStatus = GetCurrentStatus();
1598 Bitmap* pEditBgBitmap = __pEdit->GetBackgroundBitmap(editStatus);
1602 if (pEditBgBitmap->IsNinePatchedBitmap())
1604 canvas.DrawNinePatchedBitmap(editField, *pEditBgBitmap);
1608 canvas.DrawBitmap(editField, *pEditBgBitmap);
1613 DrawSingleLineBackgroundBitmap(canvas, IsFocused());
1618 if (((__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_LEFT) && !(__titleText.GetLength() == 0)) || (__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_TOP))
1620 DrawTitleText(canvas);
1629 _EditPresenter::DrawSingleLineBackgroundBitmap(Canvas& canvas, bool focused)
1631 if (__isTouchPressed)
1633 DrawChangeableBackground(canvas, focused, 0, 0);
1639 DrawChangeableBackground(canvas, focused, 0, 0, true, 0);
1643 bool tmpFocused = focused;
1644 DrawChangeableBackground(canvas, tmpFocused, 0, 0);
1652 _EditPresenter::DrawClearIcon(Canvas& canvas)
1654 result r = E_SUCCESS;
1656 int clearIconWidth = 0;
1657 int clearIconHeight = 0;
1659 _ControlOrientation orientation = __pEdit->GetOrientation();
1660 GET_SHAPE_CONFIG(EDIT::CLEAR_ICON_WIDTH, orientation, clearIconWidth);
1661 GET_SHAPE_CONFIG(EDIT::CLEAR_ICON_HEIGHT, orientation, clearIconHeight);
1663 if (__pTextString->GetLength() == 0)
1668 Bitmap* pEditBitmapClear = null;
1669 Bitmap* pEditReplacedBitmapClear = null;
1670 Color editClearIconColor;
1672 if (__isClearIconPressed)
1674 r = GET_BITMAP_CONFIG_N(EDIT::CLEAR_ICON_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pEditBitmapClear);
1676 if (pEditBitmapClear == null)
1681 GET_COLOR_CONFIG(EDIT::CLEAR_ICON_PRESSED, editClearIconColor);
1685 r = GET_BITMAP_CONFIG_N(EDIT::CLEAR_ICON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pEditBitmapClear);
1686 if (pEditBitmapClear == null)
1691 GET_COLOR_CONFIG(EDIT::CLEAR_ICON_NORMAL, editClearIconColor);
1693 pEditReplacedBitmapClear = _BitmapImpl::GetColorReplacedBitmapN(*pEditBitmapClear, Color::GetColor(COLOR_ID_MAGENTA),
1694 editClearIconColor);
1695 if (pEditReplacedBitmapClear == null)
1700 Rectangle textRect = __textObjectBounds;
1701 Rectangle afterClearIconRect(textRect.x + textRect.width, textRect.y + (textRect.height - clearIconHeight) / 2, clearIconWidth, clearIconHeight);
1702 if (__clearIconBounds != afterClearIconRect)
1704 __clearIconBounds = afterClearIconRect;
1705 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_CLEAR_ICON);
1708 Rectangle editBounds = __pEdit->GetBounds();
1709 if (editBounds.height < clearIconHeight)
1711 __clearIconBounds.y = textRect.y;
1714 if (pEditReplacedBitmapClear->IsNinePatchedBitmap())
1716 r = canvas.DrawNinePatchedBitmap(__clearIconBounds, *pEditReplacedBitmapClear);
1720 r = canvas.DrawBitmap(__clearIconBounds, *pEditReplacedBitmapClear);
1723 if (pEditBitmapClear)
1725 delete pEditBitmapClear;
1726 pEditBitmapClear = null;
1729 if (pEditReplacedBitmapClear)
1731 delete pEditReplacedBitmapClear;
1732 pEditReplacedBitmapClear = null;
1739 _EditPresenter::Draw(Canvas& canvas)
1741 result r = E_SUCCESS;
1743 if (__isInitialized == false)
1745 r = InitializeAtFirstDrawing();
1746 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Faild to initialize.");
1748 if (IsFocused() == true && __isInputConnectionBound == false)
1750 if (IsViewModeEnabled() == false)
1752 CheckUSBKeyboardStatus();
1754 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
1760 ShowFullscreenKeypad();
1766 __isCursorOpaque = true;
1768 canvas.SetBackgroundColor(Color(0));
1770 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1772 if (__rotated && !IsKeypadExist()) // Command button should be relocated after rotation in case of no keypad.
1774 ChangeLayoutInternal(__pEdit->GetOrientation());
1778 DrawBackground(canvas);
1780 if (__pTextVisualElement)
1788 if (__pEdit->GetEditStyle() & EDIT_STYLE_CLEAR)
1790 DrawClearIcon(canvas);
1799 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
1801 AdjustFlexibleHeight();
1808 _EditPresenter::ConvertLinkType(void)
1810 if (__isCutLinkParserEnabled == false || IsViewModeEnabled() == false)
1815 unsigned long autoLinkMask = GetAutoLinkMask();
1816 bool isChangingCutLink = false;
1817 EditCutLinkType editLinkType = EDIT_LINK_TYPE_INVALID;
1818 TextCutLinkParser cutlinkParser;
1819 cutlinkParser.SetCutLinkMask(autoLinkMask);
1820 TextLinkInfo* pLinkInfo = cutlinkParser.Parse(__pTextBuffer, wcslen(__pTextBuffer), 0);
1821 TextLinkInfo* pNextLinkInfo = null;
1822 int cursorPos = __cursorPos;
1824 __isCutLinkParserEnabled = false;
1826 while (pLinkInfo != null)
1828 if (IsViewModeEnabled() == true)
1830 switch (pLinkInfo->linkType)
1833 if (autoLinkMask & LINK_TYPE_URL)
1835 isChangingCutLink = true;
1836 editLinkType = EDIT_LINK_TYPE_URL;
1840 case LINK_TYPE_EMAIL:
1841 if (autoLinkMask & LINK_TYPE_EMAIL)
1843 isChangingCutLink = true;
1844 editLinkType = EDIT_LINK_TYPE_URL;
1848 case LINK_TYPE_TEL_NUM:
1849 if (autoLinkMask & LINK_TYPE_TEL_NUM)
1851 isChangingCutLink = true;
1852 editLinkType = EDIT_LINK_TYPE_PHONE_NUM;
1857 editLinkType = EDIT_LINK_TYPE_INVALID;
1863 _Text::TextElement* pTextElement = __pTextObject->GetElementAtTextIndex(pLinkInfo->srcOffset);
1864 if (pTextElement != null && pTextElement->GetType() != TEXT_ELEMENT_TYPE_CUTLINK)
1866 pNextLinkInfo = pLinkInfo->pNextLinkInfo;
1868 pLinkInfo = pNextLinkInfo;
1873 wchar_t* pCutLinkString = null;
1874 result r = E_SUCCESS;
1876 pCutLinkString = new(std::nothrow) wchar_t[(pLinkInfo->length + 1) * sizeof(wchar_t)];
1878 if (!pCutLinkString)
1880 while (pLinkInfo != null)
1882 pNextLinkInfo = pLinkInfo->pNextLinkInfo;
1884 pLinkInfo = pNextLinkInfo;
1886 SysLog(NID_UI_CTRL, "[E_SYSTEM] Unable to allocate cutlink text buffer.");
1890 for (int i = 0; i < pLinkInfo->length; i++)
1892 pCutLinkString[i] = __pTextBuffer[pLinkInfo->srcOffset + i];
1894 pCutLinkString[pLinkInfo->length] = null;
1896 r = DeleteText(pLinkInfo->srcOffset, pLinkInfo->srcOffset + pLinkInfo->length);
1900 int currentLength = __pTextString->GetLength();
1901 int fullLength = currentLength + pLinkInfo->length;
1903 r = __pTextString->Insert(String(pCutLinkString), pLinkInfo->srcOffset);
1904 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1906 wchar_t pOriginalString[currentLength - pLinkInfo->srcOffset];
1908 // Save original text.
1909 for (int i = 0; i < currentLength - pLinkInfo->srcOffset; i++)
1911 pOriginalString[i] = __pTextBuffer[pLinkInfo->srcOffset + i];
1913 pOriginalString[currentLength - pLinkInfo->srcOffset] = 0;
1916 for (int i = 0; i < pLinkInfo->length; i++)
1918 __pTextBuffer[i + pLinkInfo->srcOffset] = pCutLinkString[i];
1921 // Append origianal text.
1922 for (int i = 0; i < currentLength - pLinkInfo->srcOffset; i++)
1924 __pTextBuffer[i + pLinkInfo->srcOffset + pLinkInfo->length] = pOriginalString[i];
1926 __pTextBuffer[fullLength] = 0;
1929 if (isChangingCutLink)
1931 TextCutLink* pCutLinkObject = null;
1932 EditCutlinkColor cutlinkColor;
1934 Font* pFont = _FontImpl::CloneN(const_cast <Font&>(*__pFont));
1935 SysTryReturnResult(NID_UI_CTRL, pFont, GetLastResult(), "[EDIT] Unable to get font.");
1937 _FontImpl* fontImpl = _FontImpl::GetInstance(*pFont);
1938 SysTryReturnResult(NID_UI_CTRL, fontImpl, GetLastResult(), "[E_SYSTEM] fontImpl is null.");
1939 fontImpl->SetUnderline(true);
1941 __pEdit->GetCutlinkColorInfo(editLinkType, &cutlinkColor);
1942 pCutLinkObject = new (std::nothrow) TextCutLink(false, pLinkInfo->linkType, pCutLinkString, pLinkInfo->length, TEXT_ELEMENT_SOURCE_TYPE_INTERNAL, pFont,
1943 cutlinkColor.cutlinkFgColor, cutlinkColor.cutlinkBgColor, 0);
1947 if (pCutLinkObject == null)
1949 SysLog(NID_UI_CTRL, "[EDIT] Unable to allocate cutlink object.");
1953 pCutLinkObject->SetEditModeEnable(true);
1954 __pTextObject->InsertElementAt(pLinkInfo->srcOffset, *pCutLinkObject);
1955 __pTextObject->ChangeTextOffset(__pTextBuffer, pLinkInfo->srcOffset, pLinkInfo->length);
1960 TextSimple* pSimpleText = null;
1961 pSimpleText = new (std::nothrow) TextSimple(pCutLinkString, pLinkInfo->length, TEXT_ELEMENT_SOURCE_TYPE_INTERNAL, GetFont());
1963 if (pSimpleText == null)
1965 SysLog(NID_UI_CTRL, "[EDIT] Unable to allocate text object.");
1970 __pTextObject->InsertElementAt(pLinkInfo->srcOffset, *pSimpleText);
1971 __pTextObject->ChangeTextOffset(__pTextBuffer, pLinkInfo->srcOffset, pSimpleText->GetTextLength());
1975 pNextLinkInfo = pLinkInfo->pNextLinkInfo;
1977 pLinkInfo = pNextLinkInfo;
1979 if (pCutLinkString != null)
1981 delete[] pCutLinkString;
1982 pCutLinkString = null;
1986 __pTextObject->Compose();
1988 bool isCursorChanged = __isCursorChanged;
1989 SetCursorPosition(cursorPos);
1990 __isCursorChanged = isCursorChanged;
1996 _EditPresenter::GetLinkElementOffsetInTextBuffer(int elementIndex) const
1998 const int textElementCount = __pTextObject->GetElementCount();
1999 SysTryReturn(NID_UI_CTRL, elementIndex >= 0 && elementIndex <= textElementCount, -1, E_OUT_OF_RANGE, "[EDIT] The Invalid argument is given.");
2001 _Text::TextElement* pTextElement = null;
2002 int elementOffset = -1;
2003 int elementLength = 0;
2007 for (int index = 0; index <= elementIndex; index++)
2009 pTextElement = __pTextObject->GetElementAtElementIndex(index);
2010 if (pTextElement == null)
2015 elementOffset = static_cast<int>(pTextElement->GetValue(SET_TEXT_OFFSET));
2016 elementLength = pTextElement->GetTextLength();
2018 if (pTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)
2020 elementOffset = prevOffset + prevLength;
2023 prevOffset = elementOffset;
2024 prevLength = elementLength;
2025 pTextElement = null;
2028 return elementOffset;
2032 _EditPresenter::GetCursorPositionAt(const Point& touchPoint) const
2037 if (__textObjectBounds.Contains(touchPoint))
2039 cursorPoint.x = touchPoint.x - __textObjectBounds.x;
2040 cursorPoint.y = touchPoint.y - __textObjectBounds.y;
2042 else if (__textBoxBounds.Contains(touchPoint))
2044 if (touchPoint.y <= __textObjectBounds.y)
2046 cursorPoint.y = __textObjectBounds.y + 1;
2048 else if (touchPoint.y >= (__textObjectBounds.y + __textObjectBounds.height))
2050 cursorPoint.y = __textObjectBounds.y + __textObjectBounds.height - 1;
2054 cursorPoint.y = touchPoint.y;
2057 if (touchPoint.x <= __textObjectBounds.x)
2059 cursorPoint.x = __textObjectBounds.x + 1;
2061 else if (touchPoint.x >= (__textObjectBounds.x + __textObjectBounds.width))
2063 cursorPoint.x = __textObjectBounds.x + __textObjectBounds.width - 1;
2067 cursorPoint.x = touchPoint.x;
2069 cursorPoint.y -= __textObjectBounds.y;
2070 cursorPoint.x -= __textObjectBounds.x;
2077 cursorPos = __pTextObject->GetTextIndexFromPosition(cursorPoint.x, cursorPoint.y);
2083 _EditPresenter::IsHorizontalDirection(const _TouchInfo& touchInfo)
2085 if (touchInfo.GetTouchStatus() != _TOUCH_MOVED)
2090 if (__isMovingCursorByTouchMove)
2095 Rectangle absoluteEditRect = __pEdit->GetAbsoluteBounds();
2096 Point touchStartPoint = __pressedAbsolutePoint;
2097 Point touchPoint = touchInfo.GetCurrentPosition();
2099 int movedWidth = touchStartPoint.x - touchPoint.x - absoluteEditRect.x;
2100 int movedHeight = touchStartPoint.y - touchPoint.y - absoluteEditRect.y;
2101 movedWidth = (movedWidth >= 0) ? movedWidth : -(movedWidth);
2102 movedHeight = (movedHeight >= 0) ? movedHeight : -(movedHeight);
2104 if (movedWidth >= movedHeight * DIRECTION_DECISION_RATIO)
2113 _EditPresenter::IsInitialized(void) const
2115 return __isInitialized;
2119 _EditPresenter::CalculateCursorBounds(const Rectangle& textBounds, Rectangle& cursorBounds, int cursorPos)
2121 int cursorWidth = 0;
2122 int cursorHeight = 0;
2125 int cursorRelativeX = 0;
2126 int cursorRelativeY = 0;
2128 __pTextObject->SetBounds(textBounds);
2130 if (cursorPos == -1)
2132 cursorPos = __pTextObject->GetCursorIndex();
2135 if (__pTextObject->GetTextPositionInfoAt(cursorPos, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
2140 cursorBounds.x = cursorRelativeX;
2141 cursorBounds.y = cursorRelativeY;
2142 GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorBounds.width);
2143 cursorBounds.height = cursorHeight;
2145 if (cursorBounds.y == 0)
2147 cursorBounds.y = __textObjectBounds.y;
2150 if (cursorBounds.height == 0)
2152 cursorBounds.height = __textObjectBounds.height;
2155 if (cursorBounds.height == 0)
2160 if (cursorBounds.y < textBounds.y)
2162 int cursorHeightDiff = textBounds.y - cursorBounds.y;
2163 cursorBounds.y = textBounds.y;
2164 cursorBounds.height -= cursorHeightDiff;
2167 if (cursorBounds.x == textBounds.x + textBounds.width)
2169 cursorBounds.x -= 1;
2171 else if (cursorBounds.x > textBounds.x + textBounds.width)
2173 cursorBounds.x = textBounds.x + textBounds.width;
2177 if (__pTextObject->GetBlock() == false)
2179 cursorBounds.x -= 1;
2180 if (cursorBounds.x < textBounds.x)
2182 cursorBounds.x = textBounds.x;
2186 GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorBounds.width);
2192 _EditPresenter::ScrollContents(int moveY)
2195 int firstDisplayY = 0;
2196 int effectDistance = moveY;
2198 int totalHeight = __pTextObject->GetTotalHeight();
2199 int newFirstDisplayY = firstDisplayY = __pTextObject->GetFirstDisplayPositionY();
2200 int currentCursorLine = 0;
2202 if (__pTextObject->GetTextLength() < 1)
2207 if (__pScrollBar && __pScrollBar->GetScrollPosition() == 0 && effectDistance < 0)
2209 if (__pFlickAnimationTimer)
2214 if (__pScrollBar->IsOnFadeEffect() == true)
2216 __pScrollBar->SetScrollVisibility(false);
2221 else if (__pScrollBar && __pScrollBar->GetScrollPosition() != 0 && __pScrollBar->GetScrollPosition() == __previousScrollBarMaxPos && effectDistance > 0)
2223 if (__pFlickAnimationTimer)
2228 if (__pScrollBar->IsOnFadeEffect() == true)
2230 __pScrollBar->SetScrollVisibility(false);
2236 if (__pTextObject->GetCursorIndex() == __pTextObject->GetTextLength())
2238 currentCursorLine = __pTextObject->GetTotalLineCount() - 1;
2242 currentCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
2245 if (currentCursorLine == -1)
2250 if (currentCursorLine < 0)
2252 currentCursorLine = 0;
2255 newFirstDisplayY += moveY;
2257 if (newFirstDisplayY > (totalHeight - __textObjectBounds.height))
2259 newFirstDisplayY = totalHeight - __textObjectBounds.height;
2262 if (newFirstDisplayY < 0)
2264 newFirstDisplayY = 0;
2267 moveLine = __pTextObject->GetLineIndexAtPositionY(newFirstDisplayY);
2269 __pTextObject->SetFirstDisplayLineIndex(moveLine);
2270 __pTextObject->SetFirstDisplayPositionY(newFirstDisplayY);
2272 __isCursorOpaque = false;
2273 if (__isCopyPastePopupVisible)
2275 __pCopyPasteManager->AdjustBounds();
2282 _EditPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
2284 if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
2289 if (__isCopyPastePopupVisible)
2291 __pCopyPasteManager->ReleaseCopyPastePopup();
2294 __isTouchPressed = true;
2296 __pScrollEffect->previousY = touchInfo.GetCurrentPosition().y;
2297 __pScrollEffect->currentY = touchInfo.GetCurrentPosition().y;
2299 Rectangle absoluteEditRect = __pEdit->GetAbsoluteBounds();
2301 __pressedPoint = touchInfo.GetCurrentPosition();
2302 __pressedAbsolutePoint.x = __pressedPoint.x + absoluteEditRect.x;
2303 __pressedAbsolutePoint.y = __pressedPoint.y + absoluteEditRect.y;
2305 if (IsViewModeEnabled())
2307 int cutLinkIndex = -1;
2309 __pTextObject->ResetAllCutLinkElementsState();
2311 cutLinkIndex = __pTextObject->GetCutLinkIndexFromPositionData(__pressedPoint.x - __textObjectBounds.x, __pressedPoint.y - __textObjectBounds.y);
2313 if (cutLinkIndex != -1)
2315 __pTextObject->ChangeCutLinkState(cutLinkIndex, true);
2319 if (__pEdit->GetEditStyle() & EDIT_STYLE_CLEAR)
2321 if ((__pressedPoint.x >= __clearIconBounds.x) && (__pressedPoint.x <= __clearIconBounds.x + __clearIconBounds.width)) // Clear Icon Pressed
2323 __isClearIconPressed = true;
2328 __pEdit->Invalidate();
2334 _EditPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
2336 if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
2341 if (__isClearIconPressed)
2343 __isClearIconPressed = false;
2346 __isTouchPressed = false;
2347 __isMovingCursorByTouchMove = false;
2349 if (__isTouchReleaseSkipped || __isTouchMoving)
2351 __isTouchReleaseSkipped = false;
2353 __isTouchMoving = false;
2356 if (__isScrollBarVisible && __pScrollBar)
2358 if (__pScrollBar->IsVisible())
2360 __pScrollBar->SetScrollVisibility(false);
2362 __isScrollBarVisible = false;
2365 __isTouchMoving = false;
2366 __pEdit->Invalidate();
2372 _EditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
2374 if (__isCopyPastePopupVisible)
2376 if (__isTouchPressed && !__isCopyPastePopupMoving)
2378 InitializeCopyPasteManager();
2382 __pCopyPasteManager->CreateCopyPastePopup();
2383 __pCopyPasteManager->AdjustBounds();
2384 __pCopyPasteManager->Show();
2386 __isCopyPastePopupMoving = false;
2389 if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
2394 int cutLinkIndex = -1;
2395 Rectangle clientBounds;
2396 Point touchPoint = touchInfo.GetCurrentPosition();
2398 if (IsViewModeEnabled())
2400 __pEdit->SetFocused();
2401 __pTextObject->ResetAllCutLinkElementsState();
2404 if (__isClearIconPressed)
2406 __isClearIconPressed = false;
2407 if ((touchPoint.x >= __clearIconBounds.x) && (touchPoint.x <= __clearIconBounds.x + __clearIconBounds.width)
2408 && (touchPoint.y >= __clearIconBounds.y) && (touchPoint.y <= __clearIconBounds.y + __clearIconBounds.height))
2411 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
2412 __isTouchPressed = false;
2413 __isMovingCursorByTouchMove = false;
2414 __pEdit->Invalidate();
2420 if (!__isCopyPastePopupVisible)
2422 __isTextBlocked = false;
2424 __isTouchPressed = false;
2425 __isMovingCursorByTouchMove = false;
2427 if (__isTouchReleaseSkipped)
2429 __isTouchReleaseSkipped = false;
2431 __isTouchMoving = false;
2432 __pEdit->Invalidate();
2437 if (IsViewModeEnabled())
2439 cutLinkIndex = __pTextObject->GetCutLinkIndexFromPositionData(touchPoint.x - __textObjectBounds.x, touchPoint.y - __textObjectBounds.y);
2441 if (cutLinkIndex != -1)
2443 TextCutLink* pCutLinkObject = dynamic_cast<TextCutLink*>(__pTextObject->GetCutLinkElementAtCutLinkElementIndex(cutLinkIndex));
2444 if (pCutLinkObject == null)
2449 String cutLinkString(pCutLinkObject->GetText());
2450 LinkType baseLinkType = pCutLinkObject->GetCutLinkType();
2452 // Send Ui Link Event
2453 __pEdit->SendLinkEvent(cutLinkString, baseLinkType, cutLinkString);
2456 if (__isTouchMoving && __isInputConnectionBound == false)
2459 __isTouchMoving = false;
2460 __isTouchReleaseSkipped = false;
2461 __pEdit->Invalidate();
2466 clientBounds = __pEdit->GetBounds();
2469 touchPoint = touchInfo.GetCurrentPosition();
2470 if (clientBounds.Contains(touchPoint))
2472 int cursorPos = GetCursorPositionAt(touchPoint);
2473 if (cursorPos != -1)
2475 if (__isInputConnectionBound == true && __isTextComposing == true)
2477 __pInputConnection->FinishTextComposition();
2479 if (!__isCopyPastePopupVisible) // Copy&Paste
2481 if ((__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) == true && IsFocused() == false)
2483 __isCursorChanged = true;
2487 SetCursorPosition(cursorPos);
2493 if ((cutLinkIndex < 0) &&
2494 ((__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER) == false) && (IsKeypadEnabled()))
2496 CheckUSBKeyboardStatus();
2498 if (__isUSBKeyboardConnected)
2500 if (!__isInputConnectionBound)
2502 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
2510 __pEdit->SetFocused();
2515 ShowFullscreenKeypad();
2521 CheckKeypadStatus();
2523 if (!IsKeypadExist() || !__isInputConnectionBound)
2525 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
2533 __pEdit->SetFocused();
2538 ShowFullscreenKeypad();
2545 if (__isScrollBarVisible && __pScrollBar)
2547 if (__pScrollBar->IsVisible())
2549 __pScrollBar->SetScrollVisibility(false);
2551 __isScrollBarVisible = false;
2554 __isTouchMoving = false;
2555 __pEdit->Invalidate();
2561 _EditPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
2563 if ((&source != __pEdit) || (__pEdit->GetEnableState() == false))
2568 Point touchPoint = touchInfo.GetCurrentPosition();
2570 if (__isClearIconPressed)
2572 if ((touchPoint.x < __clearIconBounds.x) || (touchPoint.x > __clearIconBounds.x + __clearIconBounds.width)
2573 || (touchPoint.y < __clearIconBounds.y) || (touchPoint.y > __clearIconBounds.y + __clearIconBounds.height))
2575 __isClearIconPressed = false;
2576 __pEdit->Invalidate();
2580 if (__isCopyPastePopupVisible)
2582 __pCopyPasteManager->AdjustBounds();
2583 __pCopyPasteManager->Show();
2584 __isCopyPastePopupMoving = true;
2587 if (__isTouchMoving == false && IsHorizontalDirection(touchInfo))
2589 if (__isCopyPastePopupVisible && IsBlocked())
2595 Rectangle fromBounds;
2598 CalculateCursorBounds(__textObjectBounds, fromBounds);
2599 newIndex = GetCursorPositionAt(touchInfo.GetCurrentPosition());
2602 if (Math::Abs(newIndex - __cursorPos) > 3)
2607 CalculateCursorBounds(__textObjectBounds, toBounds, newIndex);
2608 __isCursorChanged = true;
2609 SetCursorPosition(newIndex);
2611 __isMovingCursorByTouchMove = true;
2612 __isTouchReleaseSkipped = true;
2615 MoveCursor(fromBounds, toBounds);
2616 __pEdit->Invalidate();
2621 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
2623 int horizontalGap = touchInfo.GetCurrentPosition().x - fromBounds.x;
2624 Dimension currentCharacterDimension;
2625 if (horizontalGap > 0 && __cursorPos < GetTextLength())
2627 currentCharacterDimension = __pTextObject->GetTextExtent(__cursorPos, 1);
2628 if (horizontalGap >= currentCharacterDimension.width)
2630 SetCursorPosition(__cursorPos+1);
2631 __pEdit->Invalidate();
2635 if (horizontalGap < 0 && __cursorPos > 0)
2637 currentCharacterDimension = __pTextObject->GetTextExtent(__cursorPos-1, 1);
2638 if (Math::Abs(horizontalGap) >= currentCharacterDimension.width)
2640 SetCursorPosition(__cursorPos-1);
2641 __pEdit->Invalidate();
2647 if (__isMovingCursorByTouchMove)
2653 int totalHeight = __pTextObject->GetTotalHeight();
2657 if (__textObjectBounds.height >= totalHeight)
2659 __isTouchMoving = true;
2660 __isTouchReleaseSkipped = true;
2665 if ((touchInfo.GetCurrentPosition().y == __pScrollEffect->currentY) ||
2666 (Math::Abs(touchInfo.GetCurrentPosition().y - __pScrollEffect->previousY) < MOVE_SKIP_DECISION_RANGE))
2671 __pScrollEffect->previousY = __pScrollEffect->currentY;
2672 __pScrollEffect->currentY = touchInfo.GetCurrentPosition().y;
2674 int moveGap = __pScrollEffect->previousY - __pScrollEffect->currentY;
2676 if (__isMovingCursorByTouchMove)
2678 __isMovingCursorByTouchMove = false;
2681 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_NOSCROLL))
2685 if (totalHeight > __textObjectBounds.height)
2687 __pScrollBar->SetScrollVisibility(true);
2691 __pScrollBar->SetScrollVisibility(false);
2696 result returnResult = ScrollContents(moveGap);
2698 __isCursorChanged = false;
2699 __isTouchMoving = true;
2703 if (returnResult == E_SUCCESS)
2709 __isTouchReleaseSkipped = true;
2715 _EditPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
2717 result r = E_SUCCESS;
2718 _KeyCode keyCode = keyInfo.GetKeyCode();
2721 if (IsViewModeEnabled() == true)
2726 if (__isUSBKeyboardConnected && (keyInfo.GetKeyModifier() & _KEY_MODIFIER_CTRL))
2731 if (__isInputConnectionBound && __isTextComposing)
2733 __pInputConnection->FinishTextComposition();
2734 __isTextComposing = false;
2735 __composingTextLength = 0;
2738 if (__isCopyPastePopupVisible)
2740 InitializeCopyPasteManager();
2743 textLength = __pEdit->GetTextLength();
2748 __pEdit->SetBlockRange(0, textLength);
2749 r = __pEdit->SendTextBlockEvent(0, textLength);
2750 UpdateComponentInformation();
2751 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r));
2752 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
2753 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, true, E_OUT_OF_MEMORY, "[EDIT] Unable to create _EditCopyPasteManager instance.");
2754 __pCopyPasteManager->AddCopyPasteEventListener(*this);
2755 __pCopyPasteManager->CreateCopyPastePopup();
2756 __pCopyPasteManager->Show();
2757 __isCopyPastePopupVisible = true;
2760 textLength = __pEdit->GetTextLength();
2766 if (__isCopyPastePopupVisible)
2768 InitializeCopyPasteManager();
2772 textLength = __pEdit->GetTextLength();
2778 if (__isCopyPastePopupVisible)
2780 InitializeCopyPasteManager();
2785 if (__isCopyPastePopupVisible)
2787 InitializeCopyPasteManager();
2793 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
2799 __pEdit->Invalidate();
2804 else if (__isUSBKeyboardConnected && keyInfo.GetKeyModifier() & _KEY_MODIFIER_SHIFT)
2806 if (!__isCopyPastePopupVisible)
2814 __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_LEFT);
2817 __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_UP);
2820 __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_DOWN);
2823 __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_RIGHT);
2830 else if (_KEY_ENTER == keyCode)
2832 if (__isInputConnectionBound != false && __isTextComposing != false)
2838 if (IsKeypadActionEnabled())
2840 char enterText[2] = {'\n', };
2841 OnTextCommitted(String(enterText));
2847 else if (_KEY_BACKSPACE == keyCode)
2849 if (__isTextComposing == false)
2851 OnSurroundingTextDeleted(-1, 1);
2852 ScrollPanelToCursorPosition();
2856 else if ((keyInfo.GetKeyModifier() & _KEY_LOCK_NUM) && (_KEY_NUM_LEFT == keyCode || _KEY_NUM_RIGHT == keyCode || _KEY_NUM_UP == keyCode || _KEY_NUM_DOWN == keyCode))
2860 else if (_KEY_LEFT == keyCode || _KEY_NUM_LEFT == keyCode)
2862 if (__isCopyPastePopupVisible)
2864 InitializeCopyPasteManager();
2867 if (__isInputConnectionBound != false && __isTextComposing != false)
2869 __pInputConnection->FinishTextComposition();
2870 __isTextComposing = false;
2871 __composingTextLength = 0;
2874 if (__cursorPos != 0)
2876 int startPosition = -1;
2877 int endPosition = -1;
2878 GetTextImageRangeAt(__cursorPos-1, startPosition, endPosition);
2879 if (startPosition>0 && startPosition < __cursorPos-1)
2881 SetCursorPosition(startPosition);
2885 SetCursorPosition(__cursorPos-1);
2887 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
2894 else if (_KEY_UP == keyCode || _KEY_NUM_UP == keyCode)
2896 if (__isCopyPastePopupVisible)
2898 InitializeCopyPasteManager();
2901 if (__isInputConnectionBound != false && __isTextComposing != false)
2903 __pInputConnection->FinishTextComposition();
2904 __isTextComposing = false;
2905 __composingTextLength = 0;
2908 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
2909 if (curCursorLine !=0 )
2911 int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
2912 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine-1);
2913 int newCursorPosition = offset + firstTextIndex;
2914 int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
2915 Rectangle clientBounds(0, 0, 0, 0);
2916 Rectangle absCursorBounds(0, 0, 0, 0);
2917 if (offset<textLength)
2919 int startPosition = -1;
2920 int endPosition = -1;
2921 GetTextImageRangeAt(newCursorPosition, startPosition, endPosition);
2922 if (endPosition > newCursorPosition && startPosition < newCursorPosition)
2924 newCursorPosition = endPosition;
2926 SetCursorPosition(newCursorPosition);
2931 __pTextString->GetCharAt(firstTextIndex+textLength - 1, ch);
2934 SetCursorPosition(firstTextIndex+textLength - 1);
2938 SetCursorPosition(firstTextIndex+textLength);
2944 clientBounds = __pParentForm->GetClientBounds();
2945 GetCursorBounds(true, absCursorBounds);
2946 if (!clientBounds.Contains(Point(absCursorBounds.x, absCursorBounds.y)))
2948 ScrollPanelToCursorPosition();
2949 __pParentForm->Draw();
2952 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
2959 else if (_KEY_DOWN == keyCode || _KEY_NUM_DOWN == keyCode)
2961 if (__isCopyPastePopupVisible)
2963 InitializeCopyPasteManager();
2966 if (__isInputConnectionBound != false && __isTextComposing != false)
2968 __pInputConnection->FinishTextComposition();
2969 __isTextComposing = false;
2970 __composingTextLength = 0;
2973 int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
2974 int totalLine = __pTextObject->GetTotalLineCount();
2975 if (curCursorLine < totalLine - 1)
2977 int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine);
2978 int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1);
2979 int newCursorPosition = offset + firstTextIndex;
2980 int textLength = __pTextObject->GetTextLengthAt(curCursorLine+1);
2981 Rectangle clientBounds(0, 0, 0, 0);
2982 Rectangle absCursorBounds(0, 0, 0, 0);
2984 if (offset<textLength)
2986 int startPosition = -1;
2987 int endPosition = -1;
2988 GetTextImageRangeAt(newCursorPosition, startPosition, endPosition);
2989 if (endPosition > newCursorPosition && startPosition < newCursorPosition)
2991 newCursorPosition = endPosition;
2993 SetCursorPosition(newCursorPosition);
2998 __pTextString->GetCharAt(firstTextIndex+textLength - 1, ch);
3001 SetCursorPosition(firstTextIndex+textLength - 1);
3005 SetCursorPosition(firstTextIndex+textLength);
3011 clientBounds = __pParentForm->GetClientBounds();
3012 GetCursorBounds(true, absCursorBounds);
3014 if (!clientBounds.Contains(Point(absCursorBounds.x, absCursorBounds.y + absCursorBounds.height)))
3016 ScrollPanelToCursorPosition();
3017 __pParentForm->Draw();
3020 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
3027 else if (_KEY_RIGHT == keyCode || _KEY_NUM_RIGHT == keyCode)
3029 if (__isCopyPastePopupVisible)
3031 InitializeCopyPasteManager();
3034 if (__isInputConnectionBound != false && __isTextComposing != false)
3036 __pInputConnection->FinishTextComposition();
3037 __isTextComposing = false;
3038 __composingTextLength = 0;
3041 if (__cursorPos < GetTextLength())
3043 int startPosition = -1;
3044 int endPosition = -1;
3045 GetTextImageRangeAt(__cursorPos, startPosition, endPosition);
3046 if (endPosition > __cursorPos+1 && startPosition > -1)
3048 SetCursorPosition(endPosition);
3052 SetCursorPosition(__cursorPos+1);
3054 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
3061 else if (_KEY_DELETE == keyCode)
3063 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
3065 if (!GetTextLength())
3071 if (__isCopyPastePopupVisible)
3073 if (IsBlocked() == true)
3077 GetBlockRange(start, end);
3078 DeleteText(start, end);
3083 int cursorPosition = GetCursorPosition();
3084 DeleteText(cursorPosition, cursorPosition+1);
3087 InitializeCopyPasteManager();
3091 if (__isInputConnectionBound && __isTextComposing)
3093 __pInputConnection->FinishTextComposition();
3094 __isTextComposing = false;
3095 __composingTextLength = 0;
3098 int cursorPosition = GetCursorPosition();
3099 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
3101 DeleteText(cursorPosition, cursorPosition+1);
3105 OnSurroundingTextDeleted(0, 1);
3108 if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false)
3114 __pEdit->Invalidate();
3116 ScrollPanelToCursorPosition();
3125 _EditPresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
3127 _KeyCode keyCode = keyInfo.GetKeyCode();
3129 if (__isUSBKeyboardConnected && (keyCode == _KEY_SHIFT_L || keyCode == _KEY_SHIFT_R))
3131 if (__pCopyPasteManager && __pCopyPasteManager->IsHandlerMovingEnabled())
3133 __pCopyPasteManager->SetHandlerMovingEnabled(false);
3134 __pCopyPasteManager->CreateCopyPastePopup();
3135 __pCopyPasteManager->Show();
3144 _EditPresenter::OnClipboardPopupClosed(const ClipboardItem* pClipboardItem)
3149 if (!pClipboardItem && IsBlocked())
3154 SysTryReturnVoidResult(NID_UI_CTRL, pClipboardItem != null, E_SYSTEM, "[E_SYSTEM] _EditPresenter::OnClipboardPopupClosed: Unable to get the clipboarditem instance.");
3156 String* pClipString = dynamic_cast<String*>(pClipboardItem->GetData());
3157 SysTryReturnVoidResult(NID_UI_CTRL, pClipString != null, E_SYSTEM, "[E_SYSTEM] _EditPresenter::OnClipboardPopupClosed: Unable to get the clipboarditem instance.");
3159 int currentLength = GetTextLength();
3160 String* pSubString = null;
3161 result r = E_SUCCESS;
3166 GetBlockRange(start, end);
3167 total = currentLength - (end - start) + pClipString->GetLength();
3168 if (total > __limitLength)
3170 DeleteText(start, end);
3172 pSubString = new String(__limitLength - currentLength + (end - start));
3173 SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "[EDIT] Unable to allocate text buffer.");
3175 pClipString->SubString(0, __limitLength - currentLength + (end - start), *pSubString);
3176 r = InsertTextAt(__cursorPos, pSubString->GetPointer());
3177 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3182 DeleteText(start, end);
3184 r = InsertTextAt(__cursorPos, pClipString->GetPointer());
3185 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3188 else if (currentLength + pClipString->GetLength() > __limitLength)
3190 if (__limitLength == currentLength)
3192 delete pClipboardItem;
3196 pSubString = new String(__limitLength - currentLength);
3197 SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "[EDIT] Unable to allocate text buffer.");
3199 pClipString->SubString(0, __limitLength - currentLength, *pSubString);
3200 r = InsertTextAt(__cursorPos, pSubString->GetPointer());
3201 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3206 r = InsertTextAt(__cursorPos, pClipString->GetPointer());
3207 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3210 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
3212 __pEdit->Invalidate();
3214 delete pClipboardItem;
3219 delete pClipboardItem;
3225 _EditPresenter::OnLongPressGestureDetected(void)
3227 if (__isCopyPastePopupVisible)
3231 else if (IsFocused() == false && !IsViewModeEnabled())
3236 __isTouchPressed = false;
3237 Rectangle cursorBounds;
3238 InitializeCopyPasteManager();
3239 if (IsClipped() || GetTextLength())
3241 if (IsClipped() && !GetTextLength() && (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER))
3246 if (__isInputConnectionBound && __isTextComposing)
3248 __pInputConnection->FinishTextComposition();
3249 __isTextComposing = false;
3250 __composingTextLength = 0;
3253 int cursorPos = GetCursorPositionAt(__pressedPoint);
3254 if (cursorPos == -1)
3258 SetCursorPosition(cursorPos);
3259 ScrollPanelToCursorPosition();
3260 GetCursorBounds(true, cursorBounds);
3262 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
3263 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, false, E_SYSTEM, "[EDIT] Unable to create _EditCopyPasteManager instance.");
3264 __pCopyPasteManager->AddCopyPasteEventListener(*this);
3265 __pCopyPasteManager->Show();
3266 __isCopyPastePopupVisible = true;
3274 _EditPresenter::OnTapGestureDetected(void)
3276 if (IsFocused() == false || __isCopyPastePopupVisible)
3281 if (!__isUSBKeyboardConnected)
3283 if (__isKeypadShowing)
3287 __isTouchPressed = false;
3288 InitializeCopyPasteManager();
3290 if (GetTextLength() > 0)
3292 Rectangle cursorBounds;
3295 int cursorPos = GetCursorPositionAt(__pressedPoint);
3297 if (cursorPos == -1)
3302 GetWordPosition(cursorPos, start, end);
3303 SetBlockRange(start, end);
3304 ScrollPanelToCursorPosition();
3305 GetCursorBounds(true, cursorBounds);
3307 __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit);
3308 SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, false, E_SYSTEM, "[EDIT] Unable to create _EditCopyPasteManager instance.");
3309 __pCopyPasteManager->AddCopyPasteEventListener(*this);
3310 __pCopyPasteManager->CreateCopyPastePopup();
3311 __pCopyPasteManager->Show();
3312 __isCopyPastePopupVisible = true;
3314 if (__isInputConnectionBound && __isTextComposing)
3316 __pInputConnection->FinishTextComposition();
3317 __isTextComposing = false;
3318 __composingTextLength = 0;
3327 _EditPresenter::GetTextAlignment(void) const
3329 return __horizontalAlignment;
3333 _EditPresenter::GetLineSpacing(void) const
3335 int linePixelGap = -1;
3337 linePixelGap = __pTextObject->GetLineSpace();
3339 return linePixelGap;
3343 _EditPresenter::GetBlockRange(int& start, int& end) const
3345 if (__isTextBlocked == false || __cursorPos == __blockStartPos)
3350 if (__cursorPos > __blockStartPos)
3352 start = __blockStartPos;
3357 start = __cursorPos;
3358 end = __blockStartPos;
3365 _EditPresenter::SetBlockRange(int start, int end)
3367 result r = E_SUCCESS;
3369 r = SetCursorPosition(start);
3370 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3372 r = BeginTextBlock();
3373 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3375 r = SetCursorPosition(end);
3376 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3382 _EditPresenter::BeginTextBlock(void)
3384 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
3387 __isTextBlocked = true;
3388 __blockStartPos = __cursorPos;
3394 _EditPresenter::ReleaseTextBlock(void)
3396 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
3400 if (__isTextBlocked == false)
3405 __isTextBlocked = false;
3411 _EditPresenter::IsBlocked(void) const
3413 return __isTextBlocked;
3417 _EditPresenter::CopyText(void)
3419 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
3422 result r = E_SUCCESS;
3424 _Clipboard* pClipBoard = _Clipboard::GetInstance();
3425 SysTryReturnResult(NID_UI_CTRL, pClipBoard != null, E_SYSTEM, "[EDIT] Unable to get the clipboard instance.");
3429 GetBlockRange(start, end);
3431 String blockString(GetText(start, end - 1));
3433 _ClipboardItem* pClipboardItem = _ClipboardItem::CreateInstanceN(CLIPBOARD_DATA_TYPE_TEXT, blockString);
3434 SysTryReturnResult(NID_UI_CTRL, pClipboardItem != null, E_SYSTEM, "[EDIT] Unable to get the clipboarditem instance.");
3436 r = pClipBoard->CopyItem(*pClipboardItem);
3438 delete pClipboardItem;
3440 _Text::TextElement* pStartTextElement = __pTextObject->GetElementAtTextIndex(start);
3441 _Text::TextElement* pEndTextElement = __pTextObject->GetElementAtTextIndex(end-1);
3443 if (pStartTextElement == null || pEndTextElement == null)
3448 const int startIndex = __pTextObject->GetElementIndexOf(*pStartTextElement);
3449 const int endIndex = __pTextObject->GetElementIndexOf(*pEndTextElement);
3451 for (int index = startIndex; index <= endIndex; index++)
3453 _Text::TextElement* pTextElement = __pTextObject->GetElementAtElementIndex(index);
3454 TextElementType objectType = pTextElement->GetType();
3455 if (objectType != TEXT_ELEMENT_TYPE_IMAGE)
3459 TextImage* pImageText = null;
3460 pImageText = dynamic_cast < TextImage* >(pTextElement);
3461 if ( pImageText == null)
3465 const Bitmap * pImage = pImageText->GetBitmap();
3466 SysTryReturnResult(NID_UI_CTRL, pImage != null, E_SYSTEM, "[EDIT] Unable to get the bitmap from textobject.");
3468 _ClipboardItem* pClipboardImageItem = _ClipboardItem::CreateInstanceN(CLIPBOARD_DATA_TYPE_IMAGE, *pImage);
3469 SysTryReturnResult(NID_UI_CTRL, pClipboardImageItem != null, E_SYSTEM, "[EDIT] Unable to get the clipboardImageitem instance.");
3471 r = pClipBoard->CopyItem(*pClipboardImageItem);
3473 delete pClipboardImageItem;
3480 _EditPresenter::CutText(void)
3482 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
3485 result r = E_SUCCESS;
3488 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3492 GetBlockRange(start, end);
3493 DeleteText(start, end);
3496 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
3502 _EditPresenter::PasteText(void)
3504 result r = E_SUCCESS;
3505 int currentLength = GetTextLength();
3506 String* pSubString = null;
3512 _Clipboard* pClipBoard = _Clipboard::GetInstance();
3513 SysTryReturnResult(NID_UI_CTRL, pClipBoard != null, E_SYSTEM, "[EDIT] Unable to get the clipboard instance.");
3515 const _ClipboardItem* pClipboardItem = pClipBoard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT);
3516 SysTryReturnResult(NID_UI_CTRL, pClipboardItem != null, E_SYSTEM, "[EDIT] Unable to get the clipboarditem instance.");
3518 const String* pClipString = dynamic_cast<const String*>(pClipboardItem->GetData());
3519 SysTryCatch(NID_UI_CTRL, pClipString, r = E_SYSTEM, E_SYSTEM, "[EDIT] Unable to get the clipboarditem instance.");
3523 GetBlockRange(start, end);
3524 total = currentLength - (end - start) + pClipString->GetLength();
3525 if (total > __limitLength)
3527 DeleteText(start, end);
3529 pSubString = new String(__limitLength - currentLength + (end - start));
3530 SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "[EDIT] Unable to allocate text buffer.");
3532 pClipString->SubString(0, __limitLength - currentLength + (end - start), *pSubString);
3533 r = InsertTextAt(__cursorPos, pSubString->GetPointer());
3534 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3539 DeleteText(start, end);
3541 r = InsertTextAt(__cursorPos, pClipString->GetPointer());
3542 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3545 else if (currentLength + pClipString->GetLength() > __limitLength)
3547 if (__limitLength == currentLength)
3549 delete pClipboardItem;
3553 pSubString = new String(__limitLength - currentLength);
3554 SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "[EDIT] Unable to allocate text buffer.");
3556 pClipString->SubString(0, __limitLength - currentLength, *pSubString);
3557 r = InsertTextAt(__cursorPos, pSubString->GetPointer());
3558 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3563 r = InsertTextAt(__cursorPos, pClipString->GetPointer());
3564 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
3567 delete pClipboardItem;
3569 ReplaceTextIntoPasswordHyphenString();
3571 __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
3576 delete pClipboardItem;
3582 _EditPresenter::RemoveTextBlock(void)
3584 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
3588 if (!__isTextBlocked)
3590 return E_OBJ_NOT_FOUND;
3596 GetBlockRange(start, end);
3599 return E_OBJ_NOT_FOUND;
3602 result r = DeleteText(start, end);
3603 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3605 __isTextBlocked = false;
3611 _EditPresenter::IsClipped(void) const
3613 _Clipboard* pClipBoard = _Clipboard::GetInstance();
3614 SysTryReturn(NID_UI_CTRL, pClipBoard != null, false, E_SYSTEM, "[EDIT] Unable to get the clipboard instance.");
3616 const _ClipboardItem* pClipboardItem = pClipBoard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT);
3617 if (pClipboardItem == null)
3619 SetLastResult(E_SUCCESS);
3622 delete pClipboardItem;
3628 _EditPresenter::SetTextAlignment(HorizontalAlignment alignment)
3630 result r = E_SUCCESS;
3632 int textAlign = TEXT_OBJECT_ALIGNMENT_LEFT;
3634 if (alignment == ALIGNMENT_CENTER)
3636 textAlign = TEXT_OBJECT_ALIGNMENT_CENTER;
3638 else if (alignment == ALIGNMENT_RIGHT)
3640 textAlign = TEXT_OBJECT_ALIGNMENT_RIGHT;
3643 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
3645 r = __pTextObject->SetAlignment(textAlign | TEXT_OBJECT_ALIGNMENT_MIDDLE);
3649 r = __pTextObject->SetAlignment(textAlign | TEXT_OBJECT_ALIGNMENT_TOP);
3651 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[EDIT] Unable to set text alignment.");
3652 __horizontalAlignment = alignment;
3658 _EditPresenter::SetLineSpacing(int linePixelGap)
3660 result r = E_SUCCESS;
3662 __pTextObject->SetLineSpace(linePixelGap);
3668 _EditPresenter::GetText(int start, int end) const
3677 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
3679 int length = end - start + 1;
3680 __pTextString->SubString(start, length, tempString);
3685 String resultString;
3686 String elementString;
3687 const int textElementCount = __pTextObject->GetElementCount();
3688 _Text::TextElement* pTextElement = __pTextObject->GetElementAtTextIndex(start);
3690 if (pTextElement == null)
3692 return resultString;
3694 const int startIndex = __pTextObject->GetElementIndexOf(*pTextElement);
3696 for (int index = startIndex; index < textElementCount; index++)
3698 _Text::TextElement* pTextElement = __pTextObject->GetElementAtElementIndex(index);
3699 TextSimple* pSimpleText = null;
3700 if (pTextElement == null)
3705 TextElementType objectType = pTextElement->GetType();
3706 if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK)
3708 pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
3709 if ( pSimpleText == null)
3720 int elementOffset = static_cast < int >(pTextElement->GetValue(SET_TEXT_OFFSET));
3721 int elementLength = pTextElement->GetTextLength();
3723 if (objectType == TEXT_ELEMENT_TYPE_CUTLINK)
3725 elementOffset = GetLinkElementOffsetInTextBuffer(index);
3726 if (elementOffset < 0)
3732 if (end < elementOffset)
3736 if (start >= elementOffset + elementLength)
3741 if (elementLength == 0)
3745 elementString.Clear();
3746 elementString.Append(pSimpleText->GetText());
3747 elementString.SetLength(elementLength);
3748 if (end < elementOffset + elementLength - 1)
3750 int removingStartIndex = end + 1;
3751 elementString.Remove(removingStartIndex - elementOffset, elementOffset + elementLength - removingStartIndex);
3753 if (start > elementOffset)
3755 elementString.Remove(0, start - elementOffset);
3757 resultString.Append(elementString);
3760 return resultString;
3764 _EditPresenter::GetText(void) const
3766 return GetText(0, GetTextLength()-1);
3770 _EditPresenter::SetText(const String& text)
3772 result r = E_SUCCESS;
3774 int length = text.GetLength();
3775 if ((__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) || (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER))
3777 if (__limitLength <= length)
3779 String tempString = GetText();
3780 SetTextLimitLength(length * 2);
3785 SysTryReturnResult(NID_UI_CTRL, length <= __limitLength, E_INVALID_ARG, "[EDIT] The Invalid argument is given.");
3788 if (__isInputConnectionBound && __isTextComposing)
3790 __pInputConnection->FinishTextComposition();
3791 __isTextComposing = false;
3792 __composingTextLength = 0;
3795 __pTextString->Clear();
3796 __pTextString->Append(text);
3798 wchar_t* tempString = const_cast<wchar_t*>(text.GetPointer());
3799 for (int i = 0; i < length; i++)
3801 __pTextBuffer[i] = tempString[i];
3803 __pTextBuffer[length] = 0;
3805 __pTextObject->RemoveAll();
3806 TextSimple* pSimpleText = new (std::nothrow)TextSimple(__pTextBuffer, length,TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, __pFont);
3807 __pTextObject->AppendElement(*pSimpleText);
3808 __pTextObject->Compose();
3810 ReplaceTextIntoPasswordHyphenString();
3812 SetCursorPosition(length);
3814 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
3816 AdjustFlexibleHeight();
3819 if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)
3821 __isCutLinkParserEnabled = true;
3824 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
3830 _EditPresenter::GetRemainingLength(void) const
3832 return __limitLength - __pTextObject->GetTextLength();
3836 _EditPresenter::SetCursorPosition(int position)
3838 result r = E_SUCCESS;
3839 int length = GetTextLength();
3841 SysTryReturnResult(NID_UI_CTRL, -1 < position && position <= length, E_INVALID_ARG, "[Edit] Invalid argument is given.");
3843 if (__isTouchMoving == false)
3845 __isCursorChanged = true;
3848 r = __pTextObject->SetCursorIndex(position);
3849 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[Edit] Failed to set cursor position");
3851 __cursorPos = position;
3857 _EditPresenter::GetCursorPosition(void) const
3863 _EditPresenter::GetTextLength(void) const
3865 return __pTextObject->GetTextLength();
3869 _EditPresenter::InsertTextAt(int index, const String& text)
3871 result r = E_SUCCESS;
3873 int currentLength = GetTextLength();
3874 int length = text.GetLength();
3875 int totalLength = currentLength + length;
3877 SysTryReturnResult(NID_UI_CTRL, index >= 0 && index <= currentLength, E_OUT_OF_RANGE, "[EDIT] The Invalid argument is given.");
3879 if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)
3881 if (__limitLength <= totalLength)
3883 String tempString = GetText();
3884 SetTextLimitLength(totalLength * 2);
3885 SetText(tempString);
3890 SysTryReturnResult(NID_UI_CTRL, totalLength <= __limitLength, E_INVALID_ARG, "[EDIT] The Invalid argument is given.");
3893 r = __pTextString->Insert(text, index);
3894 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3896 wchar_t* pTempString = const_cast<wchar_t*>(text.GetPointer());
3897 wchar_t pOriginalString[currentLength - index];
3899 for (int i = 0; i < currentLength - index; i++)
3901 pOriginalString[i] = __pTextBuffer[index + i];
3903 pOriginalString[currentLength - index] = 0;
3905 for (int i = 0; i < length; i++)
3907 __pTextBuffer[i + index] = pTempString[i];
3910 for (int i = 0; i < currentLength - index; i++)
3912 __pTextBuffer[i + index + length] = pOriginalString[i];
3914 __pTextBuffer[totalLength] = 0;
3916 __pTextObject->SetRange(index, length);
3917 r = __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), length);
3918 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[Edit] Failed to set length");
3920 __pTextObject->Compose();
3922 if (__isTextBlocked == true)
3924 DeleteText(__blockStartPos, __cursorPos);
3927 SetCursorPosition(__cursorPos + length);
3931 SetCursorPosition(index + length);
3934 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
3936 AdjustFlexibleHeight();
3939 __isCursorChanged = true;
3941 if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)
3943 __isCutLinkParserEnabled = true;
3946 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
3952 _EditPresenter::AppendText(const String& text)
3954 result r = E_SUCCESS;
3956 int currentLength = GetTextLength();
3957 int length = text.GetLength();
3958 int totalLength = currentLength + length;
3960 if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)
3962 if (__limitLength <= totalLength)
3964 String tempString = GetText();
3965 SetTextLimitLength(totalLength * 2);
3966 SetText(tempString);
3971 SysTryReturnResult(NID_UI_CTRL, totalLength <= __limitLength, E_INVALID_ARG, "[EDIT] The Invalid argument is given.");
3974 r = __pTextString->Append(text);
3975 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3977 wchar_t* pTempString = const_cast<wchar_t*>(text.GetPointer());
3979 for (int i = 0; i < length; i++)
3981 __pTextBuffer[i + currentLength] = pTempString[i];
3983 __pTextBuffer[totalLength] = 0;
3985 __pTextObject->SetRange(currentLength, length);
3986 r = __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), length);
3987 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[Edit] Failed to set length");
3989 __pTextObject->Compose();
3991 if (!__isTextBlocked)
3993 SetCursorPosition(totalLength);
3996 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
3998 AdjustFlexibleHeight();
4001 if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)
4003 __isCutLinkParserEnabled = true;
4006 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
4012 _EditPresenter::AppendCharacter(const Character& character)
4014 result r = E_SUCCESS;
4016 r = AppendText(character.ToString());
4022 _EditPresenter::ClearText(void)
4024 InitializeCopyPasteManager();
4026 result r = E_SUCCESS;
4028 if (__isInputConnectionBound && __isTextComposing)
4030 __pInputConnection->FinishTextComposition();
4031 __isTextComposing = false;
4032 __composingTextLength = 0;
4035 int textLength = GetTextLength();
4037 if (textLength == 0)
4042 r = DeleteText(0, textLength);
4043 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4049 _EditPresenter::DeleteCharacterAt(int index)
4051 result r = E_SUCCESS;
4054 length = GetTextLength();
4056 SysTryReturnResult(NID_UI_CTRL, index >= 0, E_INVALID_ARG, "Specified index is negative.");
4057 SysTryReturnResult(NID_UI_CTRL, index < length, E_OUT_OF_RANGE, "Specified index is outside the range.");
4059 r = DeleteText(index, index+1);
4064 _EditPresenter::DeleteText(int start, int end)
4066 result r = E_SUCCESS;
4068 int length = GetTextLength();
4070 SysTryReturnResult(NID_UI_CTRL, -1 < start && start < end, E_INVALID_ARG, "[EDIT] Invalid argument is given.");
4071 SysTryReturnResult(NID_UI_CTRL, start < end && end <= length, E_INVALID_ARG, "[EDIT] Invalid argument is given.");
4073 _Text::TextElement* pFirstTextElement = __pTextObject->GetElementAtTextIndex(start);
4074 const TextSimple* pFirstSimpleText = dynamic_cast <const TextSimple*>(pFirstTextElement);
4075 if (pFirstSimpleText != null && pFirstSimpleText->GetBitmap() != null)
4077 if (pFirstSimpleText->GetTextOffset() < start)
4079 start = pFirstSimpleText->GetTextOffset();
4082 _Text::TextElement* pLastTextElement = __pTextObject->GetElementAtTextIndex(end - 1);
4083 const TextSimple* pLastSimpleText = dynamic_cast <const TextSimple*>(pLastTextElement);
4084 if (pLastSimpleText != null && pLastSimpleText->GetBitmap() != null)
4086 if( (pLastSimpleText->GetTextOffset() + pLastSimpleText->GetTextLength()) > end)
4088 end = pLastSimpleText->GetTextOffset() + pLastSimpleText->GetTextLength();
4092 r = __pTextString->Remove(start, end - start);
4093 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4095 int currentLength = __pTextString->GetLength();
4097 for (int i = start; i < length; i++)
4099 __pTextBuffer[i] = __pTextBuffer[i + (length - currentLength)];
4102 for (int i = currentLength; i < length; i++)
4104 __pTextBuffer[i] = 0;
4107 SetCursorPosition(start);
4109 __pTextObject->SetRange(start, end - start);
4110 r = __pTextObject->NotifyTextChanged(__pTextBuffer, 0, currentLength, -(end - start));
4111 r = __pTextObject->Compose();
4113 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
4115 AdjustFlexibleHeight();
4118 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
4124 _EditPresenter::GetCurrentTextRange(int& start, int& end) const
4126 int currentLength = __pTextString->GetLength();
4128 start = __cursorPos;
4131 if (__pTextBuffer[--start] == TEXT_OBJ_CHARACTER)
4139 while (end < currentLength && __pTextBuffer[end] != TEXT_OBJ_CHARACTER)
4148 _EditPresenter::GetTextLimitLength(void) const
4150 return __limitLength;
4154 _EditPresenter::SetTextLimitLength(int limitLength)
4156 result r = E_SUCCESS;
4158 SysTryReturnResult(NID_UI_CTRL, (limitLength > 0), E_INVALID_ARG, "The invalid limit length is given.");
4160 String tempString = GetText();
4162 int textLength = tempString.GetLength();
4163 SysTryReturnResult(NID_UI_CTRL, (limitLength >= textLength), E_INVALID_ARG, "The invalid argument is given.");
4165 TextSimple* pSimpleText = null;
4167 if (limitLength == GetTextLimitLength())
4172 wchar_t* pTempBuffer = new (std::nothrow) wchar_t[limitLength + 1];
4173 SysTryReturnResult(NID_UI_CTRL, pTempBuffer, E_OUT_OF_MEMORY, "Unable to allocate buffer.");
4175 for (int i = 0; i < textLength; i++)
4177 pTempBuffer[i] = __pTextBuffer[i];
4180 for (int i = textLength; i < limitLength; i++)
4185 pTempBuffer[limitLength] = '\0';
4187 __pTextString->Clear();
4188 __pTextString->Append(tempString);
4191 delete[] __pTextBuffer;
4192 __pTextBuffer = null;
4194 __pTextBuffer = pTempBuffer;
4196 __pTextObject->RemoveAll();
4197 pSimpleText = new (std::nothrow)TextSimple(__pTextBuffer, textLength, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, __pFont);
4198 SysTryReturnResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "Insufficient memory.");
4200 r = __pTextObject->AppendElement(*pSimpleText);
4201 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4203 SetCursorPosition(textLength);
4205 __limitLength = limitLength;
4216 _EditPresenter::InsertCharacterAt(int index, const Character& character)
4218 result r = E_SUCCESS;
4220 r = InsertTextAt(index, character.ToString());
4226 _EditPresenter::SetModel(const _EditModel& editModel)
4230 delete __pEditModel;
4231 __pEditModel = null;
4234 __pEditModel = const_cast<_EditModel*>(&editModel);
4240 _EditPresenter::SetAutoLinkMask(unsigned long autoLinks)
4242 __isCutLinkParserEnabled = true;
4243 return __pEditModel->SetAutoLinkMask(autoLinks);
4247 _EditPresenter::GetAutoLinkMask(void) const
4249 return __pEditModel->GetAutoLinkMask();
4253 _EditPresenter::IsViewModeEnabled(void) const
4255 return __pEditModel->IsViewModeEnabled();
4259 _EditPresenter::SetViewModeEnabled(bool enable)
4261 if (!enable && __pEditModel->IsViewModeEnabled() && IsFocused())
4263 __pEdit->SetFocusOff(__pEdit);
4266 int editStyle = __pEdit->GetEditStyle();
4270 editStyle = editStyle | EDIT_STYLE_VIEWER;
4274 editStyle = editStyle & (~EDIT_STYLE_VIEWER);
4276 __pEdit->SetEditStyle(editStyle);
4280 __pEdit->SetCursorPosition(0);
4282 if (__pInputConnection && __isInputConnectionBound)
4288 __pEditModel->SetKeypadEnabled(!enable);
4289 __isCursorDisabled = enable;
4290 __pTextObject->SetCutLinkViewMode(enable);
4292 if (__pInputConnection)
4294 __pInputConnection->SetKeyEventSkipped(enable);
4298 return __pEditModel->SetViewModeEnabled(enable);
4302 _EditPresenter::SetKeypadActionEnabled(bool enable)
4305 result r = E_SUCCESS;
4307 r = __pInputConnection->SetInputPanelActionEnabled(enable);
4310 __pEditModel->SetKeypadActionEnabled(enable);
4316 _EditPresenter::IsKeypadActionEnabled(void)
4319 bool enableIc = true;
4321 enable = __pEditModel->IsKeypadActionEnabled();
4322 enableIc = __pInputConnection->IsInputPanelActionEnabled();
4328 _EditPresenter::GetKeypadAction(void) const
4330 return __pEditModel->GetKeypadAction();
4334 _EditPresenter::ConvertKeypadAction(CoreKeypadAction keypadAction)
4336 InputPanelAction inputPanelAction = INPUT_PANEL_ACTION_ENTER;
4338 switch (keypadAction)
4340 case CORE_KEYPAD_ACTION_ENTER:
4341 inputPanelAction = INPUT_PANEL_ACTION_ENTER;
4343 case CORE_KEYPAD_ACTION_GO:
4344 inputPanelAction = INPUT_PANEL_ACTION_GO;
4346 case CORE_KEYPAD_ACTION_NEXT:
4347 inputPanelAction = INPUT_PANEL_ACTION_NEXT;
4349 case CORE_KEYPAD_ACTION_SEND:
4350 inputPanelAction = INPUT_PANEL_ACTION_SEND;
4352 case CORE_KEYPAD_ACTION_SEARCH:
4353 inputPanelAction = INPUT_PANEL_ACTION_SEARCH;
4355 case CORE_KEYPAD_ACTION_LOGIN:
4356 inputPanelAction = INPUT_PANEL_ACTION_LOGIN;
4358 case CORE_KEYPAD_ACTION_SIGN_IN:
4359 inputPanelAction = INPUT_PANEL_ACTION_SIGN_IN;
4361 case CORE_KEYPAD_ACTION_JOIN:
4362 inputPanelAction = INPUT_PANEL_ACTION_JOIN;
4364 case CORE_KEYPAD_ACTION_DONE:
4365 inputPanelAction = INPUT_PANEL_ACTION_DONE;
4371 return inputPanelAction;
4376 _EditPresenter::SetKeypadAction(CoreKeypadAction keypadAction)
4378 return __pEditModel->SetKeypadAction(keypadAction);
4382 _EditPresenter::SetKeypadEnabled(bool enable)
4384 SetViewModeEnabled(!enable);
4390 _EditPresenter::IsKeypadEnabled(void)
4393 if (__pEdit->IsEnabled())
4395 enable = __pEditModel->IsKeypadEnabled();
4406 _EditPresenter::SetCurrentLanguage(LanguageCode languageCode)
4408 result r = E_SUCCESS;
4410 if (__pInputConnection && __isInputConnectionBound)
4412 r = __pInputConnection->SetInputPanelLanguage(languageCode);
4413 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4414 r = __pEditModel->SetInitialKeypadLanguage(LANGUAGE_INVALID);
4415 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4419 r = __pEditModel->SetInitialKeypadLanguage(languageCode);
4420 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4423 r = __pEditModel->SetCurrentLanguage(languageCode);
4429 _EditPresenter::GetCurrentLanguage(LanguageCode& language) const
4431 result r = E_SUCCESS;
4432 if (__pInputConnection && __isInputConnectionBound)
4434 language = __pInputConnection->GetInputPanelLanguage();
4435 r = __pEditModel->SetCurrentLanguage(language);
4436 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4439 return __pEditModel->GetCurrentLanguage(language);
4443 _EditPresenter::SetLowerCaseModeEnabled(bool enable)
4445 __pEditModel->SetLowerCaseModeEnabled(enable);
4451 _EditPresenter::IsLowerCaseModeEnabled(void) const
4453 return __pEditModel->IsLowerCaseModeEnabled();
4457 _EditPresenter::GetKeypadStyle(void) const
4459 return __pEditModel->GetKeypadStyle();
4463 _EditPresenter::SetKeypadStyle(KeypadStyle keypadStyle)
4466 bool textPredictionEnabled = __pEditModel->IsTextPredictionEnabled();
4468 InputPanelStyle inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
4470 switch (keypadStyle)
4472 case KEYPAD_STYLE_NORMAL:
4473 if (__isKeypadNormalNumberStyleEnabled)
4475 inputPanelStyle = INPUT_PANEL_STYLE_NUMBER;
4479 inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
4482 case KEYPAD_STYLE_PASSWORD:
4483 inputPanelStyle = INPUT_PANEL_STYLE_NORMAL;
4485 case KEYPAD_STYLE_EMAIL:
4486 inputPanelStyle = INPUT_PANEL_STYLE_EMAIL;
4488 case KEYPAD_STYLE_URL:
4489 inputPanelStyle = INPUT_PANEL_STYLE_URL;
4491 case KEYPAD_STYLE_NUMBER:
4492 inputPanelStyle = INPUT_PANEL_STYLE_NUMBER_ONLY;
4493 textPredictionEnabled = false;
4495 case KEYPAD_STYLE_PHONE_NUMBER:
4496 inputPanelStyle = INPUT_PANEL_STYLE_PHONE_NUMBER;
4497 textPredictionEnabled = false;
4499 case KEYPAD_STYLE_IP_V4:
4500 inputPanelStyle = INPUT_PANEL_STYLE_IP;
4501 textPredictionEnabled = false;
4507 if (__pInputConnection && __isInputConnectionBound)
4509 __pInputConnection->SetTextPredictionEnabled(textPredictionEnabled);
4510 __pInputConnection->SetInputPanelStyle(inputPanelStyle);
4513 __pEditModel->SetTextPredictionEnabled(textPredictionEnabled);
4515 return __pEditModel->SetKeypadStyle(keypadStyle);
4519 _EditPresenter::SetKeypadNormalNumberStyle(bool enable)
4521 __isKeypadNormalNumberStyleEnabled = enable;
4522 return SetKeypadStyle(__pEditModel->GetKeypadStyle());
4526 _EditPresenter::IsTextPredictionEnabled(void) const
4528 return __pEditModel->IsTextPredictionEnabled();
4532 _EditPresenter::SetTextPredictionEnabled(bool enable)
4534 KeypadStyle keypadStyle = __pEditModel->GetKeypadStyle();
4536 if (keypadStyle == KEYPAD_STYLE_NUMBER ||keypadStyle == KEYPAD_STYLE_PHONE_NUMBER ||
4537 keypadStyle == KEYPAD_STYLE_IP_V4)
4538 return E_UNSUPPORTED_OPERATION;
4540 if (__pInputConnection && __isInputConnectionBound)
4542 __pInputConnection->SetTextPredictionEnabled(enable);
4545 return __pEditModel->SetTextPredictionEnabled(enable);
4549 _EditPresenter::InsertTextAtCursorPosition(const String& text)
4551 return InsertTextAt(__cursorPos, text);
4555 _EditPresenter::InsertTextAt(int position, const String& text, const Bitmap& textImage)
4557 result r = E_SUCCESS;
4559 int currentLength = GetTextLength();
4560 int length = text.GetLength();
4561 int totalLength = currentLength + length;
4563 SysTryReturnResult(NID_UI_CTRL, position >= 0 && position <= currentLength, E_OUT_OF_RANGE, "[EDIT] The given position is out-of-range.");
4565 if ((__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) || (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER))
4567 if (__limitLength <= totalLength)
4569 String backupString = GetText();
4570 SetTextLimitLength(totalLength * 2);
4571 SetText(backupString);
4576 SysTryReturnResult(NID_UI_CTRL, totalLength <= __limitLength, E_MAX_EXCEEDED, "[EDIT] The text exceeds the limitation length.");
4579 if (__isInputConnectionBound == true && __isTextComposing == true)
4581 __pInputConnection->FinishTextComposition();
4582 __isTextComposing = false;
4583 __composingTextLength = 0;
4586 r = __pTextString->Insert(text, position);
4587 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4589 wchar_t* pInsertString = const_cast<wchar_t*>(text.GetPointer());
4591 if (currentLength > position)
4593 wchar_t pOriginalString[currentLength - position];
4595 for (int i = 0; i < currentLength - position; i++)
4597 pOriginalString[i] = __pTextBuffer[position + i];
4599 pOriginalString[currentLength - position] = 0;
4601 for (int i = 0; i < length; i++)
4603 __pTextBuffer[i + position] = pInsertString[i];
4606 for (int i = 0; i < currentLength - position; i++)
4608 __pTextBuffer[i + position + length] = pOriginalString[i];
4613 for (int i = 0; i < length; i++)
4615 __pTextBuffer[i + position] = pInsertString[i];
4619 __pTextBuffer[totalLength] = 0;
4621 TextSimple* pSimpleText = null;
4622 pSimpleText = new (std::nothrow) TextSimple(__pTextBuffer, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, GetFont());
4623 SysTryReturnResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "[Edit] Unable to allocate text simple element.");
4625 pSimpleText->ChangeTextOffset(__pTextBuffer, position);
4626 pSimpleText->SetBitmap((Bitmap&)textImage);
4627 __pTextObject->InsertElementAt(position, *pSimpleText);
4628 __pTextObject->ChangeTextOffset(__pTextBuffer, position+pSimpleText->GetTextLength(), pSimpleText->GetTextLength());
4629 __pTextObject->Compose();
4631 if (__isTextBlocked == true)
4633 DeleteText(__blockStartPos, __cursorPos);
4636 SetCursorPosition(__cursorPos + length);
4640 SetCursorPosition(position + length);
4643 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
4645 AdjustFlexibleHeight();
4648 __isCursorChanged = true;
4649 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT);
4654 _EditPresenter::DeleteCharacterAtCursorPosition(void)
4656 return DeleteCharacterAt(__cursorPos);
4660 _EditPresenter::IsFocused(void) const
4662 return __pEdit->IsFocused();
4666 _EditPresenter::OnFocusGained(void)
4668 if (__isAutoShrinkEnabled)
4670 int flexibleHeight = CalculateFlexibleHeight();
4671 Rectangle initialRect = GetInitialBounds();
4672 initialRect.height = flexibleHeight;
4674 SetFlexBounds(initialRect);
4677 if (!__pTextVisualElement)
4679 result r = E_SUCCESS;
4680 __pTextVisualElement = new (std::nothrow) _VisualElement;
4681 SysTryReturn(NID_UI_CTRL, __pTextVisualElement != null, false, E_OUT_OF_MEMORY, "[EDIT] Unable to create __pTextVisualElement instance.");
4683 r = __pTextVisualElement->Construct();
4684 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r));
4686 __pTextVisualElement->SetSurfaceOpaque(false);
4687 __pTextVisualElement->SetImplicitAnimationEnabled(false);
4689 __pTextVisualElement->SetShowState(true);
4691 _VisualElement* pEditVisualElement = __pEdit->GetVisualElement();
4692 SysTryCatch(NID_UI_CTRL, pEditVisualElement, , r = E_SYSTEM, "[E_SYSTEM] Unable to get root visual element.");
4694 pEditVisualElement->AttachChild(*__pTextVisualElement);
4695 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r));
4698 if (__pEdit->GetEnableState() == false)
4703 __isCursorOpaque = true;
4705 if (__isInputConnectionBound == false && __isInitialized)
4707 if (IsViewModeEnabled() == false)
4709 CheckUSBKeyboardStatus();
4711 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
4717 ShowFullscreenKeypad();
4721 __pEdit->Invalidate();
4726 __pTextVisualElement->Destroy();
4727 __pTextVisualElement = null;
4733 _EditPresenter::OnNotifiedN(IList* pArgs)
4735 String showKeypad(L"ShowKeypad");
4736 String* pType = dynamic_cast <String*>(pArgs->GetAt(0));
4740 if (*pType == showKeypad)
4742 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
4748 ShowFullscreenKeypad();
4751 pArgs->RemoveAll(true);
4761 _EditPresenter::OnFrameActivated(const _Frame& source)
4763 if (IsFocused() == true && __isInputConnectionBound == false && __isInitialized)
4765 if (IsViewModeEnabled() == false)
4767 CheckUSBKeyboardStatus();
4769 if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY)
4780 _EditPresenter::OnFrameDeactivated(const _Frame& source)
4786 _EditPresenter::OnFocusLost(void)
4788 if (__isAutoShrinkEnabled)
4790 Rectangle intialWindowBounds = GetInitialBounds();
4791 SetFlexBounds(intialWindowBounds);
4794 if (__pTextVisualElement)
4796 __pTextVisualElement->Destroy();
4797 __pTextVisualElement = null;
4800 if (__pEdit == null)
4805 ReplaceTextIntoPasswordHyphenString();
4807 if (__isInputConnectionBound)
4810 if (__pScrollBar && !(__pEdit->GetEditStyle() & EDIT_STYLE_NOSCROLL))
4812 __pScrollBar->SetScrollVisibility(false);
4815 __isCursorOpaque = false;
4816 __isTouchMoving = false;
4817 __isTouchReleaseSkipped = false;
4818 __isUSBKeyboardConnected = false;
4820 AdjustParentPanelHeight(true);
4825 __pEdit->Invalidate();
4831 _EditPresenter::GetCurrentStatus(void) const
4833 EditStatus editState = EDIT_STATUS_NORMAL;
4835 if (__pEdit->IsEnabled())
4839 editState = EDIT_STATUS_HIGHLIGHTED;
4841 else if (__isTouchPressed)
4843 editState = EDIT_STATUS_PRESSED;
4848 editState = EDIT_STATUS_DISABLED;
4855 _EditPresenter::GetCursorVisualElement(void) const
4857 return __pCursorVisualElement;
4861 _EditPresenter::SetMaxLineCount(int maxLineCount)
4863 __pEditModel->SetMaxLineCount(maxLineCount);
4869 _EditPresenter::GetMaxLineCount(void) const
4871 return __pEditModel->GetMaxLineCount();
4875 _EditPresenter::UpdateComponentInformation(void)
4877 result r = E_SUCCESS;
4879 if (__isCursorChanged == false)
4884 bool setFirstDisplayLine = true;
4885 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
4887 int firstDisplayY = __pTextObject->GetFirstDisplayPositionY();
4888 int totalHeight = __pTextObject->GetTotalHeight();
4889 Rectangle displayBounds = __pTextObject->GetBounds();
4890 if (totalHeight >= displayBounds.height)
4892 int textGapFromBottom = displayBounds.height - (totalHeight - firstDisplayY);
4893 if (textGapFromBottom > 0)
4895 ScrollText(-textGapFromBottom);
4899 Rectangle absCursorBounds(0, 0, 0, 0);
4900 CalculateAbsoluteCursorBounds(__cursorPos, absCursorBounds);
4901 setFirstDisplayLine = (IsContained(absCursorBounds) == false);
4904 if (setFirstDisplayLine)
4906 if (__pTextObject->IsChanged())
4908 __pTextObject->Compose();
4910 __pTextObject->SetFirstDisplayLineIndexFromTextIndex(__cursorPos);
4913 __pTextObject->SetCursorIndex(__cursorPos);
4915 __isCursorChanged = false;
4921 _EditPresenter::ScrollText(int distance)
4923 int newFirstDisplayY = __pTextObject->GetFirstDisplayPositionY();
4924 newFirstDisplayY += distance;
4926 int moveLine = __pTextObject->GetLineIndexAtPositionY(newFirstDisplayY);
4928 __pTextObject->SetFirstDisplayLineIndex(moveLine);
4929 __pTextObject->SetFirstDisplayPositionY(newFirstDisplayY);
4935 _EditPresenter::IsContained(Rectangle& paramRect) const
4937 Rectangle absBounds = __pEdit->GetAbsoluteBounds();
4939 if ((paramRect.x < absBounds.x) ||
4940 (paramRect.y < absBounds.y) ||
4941 ((paramRect.x + paramRect.width) > (absBounds.x + absBounds.width)) ||
4942 ((paramRect.y + paramRect.height) > (absBounds.y + absBounds.height)))
4951 _EditPresenter::CalculateAbsoluteCursorBounds(int index, Rectangle& absCursorBounds)
4955 int cursorWidth = 0;
4956 int cursorHeight = 0;
4957 int cursorRelativeX = 0;
4958 int cursorRelativeY = 0;
4960 Rectangle absBounds = __pEdit->GetAbsoluteBounds();
4962 __pTextObject->SetBounds(GetTextBounds());
4963 if (__pTextObject->GetTextPositionInfoAt(index, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS)
4968 absCursorBounds.x = absBounds.x + cursorRelativeX;
4970 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
4972 Rectangle tempBounds;
4973 GetCursorBounds(true, tempBounds);
4974 absCursorBounds.y = tempBounds.y;
4978 absCursorBounds.y = absBounds.y + cursorRelativeY;
4981 absCursorBounds.width = cursorWidth;
4983 if (cursorHeight > 0)
4985 absCursorBounds.height = cursorHeight;
4989 absCursorBounds.height = __pTextObject->GetLineHeightAt(0);
4996 _EditPresenter::GetCursorBounds(bool isAbsRect, Rectangle& cursorBounds)
4998 if (__isInitialized == false)
5003 CalculateCursorBounds(GetTextBounds(), cursorBounds);
5007 Rectangle absBounds = __pEdit->GetAbsoluteBounds();
5008 cursorBounds.x += absBounds.x;
5009 cursorBounds.y += absBounds.y;
5016 _EditPresenter::SetCursorDisabled(bool disabled)
5018 __isCursorDisabled = disabled;
5024 _EditPresenter::IsGuideTextActivated(void) const
5026 if (__pGuideTextObject == null)
5031 if (GetGuideText().IsEmpty())
5036 if (__pTextObject && GetTextLength() > 0)
5045 _EditPresenter::CreateCommandButtonItemN(int actionId, const String& text)
5047 result r = E_SUCCESS;
5048 _Button* pButton = _Button::CreateButtonN();
5049 SysTryReturn(NID_UI_CTRL, pButton, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance.");
5053 r = pButton->SetActionId(actionId);
5054 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5056 r = pButton->SetText(text);
5057 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5059 r = GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_FONT_SIZE, __pEdit->GetOrientation(), textSize);
5062 r = pButton->SetTextSize(textSize);
5063 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5075 _EditPresenter::SetKeypadCommandButton(const Rectangle& bounds)
5077 result r = E_SUCCESS;
5078 Bitmap* pNormalBackgroundBitmap = null;
5079 Bitmap* pReplacementColorBackgroundBitmap = null;
5080 String leftButtonText;
5081 String rightButtonText;
5082 _Control* pParent = null;
5083 Color commandBackgroundColor;
5085 if (__pCommandButton)
5087 __pCommandButton->SetResizable(true);
5088 __pCommandButton->SetMovable(true);
5090 r = __pCommandButton->SetBounds(bounds);
5092 __pCommandButton->SetResizable(false);
5093 __pCommandButton->SetMovable(false);
5098 __pCommandButton = _Toolbar::CreateToolbarN(false);
5099 SysTryReturn(NID_UI_CTRL, __pCommandButton, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance.");
5101 r = __pCommandButton->Construct();
5102 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5104 GET_BITMAP_CONFIG_N(FOOTER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundBitmap);
5105 if (pNormalBackgroundBitmap)
5107 GET_COLOR_CONFIG(FOOTER::BG_NORMAL, commandBackgroundColor);
5108 pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), commandBackgroundColor);
5110 if (pReplacementColorBackgroundBitmap)
5112 r = __pCommandButton->SetBackgroundBitmap(*pReplacementColorBackgroundBitmap);
5113 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5115 delete pReplacementColorBackgroundBitmap;
5116 pReplacementColorBackgroundBitmap = null;
5118 delete pNormalBackgroundBitmap;
5119 pNormalBackgroundBitmap = null;
5122 r = __pCommandButton->SetStyle(TOOLBAR_TEXT);
5123 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5125 __pCommandButton->SetResizable(true);
5126 __pCommandButton->SetMovable(true);
5128 r = __pCommandButton->SetBounds(bounds);
5129 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5131 __pCommandButton->SetResizable(false);
5132 __pCommandButton->SetMovable(false);
5134 leftButtonText = __pEditModel->GetKeypadCommandButtonText(COMMAND_BUTTON_POSITION_LEFT);
5135 r = __pCommandButton->AddItem(CreateCommandButtonItemN(__pEditModel->GetKeypadCommandButtonActionId(COMMAND_BUTTON_POSITION_LEFT), leftButtonText));
5136 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5138 rightButtonText = __pEditModel->GetKeypadCommandButtonText(COMMAND_BUTTON_POSITION_RIGHT);
5139 r = __pCommandButton->AddItem(CreateCommandButtonItemN(__pEditModel->GetKeypadCommandButtonActionId(COMMAND_BUTTON_POSITION_RIGHT), rightButtonText));
5140 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5142 if (__pActionEventListener)
5144 __pCommandButton->AddActionEventListener(*__pActionEventListener);
5147 if (GetParentForm())
5149 r = GetParentForm()->AttachChild(*__pCommandButton);
5150 GetParentForm()->MoveChildToTop(*__pCommandButton);
5154 pParent = __pEdit->GetParent();
5155 SysTryCatch(NID_UI_CTRL, pParent, r = E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
5156 r = pParent->AttachChild(*__pCommandButton);
5158 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
5163 delete pNormalBackgroundBitmap;
5165 delete __pCommandButton;
5166 __pCommandButton = null;
5172 _EditPresenter::CheckFooterVisible(void)
5174 _Form* pParentForm = GetParentForm();
5175 if (pParentForm == null)
5180 _Toolbar* pFooter = pParentForm->GetFooter();
5183 if (pFooter->GetVisibleState() == false)
5185 __footerVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_HIDE;
5189 __footerVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_SHOW;
5194 __footerVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE;
5201 _EditPresenter::SetFooterVisible(bool isVisible)
5203 _Form* pParentForm = GetParentForm();
5204 if (pParentForm == null)
5209 _Toolbar* pFooter = pParentForm->GetFooter();
5210 if (pFooter && __footerVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_SHOW)
5212 if ((isVisible == true && pFooter->GetVisibleState() == false) ||
5213 (isVisible == false && pFooter->GetVisibleState() == true))
5215 pFooter->SetVisibleState(isVisible);
5216 pFooter->Invalidate();
5224 _EditPresenter::ShowFullscreenKeypad(void)
5226 result r = E_SUCCESS;
5228 if (__pFullscreenKeypad)
5230 delete __pFullscreenKeypad;
5231 __pFullscreenKeypad = null;
5234 int editStyle = __pEdit->GetEditStyle();
5236 _KeypadStyleInfo keypadStyleInfo;
5237 keypadStyleInfo.keypadStyle = __pEditModel->GetKeypadStyle();
5238 keypadStyleInfo.textPredictionEnabled = __pEditModel->IsTextPredictionEnabled();
5239 keypadStyleInfo.isNormalNumberStyle = __isKeypadNormalNumberStyleEnabled;
5240 keypadStyleInfo.enterActionEnabled = true;
5241 keypadStyleInfo.isLowerCaseModeEnabled = __pEditModel->IsLowerCaseModeEnabled();
5243 if (editStyle & EDIT_STYLE_SINGLE_LINE)
5245 keypadStyleInfo.enterActionEnabled = false;
5248 if (editStyle & EDIT_STYLE_PASSWORD)
5250 editStyle = EDIT_STYLE_NORMAL | EDIT_STYLE_SINGLE_LINE | EDIT_STYLE_PASSWORD;
5254 editStyle = EDIT_STYLE_NORMAL;
5257 __pFullscreenKeypad = _Keypad::CreateKeypadN();
5258 SysTryReturn(NID_UI_CTRL, __pFullscreenKeypad, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance.");
5259 r = __pFullscreenKeypad->Initialize(editStyle, keypadStyleInfo, GetTextLimitLength(), __pEdit);
5260 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5262 __pFullscreenKeypad->SetText(GetText());
5264 r = __pFullscreenKeypad->Open();
5265 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5267 if (__pEdit->IsInputEnabled())
5269 __pEdit->SetInputEnableState(false);
5276 _EditPresenter::GetKeypadBounds(Rectangle& bounds) const
5278 if (__pInputConnection == null)
5283 bounds = __pInputConnection->GetInputPanelBounds();
5285 _CoordinateSystem* pCoordSystem = _CoordinateSystem::GetInstance();
5286 SysTryReturnResult(NID_UI_CTRL, pCoordSystem, E_SYSTEM, "[EDIT] Coordinate system load failed.");
5288 _ICoordinateSystemTransformer* pXformer = pCoordSystem->GetInverseTransformer();
5289 SysTryReturnResult(NID_UI_CTRL, pXformer, E_SYSTEM, "[EDIT] Coordinate system load failed.");
5291 bounds = pXformer->Transform(bounds);
5297 _EditPresenter::ShowKeypad(bool focus)
5299 SysTryReturnResult(NID_UI_CTRL, IsKeypadEnabled() == true, E_INVALID_STATE, "[EDIT] Keypad is not enabled.");
5303 __pEdit->SetFocused();
5306 if (!__isInitialized)
5311 _ControlManager* pControlManager = _ControlManager::GetInstance();
5313 if (!pControlManager->IsFrameActivated())
5318 __pInputConnection->BindInputMethod();
5319 __isInputConnectionBound = true;
5320 __isKeypadShowing = true;
5322 SetKeypadStyle(__pEditModel->GetKeypadStyle());
5324 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE && GetKeypadAction() == CORE_KEYPAD_ACTION_ENTER)
5326 __pInputConnection->SetInputPanelActionEnabled(false);
5330 __pInputConnection->SetInputPanelAction(ConvertKeypadAction(GetKeypadAction()));
5333 //Need to complete AutoCapitalization functionality
5334 if (__pEditModel->IsLowerCaseModeEnabled())
5336 __pInputConnection->SetAutoCapitalizationMode(AUTO_CAPITALIZATION_MODE_NONE);
5340 __pInputConnection->SetAutoCapitalizationMode(AUTO_CAPITALIZATION_MODE_SENTENCE);
5343 LanguageCode initialKeypadLanguage = LANGUAGE_INVALID;
5344 __pEditModel->GetInitialKeypadLanguage(initialKeypadLanguage);
5345 if (initialKeypadLanguage != LANGUAGE_INVALID)
5347 SetCurrentLanguage(initialKeypadLanguage);
5350 if (!__isUSBKeyboardConnected)
5352 __pInputConnection->ShowInputPanel();
5353 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
5357 if (__isKeypadCommandButtonVisible)
5359 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED);
5363 if (__isKeypadCommandButtonVisible)
5365 CheckFooterVisible();
5366 SetFooterVisible(false);
5369 ChangeLayoutInternal(__pEdit->GetOrientation());
5371 AdjustParentPanelHeight(false);
5373 ScrollPanelToTop(false);
5374 ScrollPanelToCursorPosition();
5376 __pEdit->AttachScrollPanelEvent();
5377 __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED);
5379 if (__isUSBKeyboardConnected)
5381 __pEdit->Invalidate();
5384 if (__isUSBKeyboardConnected)
5386 if (__isKeypadCommandButtonVisible)
5388 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN);
5396 _EditPresenter::ChangeLayout(_ControlOrientation orientation)
5398 result r = E_SUCCESS;
5400 int commandButtonHeight = 0;
5402 if (__pCopyPasteManager)
5404 __pCopyPasteManager->SetTextBlockReleaseFlag(false);
5405 InitializeCopyPasteManager();
5410 CheckUSBKeyboardStatus();
5411 if (__isInputConnectionBound)
5413 if (IsKeypadExist())
5415 _Form* pParentForm = GetParentForm();
5419 _Toolbar* pFooter = pParentForm->GetFooter();
5421 if (pFooter && pFooter->GetVisibleState())
5423 GET_SHAPE_CONFIG(FOOTER::HEIGHT, orientation, commandButtonHeight);
5426 pParentForm->DeflateClientRectHeight(commandButtonHeight);
5428 if (__pCommandButton && __pCommandButton->GetVisibleState())
5430 __pCommandButton->SetVisibleState(false);
5433 else //usb mode on or bounded after keypad drag
5435 ChangeLayoutInternal(orientation);
5439 __initialBounds = __pEdit->GetBounds();
5441 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to change layout.", GetErrorMessage(r));
5447 _EditPresenter::ChangeLayoutInternal(_ControlOrientation orientation)
5449 result r = E_SUCCESS;
5451 _Form* pParentForm = GetParentForm();
5452 Rectangle keypadBounds;
5453 GetKeypadBounds(keypadBounds);
5455 _ControlManager* pControlManager = _ControlManager::GetInstance();
5456 SysTryReturnResult(NID_UI_CTRL, pControlManager, E_SYSTEM, "[EDIT] Failed to get root.");
5457 Dimension screenSize;
5458 Rectangle commandButtonBounds(0, 0, 0, 0);
5460 int formDeflateHeight = 0;
5462 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
5464 screenSize.width = pControlManager->GetScreenSize().width;
5465 screenSize.height = pControlManager->GetScreenSize().height;
5469 screenSize.width = pControlManager->GetScreenSize().height;
5470 screenSize.height = pControlManager->GetScreenSize().width;
5473 if (__isInputConnectionBound)
5475 if (__isKeypadCommandButtonVisible)
5477 commandButtonBounds.width = screenSize.width;
5478 GET_SHAPE_CONFIG(FOOTER::HEIGHT, orientation, commandButtonBounds.height);
5482 formDeflateHeight += commandButtonBounds.height;
5484 if (IsKeypadExist())
5486 formDeflateHeight += keypadBounds.height;
5487 commandButtonBounds.y = screenSize.height - keypadBounds.height - commandButtonBounds.height - pParentForm->GetClientBounds().y;
5491 commandButtonBounds.y = screenSize.height - commandButtonBounds.height - pParentForm->GetClientBounds().y;
5496 if (IsKeypadExist())
5498 commandButtonBounds.y = screenSize.height - keypadBounds.height - commandButtonBounds.height;
5502 commandButtonBounds.y = screenSize.height - commandButtonBounds.height;
5506 r = SetKeypadCommandButton(commandButtonBounds);
5507 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5509 if (__pCommandButton)
5511 __pCommandButton->SetVisibleState(true);
5518 if (IsKeypadExist())
5520 formDeflateHeight += keypadBounds.height;
5527 pParentForm->DeflateClientRectHeight(formDeflateHeight);
5533 _EditPresenter::OnScrollPanelBoundsChanged(void)
5535 if (__pParentPanel && __isPanelBoundsChanging == false)
5537 __initialParentHeight = __pParentPanel->GetBounds().height;
5538 if (__pParentPanel->GetOrientation() == __pEdit->GetOrientation())
5540 AdjustParentPanelHeight(false);
5541 ScrollPanelToTop(false);
5542 ScrollPanelToCursorPosition();
5550 _EditPresenter::AdjustParentPanelHeight(bool restore, bool panelResizeByPrediction)
5552 if (__pParentPanel == null)
5557 _ControlOrientation orientation;
5558 int commandButtonHeight = 0;
5560 Rectangle absKeypadBounds;
5561 result r = GetKeypadBounds(absKeypadBounds);
5563 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
5565 _Form* pParentForm = GetParentForm();
5566 _Toolbar* pFooter = null;
5570 pFooter = pParentForm->GetFooter();
5573 Rectangle absScrollPanelBounds;
5574 Rectangle scrollPanelBounds = __pParentPanel->GetBounds();
5577 _ControlManager* pControlManager = _ControlManager::GetInstance();
5578 int displayedPanelHeight = 0;
5579 Dimension screenSize;
5581 if (__pEdit->GetOrientation()== _CONTROL_ORIENTATION_PORTRAIT)
5583 screenSize.width = pControlManager->GetScreenSize().width;
5584 screenSize.height = pControlManager->GetScreenSize().height;
5588 screenSize.width = pControlManager->GetScreenSize().height;
5589 screenSize.height = pControlManager->GetScreenSize().width;
5592 if (panelResizeByPrediction)
5597 if (__initialParentHeight)
5599 scrollPanelBounds.height = __initialParentHeight;
5601 __initialParentHeight = 0;
5602 __isPanelBoundsChanging = true;
5603 __pParentPanel->SetBounds(scrollPanelBounds);
5604 __isPanelBoundsChanging = false;
5605 __pParentPanel->Invalidate();
5610 if (__isKeypadCommandButtonVisible || (pFooter && (pFooter->GetVisibleState() == true)))
5612 orientation = __pEdit->GetOrientation();
5613 GET_SHAPE_CONFIG(FOOTER::HEIGHT, orientation, commandButtonHeight);
5616 absScrollPanelBounds = __pParentPanel->GetAbsoluteBounds();
5617 displayedPanelHeight = screenSize.height - commandButtonHeight - absScrollPanelBounds.y;
5618 gapY = (absKeypadBounds.y - commandButtonHeight)- absScrollPanelBounds.y;
5620 if (panelResizeByPrediction)
5622 if (__isUSBKeyboardConnected)
5626 scrollPanelBounds.height = gapY;
5628 __isPanelBoundsChanging = true;
5629 __pParentPanel->SetBounds(scrollPanelBounds);
5630 __isPanelBoundsChanging = false;
5632 __pParentPanel->Invalidate();
5637 if ((gapY > 0) && __initialParentHeight)
5639 scrollPanelBounds.height = gapY;
5641 __isPanelBoundsChanging = true;
5642 __pParentPanel->SetBounds(scrollPanelBounds);
5643 __isPanelBoundsChanging = false;
5645 __pParentPanel->Invalidate();
5651 if ((absKeypadBounds.y - commandButtonHeight) >= (absScrollPanelBounds.y + absScrollPanelBounds.height))
5656 if ((gapY > 0) && (gapY < displayedPanelHeight) && !__initialParentHeight)
5658 __initialParentHeight = scrollPanelBounds.height;
5660 scrollPanelBounds.height = gapY;
5662 __isPanelBoundsChanging = true;
5663 __pParentPanel->SetBounds(scrollPanelBounds);
5664 __isPanelBoundsChanging = false;
5666 __pParentPanel->Invalidate();
5675 _EditPresenter::HideKeypad(bool focus)
5677 InitializeCopyPasteManager();
5679 __isKeypadShowing = false;
5681 if (__isInitialized == false)
5686 if (__isInputConnectionBound)
5688 __pInputConnection->FinishTextComposition();
5689 __pInputConnection->HideInputPanel();
5690 __pInputConnection->UnbindInputMethod();
5691 __isKeypadHiding = true;
5692 __isTextComposing = false;
5693 __composingTextLength = 0;
5696 if (__pCommandButton && __pCommandButton->GetVisibleState() == true)
5698 SetFooterVisible(true);//must be called ahead of DeflateClientRectHeights
5699 __pCommandButton->SetVisibleState(false);
5702 _Form* pParentForm = GetParentForm();
5705 pParentForm->DeflateClientRectHeight(0);
5708 AdjustParentPanelHeight(true);
5710 __isInputConnectionBound = false;
5712 if (focus && IsFocused() && pParentForm)
5714 pParentForm->SetFocused();
5717 if (__isUSBKeyboardConnected)
5719 if (__isKeypadCommandButtonVisible)
5721 __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE);
5729 _EditPresenter::ChangeKeypadStatus(void)
5731 InitializeCopyPasteManager();
5733 if (__isInputConnectionBound)
5735 __isInputConnectionBound = false;
5742 _EditPresenter::OnTimerExpired(Timer& timer)
5744 Timer* onTimer = &timer;
5746 if (onTimer == __pCursorTimer)
5748 OnCursorTimerExpired();
5750 else if (onTimer == __pTitleSlidingTimer)
5752 OnTitleSlidingTimerExpired();
5754 else if (onTimer == __pPasswordTimer)
5756 OnPasswordTimerExpired();
5758 else if (onTimer == __pFlickAnimationTimer)
5760 OnFlickTimerExpired();
5767 _EditPresenter::OnEditCopyPasteStatusChanged(CoreCopyPasteStatus status, CoreCopyPasteAction action)
5771 case CORE_COPY_PASTE_ACTION_COPY:
5772 __pEdit->CopyText();
5774 case CORE_COPY_PASTE_ACTION_CUT:
5777 case CORE_COPY_PASTE_ACTION_PASTE:
5778 __pEdit->PasteText();
5783 InitializeCopyPasteManager();
5784 __pEdit->Invalidate();
5790 _EditPresenter::InitializeCursor(void)
5794 if (__isCursorDisabled == false && IsFocused() && __isTextBlocked == false)
5796 Rectangle cursorBounds;
5797 CalculateCursorBounds(__textObjectBounds, cursorBounds);
5799 __pCursorVisualElement->SetOpacity(1.0f);
5800 __pCursorVisualElement->SetBounds(FloatRectangle(cursorBounds.x, cursorBounds.y, cursorBounds.width, cursorBounds.height));
5802 Canvas* pCanvas = __pCursorVisualElement->GetCanvasN();
5803 if (pCanvas == null)
5807 __isCursorInitialized = false;
5808 DrawCursor(*pCanvas, cursorBounds, __isCursorOpaque);
5810 if (__pInputConnection)
5812 Rectangle absoluteEditRectangle;
5813 if (GetCursorBounds(false, absoluteEditRectangle) == E_SUCCESS)
5815 __pInputConnection->SetCursorBounds(absoluteEditRectangle);
5818 __isCursorOpaque = __isCursorOpaque ? false : true;
5822 __previousCursorBounds = cursorBounds;
5827 __pCursorVisualElement->SetOpacity(0);
5830 if (__pInputConnection != null && __isInputConnectionBound == true && !__isCopyPastePopupVisible)
5832 __pInputConnection->SetCursorPosition(__cursorPos);
5839 _EditPresenter::StopCursorTimer(void)
5843 __pCursorTimer->Cancel();
5844 delete __pCursorTimer;
5845 __pCursorTimer = null;
5851 _EditPresenter::StartCursorTimer(void)
5853 result r = E_SUCCESS;
5855 if (__pCursorTimer == null)
5857 __pCursorTimer = new (std::nothrow) Timer;
5858 if (__pCursorTimer == null)
5860 return E_OUT_OF_MEMORY;
5863 r = __pCursorTimer->Construct(*this);
5870 r = __pCursorTimer->Start(EDIT_CURSOR_TIMER_PERIOD);
5885 _EditPresenter::DrawCursor(Canvas& canvas, Rectangle& cursorBounds, bool isCursorOpaque)
5887 result r = E_SUCCESS;
5889 if (__isCursorDisabled == false)
5892 GET_COLOR_CONFIG(EDIT::CURSOR_NORMAL, cursorColor);
5894 if (__isCursorInitialized)
5896 cursorBounds.SetPosition(0, 0);
5898 if (canvas.GetBackgroundColor() != cursorColor)
5900 canvas.FillRectangle(cursorColor, cursorBounds);
5905 __pCursorVisualElement->SetOpacity(1.0f);
5909 __pCursorVisualElement->SetOpacity(0);
5914 cursorBounds.SetPosition(0, 0);
5916 canvas.FillRectangle(cursorColor, cursorBounds);
5917 __isCursorInitialized = true;
5923 __pCursorVisualElement->SetOpacity(0);
5930 _EditPresenter::MoveCursor(const Rectangle& fromRect, const Rectangle& toRect)
5932 if ((__previousCursorBounds.x != fromRect.x) || (__previousCursorBounds.y != fromRect.y) || (__previousCursorBounds.width != fromRect.width) || (__previousCursorBounds.height != fromRect.height))
5937 __pCursorVisualElement->SetOpacity(0);
5939 __pCursorVisualElement->SetBounds(FloatRectangle(toRect.x, toRect.y, toRect.width, toRect.height));
5940 Canvas* pCanvas = __pCursorVisualElement->GetCanvasN();
5942 if (pCanvas == null)
5947 if (toRect.y < 0 || toRect.y >= __clientBounds.height ||
5948 toRect.x < 0 || toRect.x >= __clientBounds.width)
5954 __pCursorVisualElement->SetOpacity(1.0f);
5958 GET_COLOR_CONFIG(EDIT::CURSOR_NORMAL, cursorColor);
5960 pCanvas->FillRectangle(cursorColor, toRect);
5962 __previousCursorBounds = toRect;
5969 _EditPresenter::OnCursorTimerExpired(void)
5971 if (!IsFocused() && __isCursorDisabled)
5977 Rectangle cursorBounds;
5979 if (CalculateCursorBounds(__textObjectBounds, cursorBounds) != E_SUCCESS)
5984 if ((__previousCursorBounds.x != cursorBounds.x) || (__previousCursorBounds.y != cursorBounds.y) || (__previousCursorBounds.width != cursorBounds.width) || (__previousCursorBounds.height != cursorBounds.height))
5986 __previousCursorBounds = cursorBounds;
5989 if (__pCursorVisualElement)
5991 __pCursorVisualElement->SetBounds(FloatRectangle(cursorBounds.x, cursorBounds.y, cursorBounds.width, cursorBounds.height));
5992 Canvas* pCanvas = __pCursorVisualElement->GetCanvasN();
5993 if (pCanvas == null)
5998 DrawCursor(*pCanvas, cursorBounds, __isCursorOpaque);
6003 __isCursorOpaque = __isCursorOpaque ? false : true;
6010 _EditPresenter::GetEllipsisPosition(void) const
6012 return __pEdit->GetEllipsisPosition();
6016 _EditPresenter::SetEllipsisPosition(EllipsisPosition position)
6018 result r = E_SUCCESS;
6019 TextObjectEllipsisType ellipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_TAIL;
6020 if (position == ELLIPSIS_POSITION_START)
6022 ellipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_HEAD;
6024 else if (position == ELLIPSIS_POSITION_MIDDLE)
6026 ellipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_MIDDLE;
6029 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
6031 r = __pTextObject->SetTextObjectEllipsisType(ellipsisType);
6032 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[EDIT] Unable to Set ellipsis position.");
6038 _EditPresenter::OnFontInfoRequested(unsigned long& style, int& size)
6040 style = __contentFontStyle;
6041 size = __contentFontSize;
6047 _EditPresenter::OnFontChanged(Font* pFont)
6049 if (!__isFontInitialized)
6054 result r = E_SUCCESS;
6056 r = AdjustFont(*pFont, EDIT_FONT_CHANGE_ALL);
6057 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "[EDIT] Unable to set font.");
6059 __titleFontFaceName = pFont->GetFaceName();
6065 _EditPresenter::GetFont(void) const
6071 _EditPresenter::GetTextSize(void) const
6073 return __contentFontSize;
6077 _EditPresenter::GetFontStyle(const Font* pBaseFont) const
6079 unsigned long style = FONT_STYLE_MIN;
6081 if (pBaseFont->IsPlain())
6083 style |= FONT_STYLE_PLAIN;
6085 if (pBaseFont->IsItalic())
6087 style |= FONT_STYLE_ITALIC;
6089 if (pBaseFont->IsBold())
6091 style |= FONT_STYLE_BOLD;
6098 _EditPresenter::SetTextSize(const int size)
6100 result r = E_SUCCESS;
6101 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
6102 r = GetLastResult();
6103 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
6105 r = fontImpl->SetSize(size);
6106 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "[EDIT] SetSize is failed.");
6110 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
6111 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
6112 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font.");
6115 if (IsGuideTextActivated())
6117 r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
6118 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font.");
6121 __contentFontSize = size;
6126 _EditPresenter::SetFont(const Font& font)
6128 result r = E_SUCCESS;
6130 Font* pFont = _FontImpl::CloneN(const_cast <Font&>(font));
6131 SysTryReturnResult(NID_UI_CTRL, pFont, GetLastResult(), "[EDIT] Unable to create font.");
6137 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
6138 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
6139 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "[EDIT] Unable to set font.");
6142 if (IsGuideTextActivated())
6144 r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
6145 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "[EDIT] Unable to set font.");
6152 _EditPresenter::AdjustFont(Font& font, _EditFontChange fontChange)
6154 result r = E_SUCCESS;
6155 Font* pFont = &font;
6157 _FontImpl* fontImpl = _FontImpl::GetInstance(*pFont);
6158 r = GetLastResult();
6159 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
6161 if (fontChange == EDIT_FONT_CHANGE_TITLE || fontChange == EDIT_FONT_CHANGE_ALL)
6163 if (__pTitleTextObject)
6165 r = fontImpl->SetSize(__titleFontSize);
6166 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "[EDIT] SetSize is failed.");
6168 r = __pTitleTextObject->SetFont(pFont, 0, __pTitleTextObject->GetTextLength());
6169 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font.");
6173 if (fontChange == EDIT_FONT_CHANGE_CONTENT || fontChange == EDIT_FONT_CHANGE_ALL)
6175 r = fontImpl->SetSize(__contentFontSize);
6176 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "[EDIT] SetSize is failed.");
6178 unsigned long style = FONT_STYLE_PLAIN;
6180 if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_BOLD)
6182 style |= FONT_STYLE_BOLD;
6184 if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_ITALIC)
6186 style |= FONT_STYLE_ITALIC;
6189 fontImpl->SetStyle(style);
6191 if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_UNDERLINE)
6193 fontImpl->SetUnderline(true);
6195 if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_STRIKEOUT)
6197 fontImpl->SetStrikeOut(true);
6202 r = __pTextObject->SetFont(pFont, 0, __pTextObject->GetTextLength());
6203 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
6204 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font.");
6207 if (IsGuideTextActivated())
6209 r = __pGuideTextObject->SetFont(pFont, 0, __pGuideTextObject->GetTextLength());
6210 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font.");
6220 _EditPresenter::GetTitleFontFaceName(void)
6222 return __titleFontFaceName;
6226 _EditPresenter::GetFontType(String& typefaceName, unsigned long& styleMask) const
6228 result r = E_SUCCESS;
6232 typefaceName = __pFont->GetFaceName();
6235 styleMask = __contentTextStyle;
6241 _EditPresenter::SetFontType(const String& typefaceName, unsigned long styleMask)
6243 result r = E_SUCCESS;
6246 IList* systemFontList = Font::GetSystemFontListN();
6247 SysTryReturnResult(NID_UI_CTRL, systemFontList, E_SYSTEM, "[EDIT] Unable to get system font list.\n");
6249 int fontListCount = systemFontList->GetCount();
6250 String tempFontFaceName;
6251 bool isFaceNameAvailable = false;
6253 int textSize = __pFont->GetSize();
6254 unsigned long fontStyle = FONT_STYLE_PLAIN;
6256 if (styleMask & TEXT_BOX_TEXT_STYLE_ITALIC)
6258 fontStyle |= FONT_STYLE_ITALIC;
6260 if (styleMask & TEXT_BOX_TEXT_STYLE_BOLD)
6262 fontStyle |= FONT_STYLE_BOLD;
6265 for (int i = 0; i < fontListCount; i++)
6267 tempFontFaceName = *static_cast<String*>(systemFontList->GetAt(i));
6269 pFont = new (std::nothrow) Font;
6270 SysTryCatch(NID_UI_CTRL, pFont, , r = E_OUT_OF_MEMORY, "[EDIT] Unable to get text information.\n");
6271 r = pFont->Construct(tempFontFaceName, fontStyle, textSize);
6272 SysTryCatch(NID_UI_CTRL, !IsFailed(r), , r, "[EDIT] Unable to construct Font.\n");
6274 // check font face name.
6275 if (typefaceName.Equals(pFont->GetFaceName(), true))
6277 isFaceNameAvailable = true;
6285 SysTryCatch(NID_UI_CTRL, isFaceNameAvailable, , r = E_INVALID_ARG, "[EDIT] The unsupported font face name is given.\n");
6287 if (styleMask & TEXT_BOX_TEXT_STYLE_UNDERLINE)
6289 pFont->SetUnderline(true);
6291 if (styleMask & TEXT_BOX_TEXT_STYLE_STRIKEOUT)
6293 pFont->SetStrikeOut(true);
6296 __contentFontStyle = fontStyle;
6297 __contentTextStyle = styleMask;
6301 systemFontList->RemoveAll(true);
6302 delete systemFontList;
6303 systemFontList = null;
6307 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
6308 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
6309 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "[EDIT] Unable to set font.");
6320 systemFontList->RemoveAll(true);
6321 delete systemFontList;
6322 systemFontList = null;
6328 _EditPresenter::GetTextStyle(void) const
6330 return __contentTextStyle;
6334 _EditPresenter::SetTextStyle(unsigned long textStyle)
6336 result r = E_SUCCESS;
6338 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
6339 r = GetLastResult();
6340 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
6342 unsigned long style = FONT_STYLE_PLAIN;
6344 if (textStyle & TEXT_BOX_TEXT_STYLE_BOLD)
6346 style |= FONT_STYLE_BOLD;
6348 if (textStyle & TEXT_BOX_TEXT_STYLE_ITALIC)
6350 style |= FONT_STYLE_ITALIC;
6353 fontImpl->SetStyle(style);
6355 if (textStyle & TEXT_BOX_TEXT_STYLE_UNDERLINE)
6357 fontImpl->SetUnderline(true);
6361 fontImpl->SetUnderline(false);
6364 if (textStyle & TEXT_BOX_TEXT_STYLE_STRIKEOUT)
6366 fontImpl->SetStrikeOut(true);
6370 fontImpl->SetStrikeOut(false);
6375 r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
6376 __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON;
6377 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font.");
6380 if (IsGuideTextActivated())
6382 r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
6383 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font.");
6386 __contentTextStyle = textStyle;
6392 _EditPresenter::GetGuideText(void) const
6398 _EditPresenter::SetGuideText(const String& guideText)
6400 result r = E_SUCCESS;
6402 int length = guideText.GetLength();
6404 __guideText = String(guideText);
6405 wchar_t* tempString = const_cast<wchar_t*>(__guideText.GetPointer());
6408 if (__pGuideTextObject != null)
6410 delete __pGuideTextObject;
6411 __pGuideTextObject = null;
6414 __pGuideTextObject = new (std::nothrow) TextObject;
6415 if (__pGuideTextObject == null)
6417 return E_OUT_OF_MEMORY;
6419 __pGuideTextObject->Construct();
6420 TextSimple* pSimpleText = new (std::nothrow)TextSimple(tempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
6421 __pGuideTextObject->AppendElement(*pSimpleText);
6423 __pGuideTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
6424 __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength());
6426 if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
6428 __pGuideTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
6432 __pGuideTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP);
6435 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE))
6437 __pGuideTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_CHARACTER);
6441 __pGuideTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
6448 _EditPresenter::GetTitleText(void) const
6454 _EditPresenter::SetTitleText(const String& title)
6456 result r = E_SUCCESS;
6458 int length = title.GetLength();
6460 __titleText = String(title);
6461 wchar_t* tempString = const_cast<wchar_t*>(__titleText.GetPointer());
6463 if (__pTitleTextObject != null)
6465 delete __pTitleTextObject;
6466 __pTitleTextObject = null;
6469 __pTitleTextObject = new (std::nothrow) TextObject;
6470 if (__pTitleTextObject == null)
6472 return E_OUT_OF_MEMORY;
6474 __pTitleTextObject->Construct();
6475 TextSimple* pSimpleText = new (std::nothrow)TextSimple(tempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
6476 __pTitleTextObject->AppendElement(*pSimpleText);
6478 __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE);
6479 __pTitleTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
6480 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
6481 __pTitleTextObject->Compose();
6484 int titleFontSize = 0;
6485 GET_SHAPE_CONFIG(EDIT::DEFAULT_TITLE_FONT_SIZE, __pEdit->GetOrientation(), titleFontSize);
6487 __titleFontSize = titleFontSize;
6489 _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont);
6493 r = fontImpl->SetSize(__titleFontSize);
6494 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "[EDIT] SetSize is failed.");
6498 r = GetLastResult();
6499 SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
6502 __pTitleTextObject->SetFont(__pFont, 0, __pTitleTextObject->GetTextLength());
6504 r = fontImpl->SetSize(__contentFontSize);
6505 SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "[EDIT] SetSize is failed.");
6507 __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TITLE_TEXT);
6513 _EditPresenter::GetTextLineCount(void) const
6515 if (GetTextLength() == 0)
6520 if (__isInitialized == false)
6522 __pTextObject->SetBounds(__textObjectBounds);
6523 __pTextObject->Compose();
6526 return __pTextObject->GetTotalLineCount();
6530 _EditPresenter::GetTextTotalHeight(void) const
6532 if (GetTextLength() == 0)
6537 if (__isInitialized == false)
6539 __pTextObject->SetBounds(__textObjectBounds);
6540 __pTextObject->Compose();
6543 return __pTextObject->GetTotalHeight();
6547 _EditPresenter::Resize(void)
6552 __pTextObject->SetBounds(__textObjectBounds);
6553 __pTextObject->Compose();
6554 __isCursorChanged = true;
6556 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_NOSCROLL))
6558 if (__pScrollBar == null)
6560 __pScrollBar = _Scroll::CreateScrollN(*__pEdit,
6561 SCROLL_DIRECTION_VERTICAL,
6569 SysTryReturn(NID_UI_CTRL, __pScrollBar != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to create the scroll.");
6570 __pEdit->AttachSystemChild(*__pScrollBar);
6572 __pScrollBar->SetScrollVisibility(false);
6573 __pScrollBar->OnParentBoundsChanged();
6576 __verticalMargin = __pEdit->GetBounds().height - __textObjectBounds.height;
6578 if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)
6580 if (__initialBounds.height > __verticalMargin)
6582 if (__initialBounds.height > __pEdit->GetBounds().height)
6584 __prevTotalTextHeight = __initialBounds.height - __verticalMargin;
6588 __prevTotalTextHeight = __pEdit->GetBounds().height - __verticalMargin;
6598 _EditPresenter::SetClientBounds(void)
6600 int editStyle = __pEdit->GetEditStyle();
6602 __clientBounds = __pEdit->GetBounds();
6603 __clientBounds.x = 0;
6604 __clientBounds.y = 0;
6606 if (!(editStyle & EDIT_STYLE_SINGLE_LINE))
6612 int rightBorder = 0;
6614 int bottomBorder = 0;
6616 int rightMargin = 0;
6618 int bottomMargin = 0;
6619 _ControlOrientation orientation = __pEdit->GetOrientation();
6621 GET_SHAPE_CONFIG(EDIT::FIELD_LEFT_MARGIN, orientation, leftMargin);
6622 GET_SHAPE_CONFIG(EDIT::FIELD_RIGHT_MARGIN, orientation, rightMargin);
6623 GET_SHAPE_CONFIG(EDIT::FIELD_TOP_MARGIN, orientation, topMargin);
6624 GET_SHAPE_CONFIG(EDIT::FIELD_BOTTOM_MARGIN, orientation, bottomMargin);
6626 if (editStyle & EDIT_STYLE_TITLE_LEFT)
6629 if (__titleWidth != -1)
6631 titleWidth = __titleWidth;
6635 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_RECT_WIDTH, orientation, titleWidth);
6638 leftBorder = titleWidth;
6639 rightBorder = rightMargin;
6640 topBorder = topMargin;
6641 bottomBorder = bottomMargin;
6643 else if (editStyle & EDIT_STYLE_TITLE_TOP)
6645 int titletHeight = 0;
6646 int titleTextTopMargin = 0;
6647 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_RECT_HEIGHT, orientation, titletHeight);
6648 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_TOP_MARGIN, orientation, titleTextTopMargin);
6650 leftBorder = leftMargin;
6651 rightBorder = rightMargin;
6652 topBorder = titletHeight + titleTextTopMargin;
6653 bottomBorder = bottomMargin;
6656 __clientBounds.x = leftBorder;
6657 __clientBounds.y = topBorder;
6658 __clientBounds.width -= leftBorder + rightBorder;
6659 __clientBounds.height -= topBorder + bottomBorder;
6665 _EditPresenter::SetInitialEditFieldBounds(void)
6667 result r = E_SUCCESS;
6668 int editStyle = __pEdit->GetEditStyle();
6670 int rightMargin = 0;
6672 int bottomMargin = 0;
6673 int textLeftMargin = 0;
6674 int textRightMargin = 0;
6675 int textTopMargin = 0;
6676 int textBottomMargin = 0;
6677 int titleRectWidth = 0;
6678 int titleRectHeight = 0;
6679 int titleTextLeftMargin = 0;
6680 int titleTextRightMargin = 0;
6681 int titleTextTopMargin = 0;
6682 int titleTextBottomMargin = 0;
6683 int clearIconWidth = 0;
6684 _ControlOrientation orientation = __pEdit->GetOrientation();
6686 GET_SHAPE_CONFIG(EDIT::FIELD_LEFT_MARGIN, orientation, leftMargin);
6687 GET_SHAPE_CONFIG(EDIT::FIELD_RIGHT_MARGIN, orientation, rightMargin);
6688 GET_SHAPE_CONFIG(EDIT::FIELD_TOP_MARGIN, orientation, topMargin);
6689 GET_SHAPE_CONFIG(EDIT::FIELD_BOTTOM_MARGIN, orientation, bottomMargin);
6690 GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_LEFT_MARGIN, orientation, textLeftMargin);
6691 GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_RIGHT_MARGIN, orientation, textRightMargin);
6692 GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_TOP_MARGIN, orientation, textTopMargin);
6693 GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_BOTTOM_MARGIN, orientation, textBottomMargin);
6694 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_RECT_WIDTH, orientation, titleRectWidth);
6695 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_RECT_HEIGHT, orientation, titleRectHeight);
6696 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_LEFT_MARGIN, orientation, titleTextLeftMargin);
6697 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_RIGHT_MARGIN, orientation, titleTextRightMargin);
6698 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_TOP_MARGIN, orientation, titleTextTopMargin);
6699 GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_BOTTOM_MARGIN, orientation, titleTextBottomMargin);
6700 GET_SHAPE_CONFIG(EDIT::CLEAR_ICON_WIDTH, orientation, clearIconWidth);
6702 if (!(editStyle & EDIT_STYLE_SINGLE_LINE))
6707 Rectangle bounds = __pEdit->GetBounds();
6708 if (editStyle & EDIT_STYLE_TITLE_LEFT)
6710 __textObjectBounds.x = __clientBounds.x + textLeftMargin;
6711 __textObjectBounds.y = __clientBounds.y + textTopMargin;
6712 __textObjectBounds.width = __clientBounds.width - textLeftMargin
6714 __textObjectBounds.height = __clientBounds.height - textTopMargin
6717 __titleBounds.x = titleTextLeftMargin;
6718 __titleBounds.y = titleTextTopMargin;
6719 __titleBounds.width = bounds.width - __clientBounds.width - __titleBounds.x;
6720 __titleBounds.height = __clientBounds.height - titleTextTopMargin
6721 - titleTextBottomMargin;
6723 if (editStyle & EDIT_STYLE_CLEAR)
6725 __textObjectBounds.width -= clearIconWidth;
6728 else if (editStyle & EDIT_STYLE_TITLE_TOP)
6730 __textObjectBounds.x = __clientBounds.x + textLeftMargin;
6731 __textObjectBounds.y = __clientBounds.y;
6732 __textObjectBounds.width = __clientBounds.width - textLeftMargin
6734 __textObjectBounds.height = __clientBounds.height - textBottomMargin;
6736 __titleBounds.x = titleTextLeftMargin;
6737 __titleBounds.y = titleTextTopMargin;
6738 __titleBounds.width = bounds.width - __titleBounds.x
6739 - titleTextRightMargin;
6740 __titleBounds.height = bounds.height - __titleBounds.y - __clientBounds.height
6743 if (editStyle & EDIT_STYLE_CLEAR)
6745 __textObjectBounds.width -= clearIconWidth;
6748 else if ((editStyle & EDIT_STYLE_NORMAL) || (editStyle & EDIT_STYLE_CLEAR))
6750 __textObjectBounds = __clientBounds;
6751 int tempLeftMargin = __pEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN);
6752 int tempRightMargin = __pEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN);
6754 if (tempLeftMargin != -1)
6756 __textObjectBounds.x = __clientBounds.x + tempLeftMargin;
6757 __textObjectBounds.width = __clientBounds.width - tempLeftMargin;
6761 __textObjectBounds.x = __clientBounds.x + textLeftMargin;
6762 __textObjectBounds.width = __clientBounds.width - textLeftMargin;
6765 if (tempRightMargin != -1)
6767 __textObjectBounds.width -= tempRightMargin;
6771 __textObjectBounds.width -= textRightMargin;
6774 if (editStyle & EDIT_STYLE_CLEAR)
6776 __textObjectBounds.width -= clearIconWidth;
6778 __textObjectBounds.y = __clientBounds.y + textTopMargin;
6779 __textObjectBounds.height = __clientBounds.height - textTopMargin
6784 int tempLeftMargin = __pEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN);
6785 int tempRightMargin = __pEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN);
6786 if (tempLeftMargin != -1)
6788 __textObjectBounds.x = __clientBounds.x + tempLeftMargin;
6789 __textObjectBounds.width = __clientBounds.width - tempLeftMargin;
6793 __textObjectBounds.x = __clientBounds.x + textLeftMargin;
6794 __textObjectBounds.width = __clientBounds.width - textLeftMargin;
6797 if (tempRightMargin != -1)
6799 __textObjectBounds.width -= tempRightMargin;
6803 __textObjectBounds.width -= textRightMargin;
6805 __textObjectBounds.y = __clientBounds.y + textTopMargin;
6806 __textObjectBounds.height = __clientBounds.height - textTopMargin
6810 int textObectMinimumWidth = 0;
6811 GET_SHAPE_CONFIG(EDIT::TEXT_OBJECT_MININMUM_WIDTH, orientation, textObectMinimumWidth);
6813 if (__textObjectBounds.width < textObectMinimumWidth)
6815 __textObjectBounds.width = textObectMinimumWidth;
6818 if (__textObjectBounds.height < __contentFontSize)
6820 __textObjectBounds.height = __contentFontSize;
6823 if (editStyle & EDIT_STYLE_TITLE_LEFT)
6826 if (__titleBounds.width < textObectMinimumWidth)
6828 gap = textObectMinimumWidth - __titleBounds.width;
6829 __titleBounds.width = textObectMinimumWidth;
6830 __textObjectBounds.x += gap;
6832 if (__titleBounds.height < __titleFontSize)
6834 __titleBounds.height = __titleFontSize;
6843 _EditPresenter::SetInitialBounds(void)
6845 result r = E_SUCCESS;
6846 Rectangle bounds = __pEdit->GetBounds();
6847 int editStyle = __pEdit->GetEditStyle();
6849 if (editStyle & EDIT_STYLE_SINGLE_LINE)
6851 r = SetInitialEditFieldBounds();
6852 __textBoxBounds.x = 0;
6853 __textBoxBounds.y = 0;
6854 __textBoxBounds.width = bounds.width;
6855 __textBoxBounds.height = bounds.height;
6861 int rightMargin = 0;
6863 int bottomMargin = 0;
6864 int textLeftMargin = 0;
6865 int textRightMargin = 0;
6866 int textTopMargin = 0;
6867 int textBottomMargin = 0;
6868 int titleRectWidth = 0;
6869 int titleRectHeight = 0;
6870 int titleTextLeftMargin = 0;
6871 int titleTextRightMargin = 0;
6872 int titleTextTopMargin = 0;
6873 int titleTextBottomMargin = 0;
6874 int clearIconWidth = 0;
6875 int scrollWidth = 0;
6876 _ControlOrientation orientation = __pEdit->GetOrientation();
6878 GET_SHAPE_CONFIG(EDIT::AREA_LEFT_MARGIN, orientation, leftMargin);
6879 GET_SHAPE_CONFIG(EDIT::AREA_RIGHT_MARGIN, orientation, rightMargin);
6880 GET_SHAPE_CONFIG(EDIT::AREA_TOP_MARGIN, orientation, topMargin);
6881 GET_SHAPE_CONFIG(EDIT::AREA_BOTTOM_MARGIN, orientation, bottomMargin);
6882 GET_SHAPE_CONFIG(EDIT::AREA_TEXT_LEFT_MARGIN, orientation, textLeftMargin);
6883 GET_SHAPE_CONFIG(EDIT::AREA_TEXT_RIGHT_MARGIN, orientation, textRightMargin);
6884 GET_SHAPE_CONFIG(EDIT::AREA_TEXT_TOP_MARGIN, orientation, textTopMargin);
6885 GET_SHAPE_CONFIG(EDIT::AREA_TEXT_BOTTOM_MARGIN, orientation, textBottomMargin);
6886 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_RECT_WIDTH, orientation, titleRectWidth);
6887 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_RECT_HEIGHT, orientation, titleRectHeight);
6888 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_LEFT_MARGIN, orientation, titleTextLeftMargin);
6889 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_RIGHT_MARGIN, orientation, titleTextRightMargin);
6890 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_TOP_MARGIN, orientation, titleTextTopMargin);
6891 GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_BOTTOM_MARGIN, orientation, titleTextBottomMargin);
6892 GET_SHAPE_CONFIG(EDIT::CLEAR_ICON_WIDTH, orientation, clearIconWidth);
6893 GET_SHAPE_CONFIG(EDIT::AREA_SCROLL_WIDTH, orientation, scrollWidth);
6895 if (editStyle & EDIT_STYLE_TITLE_TOP)
6897 __textBoxBounds.x = leftMargin;
6898 __textBoxBounds.y = titleRectHeight + titleTextTopMargin;
6899 __textBoxBounds.width = bounds.width - leftMargin - rightMargin;
6900 __textBoxBounds.height = bounds.height - titleRectHeight - titleTextTopMargin - bottomMargin;
6902 else if (editStyle & EDIT_STYLE_TITLE_LEFT)
6906 if (__titleWidth != -1)
6908 titleWidth = __titleWidth;
6912 titleWidth = titleRectWidth;
6914 __textBoxBounds.x = titleWidth;
6915 __textBoxBounds.y = topMargin;
6916 __textBoxBounds.width = bounds.width - titleWidth - leftMargin;
6917 __textBoxBounds.height = bounds.height - topMargin - bottomMargin;
6921 __textBoxBounds.x = 0;
6922 __textBoxBounds.y = 0;
6923 __textBoxBounds.width = bounds.width;
6924 __textBoxBounds.height = bounds.height;
6927 // setting textBounds
6928 if (editStyle & EDIT_STYLE_TITLE_TOP)
6930 if (__pEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN) != -1)
6932 __textObjectBounds.x = __textBoxBounds.x + __pEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN);
6933 __textObjectBounds.width = __textBoxBounds.width - __pEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN);
6937 __textObjectBounds.x = __textBoxBounds.x + textLeftMargin;
6938 __textObjectBounds.width = __textBoxBounds.width - textLeftMargin;
6941 if (__pEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN) != -1)
6943 __textObjectBounds.width -= __pEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN);
6947 __textObjectBounds.width -= textRightMargin;
6951 __textObjectBounds.y = __textBoxBounds.y;
6952 __textObjectBounds.height = __textBoxBounds.height - textBottomMargin;
6956 if (__pEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN) != -1)
6958 __textObjectBounds.x = __textBoxBounds.x + __pEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN);
6959 __textObjectBounds.width = __textBoxBounds.width - __pEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN);
6963 __textObjectBounds.x = __textBoxBounds.x + textLeftMargin;
6964 __textObjectBounds.width = __textBoxBounds.width - textLeftMargin;
6967 if (__pEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN) != -1)
6969 __textObjectBounds.width -= __pEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN);
6973 __textObjectBounds.width -= textRightMargin;
6977 if (__pEdit->GetVerticalMargin(EDIT_TEXT_TOP_MARGIN) != -1)
6979 __textObjectBounds.y = __textBoxBounds.y + __pEdit->GetVerticalMargin(EDIT_TEXT_TOP_MARGIN);
6980 __textObjectBounds.height = __textBoxBounds.height - __pEdit->GetVerticalMargin(EDIT_TEXT_TOP_MARGIN);
6984 __textObjectBounds.y = __textBoxBounds.y + textTopMargin;
6985 __textObjectBounds.height = __textBoxBounds.height - textTopMargin;
6988 if (__pEdit->GetVerticalMargin(EDIT_TEXT_BOTTOM_MARGIN) != -1)
6990 __textObjectBounds.height -= __pEdit->GetVerticalMargin(EDIT_TEXT_BOTTOM_MARGIN);
6994 __textObjectBounds.height -= textBottomMargin;
6998 if (editStyle & EDIT_STYLE_TITLE_TOP)
7000 __titleBounds.x = titleTextLeftMargin;
7001 __titleBounds.y = titleTextTopMargin;
7002 __titleBounds.width = bounds.width - titleTextLeftMargin
7003 - titleTextRightMargin;
7004 __titleBounds.height = bounds.height - __textBoxBounds.height - __titleBounds.y
7008 else if (editStyle & EDIT_STYLE_TITLE_LEFT)
7010 __titleBounds.x = titleTextLeftMargin;
7011 __titleBounds.y = titleTextTopMargin;
7012 __titleBounds.width = bounds.width - __textBoxBounds.width - __titleBounds.x
7013 - titleTextRightMargin;
7014 __titleBounds.height = __textBoxBounds.height - titleTextTopMargin
7015 - titleTextBottomMargin;
7018 if (editStyle & EDIT_STYLE_NOSCROLL)
7020 __isScrollBarVisible = false;
7021 __scrollBarBounds.x = 0;
7022 __scrollBarBounds.y = 0;
7023 __scrollBarBounds.width = 0;
7024 __scrollBarBounds.height = 0;
7028 __scrollBarBounds.width = scrollWidth;
7030 __scrollBarBounds.x = bounds.width - __scrollBarBounds.width;
7031 __scrollBarBounds.y = __textBoxBounds.y + textTopMargin;
7032 __scrollBarBounds.height = __textBoxBounds.height - textTopMargin - textBottomMargin;
7033 if (__scrollBarBounds.height < 0)
7035 __scrollBarBounds.height = 0;
7038 __isScrollBarVisible = true;
7040 if (editStyle & EDIT_STYLE_TITLE_TOP)
7042 __titleBounds.width -= __scrollBarBounds.width;
7046 int textObectMinimumWidth = 0;
7047 GET_SHAPE_CONFIG(EDIT::TEXT_OBJECT_MININMUM_WIDTH, orientation, textObectMinimumWidth);
7049 if (__textObjectBounds.width < textObectMinimumWidth)
7051 __textObjectBounds.width = textObectMinimumWidth;
7054 if (__textObjectBounds.height < __contentFontSize)
7056 __textObjectBounds.height = __contentFontSize;
7063 _EditPresenter::StopTitleSlidingTimer(void)
7065 if (__pTitleSlidingTimer)
7067 __pTitleSlidingTimer->Cancel();
7068 delete __pTitleSlidingTimer;
7069 __pTitleSlidingTimer = null;
7076 _EditPresenter::StartTitleSlidingTimer(void)
7078 result r = E_SUCCESS;
7080 if (__pTitleSlidingTimer == null)
7082 __pTitleSlidingTimer = new (std::nothrow) Timer;
7083 if (__pTitleSlidingTimer == null)
7085 return E_OUT_OF_MEMORY;
7088 r = __pTitleSlidingTimer->Construct(*this);
7094 r = __pTitleSlidingTimer->Start(TITLE_SLIDING_TIME);
7102 StopTitleSlidingTimer();
7107 _EditPresenter::OnTitleSlidingTimerExpired(void)
7109 result r = E_SUCCESS;
7113 StopTitleSlidingTimer();
7117 Rectangle tempBounds(0, 0, __pEdit->GetBounds().width, __pEdit->GetBounds().height);
7118 Canvas* pCanvas = __pEdit->GetCanvasN(tempBounds);
7119 SysTryReturnResult(NID_UI_CTRL, pCanvas, E_OUT_OF_MEMORY, "[EDIT] pCanvas is invalid!");
7121 if (__pTitleTextObject->IsChanged())
7123 DrawTitleText(*pCanvas);
7126 if (__isTouchPressed)
7128 pCanvas->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_PRESSED));
7132 pCanvas->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED));
7135 pCanvas->Clear(__titleBounds);
7136 __pTitleTextObject->DrawWithOffset(*_CanvasImpl::GetInstance(*pCanvas));
7137 r = pCanvas->Show(__titleBounds);
7141 r = StartTitleSlidingTimer();
7147 _EditPresenter::ChangePasswordToEchoCharacter(int cursorPos, int textLength)
7149 result r = E_SUCCESS;
7151 if (!(__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD))
7156 StartPasswordTimer();
7157 if (IsBlocked() == true)
7159 __pTextObject->SetRange(cursorPos, textLength);
7163 __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), 0);
7170 _EditPresenter::StopPasswordTimer(void)
7172 if (__pPasswordTimer)
7174 __pPasswordTimer->Cancel();
7175 delete __pPasswordTimer;
7176 __pPasswordTimer = null;
7183 _EditPresenter::StartPasswordTimer(void)
7185 result r = E_SUCCESS;
7187 if (__pPasswordTimer == null)
7189 __pPasswordTimer = new (std::nothrow) Timer;
7190 if (__pPasswordTimer == null)
7192 return E_OUT_OF_MEMORY;
7195 r = __pPasswordTimer->Construct(*this);
7198 StopPasswordTimer();
7203 r = __pPasswordTimer->Start(EDIT_PASSWORD_TIMER_PERIOD);
7206 StopPasswordTimer();
7213 _EditPresenter::OnPasswordTimerExpired(void)
7215 result r = E_SUCCESS;
7222 ReplaceTextIntoPasswordHyphenString();
7224 __pEdit->Invalidate();
7230 _EditPresenter::ReplaceTextIntoPasswordHyphenString(void)
7232 result r = E_SUCCESS;
7234 if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)
7236 if (GetTextLength() > 0)
7238 ChangePasswordToEchoCharacter(__pTextBuffer, __echoChar);
7246 _EditPresenter::ChangePasswordToEchoCharacter(wchar_t* dspStrBuffer, wchar_t echoChar)
7248 result r = E_SUCCESS;
7250 int bufferLength = GetTextLength();
7252 for (int i = 0; i < bufferLength && i < EDIT_PASSWORD_BUFFER_MAX - 1; i++)
7254 dspStrBuffer[i] = echoChar;
7256 dspStrBuffer[bufferLength] = null;
7262 _EditPresenter::SetAutoResizingEnabled(bool enable)
7264 return __pEditModel->SetAutoResizingEnabled(enable);
7268 _EditPresenter::IsAutoResizingEnabled(void) const
7270 return __pEditModel->IsAutoResizingEnabled();
7274 _EditPresenter::SetDefaultFont(void)
7276 result r = E_SUCCESS;
7278 Font* pControlFont = null;
7279 _ControlOrientation orientation = __pEdit->GetOrientation();
7280 int defaultFontSize = 0;
7281 GET_SHAPE_CONFIG(EDIT::DEFAULT_FONT_SIZE, orientation, defaultFontSize);
7283 __isFontInitialized = false;
7284 __contentFontSize = defaultFontSize;
7285 __contentFontStyle = FONT_STYLE_PLAIN;
7286 pControlFont = __pEdit->GetFallbackFont();
7289 AdjustFont(*pControlFont);
7296 _EditPresenter::CalculateFlexibleHeight(void)
7299 int expectedEditHeight = __pTextObject->GetTotalHeight() + __verticalMargin;
7300 int lineCount = __pTextObject->GetTotalLineCount();
7302 if (__pTextObject->GetTotalHeight())
7304 if ((lineCount >= MAX_LINE_NUMBER) && (GetMaxLineCount() > MAX_LINE_NUMBER))
7306 height = MAX_LINE_NUMBER * __pTextObject->GetLineHeightAt(0) + __verticalMargin;
7310 int maxHeight = CalculateMaximumFlexibleHeight();
7312 if (expectedEditHeight >= maxHeight)
7316 else if (expectedEditHeight < __initialBounds.height)
7318 height = __initialBounds.height;
7322 height = expectedEditHeight;
7327 height = __initialBounds.height;
7334 _EditPresenter::AdjustFlexibleHeight(void)
7336 result r = E_SUCCESS;
7338 if (__isFlexibleHeightFrozen == true)
7343 if (__maximumFlexibleHeight > 0 && __maximumFlexibleHeight <= __initialBounds.height)
7348 __pTextObject->Compose();
7350 if (__prevTotalTextHeight == __pTextObject->GetTotalHeight()) // if text height has not changed.
7352 __prevTotalTextHeight = __pTextObject->GetTotalHeight();
7357 Rectangle bounds = __pEdit->GetBounds();
7358 int calculateHeight = CalculateFlexibleHeight();
7360 if (bounds.height != calculateHeight)
7362 bounds.height = calculateHeight;
7363 __prevTotalTextHeight = __pTextObject->GetTotalHeight();
7364 return SetFlexBounds(bounds);
7366 __prevTotalTextHeight = __pTextObject->GetTotalHeight();
7371 _EditPresenter::SetFlexBounds(const Rectangle& bounds)
7373 result r = E_SUCCESS;
7375 _ExpandableEditAreaEventStatus expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_ADDED;
7376 if (__pEdit->GetBounds().height > bounds.height)
7378 expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_REMOVED;
7380 else if (__pEdit->GetBounds().height < bounds.height)
7382 expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_ADDED;
7385 _VisualElement* pVisualElement = __pEdit->GetVisualElement();
7386 SysTryReturnResult(NID_UI_CTRL, pVisualElement, E_SYSTEM, "A system error has occurred. Unable to get root visual element.");
7388 pVisualElement->SetAnimationProvider(__pEditVEDelegator);
7389 pVisualElement->SetImplicitAnimationEnabled(true);
7391 __pEdit->SetBounds(bounds);
7394 __pEdit->Invalidate();
7396 __prevTotalTextHeight = __pTextObject->GetTotalHeight();
7397 __pEdit->SendExpandableEditAreaEvent(expandableEditAreaStatus);
7399 pVisualElement->SetImplicitAnimationEnabled(false);
7405 _EditPresenter::CalculateMaximumFlexibleHeight(void)
7407 int maxHeight = __maximumFlexibleHeight;
7408 int expectedEditHeight = __pTextObject->GetTotalHeight() + __verticalMargin;
7409 int maximumFlexibleLineNumber = GetMaxLineCount();
7411 // if height is longer than max height.
7412 if (maxHeight > 0 && expectedEditHeight >= maxHeight)
7414 maxHeight = __maximumFlexibleHeight;
7416 else if (maximumFlexibleLineNumber > 0) // if max line number is set.
7418 maxHeight = maximumFlexibleLineNumber * __pTextObject->GetLineHeightAt(0) + __verticalMargin;
7420 Dimension dim = __pEdit->GetMaximumSize();
7421 if (maxHeight > dim.height)
7423 maxHeight = dim.height;
7431 _EditPresenter::SetKeypadBounds(const Rectangle& bounds)
7433 __keypadBounds.x = bounds.x;
7434 __keypadBounds.y = bounds.y;
7435 __keypadBounds.width = bounds.width;
7436 __keypadBounds.height = bounds.height;
7441 _EditPresenter::GetParentForm(void)
7448 if (__pEdit->GetInputStyle() == INPUT_STYLE_FULLSCREEN)
7453 if (__pParentForm == null)
7455 result r = E_SUCCESS;
7457 _Form* pForm = null;
7458 _Control* pControlCore = null;
7460 for (pControlCore = __pEdit->GetParent(); pForm == null; pControlCore = pControlCore->GetParent())
7462 if (pControlCore == null)
7468 pForm = dynamic_cast<_Form*>(pControlCore);
7470 __pParentForm = pForm;
7474 return __pParentForm;
7478 _EditPresenter::SetKeypadCommandButtonVisible(bool visible)
7480 __isKeypadCommandButtonVisible = visible;
7485 _EditPresenter::SetKeypadCommandButton(CommandButtonPosition position, const String& text, int actionId)
7487 result r = E_SUCCESS;
7488 FooterItem footerItem;
7489 footerItem.Construct(actionId);
7490 footerItem.SetText(text);
7492 __pEditModel->SetCommandButtonItem(position, actionId, text);
7493 if (__pCommandButton)
7495 _Button* pButton = __pCommandButton->GetItem(static_cast<int>(position));
7498 pButton->SetActionId(actionId);
7499 pButton->SetText(text);
7507 _EditPresenter::GetKeypadCommandButton(void) const
7509 return __pCommandButton;
7513 _EditPresenter::AddActionEventListener(const _IActionEventListener& listener)
7517 if (__pCommandButton)
7519 __pCommandButton->AddActionEventListener(listener);
7522 __pActionEventListener = const_cast<_IActionEventListener*>(&listener);
7528 _EditPresenter::RemoveActionEventListener(const _IActionEventListener& listener)
7532 if (__pCommandButton)
7534 __pCommandButton->RemoveActionEventListener(listener);
7537 __pActionEventListener = null;
7543 _EditPresenter::SetTextBounds(Rectangle& bounds)
7545 __textObjectBounds = bounds;
7550 _EditPresenter::GetTextBounds(void) const
7552 return __textObjectBounds;
7556 _EditPresenter::IsKeypadCommandButtonVisible(void) const
7558 return __isKeypadCommandButtonVisible;
7562 _EditPresenter::GetKeypadCommandButtonText(CommandButtonPosition position) const
7564 return __pEditModel->GetKeypadCommandButtonText(position);
7568 _EditPresenter::GetKeypadCommandButtonActionId(CommandButtonPosition position) const
7570 return __pEditModel->GetKeypadCommandButtonActionId(position);
7574 _EditPresenter::DrawScrollBar(void)
7576 result r = E_SUCCESS;
7578 if (__pScrollBar == null)
7583 int totalHeight = __pTextObject->GetTotalHeight();
7584 int dspHeight = __textObjectBounds.height;
7585 int firstDisplayY = __pTextObject->GetFirstDisplayPositionY();
7587 if (totalHeight <= dspHeight)
7589 if (__prevTotalTextHeight != 0 && __prevTotalTextHeight == totalHeight) // flexible edit's case
7594 __pScrollBar->SetScrollRange(1, 1);
7595 __pScrollBar->SetScrollPosition(0);
7597 __isScrollBarVisible = false;
7598 __previousScrollBarPos = 0;
7599 __previousScrollBarMaxPos = 0;
7603 if (firstDisplayY > 0)
7605 __pScrollBar->SetScrollRange(dspHeight, totalHeight);
7606 __pScrollBar->SetScrollPosition(firstDisplayY);
7607 __previousScrollBarMaxPos = totalHeight - dspHeight;
7611 __pScrollBar->SetScrollRange(dspHeight, totalHeight);
7612 __pScrollBar->SetScrollPosition(0);
7613 __previousScrollBarMaxPos = 0;
7616 if (__pScrollBar->GetScrollVisibility())
7618 __isScrollBarVisible = true;
7621 __previousScrollBarPos = firstDisplayY;
7628 _EditPresenter::FadeOutScrollBar(void)
7632 __pScrollBar->SetScrollVisibility(false);
7634 __isScrollBarVisible = false;
7640 _EditPresenter::InitializeFlickAnimation(void)
7642 result r = E_SUCCESS;
7644 if (__pFlickAnimation == null)
7646 __pFlickAnimation = new (std::nothrow) _FlickAnimation;
7649 // Init Flick Animation Config
7650 if (__pFlickAnimation)
7652 __pFlickAnimation->SetSizeInformation(480, 800, DEVICE_SIZE_HORIZONTAL, DEVICE_SIZE_VERTICAL);
7653 __pFlickAnimation->SetSensitivity(FLICK_ANIMATION_FPS_ICONLIST, FLICK_ANIMATION_SENSITIVITY_ICONLIST);
7660 if (__pFlickAnimationTimer == null)
7662 __pFlickAnimationTimer = new (std::nothrow) Timer;
7663 if (__pFlickAnimationTimer == null)
7665 r = E_OUT_OF_MEMORY;
7669 r = __pFlickAnimationTimer->Construct(*this);
7672 delete __pFlickAnimationTimer;
7684 _EditPresenter::StartFlickAnimation(const Point& flickPosition, int flickTime)
7686 // delete Scroll Fadeout Timer
7692 if (__pScrollBar->IsOnFadeEffect() == true)
7694 __pScrollBar->CancelFadeEffect();
7697 if (InitializeFlickAnimation() != E_SUCCESS)
7703 // Initialize flick animation
7707 __pFlickAnimation->CalculateInitializeVelocity(flickPosition.x, flickPosition.y, flickTime, &velocityX, &velocityY);
7709 if (Math::Abs(flickPosition.x) > Math::Abs(flickPosition.y))
7711 __pFlickAnimation->InitializeFlickAmount(velocityX);
7715 __pFlickAnimation->InitializeFlickAmount(velocityY);
7718 return StartFlickTimer(velocityY, velocityX);
7722 _EditPresenter::StartFlickTimer(int flickVelocityX, int flickVelocityY)
7724 if (__pFlickAnimation)
7726 if (ScrollContentsOnFlick() != E_SUCCESS)
7735 if (__pFlickAnimationTimer)
7737 if (__pFlickAnimationTimer->Start(EDIT_FLICK_SCROLL_TIMER_INTERVAL) != E_SUCCESS)
7753 _EditPresenter::ScrollContentsOnFlick(void)
7755 if (__pFlickAnimation)
7757 int moveAmountX = 0;
7758 int moveAmountY = 0;
7759 __pFlickAnimation->CalculateNextMove(&moveAmountX, &moveAmountY);
7762 if (ScrollOnFlick(-moveAmountY))
7764 __pEdit->Invalidate();
7774 _EditPresenter::ScrollOnFlick(int moveDistanceY)
7776 if (moveDistanceY == 0)
7782 if (__pScrollBar->IsOnFadeEffect() == true)
7784 __pScrollBar->CancelFadeEffect();
7787 ScrollContents(moveDistanceY);
7793 _EditPresenter::SetCursorEnabled(bool enable)
7795 __isCursorOpaque = enable;
7801 _EditPresenter::IsCursorEnabled(void) const
7803 return __isCursorOpaque;
7807 _EditPresenter::StopFlickTimer(void)
7809 if (__pFlickAnimationTimer != null)
7811 __pFlickAnimationTimer->Cancel();
7812 delete __pFlickAnimationTimer;
7813 __pFlickAnimationTimer = null;
7820 _EditPresenter::OnFlickTimerExpired(void)
7822 result r = E_SUCCESS;
7824 if (__pFlickAnimationTimer)
7827 if (__pFlickAnimationTimer->Start(EDIT_FLICK_SCROLL_TIMER_INTERVAL) != E_SUCCESS)
7834 if (ScrollContentsOnFlick() != E_SUCCESS)
7853 _EditPresenter::SetScrollBarVisible(bool enable)
7855 __isScrollBarVisible = enable;
7861 _EditPresenter::SetScrollBarBounds(const Rectangle& bounds)
7863 __scrollBarBounds = bounds;
7869 _EditPresenter::GetDisplayScrollBounds(void) const
7871 return __scrollBarBounds;
7875 _EditPresenter::GetInitialBounds(void) const
7877 return __initialBounds;
7881 _EditPresenter::SetPreviousScrollBarPosition(int position)
7883 __previousScrollBarPos = position;
7889 _EditPresenter::GetPreviousScrollPosition(void) const
7891 return __previousScrollBarPos;
7895 _EditPresenter::SetMaximumPreviousScrollBarPosition(int position)
7897 __previousScrollBarMaxPos = position;
7903 _EditPresenter::GetScrollBar(void) const
7905 return __pScrollBar;
7909 _EditPresenter::GetTextObject(void) const
7911 return __pTextObject;
7915 _EditPresenter::SetAutoShrinkModeEnabled(bool enable)
7917 __isAutoShrinkEnabled = enable;
7923 _EditPresenter::IsAutoShrinkModeEnabled(void) const
7925 return __isAutoShrinkEnabled;
7929 _EditPresenter::GetEditView(void) const
7935 _EditPresenter::InitializeParentPanel(void)
7937 if (__pParentPanel == null)
7939 _ScrollPanel* pScrollPanel = null;
7940 _Control* pControlCore = null;
7942 for (pControlCore = __pEdit->GetParent(); pScrollPanel == null; pControlCore = pControlCore->GetParent())
7944 if (pControlCore == null)
7949 pScrollPanel = dynamic_cast<_ScrollPanel*>(pControlCore);
7952 __pParentPanel = pScrollPanel;
7962 _EditPresenter::ScrollPanelToTop(bool show)
7964 if (!__pParentPanel)
7967 Rectangle editAbsoluteBounds = __pEdit->GetAbsoluteBounds();
7968 Rectangle panelAbsoluteBounds = __pParentPanel->GetAbsoluteBounds();
7969 int scrollPosition = __pParentPanel->GetScrollPosition() + (editAbsoluteBounds.y - panelAbsoluteBounds.y);
7971 __pParentPanel->SetScrollPosition(scrollPosition);
7975 __pParentPanel->Invalidate();
7982 _EditPresenter::ScrollPanelToExposedRegion(bool show)
7984 if (!__pParentPanel)
7987 __pParentPanel->ScrollToControl(*__pEdit);
7991 __pParentPanel->Invalidate();
7998 _EditPresenter::ScrollPanelToCursorPosition(bool show)
8000 if (!__pParentPanel)
8003 result r = E_SUCCESS;
8005 Rectangle absCursorBounds(0, 0, 0, 0);
8006 r = CalculateAbsoluteCursorBounds(__cursorPos, absCursorBounds);
8013 Rectangle absPanelRect = __pParentPanel->GetAbsoluteBounds();
8014 int panelHeight = __pParentPanel->GetBounds().height;
8016 int scrollPosition = __pParentPanel->GetScrollPosition();
8017 int cursorBoundsY = absCursorBounds.y - absPanelRect.y;
8019 int topYCompared = 0;
8020 int bottomYCompared = panelHeight;
8022 if (__textObjectBounds.height < absCursorBounds.height)
8024 absCursorBounds.height = __textObjectBounds.height;
8027 int upSideGap = topYCompared - cursorBoundsY;
8028 int downSideGap = (upSideGap > 0) ? 0 : cursorBoundsY + absCursorBounds.height - bottomYCompared;
8030 if (upSideGap > 0 || downSideGap > 0)
8033 int GAP_CORRECTION = __verticalMargin / 2;
8037 gap = scrollPosition - (upSideGap + GAP_CORRECTION);
8041 gap = scrollPosition + (downSideGap + GAP_CORRECTION);
8044 __pParentPanel->SetScrollPosition(gap);
8046 __pParentPanel->Invalidate();
8053 _EditPresenter::SetSearchBarFlag(bool enabled)
8055 __isSearchBar = enabled;
8061 _EditPresenter::GetSearchBarFlag(void) const
8063 return __isSearchBar;
8067 _EditPresenter::SetFocused(void)
8069 bool focused = true;
8072 if ((__pParentPanel->GetFocused() != __pEdit) && IsFocused() == false)
8077 else if (IsFocused() == false)
8082 if (focused == false)
8084 __pEdit->SetFocused();
8091 _EditPresenter::GetWordPosition(int cursorPos, int& startPos, int& endPos) const
8093 int textLength = GetTextLength();
8094 bool isDetected = false;
8096 if (cursorPos >= textLength && cursorPos > 0)
8101 if (IsDelimiter(__pTextBuffer[cursorPos]) && cursorPos > 0)
8106 for (int i = cursorPos; i >= 0; i--)
8108 if (IsDelimiter(__pTextBuffer[i]))
8116 if (isDetected == false)
8125 for (int i = cursorPos; i < textLength; i++)
8127 if (IsDelimiter(__pTextBuffer[i]))
8135 if (isDetected == false)
8137 endPos = textLength;
8144 _EditPresenter::GetTextImageRangeAt(int postion, int& startPosition, int& endPosition) const
8146 int length = GetTextLength();
8150 SysTryReturnResult(NID_UI_CTRL, postion >= 0 && postion <= length, E_OUT_OF_RANGE, "[EDIT] The given index is out-of-range.");
8151 SysTryReturnResult(NID_UI_CTRL, postion >0, E_OBJ_NOT_FOUND, "[EDIT] Object is not found at 0.");
8153 _Text::TextElement* pTextElement = __pTextObject->GetElementAtTextIndex(postion);
8154 const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
8155 if (pSimpleText != null && pSimpleText->GetBitmap() != null)
8157 startPosition = pSimpleText->GetTextOffset();
8158 endPosition = startPosition + pSimpleText->GetTextLength();
8162 return E_OBJ_NOT_FOUND;
8166 _EditPresenter::IsDelimiter(wchar_t character) const
8172 case 0x0A: // NLine Feed
8175 case 0x0D: // Carriage Return
8189 _EditPresenter::InitializeCopyPasteManager(void)
8191 bool releaseBlock = true;
8193 if (__pCopyPasteManager)
8195 releaseBlock = __pCopyPasteManager->GetTextBlockReleaseFlag();
8196 delete __pCopyPasteManager;
8197 __pCopyPasteManager = null;
8200 if (IsBlocked() == true && releaseBlock)
8203 __pEdit->Invalidate();
8206 __isCopyPastePopupVisible = false;
8207 __isCopyPastePopupMoving = false;
8213 _EditPresenter::IsCopyPastePopupVisible(void) const
8215 return __isCopyPastePopupVisible;
8219 _EditPresenter::GetTextAreaBounds(void) const
8221 return __textObjectBounds;
8225 _EditPresenter::GetTitleBounds(void) const
8227 return __titleBounds;
8231 _EditPresenter::GetClearIconBounds(void) const
8233 return __clearIconBounds;
8237 _EditPresenter::FinishTextComposition(void)
8239 if (__isInputConnectionBound)
8241 __pInputConnection->FinishTextComposition();
8242 __isTextComposing = false;
8243 __composingTextLength = 0;
8250 _EditPresenter::GetTextCompositionState(void) const
8252 return __isTextComposing;
8256 _EditPresenter::IsCopyPastePopup(const _Control& control) const
8258 if (__pCopyPasteManager)
8260 return __pCopyPasteManager->IsCopyPastePopup(control);
8267 _EditPresenter::SetCursorChangedFlag(bool enabled)
8269 __isCursorChanged = enabled;
8275 _EditPresenter::GetCursorChangedFlag(void) const
8277 return __isCursorChanged;
8281 _EditPresenter::SetEditGroupStyle(GroupStyle groupStyle)
8283 __groupStyle = groupStyle;
8289 _EditPresenter::SetKeypadClosedEventSkipped(bool enabled)
8291 if (__pEdit->IsFullScreenKeypadEdit())
8293 __isKeypadClosedEventSkipped = enabled;
8300 _EditPresenter::PostInternalEvent(const Tizen::Base::String& type)
8304 ArrayList* pArgs = new (std::nothrow) ArrayList();
8305 SysTryReturnVoidResult(NID_UI_CTRL, pArgs != null, E_SYSTEM, "[E_SYSTEM] pArgs is null.");
8307 result r = E_SYSTEM;
8308 r = pArgs->Construct();
8309 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to construct pArgs");
8311 String* pType = new (std::nothrow) String(type);
8312 SysTryReturnVoidResult(NID_UI, pType, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
8314 r = pArgs->Add(*pType);
8315 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to add type to pArgs");
8317 _UiNotificationEvent event(__pEdit->GetHandle(), pArgs);
8318 r = _UiEventManager::GetInstance()->PostEvent(event);
8319 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to send event");
8322 }}} // Tizen::Ui::Controls