2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrl_SearchBar.cpp
20 * @brief This is the implementation file for the _SearchBar class.
23 #include <FBaseErrorDefine.h>
24 #include <FBaseSysLog.h>
25 #include <FGrp_BitmapImpl.h>
26 #include "FUiAnim_VisualElement.h"
27 #include "FUi_ResourceManager.h"
28 #include "FUiCtrl_SearchBar.h"
29 #include "FUiCtrl_SearchBarPresenter.h"
30 #include "FUiCtrl_Form.h"
31 #include "FUiCtrl_Edit.h"
32 #include "FUiCtrl_Panel.h"
33 #include "FUiCtrl_OverlayPanel.h"
34 #include "FUiCtrl_Keypad.h"
35 #include "FUiCtrl_ColorPicker.h"
36 #include "FUiCtrl_ActionEvent.h"
37 #include "FUiCtrl_TextBlockEvent.h"
38 #include "FUiCtrl_TextEvent.h"
39 #include "FUi_AccessibilityContainer.h"
40 #include "FUi_AccessibilityElement.h"
41 #include "FUi_AccessibilityManager.h"
42 #include "FUi_CoordinateSystemUtils.h"
43 #include "FUiCtrl_SearchBarImpl.h"
44 #include "FUiCtrl_EditFieldImpl.h"
45 #include "FUiCtrl_ButtonImpl.h"
46 #include <FSys_SettingInfoImpl.h>
49 using namespace Tizen::Graphics;
50 using namespace Tizen::Ui;
51 using namespace Tizen::Ui::Animations;
52 using namespace Tizen::Base;
53 using namespace Tizen::Base::Runtime;
54 using namespace Tizen::Locales;
55 using namespace Tizen::System;
57 namespace Tizen { namespace Ui { namespace Controls
60 IMPLEMENT_PROPERTY(_SearchBar);
62 _SearchBar::_SearchBar(void)
63 : __pSearchBarPresenter(null)
64 , __pClippedGroupControl(null)
66 , __pCancelButton(null)
68 , __pContentControl(null)
71 , __isButtonEnabled(true)
72 , __isUsableCancelButton(false)
73 , __isUserContainerBounds(false)
74 , __isCancelActionInProgress(false)
75 , __isUserGuideTextColor(false)
76 , __isKeypadOpening(false)
77 , __isupdateContentBounds(false)
78 , __isKeyPressed(false)
79 , __isFocusCallbackToBeFired(true)
80 , __isButtonTextChangedByApp(false)
81 , __keypadAction(CORE_KEYPAD_ACTION_SEARCH)
82 , __pBackgroundBitmap(null)
83 , __backgroundColor(Color())
84 , __contentColor(Color())
85 , __pActionEvent(null)
86 , __pKeypadEvent(null)
87 , __pTextBlockEvent(null)
89 , __pSearchBarEvent(null)
90 , __pLanguageEvent(null)
91 , __pAccessibilitySearchBarElement(null)
93 for (int i = 0; i < SEARCHBAR_BUTTON_COLOR_MAX; i++)
95 __buttonColor[i] = Color(0);
96 __buttonTextColor[i] = Color(0);
99 for (int i = 0; i < SEARCHBAR_COLOR_MAX; i++)
101 __color[i] = Color(0);
102 __textColor[i] = Color(0);
103 __guideTextColor[i] = Color(0);
106 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
109 pContainer->Activate(true);
113 _SearchBar::~_SearchBar(void)
115 SettingInfo::RemoveSettingEventListener(*this);
117 delete __pSearchBarPresenter;
118 __pSearchBarPresenter = null;
120 if (__pClippedGroupControl)
122 DetachChild(*__pClippedGroupControl);
124 delete __pClippedGroupControl;
125 __pClippedGroupControl = null;
130 DetachChild(*__pContainer);
138 delete __pActionEvent;
139 __pActionEvent = null;
144 delete __pKeypadEvent;
145 __pKeypadEvent = null;
148 if (__pTextBlockEvent)
150 delete __pTextBlockEvent;
151 __pTextBlockEvent = null;
160 if (__pSearchBarEvent)
162 delete __pSearchBarEvent;
163 __pSearchBarEvent = null;
166 if (__pAccessibilitySearchBarElement)
168 __pAccessibilitySearchBarElement->Activate(false);
169 __pAccessibilitySearchBarElement = null;
172 delete __pBackgroundBitmap;
173 __pBackgroundBitmap = null;
177 _SearchBar::CreateSearchBarN(void)
179 _SearchBar* pSearchBar = new (std::nothrow) _SearchBar;
180 SysTryReturn(NID_UI_CTRL, pSearchBar, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
181 if (GetLastResult() != E_SUCCESS)
187 pSearchBar->AcquireHandle();
188 pSearchBar->SetTouchPressThreshold(_TOUCH_PRESS_THRESHOLD_INSENSITIVE);
194 _SearchBar::Initialize(bool enableSearchBarButton, CoreKeypadAction keypadAction)
196 result r = E_SUCCESS;
198 // Setting Button color
199 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_NORMAL, __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
200 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_PRESSED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
201 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_HIGHLIGHTED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
202 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_DISABLED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
204 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_NORMAL, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
205 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_PRESSED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
206 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_HIGHLIGHTED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
207 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_DISABLED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
209 GET_COLOR_CONFIG(SEARCHBAR::CONTENT_AREA_BG_NORMAL, __contentColor);
211 for (int i = 0; i < SEARCHBAR_COLOR_MAX; i++)
215 case SEARCH_FIELD_STATUS_DISABLED:
216 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_DISABLED, __color[i]);
217 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_DISABLED, __textColor[i]);
218 GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_DISABLED, __guideTextColor[i]);
221 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
222 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]);
223 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_HIGHLIGHTED, __textColor[i]);
224 GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_HIGHLIGHTED, __guideTextColor[i]);
227 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]);
228 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_NORMAL, __textColor[i]);
229 GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_NORMAL, __guideTextColor[i]);
234 __isUsableCancelButton = enableSearchBarButton;
235 __keypadAction = keypadAction;
237 GetVisualElement()->SetClipChildrenEnabled(false);
239 r = CreateClippedGroupControl();
240 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
241 "[E_SYSTEM] A system error has occurred. The construction of parent control for clipped group control failed.");
243 r = CreateSearchField();
244 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
245 "[E_SYSTEM] A system error has occurred. The edit construction failed.");
246 r = CreateCancelButton();
247 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
248 "[E_SYSTEM] A system error has occurred. The cancel button construction failed.");
251 r = CreateContentsArea();
252 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
253 "[E_SYSTEM] A system error has occurred. The construction of parent for content failed.");
255 _SearchBarPresenter* pPresenter = new (std::nothrow) _SearchBarPresenter;
256 SysTryReturn(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
258 r = pPresenter->Construct(*this);
259 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
261 r = pPresenter->Install();
262 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
264 __pSearchBarPresenter = pPresenter;
266 CreateAccessibilityElement();
268 r = _SettingInfoImpl::AddSettingEventListener(*this);
269 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
281 _SearchBar::CreateSearchField(void)
283 result r = E_SUCCESS;
285 FloatRectangle editBounds;
286 float horizontalMargin = 0.0f;
287 float verticalMargin = 0.0f;
288 float iconHorizontalMargin = 0.0f;
289 float textHorizontalMargin = 0.0f;
290 float iconWidth = 0.0f;
291 float textSize = 0.0f;
292 float searchBarMinHeight = 0.0f;
293 float searchBarMinWidthModeNormal = 0.0f;
295 FloatRectangle searchBarBounds = GetBoundsF();
296 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
298 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
299 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin);
300 GET_SHAPE_CONFIG(SEARCHBAR::ICON_HORIZONTAL_MARGIN, orientation, iconHorizontalMargin);
301 GET_SHAPE_CONFIG(SEARCHBAR::ICON_WIDTH, orientation, iconWidth);
302 GET_SHAPE_CONFIG(SEARCHBAR::TEXT_HORIZONTAL_MARGIN, orientation, textHorizontalMargin);
303 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH_NORMAL_MODE, orientation, searchBarMinWidthModeNormal);
304 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
306 float searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2.0f);
308 editBounds.x = horizontalMargin;
310 if (searchBarBounds.height < searchBarMinHeight)
312 verticalMargin = (searchBarBounds.height - searchFieldMinHeight)/2.0f;
313 if (verticalMargin < 0.0f)
315 verticalMargin = 0.0f;
319 editBounds.y = verticalMargin;
321 editBounds.width = searchBarBounds.width - (editBounds.x * 2.0f);
322 editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
324 editBounds.width = (editBounds.width > searchBarMinWidthModeNormal) ? editBounds.width : searchBarMinWidthModeNormal;
325 editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
327 _SearchBarImpl* pSearchBarImpl = static_cast<_SearchBarImpl*>(GetUserData());
328 __pEdit = &(pSearchBarImpl->GetEditFieldImpl()->GetCore());
330 SysTryReturnResult(NID_UI_CTRL, __pEdit != null, E_SYSTEM,
331 "[E_SYSTEM] A system error has occured. Failed to get _Edit instance");
333 __pEdit->SetKeypadCommandButtonVisible(false);
334 __pEdit->SetBounds(editBounds);
335 __pEdit->AddKeypadEventListener(*this);
336 __pEdit->AddTextBlockEventListener(*this);
337 __pEdit->AddTextEventListener(*this);
339 GET_SHAPE_CONFIG(SEARCHBAR::EDIT_TEXT_SIZE, orientation, textSize);
340 __pEdit->SetTextSize(textSize);
342 __pEdit->SetHorizontalMargin(iconHorizontalMargin + iconWidth + textHorizontalMargin, EDIT_TEXT_LEFT_MARGIN);
343 __pEdit->SetHorizontalMargin(textHorizontalMargin, EDIT_TEXT_RIGHT_MARGIN);
344 __pEdit->SetLimitLength(SEARCHBAR_TEXT_LENGTH_MAX);
346 for (int status = 0; status < SEARCHBAR_COLOR_MAX; status++)
348 EditStatus editStatus = ConvertSearchBarStatus((SearchFieldStatus) status);
349 __pEdit->SetColor(editStatus, __color[status]);
352 __pEdit->SetTextColor(EDIT_TEXT_COLOR_NORMAL, __textColor[SEARCH_FIELD_STATUS_NORMAL]);
353 __pEdit->SetTextColor(EDIT_TEXT_COLOR_DISABLED, __textColor[SEARCH_FIELD_STATUS_DISABLED]);
354 __pEdit->SetTextColor(EDIT_TEXT_COLOR_HIGHLIGHTED, __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
356 __pEdit->ReplaceDefaultBackgroundBitmapForSearchBar();
358 __pEdit->SetKeypadAction(__keypadAction);
360 r = __pClippedGroupControl->AttachChild(*__pEdit);
361 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
362 "[E_SYSTEM] A system error has occurred. Failed to attach edit as child.");
374 _SearchBar::CreateCancelButton(void)
376 result r = E_SUCCESS;
378 float textSize = 0.0f;
379 String cancelButtonText;
381 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
383 _SearchBarImpl* pSearchBarImpl = static_cast<_SearchBarImpl*>(GetUserData());
384 __pCancelButton = &(pSearchBarImpl->GetButtonImpl()->GetCore());
386 SysTryReturnResult(NID_UI_CTRL, __pCancelButton != null, E_SYSTEM,
387 "[E_SYSTEM] A system error has occured. Failed to get _Edit instance");
390 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
392 r = ResizeCancelButton();
393 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
395 GET_STRING_CONFIG(IDS_COM_SK_CANCEL, cancelButtonText);
396 r = __pCancelButton->SetText(cancelButtonText);
397 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
399 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_TEXT_SIZE, orientation, textSize);
400 r = __pCancelButton->SetTextSize(textSize);
401 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
403 __pCancelButton->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
404 __pCancelButton->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
406 r = __pCancelButton->SetActionId(__actionId);
407 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
409 r = __pCancelButton->AddActionEventListener(*this);
410 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
412 __pCancelButton->SetVisibleState(false);
414 for (int status = 0; status < SEARCHBAR_BUTTON_COLOR_MAX; status++)
416 _ButtonStatus buttonStatus = ConvertSearchBarButtonStatus((SearchBarButtonStatus) status);
418 r = __pCancelButton->SetColor(buttonStatus, __buttonColor[status]);
419 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
421 r = __pCancelButton->SetTextColor(buttonStatus, __buttonTextColor[status]);
422 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
425 r = __pClippedGroupControl->AttachChild(*__pCancelButton);
426 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
427 "[E_SYSTEM] A system error has occurred. Failed to attach button as child.");
432 delete __pCancelButton;
433 __pCancelButton = null;
439 _SearchBar::CreateContentsArea(void)
441 result r = E_SUCCESS;
443 __pContainer = _Control::CreateControlN();
446 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
448 __pContainer->SetVisibleState(false);
450 r = AttachChild(*__pContainer);
451 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
452 "[E_SYSTEM] A system error has occurred. Failed to attach the parent of content.");
464 _SearchBar::SetContentsArea(void)
466 if (__isUserContainerBounds)
471 FloatDimension screenSize = _ControlManager::GetInstance()->GetScreenSizeF();
472 float width = screenSize.width;
473 float height = screenSize.height;
475 _Control* pParent = GetParentForm();
478 width = pParent->GetClientBoundsF().width;
479 height = pParent->GetClientBoundsF().height;
482 FloatRectangle controlBounds = GetBoundsF();
483 controlBounds = CoordinateSystem::AlignToDevice(FloatRectangle(controlBounds));
485 __contentAreaBounds.x = 0.0f;
486 __contentAreaBounds.y = controlBounds.height;
487 __contentAreaBounds.width = width - controlBounds.x;
488 __contentAreaBounds.height = height - (controlBounds.y + controlBounds.height);
492 result r = E_SUCCESS;
493 r = __pContainer->SetBounds(__contentAreaBounds);
494 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
500 _SearchBar::GetContent(void) const
502 return __pContentControl;
506 _SearchBar::SetContent(const _Control* pContent)
508 __pContentControl = const_cast <_Control*>(pContent);
509 result r = E_SUCCESS;
513 r = __pContainer->AttachChild(*__pContentControl);
514 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating");
521 _SearchBar::UpdateContentArea(bool invalidate)
523 return __pSearchBarPresenter->UpdateContentArea(invalidate);
527 _SearchBar::SetContentAreaVisible(bool visible)
529 SysTryReturn(NID_UI_CTRL, __pContainer, E_SYSTEM, E_SYSTEM,
530 "[E_SYSTEM] A system error has occurred. The instance of parent to content is null.");
532 SearchBarMode searchBarMode = GetMode();
533 if (searchBarMode == SEARCH_BAR_MODE_INPUT)
535 __pContainer->SetVisibleState(visible);
538 return __pSearchBarPresenter->SetContentAreaVisible(visible);
542 _SearchBar::IsContentAreaVisible(void) const
544 return __pSearchBarPresenter->IsContentAreaVisible();
548 _SearchBar::SetContentAreaSize(const Dimension& size)
550 return SetProperty("contentAreaSize", Variant(size));
554 _SearchBar::GetContentAreaSize(void) const
556 Variant size = GetProperty("contentAreaSize");
558 return size.ToDimension();
562 _SearchBar::GetMode(void) const
564 return __pSearchBarPresenter->GetMode();
568 _SearchBar::IsModeLocked(void) const
570 return __pSearchBarPresenter->IsModeLocked();
574 _SearchBar::SetMode(SearchBarMode mode)
576 return __pSearchBarPresenter->SetMode(mode);
580 _SearchBar::SetModeLocked(bool modeLocked)
582 if (modeLocked == true && GetMode() == SEARCH_BAR_MODE_NORMAL)
584 __pEdit->SetViewModeEnabled(true);
587 if (modeLocked == false && __pEdit->IsViewModeEnabled())
589 __pEdit->SetViewModeEnabled(false);
592 return __pSearchBarPresenter->SetModeLocked(modeLocked);
596 _SearchBar::GetButtonActionId(void) const
598 Variant actionId = GetProperty("buttonActionId");
600 return actionId.ToInt();
604 _SearchBar::GetButtonColor(SearchBarButtonStatus status) const
610 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
611 buttonColor = GetProperty("buttonNormalColor");
613 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
614 buttonColor = GetProperty("buttonPressedColor");
616 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
617 buttonColor = GetProperty("buttonHighlightedColor");
619 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
620 buttonColor = GetProperty("buttonDisabledColor");
626 return buttonColor.ToColor();
630 _SearchBar::GetButtonTextColor(SearchBarButtonStatus status) const
632 Variant buttonTextColor;
636 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
637 buttonTextColor = GetProperty("buttonNormalTextColor");
639 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
640 buttonTextColor = GetProperty("buttonPressedTextColor");
642 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
643 buttonTextColor = GetProperty("buttonHighlightedTextColor");
645 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
646 buttonTextColor = GetProperty("buttonDisabledTextColor");
652 return buttonTextColor.ToColor();
655 SearchBarButtonStatus
656 _SearchBar::GetButtonStatus(void) const
658 SysTryReturn(NID_UI_CTRL, __pCancelButton, SEARCH_BAR_BUTTON_STATUS_NORMAL, E_SYSTEM,
659 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
661 SearchBarButtonStatus buttonStatus = SEARCH_BAR_BUTTON_STATUS_NORMAL;
663 if (__isButtonEnabled == false)
665 buttonStatus = SEARCH_BAR_BUTTON_STATUS_DISABLED;
672 _SearchBar::SetButtonText(const String& text)
674 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
675 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
677 result r = E_SUCCESS;
679 r = __pCancelButton->SetText(text);
680 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
681 "[E_SYSTEM] A system error has occurred. Failed to set text.");
683 __isButtonTextChangedByApp = true;
689 _SearchBar::SetButtonActionId(int actionId)
691 return SetProperty("buttonActionId", Variant(actionId));
695 _SearchBar::SetButtonEnabled(bool enabled)
697 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
698 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
700 __pCancelButton->SetEnableState(enabled);
702 __isButtonEnabled = enabled;
708 _SearchBar::SetButtonColor(SearchBarButtonStatus status, const Color& color)
710 result r = E_SUCCESS;
714 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
715 r = SetProperty("buttonNormalColor", Variant(color));
717 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
718 r = SetProperty("buttonPressedColor", Variant(color));
720 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
721 r = SetProperty("buttonHighlightedColor", Variant(color));
723 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
724 r = SetProperty("buttonDisabledColor", Variant(color));
734 _SearchBar::SetButtonTextColor(SearchBarButtonStatus status, const Color& color)
736 result r = E_SUCCESS;
740 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
741 r = SetProperty("buttonNormalTextColor", Variant(color));
743 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
744 r = SetProperty("buttonPressedTextColor", Variant(color));
746 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
747 r = SetProperty("buttonHighlightedTextColor", Variant(color));
749 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
750 r = SetProperty("buttonDisabledTextColor", Variant(color));
760 _SearchBar::AppendCharacter(const Character& character)
762 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
763 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
764 SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM,
765 "[E_SYSTEM] A system error has occurred. The character is null.");
767 result r = E_SUCCESS;
769 r = __pEdit->AppendCharacter(character);
770 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
771 "[E_SYSTEM] A system error has occurred. Failed to set character.");
777 _SearchBar::AppendText(const String& text)
779 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
780 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
781 SysTryReturn(NID_UI_CTRL, text.IsEmpty() == false, E_SYSTEM, E_SYSTEM,
782 "[E_SYSTEM] A system error has occurred. The text is empty.");
784 result r = E_SUCCESS;
786 r = __pEdit->AppendText(text);
787 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
788 "[E_SYSTEM] A system error has occurred. Failed to set text.");
794 _SearchBar::SetText(const String& text)
796 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
797 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
799 result r = E_SUCCESS;
801 int limitLength = __pEdit->GetTextLimitLength();
802 int textLength = text.GetLength();
803 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_SYSTEM, E_SYSTEM,
804 "[E_SYSTEM] A system error has occurred. textLength exceeds the limitLength");
806 r = __pEdit->SetText(text);
807 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
808 "[E_SYSTEM] A system error has occurred. Failed to set text.");
814 _SearchBar::InsertCharacterAt(int index, const Character& character)
816 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
817 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
818 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
819 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
820 SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM,
821 "[E_SYSTEM] A system error has occurred. The character is null.");
823 result r = E_SUCCESS;
827 limitLength = __pEdit->GetTextLimitLength();
828 textLength = __pEdit->GetTextLength() + 1;
830 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
831 "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
833 SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
834 "[E_OUT_OF_RANGE] index(%d) is out of range of current textLength(%d).", index, __pEdit->GetTextLength());
836 r = __pEdit->InsertCharacterAt(index, character);
837 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
838 "[E_SYSTEM] A system error has occurred. Failed to set text.");
844 _SearchBar::InsertTextAt(int index, const String& text)
846 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
847 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
848 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
849 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
851 result r = E_SUCCESS;
855 limitLength = __pEdit->GetTextLimitLength();
856 textLength = __pEdit->GetTextLength() + text.GetLength();
858 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
859 "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
860 SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
861 "[E_OUT_OF_RANGE] index(%d) is out of range of current textLength(%d).", index, __pEdit->GetTextLength());
863 r = __pEdit->InsertTextAt(index, text);
864 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
865 "[E_SYSTEM] A system error has occurred. Failed to insert text.");
871 _SearchBar::DeleteCharacterAt(int index)
873 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
874 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
875 SysTryReturn(NID_UI_CTRL, index > -1, E_INVALID_ARG, E_INVALID_ARG,
876 "[E_INVALID_ARG] Invalid argument(s) is used. index = %d", index);
878 result r = E_SUCCESS;
880 textLength = __pEdit->GetTextLength();
882 SysTryReturn(NID_UI_CTRL, textLength > index, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
883 "[E_OUT_OF_RANGE] index(%d) is out of range. textLength(%d)", index, textLength);
885 r = __pEdit->DeleteCharacterAt(index);
886 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM,
887 "[E_SYSTEM] A system error has occured. Failed to delete character.");
893 _SearchBar::Clear(void)
895 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
896 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
898 return __pEdit->ClearText();
902 _SearchBar::GetTextLength(void) const
904 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
905 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
907 return __pEdit->GetTextLength();
911 _SearchBar::GetText(void) const
913 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
914 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
916 return __pEdit->GetText();
920 _SearchBar::GetText(int start, int end) const
922 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
923 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
925 return __pEdit->GetText(start, end);
929 _SearchBar::GetLimitLength(void) const
931 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
932 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
934 return __pEdit->GetTextLimitLength();
938 _SearchBar::SetLimitLength(int limitLength)
940 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
941 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
942 SysTryReturn(NID_UI_CTRL, limitLength > 0, E_INVALID_ARG, E_INVALID_ARG,
943 "[E_INVALID_ARG] Invalid argument(s) is used.limitLength = %d", limitLength);
945 String tempString = GetText();
947 int textLength = tempString.GetLength();
948 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_INVALID_ARG, E_INVALID_ARG,
949 "[E_INVALID_ARG] Invalid argument(s) is used. limitLength = %d, textLength = %d", limitLength, textLength);
951 result r = __pEdit->SetLimitLength(limitLength);
952 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
954 r = SetText(tempString);
955 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
961 _SearchBar::ShowKeypad(void) const
963 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
964 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
966 SearchBarMode mode = __pSearchBarPresenter->GetMode();
967 SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_INVALID_STATE, E_INVALID_STATE,
968 "[E_INVALID_STATE] The SearchBar is currently in Normal mode.");
969 return __pEdit->ShowKeypad();
973 _SearchBar::HideKeypad(void)
975 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
976 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
978 SearchBarMode mode = __pSearchBarPresenter->GetMode();
979 SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_SYSTEM, E_SYSTEM,
980 "[E_SYSTEM] A system error has occurred. The SearchBar is currently in Normal mode.");
982 result r = __pEdit->HideKeypad();
990 _SearchBar::GetSearchFieldTextSizeF(void) const
992 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
993 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
995 return __pEdit->GetTextSizeF();
999 _SearchBar::SetSearchFieldTextSize(float size)
1001 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1002 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1004 return __pEdit->SetTextSize(size);
1008 _SearchBar::GetBlockRange(int& start, int& end) const
1010 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1011 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1013 int startIndex = -1;
1016 __pEdit->GetBlockRange(startIndex, endIndex);
1017 SysTryReturn(NID_UI_CTRL, (startIndex > -1 && endIndex > 0), E_SYSTEM, E_SYSTEM,
1018 "[E_SYSTEM] A system error has occurred. Failed to get text block range.");
1027 _SearchBar::ReleaseBlock(void)
1029 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1030 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1032 result r = E_SUCCESS;
1037 r = GetBlockRange(start, end);
1038 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1040 return __pEdit->ReleaseTextBlock();
1044 _SearchBar::SetBlockRange(int start, int end)
1046 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1047 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1049 result r = E_SUCCESS;
1052 textLength = __pEdit->GetTextLength();
1054 SysTryReturn(NID_UI_CTRL, (start < end && start >= 0 && textLength >= end), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1055 "[E_OUT_OF_RANGE] start (%d) and end (%d) is out of range.", start, end - 1);
1057 r = SetCursorPosition(start);
1058 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1060 r = __pEdit->BeginTextBlock();
1061 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1062 "[E_SYSTEM] A system error has occurred. Failed to set text block range.");
1064 r = SetCursorPosition(end);
1065 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1066 "[E_SYSTEM] A system error has occurred. Failed to set cursor position.");
1072 _SearchBar::RemoveTextBlock(void)
1074 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1075 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1077 result r = E_SUCCESS;
1079 r = __pEdit->RemoveTextBlock();
1080 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1086 _SearchBar::GetColor(void) const
1088 Variant backgroundColor = GetProperty("color");
1090 return backgroundColor.ToColor();
1094 _SearchBar::GetSearchFieldColor(SearchFieldStatus status) const
1096 Variant searchFieldColor;
1100 case SEARCH_FIELD_STATUS_NORMAL:
1101 searchFieldColor = GetProperty("searchFieldNormalColor");
1103 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1104 searchFieldColor = GetProperty("searchFieldHighlightedColor");
1106 case SEARCH_FIELD_STATUS_DISABLED:
1107 searchFieldColor = GetProperty("searchFieldDisabledColor");
1113 return searchFieldColor.ToColor();
1118 _SearchBar::GetSearchFieldTextColor(SearchFieldStatus status) const
1120 Variant searchFieldTextColor;
1124 case SEARCH_FIELD_STATUS_NORMAL:
1125 searchFieldTextColor = GetProperty("searchFieldNormalTextColor");
1127 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1128 searchFieldTextColor = GetProperty("searchFieldHighlightedTextColor");
1130 case SEARCH_FIELD_STATUS_DISABLED:
1131 searchFieldTextColor = GetProperty("searchFieldDisabledTextColor");
1137 return searchFieldTextColor.ToColor();
1142 _SearchBar::SetBackgroundBitmap(const Bitmap& bitmap)
1144 Bitmap* pNewBitmap = _BitmapImpl::CloneN(bitmap);
1145 SysTryReturn(NID_UI_CTRL, pNewBitmap, E_SYSTEM, E_SYSTEM,
1146 "[E_SYSTEM] A system error has occurred. The creation of bitmap failed.");
1148 delete __pBackgroundBitmap;
1149 __pBackgroundBitmap = null;
1151 __pBackgroundBitmap = pNewBitmap;
1157 _SearchBar::GetBackgroundBitmap(void) const
1159 return __pBackgroundBitmap;
1163 _SearchBar::SetColor(const Color& color)
1165 return SetProperty("color", Variant(color));
1169 _SearchBar::SetSearchFieldColor(SearchFieldStatus status, const Color& color)
1171 result r = E_SUCCESS;
1175 case SEARCH_FIELD_STATUS_NORMAL:
1176 r = SetProperty("searchFieldNormalColor", Variant(color));
1178 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1179 r = SetProperty("searchFieldHighlightedColor", Variant(color));
1181 case SEARCH_FIELD_STATUS_DISABLED:
1182 r = SetProperty("searchFieldDisabledColor", Variant(color));
1193 _SearchBar::SetSearchFieldTextColor(SearchFieldStatus status, const Color& color)
1195 result r = E_SUCCESS;
1199 case SEARCH_FIELD_STATUS_NORMAL:
1200 r = SetProperty("searchFieldNormalTextColor", Variant(color));
1202 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1203 r = SetProperty("searchFieldHighlightedTextColor", Variant(color));
1205 case SEARCH_FIELD_STATUS_DISABLED:
1206 r = SetProperty("searchFieldDisabledTextColor", Variant(color));
1217 _SearchBar::GetGuideText(void) const
1219 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
1220 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1222 return __pEdit->GetGuideText();
1226 _SearchBar::SetGuideText(const String& guideText)
1228 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1229 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1231 __pEdit->SetGuideText(guideText);
1237 _SearchBar::GetGuideTextColor(void) const
1239 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1240 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1242 return __pEdit->GetGuideTextColor();
1246 _SearchBar::SetGuideTextColor(const Color& color)
1248 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1249 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1251 __isUserGuideTextColor = true;
1252 return __pEdit->SetGuideTextColor(color);
1256 _SearchBar::GetCursorPosition(void) const
1258 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
1259 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1261 return __pEdit->GetCursorPosition();
1265 _SearchBar::SetCursorPosition(int index)
1267 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1268 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1269 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1270 "[E_OUT_OF_RANGE] index(%d) is out of range.", GetErrorMessage(E_OUT_OF_RANGE), index);
1272 int textLength = -1;
1273 textLength = __pEdit->GetTextLength();
1275 SysTryReturn(NID_UI_CTRL, (index > -1 && index <= textLength), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1276 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
1278 return __pEdit->SetCursorPosition(index);
1282 _SearchBar::IsLowerCaseModeEnabled(void) const
1284 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1285 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1287 return __pEdit->IsLowerCaseModeEnabled();
1291 _SearchBar::SetLowerCaseModeEnabled(bool enable)
1293 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
1294 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1296 __pEdit->SetLowerCaseModeEnabled(enable);
1300 _SearchBar::GetEllipsisPosition(void) const
1302 SysTryReturn(NID_UI_CTRL, __pEdit, ELLIPSIS_POSITION_START, E_SYSTEM,
1303 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1305 return __pEdit->GetEllipsisPosition();
1309 _SearchBar::SetEllipsisPosition(EllipsisPosition position)
1311 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1312 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1313 __pEdit->SetEllipsisPosition(position);
1319 _SearchBar::GetKeypadAction(void) const
1321 return __keypadAction;
1325 _SearchBar::IsTextPredictionEnabled(void) const
1327 SysTryReturn(NID_UI_CTRL, __pEdit, false, E_SYSTEM,
1328 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1329 return __pEdit->IsTextPredictionEnabled();
1333 _SearchBar::SetTextPredictionEnabled(bool enable)
1335 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1336 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1337 return __pEdit->SetTextPredictionEnabled(enable);
1341 _SearchBar::SetCurrentLanguage(LanguageCode languageCode)
1343 return __pEdit->SetCurrentLanguage(languageCode);
1347 _SearchBar::GetCurrentLanguage(LanguageCode& language) const
1349 return __pEdit->GetCurrentLanguage(language);
1353 _SearchBar::AddActionEventListener(const _IActionEventListener& listener)
1355 result r = E_SUCCESS;
1357 if (__pActionEvent == null)
1359 __pActionEvent = _ActionEvent::CreateInstanceN(*this);
1360 r = GetLastResult();
1361 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1363 __pActionEvent->AddListener(listener);
1370 _SearchBar::RemoveActionEventListener(const _IActionEventListener& listener)
1372 SysTryReturn(NID_UI_CTRL, __pActionEvent, E_SYSTEM, E_SYSTEM,
1373 "[E_SYSTEM] A system error has occurred. The action event instance is null.");
1374 result r = E_SUCCESS;
1376 r = __pActionEvent->RemoveListener(listener);
1377 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1383 _SearchBar::AddKeypadEventListener(const _IKeypadEventListener& listener)
1385 result r = E_SUCCESS;
1387 if (__pKeypadEvent == null)
1389 __pKeypadEvent = _KeypadEvent::CreateInstanceN(*this);
1390 r = GetLastResult();
1391 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1393 r = __pKeypadEvent->AddListener(listener);
1394 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1401 _SearchBar::RemoveKeypadEventListener(const _IKeypadEventListener& listener)
1403 SysTryReturn(NID_UI_CTRL, __pKeypadEvent, E_SYSTEM, E_SYSTEM,
1404 "[E_SYSTEM] A system error has occurred. The keypad event instance is null.");
1405 result r = E_SUCCESS;
1407 r = __pKeypadEvent->RemoveListener(listener);
1408 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1414 _SearchBar::AddTextBlockEventListener(const _ITextBlockEventListener& listener)
1416 result r = E_SUCCESS;
1418 if (__pTextBlockEvent == null)
1420 __pTextBlockEvent = _TextBlockEvent::CreateInstanceN(*this);
1421 r = GetLastResult();
1422 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1424 r = __pTextBlockEvent->AddListener(listener);
1425 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1433 _SearchBar::RemoveTextBlockEventListener(const _ITextBlockEventListener& listener)
1435 SysTryReturn(NID_UI_CTRL, __pTextBlockEvent, E_SYSTEM, E_SYSTEM,
1436 "[E_SYSTEM] A system error has occurred. The text block event instance is null.");
1437 result r = E_SUCCESS;
1439 r = __pTextBlockEvent->RemoveListener(listener);
1440 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1447 _SearchBar::AddTextEventListener(const _ITextEventListener& listener)
1449 result r = E_SUCCESS;
1451 if (__pTextEvent == null)
1453 __pTextEvent = _TextEvent::CreateInstanceN(*this);
1454 r = GetLastResult();
1455 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1457 r = __pTextEvent->AddListener(listener);
1458 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1465 _SearchBar::RemoveTextEventListener(const _ITextEventListener& listener)
1467 SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM,
1468 "[E_SYSTEM] A system error has occurred. The text event instance is null.");
1469 result r = E_SUCCESS;
1471 r = __pTextEvent->RemoveListener(listener);
1472 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1478 _SearchBar::AddSearchBarEventListener(const _ISearchBarEventListener& listener)
1480 result r = E_SUCCESS;
1482 if (__pSearchBarEvent == null)
1484 __pSearchBarEvent = _SearchBarEvent::CreateInstanceN(*this);
1485 r = GetLastResult();
1486 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1488 r = __pSearchBarEvent->AddListener(listener);
1489 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1496 _SearchBar::RemoveSearchBarEventListener(const _ISearchBarEventListener& listener)
1498 SysTryReturn(NID_UI_CTRL, __pSearchBarEvent, E_SYSTEM, E_SYSTEM,
1499 "[E_SYSTEM] A system error has occurred. The searchbar event instance is null.");
1500 result r = E_SUCCESS;
1502 r = __pSearchBarEvent->RemoveListener(listener);
1503 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1509 _SearchBar::AddLanguageEventListener(const _ILanguageEventListener& listener)
1511 result r = E_SUCCESS;
1513 if (__pLanguageEvent == null)
1515 __pLanguageEvent = _LanguageEvent::CreateInstanceN(*this);
1516 r = GetLastResult();
1517 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1519 r = __pLanguageEvent->AddListener(listener);
1520 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1527 _SearchBar::RemoveLanguageEventListener(const _ILanguageEventListener& listener)
1529 SysTryReturn(NID_UI_CTRL, __pLanguageEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.");
1530 result r = E_SUCCESS;
1532 __pLanguageEvent->RemoveListener(listener);
1533 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1539 _SearchBar::OnBoundsChanged(void)
1541 if (__pSearchBarPresenter != null)
1543 __isupdateContentBounds = true;
1544 __pSearchBarPresenter->OnBoundsChanged();
1547 if (__pAccessibilitySearchBarElement)
1549 __pAccessibilitySearchBarElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height));
1555 _SearchBar::OnChangeLayout(_ControlOrientation orientation)
1557 __isupdateContentBounds = true;
1562 _SearchBar::OnDraw(void)
1564 if (!__isUserGuideTextColor)
1566 SearchFieldStatus status = GetCurrentStatus();
1567 __pEdit->SetGuideTextColor(__guideTextColor[status]);
1570 if (__isupdateContentBounds)
1573 __isupdateContentBounds = false;
1575 __pSearchBarPresenter->Draw();
1579 _UiTouchEventDelivery
1580 _SearchBar::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1582 _Edit* pEdit = dynamic_cast <_Edit*>(const_cast <_Control*>(&source));
1585 return _UI_TOUCH_EVENT_DELIVERY_YES;
1588 if (GetMode() == SEARCH_BAR_MODE_INPUT)
1590 return _UI_TOUCH_EVENT_DELIVERY_YES;
1593 return _UI_TOUCH_EVENT_DELIVERY_YES;
1597 _SearchBar::OnActionPerformed(const _Control& source, int actionId)
1599 if (__actionId == actionId)
1601 __isCancelActionInProgress = true;
1602 SetMode(SEARCH_BAR_MODE_NORMAL);
1606 IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(__actionId);
1607 result r = GetLastResult();
1608 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1610 __pActionEvent->Fire(*pEventArg);
1612 __isCancelActionInProgress = false;
1619 _SearchBar::OnKeypadWillOpen(void)
1621 if (!__isKeypadOpening)
1625 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CREATED);
1626 result r = GetLastResult();
1627 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1629 __pKeypadEvent->Fire(*pEventArg);
1633 __isKeypadOpening = true;
1638 _SearchBar::OnKeypadOpened(void)
1642 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_OPEN);
1643 result r = GetLastResult();
1644 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1646 __pKeypadEvent->Fire(*pEventArg);
1649 __isKeypadOpening = false;
1655 _SearchBar::OnKeypadClosed(void)
1659 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CLOSE);
1660 result r = GetLastResult();
1661 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1663 __pKeypadEvent->Fire(*pEventArg);
1666 __isKeypadOpening = false;
1673 _SearchBar::OnKeypadBoundsChanged(void)
1677 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1678 result r = GetLastResult();
1679 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1681 __pKeypadEvent->Fire(*pEventArg);
1689 _SearchBar::OnKeypadActionPerformed(CoreKeypadAction keypadAction)
1693 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(keypadAction, CORE_KEYPAD_EVENT_STATUS_ENTERACTION);
1694 result r = GetLastResult();
1695 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1697 __pKeypadEvent->Fire(*pEventArg);
1702 // TextBlock callbacks
1704 _SearchBar::OnTextBlockSelected(_Control& source, int start, int end)
1706 if (__pTextBlockEvent)
1708 IEventArg* pEventArg = _TextBlockEvent::CreateTextBlockEventArgN(start, end);
1709 result r = GetLastResult();
1710 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1712 __pTextBlockEvent->Fire(*pEventArg);
1719 _SearchBar::OnTextValueChanged(const _Control& source)
1721 if (!__isCancelActionInProgress)
1723 SetContentDimming();
1724 if (__pTextEvent != null)
1726 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CHANGED);
1727 result r = GetLastResult();
1728 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1730 __pTextEvent->Fire(*pEventArg);
1737 _SearchBar::OnTextValueChangeCanceled(const _Control& source)
1739 if (__pTextEvent != null)
1741 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CANCELED);
1742 result r = GetLastResult();
1743 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1745 __pTextEvent->Fire(*pEventArg);
1751 _SearchBar::OnAttachedToMainTree(void)
1758 _SearchBar::OnFontChanged(Font* pFont)
1760 __pCancelButton->SetFont(pFont->GetFaceName());
1761 __pEdit->SetFont(*pFont);
1766 _SearchBar::OnFontInfoRequested(unsigned long& style, int& size)
1768 style = FONT_STYLE_PLAIN;
1769 size = __pCancelButton->GetTextSize();
1775 _SearchBar::OnFocusGained(const _Control& source)
1779 __isKeyPressed = false;
1780 _Control::OnDrawFocus();
1785 if (GetVisibleState() == true)
1787 __pEdit->SetFocused();
1794 _SearchBar::OnFocusLost(const _Control &source)
1796 __pEdit->SetSearchFieldFocus(false);
1797 _Control::OnFocusLost(source);
1802 _SearchBar::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1804 _KeyCode keyCode = keyInfo.GetKeyCode();
1806 if (!__pEdit->IsSearchFieldFocused())
1814 SetFocusCallbackParameter(false);
1815 if (&source == __pEdit)
1817 if ((!__isButtonEnabled || !__isUsableCancelButton) && __pContentControl && __pContentControl->GetEnableState())
1819 __pContentControl->SetFocused();
1820 __pContentControl->OnDrawFocus();
1825 __pCancelButton->SetFocused();
1830 if (&source == __pCancelButton && __pContentControl && __pContentControl->GetVisibleState() && __pContentControl->GetEnableState())
1832 __pContentControl->SetFocused();
1833 __pContentControl->OnDrawFocus();
1841 if (&source == __pCancelButton)
1843 __pEdit->SetFocused();
1847 if (&source == __pContentControl)
1849 if ((__isButtonEnabled && __isUsableCancelButton))
1851 __pCancelButton->SetFocused();
1855 __pEdit->SetFocused();
1863 if (&source == __pCancelButton)
1865 SetMode(SEARCH_BAR_MODE_NORMAL);
1866 __isKeyPressed = true;
1868 _Control::OnDrawFocus();
1883 _SearchBar::OnSettingChanged(Tizen::Base::String& key)
1885 if (__isButtonTextChangedByApp || !__isUsableCancelButton)
1890 if (key.Equals(L"http://tizen.org/setting/locale.language", false))
1893 GET_STRING_CONFIG(IDS_COM_SK_CANCEL, cancelText);
1894 __pCancelButton->SetText(cancelText);
1895 __pCancelButton->Invalidate();
1902 _SearchBar::GetParentForm(void) const
1904 _Form* pForm = null;
1905 _Control* pControlCore = GetParent();
1909 if (pControlCore == null)
1911 SysLog(NID_UI_CTRL,"[E_SYSTEM] The parent form is null.");
1916 pForm = dynamic_cast <_Form*>(pControlCore);
1923 pControlCore = pControlCore->GetParent();
1926 return pControlCore;
1930 _SearchBar::GetSearchBarButton(void) const
1932 return __pCancelButton;
1936 _SearchBar::GetSearchField(void)
1942 _SearchBar::GetSearchBarContainer(void) const
1944 return __pContainer;
1948 _SearchBar::GetClippedGroupControl(void) const
1950 return __pClippedGroupControl;
1954 _SearchBar::IsUsableCancelButton(void) const
1956 return __isUsableCancelButton;
1960 _SearchBar::ConvertSearchBarStatus(SearchFieldStatus status)
1962 EditStatus editStatus = EDIT_STATUS_NORMAL;
1965 case SEARCH_FIELD_STATUS_NORMAL:
1966 editStatus = EDIT_STATUS_NORMAL;
1969 case SEARCH_FIELD_STATUS_DISABLED:
1970 editStatus = EDIT_STATUS_DISABLED;
1973 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1974 editStatus = EDIT_STATUS_HIGHLIGHTED;
1984 _SearchBar::ConvertSearchBarButtonStatus(SearchBarButtonStatus status)
1986 _ButtonStatus buttonStatus = _BUTTON_STATUS_NORMAL;
1990 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
1991 buttonStatus = _BUTTON_STATUS_NORMAL;
1994 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
1995 buttonStatus = _BUTTON_STATUS_PRESSED;
1998 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
1999 buttonStatus = _BUTTON_STATUS_HIGHLIGHTED;
2002 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
2003 buttonStatus = _BUTTON_STATUS_DISABLED;
2009 return buttonStatus;
2013 _SearchBar::SendSearchBarEvent(_SearchBarEventStatus status)
2015 result r = E_SUCCESS;
2016 if (__pSearchBarEvent)
2018 IEventArg* pEventArg = _SearchBarEvent::CreateSearchBarEventArgN(status);
2019 r = GetLastResult();
2020 SysTryReturn(NID_UI_CTRL, pEventArg, r, r, "[%s] Propagating.", GetErrorMessage(r));
2022 if (IsContentAreaVisible() == false)
2024 SetContentAreaVisible(false);
2027 __pSearchBarEvent->Fire(*pEventArg);
2034 _SearchBar::SetHeaderVisibleState(bool visible)
2036 if (__pSearchBarPresenter != null)
2038 __pSearchBarPresenter->SetHeaderVisibleState(visible);
2044 _SearchBar::SetPropertyButtonActionId(const Variant& actionId)
2046 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2047 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2048 SysTryReturn(NID_UI_CTRL, actionId.ToInt() > -1, E_INVALID_ARG, E_INVALID_ARG,
2049 "[E_INVALID_ARG] Invalid argument(s) is used. actionId.ToInt() = %d", actionId.ToInt());
2051 result r = E_SUCCESS;
2053 r = __pCancelButton->SetPropertyActionId(actionId);
2054 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2055 "[%s] A system error has occurred. Failed to set actionId.", GetErrorMessage(E_SYSTEM));
2057 __actionId = actionId.ToInt();
2063 _SearchBar::GetPropertyButtonActionId(void) const
2065 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(-1), E_SYSTEM,
2066 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2068 return Variant(__actionId);
2072 _SearchBar::SetPropertyButtonDisabledColor(const Variant& color)
2074 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2075 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2077 result r = E_SUCCESS;
2079 r = __pCancelButton->SetPropertyDisabledColor(color);
2080 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2081 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2083 __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = color.ToColor();
2089 _SearchBar::GetPropertyButtonDisabledColor(void) const
2091 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2092 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2094 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2098 _SearchBar::SetPropertyButtonHighlightedColor(const Variant& color)
2100 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2101 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2103 result r = E_SUCCESS;
2105 r = __pCancelButton->SetPropertyHighlightedColor(color);
2106 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2107 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2109 __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
2115 _SearchBar::GetPropertyButtonHighlightedColor(void) const
2117 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2118 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2120 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2124 _SearchBar::SetPropertyButtonNormalColor(const Variant& color)
2126 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2127 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2129 result r = E_SUCCESS;
2131 r = __pCancelButton->SetPropertyNormalColor(color);
2132 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2133 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2135 __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = color.ToColor();
2141 _SearchBar::GetPropertyButtonNormalColor(void) const
2143 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2144 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2146 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2150 _SearchBar::SetPropertyButtonPressedColor(const Variant& color)
2152 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2153 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2155 result r = E_SUCCESS;
2157 r = __pCancelButton->SetPropertyPressedColor(color);
2158 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2159 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2161 __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = color.ToColor();
2167 _SearchBar::GetPropertyButtonPressedColor(void) const
2169 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2170 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2172 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2176 _SearchBar::SetPropertyButtonDisabledTextColor(const Variant& textColor)
2178 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2179 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2181 result r = E_SUCCESS;
2183 r = __pCancelButton->SetPropertyDisabledTextColor(textColor);
2184 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2185 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2187 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = textColor.ToColor();
2193 _SearchBar::GetPropertyButtonDisabledTextColor(void) const
2195 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2196 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2198 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2202 _SearchBar::SetPropertyButtonHighlightedTextColor(const Variant& textColor)
2204 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2205 "[E_SYSTEM]] A system error has occurred. The cancel button instance is null.");
2207 result r = E_SUCCESS;
2209 r = __pCancelButton->SetPropertyHighlightedTextColor(textColor);
2210 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2211 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2213 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = textColor.ToColor();
2219 _SearchBar::GetPropertyButtonHighlightedTextColor(void) const
2221 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2222 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2224 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2228 _SearchBar::SetPropertyButtonNormalTextColor(const Variant& textColor)
2230 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2231 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2233 result r = E_SUCCESS;
2235 r = __pCancelButton->SetPropertyNormalTextColor(textColor);
2236 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2237 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2239 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = textColor.ToColor();
2245 _SearchBar::GetPropertyButtonNormalTextColor(void) const
2247 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2248 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2250 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2254 _SearchBar::SetPropertyButtonPressedTextColor(const Variant& textColor)
2256 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2257 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2259 result r = E_SUCCESS;
2261 r = __pCancelButton->SetPropertyPressedTextColor(textColor);
2262 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2263 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2265 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = textColor.ToColor();
2271 _SearchBar::GetPropertyButtonPressedTextColor(void) const
2273 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2274 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2276 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2280 _SearchBar::SetPropertySearchFieldDisabledColor(const Variant& color)
2282 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2283 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2285 result r = E_SUCCESS;
2287 r = __pEdit->SetPropertyDisabledColor(color);
2288 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2289 "[E_SYSTEM] A system error has occurred. Failed to set the edit disabled color.");
2291 __color[SEARCH_FIELD_STATUS_DISABLED] = color.ToColor();
2297 _SearchBar::GetPropertySearchFieldDisabledColor(void) const
2299 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2300 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2302 return Variant(__color[SEARCH_FIELD_STATUS_DISABLED]);
2306 _SearchBar::SetPropertySearchFieldHighlightedColor(const Variant& color)
2308 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2309 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2311 result r = E_SUCCESS;
2313 r = __pEdit->SetPropertyHighlightedColor(color);
2314 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2315 "[E_SYSTEM] A system error has occurred. Failed to set the edit highlighted color.");
2317 __color[SEARCH_FIELD_STATUS_HIGHLIGHTED] = color.ToColor();
2323 _SearchBar::GetPropertySearchFieldHighlightedColor(void) const
2325 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2326 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2328 return Variant(__color[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2332 _SearchBar::SetPropertySearchFieldNormalColor(const Variant& color)
2334 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2335 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2337 result r = E_SUCCESS;
2339 r = __pEdit->SetPropertyNormalColor(color);
2340 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2341 "[E_SYSTEM] A system error has occurred. Failed to set edit normal color.");
2343 __color[SEARCH_FIELD_STATUS_NORMAL] = color.ToColor();
2349 _SearchBar::GetPropertySearchFieldNormalColor(void) const
2351 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2352 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2354 return Variant(__color[SEARCH_FIELD_STATUS_NORMAL]);
2358 _SearchBar::SetPropertySearchFieldDisabledTextColor(const Variant& textColor)
2360 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2361 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2363 result r = E_SUCCESS;
2365 r = __pEdit->SetPropertyDisabledTextColor(textColor);
2366 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2367 "[E_SYSTEM] A system error has occurred. Failed to set edit disabled text color.");
2369 __textColor[SEARCH_FIELD_STATUS_DISABLED] = textColor.ToColor();
2375 _SearchBar::GetPropertySearchFieldDisabledTextColor(void) const
2377 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2378 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2380 return Variant(__textColor[SEARCH_FIELD_STATUS_DISABLED]);
2384 _SearchBar::SetPropertySearchFieldHighlightedTextColor(const Variant& textColor)
2386 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2387 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2389 result r = E_SUCCESS;
2391 r = __pEdit->SetPropertyHighlightedTextColor(textColor);
2392 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2393 "[E_SYSTEM] A system error has occurred. Failed to set edit highlighted text color.");
2395 __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED] = textColor.ToColor();
2401 _SearchBar::GetPropertySearchFieldHighlightedTextColor(void) const
2403 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2404 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2406 return Variant(__textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2410 _SearchBar::SetPropertySearchFieldNormalTextColor(const Variant& textColor)
2412 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2413 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2415 result r = E_SUCCESS;
2417 r = __pEdit->SetPropertyNormalTextColor(textColor);
2418 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2419 "[E_SYSTEM] A system error has occurred. Failed to set edit normal text color.");
2421 __textColor[SEARCH_FIELD_STATUS_NORMAL] = textColor.ToColor();
2427 _SearchBar::GetPropertySearchFieldNormalTextColor(void) const
2429 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2430 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2432 return Variant(__textColor[SEARCH_FIELD_STATUS_NORMAL]);
2436 _SearchBar::SetPropertyColor(const Variant& color)
2438 __backgroundColor = color.ToColor();
2444 _SearchBar::GetPropertyColor(void) const
2446 return Variant(__backgroundColor);
2450 _SearchBar::SetPropertyContentAreaSize(const Variant& size)
2452 FloatDimension contentAreaSize = size.ToFloatDimension();
2453 SysTryReturn(NID_UI_CTRL, contentAreaSize.width >= 0 && contentAreaSize.height >= 0, E_INVALID_ARG, E_INVALID_ARG,
2454 "[E_INVALID_ARG] Invalid argument(s) is used. contentAreaSize.width = %f, contenAreaSize.height = %f",
2455 contentAreaSize.width, contentAreaSize.height);
2457 result r = E_SUCCESS;
2460 FloatRectangle bounds = GetBoundsF();
2461 FloatRectangle contentAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
2463 contentAreaBounds.x = 0.0f;
2464 contentAreaBounds.y = bounds.height;
2465 contentAreaBounds.width = contentAreaSize.width;
2466 contentAreaBounds.height = contentAreaSize.height;
2468 __contentAreaBounds = contentAreaBounds;
2469 __isUserContainerBounds = true;
2474 r = __pContainer->SetBounds(__contentAreaBounds);
2475 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2482 _SearchBar::GetPropertyContentAreaSize(void) const
2484 FloatDimension contentAreaSize(__contentAreaBounds.width, __contentAreaBounds.height);
2486 return Variant(contentAreaSize);
2490 _SearchBar::CreateClippedGroupControl(void)
2492 result r = E_SUCCESS;
2493 FloatRectangle clippedGroupControlBounds(FloatPoint(0.0f, 0.0f), GetSizeF());
2494 __pClippedGroupControl = _Control::CreateControlN();
2495 r = GetLastResult();
2496 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2498 r = AttachChild(*__pClippedGroupControl);
2499 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
2500 "[E_SYSTEM] A system error has occurred. Failed to attach the parent of clipped control.");
2502 r = __pClippedGroupControl->SetBounds(clippedGroupControlBounds);
2503 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2505 __pClippedGroupControl->SetBackgroundColor(Color(0));
2507 __pClippedGroupControl->SetClipChildrenEnabled(true);
2512 delete __pClippedGroupControl;
2513 __pClippedGroupControl = null;
2520 _SearchBar::CreateAccessibilityElement(void)
2522 if (__pAccessibilitySearchBarElement != null)
2526 _AccessibilityContainer* pContainer = null;
2527 pContainer = GetAccessibilityContainer();
2531 __pAccessibilitySearchBarElement = new (std::nothrow) _AccessibilityElement(true);
2532 SysTryReturnVoidResult(NID_UI_CTRL, __pAccessibilitySearchBarElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
2533 __pAccessibilitySearchBarElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height));
2534 __pAccessibilitySearchBarElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
2535 __pAccessibilitySearchBarElement->SetName("SearchBar");
2536 pContainer->AddElement(*__pAccessibilitySearchBarElement);
2543 _SearchBar::SetContentDimming(void)
2545 if (__pContainer != NULL)
2547 if (!GetTextLength())
2549 __contentColor.SetAlpha(_SEARCH_CONTENT_DIM_OPACITY);
2553 __contentColor.SetAlpha(0);
2555 __pContainer->SetBackgroundColor(__contentColor);
2561 _SearchBar::OnDrawFocus(void)
2563 __pEdit->SetSearchFieldFocus(true);
2568 _SearchBar::IsContentAttachable(const _Control* pContent)
2570 const _Window* pWindow = dynamic_cast <const _Window*>(pContent);
2571 const _ColorPicker* pColorPicker = dynamic_cast <const _ColorPicker*>(pContent);
2572 const _Form* pForm = dynamic_cast <const _Form*>(pContent);
2573 const _Keypad* pKeypad = dynamic_cast <const _Keypad*>(pContent);
2574 const _OverlayPanel* pOverlayPanel = dynamic_cast <const _OverlayPanel*>(pContent);
2576 bool isContentAttachable = true;
2578 isContentAttachable = ((pWindow == null) && (pColorPicker == null) &&
2579 (pForm == null) && (pKeypad == null) && (pOverlayPanel == null));
2580 return isContentAttachable;
2584 _SearchBar::ResizeCancelButton(void)
2586 result r = E_SUCCESS;
2588 float horizontalMargin = 0.0f;
2589 float buttonLeftMargin = 0.0f;
2590 float buttonRightMargin = 0.0f;
2591 float buttonMinWidth = 0.0f;
2592 float searchFieldMinWidth = 0.0f;
2593 float buttonVerticalMargin = 0.0f;
2594 float searchBarMinHeight = 0.0f;
2595 float buttonWidth = 0.0f;
2596 float buttonHeight = 0.0f;
2598 FloatRectangle cancelButtonBounds;
2599 FloatRectangle searchBarBounds = GetBoundsF();
2601 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2603 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2604 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2605 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2606 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2607 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2608 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2609 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2610 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2611 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2613 cancelButtonBounds.width = buttonWidth;
2614 cancelButtonBounds.height = buttonHeight;
2616 float buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth +
2617 cancelButtonBounds.width + buttonLeftMargin + buttonRightMargin);
2619 if (searchBarBounds.width < buttonResizableSearchBarWidth)
2621 cancelButtonBounds.width = searchBarBounds.width -(searchFieldMinWidth + buttonLeftMargin
2622 + buttonRightMargin + horizontalMargin);
2625 cancelButtonBounds.x = searchBarBounds.width - cancelButtonBounds.width - buttonRightMargin;
2626 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2628 cancelButtonBounds.y = cancelButtonBounds.y < 0.0f ? 0.0f:cancelButtonBounds.y;
2630 if (cancelButtonBounds.width < buttonMinWidth)
2632 cancelButtonBounds.width = buttonMinWidth;
2635 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2636 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2637 r = __pCancelButton->SetBounds(cancelButtonBounds);
2643 _SearchBar::RecalculateButtonBounds(void)
2645 result r = E_SUCCESS;
2647 float horizontalMargin = 0.0f;
2648 float verticalMargin = 0.0f;
2649 float buttonLeftMargin = 0.0f;
2650 float buttonRightMargin = 0.0f;
2651 float buttonMinWidth = 0.0f;
2652 float searchFieldMinWidth = 0.0f;
2653 float buttonVerticalMargin = 0.0f;
2654 float searchBarMinHeight = 0.0f;
2655 float buttonWidth = 0.0f;
2656 float buttonHeight = 0.0f;
2657 float cancelButtonWidth = 0.0f;
2659 FloatRectangle cancelButtonBounds;
2660 FloatRectangle editBounds;
2661 FloatRectangle searchBarBounds = GetBoundsF();
2663 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2665 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2666 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin);
2667 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2668 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2669 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2670 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2671 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2672 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2673 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2674 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2676 cancelButtonBounds.height = buttonHeight;
2678 float searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2.0f);
2679 cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightTouchMarginF() + __pCancelButton->GetLeftTouchMarginF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF();
2680 editBounds.x = horizontalMargin;
2682 if (searchBarBounds.height < searchBarMinHeight)
2684 verticalMargin = (searchBarBounds.height - searchFieldMinHeight)/2.0f;
2685 if (verticalMargin < 0.0f)
2687 verticalMargin = 0.0f;
2691 editBounds.y = verticalMargin;
2692 editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
2694 editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
2696 editBounds.width = searchBarBounds.width - cancelButtonWidth - horizontalMargin - buttonLeftMargin - buttonRightMargin;
2698 if (editBounds.width < searchFieldMinWidth)
2700 editBounds.width = searchFieldMinWidth;
2703 cancelButtonBounds.x = editBounds.width + horizontalMargin + buttonLeftMargin;
2704 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2706 cancelButtonBounds.y = cancelButtonBounds.y < 0.0f ? 0.0f:cancelButtonBounds.y;
2708 float remainingWidth = searchBarBounds.width - editBounds.width - horizontalMargin - buttonLeftMargin - buttonRightMargin;
2710 if (remainingWidth < buttonMinWidth)
2712 cancelButtonBounds.width = buttonMinWidth;
2716 cancelButtonBounds.width = searchBarBounds.width - cancelButtonBounds.x - buttonRightMargin;
2719 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2720 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2722 r = __pCancelButton->SetBounds(cancelButtonBounds);
2723 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2724 r = __pEdit->SetBounds(editBounds);
2725 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2731 _SearchBar::GetCurrentStatus(void)
2733 SearchFieldStatus searchFieldStatus = SEARCH_FIELD_STATUS_NORMAL;
2737 if (__pEdit->IsFocused())
2739 searchFieldStatus = SEARCH_FIELD_STATUS_HIGHLIGHTED;
2744 searchFieldStatus = SEARCH_FIELD_STATUS_DISABLED;
2747 return searchFieldStatus;
2751 _SearchBar::SetEditTextFilter(IEditTextFilter* pFilter)
2753 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2754 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2756 __pEdit->SetEditTextFilter(pFilter);
2762 _SearchBar::SendOpaqueCommand(const String& command)
2764 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2765 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2767 __pEdit->SendOpaqueCommand(command);
2773 _SearchBar::SetFocusCallbackParameter(bool state)
2775 __isFocusCallbackToBeFired = state;
2780 _SearchBar::IsFocusCallbackToBeFired(void) const
2782 return __isFocusCallbackToBeFired;
2784 }}} // Tizen::Ui::Controls