2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an ”AS IS” BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrl_SearchBar.cpp
20 * @brief This is the implementation file for the _SearchBar class.
23 #include <FBaseErrorDefine.h>
24 #include <FBaseSysLog.h>
25 #include <FGrp_BitmapImpl.h>
26 #include "FUiAnim_VisualElement.h"
27 #include "FUi_ResourceManager.h"
28 #include "FUiCtrl_SearchBar.h"
29 #include "FUiCtrl_SearchBarPresenter.h"
30 #include "FUiCtrl_Form.h"
31 #include "FUiCtrl_Edit.h"
32 #include "FUiCtrl_Panel.h"
33 #include "FUiCtrl_OverlayPanel.h"
34 #include "FUiCtrl_Keypad.h"
35 #include "FUiCtrl_ColorPicker.h"
36 #include "FUiCtrl_ActionEvent.h"
37 #include "FUiCtrl_TextBlockEvent.h"
38 #include "FUiCtrl_TextEvent.h"
39 #include "FUi_AccessibilityContainer.h"
40 #include "FUi_AccessibilityElement.h"
41 #include "FUi_AccessibilityManager.h"
42 #include "FUi_CoordinateSystemUtils.h"
44 using namespace Tizen::Graphics;
45 using namespace Tizen::Ui;
46 using namespace Tizen::Ui::Animations;
47 using namespace Tizen::Base;
48 using namespace Tizen::Base::Runtime;
49 using namespace Tizen::Locales;
51 namespace Tizen { namespace Ui { namespace Controls
54 IMPLEMENT_PROPERTY(_SearchBar);
56 _SearchBar::_SearchBar(void)
57 : __pSearchBarPresenter(null)
58 , __pClippedGroupControl(null)
60 , __pCancelButton(null)
62 , __pContentControl(null)
65 , __isButtonEnabled(true)
66 , __isUsableCancelButton(false)
67 , __isUserContainerBounds(false)
68 , __isCancelActionInProgress(false)
69 , __isUserGuideTextColor(false)
70 , __isKeypadOpening(false)
71 , __isupdateContentBounds(false)
72 , __keypadAction(CORE_KEYPAD_ACTION_SEARCH)
73 , __pBackgroundBitmap(null)
74 , __backgroundColor(Color())
75 , __contentColor(Color())
76 , __pActionEvent(null)
77 , __pKeypadEvent(null)
78 , __pTextBlockEvent(null)
80 , __pSearchBarEvent(null)
81 , __pLanguageEvent(null)
83 for (int i = 0; i < SEARCHBAR_BUTTON_COLOR_MAX; i++)
85 __buttonColor[i] = Color(0);
86 __buttonTextColor[i] = Color(0);
89 for (int i = 0; i < SEARCHBAR_COLOR_MAX; i++)
91 __color[i] = Color(0);
92 __textColor[i] = Color(0);
93 __guideTextColor[i] = Color(0);
96 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
99 pContainer->Activate(true);
103 _SearchBar::~_SearchBar(void)
106 delete __pSearchBarPresenter;
107 __pSearchBarPresenter = null;
111 __pEdit->HideKeypad();
113 __pClippedGroupControl->DetachChild(*__pEdit);
121 __pClippedGroupControl->DetachChild(*__pCancelButton);
123 delete __pCancelButton;
124 __pCancelButton = null;
127 if (__pClippedGroupControl)
129 DetachChild(*__pClippedGroupControl);
131 delete __pClippedGroupControl;
132 __pClippedGroupControl = null;
137 DetachChild(*__pContainer);
145 delete __pActionEvent;
146 __pActionEvent = null;
151 delete __pKeypadEvent;
152 __pKeypadEvent = null;
155 if (__pTextBlockEvent)
157 delete __pTextBlockEvent;
158 __pTextBlockEvent = null;
167 if (__pSearchBarEvent)
169 delete __pSearchBarEvent;
170 __pSearchBarEvent = null;
173 delete __pBackgroundBitmap;
174 __pBackgroundBitmap = null;
178 _SearchBar::CreateSearchBarN(void)
180 _SearchBar* pSearchBar = new (std::nothrow) _SearchBar;
181 SysTryReturn(NID_UI_CTRL, pSearchBar, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
182 if (GetLastResult() != E_SUCCESS)
188 pSearchBar->AcquireHandle();
194 _SearchBar::Initialize(bool enableSearchBarButton, CoreKeypadAction keypadAction)
196 result r = E_SUCCESS;
198 // Setting Button color
199 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_NORMAL, __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
200 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_PRESSED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
201 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_HIGHLIGHTED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
202 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_DISABLED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
204 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_NORMAL, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
205 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_PRESSED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
206 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_HIGHLIGHTED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
207 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_DISABLED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
209 GET_COLOR_CONFIG(SEARCHBAR::CONTENT_AREA_BG_NORMAL, __contentColor);
211 for (int i = 0; i < SEARCHBAR_COLOR_MAX; i++)
215 case SEARCH_FIELD_STATUS_DISABLED:
216 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_DISABLED, __color[i]);
217 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_DISABLED, __textColor[i]);
218 GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_DISABLED, __guideTextColor[i]);
221 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
222 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]);
223 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_HIGHLIGHTED, __textColor[i]);
224 GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_HIGHLIGHTED, __guideTextColor[i]);
227 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]);
228 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_NORMAL, __textColor[i]);
229 GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_NORMAL, __guideTextColor[i]);
234 __isUsableCancelButton = enableSearchBarButton;
235 __keypadAction = keypadAction;
237 GetVisualElement()->SetClipChildrenEnabled(false);
239 r = CreateClippedGroupControl();
240 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
241 "[E_SYSTEM] A system error has occurred. The construction of parent control for clipped group control failed.");
243 r = CreateSearchField();
244 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
245 "[E_SYSTEM] A system error has occurred. The edit construction failed.");
246 r = CreateCancelButton();
247 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
248 "[E_SYSTEM] A system error has occurred. The cancel button construction failed.");
251 r = CreateContentsArea();
252 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
253 "[E_SYSTEM] A system error has occurred. The construction of parent for content failed.");
255 _SearchBarPresenter* pPresenter = new (std::nothrow) _SearchBarPresenter;
256 SysTryReturn(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
258 r = pPresenter->Construct(*this);
259 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
261 r = pPresenter->Install();
262 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
264 __pSearchBarPresenter = pPresenter;
276 _SearchBar::CreateSearchField(void)
278 result r = E_SUCCESS;
280 FloatRectangle editBounds;
281 float horizontalMargin = 0.0f;
282 float verticalMargin = 0.0f;
283 float iconHorizontalMargin = 0.0f;
284 float textHorizontalMargin = 0.0f;
285 float iconWidth = 0.0f;
286 float textSize = 0.0f;
287 float searchBarMinHeight = 0.0f;
288 float searchBarMinWidthModeNormal = 0.0f;
290 FloatRectangle searchBarBounds = GetBoundsF();
291 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
292 _AccessibilityContainer* pSearchBarContainer = null;
294 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
295 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin);
296 GET_SHAPE_CONFIG(SEARCHBAR::ICON_HORIZONTAL_MARGIN, orientation, iconHorizontalMargin);
297 GET_SHAPE_CONFIG(SEARCHBAR::ICON_WIDTH, orientation, iconWidth);
298 GET_SHAPE_CONFIG(SEARCHBAR::TEXT_HORIZONTAL_MARGIN, orientation, textHorizontalMargin);
299 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH_NORMAL_MODE, orientation, searchBarMinWidthModeNormal);
300 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
302 float searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2.0f);
304 editBounds.x = horizontalMargin;
306 if (searchBarBounds.height < searchBarMinHeight)
308 verticalMargin = (searchBarBounds.height - searchFieldMinHeight)/2.0f;
309 if (verticalMargin < 0.0f)
311 verticalMargin = 0.0f;
315 editBounds.y = verticalMargin;
317 editBounds.width = searchBarBounds.width - (editBounds.x * 2.0f);
318 editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
320 editBounds.width = (editBounds.width > searchBarMinWidthModeNormal) ? editBounds.width : searchBarMinWidthModeNormal;
321 editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
323 __pEdit = _Edit::CreateEditN();
325 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
327 r = __pEdit->Initialize(EDIT_STYLE_NORMAL | EDIT_STYLE_SINGLE_LINE | EDIT_STYLE_CLEAR | EDIT_STYLE_NOSCROLL, INPUT_STYLE_OVERLAY,
328 SEARCHBAR_TEXT_LENGTH_MAX);
329 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
331 __pEdit->SetKeypadCommandButtonVisible(false);
332 __pEdit->SetBounds(editBounds);
333 __pEdit->AddKeypadEventListener(*this);
334 __pEdit->AddTextBlockEventListener(*this);
335 __pEdit->AddTextEventListener(*this);
337 GET_SHAPE_CONFIG(SEARCHBAR::EDIT_TEXT_SIZE, orientation, textSize);
338 __pEdit->SetTextSize(textSize);
340 __pEdit->SetHorizontalMargin(iconHorizontalMargin + iconWidth + textHorizontalMargin, EDIT_TEXT_LEFT_MARGIN);
341 __pEdit->SetHorizontalMargin(textHorizontalMargin, EDIT_TEXT_RIGHT_MARGIN);
342 __pEdit->SetLimitLength(SEARCHBAR_TEXT_LENGTH_MAX);
344 for (int status = 0; status < SEARCHBAR_COLOR_MAX; status++)
346 EditStatus editStatus = ConvertSearchBarStatus((SearchFieldStatus) status);
347 __pEdit->SetColor(editStatus, __color[status]);
350 __pEdit->SetTextColor(EDIT_TEXT_COLOR_NORMAL, __textColor[SEARCH_FIELD_STATUS_NORMAL]);
351 __pEdit->SetTextColor(EDIT_TEXT_COLOR_DISABLED, __textColor[SEARCH_FIELD_STATUS_DISABLED]);
352 __pEdit->SetTextColor(EDIT_TEXT_COLOR_HIGHLIGHTED, __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
354 __pEdit->ReplaceDefaultBackgroundBitmapForSearchBar();
356 __pEdit->SetKeypadAction(__keypadAction);
358 r = __pClippedGroupControl->AttachChild(*__pEdit);
359 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
360 "[E_SYSTEM] A system error has occurred. Failed to attach edit as child.");
362 if (likely(!(_AccessibilityManager::IsActivated())))
367 pSearchBarContainer = GetAccessibilityContainer();
368 if (pSearchBarContainer)
370 _AccessibilityContainer* pSearchFieldContainer = __pEdit->GetAccessibilityContainer();
371 if (pSearchFieldContainer)
373 pSearchBarContainer->AddChildContainer(*pSearchFieldContainer);
387 _SearchBar::CreateCancelButton(void)
389 result r = E_SUCCESS;
391 float textSize = 0.0f;
392 String cancelButtonText;
394 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
395 _AccessibilityContainer* pSearchBarContainer = null;
397 __pCancelButton = _Button::CreateButtonN();
399 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
401 r = ResizeCancelButton();
402 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
404 GET_STRING_CONFIG(IDS_COM_SK_CANCEL, cancelButtonText);
405 r = __pCancelButton->SetText(cancelButtonText);
406 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
408 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_TEXT_SIZE, orientation, textSize);
409 r = __pCancelButton->SetTextSize(textSize);
410 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
412 __pCancelButton->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
413 __pCancelButton->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
415 r = __pCancelButton->SetActionId(__actionId);
416 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
418 r = __pCancelButton->AddActionEventListener(*this);
419 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
421 __pCancelButton->SetVisibleState(false);
423 for (int status = 0; status < SEARCHBAR_BUTTON_COLOR_MAX; status++)
425 _ButtonStatus buttonStatus = ConvertSearchBarButtonStatus((SearchBarButtonStatus) status);
427 r = __pCancelButton->SetColor(buttonStatus, __buttonColor[status]);
428 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
430 r = __pCancelButton->SetTextColor(buttonStatus, __buttonTextColor[status]);
431 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
434 r = __pClippedGroupControl->AttachChild(*__pCancelButton);
435 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
436 "[E_SYSTEM] A system error has occurred. Failed to attach button as child.");
438 if (likely(!(_AccessibilityManager::IsActivated())))
443 pSearchBarContainer = GetAccessibilityContainer();
444 if (pSearchBarContainer)
446 _AccessibilityContainer* pButtonContainer = __pCancelButton->GetAccessibilityContainer();
447 if (pButtonContainer)
449 pSearchBarContainer->AddChildContainer(*pButtonContainer);
456 delete __pCancelButton;
457 __pCancelButton = null;
463 _SearchBar::CreateContentsArea(void)
465 result r = E_SUCCESS;
467 __pContainer = _Control::CreateControlN();
470 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
472 __pContainer->SetVisibleState(false);
474 r = AttachChild(*__pContainer);
475 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
476 "[E_SYSTEM] A system error has occurred. Failed to attach the parent of content.");
488 _SearchBar::SetContentsArea(void)
490 if (__isUserContainerBounds)
495 FloatDimension screenSize = _ControlManager::GetInstance()->GetScreenSizeF();
496 float width = screenSize.width;
497 float height = screenSize.height;
499 _Control* pParent = GetParentForm();
502 width = pParent->GetClientBoundsF().width;
503 height = pParent->GetClientBoundsF().height;
506 FloatRectangle controlBounds = GetBoundsF();
507 controlBounds = CoordinateSystem::AlignToDevice(FloatRectangle(controlBounds));
509 __contentAreaBounds.x = 0.0f;
510 __contentAreaBounds.y = controlBounds.height;
511 __contentAreaBounds.width = width - controlBounds.x;
512 __contentAreaBounds.height = height - (controlBounds.y + controlBounds.height);
516 result r = E_SUCCESS;
517 r = __pContainer->SetBounds(__contentAreaBounds);
518 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
524 _SearchBar::GetContent(void) const
526 return __pContentControl;
530 _SearchBar::SetContent(const _Control* pContent)
532 __pContentControl = const_cast <_Control*>(pContent);
533 result r = E_SUCCESS;
537 r = __pContainer->AttachChild(*__pContentControl);
538 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating");
545 _SearchBar::UpdateContentArea(bool invalidate)
547 return __pSearchBarPresenter->UpdateContentArea(invalidate);
551 _SearchBar::SetContentAreaVisible(bool visible)
553 SysTryReturn(NID_UI_CTRL, __pContainer, E_SYSTEM, E_SYSTEM,
554 "[E_SYSTEM] A system error has occurred. The instance of parent to content is null.");
556 SearchBarMode searchBarMode = GetMode();
557 if (searchBarMode == SEARCH_BAR_MODE_INPUT)
559 __pContainer->SetVisibleState(visible);
562 return __pSearchBarPresenter->SetContentAreaVisible(visible);
566 _SearchBar::IsContentAreaVisible(void) const
568 return __pSearchBarPresenter->IsContentAreaVisible();
572 _SearchBar::SetContentAreaSize(const Dimension& size)
574 return SetProperty("contentAreaSize", Variant(size));
578 _SearchBar::GetContentAreaSize(void) const
580 Variant size = GetProperty("contentAreaSize");
582 return size.ToDimension();
586 _SearchBar::GetMode(void) const
588 return __pSearchBarPresenter->GetMode();
592 _SearchBar::IsModeLocked(void) const
594 return __pSearchBarPresenter->IsModeLocked();
598 _SearchBar::SetMode(SearchBarMode mode)
600 return __pSearchBarPresenter->SetMode(mode);
604 _SearchBar::SetModeLocked(bool modeLocked)
606 return __pSearchBarPresenter->SetModeLocked(modeLocked);
610 _SearchBar::GetButtonActionId(void) const
612 Variant actionId = GetProperty("buttonActionId");
614 return actionId.ToInt();
618 _SearchBar::GetButtonColor(SearchBarButtonStatus status) const
624 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
625 buttonColor = GetProperty("buttonNormalColor");
627 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
628 buttonColor = GetProperty("buttonPressedColor");
630 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
631 buttonColor = GetProperty("buttonHighlightedColor");
633 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
634 buttonColor = GetProperty("buttonDisabledColor");
640 return buttonColor.ToColor();
644 _SearchBar::GetButtonTextColor(SearchBarButtonStatus status) const
646 Variant buttonTextColor;
650 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
651 buttonTextColor = GetProperty("buttonNormalTextColor");
653 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
654 buttonTextColor = GetProperty("buttonPressedTextColor");
656 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
657 buttonTextColor = GetProperty("buttonHighlightedTextColor");
659 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
660 buttonTextColor = GetProperty("buttonDisabledTextColor");
666 return buttonTextColor.ToColor();
669 SearchBarButtonStatus
670 _SearchBar::GetButtonStatus(void) const
672 SysTryReturn(NID_UI_CTRL, __pCancelButton, SEARCH_BAR_BUTTON_STATUS_NORMAL, E_SYSTEM,
673 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
675 SearchBarButtonStatus buttonStatus = SEARCH_BAR_BUTTON_STATUS_NORMAL;
677 if (__isButtonEnabled == false)
679 buttonStatus = SEARCH_BAR_BUTTON_STATUS_DISABLED;
686 _SearchBar::SetButtonText(const String& text)
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 result r = E_SUCCESS;
693 r = __pCancelButton->SetText(text);
694 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
695 "[E_SYSTEM] A system error has occurred. Failed to set text.");
701 _SearchBar::SetButtonActionId(int actionId)
703 return SetProperty("buttonActionId", Variant(actionId));
707 _SearchBar::SetButtonEnabled(bool enabled)
709 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
710 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
712 __pCancelButton->SetEnableState(enabled);
714 __isButtonEnabled = enabled;
720 _SearchBar::SetButtonColor(SearchBarButtonStatus status, const Color& color)
722 result r = E_SUCCESS;
726 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
727 r = SetProperty("buttonNormalColor", Variant(color));
729 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
730 r = SetProperty("buttonPressedColor", Variant(color));
732 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
733 r = SetProperty("buttonHighlightedColor", Variant(color));
735 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
736 r = SetProperty("buttonDisabledColor", Variant(color));
746 _SearchBar::SetButtonTextColor(SearchBarButtonStatus status, const Color& color)
748 result r = E_SUCCESS;
752 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
753 r = SetProperty("buttonNormalTextColor", Variant(color));
755 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
756 r = SetProperty("buttonPressedTextColor", Variant(color));
758 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
759 r = SetProperty("buttonHighlightedTextColor", Variant(color));
761 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
762 r = SetProperty("buttonDisabledTextColor", Variant(color));
772 _SearchBar::AppendCharacter(const Character& character)
774 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
775 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
776 SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM,
777 "[E_SYSTEM] A system error has occurred. The character is null.");
779 result r = E_SUCCESS;
781 r = __pEdit->AppendCharacter(character);
782 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
783 "[E_SYSTEM] A system error has occurred. Failed to set character.");
789 _SearchBar::AppendText(const String& text)
791 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
792 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
793 SysTryReturn(NID_UI_CTRL, text.IsEmpty() == false, E_SYSTEM, E_SYSTEM,
794 "[E_SYSTEM] A system error has occurred. The text is empty.");
796 result r = E_SUCCESS;
798 r = __pEdit->AppendText(text);
799 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
800 "[E_SYSTEM] A system error has occurred. Failed to set text.");
806 _SearchBar::SetText(const String& text)
808 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
809 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
811 result r = E_SUCCESS;
813 int limitLength = __pEdit->GetTextLimitLength();
814 int textLength = text.GetLength();
815 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_SYSTEM, E_SYSTEM,
816 "[E_SYSTEM] A system error has occurred. textLength exceeds the limitLength");
818 r = __pEdit->SetText(text);
819 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
820 "[E_SYSTEM] A system error has occurred. Failed to set text.");
826 _SearchBar::InsertCharacterAt(int index, const Character& character)
828 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
829 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
830 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
831 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
832 SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM,
833 "[E_SYSTEM] A system error has occurred. The character is null.");
835 result r = E_SUCCESS;
839 limitLength = __pEdit->GetTextLimitLength();
840 textLength = __pEdit->GetTextLength() + 1;
842 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
843 "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
845 SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
846 "[E_OUT_OF_RANGE] index(%d) is out of range of current textLength(%d).", index, __pEdit->GetTextLength());
848 r = __pEdit->InsertCharacterAt(index, character);
849 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
850 "[E_SYSTEM] A system error has occurred. Failed to set text.");
856 _SearchBar::InsertTextAt(int index, const String& text)
858 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
859 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
860 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
861 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
863 result r = E_SUCCESS;
867 limitLength = __pEdit->GetTextLimitLength();
868 textLength = __pEdit->GetTextLength() + text.GetLength();
870 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
871 "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
872 SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
873 "[E_OUT_OF_RANGE] index(%d) is out of range of current textLength(%d).", index, __pEdit->GetTextLength());
875 r = __pEdit->InsertTextAt(index, text);
876 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
877 "[E_SYSTEM] A system error has occurred. Failed to insert text.");
883 _SearchBar::DeleteCharacterAt(int index)
885 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
886 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
887 SysTryReturn(NID_UI_CTRL, index > -1, E_INVALID_ARG, E_INVALID_ARG,
888 "[E_INVALID_ARG] Invalid argument(s) is used. index = %d", index);
890 result r = E_SUCCESS;
892 textLength = __pEdit->GetTextLength();
894 SysTryReturn(NID_UI_CTRL, textLength > index, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
895 "[E_OUT_OF_RANGE] index(%d) is out of range. textLength(%d)", index, textLength);
897 r = __pEdit->DeleteCharacterAt(index);
898 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM,
899 "[E_SYSTEM] A system error has occured. Failed to delete character.");
905 _SearchBar::Clear(void)
907 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
908 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
910 return __pEdit->ClearText();
914 _SearchBar::GetTextLength(void) const
916 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
917 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
919 return __pEdit->GetTextLength();
923 _SearchBar::GetText(void) const
925 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
926 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
928 return __pEdit->GetText();
932 _SearchBar::GetText(int start, int end) const
934 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
935 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
937 return __pEdit->GetText(start, end);
941 _SearchBar::GetLimitLength(void) const
943 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
944 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
946 return __pEdit->GetTextLimitLength();
950 _SearchBar::SetLimitLength(int limitLength)
952 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
953 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
954 SysTryReturn(NID_UI_CTRL, limitLength > 0, E_INVALID_ARG, E_INVALID_ARG,
955 "[E_INVALID_ARG] Invalid argument(s) is used.limitLength = %d", limitLength);
957 String tempString = GetText();
959 int textLength = tempString.GetLength();
960 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_INVALID_ARG, E_INVALID_ARG,
961 "[E_INVALID_ARG] Invalid argument(s) is used. limitLength = %d, textLength = %d", limitLength, textLength);
963 result r = __pEdit->SetLimitLength(limitLength);
964 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
966 r = SetText(tempString);
967 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
973 _SearchBar::ShowKeypad(void) const
975 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
976 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
978 SearchBarMode mode = __pSearchBarPresenter->GetMode();
979 SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_INVALID_STATE, E_INVALID_STATE,
980 "[E_INVALID_STATE] The SearchBar is currently in Normal mode.");
981 return __pEdit->ShowKeypad();
985 _SearchBar::HideKeypad(void)
987 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
988 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
990 SearchBarMode mode = __pSearchBarPresenter->GetMode();
991 SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_SYSTEM, E_SYSTEM,
992 "[E_SYSTEM] A system error has occurred. The SearchBar is currently in Normal mode.");
994 result r = __pEdit->HideKeypad();
1002 _SearchBar::GetSearchFieldTextSizeF(void) const
1004 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
1005 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1007 return __pEdit->GetTextSizeF();
1011 _SearchBar::SetSearchFieldTextSize(float size)
1013 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1014 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1016 return __pEdit->SetTextSize(size);
1020 _SearchBar::GetBlockRange(int& start, int& end) const
1022 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1023 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1025 int startIndex = -1;
1028 __pEdit->GetBlockRange(startIndex, endIndex);
1029 SysTryReturn(NID_UI_CTRL, (startIndex > -1 && endIndex > 0), E_SYSTEM, E_SYSTEM,
1030 "[E_SYSTEM] A system error has occurred. Failed to get text block range.");
1039 _SearchBar::ReleaseBlock(void)
1041 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1042 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1044 result r = E_SUCCESS;
1049 r = GetBlockRange(start, end);
1050 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1052 return __pEdit->ReleaseTextBlock();
1056 _SearchBar::SetBlockRange(int start, int end)
1058 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1059 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1061 result r = E_SUCCESS;
1064 textLength = __pEdit->GetTextLength();
1066 SysTryReturn(NID_UI_CTRL, (start < end && start >= 0 && textLength >= end), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1067 "[E_OUT_OF_RANGE] start (%d) and end (%d) is out of range.", start, end - 1);
1069 r = SetCursorPosition(start);
1070 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1072 r = __pEdit->BeginTextBlock();
1073 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1074 "[E_SYSTEM] A system error has occurred. Failed to set text block range.");
1076 r = SetCursorPosition(end);
1077 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1078 "[E_SYSTEM] A system error has occurred. Failed to set cursor position.");
1084 _SearchBar::RemoveTextBlock(void)
1086 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1087 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1089 result r = E_SUCCESS;
1091 r = __pEdit->RemoveTextBlock();
1092 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1098 _SearchBar::GetColor(void) const
1100 Variant backgroundColor = GetProperty("color");
1102 return backgroundColor.ToColor();
1106 _SearchBar::GetSearchFieldColor(SearchFieldStatus status) const
1108 Variant searchFieldColor;
1112 case SEARCH_FIELD_STATUS_NORMAL:
1113 searchFieldColor = GetProperty("searchFieldNormalColor");
1115 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1116 searchFieldColor = GetProperty("searchFieldHighlightedColor");
1118 case SEARCH_FIELD_STATUS_DISABLED:
1119 searchFieldColor = GetProperty("searchFieldDisabledColor");
1125 return searchFieldColor.ToColor();
1130 _SearchBar::GetSearchFieldTextColor(SearchFieldStatus status) const
1132 Variant searchFieldTextColor;
1136 case SEARCH_FIELD_STATUS_NORMAL:
1137 searchFieldTextColor = GetProperty("searchFieldNormalTextColor");
1139 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1140 searchFieldTextColor = GetProperty("searchFieldHighlightedTextColor");
1142 case SEARCH_FIELD_STATUS_DISABLED:
1143 searchFieldTextColor = GetProperty("searchFieldDisabledTextColor");
1149 return searchFieldTextColor.ToColor();
1154 _SearchBar::SetBackgroundBitmap(const Bitmap& bitmap)
1156 Bitmap* pNewBitmap = _BitmapImpl::CloneN(bitmap);
1157 SysTryReturn(NID_UI_CTRL, pNewBitmap, E_SYSTEM, E_SYSTEM,
1158 "[E_SYSTEM] A system error has occurred. The creation of bitmap failed.");
1160 delete __pBackgroundBitmap;
1161 __pBackgroundBitmap = null;
1163 __pBackgroundBitmap = pNewBitmap;
1169 _SearchBar::GetBackgroundBitmap(void) const
1171 return __pBackgroundBitmap;
1175 _SearchBar::SetColor(const Color& color)
1177 return SetProperty("color", Variant(color));
1181 _SearchBar::SetSearchFieldColor(SearchFieldStatus status, const Color& color)
1183 result r = E_SUCCESS;
1187 case SEARCH_FIELD_STATUS_NORMAL:
1188 r = SetProperty("searchFieldNormalColor", Variant(color));
1190 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1191 r = SetProperty("searchFieldHighlightedColor", Variant(color));
1193 case SEARCH_FIELD_STATUS_DISABLED:
1194 r = SetProperty("searchFieldDisabledColor", Variant(color));
1205 _SearchBar::SetSearchFieldTextColor(SearchFieldStatus status, const Color& color)
1207 result r = E_SUCCESS;
1211 case SEARCH_FIELD_STATUS_NORMAL:
1212 r = SetProperty("searchFieldNormalTextColor", Variant(color));
1214 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1215 r = SetProperty("searchFieldHighlightedTextColor", Variant(color));
1217 case SEARCH_FIELD_STATUS_DISABLED:
1218 r = SetProperty("searchFieldDisabledTextColor", Variant(color));
1229 _SearchBar::GetGuideText(void) const
1231 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
1232 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1234 return __pEdit->GetGuideText();
1238 _SearchBar::SetGuideText(const String& guideText)
1240 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1241 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1243 __pEdit->SetGuideText(guideText);
1249 _SearchBar::GetGuideTextColor(void) const
1251 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1252 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1254 return __pEdit->GetGuideTextColor();
1258 _SearchBar::SetGuideTextColor(const Color& color)
1260 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1261 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1263 __isUserGuideTextColor = true;
1264 return __pEdit->SetGuideTextColor(color);
1268 _SearchBar::GetCursorPosition(void) const
1270 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
1271 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1273 return __pEdit->GetCursorPosition();
1277 _SearchBar::SetCursorPosition(int index)
1279 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1280 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1281 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1282 "[E_OUT_OF_RANGE] index(%d) is out of range.", GetErrorMessage(E_OUT_OF_RANGE), index);
1284 int textLength = -1;
1285 textLength = __pEdit->GetTextLength();
1287 SysTryReturn(NID_UI_CTRL, (index > -1 && index <= textLength), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1288 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
1290 return __pEdit->SetCursorPosition(index);
1294 _SearchBar::IsLowerCaseModeEnabled(void) const
1296 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1297 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1299 return __pEdit->IsLowerCaseModeEnabled();
1303 _SearchBar::SetLowerCaseModeEnabled(bool enable)
1305 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
1306 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1308 __pEdit->SetLowerCaseModeEnabled(enable);
1312 _SearchBar::GetEllipsisPosition(void) const
1314 SysTryReturn(NID_UI_CTRL, __pEdit, ELLIPSIS_POSITION_START, E_SYSTEM,
1315 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1317 return __pEdit->GetEllipsisPosition();
1321 _SearchBar::SetEllipsisPosition(EllipsisPosition position)
1323 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1324 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1325 __pEdit->SetEllipsisPosition(position);
1331 _SearchBar::GetKeypadAction(void) const
1333 return __keypadAction;
1337 _SearchBar::IsTextPredictionEnabled(void) const
1339 SysTryReturn(NID_UI_CTRL, __pEdit, false, E_SYSTEM,
1340 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1341 return __pEdit->IsTextPredictionEnabled();
1345 _SearchBar::SetTextPredictionEnabled(bool enable)
1347 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1348 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1349 return __pEdit->SetTextPredictionEnabled(enable);
1353 _SearchBar::SetCurrentLanguage(LanguageCode languageCode)
1355 return __pEdit->SetCurrentLanguage(languageCode);
1359 _SearchBar::GetCurrentLanguage(LanguageCode& language) const
1361 return __pEdit->GetCurrentLanguage(language);
1365 _SearchBar::AddActionEventListener(const _IActionEventListener& listener)
1367 result r = E_SUCCESS;
1369 if (__pActionEvent == null)
1371 __pActionEvent = _ActionEvent::CreateInstanceN(*this);
1372 r = GetLastResult();
1373 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1375 __pActionEvent->AddListener(listener);
1382 _SearchBar::RemoveActionEventListener(const _IActionEventListener& listener)
1384 SysTryReturn(NID_UI_CTRL, __pActionEvent, E_SYSTEM, E_SYSTEM,
1385 "[E_SYSTEM] A system error has occurred. The action event instance is null.");
1386 result r = E_SUCCESS;
1388 r = __pActionEvent->RemoveListener(listener);
1389 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1395 _SearchBar::AddKeypadEventListener(const _IKeypadEventListener& listener)
1397 result r = E_SUCCESS;
1399 if (__pKeypadEvent == null)
1401 __pKeypadEvent = _KeypadEvent::CreateInstanceN(*this);
1402 r = GetLastResult();
1403 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1405 r = __pKeypadEvent->AddListener(listener);
1406 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1413 _SearchBar::RemoveKeypadEventListener(const _IKeypadEventListener& listener)
1415 SysTryReturn(NID_UI_CTRL, __pKeypadEvent, E_SYSTEM, E_SYSTEM,
1416 "[E_SYSTEM] A system error has occurred. The keypad event instance is null.");
1417 result r = E_SUCCESS;
1419 r = __pKeypadEvent->RemoveListener(listener);
1420 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1426 _SearchBar::AddTextBlockEventListener(const _ITextBlockEventListener& listener)
1428 result r = E_SUCCESS;
1430 if (__pTextBlockEvent == null)
1432 __pTextBlockEvent = _TextBlockEvent::CreateInstanceN(*this);
1433 r = GetLastResult();
1434 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1436 r = __pTextBlockEvent->AddListener(listener);
1437 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1445 _SearchBar::RemoveTextBlockEventListener(const _ITextBlockEventListener& listener)
1447 SysTryReturn(NID_UI_CTRL, __pTextBlockEvent, E_SYSTEM, E_SYSTEM,
1448 "[E_SYSTEM] A system error has occurred. The text block event instance is null.");
1449 result r = E_SUCCESS;
1451 r = __pTextBlockEvent->RemoveListener(listener);
1452 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1459 _SearchBar::AddTextEventListener(const _ITextEventListener& listener)
1461 result r = E_SUCCESS;
1463 if (__pTextEvent == null)
1465 __pTextEvent = _TextEvent::CreateInstanceN(*this);
1466 r = GetLastResult();
1467 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1469 r = __pTextEvent->AddListener(listener);
1470 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1477 _SearchBar::RemoveTextEventListener(const _ITextEventListener& listener)
1479 SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM,
1480 "[E_SYSTEM] A system error has occurred. The text event instance is null.");
1481 result r = E_SUCCESS;
1483 r = __pTextEvent->RemoveListener(listener);
1484 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1490 _SearchBar::AddSearchBarEventListener(const _ISearchBarEventListener& listener)
1492 result r = E_SUCCESS;
1494 if (__pSearchBarEvent == null)
1496 __pSearchBarEvent = _SearchBarEvent::CreateInstanceN(*this);
1497 r = GetLastResult();
1498 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1500 r = __pSearchBarEvent->AddListener(listener);
1501 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1508 _SearchBar::RemoveSearchBarEventListener(const _ISearchBarEventListener& listener)
1510 SysTryReturn(NID_UI_CTRL, __pSearchBarEvent, E_SYSTEM, E_SYSTEM,
1511 "[E_SYSTEM] A system error has occurred. The searchbar event instance is null.");
1512 result r = E_SUCCESS;
1514 r = __pSearchBarEvent->RemoveListener(listener);
1515 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1521 _SearchBar::AddLanguageEventListener(const _ILanguageEventListener& listener)
1523 result r = E_SUCCESS;
1525 if (__pLanguageEvent == null)
1527 __pLanguageEvent = _LanguageEvent::CreateInstanceN(*this);
1528 r = GetLastResult();
1529 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1531 r = __pLanguageEvent->AddListener(listener);
1532 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1539 _SearchBar::RemoveLanguageEventListener(const _ILanguageEventListener& listener)
1541 SysTryReturn(NID_UI_CTRL, __pLanguageEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.");
1542 result r = E_SUCCESS;
1544 __pLanguageEvent->RemoveListener(listener);
1545 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1551 _SearchBar::OnBoundsChanged(void)
1553 if (__pSearchBarPresenter != null)
1555 __isupdateContentBounds = true;
1556 __pSearchBarPresenter->OnBoundsChanged();
1562 _SearchBar::OnChangeLayout(_ControlOrientation orientation)
1564 __isupdateContentBounds = true;
1569 _SearchBar::OnDraw(void)
1571 if (!__isUserGuideTextColor)
1573 SearchFieldStatus status = GetCurrentStatus();
1574 __pEdit->SetGuideTextColor(__guideTextColor[status]);
1577 if (__isupdateContentBounds)
1580 __isupdateContentBounds = false;
1582 __pSearchBarPresenter->Draw();
1586 _UiTouchEventDelivery
1587 _SearchBar::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1589 _Edit* pEdit = dynamic_cast <_Edit*>(const_cast <_Control*>(&source));
1592 return _UI_TOUCH_EVENT_DELIVERY_YES;
1595 if (GetMode() == SEARCH_BAR_MODE_INPUT)
1597 return _UI_TOUCH_EVENT_DELIVERY_YES;
1600 SetMode(SEARCH_BAR_MODE_INPUT);
1602 return _UI_TOUCH_EVENT_DELIVERY_YES;
1606 _SearchBar::OnActionPerformed(const _Control& source, int actionId)
1608 if (__actionId == actionId)
1610 __isCancelActionInProgress = true;
1611 SetMode(SEARCH_BAR_MODE_NORMAL);
1615 IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(__actionId);
1616 result r = GetLastResult();
1617 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1619 __pActionEvent->Fire(*pEventArg);
1621 __isCancelActionInProgress = false;
1628 _SearchBar::OnKeypadWillOpen(void)
1630 if (!__isKeypadOpening)
1634 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CREATED);
1635 result r = GetLastResult();
1636 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1638 __pKeypadEvent->Fire(*pEventArg);
1642 __isKeypadOpening = true;
1647 _SearchBar::OnKeypadOpened(void)
1651 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_OPEN);
1652 result r = GetLastResult();
1653 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1655 __pKeypadEvent->Fire(*pEventArg);
1658 __isKeypadOpening = false;
1664 _SearchBar::OnKeypadClosed(void)
1668 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CLOSE);
1669 result r = GetLastResult();
1670 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1672 __pKeypadEvent->Fire(*pEventArg);
1680 _SearchBar::OnKeypadBoundsChanged(void)
1684 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1685 result r = GetLastResult();
1686 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1688 __pKeypadEvent->Fire(*pEventArg);
1696 _SearchBar::OnKeypadActionPerformed(CoreKeypadAction keypadAction)
1700 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(keypadAction, CORE_KEYPAD_EVENT_STATUS_ENTERACTION);
1701 result r = GetLastResult();
1702 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1704 __pKeypadEvent->Fire(*pEventArg);
1709 // TextBlock callbacks
1711 _SearchBar::OnTextBlockSelected(_Control& source, int start, int end)
1713 if (__pTextBlockEvent)
1715 IEventArg* pEventArg = _TextBlockEvent::CreateTextBlockEventArgN(start, end);
1716 result r = GetLastResult();
1717 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1719 __pTextBlockEvent->Fire(*pEventArg);
1726 _SearchBar::OnTextValueChanged(const _Control& source)
1728 if (!__isCancelActionInProgress)
1730 SetContentDimming();
1731 if (__pTextEvent != null)
1733 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CHANGED);
1734 result r = GetLastResult();
1735 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1737 __pTextEvent->Fire(*pEventArg);
1744 _SearchBar::OnTextValueChangeCanceled(const _Control& source)
1746 if (__pTextEvent != null)
1748 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CANCELED);
1749 result r = GetLastResult();
1750 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1752 __pTextEvent->Fire(*pEventArg);
1758 _SearchBar::OnAttachedToMainTree(void)
1766 _SearchBar::OnFontChanged(Font* pFont)
1768 __pCancelButton->SetFont(pFont->GetFaceName());
1769 __pEdit->SetFont(*pFont);
1774 _SearchBar::OnFontInfoRequested(unsigned long& style, int& size)
1776 style = FONT_STYLE_PLAIN;
1777 size = __pCancelButton->GetTextSize();
1783 _SearchBar::OnFocusGained(const _Control& source)
1785 SetMode(SEARCH_BAR_MODE_INPUT);
1786 __pEdit->SetFocused();
1791 _SearchBar::OnFocusLost(const _Control& source)
1797 _SearchBar::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1799 if (!__pEdit->IsUsbKeyboardConnected())
1804 _KeyCode keyCode = keyInfo.GetKeyCode();
1806 if (keyCode == _KEY_RIGHT)
1808 if (__isButtonEnabled)
1810 __pEdit->SetFocused(false);
1811 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED);
1812 __pCancelButton->SetFocused();
1813 __pCancelButton->Invalidate(true);
1819 if (keyCode == _KEY_LEFT)
1821 if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_HIGHLIGHTED)
1823 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1824 __pCancelButton->SetFocused(false);
1825 __pCancelButton->Invalidate();
1829 if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_DISABLED) //Searchbar Button is disabled, left arrow key is pressed
1831 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1832 SetButtonEnabled(false);
1835 __pEdit->SetFocused();
1844 _SearchBar::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
1850 _SearchBar::GetParentForm(void) const
1852 _Form* pForm = null;
1853 _Control* pControlCore = GetParent();
1857 if (pControlCore == null)
1859 SysLog(NID_UI_CTRL,"[E_SYSTEM] The parent form is null.");
1864 pForm = dynamic_cast <_Form*>(pControlCore);
1871 pControlCore = pControlCore->GetParent();
1874 return pControlCore;
1878 _SearchBar::GetSearchBarButton(void) const
1880 return __pCancelButton;
1884 _SearchBar::GetSearchField(void)
1890 _SearchBar::GetSearchBarContainer(void) const
1892 return __pContainer;
1896 _SearchBar::GetClippedGroupControl(void) const
1898 return __pClippedGroupControl;
1902 _SearchBar::IsUsableCancelButton(void) const
1904 return __isUsableCancelButton;
1908 _SearchBar::ConvertSearchBarStatus(SearchFieldStatus status)
1910 EditStatus editStatus = EDIT_STATUS_NORMAL;
1913 case SEARCH_FIELD_STATUS_NORMAL:
1914 editStatus = EDIT_STATUS_NORMAL;
1917 case SEARCH_FIELD_STATUS_DISABLED:
1918 editStatus = EDIT_STATUS_DISABLED;
1921 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1922 editStatus = EDIT_STATUS_HIGHLIGHTED;
1932 _SearchBar::ConvertSearchBarButtonStatus(SearchBarButtonStatus status)
1934 _ButtonStatus buttonStatus = _BUTTON_STATUS_NORMAL;
1938 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
1939 buttonStatus = _BUTTON_STATUS_NORMAL;
1942 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
1943 buttonStatus = _BUTTON_STATUS_PRESSED;
1946 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
1947 buttonStatus = _BUTTON_STATUS_HIGHLIGHTED;
1950 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
1951 buttonStatus = _BUTTON_STATUS_DISABLED;
1957 return buttonStatus;
1961 _SearchBar::SendSearchBarEvent(_SearchBarEventStatus status)
1963 result r = E_SUCCESS;
1964 if (__pSearchBarEvent)
1966 IEventArg* pEventArg = _SearchBarEvent::CreateSearchBarEventArgN(status);
1967 r = GetLastResult();
1968 SysTryReturn(NID_UI_CTRL, pEventArg, r, r, "[%s] Propagating.", GetErrorMessage(r));
1970 if (IsContentAreaVisible() == false)
1972 SetContentAreaVisible(false);
1975 __pSearchBarEvent->Fire(*pEventArg);
1982 _SearchBar::SetHeaderVisibleState(bool visible)
1984 if (__pSearchBarPresenter != null)
1986 __pSearchBarPresenter->SetHeaderVisibleState(visible);
1992 _SearchBar::SetPropertyButtonActionId(const Variant& actionId)
1994 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1995 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1996 SysTryReturn(NID_UI_CTRL, actionId.ToInt() > -1, E_INVALID_ARG, E_INVALID_ARG,
1997 "[E_INVALID_ARG] Invalid argument(s) is used. actionId.ToInt() = %d", actionId.ToInt());
1999 result r = E_SUCCESS;
2001 r = __pCancelButton->SetPropertyActionId(actionId);
2002 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2003 "[%s] A system error has occurred. Failed to set actionId.", GetErrorMessage(E_SYSTEM));
2005 __actionId = actionId.ToInt();
2011 _SearchBar::GetPropertyButtonActionId(void) const
2013 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(-1), E_SYSTEM,
2014 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2016 return Variant(__actionId);
2020 _SearchBar::SetPropertyButtonDisabledColor(const Variant& color)
2022 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2023 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2025 result r = E_SUCCESS;
2027 r = __pCancelButton->SetPropertyDisabledColor(color);
2028 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2029 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2031 __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = color.ToColor();
2037 _SearchBar::GetPropertyButtonDisabledColor(void) const
2039 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2040 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2042 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2046 _SearchBar::SetPropertyButtonHighlightedColor(const Variant& color)
2048 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2049 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2051 result r = E_SUCCESS;
2053 r = __pCancelButton->SetPropertyHighlightedColor(color);
2054 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2055 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2057 __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
2063 _SearchBar::GetPropertyButtonHighlightedColor(void) const
2065 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2066 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2068 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2072 _SearchBar::SetPropertyButtonNormalColor(const Variant& color)
2074 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2075 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2077 result r = E_SUCCESS;
2079 r = __pCancelButton->SetPropertyNormalColor(color);
2080 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2081 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2083 __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = color.ToColor();
2089 _SearchBar::GetPropertyButtonNormalColor(void) const
2091 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2092 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2094 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2098 _SearchBar::SetPropertyButtonPressedColor(const Variant& color)
2100 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2101 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2103 result r = E_SUCCESS;
2105 r = __pCancelButton->SetPropertyPressedColor(color);
2106 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2107 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2109 __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = color.ToColor();
2115 _SearchBar::GetPropertyButtonPressedColor(void) const
2117 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2118 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2120 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2124 _SearchBar::SetPropertyButtonDisabledTextColor(const Variant& textColor)
2126 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2127 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2129 result r = E_SUCCESS;
2131 r = __pCancelButton->SetPropertyDisabledTextColor(textColor);
2132 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2133 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2135 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = textColor.ToColor();
2141 _SearchBar::GetPropertyButtonDisabledTextColor(void) const
2143 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2144 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2146 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2150 _SearchBar::SetPropertyButtonHighlightedTextColor(const Variant& textColor)
2152 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2153 "[E_SYSTEM]] A system error has occurred. The cancel button instance is null.");
2155 result r = E_SUCCESS;
2157 r = __pCancelButton->SetPropertyHighlightedTextColor(textColor);
2158 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2159 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2161 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = textColor.ToColor();
2167 _SearchBar::GetPropertyButtonHighlightedTextColor(void) const
2169 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2170 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2172 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2176 _SearchBar::SetPropertyButtonNormalTextColor(const Variant& textColor)
2178 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2179 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2181 result r = E_SUCCESS;
2183 r = __pCancelButton->SetPropertyNormalTextColor(textColor);
2184 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2185 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2187 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = textColor.ToColor();
2193 _SearchBar::GetPropertyButtonNormalTextColor(void) const
2195 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2196 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2198 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2202 _SearchBar::SetPropertyButtonPressedTextColor(const Variant& textColor)
2204 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2205 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2207 result r = E_SUCCESS;
2209 r = __pCancelButton->SetPropertyPressedTextColor(textColor);
2210 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2211 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2213 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = textColor.ToColor();
2219 _SearchBar::GetPropertyButtonPressedTextColor(void) const
2221 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2222 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2224 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2228 _SearchBar::SetPropertySearchFieldDisabledColor(const Variant& color)
2230 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2231 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2233 result r = E_SUCCESS;
2235 r = __pEdit->SetPropertyDisabledColor(color);
2236 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2237 "[E_SYSTEM] A system error has occurred. Failed to set the edit disabled color.");
2239 __color[SEARCH_FIELD_STATUS_DISABLED] = color.ToColor();
2245 _SearchBar::GetPropertySearchFieldDisabledColor(void) const
2247 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2248 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2250 return Variant(__color[SEARCH_FIELD_STATUS_DISABLED]);
2254 _SearchBar::SetPropertySearchFieldHighlightedColor(const Variant& color)
2256 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2257 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2259 result r = E_SUCCESS;
2261 r = __pEdit->SetPropertyHighlightedColor(color);
2262 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2263 "[E_SYSTEM] A system error has occurred. Failed to set the edit highlighted color.");
2265 __color[SEARCH_FIELD_STATUS_HIGHLIGHTED] = color.ToColor();
2271 _SearchBar::GetPropertySearchFieldHighlightedColor(void) const
2273 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2274 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2276 return Variant(__color[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2280 _SearchBar::SetPropertySearchFieldNormalColor(const Variant& color)
2282 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2283 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2285 result r = E_SUCCESS;
2287 r = __pEdit->SetPropertyNormalColor(color);
2288 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2289 "[E_SYSTEM] A system error has occurred. Failed to set edit normal color.");
2291 __color[SEARCH_FIELD_STATUS_NORMAL] = color.ToColor();
2297 _SearchBar::GetPropertySearchFieldNormalColor(void) const
2299 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2300 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2302 return Variant(__color[SEARCH_FIELD_STATUS_NORMAL]);
2306 _SearchBar::SetPropertySearchFieldDisabledTextColor(const Variant& textColor)
2308 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2309 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2311 result r = E_SUCCESS;
2313 r = __pEdit->SetPropertyDisabledTextColor(textColor);
2314 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2315 "[E_SYSTEM] A system error has occurred. Failed to set edit disabled text color.");
2317 __textColor[SEARCH_FIELD_STATUS_DISABLED] = textColor.ToColor();
2323 _SearchBar::GetPropertySearchFieldDisabledTextColor(void) const
2325 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2326 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2328 return Variant(__textColor[SEARCH_FIELD_STATUS_DISABLED]);
2332 _SearchBar::SetPropertySearchFieldHighlightedTextColor(const Variant& textColor)
2334 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2335 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2337 result r = E_SUCCESS;
2339 r = __pEdit->SetPropertyHighlightedTextColor(textColor);
2340 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2341 "[E_SYSTEM] A system error has occurred. Failed to set edit highlighted text color.");
2343 __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED] = textColor.ToColor();
2349 _SearchBar::GetPropertySearchFieldHighlightedTextColor(void) const
2351 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2352 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2354 return Variant(__textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2358 _SearchBar::SetPropertySearchFieldNormalTextColor(const Variant& textColor)
2360 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2361 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2363 result r = E_SUCCESS;
2365 r = __pEdit->SetPropertyNormalTextColor(textColor);
2366 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2367 "[E_SYSTEM] A system error has occurred. Failed to set edit normal text color.");
2369 __textColor[SEARCH_FIELD_STATUS_NORMAL] = textColor.ToColor();
2375 _SearchBar::GetPropertySearchFieldNormalTextColor(void) const
2377 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2378 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2380 return Variant(__textColor[SEARCH_FIELD_STATUS_NORMAL]);
2384 _SearchBar::SetPropertyColor(const Variant& color)
2386 __backgroundColor = color.ToColor();
2392 _SearchBar::GetPropertyColor(void) const
2394 return Variant(__backgroundColor);
2398 _SearchBar::SetPropertyContentAreaSize(const Variant& size)
2400 FloatDimension contentAreaSize = size.ToFloatDimension();
2401 SysTryReturn(NID_UI_CTRL, contentAreaSize.width >= 0 && contentAreaSize.height >= 0, E_INVALID_ARG, E_INVALID_ARG,
2402 "[E_INVALID_ARG] Invalid argument(s) is used. contentAreaSize.width = %f, contenAreaSize.height = %f",
2403 contentAreaSize.width, contentAreaSize.height);
2405 result r = E_SUCCESS;
2408 FloatRectangle bounds = GetBoundsF();
2409 FloatRectangle contentAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
2411 contentAreaBounds.x = 0.0f;
2412 contentAreaBounds.y = bounds.height;
2413 contentAreaBounds.width = contentAreaSize.width;
2414 contentAreaBounds.height = contentAreaSize.height;
2416 __contentAreaBounds = contentAreaBounds;
2417 __isUserContainerBounds = true;
2422 r = __pContainer->SetBounds(__contentAreaBounds);
2423 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2430 _SearchBar::GetPropertyContentAreaSize(void) const
2432 FloatDimension contentAreaSize(__contentAreaBounds.width, __contentAreaBounds.height);
2434 return Variant(contentAreaSize);
2438 _SearchBar::CreateClippedGroupControl(void)
2440 result r = E_SUCCESS;
2441 FloatRectangle clippedGroupControlBounds(FloatPoint(0.0f, 0.0f), GetSizeF());
2442 __pClippedGroupControl = _Control::CreateControlN();
2443 r = GetLastResult();
2444 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2446 r = AttachChild(*__pClippedGroupControl);
2447 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
2448 "[E_SYSTEM] A system error has occurred. Failed to attach the parent of clipped control.");
2450 r = __pClippedGroupControl->SetBounds(clippedGroupControlBounds);
2451 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2453 __pClippedGroupControl->SetBackgroundColor(Color(0));
2455 __pClippedGroupControl->SetClipChildrenEnabled(true);
2460 delete __pClippedGroupControl;
2461 __pClippedGroupControl = null;
2468 _SearchBar::SetContentDimming(void)
2470 if (__pContainer != NULL)
2472 if (!GetTextLength())
2474 __contentColor.SetAlpha(_SEARCH_CONTENT_DIM_OPACITY);
2478 __contentColor.SetAlpha(0);
2480 __pContainer->SetBackgroundColor(__contentColor);
2486 _SearchBar::IsContentAttachable(const _Control* pContent)
2488 const _Window* pWindow = dynamic_cast <const _Window*>(pContent);
2489 const _ColorPicker* pColorPicker = dynamic_cast <const _ColorPicker*>(pContent);
2490 const _Form* pForm = dynamic_cast <const _Form*>(pContent);
2491 const _Keypad* pKeypad = dynamic_cast <const _Keypad*>(pContent);
2492 const _OverlayPanel* pOverlayPanel = dynamic_cast <const _OverlayPanel*>(pContent);
2494 bool isContentAttachable = true;
2496 isContentAttachable = ((pWindow == null) && (pColorPicker == null) &&
2497 (pForm == null) && (pKeypad == null) && (pOverlayPanel == null));
2498 return isContentAttachable;
2502 _SearchBar::ResizeCancelButton(void)
2504 result r = E_SUCCESS;
2506 float horizontalMargin = 0.0f;
2507 float buttonLeftMargin = 0.0f;
2508 float buttonRightMargin = 0.0f;
2509 float buttonMinWidth = 0.0f;
2510 float searchFieldMinWidth = 0.0f;
2511 float buttonVerticalMargin = 0.0f;
2512 float searchBarMinHeight = 0.0f;
2513 float buttonWidth = 0.0f;
2514 float buttonHeight = 0.0f;
2516 FloatRectangle cancelButtonBounds;
2517 FloatRectangle searchBarBounds = GetBoundsF();
2519 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2521 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2522 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2523 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2524 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2525 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2526 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2527 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2528 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2529 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2531 cancelButtonBounds.width = buttonWidth;
2532 cancelButtonBounds.height = buttonHeight;
2534 float buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth +
2535 cancelButtonBounds.width + buttonLeftMargin + buttonRightMargin);
2537 if (searchBarBounds.width < buttonResizableSearchBarWidth)
2539 cancelButtonBounds.width = searchBarBounds.width -(searchFieldMinWidth + buttonLeftMargin
2540 + buttonRightMargin + horizontalMargin);
2543 cancelButtonBounds.x = searchBarBounds.width - cancelButtonBounds.width - buttonRightMargin;
2544 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2546 cancelButtonBounds.y = cancelButtonBounds.y < 0.0f ? 0.0f:cancelButtonBounds.y;
2548 if (cancelButtonBounds.width < buttonMinWidth)
2550 cancelButtonBounds.width = buttonMinWidth;
2553 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2554 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2555 r = __pCancelButton->SetBounds(cancelButtonBounds);
2561 _SearchBar::RecalculateButtonBounds(void)
2563 result r = E_SUCCESS;
2565 float horizontalMargin = 0.0f;
2566 float verticalMargin = 0.0f;
2567 float buttonLeftMargin = 0.0f;
2568 float buttonRightMargin = 0.0f;
2569 float buttonMinWidth = 0.0f;
2570 float searchFieldMinWidth = 0.0f;
2571 float buttonVerticalMargin = 0.0f;
2572 float searchBarMinHeight = 0.0f;
2573 float buttonWidth = 0.0f;
2574 float buttonHeight = 0.0f;
2575 float cancelButtonWidth = 0.0f;
2577 FloatRectangle cancelButtonBounds;
2578 FloatRectangle editBounds;
2579 FloatRectangle searchBarBounds = GetBoundsF();
2581 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2583 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2584 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin);
2585 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2586 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2587 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2588 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2589 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2590 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2591 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2592 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2594 cancelButtonBounds.height = buttonHeight;
2596 float searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2.0f);
2597 cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightTouchMarginF() + __pCancelButton->GetLeftTouchMarginF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF();
2598 editBounds.x = horizontalMargin;
2600 if (searchBarBounds.height < searchBarMinHeight)
2602 verticalMargin = (searchBarBounds.height - searchFieldMinHeight)/2.0f;
2603 if (verticalMargin < 0.0f)
2605 verticalMargin = 0.0f;
2609 editBounds.y = verticalMargin;
2610 editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
2612 editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
2614 editBounds.width = searchBarBounds.width - cancelButtonWidth - horizontalMargin - buttonLeftMargin - buttonRightMargin;
2616 if (editBounds.width < searchFieldMinWidth)
2618 editBounds.width = searchFieldMinWidth;
2621 cancelButtonBounds.x = editBounds.width + horizontalMargin + buttonLeftMargin;
2622 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2624 cancelButtonBounds.y = cancelButtonBounds.y < 0.0f ? 0.0f:cancelButtonBounds.y;
2626 float remainingWidth = searchBarBounds.width - editBounds.width - horizontalMargin - buttonLeftMargin - buttonRightMargin;
2628 if (remainingWidth < buttonMinWidth)
2630 cancelButtonBounds.width = buttonMinWidth;
2634 cancelButtonBounds.width = searchBarBounds.width - cancelButtonBounds.x - buttonRightMargin;
2637 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2638 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2640 r = __pCancelButton->SetBounds(cancelButtonBounds);
2641 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2642 r = __pEdit->SetBounds(editBounds);
2643 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2649 _SearchBar::GetCurrentStatus(void)
2651 SearchFieldStatus searchFieldStatus = SEARCH_FIELD_STATUS_NORMAL;
2655 if (__pEdit->IsFocused())
2657 searchFieldStatus = SEARCH_FIELD_STATUS_HIGHLIGHTED;
2662 searchFieldStatus = SEARCH_FIELD_STATUS_DISABLED;
2665 return searchFieldStatus;
2669 _SearchBar::SetEditTextFilter(IEditTextFilter* pFilter)
2671 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2672 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2674 __pEdit->SetEditTextFilter(pFilter);
2680 _SearchBar::SendOpaqueCommand(const String& command)
2682 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2683 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2685 __pEdit->SendOpaqueCommand(command);
2690 }}} // Tizen::Ui::Controls