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)
82 , __pAccessibilitySearchBarElement(null)
84 for (int i = 0; i < SEARCHBAR_BUTTON_COLOR_MAX; i++)
86 __buttonColor[i] = Color(0);
87 __buttonTextColor[i] = Color(0);
90 for (int i = 0; i < SEARCHBAR_COLOR_MAX; i++)
92 __color[i] = Color(0);
93 __textColor[i] = Color(0);
94 __guideTextColor[i] = Color(0);
97 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
100 pContainer->Activate(true);
104 _SearchBar::~_SearchBar(void)
107 delete __pSearchBarPresenter;
108 __pSearchBarPresenter = null;
112 __pEdit->HideKeypad();
114 __pClippedGroupControl->DetachChild(*__pEdit);
122 __pClippedGroupControl->DetachChild(*__pCancelButton);
124 delete __pCancelButton;
125 __pCancelButton = null;
128 if (__pClippedGroupControl)
130 DetachChild(*__pClippedGroupControl);
132 delete __pClippedGroupControl;
133 __pClippedGroupControl = null;
138 DetachChild(*__pContainer);
146 delete __pActionEvent;
147 __pActionEvent = null;
152 delete __pKeypadEvent;
153 __pKeypadEvent = null;
156 if (__pTextBlockEvent)
158 delete __pTextBlockEvent;
159 __pTextBlockEvent = null;
168 if (__pSearchBarEvent)
170 delete __pSearchBarEvent;
171 __pSearchBarEvent = null;
174 if (__pAccessibilitySearchBarElement)
176 __pAccessibilitySearchBarElement->Activate(false);
177 __pAccessibilitySearchBarElement = null;
180 delete __pBackgroundBitmap;
181 __pBackgroundBitmap = null;
185 _SearchBar::CreateSearchBarN(void)
187 _SearchBar* pSearchBar = new (std::nothrow) _SearchBar;
188 SysTryReturn(NID_UI_CTRL, pSearchBar, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
189 if (GetLastResult() != E_SUCCESS)
195 pSearchBar->AcquireHandle();
196 pSearchBar->SetTouchPressThreshold(_TOUCH_PRESS_THRESHOLD_INSENSITIVE);
202 _SearchBar::Initialize(bool enableSearchBarButton, CoreKeypadAction keypadAction)
204 result r = E_SUCCESS;
206 // Setting Button color
207 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_NORMAL, __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
208 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_PRESSED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
209 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_HIGHLIGHTED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
210 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_DISABLED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
212 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_NORMAL, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
213 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_PRESSED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
214 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_HIGHLIGHTED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
215 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_DISABLED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
217 GET_COLOR_CONFIG(SEARCHBAR::CONTENT_AREA_BG_NORMAL, __contentColor);
219 for (int i = 0; i < SEARCHBAR_COLOR_MAX; i++)
223 case SEARCH_FIELD_STATUS_DISABLED:
224 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_DISABLED, __color[i]);
225 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_DISABLED, __textColor[i]);
226 GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_DISABLED, __guideTextColor[i]);
229 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
230 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]);
231 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_HIGHLIGHTED, __textColor[i]);
232 GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_HIGHLIGHTED, __guideTextColor[i]);
235 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]);
236 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_NORMAL, __textColor[i]);
237 GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_NORMAL, __guideTextColor[i]);
242 __isUsableCancelButton = enableSearchBarButton;
243 __keypadAction = keypadAction;
245 GetVisualElement()->SetClipChildrenEnabled(false);
247 r = CreateClippedGroupControl();
248 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
249 "[E_SYSTEM] A system error has occurred. The construction of parent control for clipped group control failed.");
251 r = CreateSearchField();
252 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
253 "[E_SYSTEM] A system error has occurred. The edit construction failed.");
254 r = CreateCancelButton();
255 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
256 "[E_SYSTEM] A system error has occurred. The cancel button construction failed.");
259 r = CreateContentsArea();
260 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
261 "[E_SYSTEM] A system error has occurred. The construction of parent for content failed.");
263 _SearchBarPresenter* pPresenter = new (std::nothrow) _SearchBarPresenter;
264 SysTryReturn(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
266 r = pPresenter->Construct(*this);
267 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
269 r = pPresenter->Install();
270 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
272 __pSearchBarPresenter = pPresenter;
274 CreateAccessibilityElement();
285 _SearchBar::CreateSearchField(void)
287 result r = E_SUCCESS;
289 FloatRectangle editBounds;
290 float horizontalMargin = 0.0f;
291 float verticalMargin = 0.0f;
292 float iconHorizontalMargin = 0.0f;
293 float textHorizontalMargin = 0.0f;
294 float iconWidth = 0.0f;
295 float textSize = 0.0f;
296 float searchBarMinHeight = 0.0f;
297 float searchBarMinWidthModeNormal = 0.0f;
299 FloatRectangle searchBarBounds = GetBoundsF();
300 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
302 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
303 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin);
304 GET_SHAPE_CONFIG(SEARCHBAR::ICON_HORIZONTAL_MARGIN, orientation, iconHorizontalMargin);
305 GET_SHAPE_CONFIG(SEARCHBAR::ICON_WIDTH, orientation, iconWidth);
306 GET_SHAPE_CONFIG(SEARCHBAR::TEXT_HORIZONTAL_MARGIN, orientation, textHorizontalMargin);
307 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH_NORMAL_MODE, orientation, searchBarMinWidthModeNormal);
308 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
310 float searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2.0f);
312 editBounds.x = horizontalMargin;
314 if (searchBarBounds.height < searchBarMinHeight)
316 verticalMargin = (searchBarBounds.height - searchFieldMinHeight)/2.0f;
317 if (verticalMargin < 0.0f)
319 verticalMargin = 0.0f;
323 editBounds.y = verticalMargin;
325 editBounds.width = searchBarBounds.width - (editBounds.x * 2.0f);
326 editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
328 editBounds.width = (editBounds.width > searchBarMinWidthModeNormal) ? editBounds.width : searchBarMinWidthModeNormal;
329 editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
331 __pEdit = _Edit::CreateEditN();
333 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
335 r = __pEdit->Initialize(EDIT_STYLE_NORMAL | EDIT_STYLE_SINGLE_LINE | EDIT_STYLE_CLEAR | EDIT_STYLE_NOSCROLL, INPUT_STYLE_OVERLAY,
336 SEARCHBAR_TEXT_LENGTH_MAX);
337 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
339 __pEdit->SetKeypadCommandButtonVisible(false);
340 __pEdit->SetBounds(editBounds);
341 __pEdit->AddKeypadEventListener(*this);
342 __pEdit->AddTextBlockEventListener(*this);
343 __pEdit->AddTextEventListener(*this);
345 GET_SHAPE_CONFIG(SEARCHBAR::EDIT_TEXT_SIZE, orientation, textSize);
346 __pEdit->SetTextSize(textSize);
348 __pEdit->SetHorizontalMargin(iconHorizontalMargin + iconWidth + textHorizontalMargin, EDIT_TEXT_LEFT_MARGIN);
349 __pEdit->SetHorizontalMargin(textHorizontalMargin, EDIT_TEXT_RIGHT_MARGIN);
350 __pEdit->SetLimitLength(SEARCHBAR_TEXT_LENGTH_MAX);
352 for (int status = 0; status < SEARCHBAR_COLOR_MAX; status++)
354 EditStatus editStatus = ConvertSearchBarStatus((SearchFieldStatus) status);
355 __pEdit->SetColor(editStatus, __color[status]);
358 __pEdit->SetTextColor(EDIT_TEXT_COLOR_NORMAL, __textColor[SEARCH_FIELD_STATUS_NORMAL]);
359 __pEdit->SetTextColor(EDIT_TEXT_COLOR_DISABLED, __textColor[SEARCH_FIELD_STATUS_DISABLED]);
360 __pEdit->SetTextColor(EDIT_TEXT_COLOR_HIGHLIGHTED, __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
362 __pEdit->ReplaceDefaultBackgroundBitmapForSearchBar();
364 __pEdit->SetKeypadAction(__keypadAction);
366 r = __pClippedGroupControl->AttachChild(*__pEdit);
367 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
368 "[E_SYSTEM] A system error has occurred. Failed to attach edit as child.");
380 _SearchBar::CreateCancelButton(void)
382 result r = E_SUCCESS;
384 float textSize = 0.0f;
385 String cancelButtonText;
387 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
389 __pCancelButton = _Button::CreateButtonN();
391 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
393 r = ResizeCancelButton();
394 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
396 GET_STRING_CONFIG(IDS_COM_SK_CANCEL, cancelButtonText);
397 r = __pCancelButton->SetText(cancelButtonText);
398 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
400 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_TEXT_SIZE, orientation, textSize);
401 r = __pCancelButton->SetTextSize(textSize);
402 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
404 __pCancelButton->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
405 __pCancelButton->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
407 r = __pCancelButton->SetActionId(__actionId);
408 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
410 r = __pCancelButton->AddActionEventListener(*this);
411 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
413 __pCancelButton->SetVisibleState(false);
415 for (int status = 0; status < SEARCHBAR_BUTTON_COLOR_MAX; status++)
417 _ButtonStatus buttonStatus = ConvertSearchBarButtonStatus((SearchBarButtonStatus) status);
419 r = __pCancelButton->SetColor(buttonStatus, __buttonColor[status]);
420 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
422 r = __pCancelButton->SetTextColor(buttonStatus, __buttonTextColor[status]);
423 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
426 r = __pClippedGroupControl->AttachChild(*__pCancelButton);
427 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
428 "[E_SYSTEM] A system error has occurred. Failed to attach button as child.");
433 delete __pCancelButton;
434 __pCancelButton = null;
440 _SearchBar::CreateContentsArea(void)
442 result r = E_SUCCESS;
444 __pContainer = _Control::CreateControlN();
447 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
449 __pContainer->SetVisibleState(false);
451 r = AttachChild(*__pContainer);
452 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
453 "[E_SYSTEM] A system error has occurred. Failed to attach the parent of content.");
465 _SearchBar::SetContentsArea(void)
467 if (__isUserContainerBounds)
472 FloatDimension screenSize = _ControlManager::GetInstance()->GetScreenSizeF();
473 float width = screenSize.width;
474 float height = screenSize.height;
476 _Control* pParent = GetParentForm();
479 width = pParent->GetClientBoundsF().width;
480 height = pParent->GetClientBoundsF().height;
483 FloatRectangle controlBounds = GetBoundsF();
484 controlBounds = CoordinateSystem::AlignToDevice(FloatRectangle(controlBounds));
486 __contentAreaBounds.x = 0.0f;
487 __contentAreaBounds.y = controlBounds.height;
488 __contentAreaBounds.width = width - controlBounds.x;
489 __contentAreaBounds.height = height - (controlBounds.y + controlBounds.height);
493 result r = E_SUCCESS;
494 r = __pContainer->SetBounds(__contentAreaBounds);
495 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
501 _SearchBar::GetContent(void) const
503 return __pContentControl;
507 _SearchBar::SetContent(const _Control* pContent)
509 __pContentControl = const_cast <_Control*>(pContent);
510 result r = E_SUCCESS;
514 r = __pContainer->AttachChild(*__pContentControl);
515 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating");
522 _SearchBar::UpdateContentArea(bool invalidate)
524 return __pSearchBarPresenter->UpdateContentArea(invalidate);
528 _SearchBar::SetContentAreaVisible(bool visible)
530 SysTryReturn(NID_UI_CTRL, __pContainer, E_SYSTEM, E_SYSTEM,
531 "[E_SYSTEM] A system error has occurred. The instance of parent to content is null.");
533 SearchBarMode searchBarMode = GetMode();
534 if (searchBarMode == SEARCH_BAR_MODE_INPUT)
536 __pContainer->SetVisibleState(visible);
539 return __pSearchBarPresenter->SetContentAreaVisible(visible);
543 _SearchBar::IsContentAreaVisible(void) const
545 return __pSearchBarPresenter->IsContentAreaVisible();
549 _SearchBar::SetContentAreaSize(const Dimension& size)
551 return SetProperty("contentAreaSize", Variant(size));
555 _SearchBar::GetContentAreaSize(void) const
557 Variant size = GetProperty("contentAreaSize");
559 return size.ToDimension();
563 _SearchBar::GetMode(void) const
565 return __pSearchBarPresenter->GetMode();
569 _SearchBar::IsModeLocked(void) const
571 return __pSearchBarPresenter->IsModeLocked();
575 _SearchBar::SetMode(SearchBarMode mode)
577 return __pSearchBarPresenter->SetMode(mode);
581 _SearchBar::SetModeLocked(bool modeLocked)
583 return __pSearchBarPresenter->SetModeLocked(modeLocked);
587 _SearchBar::GetButtonActionId(void) const
589 Variant actionId = GetProperty("buttonActionId");
591 return actionId.ToInt();
595 _SearchBar::GetButtonColor(SearchBarButtonStatus status) const
601 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
602 buttonColor = GetProperty("buttonNormalColor");
604 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
605 buttonColor = GetProperty("buttonPressedColor");
607 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
608 buttonColor = GetProperty("buttonHighlightedColor");
610 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
611 buttonColor = GetProperty("buttonDisabledColor");
617 return buttonColor.ToColor();
621 _SearchBar::GetButtonTextColor(SearchBarButtonStatus status) const
623 Variant buttonTextColor;
627 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
628 buttonTextColor = GetProperty("buttonNormalTextColor");
630 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
631 buttonTextColor = GetProperty("buttonPressedTextColor");
633 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
634 buttonTextColor = GetProperty("buttonHighlightedTextColor");
636 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
637 buttonTextColor = GetProperty("buttonDisabledTextColor");
643 return buttonTextColor.ToColor();
646 SearchBarButtonStatus
647 _SearchBar::GetButtonStatus(void) const
649 SysTryReturn(NID_UI_CTRL, __pCancelButton, SEARCH_BAR_BUTTON_STATUS_NORMAL, E_SYSTEM,
650 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
652 SearchBarButtonStatus buttonStatus = SEARCH_BAR_BUTTON_STATUS_NORMAL;
654 if (__isButtonEnabled == false)
656 buttonStatus = SEARCH_BAR_BUTTON_STATUS_DISABLED;
663 _SearchBar::SetButtonText(const String& text)
665 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
666 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
668 result r = E_SUCCESS;
670 r = __pCancelButton->SetText(text);
671 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
672 "[E_SYSTEM] A system error has occurred. Failed to set text.");
678 _SearchBar::SetButtonActionId(int actionId)
680 return SetProperty("buttonActionId", Variant(actionId));
684 _SearchBar::SetButtonEnabled(bool enabled)
686 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
687 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
689 __pCancelButton->SetEnableState(enabled);
691 __isButtonEnabled = enabled;
697 _SearchBar::SetButtonColor(SearchBarButtonStatus status, const Color& color)
699 result r = E_SUCCESS;
703 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
704 r = SetProperty("buttonNormalColor", Variant(color));
706 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
707 r = SetProperty("buttonPressedColor", Variant(color));
709 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
710 r = SetProperty("buttonHighlightedColor", Variant(color));
712 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
713 r = SetProperty("buttonDisabledColor", Variant(color));
723 _SearchBar::SetButtonTextColor(SearchBarButtonStatus status, const Color& color)
725 result r = E_SUCCESS;
729 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
730 r = SetProperty("buttonNormalTextColor", Variant(color));
732 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
733 r = SetProperty("buttonPressedTextColor", Variant(color));
735 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
736 r = SetProperty("buttonHighlightedTextColor", Variant(color));
738 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
739 r = SetProperty("buttonDisabledTextColor", Variant(color));
749 _SearchBar::AppendCharacter(const Character& character)
751 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
752 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
753 SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM,
754 "[E_SYSTEM] A system error has occurred. The character is null.");
756 result r = E_SUCCESS;
758 r = __pEdit->AppendCharacter(character);
759 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
760 "[E_SYSTEM] A system error has occurred. Failed to set character.");
766 _SearchBar::AppendText(const String& text)
768 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
769 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
770 SysTryReturn(NID_UI_CTRL, text.IsEmpty() == false, E_SYSTEM, E_SYSTEM,
771 "[E_SYSTEM] A system error has occurred. The text is empty.");
773 result r = E_SUCCESS;
775 r = __pEdit->AppendText(text);
776 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
777 "[E_SYSTEM] A system error has occurred. Failed to set text.");
783 _SearchBar::SetText(const String& text)
785 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
786 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
788 result r = E_SUCCESS;
790 int limitLength = __pEdit->GetTextLimitLength();
791 int textLength = text.GetLength();
792 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_SYSTEM, E_SYSTEM,
793 "[E_SYSTEM] A system error has occurred. textLength exceeds the limitLength");
795 r = __pEdit->SetText(text);
796 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
797 "[E_SYSTEM] A system error has occurred. Failed to set text.");
803 _SearchBar::InsertCharacterAt(int index, const Character& character)
805 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
806 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
807 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
808 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
809 SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM,
810 "[E_SYSTEM] A system error has occurred. The character is null.");
812 result r = E_SUCCESS;
816 limitLength = __pEdit->GetTextLimitLength();
817 textLength = __pEdit->GetTextLength() + 1;
819 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
820 "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
822 SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
823 "[E_OUT_OF_RANGE] index(%d) is out of range of current textLength(%d).", index, __pEdit->GetTextLength());
825 r = __pEdit->InsertCharacterAt(index, character);
826 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
827 "[E_SYSTEM] A system error has occurred. Failed to set text.");
833 _SearchBar::InsertTextAt(int index, const String& text)
835 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
836 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
837 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
838 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
840 result r = E_SUCCESS;
844 limitLength = __pEdit->GetTextLimitLength();
845 textLength = __pEdit->GetTextLength() + text.GetLength();
847 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
848 "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
849 SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
850 "[E_OUT_OF_RANGE] index(%d) is out of range of current textLength(%d).", index, __pEdit->GetTextLength());
852 r = __pEdit->InsertTextAt(index, text);
853 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
854 "[E_SYSTEM] A system error has occurred. Failed to insert text.");
860 _SearchBar::DeleteCharacterAt(int index)
862 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
863 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
864 SysTryReturn(NID_UI_CTRL, index > -1, E_INVALID_ARG, E_INVALID_ARG,
865 "[E_INVALID_ARG] Invalid argument(s) is used. index = %d", index);
867 result r = E_SUCCESS;
869 textLength = __pEdit->GetTextLength();
871 SysTryReturn(NID_UI_CTRL, textLength > index, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
872 "[E_OUT_OF_RANGE] index(%d) is out of range. textLength(%d)", index, textLength);
874 r = __pEdit->DeleteCharacterAt(index);
875 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM,
876 "[E_SYSTEM] A system error has occured. Failed to delete character.");
882 _SearchBar::Clear(void)
884 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
885 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
887 return __pEdit->ClearText();
891 _SearchBar::GetTextLength(void) const
893 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
894 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
896 return __pEdit->GetTextLength();
900 _SearchBar::GetText(void) const
902 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
903 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
905 return __pEdit->GetText();
909 _SearchBar::GetText(int start, int end) const
911 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
912 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
914 return __pEdit->GetText(start, end);
918 _SearchBar::GetLimitLength(void) const
920 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
921 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
923 return __pEdit->GetTextLimitLength();
927 _SearchBar::SetLimitLength(int limitLength)
929 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
930 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
931 SysTryReturn(NID_UI_CTRL, limitLength > 0, E_INVALID_ARG, E_INVALID_ARG,
932 "[E_INVALID_ARG] Invalid argument(s) is used.limitLength = %d", limitLength);
934 String tempString = GetText();
936 int textLength = tempString.GetLength();
937 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_INVALID_ARG, E_INVALID_ARG,
938 "[E_INVALID_ARG] Invalid argument(s) is used. limitLength = %d, textLength = %d", limitLength, textLength);
940 result r = __pEdit->SetLimitLength(limitLength);
941 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
943 r = SetText(tempString);
944 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
950 _SearchBar::ShowKeypad(void) const
952 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
953 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
955 SearchBarMode mode = __pSearchBarPresenter->GetMode();
956 SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_INVALID_STATE, E_INVALID_STATE,
957 "[E_INVALID_STATE] The SearchBar is currently in Normal mode.");
958 return __pEdit->ShowKeypad();
962 _SearchBar::HideKeypad(void)
964 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
965 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
967 SearchBarMode mode = __pSearchBarPresenter->GetMode();
968 SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_SYSTEM, E_SYSTEM,
969 "[E_SYSTEM] A system error has occurred. The SearchBar is currently in Normal mode.");
971 result r = __pEdit->HideKeypad();
979 _SearchBar::GetSearchFieldTextSizeF(void) const
981 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
982 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
984 return __pEdit->GetTextSizeF();
988 _SearchBar::SetSearchFieldTextSize(float size)
990 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
991 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
993 return __pEdit->SetTextSize(size);
997 _SearchBar::GetBlockRange(int& start, int& end) const
999 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1000 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1002 int startIndex = -1;
1005 __pEdit->GetBlockRange(startIndex, endIndex);
1006 SysTryReturn(NID_UI_CTRL, (startIndex > -1 && endIndex > 0), E_SYSTEM, E_SYSTEM,
1007 "[E_SYSTEM] A system error has occurred. Failed to get text block range.");
1016 _SearchBar::ReleaseBlock(void)
1018 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1019 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1021 result r = E_SUCCESS;
1026 r = GetBlockRange(start, end);
1027 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1029 return __pEdit->ReleaseTextBlock();
1033 _SearchBar::SetBlockRange(int start, int end)
1035 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1036 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1038 result r = E_SUCCESS;
1041 textLength = __pEdit->GetTextLength();
1043 SysTryReturn(NID_UI_CTRL, (start < end && start >= 0 && textLength >= end), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1044 "[E_OUT_OF_RANGE] start (%d) and end (%d) is out of range.", start, end - 1);
1046 r = SetCursorPosition(start);
1047 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1049 r = __pEdit->BeginTextBlock();
1050 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1051 "[E_SYSTEM] A system error has occurred. Failed to set text block range.");
1053 r = SetCursorPosition(end);
1054 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1055 "[E_SYSTEM] A system error has occurred. Failed to set cursor position.");
1061 _SearchBar::RemoveTextBlock(void)
1063 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1064 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1066 result r = E_SUCCESS;
1068 r = __pEdit->RemoveTextBlock();
1069 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1075 _SearchBar::GetColor(void) const
1077 Variant backgroundColor = GetProperty("color");
1079 return backgroundColor.ToColor();
1083 _SearchBar::GetSearchFieldColor(SearchFieldStatus status) const
1085 Variant searchFieldColor;
1089 case SEARCH_FIELD_STATUS_NORMAL:
1090 searchFieldColor = GetProperty("searchFieldNormalColor");
1092 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1093 searchFieldColor = GetProperty("searchFieldHighlightedColor");
1095 case SEARCH_FIELD_STATUS_DISABLED:
1096 searchFieldColor = GetProperty("searchFieldDisabledColor");
1102 return searchFieldColor.ToColor();
1107 _SearchBar::GetSearchFieldTextColor(SearchFieldStatus status) const
1109 Variant searchFieldTextColor;
1113 case SEARCH_FIELD_STATUS_NORMAL:
1114 searchFieldTextColor = GetProperty("searchFieldNormalTextColor");
1116 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1117 searchFieldTextColor = GetProperty("searchFieldHighlightedTextColor");
1119 case SEARCH_FIELD_STATUS_DISABLED:
1120 searchFieldTextColor = GetProperty("searchFieldDisabledTextColor");
1126 return searchFieldTextColor.ToColor();
1131 _SearchBar::SetBackgroundBitmap(const Bitmap& bitmap)
1133 Bitmap* pNewBitmap = _BitmapImpl::CloneN(bitmap);
1134 SysTryReturn(NID_UI_CTRL, pNewBitmap, E_SYSTEM, E_SYSTEM,
1135 "[E_SYSTEM] A system error has occurred. The creation of bitmap failed.");
1137 delete __pBackgroundBitmap;
1138 __pBackgroundBitmap = null;
1140 __pBackgroundBitmap = pNewBitmap;
1146 _SearchBar::GetBackgroundBitmap(void) const
1148 return __pBackgroundBitmap;
1152 _SearchBar::SetColor(const Color& color)
1154 return SetProperty("color", Variant(color));
1158 _SearchBar::SetSearchFieldColor(SearchFieldStatus status, const Color& color)
1160 result r = E_SUCCESS;
1164 case SEARCH_FIELD_STATUS_NORMAL:
1165 r = SetProperty("searchFieldNormalColor", Variant(color));
1167 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1168 r = SetProperty("searchFieldHighlightedColor", Variant(color));
1170 case SEARCH_FIELD_STATUS_DISABLED:
1171 r = SetProperty("searchFieldDisabledColor", Variant(color));
1182 _SearchBar::SetSearchFieldTextColor(SearchFieldStatus status, const Color& color)
1184 result r = E_SUCCESS;
1188 case SEARCH_FIELD_STATUS_NORMAL:
1189 r = SetProperty("searchFieldNormalTextColor", Variant(color));
1191 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1192 r = SetProperty("searchFieldHighlightedTextColor", Variant(color));
1194 case SEARCH_FIELD_STATUS_DISABLED:
1195 r = SetProperty("searchFieldDisabledTextColor", Variant(color));
1206 _SearchBar::GetGuideText(void) const
1208 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
1209 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1211 return __pEdit->GetGuideText();
1215 _SearchBar::SetGuideText(const String& guideText)
1217 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1218 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1220 __pEdit->SetGuideText(guideText);
1226 _SearchBar::GetGuideTextColor(void) const
1228 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1229 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1231 return __pEdit->GetGuideTextColor();
1235 _SearchBar::SetGuideTextColor(const Color& color)
1237 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1238 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1240 __isUserGuideTextColor = true;
1241 return __pEdit->SetGuideTextColor(color);
1245 _SearchBar::GetCursorPosition(void) const
1247 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
1248 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1250 return __pEdit->GetCursorPosition();
1254 _SearchBar::SetCursorPosition(int index)
1256 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1257 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1258 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1259 "[E_OUT_OF_RANGE] index(%d) is out of range.", GetErrorMessage(E_OUT_OF_RANGE), index);
1261 int textLength = -1;
1262 textLength = __pEdit->GetTextLength();
1264 SysTryReturn(NID_UI_CTRL, (index > -1 && index <= textLength), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1265 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
1267 return __pEdit->SetCursorPosition(index);
1271 _SearchBar::IsLowerCaseModeEnabled(void) const
1273 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1274 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1276 return __pEdit->IsLowerCaseModeEnabled();
1280 _SearchBar::SetLowerCaseModeEnabled(bool enable)
1282 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
1283 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1285 __pEdit->SetLowerCaseModeEnabled(enable);
1289 _SearchBar::GetEllipsisPosition(void) const
1291 SysTryReturn(NID_UI_CTRL, __pEdit, ELLIPSIS_POSITION_START, E_SYSTEM,
1292 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1294 return __pEdit->GetEllipsisPosition();
1298 _SearchBar::SetEllipsisPosition(EllipsisPosition position)
1300 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1301 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1302 __pEdit->SetEllipsisPosition(position);
1308 _SearchBar::GetKeypadAction(void) const
1310 return __keypadAction;
1314 _SearchBar::IsTextPredictionEnabled(void) const
1316 SysTryReturn(NID_UI_CTRL, __pEdit, false, E_SYSTEM,
1317 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1318 return __pEdit->IsTextPredictionEnabled();
1322 _SearchBar::SetTextPredictionEnabled(bool enable)
1324 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1325 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1326 return __pEdit->SetTextPredictionEnabled(enable);
1330 _SearchBar::SetCurrentLanguage(LanguageCode languageCode)
1332 return __pEdit->SetCurrentLanguage(languageCode);
1336 _SearchBar::GetCurrentLanguage(LanguageCode& language) const
1338 return __pEdit->GetCurrentLanguage(language);
1342 _SearchBar::AddActionEventListener(const _IActionEventListener& listener)
1344 result r = E_SUCCESS;
1346 if (__pActionEvent == null)
1348 __pActionEvent = _ActionEvent::CreateInstanceN(*this);
1349 r = GetLastResult();
1350 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1352 __pActionEvent->AddListener(listener);
1359 _SearchBar::RemoveActionEventListener(const _IActionEventListener& listener)
1361 SysTryReturn(NID_UI_CTRL, __pActionEvent, E_SYSTEM, E_SYSTEM,
1362 "[E_SYSTEM] A system error has occurred. The action event instance is null.");
1363 result r = E_SUCCESS;
1365 r = __pActionEvent->RemoveListener(listener);
1366 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1372 _SearchBar::AddKeypadEventListener(const _IKeypadEventListener& listener)
1374 result r = E_SUCCESS;
1376 if (__pKeypadEvent == null)
1378 __pKeypadEvent = _KeypadEvent::CreateInstanceN(*this);
1379 r = GetLastResult();
1380 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1382 r = __pKeypadEvent->AddListener(listener);
1383 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1390 _SearchBar::RemoveKeypadEventListener(const _IKeypadEventListener& listener)
1392 SysTryReturn(NID_UI_CTRL, __pKeypadEvent, E_SYSTEM, E_SYSTEM,
1393 "[E_SYSTEM] A system error has occurred. The keypad event instance is null.");
1394 result r = E_SUCCESS;
1396 r = __pKeypadEvent->RemoveListener(listener);
1397 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1403 _SearchBar::AddTextBlockEventListener(const _ITextBlockEventListener& listener)
1405 result r = E_SUCCESS;
1407 if (__pTextBlockEvent == null)
1409 __pTextBlockEvent = _TextBlockEvent::CreateInstanceN(*this);
1410 r = GetLastResult();
1411 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1413 r = __pTextBlockEvent->AddListener(listener);
1414 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1422 _SearchBar::RemoveTextBlockEventListener(const _ITextBlockEventListener& listener)
1424 SysTryReturn(NID_UI_CTRL, __pTextBlockEvent, E_SYSTEM, E_SYSTEM,
1425 "[E_SYSTEM] A system error has occurred. The text block event instance is null.");
1426 result r = E_SUCCESS;
1428 r = __pTextBlockEvent->RemoveListener(listener);
1429 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1436 _SearchBar::AddTextEventListener(const _ITextEventListener& listener)
1438 result r = E_SUCCESS;
1440 if (__pTextEvent == null)
1442 __pTextEvent = _TextEvent::CreateInstanceN(*this);
1443 r = GetLastResult();
1444 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1446 r = __pTextEvent->AddListener(listener);
1447 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1454 _SearchBar::RemoveTextEventListener(const _ITextEventListener& listener)
1456 SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM,
1457 "[E_SYSTEM] A system error has occurred. The text event instance is null.");
1458 result r = E_SUCCESS;
1460 r = __pTextEvent->RemoveListener(listener);
1461 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1467 _SearchBar::AddSearchBarEventListener(const _ISearchBarEventListener& listener)
1469 result r = E_SUCCESS;
1471 if (__pSearchBarEvent == null)
1473 __pSearchBarEvent = _SearchBarEvent::CreateInstanceN(*this);
1474 r = GetLastResult();
1475 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1477 r = __pSearchBarEvent->AddListener(listener);
1478 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1485 _SearchBar::RemoveSearchBarEventListener(const _ISearchBarEventListener& listener)
1487 SysTryReturn(NID_UI_CTRL, __pSearchBarEvent, E_SYSTEM, E_SYSTEM,
1488 "[E_SYSTEM] A system error has occurred. The searchbar event instance is null.");
1489 result r = E_SUCCESS;
1491 r = __pSearchBarEvent->RemoveListener(listener);
1492 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1498 _SearchBar::AddLanguageEventListener(const _ILanguageEventListener& listener)
1500 result r = E_SUCCESS;
1502 if (__pLanguageEvent == null)
1504 __pLanguageEvent = _LanguageEvent::CreateInstanceN(*this);
1505 r = GetLastResult();
1506 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1508 r = __pLanguageEvent->AddListener(listener);
1509 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1516 _SearchBar::RemoveLanguageEventListener(const _ILanguageEventListener& listener)
1518 SysTryReturn(NID_UI_CTRL, __pLanguageEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.");
1519 result r = E_SUCCESS;
1521 __pLanguageEvent->RemoveListener(listener);
1522 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1528 _SearchBar::OnBoundsChanged(void)
1530 if (__pSearchBarPresenter != null)
1532 __isupdateContentBounds = true;
1533 __pSearchBarPresenter->OnBoundsChanged();
1536 if (__pAccessibilitySearchBarElement)
1538 __pAccessibilitySearchBarElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height));
1544 _SearchBar::OnChangeLayout(_ControlOrientation orientation)
1546 __isupdateContentBounds = true;
1551 _SearchBar::OnDraw(void)
1553 if (!__isUserGuideTextColor)
1555 SearchFieldStatus status = GetCurrentStatus();
1556 __pEdit->SetGuideTextColor(__guideTextColor[status]);
1559 if (__isupdateContentBounds)
1562 __isupdateContentBounds = false;
1564 __pSearchBarPresenter->Draw();
1568 _UiTouchEventDelivery
1569 _SearchBar::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1571 _Edit* pEdit = dynamic_cast <_Edit*>(const_cast <_Control*>(&source));
1574 return _UI_TOUCH_EVENT_DELIVERY_YES;
1577 if (GetMode() == SEARCH_BAR_MODE_INPUT)
1579 return _UI_TOUCH_EVENT_DELIVERY_YES;
1582 SetMode(SEARCH_BAR_MODE_INPUT);
1584 return _UI_TOUCH_EVENT_DELIVERY_YES;
1588 _SearchBar::OnActionPerformed(const _Control& source, int actionId)
1590 if (__actionId == actionId)
1592 __isCancelActionInProgress = true;
1593 SetMode(SEARCH_BAR_MODE_NORMAL);
1597 IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(__actionId);
1598 result r = GetLastResult();
1599 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1601 __pActionEvent->Fire(*pEventArg);
1603 __isCancelActionInProgress = false;
1610 _SearchBar::OnKeypadWillOpen(void)
1612 if (!__isKeypadOpening)
1616 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CREATED);
1617 result r = GetLastResult();
1618 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1620 __pKeypadEvent->Fire(*pEventArg);
1624 __isKeypadOpening = true;
1629 _SearchBar::OnKeypadOpened(void)
1633 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_OPEN);
1634 result r = GetLastResult();
1635 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1637 __pKeypadEvent->Fire(*pEventArg);
1640 __isKeypadOpening = false;
1646 _SearchBar::OnKeypadClosed(void)
1650 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CLOSE);
1651 result r = GetLastResult();
1652 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1654 __pKeypadEvent->Fire(*pEventArg);
1662 _SearchBar::OnKeypadBoundsChanged(void)
1666 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1667 result r = GetLastResult();
1668 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1670 __pKeypadEvent->Fire(*pEventArg);
1678 _SearchBar::OnKeypadActionPerformed(CoreKeypadAction keypadAction)
1682 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(keypadAction, CORE_KEYPAD_EVENT_STATUS_ENTERACTION);
1683 result r = GetLastResult();
1684 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1686 __pKeypadEvent->Fire(*pEventArg);
1691 // TextBlock callbacks
1693 _SearchBar::OnTextBlockSelected(_Control& source, int start, int end)
1695 if (__pTextBlockEvent)
1697 IEventArg* pEventArg = _TextBlockEvent::CreateTextBlockEventArgN(start, end);
1698 result r = GetLastResult();
1699 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1701 __pTextBlockEvent->Fire(*pEventArg);
1708 _SearchBar::OnTextValueChanged(const _Control& source)
1710 if (!__isCancelActionInProgress)
1712 SetContentDimming();
1713 if (__pTextEvent != null)
1715 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CHANGED);
1716 result r = GetLastResult();
1717 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1719 __pTextEvent->Fire(*pEventArg);
1726 _SearchBar::OnTextValueChangeCanceled(const _Control& source)
1728 if (__pTextEvent != null)
1730 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CANCELED);
1731 result r = GetLastResult();
1732 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1734 __pTextEvent->Fire(*pEventArg);
1740 _SearchBar::OnAttachedToMainTree(void)
1747 _SearchBar::OnFontChanged(Font* pFont)
1749 __pCancelButton->SetFont(pFont->GetFaceName());
1750 __pEdit->SetFont(*pFont);
1755 _SearchBar::OnFontInfoRequested(unsigned long& style, int& size)
1757 style = FONT_STYLE_PLAIN;
1758 size = __pCancelButton->GetTextSize();
1764 _SearchBar::OnFocusGained(const _Control& source)
1766 if (GetVisibleState() == true)
1768 SetMode(SEARCH_BAR_MODE_INPUT);
1769 __pEdit->SetFocused();
1776 _SearchBar::OnFocusLost(const _Control& source)
1782 _SearchBar::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1784 if (!__pEdit->IsUsbKeyboardConnected())
1789 _KeyCode keyCode = keyInfo.GetKeyCode();
1791 if (keyCode == _KEY_RIGHT)
1793 if (__isButtonEnabled)
1795 __pEdit->SetFocused(false);
1796 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED);
1797 __pCancelButton->SetFocused();
1798 __pCancelButton->Invalidate(true);
1804 if (keyCode == _KEY_LEFT)
1806 if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_HIGHLIGHTED)
1808 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1809 __pCancelButton->SetFocused(false);
1810 __pCancelButton->Invalidate();
1814 if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_DISABLED) //Searchbar Button is disabled, left arrow key is pressed
1816 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1817 SetButtonEnabled(false);
1820 __pEdit->SetFocused();
1829 _SearchBar::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
1835 _SearchBar::GetParentForm(void) const
1837 _Form* pForm = null;
1838 _Control* pControlCore = GetParent();
1842 if (pControlCore == null)
1844 SysLog(NID_UI_CTRL,"[E_SYSTEM] The parent form is null.");
1849 pForm = dynamic_cast <_Form*>(pControlCore);
1856 pControlCore = pControlCore->GetParent();
1859 return pControlCore;
1863 _SearchBar::GetSearchBarButton(void) const
1865 return __pCancelButton;
1869 _SearchBar::GetSearchField(void)
1875 _SearchBar::GetSearchBarContainer(void) const
1877 return __pContainer;
1881 _SearchBar::GetClippedGroupControl(void) const
1883 return __pClippedGroupControl;
1887 _SearchBar::IsUsableCancelButton(void) const
1889 return __isUsableCancelButton;
1893 _SearchBar::ConvertSearchBarStatus(SearchFieldStatus status)
1895 EditStatus editStatus = EDIT_STATUS_NORMAL;
1898 case SEARCH_FIELD_STATUS_NORMAL:
1899 editStatus = EDIT_STATUS_NORMAL;
1902 case SEARCH_FIELD_STATUS_DISABLED:
1903 editStatus = EDIT_STATUS_DISABLED;
1906 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1907 editStatus = EDIT_STATUS_HIGHLIGHTED;
1917 _SearchBar::ConvertSearchBarButtonStatus(SearchBarButtonStatus status)
1919 _ButtonStatus buttonStatus = _BUTTON_STATUS_NORMAL;
1923 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
1924 buttonStatus = _BUTTON_STATUS_NORMAL;
1927 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
1928 buttonStatus = _BUTTON_STATUS_PRESSED;
1931 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
1932 buttonStatus = _BUTTON_STATUS_HIGHLIGHTED;
1935 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
1936 buttonStatus = _BUTTON_STATUS_DISABLED;
1942 return buttonStatus;
1946 _SearchBar::SendSearchBarEvent(_SearchBarEventStatus status)
1948 result r = E_SUCCESS;
1949 if (__pSearchBarEvent)
1951 IEventArg* pEventArg = _SearchBarEvent::CreateSearchBarEventArgN(status);
1952 r = GetLastResult();
1953 SysTryReturn(NID_UI_CTRL, pEventArg, r, r, "[%s] Propagating.", GetErrorMessage(r));
1955 if (IsContentAreaVisible() == false)
1957 SetContentAreaVisible(false);
1960 __pSearchBarEvent->Fire(*pEventArg);
1967 _SearchBar::SetHeaderVisibleState(bool visible)
1969 if (__pSearchBarPresenter != null)
1971 __pSearchBarPresenter->SetHeaderVisibleState(visible);
1977 _SearchBar::SetPropertyButtonActionId(const Variant& actionId)
1979 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1980 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1981 SysTryReturn(NID_UI_CTRL, actionId.ToInt() > -1, E_INVALID_ARG, E_INVALID_ARG,
1982 "[E_INVALID_ARG] Invalid argument(s) is used. actionId.ToInt() = %d", actionId.ToInt());
1984 result r = E_SUCCESS;
1986 r = __pCancelButton->SetPropertyActionId(actionId);
1987 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1988 "[%s] A system error has occurred. Failed to set actionId.", GetErrorMessage(E_SYSTEM));
1990 __actionId = actionId.ToInt();
1996 _SearchBar::GetPropertyButtonActionId(void) const
1998 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(-1), E_SYSTEM,
1999 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2001 return Variant(__actionId);
2005 _SearchBar::SetPropertyButtonDisabledColor(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->SetPropertyDisabledColor(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_DISABLED] = color.ToColor();
2022 _SearchBar::GetPropertyButtonDisabledColor(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_DISABLED]);
2031 _SearchBar::SetPropertyButtonHighlightedColor(const Variant& color)
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->SetPropertyHighlightedColor(color);
2039 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2040 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2042 __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
2048 _SearchBar::GetPropertyButtonHighlightedColor(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(__buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2057 _SearchBar::SetPropertyButtonNormalColor(const Variant& color)
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->SetPropertyNormalColor(color);
2065 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2066 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2068 __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = color.ToColor();
2074 _SearchBar::GetPropertyButtonNormalColor(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(__buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2083 _SearchBar::SetPropertyButtonPressedColor(const Variant& color)
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->SetPropertyPressedColor(color);
2091 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2092 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2094 __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = color.ToColor();
2100 _SearchBar::GetPropertyButtonPressedColor(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(__buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2109 _SearchBar::SetPropertyButtonDisabledTextColor(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->SetPropertyDisabledTextColor(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_DISABLED] = textColor.ToColor();
2126 _SearchBar::GetPropertyButtonDisabledTextColor(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_DISABLED]);
2135 _SearchBar::SetPropertyButtonHighlightedTextColor(const Variant& textColor)
2137 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2138 "[E_SYSTEM]] A system error has occurred. The cancel button instance is null.");
2140 result r = E_SUCCESS;
2142 r = __pCancelButton->SetPropertyHighlightedTextColor(textColor);
2143 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2144 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2146 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = textColor.ToColor();
2152 _SearchBar::GetPropertyButtonHighlightedTextColor(void) const
2154 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2155 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2157 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2161 _SearchBar::SetPropertyButtonNormalTextColor(const Variant& textColor)
2163 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2164 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2166 result r = E_SUCCESS;
2168 r = __pCancelButton->SetPropertyNormalTextColor(textColor);
2169 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2170 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2172 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = textColor.ToColor();
2178 _SearchBar::GetPropertyButtonNormalTextColor(void) const
2180 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2181 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2183 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2187 _SearchBar::SetPropertyButtonPressedTextColor(const Variant& textColor)
2189 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2190 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2192 result r = E_SUCCESS;
2194 r = __pCancelButton->SetPropertyPressedTextColor(textColor);
2195 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2196 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2198 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = textColor.ToColor();
2204 _SearchBar::GetPropertyButtonPressedTextColor(void) const
2206 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2207 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2209 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2213 _SearchBar::SetPropertySearchFieldDisabledColor(const Variant& color)
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->SetPropertyDisabledColor(color);
2221 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2222 "[E_SYSTEM] A system error has occurred. Failed to set the edit disabled color.");
2224 __color[SEARCH_FIELD_STATUS_DISABLED] = color.ToColor();
2230 _SearchBar::GetPropertySearchFieldDisabledColor(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(__color[SEARCH_FIELD_STATUS_DISABLED]);
2239 _SearchBar::SetPropertySearchFieldHighlightedColor(const Variant& color)
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->SetPropertyHighlightedColor(color);
2247 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2248 "[E_SYSTEM] A system error has occurred. Failed to set the edit highlighted color.");
2250 __color[SEARCH_FIELD_STATUS_HIGHLIGHTED] = color.ToColor();
2256 _SearchBar::GetPropertySearchFieldHighlightedColor(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(__color[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2265 _SearchBar::SetPropertySearchFieldNormalColor(const Variant& color)
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->SetPropertyNormalColor(color);
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 color.");
2276 __color[SEARCH_FIELD_STATUS_NORMAL] = color.ToColor();
2282 _SearchBar::GetPropertySearchFieldNormalColor(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(__color[SEARCH_FIELD_STATUS_NORMAL]);
2291 _SearchBar::SetPropertySearchFieldDisabledTextColor(const Variant& textColor)
2293 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2294 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2296 result r = E_SUCCESS;
2298 r = __pEdit->SetPropertyDisabledTextColor(textColor);
2299 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2300 "[E_SYSTEM] A system error has occurred. Failed to set edit disabled text color.");
2302 __textColor[SEARCH_FIELD_STATUS_DISABLED] = textColor.ToColor();
2308 _SearchBar::GetPropertySearchFieldDisabledTextColor(void) const
2310 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2311 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2313 return Variant(__textColor[SEARCH_FIELD_STATUS_DISABLED]);
2317 _SearchBar::SetPropertySearchFieldHighlightedTextColor(const Variant& textColor)
2319 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2320 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2322 result r = E_SUCCESS;
2324 r = __pEdit->SetPropertyHighlightedTextColor(textColor);
2325 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2326 "[E_SYSTEM] A system error has occurred. Failed to set edit highlighted text color.");
2328 __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED] = textColor.ToColor();
2334 _SearchBar::GetPropertySearchFieldHighlightedTextColor(void) const
2336 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2337 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2339 return Variant(__textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2343 _SearchBar::SetPropertySearchFieldNormalTextColor(const Variant& textColor)
2345 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2346 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2348 result r = E_SUCCESS;
2350 r = __pEdit->SetPropertyNormalTextColor(textColor);
2351 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2352 "[E_SYSTEM] A system error has occurred. Failed to set edit normal text color.");
2354 __textColor[SEARCH_FIELD_STATUS_NORMAL] = textColor.ToColor();
2360 _SearchBar::GetPropertySearchFieldNormalTextColor(void) const
2362 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2363 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2365 return Variant(__textColor[SEARCH_FIELD_STATUS_NORMAL]);
2369 _SearchBar::SetPropertyColor(const Variant& color)
2371 __backgroundColor = color.ToColor();
2377 _SearchBar::GetPropertyColor(void) const
2379 return Variant(__backgroundColor);
2383 _SearchBar::SetPropertyContentAreaSize(const Variant& size)
2385 FloatDimension contentAreaSize = size.ToFloatDimension();
2386 SysTryReturn(NID_UI_CTRL, contentAreaSize.width >= 0 && contentAreaSize.height >= 0, E_INVALID_ARG, E_INVALID_ARG,
2387 "[E_INVALID_ARG] Invalid argument(s) is used. contentAreaSize.width = %f, contenAreaSize.height = %f",
2388 contentAreaSize.width, contentAreaSize.height);
2390 result r = E_SUCCESS;
2393 FloatRectangle bounds = GetBoundsF();
2394 FloatRectangle contentAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
2396 contentAreaBounds.x = 0.0f;
2397 contentAreaBounds.y = bounds.height;
2398 contentAreaBounds.width = contentAreaSize.width;
2399 contentAreaBounds.height = contentAreaSize.height;
2401 __contentAreaBounds = contentAreaBounds;
2402 __isUserContainerBounds = true;
2407 r = __pContainer->SetBounds(__contentAreaBounds);
2408 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2415 _SearchBar::GetPropertyContentAreaSize(void) const
2417 FloatDimension contentAreaSize(__contentAreaBounds.width, __contentAreaBounds.height);
2419 return Variant(contentAreaSize);
2423 _SearchBar::CreateClippedGroupControl(void)
2425 result r = E_SUCCESS;
2426 FloatRectangle clippedGroupControlBounds(FloatPoint(0.0f, 0.0f), GetSizeF());
2427 __pClippedGroupControl = _Control::CreateControlN();
2428 r = GetLastResult();
2429 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2431 r = AttachChild(*__pClippedGroupControl);
2432 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
2433 "[E_SYSTEM] A system error has occurred. Failed to attach the parent of clipped control.");
2435 r = __pClippedGroupControl->SetBounds(clippedGroupControlBounds);
2436 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2438 __pClippedGroupControl->SetBackgroundColor(Color(0));
2440 __pClippedGroupControl->SetClipChildrenEnabled(true);
2445 delete __pClippedGroupControl;
2446 __pClippedGroupControl = null;
2453 _SearchBar::CreateAccessibilityElement(void)
2455 if (__pAccessibilitySearchBarElement != null)
2459 _AccessibilityContainer* pContainer = null;
2460 pContainer = GetAccessibilityContainer();
2464 __pAccessibilitySearchBarElement = new (std::nothrow) _AccessibilityElement(true);
2465 SysTryReturnVoidResult(NID_UI_CTRL, __pAccessibilitySearchBarElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
2466 __pAccessibilitySearchBarElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height));
2467 __pAccessibilitySearchBarElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
2468 __pAccessibilitySearchBarElement->SetName("SearchBar");
2469 pContainer->AddElement(*__pAccessibilitySearchBarElement);
2476 _SearchBar::SetContentDimming(void)
2478 if (__pContainer != NULL)
2480 if (!GetTextLength())
2482 __contentColor.SetAlpha(_SEARCH_CONTENT_DIM_OPACITY);
2486 __contentColor.SetAlpha(0);
2488 __pContainer->SetBackgroundColor(__contentColor);
2494 _SearchBar::IsContentAttachable(const _Control* pContent)
2496 const _Window* pWindow = dynamic_cast <const _Window*>(pContent);
2497 const _ColorPicker* pColorPicker = dynamic_cast <const _ColorPicker*>(pContent);
2498 const _Form* pForm = dynamic_cast <const _Form*>(pContent);
2499 const _Keypad* pKeypad = dynamic_cast <const _Keypad*>(pContent);
2500 const _OverlayPanel* pOverlayPanel = dynamic_cast <const _OverlayPanel*>(pContent);
2502 bool isContentAttachable = true;
2504 isContentAttachable = ((pWindow == null) && (pColorPicker == null) &&
2505 (pForm == null) && (pKeypad == null) && (pOverlayPanel == null));
2506 return isContentAttachable;
2510 _SearchBar::ResizeCancelButton(void)
2512 result r = E_SUCCESS;
2514 float horizontalMargin = 0.0f;
2515 float buttonLeftMargin = 0.0f;
2516 float buttonRightMargin = 0.0f;
2517 float buttonMinWidth = 0.0f;
2518 float searchFieldMinWidth = 0.0f;
2519 float buttonVerticalMargin = 0.0f;
2520 float searchBarMinHeight = 0.0f;
2521 float buttonWidth = 0.0f;
2522 float buttonHeight = 0.0f;
2524 FloatRectangle cancelButtonBounds;
2525 FloatRectangle searchBarBounds = GetBoundsF();
2527 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2529 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2530 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2531 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2532 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2533 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2534 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2535 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2536 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2537 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2539 cancelButtonBounds.width = buttonWidth;
2540 cancelButtonBounds.height = buttonHeight;
2542 float buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth +
2543 cancelButtonBounds.width + buttonLeftMargin + buttonRightMargin);
2545 if (searchBarBounds.width < buttonResizableSearchBarWidth)
2547 cancelButtonBounds.width = searchBarBounds.width -(searchFieldMinWidth + buttonLeftMargin
2548 + buttonRightMargin + horizontalMargin);
2551 cancelButtonBounds.x = searchBarBounds.width - cancelButtonBounds.width - buttonRightMargin;
2552 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2554 cancelButtonBounds.y = cancelButtonBounds.y < 0.0f ? 0.0f:cancelButtonBounds.y;
2556 if (cancelButtonBounds.width < buttonMinWidth)
2558 cancelButtonBounds.width = buttonMinWidth;
2561 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2562 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2563 r = __pCancelButton->SetBounds(cancelButtonBounds);
2569 _SearchBar::RecalculateButtonBounds(void)
2571 result r = E_SUCCESS;
2573 float horizontalMargin = 0.0f;
2574 float verticalMargin = 0.0f;
2575 float buttonLeftMargin = 0.0f;
2576 float buttonRightMargin = 0.0f;
2577 float buttonMinWidth = 0.0f;
2578 float searchFieldMinWidth = 0.0f;
2579 float buttonVerticalMargin = 0.0f;
2580 float searchBarMinHeight = 0.0f;
2581 float buttonWidth = 0.0f;
2582 float buttonHeight = 0.0f;
2583 float cancelButtonWidth = 0.0f;
2585 FloatRectangle cancelButtonBounds;
2586 FloatRectangle editBounds;
2587 FloatRectangle searchBarBounds = GetBoundsF();
2589 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2591 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2592 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin);
2593 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2594 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2595 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2596 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2597 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2598 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2599 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2600 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2602 cancelButtonBounds.height = buttonHeight;
2604 float searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2.0f);
2605 cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightTouchMarginF() + __pCancelButton->GetLeftTouchMarginF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF();
2606 editBounds.x = horizontalMargin;
2608 if (searchBarBounds.height < searchBarMinHeight)
2610 verticalMargin = (searchBarBounds.height - searchFieldMinHeight)/2.0f;
2611 if (verticalMargin < 0.0f)
2613 verticalMargin = 0.0f;
2617 editBounds.y = verticalMargin;
2618 editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
2620 editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
2622 editBounds.width = searchBarBounds.width - cancelButtonWidth - horizontalMargin - buttonLeftMargin - buttonRightMargin;
2624 if (editBounds.width < searchFieldMinWidth)
2626 editBounds.width = searchFieldMinWidth;
2629 cancelButtonBounds.x = editBounds.width + horizontalMargin + buttonLeftMargin;
2630 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2632 cancelButtonBounds.y = cancelButtonBounds.y < 0.0f ? 0.0f:cancelButtonBounds.y;
2634 float remainingWidth = searchBarBounds.width - editBounds.width - horizontalMargin - buttonLeftMargin - buttonRightMargin;
2636 if (remainingWidth < buttonMinWidth)
2638 cancelButtonBounds.width = buttonMinWidth;
2642 cancelButtonBounds.width = searchBarBounds.width - cancelButtonBounds.x - buttonRightMargin;
2645 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2646 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2648 r = __pCancelButton->SetBounds(cancelButtonBounds);
2649 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2650 r = __pEdit->SetBounds(editBounds);
2651 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2657 _SearchBar::GetCurrentStatus(void)
2659 SearchFieldStatus searchFieldStatus = SEARCH_FIELD_STATUS_NORMAL;
2663 if (__pEdit->IsFocused())
2665 searchFieldStatus = SEARCH_FIELD_STATUS_HIGHLIGHTED;
2670 searchFieldStatus = SEARCH_FIELD_STATUS_DISABLED;
2673 return searchFieldStatus;
2677 _SearchBar::SetEditTextFilter(IEditTextFilter* pFilter)
2679 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2680 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2682 __pEdit->SetEditTextFilter(pFilter);
2688 _SearchBar::SendOpaqueCommand(const String& command)
2690 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2691 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2693 __pEdit->SendOpaqueCommand(command);
2698 }}} // Tizen::Ui::Controls