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"
47 using namespace Tizen::Graphics;
48 using namespace Tizen::Ui;
49 using namespace Tizen::Ui::Animations;
50 using namespace Tizen::Base;
51 using namespace Tizen::Base::Runtime;
52 using namespace Tizen::Locales;
54 namespace Tizen { namespace Ui { namespace Controls
57 IMPLEMENT_PROPERTY(_SearchBar);
59 _SearchBar::_SearchBar(void)
60 : __pSearchBarPresenter(null)
61 , __pClippedGroupControl(null)
63 , __pCancelButton(null)
65 , __pContentControl(null)
68 , __isButtonEnabled(true)
69 , __isUsableCancelButton(false)
70 , __isUserContainerBounds(false)
71 , __isCancelActionInProgress(false)
72 , __isUserGuideTextColor(false)
73 , __isKeypadOpening(false)
74 , __isupdateContentBounds(false)
75 , __isKeyPressed(false)
76 , __isFocusCallbackToBeFired(true)
77 , __keypadAction(CORE_KEYPAD_ACTION_SEARCH)
78 , __pBackgroundBitmap(null)
79 , __backgroundColor(Color())
80 , __contentColor(Color())
81 , __pActionEvent(null)
82 , __pKeypadEvent(null)
83 , __pTextBlockEvent(null)
85 , __pSearchBarEvent(null)
86 , __pLanguageEvent(null)
87 , __pAccessibilitySearchBarElement(null)
89 for (int i = 0; i < SEARCHBAR_BUTTON_COLOR_MAX; i++)
91 __buttonColor[i] = Color(0);
92 __buttonTextColor[i] = Color(0);
95 for (int i = 0; i < SEARCHBAR_COLOR_MAX; i++)
97 __color[i] = Color(0);
98 __textColor[i] = Color(0);
99 __guideTextColor[i] = Color(0);
102 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
105 pContainer->Activate(true);
109 _SearchBar::~_SearchBar(void)
111 delete __pSearchBarPresenter;
112 __pSearchBarPresenter = null;
114 if (__pClippedGroupControl)
116 DetachChild(*__pClippedGroupControl);
118 delete __pClippedGroupControl;
119 __pClippedGroupControl = null;
124 DetachChild(*__pContainer);
132 delete __pActionEvent;
133 __pActionEvent = null;
138 delete __pKeypadEvent;
139 __pKeypadEvent = null;
142 if (__pTextBlockEvent)
144 delete __pTextBlockEvent;
145 __pTextBlockEvent = null;
154 if (__pSearchBarEvent)
156 delete __pSearchBarEvent;
157 __pSearchBarEvent = null;
160 if (__pAccessibilitySearchBarElement)
162 __pAccessibilitySearchBarElement->Activate(false);
163 __pAccessibilitySearchBarElement = null;
166 delete __pBackgroundBitmap;
167 __pBackgroundBitmap = null;
171 _SearchBar::CreateSearchBarN(void)
173 _SearchBar* pSearchBar = new (std::nothrow) _SearchBar;
174 SysTryReturn(NID_UI_CTRL, pSearchBar, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
175 if (GetLastResult() != E_SUCCESS)
181 pSearchBar->AcquireHandle();
182 pSearchBar->SetTouchPressThreshold(_TOUCH_PRESS_THRESHOLD_INSENSITIVE);
188 _SearchBar::Initialize(bool enableSearchBarButton, CoreKeypadAction keypadAction)
190 result r = E_SUCCESS;
192 // Setting Button color
193 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_NORMAL, __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
194 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_PRESSED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
195 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_HIGHLIGHTED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
196 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_DISABLED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
198 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_NORMAL, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
199 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_PRESSED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
200 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_HIGHLIGHTED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
201 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_DISABLED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
203 GET_COLOR_CONFIG(SEARCHBAR::CONTENT_AREA_BG_NORMAL, __contentColor);
205 for (int i = 0; i < SEARCHBAR_COLOR_MAX; i++)
209 case SEARCH_FIELD_STATUS_DISABLED:
210 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_DISABLED, __color[i]);
211 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_DISABLED, __textColor[i]);
212 GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_DISABLED, __guideTextColor[i]);
215 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
216 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]);
217 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_HIGHLIGHTED, __textColor[i]);
218 GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_HIGHLIGHTED, __guideTextColor[i]);
221 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]);
222 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_NORMAL, __textColor[i]);
223 GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_NORMAL, __guideTextColor[i]);
228 __isUsableCancelButton = enableSearchBarButton;
229 __keypadAction = keypadAction;
231 GetVisualElement()->SetClipChildrenEnabled(false);
233 r = CreateClippedGroupControl();
234 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
235 "[E_SYSTEM] A system error has occurred. The construction of parent control for clipped group control failed.");
237 r = CreateSearchField();
238 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
239 "[E_SYSTEM] A system error has occurred. The edit construction failed.");
240 r = CreateCancelButton();
241 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
242 "[E_SYSTEM] A system error has occurred. The cancel button construction failed.");
245 r = CreateContentsArea();
246 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
247 "[E_SYSTEM] A system error has occurred. The construction of parent for content failed.");
249 _SearchBarPresenter* pPresenter = new (std::nothrow) _SearchBarPresenter;
250 SysTryReturn(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
252 r = pPresenter->Construct(*this);
253 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
255 r = pPresenter->Install();
256 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
258 __pSearchBarPresenter = pPresenter;
260 CreateAccessibilityElement();
271 _SearchBar::CreateSearchField(void)
273 result r = E_SUCCESS;
275 FloatRectangle editBounds;
276 float horizontalMargin = 0.0f;
277 float verticalMargin = 0.0f;
278 float iconHorizontalMargin = 0.0f;
279 float textHorizontalMargin = 0.0f;
280 float iconWidth = 0.0f;
281 float textSize = 0.0f;
282 float searchBarMinHeight = 0.0f;
283 float searchBarMinWidthModeNormal = 0.0f;
285 FloatRectangle searchBarBounds = GetBoundsF();
286 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
288 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
289 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin);
290 GET_SHAPE_CONFIG(SEARCHBAR::ICON_HORIZONTAL_MARGIN, orientation, iconHorizontalMargin);
291 GET_SHAPE_CONFIG(SEARCHBAR::ICON_WIDTH, orientation, iconWidth);
292 GET_SHAPE_CONFIG(SEARCHBAR::TEXT_HORIZONTAL_MARGIN, orientation, textHorizontalMargin);
293 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH_NORMAL_MODE, orientation, searchBarMinWidthModeNormal);
294 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
296 float searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2.0f);
298 editBounds.x = horizontalMargin;
300 if (searchBarBounds.height < searchBarMinHeight)
302 verticalMargin = (searchBarBounds.height - searchFieldMinHeight)/2.0f;
303 if (verticalMargin < 0.0f)
305 verticalMargin = 0.0f;
309 editBounds.y = verticalMargin;
311 editBounds.width = searchBarBounds.width - (editBounds.x * 2.0f);
312 editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
314 editBounds.width = (editBounds.width > searchBarMinWidthModeNormal) ? editBounds.width : searchBarMinWidthModeNormal;
315 editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
317 _SearchBarImpl* pSearchBarImpl = static_cast<_SearchBarImpl*>(GetUserData());
318 __pEdit = &(pSearchBarImpl->GetEditFieldImpl()->GetCore());
320 SysTryReturnResult(NID_UI_CTRL, __pEdit != null, E_SYSTEM,
321 "[E_SYSTEM] A system error has occured. Failed to get _Edit instance");
323 __pEdit->SetKeypadCommandButtonVisible(false);
324 __pEdit->SetBounds(editBounds);
325 __pEdit->AddKeypadEventListener(*this);
326 __pEdit->AddTextBlockEventListener(*this);
327 __pEdit->AddTextEventListener(*this);
329 GET_SHAPE_CONFIG(SEARCHBAR::EDIT_TEXT_SIZE, orientation, textSize);
330 __pEdit->SetTextSize(textSize);
332 __pEdit->SetHorizontalMargin(iconHorizontalMargin + iconWidth + textHorizontalMargin, EDIT_TEXT_LEFT_MARGIN);
333 __pEdit->SetHorizontalMargin(textHorizontalMargin, EDIT_TEXT_RIGHT_MARGIN);
334 __pEdit->SetLimitLength(SEARCHBAR_TEXT_LENGTH_MAX);
336 for (int status = 0; status < SEARCHBAR_COLOR_MAX; status++)
338 EditStatus editStatus = ConvertSearchBarStatus((SearchFieldStatus) status);
339 __pEdit->SetColor(editStatus, __color[status]);
342 __pEdit->SetTextColor(EDIT_TEXT_COLOR_NORMAL, __textColor[SEARCH_FIELD_STATUS_NORMAL]);
343 __pEdit->SetTextColor(EDIT_TEXT_COLOR_DISABLED, __textColor[SEARCH_FIELD_STATUS_DISABLED]);
344 __pEdit->SetTextColor(EDIT_TEXT_COLOR_HIGHLIGHTED, __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
346 __pEdit->ReplaceDefaultBackgroundBitmapForSearchBar();
348 __pEdit->SetKeypadAction(__keypadAction);
350 r = __pClippedGroupControl->AttachChild(*__pEdit);
351 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
352 "[E_SYSTEM] A system error has occurred. Failed to attach edit as child.");
364 _SearchBar::CreateCancelButton(void)
366 result r = E_SUCCESS;
368 float textSize = 0.0f;
369 String cancelButtonText;
371 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
373 _SearchBarImpl* pSearchBarImpl = static_cast<_SearchBarImpl*>(GetUserData());
374 __pCancelButton = &(pSearchBarImpl->GetButtonImpl()->GetCore());
376 SysTryReturnResult(NID_UI_CTRL, __pCancelButton != null, E_SYSTEM,
377 "[E_SYSTEM] A system error has occured. Failed to get _Edit instance");
380 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
382 r = ResizeCancelButton();
383 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
385 GET_STRING_CONFIG(IDS_COM_SK_CANCEL, cancelButtonText);
386 r = __pCancelButton->SetText(cancelButtonText);
387 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
389 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_TEXT_SIZE, orientation, textSize);
390 r = __pCancelButton->SetTextSize(textSize);
391 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
393 __pCancelButton->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
394 __pCancelButton->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
396 r = __pCancelButton->SetActionId(__actionId);
397 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
399 r = __pCancelButton->AddActionEventListener(*this);
400 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
402 __pCancelButton->SetVisibleState(false);
404 for (int status = 0; status < SEARCHBAR_BUTTON_COLOR_MAX; status++)
406 _ButtonStatus buttonStatus = ConvertSearchBarButtonStatus((SearchBarButtonStatus) status);
408 r = __pCancelButton->SetColor(buttonStatus, __buttonColor[status]);
409 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
411 r = __pCancelButton->SetTextColor(buttonStatus, __buttonTextColor[status]);
412 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
415 r = __pClippedGroupControl->AttachChild(*__pCancelButton);
416 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
417 "[E_SYSTEM] A system error has occurred. Failed to attach button as child.");
422 delete __pCancelButton;
423 __pCancelButton = null;
429 _SearchBar::CreateContentsArea(void)
431 result r = E_SUCCESS;
433 __pContainer = _Control::CreateControlN();
436 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
438 __pContainer->SetVisibleState(false);
440 r = AttachChild(*__pContainer);
441 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
442 "[E_SYSTEM] A system error has occurred. Failed to attach the parent of content.");
454 _SearchBar::SetContentsArea(void)
456 if (__isUserContainerBounds)
461 FloatDimension screenSize = _ControlManager::GetInstance()->GetScreenSizeF();
462 float width = screenSize.width;
463 float height = screenSize.height;
465 _Control* pParent = GetParentForm();
468 width = pParent->GetClientBoundsF().width;
469 height = pParent->GetClientBoundsF().height;
472 FloatRectangle controlBounds = GetBoundsF();
473 controlBounds = CoordinateSystem::AlignToDevice(FloatRectangle(controlBounds));
475 __contentAreaBounds.x = 0.0f;
476 __contentAreaBounds.y = controlBounds.height;
477 __contentAreaBounds.width = width - controlBounds.x;
478 __contentAreaBounds.height = height - (controlBounds.y + controlBounds.height);
482 result r = E_SUCCESS;
483 r = __pContainer->SetBounds(__contentAreaBounds);
484 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
490 _SearchBar::GetContent(void) const
492 return __pContentControl;
496 _SearchBar::SetContent(const _Control* pContent)
498 __pContentControl = const_cast <_Control*>(pContent);
499 result r = E_SUCCESS;
503 r = __pContainer->AttachChild(*__pContentControl);
504 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating");
511 _SearchBar::UpdateContentArea(bool invalidate)
513 return __pSearchBarPresenter->UpdateContentArea(invalidate);
517 _SearchBar::SetContentAreaVisible(bool visible)
519 SysTryReturn(NID_UI_CTRL, __pContainer, E_SYSTEM, E_SYSTEM,
520 "[E_SYSTEM] A system error has occurred. The instance of parent to content is null.");
522 SearchBarMode searchBarMode = GetMode();
523 if (searchBarMode == SEARCH_BAR_MODE_INPUT)
525 __pContainer->SetVisibleState(visible);
528 return __pSearchBarPresenter->SetContentAreaVisible(visible);
532 _SearchBar::IsContentAreaVisible(void) const
534 return __pSearchBarPresenter->IsContentAreaVisible();
538 _SearchBar::SetContentAreaSize(const Dimension& size)
540 return SetProperty("contentAreaSize", Variant(size));
544 _SearchBar::GetContentAreaSize(void) const
546 Variant size = GetProperty("contentAreaSize");
548 return size.ToDimension();
552 _SearchBar::GetMode(void) const
554 return __pSearchBarPresenter->GetMode();
558 _SearchBar::IsModeLocked(void) const
560 return __pSearchBarPresenter->IsModeLocked();
564 _SearchBar::SetMode(SearchBarMode mode)
566 return __pSearchBarPresenter->SetMode(mode);
570 _SearchBar::SetModeLocked(bool modeLocked)
572 if (modeLocked == true && GetMode() == SEARCH_BAR_MODE_NORMAL)
574 __pEdit->SetViewModeEnabled(true);
577 if (modeLocked == false && __pEdit->IsViewModeEnabled())
579 __pEdit->SetViewModeEnabled(false);
582 return __pSearchBarPresenter->SetModeLocked(modeLocked);
586 _SearchBar::GetButtonActionId(void) const
588 Variant actionId = GetProperty("buttonActionId");
590 return actionId.ToInt();
594 _SearchBar::GetButtonColor(SearchBarButtonStatus status) const
600 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
601 buttonColor = GetProperty("buttonNormalColor");
603 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
604 buttonColor = GetProperty("buttonPressedColor");
606 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
607 buttonColor = GetProperty("buttonHighlightedColor");
609 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
610 buttonColor = GetProperty("buttonDisabledColor");
616 return buttonColor.ToColor();
620 _SearchBar::GetButtonTextColor(SearchBarButtonStatus status) const
622 Variant buttonTextColor;
626 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
627 buttonTextColor = GetProperty("buttonNormalTextColor");
629 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
630 buttonTextColor = GetProperty("buttonPressedTextColor");
632 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
633 buttonTextColor = GetProperty("buttonHighlightedTextColor");
635 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
636 buttonTextColor = GetProperty("buttonDisabledTextColor");
642 return buttonTextColor.ToColor();
645 SearchBarButtonStatus
646 _SearchBar::GetButtonStatus(void) const
648 SysTryReturn(NID_UI_CTRL, __pCancelButton, SEARCH_BAR_BUTTON_STATUS_NORMAL, E_SYSTEM,
649 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
651 SearchBarButtonStatus buttonStatus = SEARCH_BAR_BUTTON_STATUS_NORMAL;
653 if (__isButtonEnabled == false)
655 buttonStatus = SEARCH_BAR_BUTTON_STATUS_DISABLED;
662 _SearchBar::SetButtonText(const String& text)
664 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
665 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
667 result r = E_SUCCESS;
669 r = __pCancelButton->SetText(text);
670 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
671 "[E_SYSTEM] A system error has occurred. Failed to set text.");
677 _SearchBar::SetButtonActionId(int actionId)
679 return SetProperty("buttonActionId", Variant(actionId));
683 _SearchBar::SetButtonEnabled(bool enabled)
685 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
686 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
688 __pCancelButton->SetEnableState(enabled);
690 __isButtonEnabled = enabled;
696 _SearchBar::SetButtonColor(SearchBarButtonStatus status, const Color& color)
698 result r = E_SUCCESS;
702 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
703 r = SetProperty("buttonNormalColor", Variant(color));
705 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
706 r = SetProperty("buttonPressedColor", Variant(color));
708 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
709 r = SetProperty("buttonHighlightedColor", Variant(color));
711 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
712 r = SetProperty("buttonDisabledColor", Variant(color));
722 _SearchBar::SetButtonTextColor(SearchBarButtonStatus status, const Color& color)
724 result r = E_SUCCESS;
728 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
729 r = SetProperty("buttonNormalTextColor", Variant(color));
731 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
732 r = SetProperty("buttonPressedTextColor", Variant(color));
734 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
735 r = SetProperty("buttonHighlightedTextColor", Variant(color));
737 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
738 r = SetProperty("buttonDisabledTextColor", Variant(color));
748 _SearchBar::AppendCharacter(const Character& character)
750 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
751 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
752 SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM,
753 "[E_SYSTEM] A system error has occurred. The character is null.");
755 result r = E_SUCCESS;
757 r = __pEdit->AppendCharacter(character);
758 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
759 "[E_SYSTEM] A system error has occurred. Failed to set character.");
765 _SearchBar::AppendText(const String& text)
767 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
768 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
769 SysTryReturn(NID_UI_CTRL, text.IsEmpty() == false, E_SYSTEM, E_SYSTEM,
770 "[E_SYSTEM] A system error has occurred. The text is empty.");
772 result r = E_SUCCESS;
774 r = __pEdit->AppendText(text);
775 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
776 "[E_SYSTEM] A system error has occurred. Failed to set text.");
782 _SearchBar::SetText(const String& text)
784 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
785 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
787 result r = E_SUCCESS;
789 int limitLength = __pEdit->GetTextLimitLength();
790 int textLength = text.GetLength();
791 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_SYSTEM, E_SYSTEM,
792 "[E_SYSTEM] A system error has occurred. textLength exceeds the limitLength");
794 r = __pEdit->SetText(text);
795 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
796 "[E_SYSTEM] A system error has occurred. Failed to set text.");
802 _SearchBar::InsertCharacterAt(int index, const Character& character)
804 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
805 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
806 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
807 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
808 SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM,
809 "[E_SYSTEM] A system error has occurred. The character is null.");
811 result r = E_SUCCESS;
815 limitLength = __pEdit->GetTextLimitLength();
816 textLength = __pEdit->GetTextLength() + 1;
818 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
819 "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
821 SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
822 "[E_OUT_OF_RANGE] index(%d) is out of range of current textLength(%d).", index, __pEdit->GetTextLength());
824 r = __pEdit->InsertCharacterAt(index, character);
825 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
826 "[E_SYSTEM] A system error has occurred. Failed to set text.");
832 _SearchBar::InsertTextAt(int index, const String& text)
834 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
835 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
836 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
837 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
839 result r = E_SUCCESS;
843 limitLength = __pEdit->GetTextLimitLength();
844 textLength = __pEdit->GetTextLength() + text.GetLength();
846 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
847 "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
848 SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
849 "[E_OUT_OF_RANGE] index(%d) is out of range of current textLength(%d).", index, __pEdit->GetTextLength());
851 r = __pEdit->InsertTextAt(index, text);
852 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
853 "[E_SYSTEM] A system error has occurred. Failed to insert text.");
859 _SearchBar::DeleteCharacterAt(int index)
861 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
862 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
863 SysTryReturn(NID_UI_CTRL, index > -1, E_INVALID_ARG, E_INVALID_ARG,
864 "[E_INVALID_ARG] Invalid argument(s) is used. index = %d", index);
866 result r = E_SUCCESS;
868 textLength = __pEdit->GetTextLength();
870 SysTryReturn(NID_UI_CTRL, textLength > index, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
871 "[E_OUT_OF_RANGE] index(%d) is out of range. textLength(%d)", index, textLength);
873 r = __pEdit->DeleteCharacterAt(index);
874 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM,
875 "[E_SYSTEM] A system error has occured. Failed to delete character.");
881 _SearchBar::Clear(void)
883 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
884 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
886 return __pEdit->ClearText();
890 _SearchBar::GetTextLength(void) const
892 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
893 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
895 return __pEdit->GetTextLength();
899 _SearchBar::GetText(void) const
901 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
902 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
904 return __pEdit->GetText();
908 _SearchBar::GetText(int start, int end) const
910 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
911 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
913 return __pEdit->GetText(start, end);
917 _SearchBar::GetLimitLength(void) const
919 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
920 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
922 return __pEdit->GetTextLimitLength();
926 _SearchBar::SetLimitLength(int limitLength)
928 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
929 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
930 SysTryReturn(NID_UI_CTRL, limitLength > 0, E_INVALID_ARG, E_INVALID_ARG,
931 "[E_INVALID_ARG] Invalid argument(s) is used.limitLength = %d", limitLength);
933 String tempString = GetText();
935 int textLength = tempString.GetLength();
936 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_INVALID_ARG, E_INVALID_ARG,
937 "[E_INVALID_ARG] Invalid argument(s) is used. limitLength = %d, textLength = %d", limitLength, textLength);
939 result r = __pEdit->SetLimitLength(limitLength);
940 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
942 r = SetText(tempString);
943 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
949 _SearchBar::ShowKeypad(void) const
951 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
952 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
954 SearchBarMode mode = __pSearchBarPresenter->GetMode();
955 SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_INVALID_STATE, E_INVALID_STATE,
956 "[E_INVALID_STATE] The SearchBar is currently in Normal mode.");
957 return __pEdit->ShowKeypad();
961 _SearchBar::HideKeypad(void)
963 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
964 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
966 SearchBarMode mode = __pSearchBarPresenter->GetMode();
967 SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_SYSTEM, E_SYSTEM,
968 "[E_SYSTEM] A system error has occurred. The SearchBar is currently in Normal mode.");
970 result r = __pEdit->HideKeypad();
978 _SearchBar::GetSearchFieldTextSizeF(void) const
980 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
981 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
983 return __pEdit->GetTextSizeF();
987 _SearchBar::SetSearchFieldTextSize(float size)
989 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
990 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
992 return __pEdit->SetTextSize(size);
996 _SearchBar::GetBlockRange(int& start, int& end) const
998 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
999 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1001 int startIndex = -1;
1004 __pEdit->GetBlockRange(startIndex, endIndex);
1005 SysTryReturn(NID_UI_CTRL, (startIndex > -1 && endIndex > 0), E_SYSTEM, E_SYSTEM,
1006 "[E_SYSTEM] A system error has occurred. Failed to get text block range.");
1015 _SearchBar::ReleaseBlock(void)
1017 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1018 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1020 result r = E_SUCCESS;
1025 r = GetBlockRange(start, end);
1026 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1028 return __pEdit->ReleaseTextBlock();
1032 _SearchBar::SetBlockRange(int start, int end)
1034 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1035 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1037 result r = E_SUCCESS;
1040 textLength = __pEdit->GetTextLength();
1042 SysTryReturn(NID_UI_CTRL, (start < end && start >= 0 && textLength >= end), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1043 "[E_OUT_OF_RANGE] start (%d) and end (%d) is out of range.", start, end - 1);
1045 r = SetCursorPosition(start);
1046 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1048 r = __pEdit->BeginTextBlock();
1049 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1050 "[E_SYSTEM] A system error has occurred. Failed to set text block range.");
1052 r = SetCursorPosition(end);
1053 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1054 "[E_SYSTEM] A system error has occurred. Failed to set cursor position.");
1060 _SearchBar::RemoveTextBlock(void)
1062 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1063 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1065 result r = E_SUCCESS;
1067 r = __pEdit->RemoveTextBlock();
1068 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1074 _SearchBar::GetColor(void) const
1076 Variant backgroundColor = GetProperty("color");
1078 return backgroundColor.ToColor();
1082 _SearchBar::GetSearchFieldColor(SearchFieldStatus status) const
1084 Variant searchFieldColor;
1088 case SEARCH_FIELD_STATUS_NORMAL:
1089 searchFieldColor = GetProperty("searchFieldNormalColor");
1091 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1092 searchFieldColor = GetProperty("searchFieldHighlightedColor");
1094 case SEARCH_FIELD_STATUS_DISABLED:
1095 searchFieldColor = GetProperty("searchFieldDisabledColor");
1101 return searchFieldColor.ToColor();
1106 _SearchBar::GetSearchFieldTextColor(SearchFieldStatus status) const
1108 Variant searchFieldTextColor;
1112 case SEARCH_FIELD_STATUS_NORMAL:
1113 searchFieldTextColor = GetProperty("searchFieldNormalTextColor");
1115 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1116 searchFieldTextColor = GetProperty("searchFieldHighlightedTextColor");
1118 case SEARCH_FIELD_STATUS_DISABLED:
1119 searchFieldTextColor = GetProperty("searchFieldDisabledTextColor");
1125 return searchFieldTextColor.ToColor();
1130 _SearchBar::SetBackgroundBitmap(const Bitmap& bitmap)
1132 Bitmap* pNewBitmap = _BitmapImpl::CloneN(bitmap);
1133 SysTryReturn(NID_UI_CTRL, pNewBitmap, E_SYSTEM, E_SYSTEM,
1134 "[E_SYSTEM] A system error has occurred. The creation of bitmap failed.");
1136 delete __pBackgroundBitmap;
1137 __pBackgroundBitmap = null;
1139 __pBackgroundBitmap = pNewBitmap;
1145 _SearchBar::GetBackgroundBitmap(void) const
1147 return __pBackgroundBitmap;
1151 _SearchBar::SetColor(const Color& color)
1153 return SetProperty("color", Variant(color));
1157 _SearchBar::SetSearchFieldColor(SearchFieldStatus status, const Color& color)
1159 result r = E_SUCCESS;
1163 case SEARCH_FIELD_STATUS_NORMAL:
1164 r = SetProperty("searchFieldNormalColor", Variant(color));
1166 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1167 r = SetProperty("searchFieldHighlightedColor", Variant(color));
1169 case SEARCH_FIELD_STATUS_DISABLED:
1170 r = SetProperty("searchFieldDisabledColor", Variant(color));
1181 _SearchBar::SetSearchFieldTextColor(SearchFieldStatus status, const Color& color)
1183 result r = E_SUCCESS;
1187 case SEARCH_FIELD_STATUS_NORMAL:
1188 r = SetProperty("searchFieldNormalTextColor", Variant(color));
1190 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1191 r = SetProperty("searchFieldHighlightedTextColor", Variant(color));
1193 case SEARCH_FIELD_STATUS_DISABLED:
1194 r = SetProperty("searchFieldDisabledTextColor", Variant(color));
1205 _SearchBar::GetGuideText(void) const
1207 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
1208 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1210 return __pEdit->GetGuideText();
1214 _SearchBar::SetGuideText(const String& guideText)
1216 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1217 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1219 __pEdit->SetGuideText(guideText);
1225 _SearchBar::GetGuideTextColor(void) const
1227 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1228 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1230 return __pEdit->GetGuideTextColor();
1234 _SearchBar::SetGuideTextColor(const Color& color)
1236 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1237 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1239 __isUserGuideTextColor = true;
1240 return __pEdit->SetGuideTextColor(color);
1244 _SearchBar::GetCursorPosition(void) const
1246 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
1247 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1249 return __pEdit->GetCursorPosition();
1253 _SearchBar::SetCursorPosition(int index)
1255 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1256 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1257 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1258 "[E_OUT_OF_RANGE] index(%d) is out of range.", GetErrorMessage(E_OUT_OF_RANGE), index);
1260 int textLength = -1;
1261 textLength = __pEdit->GetTextLength();
1263 SysTryReturn(NID_UI_CTRL, (index > -1 && index <= textLength), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1264 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
1266 return __pEdit->SetCursorPosition(index);
1270 _SearchBar::IsLowerCaseModeEnabled(void) const
1272 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1273 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1275 return __pEdit->IsLowerCaseModeEnabled();
1279 _SearchBar::SetLowerCaseModeEnabled(bool enable)
1281 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
1282 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1284 __pEdit->SetLowerCaseModeEnabled(enable);
1288 _SearchBar::GetEllipsisPosition(void) const
1290 SysTryReturn(NID_UI_CTRL, __pEdit, ELLIPSIS_POSITION_START, E_SYSTEM,
1291 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1293 return __pEdit->GetEllipsisPosition();
1297 _SearchBar::SetEllipsisPosition(EllipsisPosition position)
1299 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1300 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1301 __pEdit->SetEllipsisPosition(position);
1307 _SearchBar::GetKeypadAction(void) const
1309 return __keypadAction;
1313 _SearchBar::IsTextPredictionEnabled(void) const
1315 SysTryReturn(NID_UI_CTRL, __pEdit, false, E_SYSTEM,
1316 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1317 return __pEdit->IsTextPredictionEnabled();
1321 _SearchBar::SetTextPredictionEnabled(bool enable)
1323 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1324 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1325 return __pEdit->SetTextPredictionEnabled(enable);
1329 _SearchBar::SetCurrentLanguage(LanguageCode languageCode)
1331 return __pEdit->SetCurrentLanguage(languageCode);
1335 _SearchBar::GetCurrentLanguage(LanguageCode& language) const
1337 return __pEdit->GetCurrentLanguage(language);
1341 _SearchBar::AddActionEventListener(const _IActionEventListener& listener)
1343 result r = E_SUCCESS;
1345 if (__pActionEvent == null)
1347 __pActionEvent = _ActionEvent::CreateInstanceN(*this);
1348 r = GetLastResult();
1349 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1351 __pActionEvent->AddListener(listener);
1358 _SearchBar::RemoveActionEventListener(const _IActionEventListener& listener)
1360 SysTryReturn(NID_UI_CTRL, __pActionEvent, E_SYSTEM, E_SYSTEM,
1361 "[E_SYSTEM] A system error has occurred. The action event instance is null.");
1362 result r = E_SUCCESS;
1364 r = __pActionEvent->RemoveListener(listener);
1365 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1371 _SearchBar::AddKeypadEventListener(const _IKeypadEventListener& listener)
1373 result r = E_SUCCESS;
1375 if (__pKeypadEvent == null)
1377 __pKeypadEvent = _KeypadEvent::CreateInstanceN(*this);
1378 r = GetLastResult();
1379 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1381 r = __pKeypadEvent->AddListener(listener);
1382 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1389 _SearchBar::RemoveKeypadEventListener(const _IKeypadEventListener& listener)
1391 SysTryReturn(NID_UI_CTRL, __pKeypadEvent, E_SYSTEM, E_SYSTEM,
1392 "[E_SYSTEM] A system error has occurred. The keypad event instance is null.");
1393 result r = E_SUCCESS;
1395 r = __pKeypadEvent->RemoveListener(listener);
1396 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1402 _SearchBar::AddTextBlockEventListener(const _ITextBlockEventListener& listener)
1404 result r = E_SUCCESS;
1406 if (__pTextBlockEvent == null)
1408 __pTextBlockEvent = _TextBlockEvent::CreateInstanceN(*this);
1409 r = GetLastResult();
1410 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1412 r = __pTextBlockEvent->AddListener(listener);
1413 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1421 _SearchBar::RemoveTextBlockEventListener(const _ITextBlockEventListener& listener)
1423 SysTryReturn(NID_UI_CTRL, __pTextBlockEvent, E_SYSTEM, E_SYSTEM,
1424 "[E_SYSTEM] A system error has occurred. The text block event instance is null.");
1425 result r = E_SUCCESS;
1427 r = __pTextBlockEvent->RemoveListener(listener);
1428 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1435 _SearchBar::AddTextEventListener(const _ITextEventListener& listener)
1437 result r = E_SUCCESS;
1439 if (__pTextEvent == null)
1441 __pTextEvent = _TextEvent::CreateInstanceN(*this);
1442 r = GetLastResult();
1443 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1445 r = __pTextEvent->AddListener(listener);
1446 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1453 _SearchBar::RemoveTextEventListener(const _ITextEventListener& listener)
1455 SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM,
1456 "[E_SYSTEM] A system error has occurred. The text event instance is null.");
1457 result r = E_SUCCESS;
1459 r = __pTextEvent->RemoveListener(listener);
1460 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1466 _SearchBar::AddSearchBarEventListener(const _ISearchBarEventListener& listener)
1468 result r = E_SUCCESS;
1470 if (__pSearchBarEvent == null)
1472 __pSearchBarEvent = _SearchBarEvent::CreateInstanceN(*this);
1473 r = GetLastResult();
1474 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1476 r = __pSearchBarEvent->AddListener(listener);
1477 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1484 _SearchBar::RemoveSearchBarEventListener(const _ISearchBarEventListener& listener)
1486 SysTryReturn(NID_UI_CTRL, __pSearchBarEvent, E_SYSTEM, E_SYSTEM,
1487 "[E_SYSTEM] A system error has occurred. The searchbar event instance is null.");
1488 result r = E_SUCCESS;
1490 r = __pSearchBarEvent->RemoveListener(listener);
1491 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1497 _SearchBar::AddLanguageEventListener(const _ILanguageEventListener& listener)
1499 result r = E_SUCCESS;
1501 if (__pLanguageEvent == null)
1503 __pLanguageEvent = _LanguageEvent::CreateInstanceN(*this);
1504 r = GetLastResult();
1505 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1507 r = __pLanguageEvent->AddListener(listener);
1508 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1515 _SearchBar::RemoveLanguageEventListener(const _ILanguageEventListener& listener)
1517 SysTryReturn(NID_UI_CTRL, __pLanguageEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.");
1518 result r = E_SUCCESS;
1520 __pLanguageEvent->RemoveListener(listener);
1521 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1527 _SearchBar::OnBoundsChanged(void)
1529 if (__pSearchBarPresenter != null)
1531 __isupdateContentBounds = true;
1532 __pSearchBarPresenter->OnBoundsChanged();
1535 if (__pAccessibilitySearchBarElement)
1537 __pAccessibilitySearchBarElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height));
1543 _SearchBar::OnChangeLayout(_ControlOrientation orientation)
1545 __isupdateContentBounds = true;
1550 _SearchBar::OnDraw(void)
1552 if (!__isUserGuideTextColor)
1554 SearchFieldStatus status = GetCurrentStatus();
1555 __pEdit->SetGuideTextColor(__guideTextColor[status]);
1558 if (__isupdateContentBounds)
1561 __isupdateContentBounds = false;
1563 __pSearchBarPresenter->Draw();
1567 _UiTouchEventDelivery
1568 _SearchBar::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1570 _Edit* pEdit = dynamic_cast <_Edit*>(const_cast <_Control*>(&source));
1573 return _UI_TOUCH_EVENT_DELIVERY_YES;
1576 if (GetMode() == SEARCH_BAR_MODE_INPUT)
1578 return _UI_TOUCH_EVENT_DELIVERY_YES;
1581 return _UI_TOUCH_EVENT_DELIVERY_YES;
1585 _SearchBar::OnActionPerformed(const _Control& source, int actionId)
1587 if (__actionId == actionId)
1589 __isCancelActionInProgress = true;
1590 SetMode(SEARCH_BAR_MODE_NORMAL);
1594 IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(__actionId);
1595 result r = GetLastResult();
1596 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1598 __pActionEvent->Fire(*pEventArg);
1600 __isCancelActionInProgress = false;
1607 _SearchBar::OnKeypadWillOpen(void)
1609 if (!__isKeypadOpening)
1613 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CREATED);
1614 result r = GetLastResult();
1615 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1617 __pKeypadEvent->Fire(*pEventArg);
1621 __isKeypadOpening = true;
1626 _SearchBar::OnKeypadOpened(void)
1630 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_OPEN);
1631 result r = GetLastResult();
1632 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1634 __pKeypadEvent->Fire(*pEventArg);
1637 __isKeypadOpening = false;
1643 _SearchBar::OnKeypadClosed(void)
1647 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CLOSE);
1648 result r = GetLastResult();
1649 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1651 __pKeypadEvent->Fire(*pEventArg);
1659 _SearchBar::OnKeypadBoundsChanged(void)
1663 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1664 result r = GetLastResult();
1665 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1667 __pKeypadEvent->Fire(*pEventArg);
1675 _SearchBar::OnKeypadActionPerformed(CoreKeypadAction keypadAction)
1679 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(keypadAction, CORE_KEYPAD_EVENT_STATUS_ENTERACTION);
1680 result r = GetLastResult();
1681 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1683 __pKeypadEvent->Fire(*pEventArg);
1688 // TextBlock callbacks
1690 _SearchBar::OnTextBlockSelected(_Control& source, int start, int end)
1692 if (__pTextBlockEvent)
1694 IEventArg* pEventArg = _TextBlockEvent::CreateTextBlockEventArgN(start, end);
1695 result r = GetLastResult();
1696 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1698 __pTextBlockEvent->Fire(*pEventArg);
1705 _SearchBar::OnTextValueChanged(const _Control& source)
1707 if (!__isCancelActionInProgress)
1709 SetContentDimming();
1710 if (__pTextEvent != null)
1712 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CHANGED);
1713 result r = GetLastResult();
1714 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1716 __pTextEvent->Fire(*pEventArg);
1723 _SearchBar::OnTextValueChangeCanceled(const _Control& source)
1725 if (__pTextEvent != null)
1727 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CANCELED);
1728 result r = GetLastResult();
1729 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1731 __pTextEvent->Fire(*pEventArg);
1737 _SearchBar::OnAttachedToMainTree(void)
1744 _SearchBar::OnFontChanged(Font* pFont)
1746 __pCancelButton->SetFont(pFont->GetFaceName());
1747 __pEdit->SetFont(*pFont);
1752 _SearchBar::OnFontInfoRequested(unsigned long& style, int& size)
1754 style = FONT_STYLE_PLAIN;
1755 size = __pCancelButton->GetTextSize();
1761 _SearchBar::OnFocusGained(const _Control& source)
1765 __isKeyPressed = false;
1766 _Control::OnDrawFocus();
1771 if (GetVisibleState() == true)
1773 __pEdit->SetFocused();
1780 _SearchBar::OnFocusLost(const _Control &source)
1782 __pEdit->SetSearchFieldFocus(false);
1783 _Control::OnFocusLost(source);
1788 _SearchBar::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1790 _KeyCode keyCode = keyInfo.GetKeyCode();
1792 if (keyCode == _KEY_RIGHT)
1794 if (GetMode() == SEARCH_BAR_MODE_NORMAL)
1796 __pEdit->SetFocused();
1800 if (!__isButtonEnabled || __pCancelButton->IsFocused() || !__isUsableCancelButton)
1805 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED);
1806 SetFocusCallBackParameter(false);
1807 __pCancelButton->SetFocused();
1808 __pCancelButton->Invalidate(true);
1813 if (keyCode == _KEY_LEFT)
1815 if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_HIGHLIGHTED)
1817 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1818 __pCancelButton->Invalidate();
1819 __pEdit->SetFocused();
1822 if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_DISABLED) //Searchbar Button is disabled, left arrow key is pressed
1824 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1825 SetButtonEnabled(false);
1826 __pEdit->SetFocused();
1832 if (keyCode == _KEY_ENTER || keyCode == _KEY_TAB)
1834 if (GetMode() == SEARCH_BAR_MODE_NORMAL)
1839 SetMode(SEARCH_BAR_MODE_NORMAL);
1840 __isKeyPressed = true;
1850 _SearchBar::GetParentForm(void) const
1852 _Form* pForm = null;
1853 _Control* pControlCore = GetParent();
1857 if (pControlCore == null)
1859 SysLog(NID_UI_CTRL,"[E_SYSTEM] The parent form is null.");
1864 pForm = dynamic_cast <_Form*>(pControlCore);
1871 pControlCore = pControlCore->GetParent();
1874 return pControlCore;
1878 _SearchBar::GetSearchBarButton(void) const
1880 return __pCancelButton;
1884 _SearchBar::GetSearchField(void)
1890 _SearchBar::GetSearchBarContainer(void) const
1892 return __pContainer;
1896 _SearchBar::GetClippedGroupControl(void) const
1898 return __pClippedGroupControl;
1902 _SearchBar::IsUsableCancelButton(void) const
1904 return __isUsableCancelButton;
1908 _SearchBar::ConvertSearchBarStatus(SearchFieldStatus status)
1910 EditStatus editStatus = EDIT_STATUS_NORMAL;
1913 case SEARCH_FIELD_STATUS_NORMAL:
1914 editStatus = EDIT_STATUS_NORMAL;
1917 case SEARCH_FIELD_STATUS_DISABLED:
1918 editStatus = EDIT_STATUS_DISABLED;
1921 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1922 editStatus = EDIT_STATUS_HIGHLIGHTED;
1932 _SearchBar::ConvertSearchBarButtonStatus(SearchBarButtonStatus status)
1934 _ButtonStatus buttonStatus = _BUTTON_STATUS_NORMAL;
1938 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
1939 buttonStatus = _BUTTON_STATUS_NORMAL;
1942 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
1943 buttonStatus = _BUTTON_STATUS_PRESSED;
1946 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
1947 buttonStatus = _BUTTON_STATUS_HIGHLIGHTED;
1950 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
1951 buttonStatus = _BUTTON_STATUS_DISABLED;
1957 return buttonStatus;
1961 _SearchBar::SendSearchBarEvent(_SearchBarEventStatus status)
1963 result r = E_SUCCESS;
1964 if (__pSearchBarEvent)
1966 IEventArg* pEventArg = _SearchBarEvent::CreateSearchBarEventArgN(status);
1967 r = GetLastResult();
1968 SysTryReturn(NID_UI_CTRL, pEventArg, r, r, "[%s] Propagating.", GetErrorMessage(r));
1970 if (IsContentAreaVisible() == false)
1972 SetContentAreaVisible(false);
1975 __pSearchBarEvent->Fire(*pEventArg);
1982 _SearchBar::SetHeaderVisibleState(bool visible)
1984 if (__pSearchBarPresenter != null)
1986 __pSearchBarPresenter->SetHeaderVisibleState(visible);
1992 _SearchBar::SetPropertyButtonActionId(const Variant& actionId)
1994 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1995 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1996 SysTryReturn(NID_UI_CTRL, actionId.ToInt() > -1, E_INVALID_ARG, E_INVALID_ARG,
1997 "[E_INVALID_ARG] Invalid argument(s) is used. actionId.ToInt() = %d", actionId.ToInt());
1999 result r = E_SUCCESS;
2001 r = __pCancelButton->SetPropertyActionId(actionId);
2002 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2003 "[%s] A system error has occurred. Failed to set actionId.", GetErrorMessage(E_SYSTEM));
2005 __actionId = actionId.ToInt();
2011 _SearchBar::GetPropertyButtonActionId(void) const
2013 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(-1), E_SYSTEM,
2014 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2016 return Variant(__actionId);
2020 _SearchBar::SetPropertyButtonDisabledColor(const Variant& color)
2022 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2023 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2025 result r = E_SUCCESS;
2027 r = __pCancelButton->SetPropertyDisabledColor(color);
2028 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2029 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2031 __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = color.ToColor();
2037 _SearchBar::GetPropertyButtonDisabledColor(void) const
2039 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2040 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2042 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2046 _SearchBar::SetPropertyButtonHighlightedColor(const Variant& color)
2048 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2049 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2051 result r = E_SUCCESS;
2053 r = __pCancelButton->SetPropertyHighlightedColor(color);
2054 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2055 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2057 __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
2063 _SearchBar::GetPropertyButtonHighlightedColor(void) const
2065 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2066 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2068 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2072 _SearchBar::SetPropertyButtonNormalColor(const Variant& color)
2074 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2075 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2077 result r = E_SUCCESS;
2079 r = __pCancelButton->SetPropertyNormalColor(color);
2080 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2081 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2083 __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = color.ToColor();
2089 _SearchBar::GetPropertyButtonNormalColor(void) const
2091 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2092 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2094 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2098 _SearchBar::SetPropertyButtonPressedColor(const Variant& color)
2100 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2101 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2103 result r = E_SUCCESS;
2105 r = __pCancelButton->SetPropertyPressedColor(color);
2106 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2107 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2109 __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = color.ToColor();
2115 _SearchBar::GetPropertyButtonPressedColor(void) const
2117 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2118 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2120 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2124 _SearchBar::SetPropertyButtonDisabledTextColor(const Variant& textColor)
2126 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2127 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2129 result r = E_SUCCESS;
2131 r = __pCancelButton->SetPropertyDisabledTextColor(textColor);
2132 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2133 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2135 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = textColor.ToColor();
2141 _SearchBar::GetPropertyButtonDisabledTextColor(void) const
2143 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2144 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2146 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2150 _SearchBar::SetPropertyButtonHighlightedTextColor(const Variant& textColor)
2152 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2153 "[E_SYSTEM]] A system error has occurred. The cancel button instance is null.");
2155 result r = E_SUCCESS;
2157 r = __pCancelButton->SetPropertyHighlightedTextColor(textColor);
2158 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2159 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2161 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = textColor.ToColor();
2167 _SearchBar::GetPropertyButtonHighlightedTextColor(void) const
2169 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2170 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2172 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2176 _SearchBar::SetPropertyButtonNormalTextColor(const Variant& textColor)
2178 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2179 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2181 result r = E_SUCCESS;
2183 r = __pCancelButton->SetPropertyNormalTextColor(textColor);
2184 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2185 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2187 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = textColor.ToColor();
2193 _SearchBar::GetPropertyButtonNormalTextColor(void) const
2195 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2196 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2198 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2202 _SearchBar::SetPropertyButtonPressedTextColor(const Variant& textColor)
2204 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2205 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2207 result r = E_SUCCESS;
2209 r = __pCancelButton->SetPropertyPressedTextColor(textColor);
2210 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2211 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2213 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = textColor.ToColor();
2219 _SearchBar::GetPropertyButtonPressedTextColor(void) const
2221 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2222 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2224 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2228 _SearchBar::SetPropertySearchFieldDisabledColor(const Variant& color)
2230 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2231 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2233 result r = E_SUCCESS;
2235 r = __pEdit->SetPropertyDisabledColor(color);
2236 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2237 "[E_SYSTEM] A system error has occurred. Failed to set the edit disabled color.");
2239 __color[SEARCH_FIELD_STATUS_DISABLED] = color.ToColor();
2245 _SearchBar::GetPropertySearchFieldDisabledColor(void) const
2247 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2248 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2250 return Variant(__color[SEARCH_FIELD_STATUS_DISABLED]);
2254 _SearchBar::SetPropertySearchFieldHighlightedColor(const Variant& color)
2256 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2257 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2259 result r = E_SUCCESS;
2261 r = __pEdit->SetPropertyHighlightedColor(color);
2262 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2263 "[E_SYSTEM] A system error has occurred. Failed to set the edit highlighted color.");
2265 __color[SEARCH_FIELD_STATUS_HIGHLIGHTED] = color.ToColor();
2271 _SearchBar::GetPropertySearchFieldHighlightedColor(void) const
2273 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2274 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2276 return Variant(__color[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2280 _SearchBar::SetPropertySearchFieldNormalColor(const Variant& color)
2282 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2283 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2285 result r = E_SUCCESS;
2287 r = __pEdit->SetPropertyNormalColor(color);
2288 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2289 "[E_SYSTEM] A system error has occurred. Failed to set edit normal color.");
2291 __color[SEARCH_FIELD_STATUS_NORMAL] = color.ToColor();
2297 _SearchBar::GetPropertySearchFieldNormalColor(void) const
2299 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2300 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2302 return Variant(__color[SEARCH_FIELD_STATUS_NORMAL]);
2306 _SearchBar::SetPropertySearchFieldDisabledTextColor(const Variant& textColor)
2308 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2309 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2311 result r = E_SUCCESS;
2313 r = __pEdit->SetPropertyDisabledTextColor(textColor);
2314 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2315 "[E_SYSTEM] A system error has occurred. Failed to set edit disabled text color.");
2317 __textColor[SEARCH_FIELD_STATUS_DISABLED] = textColor.ToColor();
2323 _SearchBar::GetPropertySearchFieldDisabledTextColor(void) const
2325 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2326 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2328 return Variant(__textColor[SEARCH_FIELD_STATUS_DISABLED]);
2332 _SearchBar::SetPropertySearchFieldHighlightedTextColor(const Variant& textColor)
2334 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2335 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2337 result r = E_SUCCESS;
2339 r = __pEdit->SetPropertyHighlightedTextColor(textColor);
2340 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2341 "[E_SYSTEM] A system error has occurred. Failed to set edit highlighted text color.");
2343 __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED] = textColor.ToColor();
2349 _SearchBar::GetPropertySearchFieldHighlightedTextColor(void) const
2351 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2352 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2354 return Variant(__textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2358 _SearchBar::SetPropertySearchFieldNormalTextColor(const Variant& textColor)
2360 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2361 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2363 result r = E_SUCCESS;
2365 r = __pEdit->SetPropertyNormalTextColor(textColor);
2366 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2367 "[E_SYSTEM] A system error has occurred. Failed to set edit normal text color.");
2369 __textColor[SEARCH_FIELD_STATUS_NORMAL] = textColor.ToColor();
2375 _SearchBar::GetPropertySearchFieldNormalTextColor(void) const
2377 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2378 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2380 return Variant(__textColor[SEARCH_FIELD_STATUS_NORMAL]);
2384 _SearchBar::SetPropertyColor(const Variant& color)
2386 __backgroundColor = color.ToColor();
2392 _SearchBar::GetPropertyColor(void) const
2394 return Variant(__backgroundColor);
2398 _SearchBar::SetPropertyContentAreaSize(const Variant& size)
2400 FloatDimension contentAreaSize = size.ToFloatDimension();
2401 SysTryReturn(NID_UI_CTRL, contentAreaSize.width >= 0 && contentAreaSize.height >= 0, E_INVALID_ARG, E_INVALID_ARG,
2402 "[E_INVALID_ARG] Invalid argument(s) is used. contentAreaSize.width = %f, contenAreaSize.height = %f",
2403 contentAreaSize.width, contentAreaSize.height);
2405 result r = E_SUCCESS;
2408 FloatRectangle bounds = GetBoundsF();
2409 FloatRectangle contentAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
2411 contentAreaBounds.x = 0.0f;
2412 contentAreaBounds.y = bounds.height;
2413 contentAreaBounds.width = contentAreaSize.width;
2414 contentAreaBounds.height = contentAreaSize.height;
2416 __contentAreaBounds = contentAreaBounds;
2417 __isUserContainerBounds = true;
2422 r = __pContainer->SetBounds(__contentAreaBounds);
2423 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2430 _SearchBar::GetPropertyContentAreaSize(void) const
2432 FloatDimension contentAreaSize(__contentAreaBounds.width, __contentAreaBounds.height);
2434 return Variant(contentAreaSize);
2438 _SearchBar::CreateClippedGroupControl(void)
2440 result r = E_SUCCESS;
2441 FloatRectangle clippedGroupControlBounds(FloatPoint(0.0f, 0.0f), GetSizeF());
2442 __pClippedGroupControl = _Control::CreateControlN();
2443 r = GetLastResult();
2444 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2446 r = AttachChild(*__pClippedGroupControl);
2447 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
2448 "[E_SYSTEM] A system error has occurred. Failed to attach the parent of clipped control.");
2450 r = __pClippedGroupControl->SetBounds(clippedGroupControlBounds);
2451 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2453 __pClippedGroupControl->SetBackgroundColor(Color(0));
2455 __pClippedGroupControl->SetClipChildrenEnabled(true);
2460 delete __pClippedGroupControl;
2461 __pClippedGroupControl = null;
2468 _SearchBar::CreateAccessibilityElement(void)
2470 if (__pAccessibilitySearchBarElement != null)
2474 _AccessibilityContainer* pContainer = null;
2475 pContainer = GetAccessibilityContainer();
2479 __pAccessibilitySearchBarElement = new (std::nothrow) _AccessibilityElement(true);
2480 SysTryReturnVoidResult(NID_UI_CTRL, __pAccessibilitySearchBarElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
2481 __pAccessibilitySearchBarElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height));
2482 __pAccessibilitySearchBarElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
2483 __pAccessibilitySearchBarElement->SetName("SearchBar");
2484 pContainer->AddElement(*__pAccessibilitySearchBarElement);
2491 _SearchBar::SetContentDimming(void)
2493 if (__pContainer != NULL)
2495 if (!GetTextLength())
2497 __contentColor.SetAlpha(_SEARCH_CONTENT_DIM_OPACITY);
2501 __contentColor.SetAlpha(0);
2503 __pContainer->SetBackgroundColor(__contentColor);
2509 _SearchBar::OnDrawFocus(void)
2511 __pEdit->SetSearchFieldFocus(true);
2516 _SearchBar::IsContentAttachable(const _Control* pContent)
2518 const _Window* pWindow = dynamic_cast <const _Window*>(pContent);
2519 const _ColorPicker* pColorPicker = dynamic_cast <const _ColorPicker*>(pContent);
2520 const _Form* pForm = dynamic_cast <const _Form*>(pContent);
2521 const _Keypad* pKeypad = dynamic_cast <const _Keypad*>(pContent);
2522 const _OverlayPanel* pOverlayPanel = dynamic_cast <const _OverlayPanel*>(pContent);
2524 bool isContentAttachable = true;
2526 isContentAttachable = ((pWindow == null) && (pColorPicker == null) &&
2527 (pForm == null) && (pKeypad == null) && (pOverlayPanel == null));
2528 return isContentAttachable;
2532 _SearchBar::ResizeCancelButton(void)
2534 result r = E_SUCCESS;
2536 float horizontalMargin = 0.0f;
2537 float buttonLeftMargin = 0.0f;
2538 float buttonRightMargin = 0.0f;
2539 float buttonMinWidth = 0.0f;
2540 float searchFieldMinWidth = 0.0f;
2541 float buttonVerticalMargin = 0.0f;
2542 float searchBarMinHeight = 0.0f;
2543 float buttonWidth = 0.0f;
2544 float buttonHeight = 0.0f;
2546 FloatRectangle cancelButtonBounds;
2547 FloatRectangle searchBarBounds = GetBoundsF();
2549 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2551 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2552 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2553 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2554 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2555 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2556 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2557 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2558 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2559 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2561 cancelButtonBounds.width = buttonWidth;
2562 cancelButtonBounds.height = buttonHeight;
2564 float buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth +
2565 cancelButtonBounds.width + buttonLeftMargin + buttonRightMargin);
2567 if (searchBarBounds.width < buttonResizableSearchBarWidth)
2569 cancelButtonBounds.width = searchBarBounds.width -(searchFieldMinWidth + buttonLeftMargin
2570 + buttonRightMargin + horizontalMargin);
2573 cancelButtonBounds.x = searchBarBounds.width - cancelButtonBounds.width - buttonRightMargin;
2574 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2576 cancelButtonBounds.y = cancelButtonBounds.y < 0.0f ? 0.0f:cancelButtonBounds.y;
2578 if (cancelButtonBounds.width < buttonMinWidth)
2580 cancelButtonBounds.width = buttonMinWidth;
2583 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2584 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2585 r = __pCancelButton->SetBounds(cancelButtonBounds);
2591 _SearchBar::RecalculateButtonBounds(void)
2593 result r = E_SUCCESS;
2595 float horizontalMargin = 0.0f;
2596 float verticalMargin = 0.0f;
2597 float buttonLeftMargin = 0.0f;
2598 float buttonRightMargin = 0.0f;
2599 float buttonMinWidth = 0.0f;
2600 float searchFieldMinWidth = 0.0f;
2601 float buttonVerticalMargin = 0.0f;
2602 float searchBarMinHeight = 0.0f;
2603 float buttonWidth = 0.0f;
2604 float buttonHeight = 0.0f;
2605 float cancelButtonWidth = 0.0f;
2607 FloatRectangle cancelButtonBounds;
2608 FloatRectangle editBounds;
2609 FloatRectangle searchBarBounds = GetBoundsF();
2611 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2613 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2614 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin);
2615 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2616 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2617 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2618 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2619 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2620 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2621 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2622 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2624 cancelButtonBounds.height = buttonHeight;
2626 float searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2.0f);
2627 cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightTouchMarginF() + __pCancelButton->GetLeftTouchMarginF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF();
2628 editBounds.x = horizontalMargin;
2630 if (searchBarBounds.height < searchBarMinHeight)
2632 verticalMargin = (searchBarBounds.height - searchFieldMinHeight)/2.0f;
2633 if (verticalMargin < 0.0f)
2635 verticalMargin = 0.0f;
2639 editBounds.y = verticalMargin;
2640 editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
2642 editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
2644 editBounds.width = searchBarBounds.width - cancelButtonWidth - horizontalMargin - buttonLeftMargin - buttonRightMargin;
2646 if (editBounds.width < searchFieldMinWidth)
2648 editBounds.width = searchFieldMinWidth;
2651 cancelButtonBounds.x = editBounds.width + horizontalMargin + buttonLeftMargin;
2652 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2654 cancelButtonBounds.y = cancelButtonBounds.y < 0.0f ? 0.0f:cancelButtonBounds.y;
2656 float remainingWidth = searchBarBounds.width - editBounds.width - horizontalMargin - buttonLeftMargin - buttonRightMargin;
2658 if (remainingWidth < buttonMinWidth)
2660 cancelButtonBounds.width = buttonMinWidth;
2664 cancelButtonBounds.width = searchBarBounds.width - cancelButtonBounds.x - buttonRightMargin;
2667 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2668 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2670 r = __pCancelButton->SetBounds(cancelButtonBounds);
2671 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2672 r = __pEdit->SetBounds(editBounds);
2673 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2679 _SearchBar::GetCurrentStatus(void)
2681 SearchFieldStatus searchFieldStatus = SEARCH_FIELD_STATUS_NORMAL;
2685 if (__pEdit->IsFocused())
2687 searchFieldStatus = SEARCH_FIELD_STATUS_HIGHLIGHTED;
2692 searchFieldStatus = SEARCH_FIELD_STATUS_DISABLED;
2695 return searchFieldStatus;
2699 _SearchBar::SetEditTextFilter(IEditTextFilter* pFilter)
2701 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2702 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2704 __pEdit->SetEditTextFilter(pFilter);
2710 _SearchBar::SendOpaqueCommand(const String& command)
2712 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2713 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2715 __pEdit->SendOpaqueCommand(command);
2721 _SearchBar::SetFocusCallBackParameter(bool state)
2723 __isFocusCallbackToBeFired = state;
2728 _SearchBar::IsFocusCallBackToBeFired(void) const
2730 return __isFocusCallbackToBeFired;
2732 }}} // Tizen::Ui::Controls