2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 , __keypadAction(CORE_KEYPAD_ACTION_SEARCH)
70 , __pBackgroundBitmap(null)
71 , __backgroundColor(Color())
72 , __contentColor(Color())
73 , __pActionEvent(null)
74 , __pKeypadEvent(null)
75 , __pTextBlockEvent(null)
77 , __pSearchBarEvent(null)
78 , __pLanguageEvent(null)
80 for (int i = 0; i < SEARCHBAR_BUTTON_COLOR_MAX; i++)
82 __buttonColor[i] = Color(0);
83 __buttonTextColor[i] = Color(0);
86 for (int i = 0; i < SEARCHBAR_COLOR_MAX; i++)
88 __color[i] = Color(0);
89 __textColor[i] = Color(0);
90 __guideTextColor[i] = Color(0);
93 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
96 pContainer->Activate(true);
100 _SearchBar::~_SearchBar(void)
103 delete __pSearchBarPresenter;
104 __pSearchBarPresenter = null;
108 __pEdit->HideKeypad();
110 __pClippedGroupControl->DetachChild(*__pEdit);
118 __pClippedGroupControl->DetachChild(*__pCancelButton);
120 delete __pCancelButton;
121 __pCancelButton = null;
124 if (__pClippedGroupControl)
126 DetachChild(*__pClippedGroupControl);
128 delete __pClippedGroupControl;
129 __pClippedGroupControl = null;
134 DetachChild(*__pContainer);
142 delete __pActionEvent;
143 __pActionEvent = null;
148 delete __pKeypadEvent;
149 __pKeypadEvent = null;
152 if (__pTextBlockEvent)
154 delete __pTextBlockEvent;
155 __pTextBlockEvent = null;
164 if (__pSearchBarEvent)
166 delete __pSearchBarEvent;
167 __pSearchBarEvent = null;
170 delete __pBackgroundBitmap;
171 __pBackgroundBitmap = null;
175 _SearchBar::CreateSearchBarN(void)
177 _SearchBar* pSearchBar = new (std::nothrow) _SearchBar;
178 SysTryReturn(NID_UI_CTRL, pSearchBar, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
179 if (GetLastResult() != E_SUCCESS)
185 pSearchBar->AcquireHandle();
191 _SearchBar::Initialize(bool enableSearchBarButton, CoreKeypadAction keypadAction)
193 result r = E_SUCCESS;
195 // Setting Button color
196 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_NORMAL, __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
197 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_PRESSED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
198 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_HIGHLIGHTED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
199 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_DISABLED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
201 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_NORMAL, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
202 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_PRESSED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
203 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_HIGHLIGHTED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
204 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_DISABLED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
206 GET_COLOR_CONFIG(SEARCHBAR::CONTENT_AREA_BG_NORMAL, __contentColor);
208 for (int i = 0; i < SEARCHBAR_COLOR_MAX; i++)
212 case SEARCH_FIELD_STATUS_DISABLED:
213 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_DISABLED, __color[i]);
214 GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_DISABLED, __guideTextColor[i]);
217 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
218 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]);
219 GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_HIGHLIGHTED, __guideTextColor[i]);
222 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[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;
270 _SearchBar::CreateSearchField(void)
272 result r = E_SUCCESS;
274 FloatRectangle editBounds;
275 int horizontalMargin = 0;
276 int verticalMargin = 0;
277 int iconHorizontalMargin = 0;
278 int textHorizontalMargin = 0;
281 int searchFieldMinWidth = 0;
282 int searchBarMinHeight = 0;
284 FloatRectangle searchBarBounds = GetBoundsF();
285 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
286 _AccessibilityContainer* pSearchBarContainer = null;
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, orientation, searchFieldMinWidth);
294 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
296 int searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2);
298 editBounds.x = _CoordinateSystemUtils::ConvertToFloat(horizontalMargin);
299 editBounds.y = _CoordinateSystemUtils::ConvertToFloat(verticalMargin);
300 editBounds.width = searchBarBounds.width - (editBounds.x * 2.0f);
301 editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
303 editBounds.width = (editBounds.width > searchFieldMinWidth) ? editBounds.width : searchFieldMinWidth;
304 editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
307 __pEdit = _Edit::CreateEditN();
309 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
311 r = __pEdit->Initialize(EDIT_STYLE_NORMAL | EDIT_STYLE_SINGLE_LINE | EDIT_STYLE_CLEAR | EDIT_STYLE_NOSCROLL, INPUT_STYLE_OVERLAY,
312 SEARCHBAR_TEXT_LENGTH_MAX);
313 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
315 __pEdit->SetKeypadCommandButtonVisible(false);
316 __pEdit->SetBounds(editBounds);
317 __pEdit->AddKeypadEventListener(*this);
318 __pEdit->AddTextBlockEventListener(*this);
319 __pEdit->AddTextEventListener(*this);
321 GET_SHAPE_CONFIG(SEARCHBAR::EDIT_TEXT_SIZE, orientation, textSize);
322 __pEdit->SetTextSize(textSize);
324 __pEdit->SetHorizontalMargin(iconHorizontalMargin + iconWidth + textHorizontalMargin, EDIT_TEXT_LEFT_MARGIN);
325 __pEdit->SetHorizontalMargin(textHorizontalMargin, EDIT_TEXT_RIGHT_MARGIN);
326 __pEdit->SetLimitLength(SEARCHBAR_TEXT_LENGTH_MAX);
328 for (int status = 0; status < SEARCHBAR_COLOR_MAX; status++)
330 EditStatus editStatus = ConvertSearchBarStatus((SearchFieldStatus) status);
331 __pEdit->SetColor(editStatus, __color[status]);
334 __pEdit->ReplaceDefaultBackgroundBitmapForSearchBar();
335 __pEdit->SetPressedGuideTextColor(__guideTextColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
337 __pEdit->SetKeypadAction(__keypadAction);
339 r = __pClippedGroupControl->AttachChild(*__pEdit);
340 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
341 "[E_SYSTEM] A system error has occurred. Failed to attach edit as child.");
343 if (likely(!(_AccessibilityManager::IsActivated())))
348 pSearchBarContainer = GetAccessibilityContainer();
349 if (pSearchBarContainer)
351 _AccessibilityContainer* pSearchFieldContainer = __pEdit->GetAccessibilityContainer();
352 if (pSearchFieldContainer)
354 pSearchBarContainer->AddChildContainer(*pSearchFieldContainer);
368 _SearchBar::CreateCancelButton(void)
370 result r = E_SUCCESS;
373 String cancelButtonText;
375 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
376 _AccessibilityContainer* pSearchBarContainer = null;
378 __pCancelButton = _Button::CreateButtonN();
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.");
419 if (likely(!(_AccessibilityManager::IsActivated())))
424 pSearchBarContainer = GetAccessibilityContainer();
425 if (pSearchBarContainer)
427 _AccessibilityContainer* pButtonContainer = __pCancelButton->GetAccessibilityContainer();
428 if (pButtonContainer)
430 pSearchBarContainer->AddChildContainer(*pButtonContainer);
437 delete __pCancelButton;
438 __pCancelButton = null;
444 _SearchBar::CreateContentsArea(void)
446 result r = E_SUCCESS;
448 __pContainer = _Control::CreateControlN();
451 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
453 __pContainer->SetVisibleState(false);
455 r = AttachChild(*__pContainer);
456 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
457 "[E_SYSTEM] A system error has occurred. Failed to attach the parent of content.");
469 _SearchBar::SetContentsArea(void)
471 if (__isUserContainerBounds)
476 FloatDimension screenSize = _ControlManager::GetInstance()->GetScreenSizeF();
477 float width = screenSize.width;
478 float height = screenSize.height;
480 _Control* pParent = GetParentForm();
483 width = pParent->GetClientBoundsF().width;
484 height = pParent->GetClientBoundsF().height;
487 __contentAreaBounds = GetBoundsF();
488 __contentAreaBounds.x = 0.0f;
489 __contentAreaBounds.y = __contentAreaBounds.height;
490 __contentAreaBounds.width = width;
491 __contentAreaBounds.height = height - __contentAreaBounds.height;
495 result r = E_SUCCESS;
496 r = __pContainer->SetBounds(__contentAreaBounds);
497 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
503 _SearchBar::GetContent(void) const
505 return __pContentControl;
509 _SearchBar::SetContent(const _Control* pContent)
511 __pContentControl = const_cast <_Control*>(pContent);
512 result r = E_SUCCESS;
516 r = __pContainer->AttachChild(*__pContentControl);
517 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating");
524 _SearchBar::UpdateContentArea(bool invalidate)
526 return __pSearchBarPresenter->UpdateContentArea(invalidate);
530 _SearchBar::SetContentAreaVisible(bool visible)
532 SysTryReturn(NID_UI_CTRL, __pContainer, E_SYSTEM, E_SYSTEM,
533 "[E_SYSTEM] A system error has occurred. The instance of parent to content is null.");
535 SearchBarMode searchBarMode = GetMode();
536 if (searchBarMode == SEARCH_BAR_MODE_INPUT)
538 __pContainer->SetVisibleState(visible);
541 return __pSearchBarPresenter->SetContentAreaVisible(visible);
545 _SearchBar::IsContentAreaVisible(void) const
547 return __pSearchBarPresenter->IsContentAreaVisible();
551 _SearchBar::SetContentAreaSize(const Dimension& size)
553 return SetProperty("contentAreaSize", Variant(size));
557 _SearchBar::GetContentAreaSize(void) const
559 Variant size = GetProperty("contentAreaSize");
561 return size.ToDimension();
565 _SearchBar::GetMode(void) const
567 return __pSearchBarPresenter->GetMode();
571 _SearchBar::IsModeLocked(void) const
573 return __pSearchBarPresenter->IsModeLocked();
577 _SearchBar::SetMode(SearchBarMode mode)
579 return __pSearchBarPresenter->SetMode(mode);
583 _SearchBar::SetModeLocked(bool modeLocked)
585 return __pSearchBarPresenter->SetModeLocked(modeLocked);
589 _SearchBar::GetButtonActionId(void) const
591 Variant actionId = GetProperty("buttonActionId");
593 return actionId.ToInt();
597 _SearchBar::GetButtonColor(SearchBarButtonStatus status) const
603 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
604 buttonColor = GetProperty("buttonNormalColor");
606 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
607 buttonColor = GetProperty("buttonPressedColor");
609 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
610 buttonColor = GetProperty("buttonHighlightedColor");
612 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
613 buttonColor = GetProperty("buttonDisabledColor");
619 return buttonColor.ToColor();
623 _SearchBar::GetButtonTextColor(SearchBarButtonStatus status) const
625 Variant buttonTextColor;
629 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
630 buttonTextColor = GetProperty("buttonNormalTextColor");
632 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
633 buttonTextColor = GetProperty("buttonPressedTextColor");
635 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
636 buttonTextColor = GetProperty("buttonHighlightedTextColor");
638 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
639 buttonTextColor = GetProperty("buttonDisabledTextColor");
645 return buttonTextColor.ToColor();
648 SearchBarButtonStatus
649 _SearchBar::GetButtonStatus(void) const
651 SysTryReturn(NID_UI_CTRL, __pCancelButton, SEARCH_BAR_BUTTON_STATUS_NORMAL, E_SYSTEM,
652 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
654 SearchBarButtonStatus buttonStatus = SEARCH_BAR_BUTTON_STATUS_NORMAL;
656 if (__isButtonEnabled == false)
658 buttonStatus = SEARCH_BAR_BUTTON_STATUS_DISABLED;
665 _SearchBar::SetButtonText(const String& text)
667 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
668 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
670 result r = E_SUCCESS;
672 r = __pCancelButton->SetText(text);
673 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
674 "[E_SYSTEM] A system error has occurred. Failed to set text.");
680 _SearchBar::SetButtonActionId(int actionId)
682 return SetProperty("buttonActionId", Variant(actionId));
686 _SearchBar::SetButtonEnabled(bool enabled)
688 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
689 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
691 __pCancelButton->SetEnableState(enabled);
693 __isButtonEnabled = enabled;
699 _SearchBar::SetButtonColor(SearchBarButtonStatus status, const Color& color)
701 result r = E_SUCCESS;
705 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
706 r = SetProperty("buttonNormalColor", Variant(color));
708 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
709 r = SetProperty("buttonPressedColor", Variant(color));
711 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
712 r = SetProperty("buttonHighlightedColor", Variant(color));
714 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
715 r = SetProperty("buttonDisabledColor", Variant(color));
725 _SearchBar::SetButtonTextColor(SearchBarButtonStatus status, const Color& color)
727 result r = E_SUCCESS;
731 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
732 r = SetProperty("buttonNormalTextColor", Variant(color));
734 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
735 r = SetProperty("buttonPressedTextColor", Variant(color));
737 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
738 r = SetProperty("buttonHighlightedTextColor", Variant(color));
740 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
741 r = SetProperty("buttonDisabledTextColor", Variant(color));
751 _SearchBar::AppendCharacter(const Character& character)
753 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
754 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
755 SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM,
756 "[E_SYSTEM] A system error has occurred. The character is null.");
758 result r = E_SUCCESS;
760 r = __pEdit->AppendCharacter(character);
761 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
762 "[E_SYSTEM] A system error has occurred. Failed to set character.");
768 _SearchBar::AppendText(const String& text)
770 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
771 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
772 SysTryReturn(NID_UI_CTRL, text.IsEmpty() == false, E_SYSTEM, E_SYSTEM,
773 "[E_SYSTEM] A system error has occurred. The text is empty.");
775 result r = E_SUCCESS;
777 r = __pEdit->AppendText(text);
778 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
779 "[E_SYSTEM] A system error has occurred. Failed to set text.");
785 _SearchBar::SetText(const String& text)
787 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
788 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
790 result r = E_SUCCESS;
792 int limitLength = __pEdit->GetTextLimitLength();
793 int textLength = text.GetLength();
794 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_SYSTEM, E_SYSTEM,
795 "[E_SYSTEM] A system error has occurred. textLength exceeds the limitLength");
797 r = __pEdit->SetText(text);
798 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
799 "[E_SYSTEM] A system error has occurred. Failed to set text.");
805 _SearchBar::InsertCharacterAt(int index, const Character& character)
807 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
808 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
809 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
810 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
811 SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM,
812 "[E_SYSTEM] A system error has occurred. The character is null.");
814 result r = E_SUCCESS;
818 limitLength = __pEdit->GetTextLimitLength();
819 textLength = __pEdit->GetTextLength() + 1;
821 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
822 "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
824 SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
825 "[E_OUT_OF_RANGE] index(%d) is out of range of current textLength(%d).", index, __pEdit->GetTextLength());
827 r = __pEdit->InsertCharacterAt(index, character);
828 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
829 "[E_SYSTEM] A system error has occurred. Failed to set text.");
835 _SearchBar::InsertTextAt(int index, const String& text)
837 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
838 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
839 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
840 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
842 result r = E_SUCCESS;
846 limitLength = __pEdit->GetTextLimitLength();
847 textLength = __pEdit->GetTextLength() + text.GetLength();
849 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
850 "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
851 SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
852 "[E_OUT_OF_RANGE] index(%d) is out of range of current textLength(%d).", index, __pEdit->GetTextLength());
854 r = __pEdit->InsertTextAt(index, text);
855 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
856 "[E_SYSTEM] A system error has occurred. Failed to insert text.");
862 _SearchBar::DeleteCharacterAt(int index)
864 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
865 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
866 SysTryReturn(NID_UI_CTRL, index > -1, E_INVALID_ARG, E_INVALID_ARG,
867 "[E_INVALID_ARG] Invalid argument(s) is used. index = %d", index);
869 result r = E_SUCCESS;
871 textLength = __pEdit->GetTextLength();
873 SysTryReturn(NID_UI_CTRL, textLength > index, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
874 "[E_OUT_OF_RANGE] index(%d) is out of range. textLength(%d)", index, textLength);
876 r = __pEdit->DeleteCharacterAt(index);
877 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM,
878 "[E_SYSTEM] A system error has occured. Failed to delete character.");
884 _SearchBar::Clear(void)
886 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
887 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
889 return __pEdit->ClearText();
893 _SearchBar::GetTextLength(void) const
895 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
896 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
898 return __pEdit->GetTextLength();
902 _SearchBar::GetText(void) const
904 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
905 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
907 return __pEdit->GetText();
911 _SearchBar::GetText(int start, int end) const
913 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
914 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
916 return __pEdit->GetText(start, end);
920 _SearchBar::GetLimitLength(void) const
922 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
923 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
925 return __pEdit->GetTextLimitLength();
929 _SearchBar::SetLimitLength(int limitLength)
931 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
932 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
933 SysTryReturn(NID_UI_CTRL, limitLength > 0, E_INVALID_ARG, E_INVALID_ARG,
934 "[E_INVALID_ARG] Invalid argument(s) is used.limitLength = %d", limitLength);
936 String tempString = GetText();
938 int textLength = tempString.GetLength();
939 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_INVALID_ARG, E_INVALID_ARG,
940 "[E_INVALID_ARG] Invalid argument(s) is used. limitLength = %d, textLength = %d", limitLength, textLength);
942 result r = __pEdit->SetLimitLength(limitLength);
943 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
945 r = SetText(tempString);
946 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
952 _SearchBar::ShowKeypad(void) const
954 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
955 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
957 SearchBarMode mode = __pSearchBarPresenter->GetMode();
958 SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_INVALID_STATE, E_INVALID_STATE,
959 "[E_INVALID_STATE] The SearchBar is currently in Normal mode.");
960 return __pEdit->ShowKeypad();
964 _SearchBar::HideKeypad(void)
966 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
967 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
969 SearchBarMode mode = __pSearchBarPresenter->GetMode();
970 SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_SYSTEM, E_SYSTEM,
971 "[E_SYSTEM] A system error has occurred. The SearchBar is currently in Normal mode.");
973 result r = __pEdit->HideKeypad();
981 _SearchBar::GetSearchFieldTextSizeF(void) const
983 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
984 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
986 return __pEdit->GetTextSizeF();
990 _SearchBar::SetSearchFieldTextSize(float size)
992 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
993 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
995 return __pEdit->SetTextSize(size);
999 _SearchBar::GetBlockRange(int& start, int& end) const
1001 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1002 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1004 int startIndex = -1;
1007 __pEdit->GetBlockRange(startIndex, endIndex);
1008 SysTryReturn(NID_UI_CTRL, (startIndex > -1 && endIndex > 0), E_SYSTEM, E_SYSTEM,
1009 "[E_SYSTEM] A system error has occurred. Failed to get text block range.");
1018 _SearchBar::ReleaseBlock(void)
1020 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1021 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1023 result r = E_SUCCESS;
1028 r = GetBlockRange(start, end);
1029 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1031 return __pEdit->ReleaseTextBlock();
1035 _SearchBar::SetBlockRange(int start, int end)
1037 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1038 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1040 result r = E_SUCCESS;
1043 textLength = __pEdit->GetTextLength();
1045 SysTryReturn(NID_UI_CTRL, (start < end && start >= 0 && textLength >= end), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1046 "[E_OUT_OF_RANGE] start (%d) and end (%d) is out of range.", start, end - 1);
1048 r = SetCursorPosition(start);
1049 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1051 r = __pEdit->BeginTextBlock();
1052 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1053 "[E_SYSTEM] A system error has occurred. Failed to set text block range.");
1055 r = SetCursorPosition(end);
1056 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1057 "[E_SYSTEM] A system error has occurred. Failed to set cursor position.");
1063 _SearchBar::RemoveTextBlock(void)
1065 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1066 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1068 result r = E_SUCCESS;
1070 r = __pEdit->RemoveTextBlock();
1071 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1077 _SearchBar::GetColor(void) const
1079 Variant backgroundColor = GetProperty("color");
1081 return backgroundColor.ToColor();
1085 _SearchBar::GetSearchFieldColor(SearchFieldStatus status) const
1087 Variant searchFieldColor;
1091 case SEARCH_FIELD_STATUS_NORMAL:
1092 searchFieldColor = GetProperty("searchFieldNormalColor");
1094 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1095 searchFieldColor = GetProperty("searchFieldHighlightedColor");
1097 case SEARCH_FIELD_STATUS_DISABLED:
1098 searchFieldColor = GetProperty("searchFieldDisabledColor");
1104 return searchFieldColor.ToColor();
1109 _SearchBar::GetSearchFieldTextColor(SearchFieldStatus status) const
1111 Variant searchFieldTextColor;
1115 case SEARCH_FIELD_STATUS_NORMAL:
1116 searchFieldTextColor = GetProperty("searchFieldNormalTextColor");
1118 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1119 searchFieldTextColor = GetProperty("searchFieldHighlightedTextColor");
1121 case SEARCH_FIELD_STATUS_DISABLED:
1122 searchFieldTextColor = GetProperty("searchFieldDisabledTextColor");
1128 return searchFieldTextColor.ToColor();
1133 _SearchBar::SetBackgroundBitmap(const Bitmap& bitmap)
1135 Bitmap* pNewBitmap = _BitmapImpl::CloneN(bitmap);
1136 SysTryReturn(NID_UI_CTRL, pNewBitmap, E_SYSTEM, E_SYSTEM,
1137 "[E_SYSTEM] A system error has occurred. The creation of bitmap failed.");
1139 delete __pBackgroundBitmap;
1140 __pBackgroundBitmap = null;
1142 __pBackgroundBitmap = pNewBitmap;
1148 _SearchBar::GetBackgroundBitmap(void) const
1150 return __pBackgroundBitmap;
1154 _SearchBar::SetColor(const Color& color)
1156 return SetProperty("color", Variant(color));
1160 _SearchBar::SetSearchFieldColor(SearchFieldStatus status, const Color& color)
1162 result r = E_SUCCESS;
1166 case SEARCH_FIELD_STATUS_NORMAL:
1167 r = SetProperty("searchFieldNormalColor", Variant(color));
1169 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1170 r = SetProperty("searchFieldHighlightedColor", Variant(color));
1172 case SEARCH_FIELD_STATUS_DISABLED:
1173 r = SetProperty("searchFieldDisabledColor", Variant(color));
1184 _SearchBar::SetSearchFieldTextColor(SearchFieldStatus status, const Color& color)
1186 result r = E_SUCCESS;
1190 case SEARCH_FIELD_STATUS_NORMAL:
1191 r = SetProperty("searchFieldNormalTextColor", Variant(color));
1193 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1194 r = SetProperty("searchFieldHighlightedTextColor", Variant(color));
1196 case SEARCH_FIELD_STATUS_DISABLED:
1197 r = SetProperty("searchFieldDisabledTextColor", Variant(color));
1208 _SearchBar::GetGuideText(void) const
1210 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
1211 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1213 return __pEdit->GetGuideText();
1217 _SearchBar::SetGuideText(const String& guideText)
1219 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1220 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1222 __pEdit->SetGuideText(guideText);
1228 _SearchBar::GetGuideTextColor(void) const
1230 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1231 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1233 return __pEdit->GetGuideTextColor();
1237 _SearchBar::SetGuideTextColor(const Color& color)
1239 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1240 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1242 return __pEdit->SetGuideTextColor(color);
1246 _SearchBar::GetCursorPosition(void) const
1248 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
1249 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1251 return __pEdit->GetCursorPosition();
1255 _SearchBar::SetCursorPosition(int index)
1257 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1258 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1259 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1260 "[E_OUT_OF_RANGE] index(%d) is out of range.", GetErrorMessage(E_OUT_OF_RANGE), index);
1262 int textLength = -1;
1263 textLength = __pEdit->GetTextLength();
1265 SysTryReturn(NID_UI_CTRL, (index > -1 && index <= textLength), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1266 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
1268 return __pEdit->SetCursorPosition(index);
1272 _SearchBar::IsLowerCaseModeEnabled(void) const
1274 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1275 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1277 return __pEdit->IsLowerCaseModeEnabled();
1281 _SearchBar::SetLowerCaseModeEnabled(bool enable)
1283 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
1284 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1286 __pEdit->SetLowerCaseModeEnabled(enable);
1290 _SearchBar::GetEllipsisPosition(void) const
1292 SysTryReturn(NID_UI_CTRL, __pEdit, ELLIPSIS_POSITION_START, E_SYSTEM,
1293 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1295 return __pEdit->GetEllipsisPosition();
1299 _SearchBar::SetEllipsisPosition(EllipsisPosition position)
1301 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1302 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1303 __pEdit->SetEllipsisPosition(position);
1309 _SearchBar::GetKeypadAction(void) const
1311 return __keypadAction;
1315 _SearchBar::IsTextPredictionEnabled(void) const
1317 SysTryReturn(NID_UI_CTRL, __pEdit, false, E_SYSTEM,
1318 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1319 return __pEdit->IsTextPredictionEnabled();
1323 _SearchBar::SetTextPredictionEnabled(bool enable)
1325 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1326 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1327 return __pEdit->SetTextPredictionEnabled(enable);
1331 _SearchBar::SetCurrentLanguage(LanguageCode languageCode)
1333 return __pEdit->SetCurrentLanguage(languageCode);
1337 _SearchBar::GetCurrentLanguage(LanguageCode& language) const
1339 return __pEdit->GetCurrentLanguage(language);
1343 _SearchBar::AddActionEventListener(const _IActionEventListener& listener)
1345 result r = E_SUCCESS;
1347 if (__pActionEvent == null)
1349 __pActionEvent = _ActionEvent::CreateInstanceN(*this);
1350 r = GetLastResult();
1351 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1353 __pActionEvent->AddListener(listener);
1360 _SearchBar::RemoveActionEventListener(const _IActionEventListener& listener)
1362 SysTryReturn(NID_UI_CTRL, __pActionEvent, E_SYSTEM, E_SYSTEM,
1363 "[E_SYSTEM] A system error has occurred. The action event instance is null.");
1364 result r = E_SUCCESS;
1366 r = __pActionEvent->RemoveListener(listener);
1367 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1373 _SearchBar::AddKeypadEventListener(const _IKeypadEventListener& listener)
1375 result r = E_SUCCESS;
1377 if (__pKeypadEvent == null)
1379 __pKeypadEvent = _KeypadEvent::CreateInstanceN(*this);
1380 r = GetLastResult();
1381 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1383 r = __pKeypadEvent->AddListener(listener);
1384 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1391 _SearchBar::RemoveKeypadEventListener(const _IKeypadEventListener& listener)
1393 SysTryReturn(NID_UI_CTRL, __pKeypadEvent, E_SYSTEM, E_SYSTEM,
1394 "[E_SYSTEM] A system error has occurred. The keypad event instance is null.");
1395 result r = E_SUCCESS;
1397 r = __pKeypadEvent->RemoveListener(listener);
1398 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1404 _SearchBar::AddTextBlockEventListener(const _ITextBlockEventListener& listener)
1406 result r = E_SUCCESS;
1408 if (__pTextBlockEvent == null)
1410 __pTextBlockEvent = _TextBlockEvent::CreateInstanceN(*this);
1411 r = GetLastResult();
1412 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1414 r = __pTextBlockEvent->AddListener(listener);
1415 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1423 _SearchBar::RemoveTextBlockEventListener(const _ITextBlockEventListener& listener)
1425 SysTryReturn(NID_UI_CTRL, __pTextBlockEvent, E_SYSTEM, E_SYSTEM,
1426 "[E_SYSTEM] A system error has occurred. The text block event instance is null.");
1427 result r = E_SUCCESS;
1429 r = __pTextBlockEvent->RemoveListener(listener);
1430 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1437 _SearchBar::AddTextEventListener(const _ITextEventListener& listener)
1439 result r = E_SUCCESS;
1441 if (__pTextEvent == null)
1443 __pTextEvent = _TextEvent::CreateInstanceN(*this);
1444 r = GetLastResult();
1445 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1447 r = __pTextEvent->AddListener(listener);
1448 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1455 _SearchBar::RemoveTextEventListener(const _ITextEventListener& listener)
1457 SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM,
1458 "[E_SYSTEM] A system error has occurred. The text event instance is null.");
1459 result r = E_SUCCESS;
1461 r = __pTextEvent->RemoveListener(listener);
1462 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1468 _SearchBar::AddSearchBarEventListener(const _ISearchBarEventListener& listener)
1470 result r = E_SUCCESS;
1472 if (__pSearchBarEvent == null)
1474 __pSearchBarEvent = _SearchBarEvent::CreateInstanceN(*this);
1475 r = GetLastResult();
1476 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1478 r = __pSearchBarEvent->AddListener(listener);
1479 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1486 _SearchBar::RemoveSearchBarEventListener(const _ISearchBarEventListener& listener)
1488 SysTryReturn(NID_UI_CTRL, __pSearchBarEvent, E_SYSTEM, E_SYSTEM,
1489 "[E_SYSTEM] A system error has occurred. The searchbar event instance is null.");
1490 result r = E_SUCCESS;
1492 r = __pSearchBarEvent->RemoveListener(listener);
1493 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1499 _SearchBar::AddLanguageEventListener(const _ILanguageEventListener& listener)
1501 result r = E_SUCCESS;
1503 if (__pLanguageEvent == null)
1505 __pLanguageEvent = _LanguageEvent::CreateInstanceN(*this);
1506 r = GetLastResult();
1507 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1509 r = __pLanguageEvent->AddListener(listener);
1510 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1517 _SearchBar::RemoveLanguageEventListener(const _ILanguageEventListener& listener)
1519 SysTryReturn(NID_UI_CTRL, __pLanguageEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.");
1520 result r = E_SUCCESS;
1522 __pLanguageEvent->RemoveListener(listener);
1523 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1529 _SearchBar::OnBoundsChanged(void)
1531 if (__pSearchBarPresenter != null)
1533 __pSearchBarPresenter->OnBoundsChanged();
1539 _SearchBar::OnChangeLayout(_ControlOrientation orientation)
1545 _SearchBar::OnDraw(void)
1547 SearchFieldStatus searchFieldStatus = GetCurrentStatus();
1548 SetGuideTextColor(__guideTextColor[searchFieldStatus]);
1550 __pSearchBarPresenter->Draw();
1554 _UiTouchEventDelivery
1555 _SearchBar::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1557 _Edit* pEdit = dynamic_cast <_Edit*>(const_cast <_Control*>(&source));
1560 return _UI_TOUCH_EVENT_DELIVERY_YES;
1563 if (GetMode() == SEARCH_BAR_MODE_INPUT)
1565 return _UI_TOUCH_EVENT_DELIVERY_YES;
1568 SetMode(SEARCH_BAR_MODE_INPUT);
1570 return _UI_TOUCH_EVENT_DELIVERY_YES;
1574 _SearchBar::OnActionPerformed(const _Control& source, int actionId)
1576 if (__actionId == actionId)
1578 __isCancelActionInProgress = true;
1579 SetMode(SEARCH_BAR_MODE_NORMAL);
1583 IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(__actionId);
1584 result r = GetLastResult();
1585 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1587 __pActionEvent->Fire(*pEventArg);
1589 __isCancelActionInProgress = false;
1596 _SearchBar::OnKeypadWillOpen(void)
1600 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CREATED);
1601 result r = GetLastResult();
1602 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1604 __pKeypadEvent->Fire(*pEventArg);
1610 _SearchBar::OnKeypadOpened(void)
1614 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_OPEN);
1615 result r = GetLastResult();
1616 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1618 __pKeypadEvent->Fire(*pEventArg);
1624 _SearchBar::OnKeypadClosed(void)
1628 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CLOSE);
1629 result r = GetLastResult();
1630 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1632 __pKeypadEvent->Fire(*pEventArg);
1640 _SearchBar::OnKeypadBoundsChanged(void)
1644 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1645 result r = GetLastResult();
1646 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1648 __pKeypadEvent->Fire(*pEventArg);
1656 _SearchBar::OnKeypadActionPerformed(CoreKeypadAction keypadAction)
1660 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(keypadAction, CORE_KEYPAD_EVENT_STATUS_ENTERACTION);
1661 result r = GetLastResult();
1662 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1664 __pKeypadEvent->Fire(*pEventArg);
1669 // TextBlock callbacks
1671 _SearchBar::OnTextBlockSelected(_Control& source, int start, int end)
1673 if (__pTextBlockEvent)
1675 IEventArg* pEventArg = _TextBlockEvent::CreateTextBlockEventArgN(start, end);
1676 result r = GetLastResult();
1677 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1679 __pTextBlockEvent->Fire(*pEventArg);
1686 _SearchBar::OnTextValueChanged(const _Control& source)
1688 if (!__isCancelActionInProgress)
1690 SetContentDimming();
1691 if (__pTextEvent != null)
1693 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CHANGED);
1694 result r = GetLastResult();
1695 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1697 __pTextEvent->Fire(*pEventArg);
1704 _SearchBar::OnTextValueChangeCanceled(const _Control& source)
1706 if (__pTextEvent != null)
1708 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CANCELED);
1709 result r = GetLastResult();
1710 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1712 __pTextEvent->Fire(*pEventArg);
1718 _SearchBar::OnAttachedToMainTree(void)
1726 _SearchBar::OnFontChanged(Font* pFont)
1728 __pCancelButton->SetFont(pFont->GetFaceName());
1729 __pEdit->SetFont(*pFont);
1734 _SearchBar::OnFontInfoRequested(unsigned long& style, int& size)
1736 style = FONT_STYLE_PLAIN;
1737 size = __pCancelButton->GetTextSize();
1743 _SearchBar::OnFocusGained(const _Control& source)
1745 SetMode(SEARCH_BAR_MODE_INPUT);
1746 __pEdit->SetFocused();
1751 _SearchBar::OnFocusLost(const _Control& source)
1757 _SearchBar::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1759 if (!__pEdit->IsUsbKeyboardConnected())
1764 _KeyCode keyCode = keyInfo.GetKeyCode();
1766 if (keyCode == _KEY_RIGHT)
1768 if (__isButtonEnabled)
1770 __pEdit->SetFocused(false);
1771 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED);
1772 __pCancelButton->SetFocused();
1773 __pCancelButton->Invalidate(true);
1779 if (keyCode == _KEY_LEFT)
1781 if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_HIGHLIGHTED)
1783 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1784 __pCancelButton->SetFocused(false);
1785 __pCancelButton->Invalidate();
1789 if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_DISABLED) //Searchbar Button is disabled, left arrow key is pressed
1791 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1792 SetButtonEnabled(false);
1795 __pEdit->SetFocused();
1804 _SearchBar::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
1810 _SearchBar::GetParentForm(void) const
1812 _Form* pForm = null;
1813 _Control* pControlCore = GetParent();
1817 if (pControlCore == null)
1819 SysLog(NID_UI_CTRL,"[E_SYSTEM] The parent form is null.");
1824 pForm = dynamic_cast <_Form*>(pControlCore);
1831 pControlCore = pControlCore->GetParent();
1834 return pControlCore;
1838 _SearchBar::GetSearchBarButton(void) const
1840 return __pCancelButton;
1844 _SearchBar::GetSearchField(void)
1850 _SearchBar::GetSearchBarContainer(void) const
1852 return __pContainer;
1856 _SearchBar::GetClippedGroupControl(void) const
1858 return __pClippedGroupControl;
1862 _SearchBar::IsUsableCancelButton(void) const
1864 return __isUsableCancelButton;
1868 _SearchBar::ConvertSearchBarStatus(SearchFieldStatus status)
1870 EditStatus editStatus = EDIT_STATUS_NORMAL;
1873 case SEARCH_FIELD_STATUS_NORMAL:
1874 editStatus = EDIT_STATUS_NORMAL;
1877 case SEARCH_FIELD_STATUS_DISABLED:
1878 editStatus = EDIT_STATUS_DISABLED;
1881 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1882 editStatus = EDIT_STATUS_HIGHLIGHTED;
1892 _SearchBar::ConvertSearchBarButtonStatus(SearchBarButtonStatus status)
1894 _ButtonStatus buttonStatus = _BUTTON_STATUS_NORMAL;
1898 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
1899 buttonStatus = _BUTTON_STATUS_NORMAL;
1902 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
1903 buttonStatus = _BUTTON_STATUS_PRESSED;
1906 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
1907 buttonStatus = _BUTTON_STATUS_HIGHLIGHTED;
1910 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
1911 buttonStatus = _BUTTON_STATUS_DISABLED;
1917 return buttonStatus;
1921 _SearchBar::SendSearchBarEvent(_SearchBarEventStatus status)
1923 result r = E_SUCCESS;
1924 if (__pSearchBarEvent)
1926 IEventArg* pEventArg = _SearchBarEvent::CreateSearchBarEventArgN(status);
1927 r = GetLastResult();
1928 SysTryReturn(NID_UI_CTRL, pEventArg, r, r, "[%s] Propagating.", GetErrorMessage(r));
1930 if (IsContentAreaVisible() == false)
1932 SetContentAreaVisible(false);
1935 __pSearchBarEvent->Fire(*pEventArg);
1942 _SearchBar::SetHeaderVisibleState(bool visible)
1944 if (__pSearchBarPresenter != null)
1946 __pSearchBarPresenter->SetHeaderVisibleState(visible);
1952 _SearchBar::SetPropertyButtonActionId(const Variant& actionId)
1954 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1955 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1956 SysTryReturn(NID_UI_CTRL, actionId.ToInt() > -1, E_INVALID_ARG, E_INVALID_ARG,
1957 "[E_INVALID_ARG] Invalid argument(s) is used. actionId.ToInt() = %d", actionId.ToInt());
1959 result r = E_SUCCESS;
1961 r = __pCancelButton->SetPropertyActionId(actionId);
1962 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1963 "[%s] A system error has occurred. Failed to set actionId.", GetErrorMessage(E_SYSTEM));
1965 __actionId = actionId.ToInt();
1971 _SearchBar::GetPropertyButtonActionId(void) const
1973 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(-1), E_SYSTEM,
1974 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1976 return Variant(__actionId);
1980 _SearchBar::SetPropertyButtonDisabledColor(const Variant& color)
1982 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1983 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1985 result r = E_SUCCESS;
1987 r = __pCancelButton->SetPropertyDisabledColor(color);
1988 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1989 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
1991 __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = color.ToColor();
1997 _SearchBar::GetPropertyButtonDisabledColor(void) const
1999 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2000 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2002 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2006 _SearchBar::SetPropertyButtonHighlightedColor(const Variant& color)
2008 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2009 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2011 result r = E_SUCCESS;
2013 r = __pCancelButton->SetPropertyHighlightedColor(color);
2014 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2015 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2017 __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
2023 _SearchBar::GetPropertyButtonHighlightedColor(void) const
2025 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2026 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2028 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2032 _SearchBar::SetPropertyButtonNormalColor(const Variant& color)
2034 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2035 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2037 result r = E_SUCCESS;
2039 r = __pCancelButton->SetPropertyNormalColor(color);
2040 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2041 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2043 __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = color.ToColor();
2049 _SearchBar::GetPropertyButtonNormalColor(void) const
2051 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2052 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2054 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2058 _SearchBar::SetPropertyButtonPressedColor(const Variant& color)
2060 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2061 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2063 result r = E_SUCCESS;
2065 r = __pCancelButton->SetPropertyPressedColor(color);
2066 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2067 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2069 __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = color.ToColor();
2075 _SearchBar::GetPropertyButtonPressedColor(void) const
2077 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2078 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2080 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2084 _SearchBar::SetPropertyButtonDisabledTextColor(const Variant& textColor)
2086 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2087 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2089 result r = E_SUCCESS;
2091 r = __pCancelButton->SetPropertyDisabledTextColor(textColor);
2092 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2093 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2095 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = textColor.ToColor();
2101 _SearchBar::GetPropertyButtonDisabledTextColor(void) const
2103 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2104 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2106 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2110 _SearchBar::SetPropertyButtonHighlightedTextColor(const Variant& textColor)
2112 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2113 "[E_SYSTEM]] A system error has occurred. The cancel button instance is null.");
2115 result r = E_SUCCESS;
2117 r = __pCancelButton->SetPropertyHighlightedTextColor(textColor);
2118 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2119 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2121 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = textColor.ToColor();
2127 _SearchBar::GetPropertyButtonHighlightedTextColor(void) const
2129 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2130 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2132 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2136 _SearchBar::SetPropertyButtonNormalTextColor(const Variant& textColor)
2138 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2139 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2141 result r = E_SUCCESS;
2143 r = __pCancelButton->SetPropertyNormalTextColor(textColor);
2144 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2145 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2147 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = textColor.ToColor();
2153 _SearchBar::GetPropertyButtonNormalTextColor(void) const
2155 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2156 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2158 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2162 _SearchBar::SetPropertyButtonPressedTextColor(const Variant& textColor)
2164 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2165 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2167 result r = E_SUCCESS;
2169 r = __pCancelButton->SetPropertyPressedTextColor(textColor);
2170 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2171 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2173 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = textColor.ToColor();
2179 _SearchBar::GetPropertyButtonPressedTextColor(void) const
2181 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2182 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2184 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2188 _SearchBar::SetPropertySearchFieldDisabledColor(const Variant& color)
2190 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2191 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2193 result r = E_SUCCESS;
2195 r = __pEdit->SetPropertyDisabledColor(color);
2196 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2197 "[E_SYSTEM] A system error has occurred. Failed to set the edit disabled color.");
2199 __color[SEARCH_FIELD_STATUS_DISABLED] = color.ToColor();
2205 _SearchBar::GetPropertySearchFieldDisabledColor(void) const
2207 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2208 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2210 return Variant(__color[SEARCH_FIELD_STATUS_DISABLED]);
2214 _SearchBar::SetPropertySearchFieldHighlightedColor(const Variant& color)
2216 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2217 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2219 result r = E_SUCCESS;
2221 r = __pEdit->SetPropertyHighlightedColor(color);
2222 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2223 "[E_SYSTEM] A system error has occurred. Failed to set the edit highlighted color.");
2225 __color[SEARCH_FIELD_STATUS_HIGHLIGHTED] = color.ToColor();
2231 _SearchBar::GetPropertySearchFieldHighlightedColor(void) const
2233 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2234 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2236 return Variant(__color[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2240 _SearchBar::SetPropertySearchFieldNormalColor(const Variant& color)
2242 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2243 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2245 result r = E_SUCCESS;
2247 r = __pEdit->SetPropertyNormalColor(color);
2248 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2249 "[E_SYSTEM] A system error has occurred. Failed to set edit normal color.");
2251 __color[SEARCH_FIELD_STATUS_NORMAL] = color.ToColor();
2257 _SearchBar::GetPropertySearchFieldNormalColor(void) const
2259 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2260 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2262 return Variant(__color[SEARCH_FIELD_STATUS_NORMAL]);
2266 _SearchBar::SetPropertySearchFieldDisabledTextColor(const Variant& textColor)
2268 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2269 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2271 result r = E_SUCCESS;
2273 r = __pEdit->SetPropertyDisabledTextColor(textColor);
2274 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2275 "[E_SYSTEM] A system error has occurred. Failed to set edit disabled text color.");
2277 __textColor[SEARCH_FIELD_STATUS_DISABLED] = textColor.ToColor();
2283 _SearchBar::GetPropertySearchFieldDisabledTextColor(void) const
2285 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2286 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2288 return Variant(__textColor[SEARCH_FIELD_STATUS_DISABLED]);
2292 _SearchBar::SetPropertySearchFieldHighlightedTextColor(const Variant& textColor)
2294 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2295 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2297 result r = E_SUCCESS;
2299 r = __pEdit->SetPropertyHighlightedTextColor(textColor);
2300 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2301 "[E_SYSTEM] A system error has occurred. Failed to set edit highlighted text color.");
2303 __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED] = textColor.ToColor();
2309 _SearchBar::GetPropertySearchFieldHighlightedTextColor(void) const
2311 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2312 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2314 return Variant(__textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2318 _SearchBar::SetPropertySearchFieldNormalTextColor(const Variant& textColor)
2320 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2321 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2323 result r = E_SUCCESS;
2325 r = __pEdit->SetPropertyNormalTextColor(textColor);
2326 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2327 "[E_SYSTEM] A system error has occurred. Failed to set edit normal text color.");
2329 __textColor[SEARCH_FIELD_STATUS_NORMAL] = textColor.ToColor();
2335 _SearchBar::GetPropertySearchFieldNormalTextColor(void) const
2337 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2338 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2340 return Variant(__textColor[SEARCH_FIELD_STATUS_NORMAL]);
2344 _SearchBar::SetPropertyColor(const Variant& color)
2346 __backgroundColor = color.ToColor();
2352 _SearchBar::GetPropertyColor(void) const
2354 return Variant(__backgroundColor);
2358 _SearchBar::SetPropertyContentAreaSize(const Variant& size)
2360 FloatDimension contentAreaSize = size.ToFloatDimension();
2361 SysTryReturn(NID_UI_CTRL, contentAreaSize.width >= 0 && contentAreaSize.height >= 0, E_INVALID_ARG, E_INVALID_ARG,
2362 "[E_INVALID_ARG] Invalid argument(s) is used. contentAreaSize.width = %f, contenAreaSize.height = %f",
2363 contentAreaSize.width, contentAreaSize.height);
2365 result r = E_SUCCESS;
2368 FloatRectangle bounds = GetBoundsF();
2369 FloatRectangle contentAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
2371 contentAreaBounds.x = 0.0f;
2372 contentAreaBounds.y = bounds.height;
2373 contentAreaBounds.width = contentAreaSize.width;
2374 contentAreaBounds.height = contentAreaSize.height;
2376 __contentAreaBounds = contentAreaBounds;
2377 __isUserContainerBounds = true;
2382 r = __pContainer->SetBounds(__contentAreaBounds);
2383 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2390 _SearchBar::GetPropertyContentAreaSize(void) const
2392 FloatDimension contentAreaSize(__contentAreaBounds.width, __contentAreaBounds.height);
2394 return Variant(contentAreaSize);
2398 _SearchBar::CreateClippedGroupControl(void)
2400 result r = E_SUCCESS;
2401 FloatRectangle clippedGroupControlBounds(FloatPoint(0.0f, 0.0f), GetSizeF());
2402 __pClippedGroupControl = _Control::CreateControlN();
2403 r = GetLastResult();
2404 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2406 r = AttachChild(*__pClippedGroupControl);
2407 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
2408 "[E_SYSTEM] A system error has occurred. Failed to attach the parent of clipped control.");
2410 r = __pClippedGroupControl->SetBounds(clippedGroupControlBounds);
2411 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2413 __pClippedGroupControl->SetBackgroundColor(Color(0));
2415 __pClippedGroupControl->SetClipChildrenEnabled(true);
2420 delete __pClippedGroupControl;
2421 __pClippedGroupControl = null;
2428 _SearchBar::SetContentDimming(void)
2430 if (__pContainer != NULL)
2432 if (!GetTextLength())
2434 __contentColor.SetAlpha(_SEARCH_CONTENT_DIM_OPACITY);
2438 __contentColor.SetAlpha(0);
2440 __pContainer->SetBackgroundColor(__contentColor);
2446 _SearchBar::IsContentAttachable(const _Control* pContent)
2448 const _Window* pWindow = dynamic_cast <const _Window*>(pContent);
2449 const _ColorPicker* pColorPicker = dynamic_cast <const _ColorPicker*>(pContent);
2450 const _Form* pForm = dynamic_cast <const _Form*>(pContent);
2451 const _Keypad* pKeypad = dynamic_cast <const _Keypad*>(pContent);
2452 const _OverlayPanel* pOverlayPanel = dynamic_cast <const _OverlayPanel*>(pContent);
2454 bool isContentAttachable = true;
2456 isContentAttachable = ((pWindow == null) && (pColorPicker == null) &&
2457 (pForm == null) && (pKeypad == null) && (pOverlayPanel == null));
2458 return isContentAttachable;
2462 _SearchBar::ResizeCancelButton(void)
2464 result r = E_SUCCESS;
2466 int horizontalMargin = 0;
2467 int buttonLeftMargin = 0;
2468 int buttonRightMargin = 0;
2469 int buttonMinWidth = 0;
2470 int searchFieldMinWidth = 0;
2471 int buttonVerticalMargin = 0;
2472 int searchBarMinHeight = 0;
2473 int buttonWidth = 0;
2474 int buttonHeight = 0;
2476 FloatRectangle cancelButtonBounds;
2477 FloatRectangle searchBarBounds = GetBoundsF();
2479 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2481 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2482 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2483 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2484 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2485 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2486 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2487 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2488 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2489 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2491 cancelButtonBounds.width = _CoordinateSystemUtils::ConvertToFloat(buttonWidth);
2492 cancelButtonBounds.height = _CoordinateSystemUtils::ConvertToFloat(buttonHeight);
2494 float buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth +
2495 cancelButtonBounds.width + buttonLeftMargin + buttonRightMargin);
2497 if (searchBarBounds.width < buttonResizableSearchBarWidth)
2499 cancelButtonBounds.width = searchBarBounds.width -(searchFieldMinWidth + buttonLeftMargin
2500 + buttonRightMargin + horizontalMargin);
2503 cancelButtonBounds.x = searchBarBounds.width - cancelButtonBounds.width - buttonRightMargin;
2504 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2506 if (searchBarBounds.height < searchBarMinHeight)
2508 cancelButtonBounds.y = buttonVerticalMargin;
2511 if (cancelButtonBounds.width < buttonMinWidth)
2513 cancelButtonBounds.width = buttonMinWidth;
2516 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2517 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2518 r = __pCancelButton->SetBounds(cancelButtonBounds);
2525 _SearchBar::RecalculateButtonBounds(void)
2527 result r = E_SUCCESS;
2529 Float horizontalMargin = 0;
2530 Float verticalMargin = 0;
2531 Float buttonLeftMargin = 0;
2532 Float buttonRightMargin = 0;
2533 Float buttonMinWidth = 0;
2534 Float searchFieldMinWidth = 0;
2535 Float buttonVerticalMargin = 0;
2536 Float searchBarMinHeight = 0;
2537 Float buttonWidth = 0;
2538 Float buttonHeight = 0;
2540 FloatRectangle cancelButtonBounds;
2541 FloatRectangle searchBarBounds = GetBoundsF();
2543 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2545 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2546 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin);
2547 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2548 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2549 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2550 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2551 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2552 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2553 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2554 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2556 cancelButtonBounds.height = buttonHeight ;
2558 FloatRectangle editBounds;
2560 float cancelButtonWidth = 0;
2561 cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightTouchMarginF() + __pCancelButton->GetLeftTouchMarginF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF();
2562 editBounds.x = horizontalMargin;
2563 editBounds.y = verticalMargin;
2565 editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
2566 editBounds.height = (editBounds.height > searchBarMinHeight) ? editBounds.height : searchBarMinHeight;
2568 editBounds.width = searchBarBounds.width - cancelButtonWidth - (2 * horizontalMargin) - buttonLeftMargin;
2570 if (editBounds.width < searchFieldMinWidth)
2572 editBounds.width = searchFieldMinWidth;
2575 cancelButtonBounds.x = editBounds.width + horizontalMargin + buttonLeftMargin;
2576 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2578 if (searchBarBounds.height < searchBarMinHeight)
2580 cancelButtonBounds.y = buttonVerticalMargin;
2583 if (cancelButtonWidth < buttonMinWidth)
2585 cancelButtonBounds.width = buttonMinWidth;
2589 cancelButtonBounds.width = searchBarBounds.width - cancelButtonBounds.x - buttonRightMargin;
2592 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2593 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2595 r = __pCancelButton->SetBounds(cancelButtonBounds);
2596 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2597 r = __pEdit->SetBounds(editBounds);
2598 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2604 _SearchBar::GetCurrentStatus(void)
2606 SearchFieldStatus searchFieldStatus = SEARCH_FIELD_STATUS_NORMAL;
2610 if (__pEdit->IsFocused())
2612 searchFieldStatus = SEARCH_FIELD_STATUS_HIGHLIGHTED;
2617 searchFieldStatus = SEARCH_FIELD_STATUS_DISABLED;
2620 return searchFieldStatus;
2624 _SearchBar::SetEditTextFilter(IEditTextFilter* pFilter)
2626 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2627 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2629 __pEdit->SetEditTextFilter(pFilter);
2635 _SearchBar::SendOpaqueCommand(const String& command)
2637 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2638 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2640 __pEdit->SendOpaqueCommand(command);
2645 }}} // Tizen::Ui::Controls