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 __isButtonTextChangedByApp = true;
675 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
676 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
678 result r = E_SUCCESS;
680 r = __pCancelButton->SetText(text);
681 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
682 "[E_SYSTEM] A system error has occurred. Failed to set text.");
688 _SearchBar::SetButtonActionId(int actionId)
690 return SetProperty("buttonActionId", Variant(actionId));
694 _SearchBar::SetButtonEnabled(bool enabled)
696 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
697 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
699 __pCancelButton->SetEnableState(enabled);
701 __isButtonEnabled = enabled;
707 _SearchBar::SetButtonColor(SearchBarButtonStatus status, const Color& color)
709 result r = E_SUCCESS;
713 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
714 r = SetProperty("buttonNormalColor", Variant(color));
716 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
717 r = SetProperty("buttonPressedColor", Variant(color));
719 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
720 r = SetProperty("buttonHighlightedColor", Variant(color));
722 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
723 r = SetProperty("buttonDisabledColor", Variant(color));
733 _SearchBar::SetButtonTextColor(SearchBarButtonStatus status, const Color& color)
735 result r = E_SUCCESS;
739 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
740 r = SetProperty("buttonNormalTextColor", Variant(color));
742 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
743 r = SetProperty("buttonPressedTextColor", Variant(color));
745 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
746 r = SetProperty("buttonHighlightedTextColor", Variant(color));
748 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
749 r = SetProperty("buttonDisabledTextColor", Variant(color));
759 _SearchBar::AppendCharacter(const Character& character)
761 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
762 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
763 SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM,
764 "[E_SYSTEM] A system error has occurred. The character is null.");
766 result r = E_SUCCESS;
768 r = __pEdit->AppendCharacter(character);
769 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
770 "[E_SYSTEM] A system error has occurred. Failed to set character.");
776 _SearchBar::AppendText(const String& text)
778 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
779 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
780 SysTryReturn(NID_UI_CTRL, text.IsEmpty() == false, E_SYSTEM, E_SYSTEM,
781 "[E_SYSTEM] A system error has occurred. The text is empty.");
783 result r = E_SUCCESS;
785 r = __pEdit->AppendText(text);
786 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
787 "[E_SYSTEM] A system error has occurred. Failed to set text.");
793 _SearchBar::SetText(const String& text)
795 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
796 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
798 result r = E_SUCCESS;
800 int limitLength = __pEdit->GetTextLimitLength();
801 int textLength = text.GetLength();
802 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_SYSTEM, E_SYSTEM,
803 "[E_SYSTEM] A system error has occurred. textLength exceeds the limitLength");
805 r = __pEdit->SetText(text);
806 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
807 "[E_SYSTEM] A system error has occurred. Failed to set text.");
813 _SearchBar::InsertCharacterAt(int index, const Character& character)
815 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
816 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
817 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
818 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
819 SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM,
820 "[E_SYSTEM] A system error has occurred. The character is null.");
822 result r = E_SUCCESS;
826 limitLength = __pEdit->GetTextLimitLength();
827 textLength = __pEdit->GetTextLength() + 1;
829 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
830 "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
832 SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
833 "[E_OUT_OF_RANGE] index(%d) is out of range of current textLength(%d).", index, __pEdit->GetTextLength());
835 r = __pEdit->InsertCharacterAt(index, character);
836 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
837 "[E_SYSTEM] A system error has occurred. Failed to set text.");
843 _SearchBar::InsertTextAt(int index, const String& text)
845 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
846 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
847 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
848 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
850 result r = E_SUCCESS;
854 limitLength = __pEdit->GetTextLimitLength();
855 textLength = __pEdit->GetTextLength() + text.GetLength();
857 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
858 "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
859 SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
860 "[E_OUT_OF_RANGE] index(%d) is out of range of current textLength(%d).", index, __pEdit->GetTextLength());
862 r = __pEdit->InsertTextAt(index, text);
863 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
864 "[E_SYSTEM] A system error has occurred. Failed to insert text.");
870 _SearchBar::DeleteCharacterAt(int index)
872 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
873 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
874 SysTryReturn(NID_UI_CTRL, index > -1, E_INVALID_ARG, E_INVALID_ARG,
875 "[E_INVALID_ARG] Invalid argument(s) is used. index = %d", index);
877 result r = E_SUCCESS;
879 textLength = __pEdit->GetTextLength();
881 SysTryReturn(NID_UI_CTRL, textLength > index, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
882 "[E_OUT_OF_RANGE] index(%d) is out of range. textLength(%d)", index, textLength);
884 r = __pEdit->DeleteCharacterAt(index);
885 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM,
886 "[E_SYSTEM] A system error has occured. Failed to delete character.");
892 _SearchBar::Clear(void)
894 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
895 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
897 return __pEdit->ClearText();
901 _SearchBar::GetTextLength(void) const
903 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
904 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
906 return __pEdit->GetTextLength();
910 _SearchBar::GetText(void) const
912 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
913 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
915 return __pEdit->GetText();
919 _SearchBar::GetText(int start, int end) const
921 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
922 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
924 return __pEdit->GetText(start, end);
928 _SearchBar::GetLimitLength(void) const
930 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
931 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
933 return __pEdit->GetTextLimitLength();
937 _SearchBar::SetLimitLength(int limitLength)
939 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
940 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
941 SysTryReturn(NID_UI_CTRL, limitLength > 0, E_INVALID_ARG, E_INVALID_ARG,
942 "[E_INVALID_ARG] Invalid argument(s) is used.limitLength = %d", limitLength);
944 String tempString = GetText();
946 int textLength = tempString.GetLength();
947 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_INVALID_ARG, E_INVALID_ARG,
948 "[E_INVALID_ARG] Invalid argument(s) is used. limitLength = %d, textLength = %d", limitLength, textLength);
950 result r = __pEdit->SetLimitLength(limitLength);
951 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
953 r = SetText(tempString);
954 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
960 _SearchBar::ShowKeypad(void) const
962 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
963 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
965 SearchBarMode mode = __pSearchBarPresenter->GetMode();
966 SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_INVALID_STATE, E_INVALID_STATE,
967 "[E_INVALID_STATE] The SearchBar is currently in Normal mode.");
968 return __pEdit->ShowKeypad();
972 _SearchBar::HideKeypad(void)
974 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
975 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
977 SearchBarMode mode = __pSearchBarPresenter->GetMode();
978 SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_SYSTEM, E_SYSTEM,
979 "[E_SYSTEM] A system error has occurred. The SearchBar is currently in Normal mode.");
981 result r = __pEdit->HideKeypad();
989 _SearchBar::GetSearchFieldTextSizeF(void) const
991 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
992 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
994 return __pEdit->GetTextSizeF();
998 _SearchBar::SetSearchFieldTextSize(float size)
1000 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1001 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1003 return __pEdit->SetTextSize(size);
1007 _SearchBar::GetBlockRange(int& start, int& end) const
1009 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1010 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1012 int startIndex = -1;
1015 __pEdit->GetBlockRange(startIndex, endIndex);
1016 SysTryReturn(NID_UI_CTRL, (startIndex > -1 && endIndex > 0), E_SYSTEM, E_SYSTEM,
1017 "[E_SYSTEM] A system error has occurred. Failed to get text block range.");
1026 _SearchBar::ReleaseBlock(void)
1028 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1029 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1031 result r = E_SUCCESS;
1036 r = GetBlockRange(start, end);
1037 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1039 return __pEdit->ReleaseTextBlock();
1043 _SearchBar::SetBlockRange(int start, int end)
1045 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1046 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1048 result r = E_SUCCESS;
1051 textLength = __pEdit->GetTextLength();
1053 SysTryReturn(NID_UI_CTRL, (start < end && start >= 0 && textLength >= end), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1054 "[E_OUT_OF_RANGE] start (%d) and end (%d) is out of range.", start, end - 1);
1056 r = SetCursorPosition(start);
1057 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1059 r = __pEdit->BeginTextBlock();
1060 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1061 "[E_SYSTEM] A system error has occurred. Failed to set text block range.");
1063 r = SetCursorPosition(end);
1064 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1065 "[E_SYSTEM] A system error has occurred. Failed to set cursor position.");
1071 _SearchBar::RemoveTextBlock(void)
1073 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1074 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1076 result r = E_SUCCESS;
1078 r = __pEdit->RemoveTextBlock();
1079 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1085 _SearchBar::GetColor(void) const
1087 Variant backgroundColor = GetProperty("color");
1089 return backgroundColor.ToColor();
1093 _SearchBar::GetSearchFieldColor(SearchFieldStatus status) const
1095 Variant searchFieldColor;
1099 case SEARCH_FIELD_STATUS_NORMAL:
1100 searchFieldColor = GetProperty("searchFieldNormalColor");
1102 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1103 searchFieldColor = GetProperty("searchFieldHighlightedColor");
1105 case SEARCH_FIELD_STATUS_DISABLED:
1106 searchFieldColor = GetProperty("searchFieldDisabledColor");
1112 return searchFieldColor.ToColor();
1117 _SearchBar::GetSearchFieldTextColor(SearchFieldStatus status) const
1119 Variant searchFieldTextColor;
1123 case SEARCH_FIELD_STATUS_NORMAL:
1124 searchFieldTextColor = GetProperty("searchFieldNormalTextColor");
1126 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1127 searchFieldTextColor = GetProperty("searchFieldHighlightedTextColor");
1129 case SEARCH_FIELD_STATUS_DISABLED:
1130 searchFieldTextColor = GetProperty("searchFieldDisabledTextColor");
1136 return searchFieldTextColor.ToColor();
1141 _SearchBar::SetBackgroundBitmap(const Bitmap& bitmap)
1143 Bitmap* pNewBitmap = _BitmapImpl::CloneN(bitmap);
1144 SysTryReturn(NID_UI_CTRL, pNewBitmap, E_SYSTEM, E_SYSTEM,
1145 "[E_SYSTEM] A system error has occurred. The creation of bitmap failed.");
1147 delete __pBackgroundBitmap;
1148 __pBackgroundBitmap = null;
1150 __pBackgroundBitmap = pNewBitmap;
1156 _SearchBar::GetBackgroundBitmap(void) const
1158 return __pBackgroundBitmap;
1162 _SearchBar::SetColor(const Color& color)
1164 return SetProperty("color", Variant(color));
1168 _SearchBar::SetSearchFieldColor(SearchFieldStatus status, const Color& color)
1170 result r = E_SUCCESS;
1174 case SEARCH_FIELD_STATUS_NORMAL:
1175 r = SetProperty("searchFieldNormalColor", Variant(color));
1177 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1178 r = SetProperty("searchFieldHighlightedColor", Variant(color));
1180 case SEARCH_FIELD_STATUS_DISABLED:
1181 r = SetProperty("searchFieldDisabledColor", Variant(color));
1192 _SearchBar::SetSearchFieldTextColor(SearchFieldStatus status, const Color& color)
1194 result r = E_SUCCESS;
1198 case SEARCH_FIELD_STATUS_NORMAL:
1199 r = SetProperty("searchFieldNormalTextColor", Variant(color));
1201 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1202 r = SetProperty("searchFieldHighlightedTextColor", Variant(color));
1204 case SEARCH_FIELD_STATUS_DISABLED:
1205 r = SetProperty("searchFieldDisabledTextColor", Variant(color));
1216 _SearchBar::GetGuideText(void) const
1218 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
1219 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1221 return __pEdit->GetGuideText();
1225 _SearchBar::SetGuideText(const String& guideText)
1227 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1228 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1230 __pEdit->SetGuideText(guideText);
1236 _SearchBar::GetGuideTextColor(void) const
1238 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1239 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1241 return __pEdit->GetGuideTextColor();
1245 _SearchBar::SetGuideTextColor(const Color& color)
1247 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1248 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1250 __isUserGuideTextColor = true;
1251 return __pEdit->SetGuideTextColor(color);
1255 _SearchBar::GetCursorPosition(void) const
1257 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
1258 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1260 return __pEdit->GetCursorPosition();
1264 _SearchBar::SetCursorPosition(int index)
1266 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1267 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1268 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1269 "[E_OUT_OF_RANGE] index(%d) is out of range.", GetErrorMessage(E_OUT_OF_RANGE), index);
1271 int textLength = -1;
1272 textLength = __pEdit->GetTextLength();
1274 SysTryReturn(NID_UI_CTRL, (index > -1 && index <= textLength), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1275 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
1277 return __pEdit->SetCursorPosition(index);
1281 _SearchBar::IsLowerCaseModeEnabled(void) const
1283 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1284 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1286 return __pEdit->IsLowerCaseModeEnabled();
1290 _SearchBar::SetLowerCaseModeEnabled(bool enable)
1292 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
1293 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1295 __pEdit->SetLowerCaseModeEnabled(enable);
1299 _SearchBar::GetEllipsisPosition(void) const
1301 SysTryReturn(NID_UI_CTRL, __pEdit, ELLIPSIS_POSITION_START, E_SYSTEM,
1302 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1304 return __pEdit->GetEllipsisPosition();
1308 _SearchBar::SetEllipsisPosition(EllipsisPosition position)
1310 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1311 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1312 __pEdit->SetEllipsisPosition(position);
1318 _SearchBar::GetKeypadAction(void) const
1320 return __keypadAction;
1324 _SearchBar::IsTextPredictionEnabled(void) const
1326 SysTryReturn(NID_UI_CTRL, __pEdit, false, E_SYSTEM,
1327 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1328 return __pEdit->IsTextPredictionEnabled();
1332 _SearchBar::SetTextPredictionEnabled(bool enable)
1334 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1335 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1336 return __pEdit->SetTextPredictionEnabled(enable);
1340 _SearchBar::SetCurrentLanguage(LanguageCode languageCode)
1342 return __pEdit->SetCurrentLanguage(languageCode);
1346 _SearchBar::GetCurrentLanguage(LanguageCode& language) const
1348 return __pEdit->GetCurrentLanguage(language);
1352 _SearchBar::AddActionEventListener(const _IActionEventListener& listener)
1354 result r = E_SUCCESS;
1356 if (__pActionEvent == null)
1358 __pActionEvent = _ActionEvent::CreateInstanceN(*this);
1359 r = GetLastResult();
1360 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1362 __pActionEvent->AddListener(listener);
1369 _SearchBar::RemoveActionEventListener(const _IActionEventListener& listener)
1371 SysTryReturn(NID_UI_CTRL, __pActionEvent, E_SYSTEM, E_SYSTEM,
1372 "[E_SYSTEM] A system error has occurred. The action event instance is null.");
1373 result r = E_SUCCESS;
1375 r = __pActionEvent->RemoveListener(listener);
1376 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1382 _SearchBar::AddKeypadEventListener(const _IKeypadEventListener& listener)
1384 result r = E_SUCCESS;
1386 if (__pKeypadEvent == null)
1388 __pKeypadEvent = _KeypadEvent::CreateInstanceN(*this);
1389 r = GetLastResult();
1390 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1392 r = __pKeypadEvent->AddListener(listener);
1393 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1400 _SearchBar::RemoveKeypadEventListener(const _IKeypadEventListener& listener)
1402 SysTryReturn(NID_UI_CTRL, __pKeypadEvent, E_SYSTEM, E_SYSTEM,
1403 "[E_SYSTEM] A system error has occurred. The keypad event instance is null.");
1404 result r = E_SUCCESS;
1406 r = __pKeypadEvent->RemoveListener(listener);
1407 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1413 _SearchBar::AddTextBlockEventListener(const _ITextBlockEventListener& listener)
1415 result r = E_SUCCESS;
1417 if (__pTextBlockEvent == null)
1419 __pTextBlockEvent = _TextBlockEvent::CreateInstanceN(*this);
1420 r = GetLastResult();
1421 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1423 r = __pTextBlockEvent->AddListener(listener);
1424 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1432 _SearchBar::RemoveTextBlockEventListener(const _ITextBlockEventListener& listener)
1434 SysTryReturn(NID_UI_CTRL, __pTextBlockEvent, E_SYSTEM, E_SYSTEM,
1435 "[E_SYSTEM] A system error has occurred. The text block event instance is null.");
1436 result r = E_SUCCESS;
1438 r = __pTextBlockEvent->RemoveListener(listener);
1439 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1446 _SearchBar::AddTextEventListener(const _ITextEventListener& listener)
1448 result r = E_SUCCESS;
1450 if (__pTextEvent == null)
1452 __pTextEvent = _TextEvent::CreateInstanceN(*this);
1453 r = GetLastResult();
1454 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1456 r = __pTextEvent->AddListener(listener);
1457 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1464 _SearchBar::RemoveTextEventListener(const _ITextEventListener& listener)
1466 SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM,
1467 "[E_SYSTEM] A system error has occurred. The text event instance is null.");
1468 result r = E_SUCCESS;
1470 r = __pTextEvent->RemoveListener(listener);
1471 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1477 _SearchBar::AddSearchBarEventListener(const _ISearchBarEventListener& listener)
1479 result r = E_SUCCESS;
1481 if (__pSearchBarEvent == null)
1483 __pSearchBarEvent = _SearchBarEvent::CreateInstanceN(*this);
1484 r = GetLastResult();
1485 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1487 r = __pSearchBarEvent->AddListener(listener);
1488 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1495 _SearchBar::RemoveSearchBarEventListener(const _ISearchBarEventListener& listener)
1497 SysTryReturn(NID_UI_CTRL, __pSearchBarEvent, E_SYSTEM, E_SYSTEM,
1498 "[E_SYSTEM] A system error has occurred. The searchbar event instance is null.");
1499 result r = E_SUCCESS;
1501 r = __pSearchBarEvent->RemoveListener(listener);
1502 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1508 _SearchBar::AddLanguageEventListener(const _ILanguageEventListener& listener)
1510 result r = E_SUCCESS;
1512 if (__pLanguageEvent == null)
1514 __pLanguageEvent = _LanguageEvent::CreateInstanceN(*this);
1515 r = GetLastResult();
1516 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1518 r = __pLanguageEvent->AddListener(listener);
1519 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1526 _SearchBar::RemoveLanguageEventListener(const _ILanguageEventListener& listener)
1528 SysTryReturn(NID_UI_CTRL, __pLanguageEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.");
1529 result r = E_SUCCESS;
1531 __pLanguageEvent->RemoveListener(listener);
1532 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1538 _SearchBar::OnBoundsChanged(void)
1540 if (__pSearchBarPresenter != null)
1542 __isupdateContentBounds = true;
1543 __pSearchBarPresenter->OnBoundsChanged();
1546 if (__pAccessibilitySearchBarElement)
1548 __pAccessibilitySearchBarElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height));
1554 _SearchBar::OnChangeLayout(_ControlOrientation orientation)
1556 __isupdateContentBounds = true;
1561 _SearchBar::OnDraw(void)
1563 if (!__isUserGuideTextColor)
1565 SearchFieldStatus status = GetCurrentStatus();
1566 __pEdit->SetGuideTextColor(__guideTextColor[status]);
1569 if (__isupdateContentBounds)
1572 __isupdateContentBounds = false;
1574 __pSearchBarPresenter->Draw();
1578 _UiTouchEventDelivery
1579 _SearchBar::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1581 _Edit* pEdit = dynamic_cast <_Edit*>(const_cast <_Control*>(&source));
1584 return _UI_TOUCH_EVENT_DELIVERY_YES;
1587 if (GetMode() == SEARCH_BAR_MODE_INPUT)
1589 return _UI_TOUCH_EVENT_DELIVERY_YES;
1592 return _UI_TOUCH_EVENT_DELIVERY_YES;
1596 _SearchBar::OnActionPerformed(const _Control& source, int actionId)
1598 if (__actionId == actionId)
1600 __isCancelActionInProgress = true;
1601 SetMode(SEARCH_BAR_MODE_NORMAL);
1605 IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(__actionId);
1606 result r = GetLastResult();
1607 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1609 __pActionEvent->Fire(*pEventArg);
1611 __isCancelActionInProgress = false;
1618 _SearchBar::OnKeypadWillOpen(void)
1620 if (!__isKeypadOpening)
1624 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CREATED);
1625 result r = GetLastResult();
1626 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1628 __pKeypadEvent->Fire(*pEventArg);
1632 __isKeypadOpening = true;
1637 _SearchBar::OnKeypadOpened(void)
1641 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_OPEN);
1642 result r = GetLastResult();
1643 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1645 __pKeypadEvent->Fire(*pEventArg);
1648 __isKeypadOpening = false;
1654 _SearchBar::OnKeypadClosed(void)
1658 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CLOSE);
1659 result r = GetLastResult();
1660 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1662 __pKeypadEvent->Fire(*pEventArg);
1670 _SearchBar::OnKeypadBoundsChanged(void)
1674 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1675 result r = GetLastResult();
1676 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1678 __pKeypadEvent->Fire(*pEventArg);
1686 _SearchBar::OnKeypadActionPerformed(CoreKeypadAction keypadAction)
1690 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(keypadAction, CORE_KEYPAD_EVENT_STATUS_ENTERACTION);
1691 result r = GetLastResult();
1692 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1694 __pKeypadEvent->Fire(*pEventArg);
1699 // TextBlock callbacks
1701 _SearchBar::OnTextBlockSelected(_Control& source, int start, int end)
1703 if (__pTextBlockEvent)
1705 IEventArg* pEventArg = _TextBlockEvent::CreateTextBlockEventArgN(start, end);
1706 result r = GetLastResult();
1707 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1709 __pTextBlockEvent->Fire(*pEventArg);
1716 _SearchBar::OnTextValueChanged(const _Control& source)
1718 if (!__isCancelActionInProgress)
1720 SetContentDimming();
1721 if (__pTextEvent != null)
1723 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CHANGED);
1724 result r = GetLastResult();
1725 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1727 __pTextEvent->Fire(*pEventArg);
1734 _SearchBar::OnTextValueChangeCanceled(const _Control& source)
1736 if (__pTextEvent != null)
1738 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CANCELED);
1739 result r = GetLastResult();
1740 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1742 __pTextEvent->Fire(*pEventArg);
1748 _SearchBar::OnAttachedToMainTree(void)
1755 _SearchBar::OnFontChanged(Font* pFont)
1757 __pCancelButton->SetFont(pFont->GetFaceName());
1758 __pEdit->SetFont(*pFont);
1763 _SearchBar::OnFontInfoRequested(unsigned long& style, int& size)
1765 style = FONT_STYLE_PLAIN;
1766 size = __pCancelButton->GetTextSize();
1772 _SearchBar::OnFocusGained(const _Control& source)
1776 __isKeyPressed = false;
1777 _Control::OnDrawFocus();
1782 if (GetVisibleState() == true)
1784 __pEdit->SetFocused();
1791 _SearchBar::OnFocusLost(const _Control &source)
1793 __pEdit->SetSearchFieldFocus(false);
1794 _Control::OnFocusLost(source);
1799 _SearchBar::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1801 _KeyCode keyCode = keyInfo.GetKeyCode();
1803 if (keyCode == _KEY_RIGHT)
1805 if (GetMode() == SEARCH_BAR_MODE_NORMAL)
1807 __pEdit->SetFocused();
1811 if (!__isButtonEnabled || __pCancelButton->IsFocused() || !__isUsableCancelButton)
1816 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED);
1817 SetFocusCallBackParameter(false);
1818 __pCancelButton->SetFocused();
1819 __pCancelButton->Invalidate(true);
1824 if (keyCode == _KEY_LEFT)
1826 if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_HIGHLIGHTED)
1828 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1829 __pCancelButton->Invalidate();
1830 __pEdit->SetFocused();
1833 if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_DISABLED) //Searchbar Button is disabled, left arrow key is pressed
1835 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1836 SetButtonEnabled(false);
1837 __pEdit->SetFocused();
1843 if (keyCode == _KEY_ENTER || keyCode == _KEY_TAB)
1845 if (GetMode() == SEARCH_BAR_MODE_NORMAL)
1850 SetMode(SEARCH_BAR_MODE_NORMAL);
1851 __isKeyPressed = true;
1861 _SearchBar::OnSettingChanged(Tizen::Base::String& key)
1863 if (__isButtonTextChangedByApp || !__isUsableCancelButton)
1868 if (key.Equals(L"http://tizen.org/setting/locale.language", false))
1871 GET_STRING_CONFIG(IDS_COM_SK_CANCEL, cancelText);
1872 __pCancelButton->SetText(cancelText);
1873 __pCancelButton->Invalidate();
1880 _SearchBar::GetParentForm(void) const
1882 _Form* pForm = null;
1883 _Control* pControlCore = GetParent();
1887 if (pControlCore == null)
1889 SysLog(NID_UI_CTRL,"[E_SYSTEM] The parent form is null.");
1894 pForm = dynamic_cast <_Form*>(pControlCore);
1901 pControlCore = pControlCore->GetParent();
1904 return pControlCore;
1908 _SearchBar::GetSearchBarButton(void) const
1910 return __pCancelButton;
1914 _SearchBar::GetSearchField(void)
1920 _SearchBar::GetSearchBarContainer(void) const
1922 return __pContainer;
1926 _SearchBar::GetClippedGroupControl(void) const
1928 return __pClippedGroupControl;
1932 _SearchBar::IsUsableCancelButton(void) const
1934 return __isUsableCancelButton;
1938 _SearchBar::ConvertSearchBarStatus(SearchFieldStatus status)
1940 EditStatus editStatus = EDIT_STATUS_NORMAL;
1943 case SEARCH_FIELD_STATUS_NORMAL:
1944 editStatus = EDIT_STATUS_NORMAL;
1947 case SEARCH_FIELD_STATUS_DISABLED:
1948 editStatus = EDIT_STATUS_DISABLED;
1951 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1952 editStatus = EDIT_STATUS_HIGHLIGHTED;
1962 _SearchBar::ConvertSearchBarButtonStatus(SearchBarButtonStatus status)
1964 _ButtonStatus buttonStatus = _BUTTON_STATUS_NORMAL;
1968 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
1969 buttonStatus = _BUTTON_STATUS_NORMAL;
1972 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
1973 buttonStatus = _BUTTON_STATUS_PRESSED;
1976 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
1977 buttonStatus = _BUTTON_STATUS_HIGHLIGHTED;
1980 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
1981 buttonStatus = _BUTTON_STATUS_DISABLED;
1987 return buttonStatus;
1991 _SearchBar::SendSearchBarEvent(_SearchBarEventStatus status)
1993 result r = E_SUCCESS;
1994 if (__pSearchBarEvent)
1996 IEventArg* pEventArg = _SearchBarEvent::CreateSearchBarEventArgN(status);
1997 r = GetLastResult();
1998 SysTryReturn(NID_UI_CTRL, pEventArg, r, r, "[%s] Propagating.", GetErrorMessage(r));
2000 if (IsContentAreaVisible() == false)
2002 SetContentAreaVisible(false);
2005 __pSearchBarEvent->Fire(*pEventArg);
2012 _SearchBar::SetHeaderVisibleState(bool visible)
2014 if (__pSearchBarPresenter != null)
2016 __pSearchBarPresenter->SetHeaderVisibleState(visible);
2022 _SearchBar::SetPropertyButtonActionId(const Variant& actionId)
2024 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2025 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2026 SysTryReturn(NID_UI_CTRL, actionId.ToInt() > -1, E_INVALID_ARG, E_INVALID_ARG,
2027 "[E_INVALID_ARG] Invalid argument(s) is used. actionId.ToInt() = %d", actionId.ToInt());
2029 result r = E_SUCCESS;
2031 r = __pCancelButton->SetPropertyActionId(actionId);
2032 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2033 "[%s] A system error has occurred. Failed to set actionId.", GetErrorMessage(E_SYSTEM));
2035 __actionId = actionId.ToInt();
2041 _SearchBar::GetPropertyButtonActionId(void) const
2043 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(-1), E_SYSTEM,
2044 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2046 return Variant(__actionId);
2050 _SearchBar::SetPropertyButtonDisabledColor(const Variant& color)
2052 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2053 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2055 result r = E_SUCCESS;
2057 r = __pCancelButton->SetPropertyDisabledColor(color);
2058 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2059 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2061 __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = color.ToColor();
2067 _SearchBar::GetPropertyButtonDisabledColor(void) const
2069 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2070 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2072 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2076 _SearchBar::SetPropertyButtonHighlightedColor(const Variant& color)
2078 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2079 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2081 result r = E_SUCCESS;
2083 r = __pCancelButton->SetPropertyHighlightedColor(color);
2084 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2085 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2087 __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
2093 _SearchBar::GetPropertyButtonHighlightedColor(void) const
2095 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2096 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2098 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2102 _SearchBar::SetPropertyButtonNormalColor(const Variant& color)
2104 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2105 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2107 result r = E_SUCCESS;
2109 r = __pCancelButton->SetPropertyNormalColor(color);
2110 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2111 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2113 __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = color.ToColor();
2119 _SearchBar::GetPropertyButtonNormalColor(void) const
2121 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2122 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2124 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2128 _SearchBar::SetPropertyButtonPressedColor(const Variant& color)
2130 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2131 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2133 result r = E_SUCCESS;
2135 r = __pCancelButton->SetPropertyPressedColor(color);
2136 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2137 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2139 __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = color.ToColor();
2145 _SearchBar::GetPropertyButtonPressedColor(void) const
2147 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2148 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2150 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2154 _SearchBar::SetPropertyButtonDisabledTextColor(const Variant& textColor)
2156 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2157 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2159 result r = E_SUCCESS;
2161 r = __pCancelButton->SetPropertyDisabledTextColor(textColor);
2162 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2163 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2165 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = textColor.ToColor();
2171 _SearchBar::GetPropertyButtonDisabledTextColor(void) const
2173 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2174 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2176 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2180 _SearchBar::SetPropertyButtonHighlightedTextColor(const Variant& textColor)
2182 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2183 "[E_SYSTEM]] A system error has occurred. The cancel button instance is null.");
2185 result r = E_SUCCESS;
2187 r = __pCancelButton->SetPropertyHighlightedTextColor(textColor);
2188 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2189 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2191 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = textColor.ToColor();
2197 _SearchBar::GetPropertyButtonHighlightedTextColor(void) const
2199 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2200 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2202 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2206 _SearchBar::SetPropertyButtonNormalTextColor(const Variant& textColor)
2208 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2209 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2211 result r = E_SUCCESS;
2213 r = __pCancelButton->SetPropertyNormalTextColor(textColor);
2214 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2215 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2217 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = textColor.ToColor();
2223 _SearchBar::GetPropertyButtonNormalTextColor(void) const
2225 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2226 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2228 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2232 _SearchBar::SetPropertyButtonPressedTextColor(const Variant& textColor)
2234 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2235 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2237 result r = E_SUCCESS;
2239 r = __pCancelButton->SetPropertyPressedTextColor(textColor);
2240 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2241 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2243 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = textColor.ToColor();
2249 _SearchBar::GetPropertyButtonPressedTextColor(void) const
2251 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2252 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2254 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2258 _SearchBar::SetPropertySearchFieldDisabledColor(const Variant& color)
2260 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2261 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2263 result r = E_SUCCESS;
2265 r = __pEdit->SetPropertyDisabledColor(color);
2266 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2267 "[E_SYSTEM] A system error has occurred. Failed to set the edit disabled color.");
2269 __color[SEARCH_FIELD_STATUS_DISABLED] = color.ToColor();
2275 _SearchBar::GetPropertySearchFieldDisabledColor(void) const
2277 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2278 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2280 return Variant(__color[SEARCH_FIELD_STATUS_DISABLED]);
2284 _SearchBar::SetPropertySearchFieldHighlightedColor(const Variant& color)
2286 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2287 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2289 result r = E_SUCCESS;
2291 r = __pEdit->SetPropertyHighlightedColor(color);
2292 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2293 "[E_SYSTEM] A system error has occurred. Failed to set the edit highlighted color.");
2295 __color[SEARCH_FIELD_STATUS_HIGHLIGHTED] = color.ToColor();
2301 _SearchBar::GetPropertySearchFieldHighlightedColor(void) const
2303 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2304 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2306 return Variant(__color[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2310 _SearchBar::SetPropertySearchFieldNormalColor(const Variant& color)
2312 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2313 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2315 result r = E_SUCCESS;
2317 r = __pEdit->SetPropertyNormalColor(color);
2318 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2319 "[E_SYSTEM] A system error has occurred. Failed to set edit normal color.");
2321 __color[SEARCH_FIELD_STATUS_NORMAL] = color.ToColor();
2327 _SearchBar::GetPropertySearchFieldNormalColor(void) const
2329 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2330 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2332 return Variant(__color[SEARCH_FIELD_STATUS_NORMAL]);
2336 _SearchBar::SetPropertySearchFieldDisabledTextColor(const Variant& textColor)
2338 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2339 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2341 result r = E_SUCCESS;
2343 r = __pEdit->SetPropertyDisabledTextColor(textColor);
2344 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2345 "[E_SYSTEM] A system error has occurred. Failed to set edit disabled text color.");
2347 __textColor[SEARCH_FIELD_STATUS_DISABLED] = textColor.ToColor();
2353 _SearchBar::GetPropertySearchFieldDisabledTextColor(void) const
2355 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2356 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2358 return Variant(__textColor[SEARCH_FIELD_STATUS_DISABLED]);
2362 _SearchBar::SetPropertySearchFieldHighlightedTextColor(const Variant& textColor)
2364 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2365 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2367 result r = E_SUCCESS;
2369 r = __pEdit->SetPropertyHighlightedTextColor(textColor);
2370 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2371 "[E_SYSTEM] A system error has occurred. Failed to set edit highlighted text color.");
2373 __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED] = textColor.ToColor();
2379 _SearchBar::GetPropertySearchFieldHighlightedTextColor(void) const
2381 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2382 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2384 return Variant(__textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2388 _SearchBar::SetPropertySearchFieldNormalTextColor(const Variant& textColor)
2390 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2391 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2393 result r = E_SUCCESS;
2395 r = __pEdit->SetPropertyNormalTextColor(textColor);
2396 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2397 "[E_SYSTEM] A system error has occurred. Failed to set edit normal text color.");
2399 __textColor[SEARCH_FIELD_STATUS_NORMAL] = textColor.ToColor();
2405 _SearchBar::GetPropertySearchFieldNormalTextColor(void) const
2407 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2408 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2410 return Variant(__textColor[SEARCH_FIELD_STATUS_NORMAL]);
2414 _SearchBar::SetPropertyColor(const Variant& color)
2416 __backgroundColor = color.ToColor();
2422 _SearchBar::GetPropertyColor(void) const
2424 return Variant(__backgroundColor);
2428 _SearchBar::SetPropertyContentAreaSize(const Variant& size)
2430 FloatDimension contentAreaSize = size.ToFloatDimension();
2431 SysTryReturn(NID_UI_CTRL, contentAreaSize.width >= 0 && contentAreaSize.height >= 0, E_INVALID_ARG, E_INVALID_ARG,
2432 "[E_INVALID_ARG] Invalid argument(s) is used. contentAreaSize.width = %f, contenAreaSize.height = %f",
2433 contentAreaSize.width, contentAreaSize.height);
2435 result r = E_SUCCESS;
2438 FloatRectangle bounds = GetBoundsF();
2439 FloatRectangle contentAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
2441 contentAreaBounds.x = 0.0f;
2442 contentAreaBounds.y = bounds.height;
2443 contentAreaBounds.width = contentAreaSize.width;
2444 contentAreaBounds.height = contentAreaSize.height;
2446 __contentAreaBounds = contentAreaBounds;
2447 __isUserContainerBounds = true;
2452 r = __pContainer->SetBounds(__contentAreaBounds);
2453 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2460 _SearchBar::GetPropertyContentAreaSize(void) const
2462 FloatDimension contentAreaSize(__contentAreaBounds.width, __contentAreaBounds.height);
2464 return Variant(contentAreaSize);
2468 _SearchBar::CreateClippedGroupControl(void)
2470 result r = E_SUCCESS;
2471 FloatRectangle clippedGroupControlBounds(FloatPoint(0.0f, 0.0f), GetSizeF());
2472 __pClippedGroupControl = _Control::CreateControlN();
2473 r = GetLastResult();
2474 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2476 r = AttachChild(*__pClippedGroupControl);
2477 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
2478 "[E_SYSTEM] A system error has occurred. Failed to attach the parent of clipped control.");
2480 r = __pClippedGroupControl->SetBounds(clippedGroupControlBounds);
2481 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2483 __pClippedGroupControl->SetBackgroundColor(Color(0));
2485 __pClippedGroupControl->SetClipChildrenEnabled(true);
2490 delete __pClippedGroupControl;
2491 __pClippedGroupControl = null;
2498 _SearchBar::CreateAccessibilityElement(void)
2500 if (__pAccessibilitySearchBarElement != null)
2504 _AccessibilityContainer* pContainer = null;
2505 pContainer = GetAccessibilityContainer();
2509 __pAccessibilitySearchBarElement = new (std::nothrow) _AccessibilityElement(true);
2510 SysTryReturnVoidResult(NID_UI_CTRL, __pAccessibilitySearchBarElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
2511 __pAccessibilitySearchBarElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height));
2512 __pAccessibilitySearchBarElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
2513 __pAccessibilitySearchBarElement->SetName("SearchBar");
2514 pContainer->AddElement(*__pAccessibilitySearchBarElement);
2521 _SearchBar::SetContentDimming(void)
2523 if (__pContainer != NULL)
2525 if (!GetTextLength())
2527 __contentColor.SetAlpha(_SEARCH_CONTENT_DIM_OPACITY);
2531 __contentColor.SetAlpha(0);
2533 __pContainer->SetBackgroundColor(__contentColor);
2539 _SearchBar::OnDrawFocus(void)
2541 __pEdit->SetSearchFieldFocus(true);
2546 _SearchBar::IsContentAttachable(const _Control* pContent)
2548 const _Window* pWindow = dynamic_cast <const _Window*>(pContent);
2549 const _ColorPicker* pColorPicker = dynamic_cast <const _ColorPicker*>(pContent);
2550 const _Form* pForm = dynamic_cast <const _Form*>(pContent);
2551 const _Keypad* pKeypad = dynamic_cast <const _Keypad*>(pContent);
2552 const _OverlayPanel* pOverlayPanel = dynamic_cast <const _OverlayPanel*>(pContent);
2554 bool isContentAttachable = true;
2556 isContentAttachable = ((pWindow == null) && (pColorPicker == null) &&
2557 (pForm == null) && (pKeypad == null) && (pOverlayPanel == null));
2558 return isContentAttachable;
2562 _SearchBar::ResizeCancelButton(void)
2564 result r = E_SUCCESS;
2566 float horizontalMargin = 0.0f;
2567 float buttonLeftMargin = 0.0f;
2568 float buttonRightMargin = 0.0f;
2569 float buttonMinWidth = 0.0f;
2570 float searchFieldMinWidth = 0.0f;
2571 float buttonVerticalMargin = 0.0f;
2572 float searchBarMinHeight = 0.0f;
2573 float buttonWidth = 0.0f;
2574 float buttonHeight = 0.0f;
2576 FloatRectangle cancelButtonBounds;
2577 FloatRectangle searchBarBounds = GetBoundsF();
2579 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2581 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2582 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2583 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2584 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2585 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2586 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2587 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2588 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2589 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2591 cancelButtonBounds.width = buttonWidth;
2592 cancelButtonBounds.height = buttonHeight;
2594 float buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth +
2595 cancelButtonBounds.width + buttonLeftMargin + buttonRightMargin);
2597 if (searchBarBounds.width < buttonResizableSearchBarWidth)
2599 cancelButtonBounds.width = searchBarBounds.width -(searchFieldMinWidth + buttonLeftMargin
2600 + buttonRightMargin + horizontalMargin);
2603 cancelButtonBounds.x = searchBarBounds.width - cancelButtonBounds.width - buttonRightMargin;
2604 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2606 cancelButtonBounds.y = cancelButtonBounds.y < 0.0f ? 0.0f:cancelButtonBounds.y;
2608 if (cancelButtonBounds.width < buttonMinWidth)
2610 cancelButtonBounds.width = buttonMinWidth;
2613 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2614 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2615 r = __pCancelButton->SetBounds(cancelButtonBounds);
2621 _SearchBar::RecalculateButtonBounds(void)
2623 result r = E_SUCCESS;
2625 float horizontalMargin = 0.0f;
2626 float verticalMargin = 0.0f;
2627 float buttonLeftMargin = 0.0f;
2628 float buttonRightMargin = 0.0f;
2629 float buttonMinWidth = 0.0f;
2630 float searchFieldMinWidth = 0.0f;
2631 float buttonVerticalMargin = 0.0f;
2632 float searchBarMinHeight = 0.0f;
2633 float buttonWidth = 0.0f;
2634 float buttonHeight = 0.0f;
2635 float cancelButtonWidth = 0.0f;
2637 FloatRectangle cancelButtonBounds;
2638 FloatRectangle editBounds;
2639 FloatRectangle searchBarBounds = GetBoundsF();
2641 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2643 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2644 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin);
2645 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2646 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2647 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2648 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2649 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2650 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2651 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2652 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2654 cancelButtonBounds.height = buttonHeight;
2656 float searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2.0f);
2657 cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightTouchMarginF() + __pCancelButton->GetLeftTouchMarginF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF();
2658 editBounds.x = horizontalMargin;
2660 if (searchBarBounds.height < searchBarMinHeight)
2662 verticalMargin = (searchBarBounds.height - searchFieldMinHeight)/2.0f;
2663 if (verticalMargin < 0.0f)
2665 verticalMargin = 0.0f;
2669 editBounds.y = verticalMargin;
2670 editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
2672 editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
2674 editBounds.width = searchBarBounds.width - cancelButtonWidth - horizontalMargin - buttonLeftMargin - buttonRightMargin;
2676 if (editBounds.width < searchFieldMinWidth)
2678 editBounds.width = searchFieldMinWidth;
2681 cancelButtonBounds.x = editBounds.width + horizontalMargin + buttonLeftMargin;
2682 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2684 cancelButtonBounds.y = cancelButtonBounds.y < 0.0f ? 0.0f:cancelButtonBounds.y;
2686 float remainingWidth = searchBarBounds.width - editBounds.width - horizontalMargin - buttonLeftMargin - buttonRightMargin;
2688 if (remainingWidth < buttonMinWidth)
2690 cancelButtonBounds.width = buttonMinWidth;
2694 cancelButtonBounds.width = searchBarBounds.width - cancelButtonBounds.x - buttonRightMargin;
2697 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2698 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2700 r = __pCancelButton->SetBounds(cancelButtonBounds);
2701 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2702 r = __pEdit->SetBounds(editBounds);
2703 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2709 _SearchBar::GetCurrentStatus(void)
2711 SearchFieldStatus searchFieldStatus = SEARCH_FIELD_STATUS_NORMAL;
2715 if (__pEdit->IsFocused())
2717 searchFieldStatus = SEARCH_FIELD_STATUS_HIGHLIGHTED;
2722 searchFieldStatus = SEARCH_FIELD_STATUS_DISABLED;
2725 return searchFieldStatus;
2729 _SearchBar::SetEditTextFilter(IEditTextFilter* pFilter)
2731 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2732 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2734 __pEdit->SetEditTextFilter(pFilter);
2740 _SearchBar::SendOpaqueCommand(const String& command)
2742 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2743 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2745 __pEdit->SendOpaqueCommand(command);
2751 _SearchBar::SetFocusCallBackParameter(bool state)
2753 __isFocusCallbackToBeFired = state;
2758 _SearchBar::IsFocusCallBackToBeFired(void) const
2760 return __isFocusCallbackToBeFired;
2762 }}} // Tizen::Ui::Controls