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"
44 using namespace Tizen::Graphics;
45 using namespace Tizen::Ui;
46 using namespace Tizen::Ui::Animations;
47 using namespace Tizen::Base;
48 using namespace Tizen::Base::Runtime;
49 using namespace Tizen::Locales;
51 namespace Tizen { namespace Ui { namespace Controls
54 IMPLEMENT_PROPERTY(_SearchBar);
56 _SearchBar::_SearchBar(void)
57 : __pSearchBarPresenter(null)
58 , __pClippedGroupControl(null)
60 , __pCancelButton(null)
62 , __pContentControl(null)
65 , __isButtonEnabled(true)
66 , __isUsableCancelButton(false)
67 , __isUserContainerBounds(false)
68 , __isCancelActionInProgress(false)
69 , __isUserGuideTextColor(false)
70 , __isKeypadOpening(false)
71 , __isupdateContentBounds(false)
72 , __keypadAction(CORE_KEYPAD_ACTION_SEARCH)
73 , __pBackgroundBitmap(null)
74 , __backgroundColor(Color())
75 , __contentColor(Color())
76 , __pActionEvent(null)
77 , __pKeypadEvent(null)
78 , __pTextBlockEvent(null)
80 , __pSearchBarEvent(null)
81 , __pLanguageEvent(null)
83 for (int i = 0; i < SEARCHBAR_BUTTON_COLOR_MAX; i++)
85 __buttonColor[i] = Color(0);
86 __buttonTextColor[i] = Color(0);
89 for (int i = 0; i < SEARCHBAR_COLOR_MAX; i++)
91 __color[i] = Color(0);
92 __textColor[i] = Color(0);
93 __guideTextColor[i] = Color(0);
96 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
99 pContainer->Activate(true);
103 _SearchBar::~_SearchBar(void)
106 delete __pSearchBarPresenter;
107 __pSearchBarPresenter = null;
111 __pEdit->HideKeypad();
113 __pClippedGroupControl->DetachChild(*__pEdit);
121 __pClippedGroupControl->DetachChild(*__pCancelButton);
123 delete __pCancelButton;
124 __pCancelButton = null;
127 if (__pClippedGroupControl)
129 DetachChild(*__pClippedGroupControl);
131 delete __pClippedGroupControl;
132 __pClippedGroupControl = null;
137 DetachChild(*__pContainer);
145 delete __pActionEvent;
146 __pActionEvent = null;
151 delete __pKeypadEvent;
152 __pKeypadEvent = null;
155 if (__pTextBlockEvent)
157 delete __pTextBlockEvent;
158 __pTextBlockEvent = null;
167 if (__pSearchBarEvent)
169 delete __pSearchBarEvent;
170 __pSearchBarEvent = null;
173 delete __pBackgroundBitmap;
174 __pBackgroundBitmap = null;
178 _SearchBar::CreateSearchBarN(void)
180 _SearchBar* pSearchBar = new (std::nothrow) _SearchBar;
181 SysTryReturn(NID_UI_CTRL, pSearchBar, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
182 if (GetLastResult() != E_SUCCESS)
188 pSearchBar->AcquireHandle();
194 _SearchBar::Initialize(bool enableSearchBarButton, CoreKeypadAction keypadAction)
196 result r = E_SUCCESS;
198 // Setting Button color
199 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_NORMAL, __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
200 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_PRESSED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
201 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_HIGHLIGHTED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
202 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_DISABLED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
204 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_NORMAL, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
205 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_PRESSED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
206 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_HIGHLIGHTED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
207 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_DISABLED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
209 GET_COLOR_CONFIG(SEARCHBAR::CONTENT_AREA_BG_NORMAL, __contentColor);
211 for (int i = 0; i < SEARCHBAR_COLOR_MAX; i++)
215 case SEARCH_FIELD_STATUS_DISABLED:
216 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_DISABLED, __color[i]);
217 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_DISABLED, __textColor[i]);
218 GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_DISABLED, __guideTextColor[i]);
221 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
222 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]);
223 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_HIGHLIGHTED, __textColor[i]);
224 GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_HIGHLIGHTED, __guideTextColor[i]);
227 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]);
228 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_NORMAL, __textColor[i]);
229 GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_NORMAL, __guideTextColor[i]);
234 __isUsableCancelButton = enableSearchBarButton;
235 __keypadAction = keypadAction;
237 GetVisualElement()->SetClipChildrenEnabled(false);
239 r = CreateClippedGroupControl();
240 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
241 "[E_SYSTEM] A system error has occurred. The construction of parent control for clipped group control failed.");
243 r = CreateSearchField();
244 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
245 "[E_SYSTEM] A system error has occurred. The edit construction failed.");
246 r = CreateCancelButton();
247 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
248 "[E_SYSTEM] A system error has occurred. The cancel button construction failed.");
251 r = CreateContentsArea();
252 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
253 "[E_SYSTEM] A system error has occurred. The construction of parent for content failed.");
255 _SearchBarPresenter* pPresenter = new (std::nothrow) _SearchBarPresenter;
256 SysTryReturn(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
258 r = pPresenter->Construct(*this);
259 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
261 r = pPresenter->Install();
262 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
264 __pSearchBarPresenter = pPresenter;
276 _SearchBar::CreateSearchField(void)
278 result r = E_SUCCESS;
280 FloatRectangle editBounds;
281 float horizontalMargin = 0.0f;
282 float verticalMargin = 0.0f;
283 float iconHorizontalMargin = 0.0f;
284 float textHorizontalMargin = 0.0f;
285 float iconWidth = 0.0f;
286 float textSize = 0.0f;
287 float searchBarMinHeight = 0.0f;
288 float searchBarMinWidthModeNormal = 0.0f;
290 FloatRectangle searchBarBounds = GetBoundsF();
291 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
292 _AccessibilityContainer* pSearchBarContainer = null;
294 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
295 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin);
296 GET_SHAPE_CONFIG(SEARCHBAR::ICON_HORIZONTAL_MARGIN, orientation, iconHorizontalMargin);
297 GET_SHAPE_CONFIG(SEARCHBAR::ICON_WIDTH, orientation, iconWidth);
298 GET_SHAPE_CONFIG(SEARCHBAR::TEXT_HORIZONTAL_MARGIN, orientation, textHorizontalMargin);
299 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH_NORMAL_MODE, orientation, searchBarMinWidthModeNormal);
300 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
302 float searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2.0f);
304 editBounds.x = horizontalMargin;
306 if (searchBarBounds.height < searchBarMinHeight)
308 verticalMargin = (searchBarBounds.height - searchFieldMinHeight)/2.0f;
309 if (verticalMargin < 0.0f)
311 verticalMargin = 0.0f;
315 editBounds.y = verticalMargin;
317 editBounds.width = searchBarBounds.width - (editBounds.x * 2.0f);
318 editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
320 editBounds.width = (editBounds.width > searchBarMinWidthModeNormal) ? editBounds.width : searchBarMinWidthModeNormal;
321 editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
323 __pEdit = _Edit::CreateEditN();
325 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
327 r = __pEdit->Initialize(EDIT_STYLE_NORMAL | EDIT_STYLE_SINGLE_LINE | EDIT_STYLE_CLEAR | EDIT_STYLE_NOSCROLL, INPUT_STYLE_OVERLAY,
328 SEARCHBAR_TEXT_LENGTH_MAX);
329 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
331 __pEdit->SetKeypadCommandButtonVisible(false);
332 __pEdit->SetBounds(editBounds);
333 __pEdit->AddKeypadEventListener(*this);
334 __pEdit->AddTextBlockEventListener(*this);
335 __pEdit->AddTextEventListener(*this);
337 GET_SHAPE_CONFIG(SEARCHBAR::EDIT_TEXT_SIZE, orientation, textSize);
338 __pEdit->SetTextSize(textSize);
340 __pEdit->SetHorizontalMargin(iconHorizontalMargin + iconWidth + textHorizontalMargin, EDIT_TEXT_LEFT_MARGIN);
341 __pEdit->SetHorizontalMargin(textHorizontalMargin, EDIT_TEXT_RIGHT_MARGIN);
342 __pEdit->SetLimitLength(SEARCHBAR_TEXT_LENGTH_MAX);
344 for (int status = 0; status < SEARCHBAR_COLOR_MAX; status++)
346 EditStatus editStatus = ConvertSearchBarStatus((SearchFieldStatus) status);
347 __pEdit->SetColor(editStatus, __color[status]);
350 __pEdit->SetTextColor(EDIT_TEXT_COLOR_NORMAL, __textColor[SEARCH_FIELD_STATUS_NORMAL]);
351 __pEdit->SetTextColor(EDIT_TEXT_COLOR_DISABLED, __textColor[SEARCH_FIELD_STATUS_DISABLED]);
352 __pEdit->SetTextColor(EDIT_TEXT_COLOR_HIGHLIGHTED, __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
354 __pEdit->ReplaceDefaultBackgroundBitmapForSearchBar();
356 __pEdit->SetKeypadAction(__keypadAction);
358 r = __pClippedGroupControl->AttachChild(*__pEdit);
359 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
360 "[E_SYSTEM] A system error has occurred. Failed to attach edit as child.");
362 if (likely(!(_AccessibilityManager::IsActivated())))
367 pSearchBarContainer = GetAccessibilityContainer();
368 if (pSearchBarContainer)
370 _AccessibilityContainer* pSearchFieldContainer = __pEdit->GetAccessibilityContainer();
371 if (pSearchFieldContainer)
373 pSearchBarContainer->AddChildContainer(*pSearchFieldContainer);
387 _SearchBar::CreateCancelButton(void)
389 result r = E_SUCCESS;
391 float textSize = 0.0f;
392 String cancelButtonText;
394 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
395 _AccessibilityContainer* pSearchBarContainer = null;
397 __pCancelButton = _Button::CreateButtonN();
399 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
401 r = ResizeCancelButton();
402 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
404 GET_STRING_CONFIG(IDS_COM_SK_CANCEL, cancelButtonText);
405 r = __pCancelButton->SetText(cancelButtonText);
406 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
408 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_TEXT_SIZE, orientation, textSize);
409 r = __pCancelButton->SetTextSize(textSize);
410 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
412 __pCancelButton->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
413 __pCancelButton->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
415 r = __pCancelButton->SetActionId(__actionId);
416 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
418 r = __pCancelButton->AddActionEventListener(*this);
419 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
421 __pCancelButton->SetVisibleState(false);
423 for (int status = 0; status < SEARCHBAR_BUTTON_COLOR_MAX; status++)
425 _ButtonStatus buttonStatus = ConvertSearchBarButtonStatus((SearchBarButtonStatus) status);
427 r = __pCancelButton->SetColor(buttonStatus, __buttonColor[status]);
428 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
430 r = __pCancelButton->SetTextColor(buttonStatus, __buttonTextColor[status]);
431 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
434 r = __pClippedGroupControl->AttachChild(*__pCancelButton);
435 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
436 "[E_SYSTEM] A system error has occurred. Failed to attach button as child.");
438 if (likely(!(_AccessibilityManager::IsActivated())))
443 pSearchBarContainer = GetAccessibilityContainer();
444 if (pSearchBarContainer)
446 _AccessibilityContainer* pButtonContainer = __pCancelButton->GetAccessibilityContainer();
447 if (pButtonContainer)
449 pSearchBarContainer->AddChildContainer(*pButtonContainer);
456 delete __pCancelButton;
457 __pCancelButton = null;
463 _SearchBar::CreateContentsArea(void)
465 result r = E_SUCCESS;
467 __pContainer = _Control::CreateControlN();
470 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
472 __pContainer->SetVisibleState(false);
474 r = AttachChild(*__pContainer);
475 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
476 "[E_SYSTEM] A system error has occurred. Failed to attach the parent of content.");
488 _SearchBar::SetContentsArea(void)
490 if (__isUserContainerBounds)
495 FloatDimension screenSize = _ControlManager::GetInstance()->GetScreenSizeF();
496 float width = screenSize.width;
497 float height = screenSize.height;
499 _Control* pParent = GetParentForm();
502 width = pParent->GetClientBoundsF().width;
503 height = pParent->GetClientBoundsF().height;
506 FloatRectangle controlBounds = GetBoundsF();
507 __contentAreaBounds.x = 0.0f;
508 __contentAreaBounds.y = controlBounds.height;
509 __contentAreaBounds.width = width - controlBounds.x;
510 __contentAreaBounds.height = height - (controlBounds.y + controlBounds.height);
514 result r = E_SUCCESS;
515 r = __pContainer->SetBounds(__contentAreaBounds);
516 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
522 _SearchBar::GetContent(void) const
524 return __pContentControl;
528 _SearchBar::SetContent(const _Control* pContent)
530 __pContentControl = const_cast <_Control*>(pContent);
531 result r = E_SUCCESS;
535 r = __pContainer->AttachChild(*__pContentControl);
536 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating");
543 _SearchBar::UpdateContentArea(bool invalidate)
545 return __pSearchBarPresenter->UpdateContentArea(invalidate);
549 _SearchBar::SetContentAreaVisible(bool visible)
551 SysTryReturn(NID_UI_CTRL, __pContainer, E_SYSTEM, E_SYSTEM,
552 "[E_SYSTEM] A system error has occurred. The instance of parent to content is null.");
554 SearchBarMode searchBarMode = GetMode();
555 if (searchBarMode == SEARCH_BAR_MODE_INPUT)
557 __pContainer->SetVisibleState(visible);
560 return __pSearchBarPresenter->SetContentAreaVisible(visible);
564 _SearchBar::IsContentAreaVisible(void) const
566 return __pSearchBarPresenter->IsContentAreaVisible();
570 _SearchBar::SetContentAreaSize(const Dimension& size)
572 return SetProperty("contentAreaSize", Variant(size));
576 _SearchBar::GetContentAreaSize(void) const
578 Variant size = GetProperty("contentAreaSize");
580 return size.ToDimension();
584 _SearchBar::GetMode(void) const
586 return __pSearchBarPresenter->GetMode();
590 _SearchBar::IsModeLocked(void) const
592 return __pSearchBarPresenter->IsModeLocked();
596 _SearchBar::SetMode(SearchBarMode mode)
598 return __pSearchBarPresenter->SetMode(mode);
602 _SearchBar::SetModeLocked(bool modeLocked)
604 return __pSearchBarPresenter->SetModeLocked(modeLocked);
608 _SearchBar::GetButtonActionId(void) const
610 Variant actionId = GetProperty("buttonActionId");
612 return actionId.ToInt();
616 _SearchBar::GetButtonColor(SearchBarButtonStatus status) const
622 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
623 buttonColor = GetProperty("buttonNormalColor");
625 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
626 buttonColor = GetProperty("buttonPressedColor");
628 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
629 buttonColor = GetProperty("buttonHighlightedColor");
631 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
632 buttonColor = GetProperty("buttonDisabledColor");
638 return buttonColor.ToColor();
642 _SearchBar::GetButtonTextColor(SearchBarButtonStatus status) const
644 Variant buttonTextColor;
648 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
649 buttonTextColor = GetProperty("buttonNormalTextColor");
651 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
652 buttonTextColor = GetProperty("buttonPressedTextColor");
654 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
655 buttonTextColor = GetProperty("buttonHighlightedTextColor");
657 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
658 buttonTextColor = GetProperty("buttonDisabledTextColor");
664 return buttonTextColor.ToColor();
667 SearchBarButtonStatus
668 _SearchBar::GetButtonStatus(void) const
670 SysTryReturn(NID_UI_CTRL, __pCancelButton, SEARCH_BAR_BUTTON_STATUS_NORMAL, E_SYSTEM,
671 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
673 SearchBarButtonStatus buttonStatus = SEARCH_BAR_BUTTON_STATUS_NORMAL;
675 if (__isButtonEnabled == false)
677 buttonStatus = SEARCH_BAR_BUTTON_STATUS_DISABLED;
684 _SearchBar::SetButtonText(const String& text)
686 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
687 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
689 result r = E_SUCCESS;
691 r = __pCancelButton->SetText(text);
692 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
693 "[E_SYSTEM] A system error has occurred. Failed to set text.");
699 _SearchBar::SetButtonActionId(int actionId)
701 return SetProperty("buttonActionId", Variant(actionId));
705 _SearchBar::SetButtonEnabled(bool enabled)
707 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
708 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
710 __pCancelButton->SetEnableState(enabled);
712 __isButtonEnabled = enabled;
718 _SearchBar::SetButtonColor(SearchBarButtonStatus status, const Color& color)
720 result r = E_SUCCESS;
724 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
725 r = SetProperty("buttonNormalColor", Variant(color));
727 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
728 r = SetProperty("buttonPressedColor", Variant(color));
730 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
731 r = SetProperty("buttonHighlightedColor", Variant(color));
733 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
734 r = SetProperty("buttonDisabledColor", Variant(color));
744 _SearchBar::SetButtonTextColor(SearchBarButtonStatus status, const Color& color)
746 result r = E_SUCCESS;
750 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
751 r = SetProperty("buttonNormalTextColor", Variant(color));
753 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
754 r = SetProperty("buttonPressedTextColor", Variant(color));
756 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
757 r = SetProperty("buttonHighlightedTextColor", Variant(color));
759 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
760 r = SetProperty("buttonDisabledTextColor", Variant(color));
770 _SearchBar::AppendCharacter(const Character& character)
772 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
773 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
774 SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM,
775 "[E_SYSTEM] A system error has occurred. The character is null.");
777 result r = E_SUCCESS;
779 r = __pEdit->AppendCharacter(character);
780 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
781 "[E_SYSTEM] A system error has occurred. Failed to set character.");
787 _SearchBar::AppendText(const String& text)
789 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
790 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
791 SysTryReturn(NID_UI_CTRL, text.IsEmpty() == false, E_SYSTEM, E_SYSTEM,
792 "[E_SYSTEM] A system error has occurred. The text is empty.");
794 result r = E_SUCCESS;
796 r = __pEdit->AppendText(text);
797 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
798 "[E_SYSTEM] A system error has occurred. Failed to set text.");
804 _SearchBar::SetText(const String& text)
806 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
807 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
809 result r = E_SUCCESS;
811 int limitLength = __pEdit->GetTextLimitLength();
812 int textLength = text.GetLength();
813 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_SYSTEM, E_SYSTEM,
814 "[E_SYSTEM] A system error has occurred. textLength exceeds the limitLength");
816 r = __pEdit->SetText(text);
817 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
818 "[E_SYSTEM] A system error has occurred. Failed to set text.");
824 _SearchBar::InsertCharacterAt(int index, const Character& character)
826 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
827 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
828 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
829 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
830 SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM,
831 "[E_SYSTEM] A system error has occurred. The character is null.");
833 result r = E_SUCCESS;
837 limitLength = __pEdit->GetTextLimitLength();
838 textLength = __pEdit->GetTextLength() + 1;
840 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
841 "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
843 SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
844 "[E_OUT_OF_RANGE] index(%d) is out of range of current textLength(%d).", index, __pEdit->GetTextLength());
846 r = __pEdit->InsertCharacterAt(index, character);
847 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
848 "[E_SYSTEM] A system error has occurred. Failed to set text.");
854 _SearchBar::InsertTextAt(int index, const String& text)
856 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
857 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
858 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
859 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
861 result r = E_SUCCESS;
865 limitLength = __pEdit->GetTextLimitLength();
866 textLength = __pEdit->GetTextLength() + text.GetLength();
868 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
869 "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
870 SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
871 "[E_OUT_OF_RANGE] index(%d) is out of range of current textLength(%d).", index, __pEdit->GetTextLength());
873 r = __pEdit->InsertTextAt(index, text);
874 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
875 "[E_SYSTEM] A system error has occurred. Failed to insert text.");
881 _SearchBar::DeleteCharacterAt(int index)
883 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
884 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
885 SysTryReturn(NID_UI_CTRL, index > -1, E_INVALID_ARG, E_INVALID_ARG,
886 "[E_INVALID_ARG] Invalid argument(s) is used. index = %d", index);
888 result r = E_SUCCESS;
890 textLength = __pEdit->GetTextLength();
892 SysTryReturn(NID_UI_CTRL, textLength > index, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
893 "[E_OUT_OF_RANGE] index(%d) is out of range. textLength(%d)", index, textLength);
895 r = __pEdit->DeleteCharacterAt(index);
896 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM,
897 "[E_SYSTEM] A system error has occured. Failed to delete character.");
903 _SearchBar::Clear(void)
905 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
906 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
908 return __pEdit->ClearText();
912 _SearchBar::GetTextLength(void) const
914 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
915 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
917 return __pEdit->GetTextLength();
921 _SearchBar::GetText(void) const
923 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
924 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
926 return __pEdit->GetText();
930 _SearchBar::GetText(int start, int end) const
932 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
933 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
935 return __pEdit->GetText(start, end);
939 _SearchBar::GetLimitLength(void) const
941 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
942 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
944 return __pEdit->GetTextLimitLength();
948 _SearchBar::SetLimitLength(int limitLength)
950 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
951 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
952 SysTryReturn(NID_UI_CTRL, limitLength > 0, E_INVALID_ARG, E_INVALID_ARG,
953 "[E_INVALID_ARG] Invalid argument(s) is used.limitLength = %d", limitLength);
955 String tempString = GetText();
957 int textLength = tempString.GetLength();
958 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_INVALID_ARG, E_INVALID_ARG,
959 "[E_INVALID_ARG] Invalid argument(s) is used. limitLength = %d, textLength = %d", limitLength, textLength);
961 result r = __pEdit->SetLimitLength(limitLength);
962 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
964 r = SetText(tempString);
965 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
971 _SearchBar::ShowKeypad(void) const
973 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
974 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
976 SearchBarMode mode = __pSearchBarPresenter->GetMode();
977 SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_INVALID_STATE, E_INVALID_STATE,
978 "[E_INVALID_STATE] The SearchBar is currently in Normal mode.");
979 return __pEdit->ShowKeypad();
983 _SearchBar::HideKeypad(void)
985 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
986 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
988 SearchBarMode mode = __pSearchBarPresenter->GetMode();
989 SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_SYSTEM, E_SYSTEM,
990 "[E_SYSTEM] A system error has occurred. The SearchBar is currently in Normal mode.");
992 result r = __pEdit->HideKeypad();
1000 _SearchBar::GetSearchFieldTextSizeF(void) const
1002 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
1003 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1005 return __pEdit->GetTextSizeF();
1009 _SearchBar::SetSearchFieldTextSize(float size)
1011 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1012 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1014 return __pEdit->SetTextSize(size);
1018 _SearchBar::GetBlockRange(int& start, int& end) const
1020 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1021 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1023 int startIndex = -1;
1026 __pEdit->GetBlockRange(startIndex, endIndex);
1027 SysTryReturn(NID_UI_CTRL, (startIndex > -1 && endIndex > 0), E_SYSTEM, E_SYSTEM,
1028 "[E_SYSTEM] A system error has occurred. Failed to get text block range.");
1037 _SearchBar::ReleaseBlock(void)
1039 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1040 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1042 result r = E_SUCCESS;
1047 r = GetBlockRange(start, end);
1048 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1050 return __pEdit->ReleaseTextBlock();
1054 _SearchBar::SetBlockRange(int start, int end)
1056 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1057 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1059 result r = E_SUCCESS;
1062 textLength = __pEdit->GetTextLength();
1064 SysTryReturn(NID_UI_CTRL, (start < end && start >= 0 && textLength >= end), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1065 "[E_OUT_OF_RANGE] start (%d) and end (%d) is out of range.", start, end - 1);
1067 r = SetCursorPosition(start);
1068 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1070 r = __pEdit->BeginTextBlock();
1071 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1072 "[E_SYSTEM] A system error has occurred. Failed to set text block range.");
1074 r = SetCursorPosition(end);
1075 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1076 "[E_SYSTEM] A system error has occurred. Failed to set cursor position.");
1082 _SearchBar::RemoveTextBlock(void)
1084 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1085 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1087 result r = E_SUCCESS;
1089 r = __pEdit->RemoveTextBlock();
1090 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1096 _SearchBar::GetColor(void) const
1098 Variant backgroundColor = GetProperty("color");
1100 return backgroundColor.ToColor();
1104 _SearchBar::GetSearchFieldColor(SearchFieldStatus status) const
1106 Variant searchFieldColor;
1110 case SEARCH_FIELD_STATUS_NORMAL:
1111 searchFieldColor = GetProperty("searchFieldNormalColor");
1113 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1114 searchFieldColor = GetProperty("searchFieldHighlightedColor");
1116 case SEARCH_FIELD_STATUS_DISABLED:
1117 searchFieldColor = GetProperty("searchFieldDisabledColor");
1123 return searchFieldColor.ToColor();
1128 _SearchBar::GetSearchFieldTextColor(SearchFieldStatus status) const
1130 Variant searchFieldTextColor;
1134 case SEARCH_FIELD_STATUS_NORMAL:
1135 searchFieldTextColor = GetProperty("searchFieldNormalTextColor");
1137 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1138 searchFieldTextColor = GetProperty("searchFieldHighlightedTextColor");
1140 case SEARCH_FIELD_STATUS_DISABLED:
1141 searchFieldTextColor = GetProperty("searchFieldDisabledTextColor");
1147 return searchFieldTextColor.ToColor();
1152 _SearchBar::SetBackgroundBitmap(const Bitmap& bitmap)
1154 Bitmap* pNewBitmap = _BitmapImpl::CloneN(bitmap);
1155 SysTryReturn(NID_UI_CTRL, pNewBitmap, E_SYSTEM, E_SYSTEM,
1156 "[E_SYSTEM] A system error has occurred. The creation of bitmap failed.");
1158 delete __pBackgroundBitmap;
1159 __pBackgroundBitmap = null;
1161 __pBackgroundBitmap = pNewBitmap;
1167 _SearchBar::GetBackgroundBitmap(void) const
1169 return __pBackgroundBitmap;
1173 _SearchBar::SetColor(const Color& color)
1175 return SetProperty("color", Variant(color));
1179 _SearchBar::SetSearchFieldColor(SearchFieldStatus status, const Color& color)
1181 result r = E_SUCCESS;
1185 case SEARCH_FIELD_STATUS_NORMAL:
1186 r = SetProperty("searchFieldNormalColor", Variant(color));
1188 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1189 r = SetProperty("searchFieldHighlightedColor", Variant(color));
1191 case SEARCH_FIELD_STATUS_DISABLED:
1192 r = SetProperty("searchFieldDisabledColor", Variant(color));
1203 _SearchBar::SetSearchFieldTextColor(SearchFieldStatus status, const Color& color)
1205 result r = E_SUCCESS;
1209 case SEARCH_FIELD_STATUS_NORMAL:
1210 r = SetProperty("searchFieldNormalTextColor", Variant(color));
1212 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1213 r = SetProperty("searchFieldHighlightedTextColor", Variant(color));
1215 case SEARCH_FIELD_STATUS_DISABLED:
1216 r = SetProperty("searchFieldDisabledTextColor", Variant(color));
1227 _SearchBar::GetGuideText(void) const
1229 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
1230 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1232 return __pEdit->GetGuideText();
1236 _SearchBar::SetGuideText(const String& guideText)
1238 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1239 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1241 __pEdit->SetGuideText(guideText);
1247 _SearchBar::GetGuideTextColor(void) const
1249 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1250 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1252 return __pEdit->GetGuideTextColor();
1256 _SearchBar::SetGuideTextColor(const Color& color)
1258 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1259 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1261 __isUserGuideTextColor = true;
1262 return __pEdit->SetGuideTextColor(color);
1266 _SearchBar::GetCursorPosition(void) const
1268 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
1269 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1271 return __pEdit->GetCursorPosition();
1275 _SearchBar::SetCursorPosition(int index)
1277 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1278 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1279 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1280 "[E_OUT_OF_RANGE] index(%d) is out of range.", GetErrorMessage(E_OUT_OF_RANGE), index);
1282 int textLength = -1;
1283 textLength = __pEdit->GetTextLength();
1285 SysTryReturn(NID_UI_CTRL, (index > -1 && index <= textLength), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1286 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
1288 return __pEdit->SetCursorPosition(index);
1292 _SearchBar::IsLowerCaseModeEnabled(void) const
1294 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1295 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1297 return __pEdit->IsLowerCaseModeEnabled();
1301 _SearchBar::SetLowerCaseModeEnabled(bool enable)
1303 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
1304 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1306 __pEdit->SetLowerCaseModeEnabled(enable);
1310 _SearchBar::GetEllipsisPosition(void) const
1312 SysTryReturn(NID_UI_CTRL, __pEdit, ELLIPSIS_POSITION_START, E_SYSTEM,
1313 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1315 return __pEdit->GetEllipsisPosition();
1319 _SearchBar::SetEllipsisPosition(EllipsisPosition position)
1321 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1322 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1323 __pEdit->SetEllipsisPosition(position);
1329 _SearchBar::GetKeypadAction(void) const
1331 return __keypadAction;
1335 _SearchBar::IsTextPredictionEnabled(void) const
1337 SysTryReturn(NID_UI_CTRL, __pEdit, false, E_SYSTEM,
1338 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1339 return __pEdit->IsTextPredictionEnabled();
1343 _SearchBar::SetTextPredictionEnabled(bool enable)
1345 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1346 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1347 return __pEdit->SetTextPredictionEnabled(enable);
1351 _SearchBar::SetCurrentLanguage(LanguageCode languageCode)
1353 return __pEdit->SetCurrentLanguage(languageCode);
1357 _SearchBar::GetCurrentLanguage(LanguageCode& language) const
1359 return __pEdit->GetCurrentLanguage(language);
1363 _SearchBar::AddActionEventListener(const _IActionEventListener& listener)
1365 result r = E_SUCCESS;
1367 if (__pActionEvent == null)
1369 __pActionEvent = _ActionEvent::CreateInstanceN(*this);
1370 r = GetLastResult();
1371 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1373 __pActionEvent->AddListener(listener);
1380 _SearchBar::RemoveActionEventListener(const _IActionEventListener& listener)
1382 SysTryReturn(NID_UI_CTRL, __pActionEvent, E_SYSTEM, E_SYSTEM,
1383 "[E_SYSTEM] A system error has occurred. The action event instance is null.");
1384 result r = E_SUCCESS;
1386 r = __pActionEvent->RemoveListener(listener);
1387 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1393 _SearchBar::AddKeypadEventListener(const _IKeypadEventListener& listener)
1395 result r = E_SUCCESS;
1397 if (__pKeypadEvent == null)
1399 __pKeypadEvent = _KeypadEvent::CreateInstanceN(*this);
1400 r = GetLastResult();
1401 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1403 r = __pKeypadEvent->AddListener(listener);
1404 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1411 _SearchBar::RemoveKeypadEventListener(const _IKeypadEventListener& listener)
1413 SysTryReturn(NID_UI_CTRL, __pKeypadEvent, E_SYSTEM, E_SYSTEM,
1414 "[E_SYSTEM] A system error has occurred. The keypad event instance is null.");
1415 result r = E_SUCCESS;
1417 r = __pKeypadEvent->RemoveListener(listener);
1418 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1424 _SearchBar::AddTextBlockEventListener(const _ITextBlockEventListener& listener)
1426 result r = E_SUCCESS;
1428 if (__pTextBlockEvent == null)
1430 __pTextBlockEvent = _TextBlockEvent::CreateInstanceN(*this);
1431 r = GetLastResult();
1432 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1434 r = __pTextBlockEvent->AddListener(listener);
1435 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1443 _SearchBar::RemoveTextBlockEventListener(const _ITextBlockEventListener& listener)
1445 SysTryReturn(NID_UI_CTRL, __pTextBlockEvent, E_SYSTEM, E_SYSTEM,
1446 "[E_SYSTEM] A system error has occurred. The text block event instance is null.");
1447 result r = E_SUCCESS;
1449 r = __pTextBlockEvent->RemoveListener(listener);
1450 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1457 _SearchBar::AddTextEventListener(const _ITextEventListener& listener)
1459 result r = E_SUCCESS;
1461 if (__pTextEvent == null)
1463 __pTextEvent = _TextEvent::CreateInstanceN(*this);
1464 r = GetLastResult();
1465 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1467 r = __pTextEvent->AddListener(listener);
1468 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1475 _SearchBar::RemoveTextEventListener(const _ITextEventListener& listener)
1477 SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM,
1478 "[E_SYSTEM] A system error has occurred. The text event instance is null.");
1479 result r = E_SUCCESS;
1481 r = __pTextEvent->RemoveListener(listener);
1482 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1488 _SearchBar::AddSearchBarEventListener(const _ISearchBarEventListener& listener)
1490 result r = E_SUCCESS;
1492 if (__pSearchBarEvent == null)
1494 __pSearchBarEvent = _SearchBarEvent::CreateInstanceN(*this);
1495 r = GetLastResult();
1496 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1498 r = __pSearchBarEvent->AddListener(listener);
1499 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1506 _SearchBar::RemoveSearchBarEventListener(const _ISearchBarEventListener& listener)
1508 SysTryReturn(NID_UI_CTRL, __pSearchBarEvent, E_SYSTEM, E_SYSTEM,
1509 "[E_SYSTEM] A system error has occurred. The searchbar event instance is null.");
1510 result r = E_SUCCESS;
1512 r = __pSearchBarEvent->RemoveListener(listener);
1513 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1519 _SearchBar::AddLanguageEventListener(const _ILanguageEventListener& listener)
1521 result r = E_SUCCESS;
1523 if (__pLanguageEvent == null)
1525 __pLanguageEvent = _LanguageEvent::CreateInstanceN(*this);
1526 r = GetLastResult();
1527 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1529 r = __pLanguageEvent->AddListener(listener);
1530 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1537 _SearchBar::RemoveLanguageEventListener(const _ILanguageEventListener& listener)
1539 SysTryReturn(NID_UI_CTRL, __pLanguageEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.");
1540 result r = E_SUCCESS;
1542 __pLanguageEvent->RemoveListener(listener);
1543 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1549 _SearchBar::OnBoundsChanged(void)
1551 if (__pSearchBarPresenter != null)
1553 __isupdateContentBounds = true;
1554 __pSearchBarPresenter->OnBoundsChanged();
1560 _SearchBar::OnChangeLayout(_ControlOrientation orientation)
1562 __isupdateContentBounds = true;
1567 _SearchBar::OnDraw(void)
1569 if (!__isUserGuideTextColor)
1571 SearchFieldStatus status = GetCurrentStatus();
1572 __pEdit->SetGuideTextColor(__guideTextColor[status]);
1575 if (__isupdateContentBounds)
1578 __isupdateContentBounds = false;
1580 __pSearchBarPresenter->Draw();
1584 _UiTouchEventDelivery
1585 _SearchBar::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1587 _Edit* pEdit = dynamic_cast <_Edit*>(const_cast <_Control*>(&source));
1590 return _UI_TOUCH_EVENT_DELIVERY_YES;
1593 if (GetMode() == SEARCH_BAR_MODE_INPUT)
1595 return _UI_TOUCH_EVENT_DELIVERY_YES;
1598 SetMode(SEARCH_BAR_MODE_INPUT);
1600 return _UI_TOUCH_EVENT_DELIVERY_YES;
1604 _SearchBar::OnActionPerformed(const _Control& source, int actionId)
1606 if (__actionId == actionId)
1608 __isCancelActionInProgress = true;
1609 SetMode(SEARCH_BAR_MODE_NORMAL);
1613 IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(__actionId);
1614 result r = GetLastResult();
1615 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1617 __pActionEvent->Fire(*pEventArg);
1619 __isCancelActionInProgress = false;
1626 _SearchBar::OnKeypadWillOpen(void)
1628 if (!__isKeypadOpening)
1632 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CREATED);
1633 result r = GetLastResult();
1634 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1636 __pKeypadEvent->Fire(*pEventArg);
1640 __isKeypadOpening = true;
1645 _SearchBar::OnKeypadOpened(void)
1649 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_OPEN);
1650 result r = GetLastResult();
1651 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1653 __pKeypadEvent->Fire(*pEventArg);
1656 __isKeypadOpening = false;
1662 _SearchBar::OnKeypadClosed(void)
1666 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CLOSE);
1667 result r = GetLastResult();
1668 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1670 __pKeypadEvent->Fire(*pEventArg);
1678 _SearchBar::OnKeypadBoundsChanged(void)
1682 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1683 result r = GetLastResult();
1684 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1686 __pKeypadEvent->Fire(*pEventArg);
1694 _SearchBar::OnKeypadActionPerformed(CoreKeypadAction keypadAction)
1698 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(keypadAction, CORE_KEYPAD_EVENT_STATUS_ENTERACTION);
1699 result r = GetLastResult();
1700 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1702 __pKeypadEvent->Fire(*pEventArg);
1707 // TextBlock callbacks
1709 _SearchBar::OnTextBlockSelected(_Control& source, int start, int end)
1711 if (__pTextBlockEvent)
1713 IEventArg* pEventArg = _TextBlockEvent::CreateTextBlockEventArgN(start, end);
1714 result r = GetLastResult();
1715 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1717 __pTextBlockEvent->Fire(*pEventArg);
1724 _SearchBar::OnTextValueChanged(const _Control& source)
1726 if (!__isCancelActionInProgress)
1728 SetContentDimming();
1729 if (__pTextEvent != null)
1731 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CHANGED);
1732 result r = GetLastResult();
1733 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1735 __pTextEvent->Fire(*pEventArg);
1742 _SearchBar::OnTextValueChangeCanceled(const _Control& source)
1744 if (__pTextEvent != null)
1746 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CANCELED);
1747 result r = GetLastResult();
1748 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1750 __pTextEvent->Fire(*pEventArg);
1756 _SearchBar::OnAttachedToMainTree(void)
1764 _SearchBar::OnFontChanged(Font* pFont)
1766 __pCancelButton->SetFont(pFont->GetFaceName());
1767 __pEdit->SetFont(*pFont);
1772 _SearchBar::OnFontInfoRequested(unsigned long& style, int& size)
1774 style = FONT_STYLE_PLAIN;
1775 size = __pCancelButton->GetTextSize();
1781 _SearchBar::OnFocusGained(const _Control& source)
1783 SetMode(SEARCH_BAR_MODE_INPUT);
1784 __pEdit->SetFocused();
1789 _SearchBar::OnFocusLost(const _Control& source)
1795 _SearchBar::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1797 if (!__pEdit->IsUsbKeyboardConnected())
1802 _KeyCode keyCode = keyInfo.GetKeyCode();
1804 if (keyCode == _KEY_RIGHT)
1806 if (__isButtonEnabled)
1808 __pEdit->SetFocused(false);
1809 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED);
1810 __pCancelButton->SetFocused();
1811 __pCancelButton->Invalidate(true);
1817 if (keyCode == _KEY_LEFT)
1819 if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_HIGHLIGHTED)
1821 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1822 __pCancelButton->SetFocused(false);
1823 __pCancelButton->Invalidate();
1827 if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_DISABLED) //Searchbar Button is disabled, left arrow key is pressed
1829 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1830 SetButtonEnabled(false);
1833 __pEdit->SetFocused();
1842 _SearchBar::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
1848 _SearchBar::GetParentForm(void) const
1850 _Form* pForm = null;
1851 _Control* pControlCore = GetParent();
1855 if (pControlCore == null)
1857 SysLog(NID_UI_CTRL,"[E_SYSTEM] The parent form is null.");
1862 pForm = dynamic_cast <_Form*>(pControlCore);
1869 pControlCore = pControlCore->GetParent();
1872 return pControlCore;
1876 _SearchBar::GetSearchBarButton(void) const
1878 return __pCancelButton;
1882 _SearchBar::GetSearchField(void)
1888 _SearchBar::GetSearchBarContainer(void) const
1890 return __pContainer;
1894 _SearchBar::GetClippedGroupControl(void) const
1896 return __pClippedGroupControl;
1900 _SearchBar::IsUsableCancelButton(void) const
1902 return __isUsableCancelButton;
1906 _SearchBar::ConvertSearchBarStatus(SearchFieldStatus status)
1908 EditStatus editStatus = EDIT_STATUS_NORMAL;
1911 case SEARCH_FIELD_STATUS_NORMAL:
1912 editStatus = EDIT_STATUS_NORMAL;
1915 case SEARCH_FIELD_STATUS_DISABLED:
1916 editStatus = EDIT_STATUS_DISABLED;
1919 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1920 editStatus = EDIT_STATUS_HIGHLIGHTED;
1930 _SearchBar::ConvertSearchBarButtonStatus(SearchBarButtonStatus status)
1932 _ButtonStatus buttonStatus = _BUTTON_STATUS_NORMAL;
1936 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
1937 buttonStatus = _BUTTON_STATUS_NORMAL;
1940 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
1941 buttonStatus = _BUTTON_STATUS_PRESSED;
1944 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
1945 buttonStatus = _BUTTON_STATUS_HIGHLIGHTED;
1948 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
1949 buttonStatus = _BUTTON_STATUS_DISABLED;
1955 return buttonStatus;
1959 _SearchBar::SendSearchBarEvent(_SearchBarEventStatus status)
1961 result r = E_SUCCESS;
1962 if (__pSearchBarEvent)
1964 IEventArg* pEventArg = _SearchBarEvent::CreateSearchBarEventArgN(status);
1965 r = GetLastResult();
1966 SysTryReturn(NID_UI_CTRL, pEventArg, r, r, "[%s] Propagating.", GetErrorMessage(r));
1968 if (IsContentAreaVisible() == false)
1970 SetContentAreaVisible(false);
1973 __pSearchBarEvent->Fire(*pEventArg);
1980 _SearchBar::SetHeaderVisibleState(bool visible)
1982 if (__pSearchBarPresenter != null)
1984 __pSearchBarPresenter->SetHeaderVisibleState(visible);
1990 _SearchBar::SetPropertyButtonActionId(const Variant& actionId)
1992 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1993 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1994 SysTryReturn(NID_UI_CTRL, actionId.ToInt() > -1, E_INVALID_ARG, E_INVALID_ARG,
1995 "[E_INVALID_ARG] Invalid argument(s) is used. actionId.ToInt() = %d", actionId.ToInt());
1997 result r = E_SUCCESS;
1999 r = __pCancelButton->SetPropertyActionId(actionId);
2000 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2001 "[%s] A system error has occurred. Failed to set actionId.", GetErrorMessage(E_SYSTEM));
2003 __actionId = actionId.ToInt();
2009 _SearchBar::GetPropertyButtonActionId(void) const
2011 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(-1), E_SYSTEM,
2012 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2014 return Variant(__actionId);
2018 _SearchBar::SetPropertyButtonDisabledColor(const Variant& color)
2020 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2021 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2023 result r = E_SUCCESS;
2025 r = __pCancelButton->SetPropertyDisabledColor(color);
2026 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2027 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2029 __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = color.ToColor();
2035 _SearchBar::GetPropertyButtonDisabledColor(void) const
2037 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2038 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2040 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2044 _SearchBar::SetPropertyButtonHighlightedColor(const Variant& color)
2046 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2047 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2049 result r = E_SUCCESS;
2051 r = __pCancelButton->SetPropertyHighlightedColor(color);
2052 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2053 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2055 __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
2061 _SearchBar::GetPropertyButtonHighlightedColor(void) const
2063 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2064 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2066 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2070 _SearchBar::SetPropertyButtonNormalColor(const Variant& color)
2072 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2073 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2075 result r = E_SUCCESS;
2077 r = __pCancelButton->SetPropertyNormalColor(color);
2078 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2079 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2081 __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = color.ToColor();
2087 _SearchBar::GetPropertyButtonNormalColor(void) const
2089 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2090 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2092 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2096 _SearchBar::SetPropertyButtonPressedColor(const Variant& color)
2098 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2099 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2101 result r = E_SUCCESS;
2103 r = __pCancelButton->SetPropertyPressedColor(color);
2104 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2105 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2107 __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = color.ToColor();
2113 _SearchBar::GetPropertyButtonPressedColor(void) const
2115 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2116 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2118 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2122 _SearchBar::SetPropertyButtonDisabledTextColor(const Variant& textColor)
2124 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2125 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2127 result r = E_SUCCESS;
2129 r = __pCancelButton->SetPropertyDisabledTextColor(textColor);
2130 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2131 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2133 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = textColor.ToColor();
2139 _SearchBar::GetPropertyButtonDisabledTextColor(void) const
2141 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2142 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2144 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2148 _SearchBar::SetPropertyButtonHighlightedTextColor(const Variant& textColor)
2150 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2151 "[E_SYSTEM]] A system error has occurred. The cancel button instance is null.");
2153 result r = E_SUCCESS;
2155 r = __pCancelButton->SetPropertyHighlightedTextColor(textColor);
2156 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2157 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2159 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = textColor.ToColor();
2165 _SearchBar::GetPropertyButtonHighlightedTextColor(void) const
2167 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2168 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2170 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2174 _SearchBar::SetPropertyButtonNormalTextColor(const Variant& textColor)
2176 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2177 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2179 result r = E_SUCCESS;
2181 r = __pCancelButton->SetPropertyNormalTextColor(textColor);
2182 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2183 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2185 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = textColor.ToColor();
2191 _SearchBar::GetPropertyButtonNormalTextColor(void) const
2193 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2194 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2196 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2200 _SearchBar::SetPropertyButtonPressedTextColor(const Variant& textColor)
2202 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2203 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2205 result r = E_SUCCESS;
2207 r = __pCancelButton->SetPropertyPressedTextColor(textColor);
2208 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2209 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2211 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = textColor.ToColor();
2217 _SearchBar::GetPropertyButtonPressedTextColor(void) const
2219 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2220 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2222 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2226 _SearchBar::SetPropertySearchFieldDisabledColor(const Variant& color)
2228 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2229 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2231 result r = E_SUCCESS;
2233 r = __pEdit->SetPropertyDisabledColor(color);
2234 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2235 "[E_SYSTEM] A system error has occurred. Failed to set the edit disabled color.");
2237 __color[SEARCH_FIELD_STATUS_DISABLED] = color.ToColor();
2243 _SearchBar::GetPropertySearchFieldDisabledColor(void) const
2245 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2246 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2248 return Variant(__color[SEARCH_FIELD_STATUS_DISABLED]);
2252 _SearchBar::SetPropertySearchFieldHighlightedColor(const Variant& color)
2254 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2255 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2257 result r = E_SUCCESS;
2259 r = __pEdit->SetPropertyHighlightedColor(color);
2260 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2261 "[E_SYSTEM] A system error has occurred. Failed to set the edit highlighted color.");
2263 __color[SEARCH_FIELD_STATUS_HIGHLIGHTED] = color.ToColor();
2269 _SearchBar::GetPropertySearchFieldHighlightedColor(void) const
2271 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2272 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2274 return Variant(__color[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2278 _SearchBar::SetPropertySearchFieldNormalColor(const Variant& color)
2280 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2281 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2283 result r = E_SUCCESS;
2285 r = __pEdit->SetPropertyNormalColor(color);
2286 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2287 "[E_SYSTEM] A system error has occurred. Failed to set edit normal color.");
2289 __color[SEARCH_FIELD_STATUS_NORMAL] = color.ToColor();
2295 _SearchBar::GetPropertySearchFieldNormalColor(void) const
2297 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2298 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2300 return Variant(__color[SEARCH_FIELD_STATUS_NORMAL]);
2304 _SearchBar::SetPropertySearchFieldDisabledTextColor(const Variant& textColor)
2306 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2307 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2309 result r = E_SUCCESS;
2311 r = __pEdit->SetPropertyDisabledTextColor(textColor);
2312 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2313 "[E_SYSTEM] A system error has occurred. Failed to set edit disabled text color.");
2315 __textColor[SEARCH_FIELD_STATUS_DISABLED] = textColor.ToColor();
2321 _SearchBar::GetPropertySearchFieldDisabledTextColor(void) const
2323 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2324 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2326 return Variant(__textColor[SEARCH_FIELD_STATUS_DISABLED]);
2330 _SearchBar::SetPropertySearchFieldHighlightedTextColor(const Variant& textColor)
2332 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2333 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2335 result r = E_SUCCESS;
2337 r = __pEdit->SetPropertyHighlightedTextColor(textColor);
2338 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2339 "[E_SYSTEM] A system error has occurred. Failed to set edit highlighted text color.");
2341 __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED] = textColor.ToColor();
2347 _SearchBar::GetPropertySearchFieldHighlightedTextColor(void) const
2349 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2350 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2352 return Variant(__textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2356 _SearchBar::SetPropertySearchFieldNormalTextColor(const Variant& textColor)
2358 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2359 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2361 result r = E_SUCCESS;
2363 r = __pEdit->SetPropertyNormalTextColor(textColor);
2364 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2365 "[E_SYSTEM] A system error has occurred. Failed to set edit normal text color.");
2367 __textColor[SEARCH_FIELD_STATUS_NORMAL] = textColor.ToColor();
2373 _SearchBar::GetPropertySearchFieldNormalTextColor(void) const
2375 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2376 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2378 return Variant(__textColor[SEARCH_FIELD_STATUS_NORMAL]);
2382 _SearchBar::SetPropertyColor(const Variant& color)
2384 __backgroundColor = color.ToColor();
2390 _SearchBar::GetPropertyColor(void) const
2392 return Variant(__backgroundColor);
2396 _SearchBar::SetPropertyContentAreaSize(const Variant& size)
2398 FloatDimension contentAreaSize = size.ToFloatDimension();
2399 SysTryReturn(NID_UI_CTRL, contentAreaSize.width >= 0 && contentAreaSize.height >= 0, E_INVALID_ARG, E_INVALID_ARG,
2400 "[E_INVALID_ARG] Invalid argument(s) is used. contentAreaSize.width = %f, contenAreaSize.height = %f",
2401 contentAreaSize.width, contentAreaSize.height);
2403 result r = E_SUCCESS;
2406 FloatRectangle bounds = GetBoundsF();
2407 FloatRectangle contentAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
2409 contentAreaBounds.x = 0.0f;
2410 contentAreaBounds.y = bounds.height;
2411 contentAreaBounds.width = contentAreaSize.width;
2412 contentAreaBounds.height = contentAreaSize.height;
2414 __contentAreaBounds = contentAreaBounds;
2415 __isUserContainerBounds = true;
2420 r = __pContainer->SetBounds(__contentAreaBounds);
2421 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2428 _SearchBar::GetPropertyContentAreaSize(void) const
2430 FloatDimension contentAreaSize(__contentAreaBounds.width, __contentAreaBounds.height);
2432 return Variant(contentAreaSize);
2436 _SearchBar::CreateClippedGroupControl(void)
2438 result r = E_SUCCESS;
2439 FloatRectangle clippedGroupControlBounds(FloatPoint(0.0f, 0.0f), GetSizeF());
2440 __pClippedGroupControl = _Control::CreateControlN();
2441 r = GetLastResult();
2442 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2444 r = AttachChild(*__pClippedGroupControl);
2445 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
2446 "[E_SYSTEM] A system error has occurred. Failed to attach the parent of clipped control.");
2448 r = __pClippedGroupControl->SetBounds(clippedGroupControlBounds);
2449 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2451 __pClippedGroupControl->SetBackgroundColor(Color(0));
2453 __pClippedGroupControl->SetClipChildrenEnabled(true);
2458 delete __pClippedGroupControl;
2459 __pClippedGroupControl = null;
2466 _SearchBar::SetContentDimming(void)
2468 if (__pContainer != NULL)
2470 if (!GetTextLength())
2472 __contentColor.SetAlpha(_SEARCH_CONTENT_DIM_OPACITY);
2476 __contentColor.SetAlpha(0);
2478 __pContainer->SetBackgroundColor(__contentColor);
2484 _SearchBar::IsContentAttachable(const _Control* pContent)
2486 const _Window* pWindow = dynamic_cast <const _Window*>(pContent);
2487 const _ColorPicker* pColorPicker = dynamic_cast <const _ColorPicker*>(pContent);
2488 const _Form* pForm = dynamic_cast <const _Form*>(pContent);
2489 const _Keypad* pKeypad = dynamic_cast <const _Keypad*>(pContent);
2490 const _OverlayPanel* pOverlayPanel = dynamic_cast <const _OverlayPanel*>(pContent);
2492 bool isContentAttachable = true;
2494 isContentAttachable = ((pWindow == null) && (pColorPicker == null) &&
2495 (pForm == null) && (pKeypad == null) && (pOverlayPanel == null));
2496 return isContentAttachable;
2500 _SearchBar::ResizeCancelButton(void)
2502 result r = E_SUCCESS;
2504 float horizontalMargin = 0.0f;
2505 float buttonLeftMargin = 0.0f;
2506 float buttonRightMargin = 0.0f;
2507 float buttonMinWidth = 0.0f;
2508 float searchFieldMinWidth = 0.0f;
2509 float buttonVerticalMargin = 0.0f;
2510 float searchBarMinHeight = 0.0f;
2511 float buttonWidth = 0.0f;
2512 float buttonHeight = 0.0f;
2514 FloatRectangle cancelButtonBounds;
2515 FloatRectangle searchBarBounds = GetBoundsF();
2517 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2519 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2520 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2521 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2522 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2523 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2524 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2525 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2526 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2527 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2529 cancelButtonBounds.width = buttonWidth;
2530 cancelButtonBounds.height = buttonHeight;
2532 float buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth +
2533 cancelButtonBounds.width + buttonLeftMargin + buttonRightMargin);
2535 if (searchBarBounds.width < buttonResizableSearchBarWidth)
2537 cancelButtonBounds.width = searchBarBounds.width -(searchFieldMinWidth + buttonLeftMargin
2538 + buttonRightMargin + horizontalMargin);
2541 cancelButtonBounds.x = searchBarBounds.width - cancelButtonBounds.width - buttonRightMargin;
2542 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2544 cancelButtonBounds.y = cancelButtonBounds.y < 0.0f ? 0.0f:cancelButtonBounds.y;
2546 if (cancelButtonBounds.width < buttonMinWidth)
2548 cancelButtonBounds.width = buttonMinWidth;
2551 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2552 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2553 r = __pCancelButton->SetBounds(cancelButtonBounds);
2559 _SearchBar::RecalculateButtonBounds(void)
2561 result r = E_SUCCESS;
2563 float horizontalMargin = 0.0f;
2564 float verticalMargin = 0.0f;
2565 float buttonLeftMargin = 0.0f;
2566 float buttonRightMargin = 0.0f;
2567 float buttonMinWidth = 0.0f;
2568 float searchFieldMinWidth = 0.0f;
2569 float buttonVerticalMargin = 0.0f;
2570 float searchBarMinHeight = 0.0f;
2571 float buttonWidth = 0.0f;
2572 float buttonHeight = 0.0f;
2573 float cancelButtonWidth = 0.0f;
2575 FloatRectangle cancelButtonBounds;
2576 FloatRectangle editBounds;
2577 FloatRectangle searchBarBounds = GetBoundsF();
2579 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2581 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2582 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin);
2583 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2584 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2585 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2586 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2587 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2588 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2589 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2590 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2592 cancelButtonBounds.height = buttonHeight;
2594 float searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2.0f);
2595 cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightTouchMarginF() + __pCancelButton->GetLeftTouchMarginF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF();
2596 editBounds.x = horizontalMargin;
2598 if (searchBarBounds.height < searchBarMinHeight)
2600 verticalMargin = (searchBarBounds.height - searchFieldMinHeight)/2.0f;
2601 if (verticalMargin < 0.0f)
2603 verticalMargin = 0.0f;
2607 editBounds.y = verticalMargin;
2608 editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
2610 editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
2612 editBounds.width = searchBarBounds.width - cancelButtonWidth - horizontalMargin - buttonLeftMargin - buttonRightMargin;
2614 if (editBounds.width < searchFieldMinWidth)
2616 editBounds.width = searchFieldMinWidth;
2619 cancelButtonBounds.x = editBounds.width + horizontalMargin + buttonLeftMargin;
2620 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2622 cancelButtonBounds.y = cancelButtonBounds.y < 0.0f ? 0.0f:cancelButtonBounds.y;
2624 float remainingWidth = searchBarBounds.width - editBounds.width - horizontalMargin - buttonLeftMargin - buttonRightMargin;
2626 if (remainingWidth < buttonMinWidth)
2628 cancelButtonBounds.width = buttonMinWidth;
2632 cancelButtonBounds.width = searchBarBounds.width - cancelButtonBounds.x - buttonRightMargin;
2635 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2636 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2638 r = __pCancelButton->SetBounds(cancelButtonBounds);
2639 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2640 r = __pEdit->SetBounds(editBounds);
2641 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2647 _SearchBar::GetCurrentStatus(void)
2649 SearchFieldStatus searchFieldStatus = SEARCH_FIELD_STATUS_NORMAL;
2653 if (__pEdit->IsFocused())
2655 searchFieldStatus = SEARCH_FIELD_STATUS_HIGHLIGHTED;
2660 searchFieldStatus = SEARCH_FIELD_STATUS_DISABLED;
2663 return searchFieldStatus;
2667 _SearchBar::SetEditTextFilter(IEditTextFilter* pFilter)
2669 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2670 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2672 __pEdit->SetEditTextFilter(pFilter);
2678 _SearchBar::SendOpaqueCommand(const String& command)
2680 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2681 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2683 __pEdit->SendOpaqueCommand(command);
2688 }}} // Tizen::Ui::Controls