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::GetParentForm(void) const
1759 _Form* pForm = null;
1760 _Control* pControlCore = GetParent();
1764 if (pControlCore == null)
1766 SysLog(NID_UI_CTRL,"[E_SYSTEM] The parent form is null.");
1771 pForm = dynamic_cast <_Form*>(pControlCore);
1778 pControlCore = pControlCore->GetParent();
1781 return pControlCore;
1785 _SearchBar::GetSearchBarButton(void) const
1787 return __pCancelButton;
1791 _SearchBar::GetSearchField(void)
1797 _SearchBar::GetSearchBarContainer(void) const
1799 return __pContainer;
1803 _SearchBar::GetClippedGroupControl(void) const
1805 return __pClippedGroupControl;
1809 _SearchBar::IsUsableCancelButton(void) const
1811 return __isUsableCancelButton;
1815 _SearchBar::ConvertSearchBarStatus(SearchFieldStatus status)
1817 EditStatus editStatus = EDIT_STATUS_NORMAL;
1820 case SEARCH_FIELD_STATUS_NORMAL:
1821 editStatus = EDIT_STATUS_NORMAL;
1824 case SEARCH_FIELD_STATUS_DISABLED:
1825 editStatus = EDIT_STATUS_DISABLED;
1828 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1829 editStatus = EDIT_STATUS_HIGHLIGHTED;
1839 _SearchBar::ConvertSearchBarButtonStatus(SearchBarButtonStatus status)
1841 _ButtonStatus buttonStatus = _BUTTON_STATUS_NORMAL;
1845 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
1846 buttonStatus = _BUTTON_STATUS_NORMAL;
1849 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
1850 buttonStatus = _BUTTON_STATUS_PRESSED;
1853 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
1854 buttonStatus = _BUTTON_STATUS_HIGHLIGHTED;
1857 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
1858 buttonStatus = _BUTTON_STATUS_DISABLED;
1864 return buttonStatus;
1868 _SearchBar::SendSearchBarEvent(_SearchBarEventStatus status)
1870 result r = E_SUCCESS;
1871 if (__pSearchBarEvent)
1873 IEventArg* pEventArg = _SearchBarEvent::CreateSearchBarEventArgN(status);
1874 r = GetLastResult();
1875 SysTryReturn(NID_UI_CTRL, pEventArg, r, r, "[%s] Propagating.", GetErrorMessage(r));
1877 if (IsContentAreaVisible() == false)
1879 SetContentAreaVisible(false);
1882 __pSearchBarEvent->Fire(*pEventArg);
1889 _SearchBar::SetHeaderVisibleState(bool visible)
1891 if (__pSearchBarPresenter != null)
1893 __pSearchBarPresenter->SetHeaderVisibleState(visible);
1899 _SearchBar::SetPropertyButtonActionId(const Variant& actionId)
1901 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1902 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1903 SysTryReturn(NID_UI_CTRL, actionId.ToInt() > -1, E_INVALID_ARG, E_INVALID_ARG,
1904 "[E_INVALID_ARG] Invalid argument(s) is used. actionId.ToInt() = %d", actionId.ToInt());
1906 result r = E_SUCCESS;
1908 r = __pCancelButton->SetPropertyActionId(actionId);
1909 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1910 "[%s] A system error has occurred. Failed to set actionId.", GetErrorMessage(E_SYSTEM));
1912 __actionId = actionId.ToInt();
1918 _SearchBar::GetPropertyButtonActionId(void) const
1920 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(-1), E_SYSTEM,
1921 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1923 return Variant(__actionId);
1927 _SearchBar::SetPropertyButtonDisabledColor(const Variant& color)
1929 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1930 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1932 result r = E_SUCCESS;
1934 r = __pCancelButton->SetPropertyDisabledColor(color);
1935 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1936 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
1938 __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = color.ToColor();
1944 _SearchBar::GetPropertyButtonDisabledColor(void) const
1946 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
1947 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1949 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
1953 _SearchBar::SetPropertyButtonHighlightedColor(const Variant& color)
1955 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1956 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1958 result r = E_SUCCESS;
1960 r = __pCancelButton->SetPropertyHighlightedColor(color);
1961 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1962 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
1964 __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
1970 _SearchBar::GetPropertyButtonHighlightedColor(void) const
1972 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
1973 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1975 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
1979 _SearchBar::SetPropertyButtonNormalColor(const Variant& color)
1981 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1982 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1984 result r = E_SUCCESS;
1986 r = __pCancelButton->SetPropertyNormalColor(color);
1987 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1988 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
1990 __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = color.ToColor();
1996 _SearchBar::GetPropertyButtonNormalColor(void) const
1998 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
1999 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2001 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2005 _SearchBar::SetPropertyButtonPressedColor(const Variant& color)
2007 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2008 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2010 result r = E_SUCCESS;
2012 r = __pCancelButton->SetPropertyPressedColor(color);
2013 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2014 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2016 __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = color.ToColor();
2022 _SearchBar::GetPropertyButtonPressedColor(void) const
2024 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2025 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2027 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2031 _SearchBar::SetPropertyButtonDisabledTextColor(const Variant& textColor)
2033 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2034 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2036 result r = E_SUCCESS;
2038 r = __pCancelButton->SetPropertyDisabledTextColor(textColor);
2039 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2040 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2042 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = textColor.ToColor();
2048 _SearchBar::GetPropertyButtonDisabledTextColor(void) const
2050 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2051 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2053 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2057 _SearchBar::SetPropertyButtonHighlightedTextColor(const Variant& textColor)
2059 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2060 "[E_SYSTEM]] A system error has occurred. The cancel button instance is null.");
2062 result r = E_SUCCESS;
2064 r = __pCancelButton->SetPropertyHighlightedTextColor(textColor);
2065 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2066 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2068 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = textColor.ToColor();
2074 _SearchBar::GetPropertyButtonHighlightedTextColor(void) const
2076 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2077 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2079 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2083 _SearchBar::SetPropertyButtonNormalTextColor(const Variant& textColor)
2085 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2086 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2088 result r = E_SUCCESS;
2090 r = __pCancelButton->SetPropertyNormalTextColor(textColor);
2091 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2092 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2094 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = textColor.ToColor();
2100 _SearchBar::GetPropertyButtonNormalTextColor(void) const
2102 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2103 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2105 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2109 _SearchBar::SetPropertyButtonPressedTextColor(const Variant& textColor)
2111 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2112 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2114 result r = E_SUCCESS;
2116 r = __pCancelButton->SetPropertyPressedTextColor(textColor);
2117 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2118 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2120 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = textColor.ToColor();
2126 _SearchBar::GetPropertyButtonPressedTextColor(void) const
2128 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2129 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2131 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2135 _SearchBar::SetPropertySearchFieldDisabledColor(const Variant& color)
2137 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2138 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2140 result r = E_SUCCESS;
2142 r = __pEdit->SetPropertyDisabledColor(color);
2143 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2144 "[E_SYSTEM] A system error has occurred. Failed to set the edit disabled color.");
2146 __color[SEARCH_FIELD_STATUS_DISABLED] = color.ToColor();
2152 _SearchBar::GetPropertySearchFieldDisabledColor(void) const
2154 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2155 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2157 return Variant(__color[SEARCH_FIELD_STATUS_DISABLED]);
2161 _SearchBar::SetPropertySearchFieldHighlightedColor(const Variant& color)
2163 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2164 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2166 result r = E_SUCCESS;
2168 r = __pEdit->SetPropertyHighlightedColor(color);
2169 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2170 "[E_SYSTEM] A system error has occurred. Failed to set the edit highlighted color.");
2172 __color[SEARCH_FIELD_STATUS_HIGHLIGHTED] = color.ToColor();
2178 _SearchBar::GetPropertySearchFieldHighlightedColor(void) const
2180 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2181 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2183 return Variant(__color[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2187 _SearchBar::SetPropertySearchFieldNormalColor(const Variant& color)
2189 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2190 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2192 result r = E_SUCCESS;
2194 r = __pEdit->SetPropertyNormalColor(color);
2195 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2196 "[E_SYSTEM] A system error has occurred. Failed to set edit normal color.");
2198 __color[SEARCH_FIELD_STATUS_NORMAL] = color.ToColor();
2204 _SearchBar::GetPropertySearchFieldNormalColor(void) const
2206 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2207 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2209 return Variant(__color[SEARCH_FIELD_STATUS_NORMAL]);
2213 _SearchBar::SetPropertySearchFieldDisabledTextColor(const Variant& textColor)
2215 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2216 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2218 result r = E_SUCCESS;
2220 r = __pEdit->SetPropertyDisabledTextColor(textColor);
2221 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2222 "[E_SYSTEM] A system error has occurred. Failed to set edit disabled text color.");
2224 __textColor[SEARCH_FIELD_STATUS_DISABLED] = textColor.ToColor();
2230 _SearchBar::GetPropertySearchFieldDisabledTextColor(void) const
2232 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2233 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2235 return Variant(__textColor[SEARCH_FIELD_STATUS_DISABLED]);
2239 _SearchBar::SetPropertySearchFieldHighlightedTextColor(const Variant& textColor)
2241 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2242 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2244 result r = E_SUCCESS;
2246 r = __pEdit->SetPropertyHighlightedTextColor(textColor);
2247 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2248 "[E_SYSTEM] A system error has occurred. Failed to set edit highlighted text color.");
2250 __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED] = textColor.ToColor();
2256 _SearchBar::GetPropertySearchFieldHighlightedTextColor(void) const
2258 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2259 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2261 return Variant(__textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2265 _SearchBar::SetPropertySearchFieldNormalTextColor(const Variant& textColor)
2267 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2268 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2270 result r = E_SUCCESS;
2272 r = __pEdit->SetPropertyNormalTextColor(textColor);
2273 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2274 "[E_SYSTEM] A system error has occurred. Failed to set edit normal text color.");
2276 __textColor[SEARCH_FIELD_STATUS_NORMAL] = textColor.ToColor();
2282 _SearchBar::GetPropertySearchFieldNormalTextColor(void) const
2284 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2285 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2287 return Variant(__textColor[SEARCH_FIELD_STATUS_NORMAL]);
2291 _SearchBar::SetPropertyColor(const Variant& color)
2293 __backgroundColor = color.ToColor();
2299 _SearchBar::GetPropertyColor(void) const
2301 return Variant(__backgroundColor);
2305 _SearchBar::SetPropertyContentAreaSize(const Variant& size)
2307 FloatDimension contentAreaSize = size.ToFloatDimension();
2308 SysTryReturn(NID_UI_CTRL, contentAreaSize.width >= 0 && contentAreaSize.height >= 0, E_INVALID_ARG, E_INVALID_ARG,
2309 "[E_INVALID_ARG] Invalid argument(s) is used. contentAreaSize.width = %f, contenAreaSize.height = %f",
2310 contentAreaSize.width, contentAreaSize.height);
2312 result r = E_SUCCESS;
2315 FloatRectangle bounds = GetBoundsF();
2316 FloatRectangle contentAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
2318 contentAreaBounds.x = 0.0f;
2319 contentAreaBounds.y = bounds.height;
2320 contentAreaBounds.width = contentAreaSize.width;
2321 contentAreaBounds.height = contentAreaSize.height;
2323 __contentAreaBounds = contentAreaBounds;
2324 __isUserContainerBounds = true;
2329 r = __pContainer->SetBounds(__contentAreaBounds);
2330 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2337 _SearchBar::GetPropertyContentAreaSize(void) const
2339 FloatDimension contentAreaSize(__contentAreaBounds.width, __contentAreaBounds.height);
2341 return Variant(contentAreaSize);
2345 _SearchBar::CreateClippedGroupControl(void)
2347 result r = E_SUCCESS;
2348 FloatRectangle clippedGroupControlBounds(FloatPoint(0.0f, 0.0f), GetSizeF());
2349 __pClippedGroupControl = _Control::CreateControlN();
2350 r = GetLastResult();
2351 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2353 r = AttachChild(*__pClippedGroupControl);
2354 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
2355 "[E_SYSTEM] A system error has occurred. Failed to attach the parent of clipped control.");
2357 r = __pClippedGroupControl->SetBounds(clippedGroupControlBounds);
2358 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2360 __pClippedGroupControl->SetBackgroundColor(Color(0));
2362 __pClippedGroupControl->SetClipChildrenEnabled(true);
2367 delete __pClippedGroupControl;
2368 __pClippedGroupControl = null;
2375 _SearchBar::SetContentDimming(void)
2377 if (__pContainer != NULL)
2379 if (!GetTextLength())
2381 __contentColor.SetAlpha(_SEARCH_CONTENT_DIM_OPACITY);
2385 __contentColor.SetAlpha(0);
2387 __pContainer->SetBackgroundColor(__contentColor);
2393 _SearchBar::IsContentAttachable(const _Control* pContent)
2395 const _Window* pWindow = dynamic_cast <const _Window*>(pContent);
2396 const _ColorPicker* pColorPicker = dynamic_cast <const _ColorPicker*>(pContent);
2397 const _Form* pForm = dynamic_cast <const _Form*>(pContent);
2398 const _Keypad* pKeypad = dynamic_cast <const _Keypad*>(pContent);
2399 const _OverlayPanel* pOverlayPanel = dynamic_cast <const _OverlayPanel*>(pContent);
2401 bool isContentAttachable = true;
2403 isContentAttachable = ((pWindow == null) && (pColorPicker == null) &&
2404 (pForm == null) && (pKeypad == null) && (pOverlayPanel == null));
2405 return isContentAttachable;
2409 _SearchBar::ResizeCancelButton(void)
2411 result r = E_SUCCESS;
2413 int horizontalMargin = 0;
2414 int buttonLeftMargin = 0;
2415 int buttonRightMargin = 0;
2416 int buttonMinWidth = 0;
2417 int searchFieldMinWidth = 0;
2418 int buttonVerticalMargin = 0;
2419 int searchBarMinHeight = 0;
2420 int buttonWidth = 0;
2421 int buttonHeight = 0;
2423 FloatRectangle cancelButtonBounds;
2424 FloatRectangle searchBarBounds = GetBoundsF();
2426 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2428 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2429 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2430 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2431 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2432 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2433 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2434 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2435 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2436 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2438 cancelButtonBounds.width = _CoordinateSystemUtils::ConvertToFloat(buttonWidth);
2439 cancelButtonBounds.height = _CoordinateSystemUtils::ConvertToFloat(buttonHeight);
2441 float buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth +
2442 cancelButtonBounds.width + buttonLeftMargin + buttonRightMargin);
2444 if (searchBarBounds.width < buttonResizableSearchBarWidth)
2446 cancelButtonBounds.width = searchBarBounds.width -(searchFieldMinWidth + buttonLeftMargin
2447 + buttonRightMargin + horizontalMargin);
2450 cancelButtonBounds.x = searchBarBounds.width - cancelButtonBounds.width - buttonRightMargin;
2451 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2453 if (searchBarBounds.height < searchBarMinHeight)
2455 cancelButtonBounds.y = buttonVerticalMargin;
2458 if (cancelButtonBounds.width < buttonMinWidth)
2460 cancelButtonBounds.width = buttonMinWidth;
2463 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2464 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2465 r = __pCancelButton->SetBounds(cancelButtonBounds);
2472 _SearchBar::GetCurrentStatus(void)
2474 SearchFieldStatus searchFieldStatus = SEARCH_FIELD_STATUS_NORMAL;
2478 if (__pEdit->IsFocused())
2480 searchFieldStatus = SEARCH_FIELD_STATUS_HIGHLIGHTED;
2485 searchFieldStatus = SEARCH_FIELD_STATUS_DISABLED;
2488 return searchFieldStatus;
2492 _SearchBar::SetEditTextFilter(IEditTextFilter* pFilter)
2494 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2495 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2497 __pEdit->SetEditTextFilter(pFilter);
2503 _SearchBar::SendOpaqueCommand(const String& command)
2505 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2506 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2508 __pEdit->SendOpaqueCommand(command);
2513 }}} // Tizen::Ui::Controls