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 <FSys_SettingInfoImpl.h>
27 #include "FUi_ResourceManager.h"
28 #include "FUi_FocusManagerImpl.h"
29 #include "FUi_AccessibilityContainer.h"
30 #include "FUi_AccessibilityElement.h"
31 #include "FUi_AccessibilityManager.h"
32 #include "FUi_CoordinateSystemUtils.h"
33 #include "FUiAnim_VisualElement.h"
34 #include "FUiCtrl_SearchBar.h"
35 #include "FUiCtrl_SearchBarPresenter.h"
36 #include "FUiCtrl_Form.h"
37 #include "FUiCtrl_Edit.h"
38 #include "FUiCtrl_Panel.h"
39 #include "FUiCtrl_OverlayPanel.h"
40 #include "FUiCtrl_Keypad.h"
41 #include "FUiCtrl_ColorPicker.h"
42 #include "FUiCtrl_ActionEvent.h"
43 #include "FUiCtrl_TextBlockEvent.h"
44 #include "FUiCtrl_TextEvent.h"
45 #include "FUiCtrl_SearchBarImpl.h"
46 #include "FUiCtrl_EditFieldImpl.h"
47 #include "FUiCtrl_ButtonImpl.h"
50 using namespace Tizen::Graphics;
51 using namespace Tizen::Ui;
52 using namespace Tizen::Ui::Animations;
53 using namespace Tizen::Base;
54 using namespace Tizen::Base::Runtime;
55 using namespace Tizen::Locales;
56 using namespace Tizen::System;
58 namespace Tizen { namespace Ui { namespace Controls
61 IMPLEMENT_PROPERTY(_SearchBar);
63 _SearchBar::_SearchBar(void)
64 : __pSearchBarPresenter(null)
65 , __pClippedGroupControl(null)
67 , __pCancelButton(null)
69 , __pContentControl(null)
72 , __isButtonEnabled(true)
73 , __isUsableCancelButton(false)
74 , __isUserContainerBounds(false)
75 , __isCancelActionInProgress(false)
76 , __isUserGuideTextColor(false)
77 , __isKeypadOpening(false)
78 , __isupdateContentBounds(false)
79 , __isFocusCallbackToBeFired(true)
80 , __isButtonTextChangedByApp(false)
81 , __contentVisibilitySetByApp(true)
82 , __isFocusUiInitialized(false)
83 , __isTouchMoved(false)
84 , __keypadAction(CORE_KEYPAD_ACTION_SEARCH)
85 , __pBackgroundBitmap(null)
86 , __backgroundColor(Color())
87 , __contentColor(Color())
88 , __pActionEvent(null)
89 , __pKeypadEvent(null)
90 , __pTextBlockEvent(null)
92 , __pSearchBarEvent(null)
93 , __pLanguageEvent(null)
94 , __pAccessibilitySearchBarElement(null)
96 for (int i = 0; i < SEARCHBAR_BUTTON_COLOR_MAX; i++)
98 __buttonColor[i] = Color(0);
99 __buttonTextColor[i] = Color(0);
102 for (int i = 0; i < SEARCHBAR_COLOR_MAX; i++)
104 __color[i] = Color(0);
105 __textColor[i] = Color(0);
106 __guideTextColor[i] = Color(0);
109 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
110 if (pContainer != null)
112 pContainer->Activate(true);
116 _SearchBar::~_SearchBar(void)
118 SettingInfo::RemoveSettingEventListener(*this);
120 delete __pSearchBarPresenter;
121 __pSearchBarPresenter = null;
123 if (__pClippedGroupControl != null)
125 DetachChild(*__pClippedGroupControl);
127 delete __pClippedGroupControl;
128 __pClippedGroupControl = null;
131 if (__pContainer != null)
133 DetachChild(*__pContainer);
139 delete __pActionEvent;
140 __pActionEvent = null;
142 delete __pKeypadEvent;
143 __pKeypadEvent = null;
145 delete __pTextBlockEvent;
146 __pTextBlockEvent = null;
151 delete __pSearchBarEvent;
152 __pSearchBarEvent = null;
154 delete __pLanguageEvent;
155 __pLanguageEvent = null;
157 if (__pAccessibilitySearchBarElement != null)
159 __pAccessibilitySearchBarElement->Activate(false);
160 __pAccessibilitySearchBarElement = null;
163 delete __pBackgroundBitmap;
164 __pBackgroundBitmap = null;
168 _SearchBar::CreateSearchBarN(void)
170 _SearchBar* pSearchBar = new (std::nothrow) _SearchBar();
171 SysTryReturn(NID_UI_CTRL, pSearchBar != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
172 if (GetLastResult() != E_SUCCESS)
178 pSearchBar->AcquireHandle();
179 pSearchBar->SetTouchPressThreshold(_TOUCH_PRESS_THRESHOLD_INSENSITIVE);
185 _SearchBar::Initialize(bool enableSearchBarButton, CoreKeypadAction keypadAction)
187 result r = E_SUCCESS;
189 // Setting Button color
190 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_NORMAL, __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
191 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_PRESSED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
192 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_HIGHLIGHTED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
193 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_DISABLED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
195 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_NORMAL, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
196 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_PRESSED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
197 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_HIGHLIGHTED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
198 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_DISABLED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
200 GET_COLOR_CONFIG(SEARCHBAR::CONTENT_AREA_BG_NORMAL, __contentColor);
202 for (int i = 0; i < SEARCHBAR_COLOR_MAX; i++)
206 case SEARCH_FIELD_STATUS_DISABLED:
207 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_DISABLED, __color[i]);
208 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_DISABLED, __textColor[i]);
209 GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_DISABLED, __guideTextColor[i]);
212 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
213 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]);
214 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_HIGHLIGHTED, __textColor[i]);
215 GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_NORMAL, __guideTextColor[i]);
218 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]);
219 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_NORMAL, __textColor[i]);
220 GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_NORMAL, __guideTextColor[i]);
225 GET_COLOR_CONFIG(SEARCHBAR::BG_NORMAL, __backgroundColor);
227 __isUsableCancelButton = enableSearchBarButton;
228 __keypadAction = keypadAction;
230 GetVisualElement()->SetClipChildrenEnabled(false);
232 r = CreateClippedGroupControl();
233 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
234 "[%s] A system error has occurred. The construction of parent control for clipped group control failed.", GetErrorMessage(E_SYSTEM));
236 r = CreateSearchField();
237 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
238 "[%s] A system error has occurred. The edit construction failed.", GetErrorMessage(E_SYSTEM));
239 r = CreateCancelButton();
240 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
241 "[%s] A system error has occurred. The cancel button construction failed.", GetErrorMessage(E_SYSTEM));
244 r = CreateContentsArea();
245 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
246 "[%s] A system error has occurred. The construction of parent for content failed.", GetErrorMessage(E_SYSTEM));
248 _SearchBarPresenter* pPresenter = new (std::nothrow) _SearchBarPresenter();
249 SysTryReturn(NID_UI_CTRL, pPresenter != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
251 r = pPresenter->Construct(*this);
252 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
254 r = pPresenter->Install();
255 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
257 __pSearchBarPresenter = pPresenter;
259 InitializeAccessibility();
261 r = _SettingInfoImpl::AddSettingEventListener(*this);
262 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
274 _SearchBar::CreateSearchField(void)
276 result r = E_SUCCESS;
278 FloatRectangle editBounds;
279 float horizontalMargin = 0.0f;
280 float verticalMargin = 0.0f;
281 float iconHorizontalMargin = 0.0f;
282 float textHorizontalMargin = 0.0f;
283 float iconWidth = 0.0f;
284 float textSize = 0.0f;
285 float searchBarMinHeight = 0.0f;
286 float searchBarMinWidthModeNormal = 0.0f;
288 FloatRectangle searchBarBounds = GetBoundsF();
289 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
291 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
292 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin);
293 GET_SHAPE_CONFIG(SEARCHBAR::ICON_HORIZONTAL_MARGIN, orientation, iconHorizontalMargin);
294 GET_SHAPE_CONFIG(SEARCHBAR::ICON_WIDTH, orientation, iconWidth);
295 GET_SHAPE_CONFIG(SEARCHBAR::TEXT_HORIZONTAL_MARGIN, orientation, textHorizontalMargin);
296 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH_NORMAL_MODE, orientation, searchBarMinWidthModeNormal);
297 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
299 float searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2.0f);
301 editBounds.x = horizontalMargin;
303 if (searchBarBounds.height < searchBarMinHeight)
305 verticalMargin = (searchBarBounds.height - searchFieldMinHeight)/2.0f;
306 if (verticalMargin < 0.0f)
308 verticalMargin = 0.0f;
312 editBounds.y = verticalMargin;
314 editBounds.width = searchBarBounds.width - (editBounds.x * 2.0f);
315 editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
317 editBounds.width = (editBounds.width > searchBarMinWidthModeNormal) ? editBounds.width : searchBarMinWidthModeNormal;
318 editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
320 _SearchBarImpl* pSearchBarImpl = static_cast<_SearchBarImpl*>(GetUserData());
321 SysTryReturnResult(NID_UI_CTRL, pSearchBarImpl != null, E_SYSTEM,
322 "A system error has occurred. Failed to get _SearchBarImpl instance.");
324 __pEdit = &(pSearchBarImpl->GetEditFieldImpl()->GetCore());
325 SysTryReturnResult(NID_UI_CTRL, __pEdit != null, E_SYSTEM,
326 "A system error has occurred. Failed to get _Edit instance.");
328 __pEdit->SetKeypadCommandButtonVisible(false);
329 __pEdit->SetBounds(editBounds);
330 __pEdit->AddKeypadEventListener(*this);
331 __pEdit->AddTextBlockEventListener(*this);
332 __pEdit->AddTextEventListener(*this);
334 GET_SHAPE_CONFIG(SEARCHBAR::EDIT_TEXT_SIZE, orientation, textSize);
335 __pEdit->SetTextSize(textSize);
337 __pEdit->SetHorizontalMargin(iconHorizontalMargin + iconWidth + textHorizontalMargin, EDIT_TEXT_LEFT_MARGIN);
338 __pEdit->SetHorizontalMargin(textHorizontalMargin, EDIT_TEXT_RIGHT_MARGIN);
339 __pEdit->SetLimitLength(SEARCHBAR_TEXT_LENGTH_MAX);
341 for (int status = 0; status < SEARCHBAR_COLOR_MAX; status++)
343 EditStatus editStatus = ConvertSearchBarStatus((SearchFieldStatus) status);
344 __pEdit->SetColor(editStatus, __color[status]);
347 __pEdit->SetTextColor(EDIT_TEXT_COLOR_NORMAL, __textColor[SEARCH_FIELD_STATUS_NORMAL]);
348 __pEdit->SetTextColor(EDIT_TEXT_COLOR_DISABLED, __textColor[SEARCH_FIELD_STATUS_DISABLED]);
349 __pEdit->SetTextColor(EDIT_TEXT_COLOR_HIGHLIGHTED, __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
351 __pEdit->ReplaceDefaultBackgroundBitmapForSearchBar();
353 __pEdit->SetKeypadAction(__keypadAction);
355 r = __pClippedGroupControl->AttachChild(*__pEdit);
356 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
357 "[%s] A system error has occurred. Failed to attach edit as child.", GetErrorMessage(E_SYSTEM));
369 _SearchBar::CreateCancelButton(void)
371 result r = E_SUCCESS;
373 float textSize = 0.0f;
374 String cancelButtonText;
376 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
378 _SearchBarImpl* pSearchBarImpl = static_cast<_SearchBarImpl*>(GetUserData());
379 SysTryReturnResult(NID_UI_CTRL, pSearchBarImpl != null, E_SYSTEM,
380 "A system error has occurred. Failed to get _SearchBarImpl instance.");
382 __pCancelButton = &(pSearchBarImpl->GetButtonImpl()->GetCore());
383 SysTryReturnResult(NID_UI_CTRL, __pCancelButton != null, E_SYSTEM,
384 "A system error has occurred. Failed to get _Button instance.");
387 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
389 r = ResizeCancelButton();
390 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
392 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_CANCEL_ABB, cancelButtonText);
393 r = __pCancelButton->SetText(cancelButtonText);
394 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
396 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_TEXT_SIZE, orientation, textSize);
397 r = __pCancelButton->SetTextSize(textSize);
398 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
400 __pCancelButton->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
401 __pCancelButton->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
403 r = __pCancelButton->SetActionId(__actionId);
404 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
406 r = __pCancelButton->AddActionEventListener(*this);
407 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
409 __pCancelButton->SetVisibleState(false);
411 for (int status = 0; status < SEARCHBAR_BUTTON_COLOR_MAX; status++)
413 _ButtonStatus buttonStatus = ConvertSearchBarButtonStatus((SearchBarButtonStatus) status);
415 r = __pCancelButton->SetColor(buttonStatus, __buttonColor[status]);
416 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
418 r = __pCancelButton->SetTextColor(buttonStatus, __buttonTextColor[status]);
419 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
422 r = __pClippedGroupControl->AttachChild(*__pCancelButton);
423 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
424 "[%s] A system error has occurred. Failed to attach button as child.", GetErrorMessage(E_SYSTEM));
429 delete __pCancelButton;
430 __pCancelButton = null;
436 _SearchBar::CreateContentsArea(void)
438 result r = E_SUCCESS;
440 __pContainer = _Control::CreateControlN();
443 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
445 __pContainer->SetVisibleState(false);
447 r = AttachChild(*__pContainer);
448 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
449 "[%s] A system error has occurred. Failed to attach the parent of content.", GetErrorMessage(E_SYSTEM));
461 _SearchBar::SetContentsArea(void)
463 if (__isUserContainerBounds)
468 FloatDimension screenSize = _ControlManager::GetInstance()->GetScreenSizeF();
469 float width = screenSize.width;
470 float height = screenSize.height;
472 _Control* pParent = GetParentForm();
475 width = pParent->GetClientBoundsF().width;
476 height = pParent->GetClientBoundsF().height;
479 FloatRectangle controlBounds = GetBoundsF();
480 controlBounds = CoordinateSystem::AlignToDevice(FloatRectangle(controlBounds));
482 __contentAreaBounds.x = 0.0f;
483 __contentAreaBounds.y = controlBounds.height;
484 __contentAreaBounds.width = width - controlBounds.x;
485 __contentAreaBounds.height = height - (controlBounds.y + controlBounds.height);
487 if (__pContainer != null)
489 result r = E_SUCCESS;
490 r = __pContainer->SetBounds(__contentAreaBounds);
491 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
497 _SearchBar::GetContent(void) const
499 return __pContentControl;
503 _SearchBar::SetContent(const _Control* pContent)
505 __pContentControl = const_cast <_Control*>(pContent);
506 result r = E_SUCCESS;
508 if (__pContainer != null)
510 r = __pContainer->AttachChild(*__pContentControl);
511 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating");
518 _SearchBar::UpdateContentArea(bool invalidate)
520 return __pSearchBarPresenter->UpdateContentArea(invalidate);
524 _SearchBar::SetContentAreaVisible(bool visible, bool isCalledByApp)
526 SysTryReturn(NID_UI_CTRL, __pContainer != null, E_SYSTEM, E_SYSTEM,
527 "[%s] A system error has occurred. The instance of parent to content is null.", GetErrorMessage(E_SYSTEM));
529 SearchBarMode searchBarMode = GetMode();
530 if (searchBarMode == SEARCH_BAR_MODE_INPUT)
532 __pContainer->SetVisibleState(visible);
537 __contentVisibilitySetByApp = visible;
540 return __pSearchBarPresenter->SetContentAreaVisible(visible);
544 _SearchBar::IsContentAreaVisible(void) const
546 return __pSearchBarPresenter->IsContentAreaVisible();
550 _SearchBar::SetContentAreaSize(const Dimension& size)
552 return SetProperty("contentAreaSize", Variant(size));
556 _SearchBar::GetContentAreaSize(void) const
558 Variant size = GetProperty("contentAreaSize");
560 return size.ToDimension();
564 _SearchBar::GetMode(void) const
566 return __pSearchBarPresenter->GetMode();
570 _SearchBar::IsModeLocked(void) const
572 return __pSearchBarPresenter->IsModeLocked();
576 _SearchBar::SetMode(SearchBarMode mode, bool isCalledByApp)
578 _AccessibilityElement* pEditElement = __pEdit->GetTextAccessibilityElement();
579 // if (mode == SEARCH_BAR_MODE_NORMAL)
581 // pEditElement->SetHint("Double Tap To Type Search Text");
585 // pEditElement->SetHint("Enter Search Text");
588 // pEditElement->SetTrait("SearchBar");
589 pEditElement->SetName("SearchField");
591 return __pSearchBarPresenter->SetMode(mode, isCalledByApp);
595 _SearchBar::SetModeLocked(bool modeLocked)
597 if (modeLocked && GetMode() == SEARCH_BAR_MODE_NORMAL)
599 __pEdit->SetViewModeEnabled(true);
602 if (!modeLocked && __pEdit->IsViewModeEnabled())
604 __pEdit->SetViewModeEnabled(false);
607 return __pSearchBarPresenter->SetModeLocked(modeLocked);
611 _SearchBar::GetButtonActionId(void) const
613 Variant actionId = GetProperty("buttonActionId");
615 return actionId.ToInt();
619 _SearchBar::GetButtonColor(SearchBarButtonStatus status) const
625 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
626 buttonColor = GetProperty("buttonNormalColor");
628 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
629 buttonColor = GetProperty("buttonPressedColor");
631 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
632 buttonColor = GetProperty("buttonHighlightedColor");
634 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
635 buttonColor = GetProperty("buttonDisabledColor");
641 return buttonColor.ToColor();
645 _SearchBar::GetButtonTextColor(SearchBarButtonStatus status) const
647 Variant buttonTextColor;
651 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
652 buttonTextColor = GetProperty("buttonNormalTextColor");
654 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
655 buttonTextColor = GetProperty("buttonPressedTextColor");
657 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
658 buttonTextColor = GetProperty("buttonHighlightedTextColor");
660 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
661 buttonTextColor = GetProperty("buttonDisabledTextColor");
667 return buttonTextColor.ToColor();
670 SearchBarButtonStatus
671 _SearchBar::GetButtonStatus(void) const
673 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, SEARCH_BAR_BUTTON_STATUS_NORMAL, E_SYSTEM,
674 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
676 SearchBarButtonStatus buttonStatus = SEARCH_BAR_BUTTON_STATUS_NORMAL;
678 if (!__isButtonEnabled)
680 buttonStatus = SEARCH_BAR_BUTTON_STATUS_DISABLED;
687 _SearchBar::SetButtonText(const String& text)
689 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, E_SYSTEM, E_SYSTEM,
690 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
692 result r = E_SUCCESS;
694 r = __pCancelButton->SetText(text);
695 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
696 "[%s] A system error has occurred. Failed to set text.", GetErrorMessage(E_SYSTEM));
698 __isButtonTextChangedByApp = true;
704 _SearchBar::SetButtonActionId(int actionId)
706 return SetProperty("buttonActionId", Variant(actionId));
710 _SearchBar::SetButtonEnabled(bool enabled)
712 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, E_SYSTEM, E_SYSTEM,
713 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
715 __pCancelButton->SetEnableState(enabled);
717 __isButtonEnabled = enabled;
723 _SearchBar::SetButtonColor(SearchBarButtonStatus status, const Color& color)
725 result r = E_SUCCESS;
729 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
730 r = SetProperty("buttonNormalColor", Variant(color));
732 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
733 r = SetProperty("buttonPressedColor", Variant(color));
735 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
736 r = SetProperty("buttonHighlightedColor", Variant(color));
738 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
739 r = SetProperty("buttonDisabledColor", Variant(color));
749 _SearchBar::SetButtonTextColor(SearchBarButtonStatus status, const Color& color)
751 result r = E_SUCCESS;
755 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
756 r = SetProperty("buttonNormalTextColor", Variant(color));
758 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
759 r = SetProperty("buttonPressedTextColor", Variant(color));
761 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
762 r = SetProperty("buttonHighlightedTextColor", Variant(color));
764 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
765 r = SetProperty("buttonDisabledTextColor", Variant(color));
775 _SearchBar::AppendCharacter(const Character& character)
777 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
778 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
779 SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM,
780 "[%s] A system error has occurred. The character is null.", GetErrorMessage(E_SYSTEM));
782 result r = E_SUCCESS;
784 r = __pEdit->AppendCharacter(character);
785 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
786 "[%s] A system error has occurred. Failed to set character.", GetErrorMessage(E_SYSTEM));
792 _SearchBar::AppendText(const String& text)
794 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
795 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
796 SysTryReturn(NID_UI_CTRL, text.IsEmpty() == false, E_SYSTEM, E_SYSTEM,
797 "[%s] A system error has occurred. The text is empty.", GetErrorMessage(E_SYSTEM));
799 result r = E_SUCCESS;
801 r = __pEdit->AppendText(text);
802 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
803 "[%s] A system error has occurred. Failed to set text.", GetErrorMessage(E_SYSTEM));
809 _SearchBar::SetText(const String& text)
811 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
812 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
814 result r = E_SUCCESS;
816 int limitLength = __pEdit->GetTextLimitLength();
817 int textLength = text.GetLength();
818 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_SYSTEM, E_SYSTEM,
819 "[%s] A system error has occurred. textLength exceeds the limitLength", GetErrorMessage(E_SYSTEM));
821 r = __pEdit->SetText(text);
822 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
823 "[%s] A system error has occurred. Failed to set text.", GetErrorMessage(E_SYSTEM));
829 _SearchBar::InsertCharacterAt(int index, const Character& character)
831 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
832 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
833 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
834 "[%s] index(%d) is out of range.", GetErrorMessage(E_OUT_OF_RANGE), index);
835 SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM,
836 "[%s] A system error has occurred. The character is null.", GetErrorMessage(E_SYSTEM));
838 result r = E_SUCCESS;
842 limitLength = __pEdit->GetTextLimitLength();
843 textLength = __pEdit->GetTextLength() + 1;
845 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
846 "[%s] limitLength(%d) exceeds the maximum limit textLength(%d).", GetErrorMessage(E_MAX_EXCEEDED), limitLength, textLength);
848 SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
849 "[%s] index(%d) is out of range of current textLength(%d).", GetErrorMessage(E_OUT_OF_RANGE), index, __pEdit->GetTextLength());
851 r = __pEdit->InsertCharacterAt(index, character);
852 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
853 "[%s] A system error has occurred. Failed to set text.", GetErrorMessage(E_SYSTEM));
859 _SearchBar::InsertTextAt(int index, const String& text)
861 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
862 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
863 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
864 "[%s] index(%d) is out of range.", GetErrorMessage(E_OUT_OF_RANGE), index);
866 result r = E_SUCCESS;
870 limitLength = __pEdit->GetTextLimitLength();
871 textLength = __pEdit->GetTextLength() + text.GetLength();
873 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
874 "[%s] limitLength(%d) exceeds the maximum limit textLength(%d).", GetErrorMessage(E_MAX_EXCEEDED), limitLength, textLength);
875 SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
876 "[%s] index(%d) is out of range of current textLength(%d).", GetErrorMessage(E_OUT_OF_RANGE), index, __pEdit->GetTextLength());
878 r = __pEdit->InsertTextAt(index, text);
879 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
880 "[%s] A system error has occurred. Failed to insert text.", GetErrorMessage(E_SYSTEM));
886 _SearchBar::DeleteCharacterAt(int index)
888 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
889 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
890 SysTryReturn(NID_UI_CTRL, index > -1, E_INVALID_ARG, E_INVALID_ARG,
891 "[%s] Invalid argument(s) is used. index = %d", GetErrorMessage(E_INVALID_ARG), index);
893 result r = E_SUCCESS;
895 textLength = __pEdit->GetTextLength();
897 SysTryReturn(NID_UI_CTRL, textLength > index, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
898 "[%s] index(%d) is out of range. textLength(%d)", GetErrorMessage(E_OUT_OF_RANGE), index, textLength);
900 r = __pEdit->DeleteCharacterAt(index);
901 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM,
902 "A system error has occurred. Failed to delete character.");
908 _SearchBar::Clear(void)
910 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
911 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
913 return __pEdit->ClearText();
917 _SearchBar::GetTextLength(void) const
919 SysTryReturn(NID_UI_CTRL, __pEdit != null, -1, E_SYSTEM,
920 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
922 return __pEdit->GetTextLength();
926 _SearchBar::GetText(void) const
928 SysTryReturn(NID_UI_CTRL, __pEdit != null, String(), E_SYSTEM,
929 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
931 return __pEdit->GetText();
935 _SearchBar::GetText(int start, int end) const
937 SysTryReturn(NID_UI_CTRL, __pEdit != null, String(), E_SYSTEM,
938 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
940 return __pEdit->GetText(start, end);
944 _SearchBar::GetLimitLength(void) const
946 SysTryReturn(NID_UI_CTRL, __pEdit != null, -1, E_SYSTEM,
947 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
949 return __pEdit->GetTextLimitLength();
953 _SearchBar::SetLimitLength(int limitLength)
955 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
956 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
957 SysTryReturn(NID_UI_CTRL, limitLength > 0, E_INVALID_ARG, E_INVALID_ARG,
958 "[%s] Invalid argument(s) is used.limitLength = %d", GetErrorMessage(E_INVALID_ARG), limitLength);
960 String tempString = GetText();
962 int textLength = tempString.GetLength();
963 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_INVALID_ARG, E_INVALID_ARG,
964 "[%s] Invalid argument(s) is used. limitLength = %d, textLength = %d", GetErrorMessage(E_INVALID_ARG), limitLength, textLength);
966 result r = __pEdit->SetLimitLength(limitLength);
967 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
969 r = SetText(tempString);
970 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
976 _SearchBar::ShowKeypad(void) const
978 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
979 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
981 SearchBarMode mode = __pSearchBarPresenter->GetMode();
982 SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_INVALID_STATE, E_INVALID_STATE,
983 "[%s] The SearchBar is currently in Normal mode.", GetErrorMessage(E_INVALID_STATE));
984 return __pEdit->ShowKeypad();
988 _SearchBar::HideKeypad(void)
990 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
991 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
993 SearchBarMode mode = __pSearchBarPresenter->GetMode();
994 SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_SYSTEM, E_SYSTEM,
995 "[%s] A system error has occurred. The SearchBar is currently in Normal mode.", GetErrorMessage(E_SYSTEM));
997 result r = __pEdit->HideKeypad();
1005 _SearchBar::GetSearchFieldTextSizeF(void) const
1007 SysTryReturn(NID_UI_CTRL, __pEdit != null, -1, E_SYSTEM,
1008 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
1010 return __pEdit->GetTextSizeF();
1014 _SearchBar::SetSearchFieldTextSize(float size)
1016 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
1017 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
1019 return __pEdit->SetTextSize(size);
1023 _SearchBar::GetBlockRange(int& start, int& end) const
1025 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
1026 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
1028 int startIndex = -1;
1031 __pEdit->GetBlockRange(startIndex, endIndex);
1032 SysTryReturn(NID_UI_CTRL, (startIndex > -1 && endIndex > 0), E_SYSTEM, E_SYSTEM,
1033 "[%s] A system error has occurred. Failed to get text block range.", GetErrorMessage(E_SYSTEM));
1042 _SearchBar::ReleaseBlock(void)
1044 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
1045 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
1047 result r = E_SUCCESS;
1052 r = GetBlockRange(start, end);
1053 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1055 return __pEdit->ReleaseTextBlock();
1059 _SearchBar::SetBlockRange(int start, int end)
1061 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
1062 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
1064 result r = E_SUCCESS;
1067 textLength = __pEdit->GetTextLength();
1069 SysTryReturn(NID_UI_CTRL, (start < end && start >= 0 && textLength >= end), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1070 "[%s] start (%d) and end (%d) is out of range.", GetErrorMessage(E_OUT_OF_RANGE), start, end - 1);
1072 r = SetCursorPosition(start);
1073 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1075 r = __pEdit->BeginTextBlock();
1076 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1077 "[%s] A system error has occurred. Failed to set text block range.", GetErrorMessage(E_SYSTEM));
1079 r = SetCursorPosition(end);
1080 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1081 "[%s] A system error has occurred. Failed to set cursor position.", GetErrorMessage(E_SYSTEM));
1087 _SearchBar::RemoveTextBlock(void)
1089 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
1090 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
1092 result r = E_SUCCESS;
1094 r = __pEdit->RemoveTextBlock();
1095 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1101 _SearchBar::GetColor(void) const
1103 Variant backgroundColor = GetProperty("color");
1105 return backgroundColor.ToColor();
1109 _SearchBar::GetSearchFieldColor(SearchFieldStatus status) const
1111 Variant searchFieldColor;
1115 case SEARCH_FIELD_STATUS_NORMAL:
1116 searchFieldColor = GetProperty("searchFieldNormalColor");
1118 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1119 searchFieldColor = GetProperty("searchFieldHighlightedColor");
1121 case SEARCH_FIELD_STATUS_DISABLED:
1122 searchFieldColor = GetProperty("searchFieldDisabledColor");
1128 return searchFieldColor.ToColor();
1133 _SearchBar::GetSearchFieldTextColor(SearchFieldStatus status) const
1135 Variant searchFieldTextColor;
1139 case SEARCH_FIELD_STATUS_NORMAL:
1140 searchFieldTextColor = GetProperty("searchFieldNormalTextColor");
1142 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1143 searchFieldTextColor = GetProperty("searchFieldHighlightedTextColor");
1145 case SEARCH_FIELD_STATUS_DISABLED:
1146 searchFieldTextColor = GetProperty("searchFieldDisabledTextColor");
1152 return searchFieldTextColor.ToColor();
1157 _SearchBar::SetBackgroundBitmap(const Bitmap& bitmap)
1159 Bitmap* pNewBitmap = _BitmapImpl::CloneN(bitmap);
1160 SysTryReturn(NID_UI_CTRL, pNewBitmap != null, E_SYSTEM, E_SYSTEM,
1161 "[%s] A system error has occurred. The creation of bitmap failed.", GetErrorMessage(E_SYSTEM));
1163 delete __pBackgroundBitmap;
1164 __pBackgroundBitmap = null;
1166 __pBackgroundBitmap = pNewBitmap;
1172 _SearchBar::GetBackgroundBitmap(void) const
1174 return __pBackgroundBitmap;
1178 _SearchBar::SetColor(const Color& color)
1180 return SetProperty("color", Variant(color));
1184 _SearchBar::SetSearchFieldColor(SearchFieldStatus status, const Color& color)
1186 result r = E_SUCCESS;
1190 case SEARCH_FIELD_STATUS_NORMAL:
1191 r = SetProperty("searchFieldNormalColor", Variant(color));
1193 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1194 r = SetProperty("searchFieldHighlightedColor", Variant(color));
1196 case SEARCH_FIELD_STATUS_DISABLED:
1197 r = SetProperty("searchFieldDisabledColor", Variant(color));
1208 _SearchBar::SetSearchFieldTextColor(SearchFieldStatus status, const Color& color)
1210 result r = E_SUCCESS;
1214 case SEARCH_FIELD_STATUS_NORMAL:
1215 r = SetProperty("searchFieldNormalTextColor", Variant(color));
1217 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1218 r = SetProperty("searchFieldHighlightedTextColor", Variant(color));
1220 case SEARCH_FIELD_STATUS_DISABLED:
1221 r = SetProperty("searchFieldDisabledTextColor", Variant(color));
1232 _SearchBar::GetGuideText(void) const
1234 SysTryReturn(NID_UI_CTRL, __pEdit != null, String(), E_SYSTEM,
1235 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
1237 return __pEdit->GetGuideText();
1241 _SearchBar::SetGuideText(const String& guideText)
1243 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
1244 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
1246 __pEdit->SetGuideText(guideText);
1252 _SearchBar::GetGuideTextColor(void) const
1254 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
1255 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
1257 return __pEdit->GetGuideTextColor();
1261 _SearchBar::SetGuideTextColor(const Color& color)
1263 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
1264 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
1266 __isUserGuideTextColor = true;
1267 return __pEdit->SetGuideTextColor(color);
1271 _SearchBar::GetCursorPosition(void) const
1273 SysTryReturn(NID_UI_CTRL, __pEdit != null, -1, E_SYSTEM,
1274 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
1276 return __pEdit->GetCursorPosition();
1280 _SearchBar::SetCursorPosition(int index)
1282 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
1283 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
1284 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1285 "[%s] index(%d) is out of range.", GetErrorMessage(E_OUT_OF_RANGE), index);
1287 int textLength = -1;
1288 textLength = __pEdit->GetTextLength();
1290 SysTryReturn(NID_UI_CTRL, (index > -1 && index <= textLength), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1291 "[%s] index(%d) is out of range.", GetErrorMessage(E_OUT_OF_RANGE), index);
1293 return __pEdit->SetCursorPosition(index);
1297 _SearchBar::IsLowerCaseModeEnabled(void) const
1299 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
1300 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
1302 return __pEdit->IsLowerCaseModeEnabled();
1306 _SearchBar::SetLowerCaseModeEnabled(bool enable)
1308 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit != null, E_SYSTEM,
1309 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
1311 __pEdit->SetLowerCaseModeEnabled(enable);
1315 _SearchBar::GetEllipsisPosition(void) const
1317 SysTryReturn(NID_UI_CTRL, __pEdit != null, ELLIPSIS_POSITION_START, E_SYSTEM,
1318 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
1320 return __pEdit->GetEllipsisPosition();
1324 _SearchBar::SetEllipsisPosition(EllipsisPosition position)
1326 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
1327 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
1328 __pEdit->SetEllipsisPosition(position);
1334 _SearchBar::GetKeypadAction(void) const
1336 return __keypadAction;
1340 _SearchBar::IsTextPredictionEnabled(void) const
1342 SysTryReturn(NID_UI_CTRL, __pEdit != null, false, E_SYSTEM,
1343 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
1344 return __pEdit->IsTextPredictionEnabled();
1348 _SearchBar::SetTextPredictionEnabled(bool enable)
1350 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
1351 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
1352 return __pEdit->SetTextPredictionEnabled(enable);
1356 _SearchBar::SetCurrentLanguage(LanguageCode languageCode)
1358 return __pEdit->SetCurrentLanguage(languageCode);
1362 _SearchBar::GetCurrentLanguage(LanguageCode& language) const
1364 return __pEdit->GetCurrentLanguage(language);
1368 _SearchBar::AddActionEventListener(const _IActionEventListener& listener)
1370 result r = E_SUCCESS;
1372 if (__pActionEvent == null)
1374 __pActionEvent = _ActionEvent::CreateInstanceN(*this);
1375 r = GetLastResult();
1376 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1378 __pActionEvent->AddListener(listener);
1385 _SearchBar::RemoveActionEventListener(const _IActionEventListener& listener)
1387 SysTryReturn(NID_UI_CTRL, __pActionEvent != null, E_SYSTEM, E_SYSTEM,
1388 "[%s] A system error has occurred. The action event instance is null.", GetErrorMessage(E_SYSTEM));
1389 result r = E_SUCCESS;
1391 r = __pActionEvent->RemoveListener(listener);
1392 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1398 _SearchBar::AddKeypadEventListener(const _IKeypadEventListener& listener)
1400 result r = E_SUCCESS;
1402 if (__pKeypadEvent == null)
1404 __pKeypadEvent = _KeypadEvent::CreateInstanceN(*this);
1405 r = GetLastResult();
1406 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1408 r = __pKeypadEvent->AddListener(listener);
1409 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1416 _SearchBar::RemoveKeypadEventListener(const _IKeypadEventListener& listener)
1418 SysTryReturn(NID_UI_CTRL, __pKeypadEvent != null, E_SYSTEM, E_SYSTEM,
1419 "[%s] A system error has occurred. The keypad event instance is null.", GetErrorMessage(E_SYSTEM));
1420 result r = E_SUCCESS;
1422 r = __pKeypadEvent->RemoveListener(listener);
1423 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1429 _SearchBar::AddTextBlockEventListener(const _ITextBlockEventListener& listener)
1431 result r = E_SUCCESS;
1433 if (__pTextBlockEvent == null)
1435 __pTextBlockEvent = _TextBlockEvent::CreateInstanceN(*this);
1436 r = GetLastResult();
1437 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1439 r = __pTextBlockEvent->AddListener(listener);
1440 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1448 _SearchBar::RemoveTextBlockEventListener(const _ITextBlockEventListener& listener)
1450 SysTryReturn(NID_UI_CTRL, __pTextBlockEvent != null, E_SYSTEM, E_SYSTEM,
1451 "[%s] A system error has occurred. The text block event instance is null.", GetErrorMessage(E_SYSTEM));
1452 result r = E_SUCCESS;
1454 r = __pTextBlockEvent->RemoveListener(listener);
1455 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1462 _SearchBar::AddTextEventListener(const _ITextEventListener& listener)
1464 result r = E_SUCCESS;
1466 if (__pTextEvent == null)
1468 __pTextEvent = _TextEvent::CreateInstanceN(*this);
1469 r = GetLastResult();
1470 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1472 r = __pTextEvent->AddListener(listener);
1473 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1480 _SearchBar::RemoveTextEventListener(const _ITextEventListener& listener)
1482 SysTryReturn(NID_UI_CTRL, __pTextEvent != null, E_SYSTEM, E_SYSTEM,
1483 "[%s] A system error has occurred. The text event instance is null.", GetErrorMessage(E_SYSTEM));
1484 result r = E_SUCCESS;
1486 r = __pTextEvent->RemoveListener(listener);
1487 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1493 _SearchBar::AddSearchBarEventListener(const _ISearchBarEventListener& listener)
1495 result r = E_SUCCESS;
1497 if (__pSearchBarEvent == null)
1499 __pSearchBarEvent = _SearchBarEvent::CreateInstanceN(*this);
1500 r = GetLastResult();
1501 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1503 r = __pSearchBarEvent->AddListener(listener);
1504 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1511 _SearchBar::RemoveSearchBarEventListener(const _ISearchBarEventListener& listener)
1513 SysTryReturn(NID_UI_CTRL, __pSearchBarEvent != null, E_SYSTEM, E_SYSTEM,
1514 "[%s] A system error has occurred. The searchbar event instance is null.", GetErrorMessage(E_SYSTEM));
1515 result r = E_SUCCESS;
1517 r = __pSearchBarEvent->RemoveListener(listener);
1518 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1524 _SearchBar::AddLanguageEventListener(const _ILanguageEventListener& listener)
1526 result r = E_SUCCESS;
1528 if (__pLanguageEvent == null)
1530 __pLanguageEvent = _LanguageEvent::CreateInstanceN(*this);
1531 r = GetLastResult();
1532 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1534 r = __pLanguageEvent->AddListener(listener);
1535 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1542 _SearchBar::RemoveLanguageEventListener(const _ILanguageEventListener& listener)
1544 SysTryReturn(NID_UI_CTRL, __pLanguageEvent != null, E_SYSTEM, E_SYSTEM, "[%s] This instance isn't constructed.", GetErrorMessage(E_SYSTEM));
1545 result r = E_SUCCESS;
1547 __pLanguageEvent->RemoveListener(listener);
1548 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1554 _SearchBar::OnBoundsChanged(void)
1556 if (__pSearchBarPresenter != null)
1558 __isupdateContentBounds = true;
1559 __pSearchBarPresenter->OnBoundsChanged();
1562 if (__pAccessibilitySearchBarElement != null)
1564 __pAccessibilitySearchBarElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height));
1569 RemoveFocusRing(true);
1570 if (IsFocusModeStateEnabled())
1580 _SearchBar::OnChangeLayout(_ControlOrientation orientation)
1582 __isupdateContentBounds = true;
1587 _SearchBar::OnDraw(void)
1589 if (!__isUserGuideTextColor)
1591 SearchFieldStatus status = GetCurrentStatus();
1592 __pEdit->SetGuideTextColor(__guideTextColor[status]);
1595 if (__isupdateContentBounds)
1598 __isupdateContentBounds = false;
1600 __pSearchBarPresenter->Draw();
1604 _UiTouchEventDelivery
1605 _SearchBar::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1607 if (&source == __pEdit)
1609 __isTouchMoved = true;
1612 return _UI_TOUCH_EVENT_DELIVERY_YES;
1615 _UiTouchEventDelivery
1616 _SearchBar::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1618 _Edit* pEdit = dynamic_cast <_Edit*>(const_cast <_Control*>(&source));
1621 return _UI_TOUCH_EVENT_DELIVERY_YES;
1624 if (pEdit->IsClearIconPressed())
1626 __isTouchMoved = false;
1627 return _UI_TOUCH_EVENT_DELIVERY_YES;
1630 SetContentAreaVisible(__contentVisibilitySetByApp); //When a touch happens on SearchField
1631 SetFocusCallbackParameter(true);
1633 if (!__isTouchMoved)
1635 SetMode(SEARCH_BAR_MODE_INPUT);
1638 __isTouchMoved = false;
1639 return _UI_TOUCH_EVENT_DELIVERY_YES;
1642 _UiTouchEventDelivery
1643 _SearchBar::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1645 __isTouchMoved = false;
1646 return _UI_TOUCH_EVENT_DELIVERY_YES;
1650 _SearchBar::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1652 __pSearchBarPresenter->OnTouchReleased(source);
1657 _SearchBar::FireButtonActionEvent(const _Control &source, int actionId)
1659 if (__actionId == actionId)
1661 __isCancelActionInProgress = true;
1662 SetFocusCallbackParameter(true);
1663 SetMode(SEARCH_BAR_MODE_NORMAL);
1667 if (__pActionEvent != null)
1669 IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(__actionId);
1670 result r = GetLastResult();
1671 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r));
1673 __pActionEvent->Fire(*pEventArg);
1675 __isCancelActionInProgress = false;
1680 _SearchBar::OnActionPerformed(const _Control& source, int actionId)
1682 FireButtonActionEvent(source, actionId);
1688 _SearchBar::OnKeypadWillOpen(void)
1690 if (!__isKeypadOpening)
1692 if (__pKeypadEvent != null)
1694 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CREATED);
1695 result r = GetLastResult();
1696 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r));
1698 __pKeypadEvent->Fire(*pEventArg);
1702 __isKeypadOpening = true;
1707 _SearchBar::OnKeypadOpened(void)
1709 if (__pKeypadEvent != null)
1711 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_OPEN);
1712 result r = GetLastResult();
1713 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r));
1715 __pKeypadEvent->Fire(*pEventArg);
1718 __isKeypadOpening = false;
1724 _SearchBar::OnKeypadClosed(void)
1726 if (__pKeypadEvent != null)
1728 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CLOSE);
1729 result r = GetLastResult();
1730 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r));
1732 __pKeypadEvent->Fire(*pEventArg);
1735 __isKeypadOpening = false;
1742 _SearchBar::OnKeypadBoundsChanged(void)
1744 if (__pKeypadEvent != null)
1746 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1747 result r = GetLastResult();
1748 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r));
1750 __pKeypadEvent->Fire(*pEventArg);
1758 _SearchBar::OnKeypadActionPerformed(CoreKeypadAction keypadAction)
1760 if (__pKeypadEvent != null)
1762 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(keypadAction, CORE_KEYPAD_EVENT_STATUS_ENTERACTION);
1763 result r = GetLastResult();
1764 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r));
1766 __pKeypadEvent->Fire(*pEventArg);
1771 // TextBlock callbacks
1773 _SearchBar::OnTextBlockSelected(_Control& source, int start, int end)
1775 if (__pTextBlockEvent != null)
1777 IEventArg* pEventArg = _TextBlockEvent::CreateTextBlockEventArgN(start, end);
1778 result r = GetLastResult();
1779 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r));
1781 __pTextBlockEvent->Fire(*pEventArg);
1788 _SearchBar::OnTextValueChanged(const _Control& source)
1790 if (GetTextLength())
1792 SetContentAreaVisible(__contentVisibilitySetByApp);
1795 if (!__isCancelActionInProgress)
1797 SetContentDimming();
1798 if (__pTextEvent != null)
1800 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CHANGED);
1801 result r = GetLastResult();
1802 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r));
1804 __pTextEvent->Fire(*pEventArg);
1811 _SearchBar::OnTextValueChangeCanceled(const _Control& source)
1813 if (__pTextEvent != null)
1815 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CANCELED);
1816 result r = GetLastResult();
1817 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r));
1819 __pTextEvent->Fire(*pEventArg);
1825 _SearchBar::OnAttachedToMainTree(void)
1832 _SearchBar::OnFontChanged(Font* pFont)
1834 __pCancelButton->SetFont(pFont->GetFaceName());
1835 __pEdit->SetFont(*pFont);
1840 _SearchBar::OnFontInfoRequested(unsigned long& style, int& size)
1842 style = FONT_STYLE_PLAIN;
1843 size = __pCancelButton->GetTextSize();
1849 _SearchBar::OnFocusGained(const _Control& source)
1851 return _Control::OnFocusGained(source);
1855 _SearchBar::OnFocusLost(const _Control &source)
1857 return _Control::OnFocusLost(source);
1861 _SearchBar::OnDrawFocus(void)
1863 __isFocusUiInitialized = true;
1864 _Control::OnDrawFocus();
1870 _SearchBar::IsChildControlFocusManage(void) const
1876 _SearchBar::OnPreviewKeyPressed(const _Control &source, const _KeyInfo &keyInfo)
1878 if (!__pEdit->IsUsbKeyboardConnected())
1883 _KeyCode keyCode = keyInfo.GetKeyCode();
1885 if (keyCode == _KEY_TAB && GetMode() == SEARCH_BAR_MODE_INPUT && __isFocusUiInitialized == false)
1887 __isFocusUiInitialized = true;
1896 SetFocusCallbackParameter(true);
1897 if ((__pContentControl && __pContentControl->IsVisible() == false) || !__pContentControl)
1899 SetContentAreaVisible(false);
1910 _SearchBar::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1912 if (!__pEdit->IsUsbKeyboardConnected())
1922 _FocusManagerImpl* pFocusMgrImpl = _FocusManagerImpl::GetInstance();
1923 if (!pFocusMgrImpl->IsFocusModeStateEnabled())
1928 _KeyCode keyCode = keyInfo.GetKeyCode();
1933 if (&source == this)
1935 SetContentAreaVisible(__contentVisibilitySetByApp);
1936 SetFocusCallbackParameter(true);
1937 SetMode(SEARCH_BAR_MODE_INPUT);
1938 __pEdit->SetFocused();
1941 SetFocusCallbackParameter(false);
1943 if (&source == __pEdit)
1945 if ((!__isButtonEnabled || !__isUsableCancelButton) && __pContentControl && __pContentControl->IsVisible() && __pContentControl->GetEnableState())
1947 __pContentControl->SetFocused();
1948 __pContentControl->OnDrawFocus();
1952 else if (__isButtonEnabled && __isUsableCancelButton)
1954 __pCancelButton->SetFocused();
1960 if (&source == __pCancelButton && __pContentControl && __pContentControl->IsVisible() && __pContentControl->GetEnableState())
1962 __pContentControl->SetFocused();
1963 __pContentControl->OnDrawFocus();
1971 if (&source == __pCancelButton)
1973 __pEdit->SetFocused();
1977 if (&source == __pContentControl)
1979 if ((__isButtonEnabled && __isUsableCancelButton))
1981 __pCancelButton->SetFocused();
1985 __pEdit->SetFocused();
1993 if (&source == __pCancelButton)
1995 FireButtonActionEvent(source, __actionId);
1996 _Control::OnDrawFocus();
2011 _SearchBar::OnSettingChanged(Tizen::Base::String& key)
2013 if (__isButtonTextChangedByApp || !__isUsableCancelButton)
2018 if (key.Equals(L"http://tizen.org/setting/locale.language", false))
2021 GET_STRING_CONFIG(IDS_TPLATFORM_BUTTON_CANCEL_ABB, cancelText);
2022 __pCancelButton->SetText(cancelText);
2023 __pCancelButton->Invalidate();
2030 _SearchBar::OnCanvasRequestedN(const FloatRectangle& bounds)
2032 return __pSearchBarPresenter->OnCanvasRequestedN(bounds);
2036 _SearchBar::GetParentForm(void) const
2038 _Form* pForm = null;
2039 _Control* pControlCore = GetParent();
2043 if (pControlCore == null)
2045 SysLog(NID_UI_CTRL,"[E_SYSTEM] The parent form is null.");
2050 pForm = dynamic_cast <_Form*>(pControlCore);
2057 pControlCore = pControlCore->GetParent();
2060 return pControlCore;
2064 _SearchBar::GetSearchBarButton(void) const
2066 return __pCancelButton;
2070 _SearchBar::GetSearchField(void)
2076 _SearchBar::GetSearchBarContainer(void) const
2078 return __pContainer;
2082 _SearchBar::GetClippedGroupControl(void) const
2084 return __pClippedGroupControl;
2088 _SearchBar::IsUsableCancelButton(void) const
2090 return __isUsableCancelButton;
2094 _SearchBar::ConvertSearchBarStatus(SearchFieldStatus status)
2096 EditStatus editStatus = EDIT_STATUS_NORMAL;
2099 case SEARCH_FIELD_STATUS_NORMAL:
2100 editStatus = EDIT_STATUS_NORMAL;
2103 case SEARCH_FIELD_STATUS_DISABLED:
2104 editStatus = EDIT_STATUS_DISABLED;
2107 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
2108 editStatus = EDIT_STATUS_HIGHLIGHTED;
2118 _SearchBar::ConvertSearchBarButtonStatus(SearchBarButtonStatus status)
2120 _ButtonStatus buttonStatus = _BUTTON_STATUS_NORMAL;
2124 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
2125 buttonStatus = _BUTTON_STATUS_NORMAL;
2128 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
2129 buttonStatus = _BUTTON_STATUS_PRESSED;
2132 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
2133 buttonStatus = _BUTTON_STATUS_HIGHLIGHTED;
2136 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
2137 buttonStatus = _BUTTON_STATUS_DISABLED;
2143 return buttonStatus;
2147 _SearchBar::SendSearchBarEvent(_SearchBarEventStatus status)
2149 result r = E_SUCCESS;
2150 if (__pSearchBarEvent != null)
2152 IEventArg* pEventArg = _SearchBarEvent::CreateSearchBarEventArgN(status);
2153 r = GetLastResult();
2154 SysTryReturn(NID_UI_CTRL, pEventArg != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
2156 if (!IsContentAreaVisible())
2158 SetContentAreaVisible(false);
2161 __pSearchBarEvent->Fire(*pEventArg);
2168 _SearchBar::SetHeaderVisibleState(bool visible)
2170 if (__pSearchBarPresenter != null)
2172 __pSearchBarPresenter->SetHeaderVisibleState(visible);
2178 _SearchBar::SetPropertyButtonActionId(const Variant& actionId)
2180 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, E_SYSTEM, E_SYSTEM,
2181 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
2182 SysTryReturn(NID_UI_CTRL, actionId.ToInt() > -1, E_INVALID_ARG, E_INVALID_ARG,
2183 "[%s] Invalid argument(s) is used. actionId.ToInt() = %d", GetErrorMessage(E_INVALID_ARG), actionId.ToInt());
2185 result r = E_SUCCESS;
2187 r = __pCancelButton->SetPropertyActionId(actionId);
2188 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2189 "[%s] A system error has occurred. Failed to set actionId.", GetErrorMessage(E_SYSTEM));
2191 __actionId = actionId.ToInt();
2197 _SearchBar::GetPropertyButtonActionId(void) const
2199 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, Variant(-1), E_SYSTEM,
2200 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
2202 return Variant(__actionId);
2206 _SearchBar::SetPropertyButtonDisabledColor(const Variant& color)
2208 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, E_SYSTEM, E_SYSTEM,
2209 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
2211 result r = E_SUCCESS;
2213 r = __pCancelButton->SetPropertyDisabledColor(color);
2214 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2215 "[%s] A system error has occurred. Failed to set button color.", GetErrorMessage(E_SYSTEM));
2217 __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = color.ToColor();
2223 _SearchBar::GetPropertyButtonDisabledColor(void) const
2225 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, Variant(Color()), E_SYSTEM,
2226 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
2228 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2232 _SearchBar::SetPropertyButtonHighlightedColor(const Variant& color)
2234 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, E_SYSTEM, E_SYSTEM,
2235 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
2237 result r = E_SUCCESS;
2239 r = __pCancelButton->SetPropertyHighlightedColor(color);
2240 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2241 "[%s] A system error has occurred. Failed to set button color.", GetErrorMessage(E_SYSTEM));
2243 __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
2249 _SearchBar::GetPropertyButtonHighlightedColor(void) const
2251 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, Variant(Color()), E_SYSTEM,
2252 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
2254 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2258 _SearchBar::SetPropertyButtonNormalColor(const Variant& color)
2260 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, E_SYSTEM, E_SYSTEM,
2261 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
2263 result r = E_SUCCESS;
2265 r = __pCancelButton->SetPropertyNormalColor(color);
2266 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2267 "[%s] A system error has occurred. Failed to set button color.", GetErrorMessage(E_SYSTEM));
2269 __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = color.ToColor();
2275 _SearchBar::GetPropertyButtonNormalColor(void) const
2277 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, Variant(Color()), E_SYSTEM,
2278 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
2280 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2284 _SearchBar::SetPropertyButtonPressedColor(const Variant& color)
2286 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, E_SYSTEM, E_SYSTEM,
2287 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
2289 result r = E_SUCCESS;
2291 r = __pCancelButton->SetPropertyPressedColor(color);
2292 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2293 "[%s] A system error has occurred. Failed to set button color.", GetErrorMessage(E_SYSTEM));
2295 __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = color.ToColor();
2301 _SearchBar::GetPropertyButtonPressedColor(void) const
2303 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, Variant(Color()), E_SYSTEM,
2304 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
2306 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2310 _SearchBar::SetPropertyButtonDisabledTextColor(const Variant& textColor)
2312 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, E_SYSTEM, E_SYSTEM,
2313 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
2315 result r = E_SUCCESS;
2317 r = __pCancelButton->SetPropertyDisabledTextColor(textColor);
2318 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2319 "[%s] A system error has occurred. Failed to set button text color.", GetErrorMessage(E_SYSTEM));
2321 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = textColor.ToColor();
2327 _SearchBar::GetPropertyButtonDisabledTextColor(void) const
2329 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, Variant(Color()), E_SYSTEM,
2330 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
2332 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2336 _SearchBar::SetPropertyButtonHighlightedTextColor(const Variant& textColor)
2338 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, E_SYSTEM, E_SYSTEM,
2339 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
2341 result r = E_SUCCESS;
2343 r = __pCancelButton->SetPropertyHighlightedTextColor(textColor);
2344 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2345 "[%s] A system error has occurred. Failed to set button text color.", GetErrorMessage(E_SYSTEM));
2347 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = textColor.ToColor();
2353 _SearchBar::GetPropertyButtonHighlightedTextColor(void) const
2355 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, Variant(Color()), E_SYSTEM,
2356 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
2358 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2362 _SearchBar::SetPropertyButtonNormalTextColor(const Variant& textColor)
2364 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, E_SYSTEM, E_SYSTEM,
2365 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
2367 result r = E_SUCCESS;
2369 r = __pCancelButton->SetPropertyNormalTextColor(textColor);
2370 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2371 "[%s] A system error has occurred. Failed to set button text color.", GetErrorMessage(E_SYSTEM));
2373 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = textColor.ToColor();
2379 _SearchBar::GetPropertyButtonNormalTextColor(void) const
2381 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, Variant(Color()), E_SYSTEM,
2382 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
2384 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2388 _SearchBar::SetPropertyButtonPressedTextColor(const Variant& textColor)
2390 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, E_SYSTEM, E_SYSTEM,
2391 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
2393 result r = E_SUCCESS;
2395 r = __pCancelButton->SetPropertyPressedTextColor(textColor);
2396 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2397 "[%s] A system error has occurred. Failed to set button text color.", GetErrorMessage(E_SYSTEM));
2399 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = textColor.ToColor();
2405 _SearchBar::GetPropertyButtonPressedTextColor(void) const
2407 SysTryReturn(NID_UI_CTRL, __pCancelButton != null, Variant(Color()), E_SYSTEM,
2408 "[%s] A system error has occurred. The _Button instance is null.", GetErrorMessage(E_SYSTEM));
2410 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2414 _SearchBar::SetPropertySearchFieldDisabledColor(const Variant& color)
2416 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
2417 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
2419 result r = E_SUCCESS;
2421 r = __pEdit->SetPropertyDisabledColor(color);
2422 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2423 "[%s] A system error has occurred. Failed to set the edit disabled color.", GetErrorMessage(E_SYSTEM));
2425 __color[SEARCH_FIELD_STATUS_DISABLED] = color.ToColor();
2431 _SearchBar::GetPropertySearchFieldDisabledColor(void) const
2433 SysTryReturn(NID_UI_CTRL, __pEdit != null, Variant(Color()), E_SYSTEM,
2434 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
2436 return Variant(__color[SEARCH_FIELD_STATUS_DISABLED]);
2440 _SearchBar::SetPropertySearchFieldHighlightedColor(const Variant& color)
2442 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
2443 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
2445 result r = E_SUCCESS;
2447 r = __pEdit->SetPropertyHighlightedColor(color);
2448 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2449 "[%s] A system error has occurred. Failed to set the edit highlighted color.", GetErrorMessage(E_SYSTEM));
2451 __color[SEARCH_FIELD_STATUS_HIGHLIGHTED] = color.ToColor();
2457 _SearchBar::GetPropertySearchFieldHighlightedColor(void) const
2459 SysTryReturn(NID_UI_CTRL, __pEdit != null, Variant(Color()), E_SYSTEM,
2460 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
2462 return Variant(__color[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2466 _SearchBar::SetPropertySearchFieldNormalColor(const Variant& color)
2468 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
2469 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
2471 result r = E_SUCCESS;
2473 r = __pEdit->SetPropertyNormalColor(color);
2474 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2475 "[%s] A system error has occurred. Failed to set edit normal color.", GetErrorMessage(E_SYSTEM));
2477 __color[SEARCH_FIELD_STATUS_NORMAL] = color.ToColor();
2483 _SearchBar::GetPropertySearchFieldNormalColor(void) const
2485 SysTryReturn(NID_UI_CTRL, __pEdit != null, Variant(Color()), E_SYSTEM,
2486 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
2488 return Variant(__color[SEARCH_FIELD_STATUS_NORMAL]);
2492 _SearchBar::SetPropertySearchFieldDisabledTextColor(const Variant& textColor)
2494 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
2495 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
2497 result r = E_SUCCESS;
2499 r = __pEdit->SetPropertyDisabledTextColor(textColor);
2500 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2501 "[%s] A system error has occurred. Failed to set edit disabled text color.", GetErrorMessage(E_SYSTEM));
2503 __textColor[SEARCH_FIELD_STATUS_DISABLED] = textColor.ToColor();
2509 _SearchBar::GetPropertySearchFieldDisabledTextColor(void) const
2511 SysTryReturn(NID_UI_CTRL, __pEdit != null, Variant(Color()), E_SYSTEM,
2512 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
2514 return Variant(__textColor[SEARCH_FIELD_STATUS_DISABLED]);
2518 _SearchBar::SetPropertySearchFieldHighlightedTextColor(const Variant& textColor)
2520 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
2521 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
2523 result r = E_SUCCESS;
2525 r = __pEdit->SetPropertyHighlightedTextColor(textColor);
2526 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2527 "[%s] A system error has occurred. Failed to set edit highlighted text color.", GetErrorMessage(E_SYSTEM));
2529 __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED] = textColor.ToColor();
2535 _SearchBar::GetPropertySearchFieldHighlightedTextColor(void) const
2537 SysTryReturn(NID_UI_CTRL, __pEdit != null, Variant(Color()), E_SYSTEM,
2538 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
2540 return Variant(__textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2544 _SearchBar::SetPropertySearchFieldNormalTextColor(const Variant& textColor)
2546 SysTryReturn(NID_UI_CTRL, __pEdit != null, E_SYSTEM, E_SYSTEM,
2547 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
2549 result r = E_SUCCESS;
2551 r = __pEdit->SetPropertyNormalTextColor(textColor);
2552 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2553 "[%s] A system error has occurred. Failed to set edit normal text color.", GetErrorMessage(E_SYSTEM));
2555 __textColor[SEARCH_FIELD_STATUS_NORMAL] = textColor.ToColor();
2561 _SearchBar::GetPropertySearchFieldNormalTextColor(void) const
2563 SysTryReturn(NID_UI_CTRL, __pEdit != null, Variant(Color()), E_SYSTEM,
2564 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
2566 return Variant(__textColor[SEARCH_FIELD_STATUS_NORMAL]);
2570 _SearchBar::SetPropertyColor(const Variant& color)
2572 __backgroundColor = color.ToColor();
2578 _SearchBar::GetPropertyColor(void) const
2580 return Variant(__backgroundColor);
2584 _SearchBar::SetPropertyContentAreaSize(const Variant& size)
2586 FloatDimension contentAreaSize = size.ToFloatDimension();
2587 SysTryReturn(NID_UI_CTRL, contentAreaSize.width >= 0 && contentAreaSize.height >= 0, E_INVALID_ARG, E_INVALID_ARG,
2588 "[%s] Invalid argument(s) is used. contentAreaSize.width = %f, contenAreaSize.height = %f",
2589 GetErrorMessage(E_INVALID_ARG), contentAreaSize.width, contentAreaSize.height);
2591 result r = E_SUCCESS;
2594 FloatRectangle bounds = GetBoundsF();
2595 FloatRectangle contentAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
2597 contentAreaBounds.x = 0.0f;
2598 contentAreaBounds.y = bounds.height;
2599 contentAreaBounds.width = contentAreaSize.width;
2600 contentAreaBounds.height = contentAreaSize.height;
2602 __contentAreaBounds = contentAreaBounds;
2603 __isUserContainerBounds = true;
2606 if (__pContainer != null)
2608 r = __pContainer->SetBounds(__contentAreaBounds);
2609 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2616 _SearchBar::GetPropertyContentAreaSize(void) const
2618 FloatDimension contentAreaSize(__contentAreaBounds.width, __contentAreaBounds.height);
2620 return Variant(contentAreaSize);
2624 _SearchBar::CreateClippedGroupControl(void)
2626 result r = E_SUCCESS;
2627 FloatRectangle clippedGroupControlBounds(FloatPoint(0.0f, 0.0f), GetSizeF());
2628 __pClippedGroupControl = _Control::CreateControlN();
2629 r = GetLastResult();
2630 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2632 r = AttachChild(*__pClippedGroupControl);
2633 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
2634 "[E_SYSTEM] A system error has occurred. Failed to attach the parent of clipped control.");
2636 r = __pClippedGroupControl->SetBounds(clippedGroupControlBounds);
2637 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2639 __pClippedGroupControl->SetBackgroundColor(Color(0));
2641 __pClippedGroupControl->SetClipChildrenEnabled(true);
2646 delete __pClippedGroupControl;
2647 __pClippedGroupControl = null;
2653 _SearchBar::InitializeAccessibility(void)
2655 _AccessibilityContainer* pSBContainer = null;
2656 pSBContainer = GetAccessibilityContainer();
2658 _AccessibilityContainer* pEditContainer = null;
2659 pEditContainer = __pEdit->GetAccessibilityContainer();
2660 pSBContainer->AddChildContainer(*pEditContainer);
2662 _AccessibilityContainer* pButtonContainer = null;
2663 pButtonContainer = __pCancelButton->GetAccessibilityContainer();
2665 if (__isUsableCancelButton)
2667 pSBContainer->AddChildContainer(*pButtonContainer);
2670 _AccessibilityElement* pEditElement = __pEdit->GetTextAccessibilityElement();
2672 // pEditElement->SetHintWithStringId("Double Tap To Type Search Text");
2673 // pEditElement->SetTrait("SearchBar");
2674 pEditElement->SetName("SearchField");
2676 pSBContainer->Activate(false);
2682 _SearchBar::SetContentDimming(void)
2684 if (__pContainer != null)
2686 if (!GetTextLength())
2688 __contentColor.SetAlpha(_SEARCH_CONTENT_DIM_OPACITY);
2692 __contentColor.SetAlpha(0);
2694 __pContainer->SetBackgroundColor(__contentColor);
2700 _SearchBar::IsContentAttachable(const _Control* pContent)
2702 const _Window* pWindow = dynamic_cast <const _Window*>(pContent);
2703 const _ColorPicker* pColorPicker = dynamic_cast <const _ColorPicker*>(pContent);
2704 const _Form* pForm = dynamic_cast <const _Form*>(pContent);
2705 const _Keypad* pKeypad = dynamic_cast <const _Keypad*>(pContent);
2706 const _OverlayPanel* pOverlayPanel = dynamic_cast <const _OverlayPanel*>(pContent);
2708 bool isContentAttachable = true;
2710 isContentAttachable = ((pWindow == null) && (pColorPicker == null) &&
2711 (pForm == null) && (pKeypad == null) && (pOverlayPanel == null));
2712 return isContentAttachable;
2716 _SearchBar::ResizeCancelButton(void)
2718 result r = E_SUCCESS;
2720 float horizontalMargin = 0.0f;
2721 float buttonLeftMargin = 0.0f;
2722 float buttonRightMargin = 0.0f;
2723 float buttonMinWidth = 0.0f;
2724 float searchFieldMinWidth = 0.0f;
2725 float buttonVerticalMargin = 0.0f;
2726 float searchBarMinHeight = 0.0f;
2727 float buttonWidth = 0.0f;
2728 float buttonHeight = 0.0f;
2730 FloatRectangle cancelButtonBounds;
2731 FloatRectangle searchBarBounds = GetBoundsF();
2733 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2735 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2736 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2737 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2738 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2739 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2740 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2741 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2742 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2743 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2745 cancelButtonBounds.width = buttonWidth;
2746 cancelButtonBounds.height = buttonHeight;
2748 float buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth +
2749 cancelButtonBounds.width + buttonLeftMargin + buttonRightMargin);
2751 if (searchBarBounds.width < buttonResizableSearchBarWidth)
2753 cancelButtonBounds.width = searchBarBounds.width -(searchFieldMinWidth + buttonLeftMargin
2754 + buttonRightMargin + horizontalMargin);
2757 cancelButtonBounds.x = searchBarBounds.width - cancelButtonBounds.width - buttonRightMargin;
2758 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2760 cancelButtonBounds.y = cancelButtonBounds.y < 0.0f ? 0.0f:cancelButtonBounds.y;
2762 if (cancelButtonBounds.width < buttonMinWidth)
2764 cancelButtonBounds.width = buttonMinWidth;
2767 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2768 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2769 r = __pCancelButton->SetBounds(cancelButtonBounds);
2775 _SearchBar::RecalculateButtonBounds(void)
2777 result r = E_SUCCESS;
2779 float horizontalMargin = 0.0f;
2780 float verticalMargin = 0.0f;
2781 float buttonLeftMargin = 0.0f;
2782 float buttonRightMargin = 0.0f;
2783 float buttonMinWidth = 0.0f;
2784 float searchFieldMinWidth = 0.0f;
2785 float buttonVerticalMargin = 0.0f;
2786 float searchBarMinHeight = 0.0f;
2787 float buttonWidth = 0.0f;
2788 float buttonHeight = 0.0f;
2789 float cancelButtonWidth = 0.0f;
2791 FloatRectangle cancelButtonBounds;
2792 FloatRectangle editBounds;
2793 FloatRectangle searchBarBounds = GetBoundsF();
2795 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2797 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2798 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin);
2799 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2800 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2801 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2802 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2803 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2804 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2805 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2806 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2808 cancelButtonBounds.height = buttonHeight;
2810 float searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2.0f);
2811 cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF();
2812 editBounds.x = horizontalMargin;
2814 if (searchBarBounds.height < searchBarMinHeight)
2816 verticalMargin = (searchBarBounds.height - searchFieldMinHeight)/2.0f;
2817 if (verticalMargin < 0.0f)
2819 verticalMargin = 0.0f;
2823 editBounds.y = verticalMargin;
2824 editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
2826 editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
2828 editBounds.width = searchBarBounds.width - cancelButtonWidth - horizontalMargin - buttonLeftMargin - buttonRightMargin;
2830 if (editBounds.width < searchFieldMinWidth)
2832 editBounds.width = searchFieldMinWidth;
2835 cancelButtonBounds.x = editBounds.width + horizontalMargin + buttonLeftMargin;
2836 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2838 cancelButtonBounds.y = cancelButtonBounds.y < 0.0f ? 0.0f:cancelButtonBounds.y;
2840 float remainingWidth = searchBarBounds.width - editBounds.width - horizontalMargin - buttonLeftMargin - buttonRightMargin;
2842 if (remainingWidth < buttonMinWidth)
2844 cancelButtonBounds.width = buttonMinWidth;
2848 cancelButtonBounds.width = searchBarBounds.width - cancelButtonBounds.x - buttonRightMargin;
2851 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2852 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2854 r = __pCancelButton->SetBounds(cancelButtonBounds);
2855 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2856 r = __pEdit->SetBounds(editBounds);
2857 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2863 _SearchBar::GetCurrentStatus(void)
2865 SearchFieldStatus searchFieldStatus = SEARCH_FIELD_STATUS_NORMAL;
2869 if (__pEdit->IsFocused())
2871 searchFieldStatus = SEARCH_FIELD_STATUS_HIGHLIGHTED;
2876 searchFieldStatus = SEARCH_FIELD_STATUS_DISABLED;
2879 return searchFieldStatus;
2883 _SearchBar::SetEditTextFilter(IEditTextFilter* pFilter)
2885 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit != null, E_SYSTEM,
2886 "[%s] A system error has occurred. The _Edit instance is null.", GetErrorMessage(E_SYSTEM));
2888 __pEdit->SetEditTextFilter(pFilter);
2894 _SearchBar::SendOpaqueCommand(const String& command)
2896 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit != null, E_SYSTEM,
2897 "[E_SYSTEM] A system error has occurred. The _Edit instance is null.");
2899 __pEdit->SendOpaqueCommand(command);
2905 _SearchBar::SetFocusCallbackParameter(bool state)
2907 __isFocusCallbackToBeFired = state;
2912 _SearchBar::IsFocusCallbackToBeFired(void) const
2914 return __isFocusCallbackToBeFired;
2916 }}} // Tizen::Ui::Controls