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 (keyCode == _KEY_RIGHT)
1808 if (GetMode() == SEARCH_BAR_MODE_NORMAL)
1810 __pEdit->SetFocused();
1814 if (!__isButtonEnabled || __pCancelButton->IsFocused() || !__isUsableCancelButton)
1819 SetFocusCallBackParameter(false);
1820 __pCancelButton->SetFocused();
1821 __pCancelButton->Invalidate(true);
1826 if (keyCode == _KEY_LEFT)
1828 if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_HIGHLIGHTED)
1830 __pCancelButton->Invalidate();
1831 __pEdit->SetFocused();
1834 if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_DISABLED) //Searchbar Button is disabled, left arrow key is pressed
1836 __pEdit->SetFocused();
1842 if (keyCode == _KEY_ENTER || keyCode == _KEY_TAB)
1844 if (GetMode() == SEARCH_BAR_MODE_NORMAL)
1849 SetMode(SEARCH_BAR_MODE_NORMAL);
1850 __isKeyPressed = true;
1860 _SearchBar::OnSettingChanged(Tizen::Base::String& key)
1862 if (__isButtonTextChangedByApp || !__isUsableCancelButton)
1867 if (key.Equals(L"http://tizen.org/setting/locale.language", false))
1870 GET_STRING_CONFIG(IDS_COM_SK_CANCEL, cancelText);
1871 __pCancelButton->SetText(cancelText);
1872 __pCancelButton->Invalidate();
1879 _SearchBar::GetParentForm(void) const
1881 _Form* pForm = null;
1882 _Control* pControlCore = GetParent();
1886 if (pControlCore == null)
1888 SysLog(NID_UI_CTRL,"[E_SYSTEM] The parent form is null.");
1893 pForm = dynamic_cast <_Form*>(pControlCore);
1900 pControlCore = pControlCore->GetParent();
1903 return pControlCore;
1907 _SearchBar::GetSearchBarButton(void) const
1909 return __pCancelButton;
1913 _SearchBar::GetSearchField(void)
1919 _SearchBar::GetSearchBarContainer(void) const
1921 return __pContainer;
1925 _SearchBar::GetClippedGroupControl(void) const
1927 return __pClippedGroupControl;
1931 _SearchBar::IsUsableCancelButton(void) const
1933 return __isUsableCancelButton;
1937 _SearchBar::ConvertSearchBarStatus(SearchFieldStatus status)
1939 EditStatus editStatus = EDIT_STATUS_NORMAL;
1942 case SEARCH_FIELD_STATUS_NORMAL:
1943 editStatus = EDIT_STATUS_NORMAL;
1946 case SEARCH_FIELD_STATUS_DISABLED:
1947 editStatus = EDIT_STATUS_DISABLED;
1950 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1951 editStatus = EDIT_STATUS_HIGHLIGHTED;
1961 _SearchBar::ConvertSearchBarButtonStatus(SearchBarButtonStatus status)
1963 _ButtonStatus buttonStatus = _BUTTON_STATUS_NORMAL;
1967 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
1968 buttonStatus = _BUTTON_STATUS_NORMAL;
1971 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
1972 buttonStatus = _BUTTON_STATUS_PRESSED;
1975 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
1976 buttonStatus = _BUTTON_STATUS_HIGHLIGHTED;
1979 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
1980 buttonStatus = _BUTTON_STATUS_DISABLED;
1986 return buttonStatus;
1990 _SearchBar::SendSearchBarEvent(_SearchBarEventStatus status)
1992 result r = E_SUCCESS;
1993 if (__pSearchBarEvent)
1995 IEventArg* pEventArg = _SearchBarEvent::CreateSearchBarEventArgN(status);
1996 r = GetLastResult();
1997 SysTryReturn(NID_UI_CTRL, pEventArg, r, r, "[%s] Propagating.", GetErrorMessage(r));
1999 if (IsContentAreaVisible() == false)
2001 SetContentAreaVisible(false);
2004 __pSearchBarEvent->Fire(*pEventArg);
2011 _SearchBar::SetHeaderVisibleState(bool visible)
2013 if (__pSearchBarPresenter != null)
2015 __pSearchBarPresenter->SetHeaderVisibleState(visible);
2021 _SearchBar::SetPropertyButtonActionId(const Variant& actionId)
2023 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2024 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2025 SysTryReturn(NID_UI_CTRL, actionId.ToInt() > -1, E_INVALID_ARG, E_INVALID_ARG,
2026 "[E_INVALID_ARG] Invalid argument(s) is used. actionId.ToInt() = %d", actionId.ToInt());
2028 result r = E_SUCCESS;
2030 r = __pCancelButton->SetPropertyActionId(actionId);
2031 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2032 "[%s] A system error has occurred. Failed to set actionId.", GetErrorMessage(E_SYSTEM));
2034 __actionId = actionId.ToInt();
2040 _SearchBar::GetPropertyButtonActionId(void) const
2042 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(-1), E_SYSTEM,
2043 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2045 return Variant(__actionId);
2049 _SearchBar::SetPropertyButtonDisabledColor(const Variant& color)
2051 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2052 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2054 result r = E_SUCCESS;
2056 r = __pCancelButton->SetPropertyDisabledColor(color);
2057 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2058 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2060 __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = color.ToColor();
2066 _SearchBar::GetPropertyButtonDisabledColor(void) const
2068 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2069 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2071 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2075 _SearchBar::SetPropertyButtonHighlightedColor(const Variant& color)
2077 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2078 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2080 result r = E_SUCCESS;
2082 r = __pCancelButton->SetPropertyHighlightedColor(color);
2083 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2084 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2086 __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
2092 _SearchBar::GetPropertyButtonHighlightedColor(void) const
2094 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2095 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2097 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2101 _SearchBar::SetPropertyButtonNormalColor(const Variant& color)
2103 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2104 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2106 result r = E_SUCCESS;
2108 r = __pCancelButton->SetPropertyNormalColor(color);
2109 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2110 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2112 __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = color.ToColor();
2118 _SearchBar::GetPropertyButtonNormalColor(void) const
2120 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2121 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2123 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2127 _SearchBar::SetPropertyButtonPressedColor(const Variant& color)
2129 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2130 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2132 result r = E_SUCCESS;
2134 r = __pCancelButton->SetPropertyPressedColor(color);
2135 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2136 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2138 __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = color.ToColor();
2144 _SearchBar::GetPropertyButtonPressedColor(void) const
2146 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2147 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2149 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2153 _SearchBar::SetPropertyButtonDisabledTextColor(const Variant& textColor)
2155 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2156 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2158 result r = E_SUCCESS;
2160 r = __pCancelButton->SetPropertyDisabledTextColor(textColor);
2161 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2162 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2164 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = textColor.ToColor();
2170 _SearchBar::GetPropertyButtonDisabledTextColor(void) const
2172 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2173 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2175 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2179 _SearchBar::SetPropertyButtonHighlightedTextColor(const Variant& textColor)
2181 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2182 "[E_SYSTEM]] A system error has occurred. The cancel button instance is null.");
2184 result r = E_SUCCESS;
2186 r = __pCancelButton->SetPropertyHighlightedTextColor(textColor);
2187 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2188 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2190 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = textColor.ToColor();
2196 _SearchBar::GetPropertyButtonHighlightedTextColor(void) const
2198 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2199 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2201 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2205 _SearchBar::SetPropertyButtonNormalTextColor(const Variant& textColor)
2207 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2208 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2210 result r = E_SUCCESS;
2212 r = __pCancelButton->SetPropertyNormalTextColor(textColor);
2213 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2214 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2216 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = textColor.ToColor();
2222 _SearchBar::GetPropertyButtonNormalTextColor(void) const
2224 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2225 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2227 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2231 _SearchBar::SetPropertyButtonPressedTextColor(const Variant& textColor)
2233 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2234 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2236 result r = E_SUCCESS;
2238 r = __pCancelButton->SetPropertyPressedTextColor(textColor);
2239 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2240 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2242 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = textColor.ToColor();
2248 _SearchBar::GetPropertyButtonPressedTextColor(void) const
2250 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2251 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2253 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2257 _SearchBar::SetPropertySearchFieldDisabledColor(const Variant& color)
2259 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2260 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2262 result r = E_SUCCESS;
2264 r = __pEdit->SetPropertyDisabledColor(color);
2265 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2266 "[E_SYSTEM] A system error has occurred. Failed to set the edit disabled color.");
2268 __color[SEARCH_FIELD_STATUS_DISABLED] = color.ToColor();
2274 _SearchBar::GetPropertySearchFieldDisabledColor(void) const
2276 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2277 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2279 return Variant(__color[SEARCH_FIELD_STATUS_DISABLED]);
2283 _SearchBar::SetPropertySearchFieldHighlightedColor(const Variant& color)
2285 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2286 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2288 result r = E_SUCCESS;
2290 r = __pEdit->SetPropertyHighlightedColor(color);
2291 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2292 "[E_SYSTEM] A system error has occurred. Failed to set the edit highlighted color.");
2294 __color[SEARCH_FIELD_STATUS_HIGHLIGHTED] = color.ToColor();
2300 _SearchBar::GetPropertySearchFieldHighlightedColor(void) const
2302 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2303 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2305 return Variant(__color[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2309 _SearchBar::SetPropertySearchFieldNormalColor(const Variant& color)
2311 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2312 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2314 result r = E_SUCCESS;
2316 r = __pEdit->SetPropertyNormalColor(color);
2317 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2318 "[E_SYSTEM] A system error has occurred. Failed to set edit normal color.");
2320 __color[SEARCH_FIELD_STATUS_NORMAL] = color.ToColor();
2326 _SearchBar::GetPropertySearchFieldNormalColor(void) const
2328 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2329 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2331 return Variant(__color[SEARCH_FIELD_STATUS_NORMAL]);
2335 _SearchBar::SetPropertySearchFieldDisabledTextColor(const Variant& textColor)
2337 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2338 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2340 result r = E_SUCCESS;
2342 r = __pEdit->SetPropertyDisabledTextColor(textColor);
2343 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2344 "[E_SYSTEM] A system error has occurred. Failed to set edit disabled text color.");
2346 __textColor[SEARCH_FIELD_STATUS_DISABLED] = textColor.ToColor();
2352 _SearchBar::GetPropertySearchFieldDisabledTextColor(void) const
2354 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2355 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2357 return Variant(__textColor[SEARCH_FIELD_STATUS_DISABLED]);
2361 _SearchBar::SetPropertySearchFieldHighlightedTextColor(const Variant& textColor)
2363 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2364 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2366 result r = E_SUCCESS;
2368 r = __pEdit->SetPropertyHighlightedTextColor(textColor);
2369 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2370 "[E_SYSTEM] A system error has occurred. Failed to set edit highlighted text color.");
2372 __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED] = textColor.ToColor();
2378 _SearchBar::GetPropertySearchFieldHighlightedTextColor(void) const
2380 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2381 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2383 return Variant(__textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2387 _SearchBar::SetPropertySearchFieldNormalTextColor(const Variant& textColor)
2389 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2390 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2392 result r = E_SUCCESS;
2394 r = __pEdit->SetPropertyNormalTextColor(textColor);
2395 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2396 "[E_SYSTEM] A system error has occurred. Failed to set edit normal text color.");
2398 __textColor[SEARCH_FIELD_STATUS_NORMAL] = textColor.ToColor();
2404 _SearchBar::GetPropertySearchFieldNormalTextColor(void) const
2406 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2407 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2409 return Variant(__textColor[SEARCH_FIELD_STATUS_NORMAL]);
2413 _SearchBar::SetPropertyColor(const Variant& color)
2415 __backgroundColor = color.ToColor();
2421 _SearchBar::GetPropertyColor(void) const
2423 return Variant(__backgroundColor);
2427 _SearchBar::SetPropertyContentAreaSize(const Variant& size)
2429 FloatDimension contentAreaSize = size.ToFloatDimension();
2430 SysTryReturn(NID_UI_CTRL, contentAreaSize.width >= 0 && contentAreaSize.height >= 0, E_INVALID_ARG, E_INVALID_ARG,
2431 "[E_INVALID_ARG] Invalid argument(s) is used. contentAreaSize.width = %f, contenAreaSize.height = %f",
2432 contentAreaSize.width, contentAreaSize.height);
2434 result r = E_SUCCESS;
2437 FloatRectangle bounds = GetBoundsF();
2438 FloatRectangle contentAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
2440 contentAreaBounds.x = 0.0f;
2441 contentAreaBounds.y = bounds.height;
2442 contentAreaBounds.width = contentAreaSize.width;
2443 contentAreaBounds.height = contentAreaSize.height;
2445 __contentAreaBounds = contentAreaBounds;
2446 __isUserContainerBounds = true;
2451 r = __pContainer->SetBounds(__contentAreaBounds);
2452 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2459 _SearchBar::GetPropertyContentAreaSize(void) const
2461 FloatDimension contentAreaSize(__contentAreaBounds.width, __contentAreaBounds.height);
2463 return Variant(contentAreaSize);
2467 _SearchBar::CreateClippedGroupControl(void)
2469 result r = E_SUCCESS;
2470 FloatRectangle clippedGroupControlBounds(FloatPoint(0.0f, 0.0f), GetSizeF());
2471 __pClippedGroupControl = _Control::CreateControlN();
2472 r = GetLastResult();
2473 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2475 r = AttachChild(*__pClippedGroupControl);
2476 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
2477 "[E_SYSTEM] A system error has occurred. Failed to attach the parent of clipped control.");
2479 r = __pClippedGroupControl->SetBounds(clippedGroupControlBounds);
2480 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2482 __pClippedGroupControl->SetBackgroundColor(Color(0));
2484 __pClippedGroupControl->SetClipChildrenEnabled(true);
2489 delete __pClippedGroupControl;
2490 __pClippedGroupControl = null;
2497 _SearchBar::CreateAccessibilityElement(void)
2499 if (__pAccessibilitySearchBarElement != null)
2503 _AccessibilityContainer* pContainer = null;
2504 pContainer = GetAccessibilityContainer();
2508 __pAccessibilitySearchBarElement = new (std::nothrow) _AccessibilityElement(true);
2509 SysTryReturnVoidResult(NID_UI_CTRL, __pAccessibilitySearchBarElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
2510 __pAccessibilitySearchBarElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height));
2511 __pAccessibilitySearchBarElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
2512 __pAccessibilitySearchBarElement->SetName("SearchBar");
2513 pContainer->AddElement(*__pAccessibilitySearchBarElement);
2520 _SearchBar::SetContentDimming(void)
2522 if (__pContainer != NULL)
2524 if (!GetTextLength())
2526 __contentColor.SetAlpha(_SEARCH_CONTENT_DIM_OPACITY);
2530 __contentColor.SetAlpha(0);
2532 __pContainer->SetBackgroundColor(__contentColor);
2538 _SearchBar::OnDrawFocus(void)
2540 __pEdit->SetSearchFieldFocus(true);
2545 _SearchBar::IsContentAttachable(const _Control* pContent)
2547 const _Window* pWindow = dynamic_cast <const _Window*>(pContent);
2548 const _ColorPicker* pColorPicker = dynamic_cast <const _ColorPicker*>(pContent);
2549 const _Form* pForm = dynamic_cast <const _Form*>(pContent);
2550 const _Keypad* pKeypad = dynamic_cast <const _Keypad*>(pContent);
2551 const _OverlayPanel* pOverlayPanel = dynamic_cast <const _OverlayPanel*>(pContent);
2553 bool isContentAttachable = true;
2555 isContentAttachable = ((pWindow == null) && (pColorPicker == null) &&
2556 (pForm == null) && (pKeypad == null) && (pOverlayPanel == null));
2557 return isContentAttachable;
2561 _SearchBar::ResizeCancelButton(void)
2563 result r = E_SUCCESS;
2565 float horizontalMargin = 0.0f;
2566 float buttonLeftMargin = 0.0f;
2567 float buttonRightMargin = 0.0f;
2568 float buttonMinWidth = 0.0f;
2569 float searchFieldMinWidth = 0.0f;
2570 float buttonVerticalMargin = 0.0f;
2571 float searchBarMinHeight = 0.0f;
2572 float buttonWidth = 0.0f;
2573 float buttonHeight = 0.0f;
2575 FloatRectangle cancelButtonBounds;
2576 FloatRectangle searchBarBounds = GetBoundsF();
2578 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2580 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2581 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2582 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2583 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2584 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2585 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2586 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2587 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2588 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2590 cancelButtonBounds.width = buttonWidth;
2591 cancelButtonBounds.height = buttonHeight;
2593 float buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth +
2594 cancelButtonBounds.width + buttonLeftMargin + buttonRightMargin);
2596 if (searchBarBounds.width < buttonResizableSearchBarWidth)
2598 cancelButtonBounds.width = searchBarBounds.width -(searchFieldMinWidth + buttonLeftMargin
2599 + buttonRightMargin + horizontalMargin);
2602 cancelButtonBounds.x = searchBarBounds.width - cancelButtonBounds.width - buttonRightMargin;
2603 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2605 cancelButtonBounds.y = cancelButtonBounds.y < 0.0f ? 0.0f:cancelButtonBounds.y;
2607 if (cancelButtonBounds.width < buttonMinWidth)
2609 cancelButtonBounds.width = buttonMinWidth;
2612 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2613 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2614 r = __pCancelButton->SetBounds(cancelButtonBounds);
2620 _SearchBar::RecalculateButtonBounds(void)
2622 result r = E_SUCCESS;
2624 float horizontalMargin = 0.0f;
2625 float verticalMargin = 0.0f;
2626 float buttonLeftMargin = 0.0f;
2627 float buttonRightMargin = 0.0f;
2628 float buttonMinWidth = 0.0f;
2629 float searchFieldMinWidth = 0.0f;
2630 float buttonVerticalMargin = 0.0f;
2631 float searchBarMinHeight = 0.0f;
2632 float buttonWidth = 0.0f;
2633 float buttonHeight = 0.0f;
2634 float cancelButtonWidth = 0.0f;
2636 FloatRectangle cancelButtonBounds;
2637 FloatRectangle editBounds;
2638 FloatRectangle searchBarBounds = GetBoundsF();
2640 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2642 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2643 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin);
2644 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2645 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2646 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2647 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2648 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2649 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2650 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2651 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2653 cancelButtonBounds.height = buttonHeight;
2655 float searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2.0f);
2656 cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightTouchMarginF() + __pCancelButton->GetLeftTouchMarginF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF();
2657 editBounds.x = horizontalMargin;
2659 if (searchBarBounds.height < searchBarMinHeight)
2661 verticalMargin = (searchBarBounds.height - searchFieldMinHeight)/2.0f;
2662 if (verticalMargin < 0.0f)
2664 verticalMargin = 0.0f;
2668 editBounds.y = verticalMargin;
2669 editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
2671 editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
2673 editBounds.width = searchBarBounds.width - cancelButtonWidth - horizontalMargin - buttonLeftMargin - buttonRightMargin;
2675 if (editBounds.width < searchFieldMinWidth)
2677 editBounds.width = searchFieldMinWidth;
2680 cancelButtonBounds.x = editBounds.width + horizontalMargin + buttonLeftMargin;
2681 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2683 cancelButtonBounds.y = cancelButtonBounds.y < 0.0f ? 0.0f:cancelButtonBounds.y;
2685 float remainingWidth = searchBarBounds.width - editBounds.width - horizontalMargin - buttonLeftMargin - buttonRightMargin;
2687 if (remainingWidth < buttonMinWidth)
2689 cancelButtonBounds.width = buttonMinWidth;
2693 cancelButtonBounds.width = searchBarBounds.width - cancelButtonBounds.x - buttonRightMargin;
2696 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2697 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2699 r = __pCancelButton->SetBounds(cancelButtonBounds);
2700 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2701 r = __pEdit->SetBounds(editBounds);
2702 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2708 _SearchBar::GetCurrentStatus(void)
2710 SearchFieldStatus searchFieldStatus = SEARCH_FIELD_STATUS_NORMAL;
2714 if (__pEdit->IsFocused())
2716 searchFieldStatus = SEARCH_FIELD_STATUS_HIGHLIGHTED;
2721 searchFieldStatus = SEARCH_FIELD_STATUS_DISABLED;
2724 return searchFieldStatus;
2728 _SearchBar::SetEditTextFilter(IEditTextFilter* pFilter)
2730 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2731 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2733 __pEdit->SetEditTextFilter(pFilter);
2739 _SearchBar::SendOpaqueCommand(const String& command)
2741 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2742 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2744 __pEdit->SendOpaqueCommand(command);
2750 _SearchBar::SetFocusCallBackParameter(bool state)
2752 __isFocusCallbackToBeFired = state;
2757 _SearchBar::IsFocusCallBackToBeFired(void) const
2759 return __isFocusCallbackToBeFired;
2761 }}} // Tizen::Ui::Controls