2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrl_SearchBar.cpp
20 * @brief This is the implementation file for the _SearchBar class.
23 #include <FBaseErrorDefine.h>
24 #include <FBaseSysLog.h>
25 #include <FGrp_BitmapImpl.h>
26 #include "FUiAnim_VisualElement.h"
27 #include "FUi_ResourceManager.h"
28 #include "FUiCtrl_SearchBar.h"
29 #include "FUiCtrl_SearchBarPresenter.h"
30 #include "FUiCtrl_Form.h"
31 #include "FUiCtrl_Edit.h"
32 #include "FUiCtrl_Panel.h"
33 #include "FUiCtrl_OverlayPanel.h"
34 #include "FUiCtrl_Keypad.h"
35 #include "FUiCtrl_ColorPicker.h"
36 #include "FUiCtrl_ActionEvent.h"
37 #include "FUiCtrl_TextBlockEvent.h"
38 #include "FUiCtrl_TextEvent.h"
39 #include "FUi_AccessibilityContainer.h"
40 #include "FUi_AccessibilityElement.h"
41 #include "FUi_AccessibilityManager.h"
42 #include "FUi_CoordinateSystemUtils.h"
44 using namespace Tizen::Graphics;
45 using namespace Tizen::Ui;
46 using namespace Tizen::Ui::Animations;
47 using namespace Tizen::Base;
48 using namespace Tizen::Base::Runtime;
49 using namespace Tizen::Locales;
51 namespace Tizen { namespace Ui { namespace Controls
54 IMPLEMENT_PROPERTY(_SearchBar);
56 _SearchBar::_SearchBar(void)
57 : __pSearchBarPresenter(null)
58 , __pClippedGroupControl(null)
60 , __pCancelButton(null)
62 , __pContentControl(null)
65 , __isButtonEnabled(true)
66 , __isUsableCancelButton(false)
67 , __isUserContainerBounds(false)
68 , __isCancelActionInProgress(false)
69 , __isUserGuideTextColor(false)
70 , __isKeypadOpening(false)
71 , __keypadAction(CORE_KEYPAD_ACTION_SEARCH)
72 , __pBackgroundBitmap(null)
73 , __backgroundColor(Color())
74 , __contentColor(Color())
75 , __pActionEvent(null)
76 , __pKeypadEvent(null)
77 , __pTextBlockEvent(null)
79 , __pSearchBarEvent(null)
80 , __pLanguageEvent(null)
81 , __isupdateContentBounds(false)
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 searchFieldMinWidth = 0.0f;
288 float searchBarMinHeight = 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, orientation, searchFieldMinWidth);
300 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
302 float searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2.0f);
304 editBounds.x = horizontalMargin;
305 editBounds.y = verticalMargin;
306 editBounds.width = searchBarBounds.width - (editBounds.x * 2.0f);
307 editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
309 editBounds.width = (editBounds.width > searchFieldMinWidth) ? editBounds.width : searchFieldMinWidth;
310 editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
312 __pEdit = _Edit::CreateEditN();
314 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
316 r = __pEdit->Initialize(EDIT_STYLE_NORMAL | EDIT_STYLE_SINGLE_LINE | EDIT_STYLE_CLEAR | EDIT_STYLE_NOSCROLL, INPUT_STYLE_OVERLAY,
317 SEARCHBAR_TEXT_LENGTH_MAX);
318 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
320 __pEdit->SetKeypadCommandButtonVisible(false);
321 __pEdit->SetBounds(editBounds);
322 __pEdit->AddKeypadEventListener(*this);
323 __pEdit->AddTextBlockEventListener(*this);
324 __pEdit->AddTextEventListener(*this);
326 GET_SHAPE_CONFIG(SEARCHBAR::EDIT_TEXT_SIZE, orientation, textSize);
327 __pEdit->SetTextSize(textSize);
329 __pEdit->SetHorizontalMargin(iconHorizontalMargin + iconWidth + textHorizontalMargin, EDIT_TEXT_LEFT_MARGIN);
330 __pEdit->SetHorizontalMargin(textHorizontalMargin, EDIT_TEXT_RIGHT_MARGIN);
331 __pEdit->SetLimitLength(SEARCHBAR_TEXT_LENGTH_MAX);
333 for (int status = 0; status < SEARCHBAR_COLOR_MAX; status++)
335 EditStatus editStatus = ConvertSearchBarStatus((SearchFieldStatus) status);
336 __pEdit->SetColor(editStatus, __color[status]);
339 __pEdit->SetTextColor(EDIT_TEXT_COLOR_NORMAL, __textColor[SEARCH_FIELD_STATUS_NORMAL]);
340 __pEdit->SetTextColor(EDIT_TEXT_COLOR_DISABLED, __textColor[SEARCH_FIELD_STATUS_DISABLED]);
341 __pEdit->SetTextColor(EDIT_TEXT_COLOR_HIGHLIGHTED, __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
343 __pEdit->ReplaceDefaultBackgroundBitmapForSearchBar();
345 __pEdit->SetKeypadAction(__keypadAction);
347 r = __pClippedGroupControl->AttachChild(*__pEdit);
348 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
349 "[E_SYSTEM] A system error has occurred. Failed to attach edit as child.");
351 if (likely(!(_AccessibilityManager::IsActivated())))
356 pSearchBarContainer = GetAccessibilityContainer();
357 if (pSearchBarContainer)
359 _AccessibilityContainer* pSearchFieldContainer = __pEdit->GetAccessibilityContainer();
360 if (pSearchFieldContainer)
362 pSearchBarContainer->AddChildContainer(*pSearchFieldContainer);
376 _SearchBar::CreateCancelButton(void)
378 result r = E_SUCCESS;
380 float textSize = 0.0f;
381 String cancelButtonText;
383 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
384 _AccessibilityContainer* pSearchBarContainer = null;
386 __pCancelButton = _Button::CreateButtonN();
388 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
390 r = ResizeCancelButton();
391 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
393 GET_STRING_CONFIG(IDS_COM_SK_CANCEL, cancelButtonText);
394 r = __pCancelButton->SetText(cancelButtonText);
395 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
397 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_TEXT_SIZE, orientation, textSize);
398 r = __pCancelButton->SetTextSize(textSize);
399 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
401 __pCancelButton->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
402 __pCancelButton->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
404 r = __pCancelButton->SetActionId(__actionId);
405 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
407 r = __pCancelButton->AddActionEventListener(*this);
408 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
410 __pCancelButton->SetVisibleState(false);
412 for (int status = 0; status < SEARCHBAR_BUTTON_COLOR_MAX; status++)
414 _ButtonStatus buttonStatus = ConvertSearchBarButtonStatus((SearchBarButtonStatus) status);
416 r = __pCancelButton->SetColor(buttonStatus, __buttonColor[status]);
417 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
419 r = __pCancelButton->SetTextColor(buttonStatus, __buttonTextColor[status]);
420 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
423 r = __pClippedGroupControl->AttachChild(*__pCancelButton);
424 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
425 "[E_SYSTEM] A system error has occurred. Failed to attach button as child.");
427 if (likely(!(_AccessibilityManager::IsActivated())))
432 pSearchBarContainer = GetAccessibilityContainer();
433 if (pSearchBarContainer)
435 _AccessibilityContainer* pButtonContainer = __pCancelButton->GetAccessibilityContainer();
436 if (pButtonContainer)
438 pSearchBarContainer->AddChildContainer(*pButtonContainer);
445 delete __pCancelButton;
446 __pCancelButton = null;
452 _SearchBar::CreateContentsArea(void)
454 result r = E_SUCCESS;
456 __pContainer = _Control::CreateControlN();
459 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
461 __pContainer->SetVisibleState(false);
463 r = AttachChild(*__pContainer);
464 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
465 "[E_SYSTEM] A system error has occurred. Failed to attach the parent of content.");
477 _SearchBar::SetContentsArea(void)
479 if (__isUserContainerBounds)
484 FloatDimension screenSize = _ControlManager::GetInstance()->GetScreenSizeF();
485 float width = screenSize.width;
486 float height = screenSize.height;
488 _Control* pParent = GetParentForm();
491 width = pParent->GetClientBoundsF().width;
492 height = pParent->GetClientBoundsF().height;
495 FloatRectangle controlBounds = GetBoundsF();
496 __contentAreaBounds.x = 0.0f;
497 __contentAreaBounds.y = controlBounds.height;
498 __contentAreaBounds.width = width - controlBounds.x;
499 __contentAreaBounds.height = height - (controlBounds.y + controlBounds.height);
503 result r = E_SUCCESS;
504 r = __pContainer->SetBounds(__contentAreaBounds);
505 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
511 _SearchBar::GetContent(void) const
513 return __pContentControl;
517 _SearchBar::SetContent(const _Control* pContent)
519 __pContentControl = const_cast <_Control*>(pContent);
520 result r = E_SUCCESS;
524 r = __pContainer->AttachChild(*__pContentControl);
525 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating");
532 _SearchBar::UpdateContentArea(bool invalidate)
534 return __pSearchBarPresenter->UpdateContentArea(invalidate);
538 _SearchBar::SetContentAreaVisible(bool visible)
540 SysTryReturn(NID_UI_CTRL, __pContainer, E_SYSTEM, E_SYSTEM,
541 "[E_SYSTEM] A system error has occurred. The instance of parent to content is null.");
543 SearchBarMode searchBarMode = GetMode();
544 if (searchBarMode == SEARCH_BAR_MODE_INPUT)
546 __pContainer->SetVisibleState(visible);
549 return __pSearchBarPresenter->SetContentAreaVisible(visible);
553 _SearchBar::IsContentAreaVisible(void) const
555 return __pSearchBarPresenter->IsContentAreaVisible();
559 _SearchBar::SetContentAreaSize(const Dimension& size)
561 return SetProperty("contentAreaSize", Variant(size));
565 _SearchBar::GetContentAreaSize(void) const
567 Variant size = GetProperty("contentAreaSize");
569 return size.ToDimension();
573 _SearchBar::GetMode(void) const
575 return __pSearchBarPresenter->GetMode();
579 _SearchBar::IsModeLocked(void) const
581 return __pSearchBarPresenter->IsModeLocked();
585 _SearchBar::SetMode(SearchBarMode mode)
587 return __pSearchBarPresenter->SetMode(mode);
591 _SearchBar::SetModeLocked(bool modeLocked)
593 return __pSearchBarPresenter->SetModeLocked(modeLocked);
597 _SearchBar::GetButtonActionId(void) const
599 Variant actionId = GetProperty("buttonActionId");
601 return actionId.ToInt();
605 _SearchBar::GetButtonColor(SearchBarButtonStatus status) const
611 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
612 buttonColor = GetProperty("buttonNormalColor");
614 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
615 buttonColor = GetProperty("buttonPressedColor");
617 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
618 buttonColor = GetProperty("buttonHighlightedColor");
620 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
621 buttonColor = GetProperty("buttonDisabledColor");
627 return buttonColor.ToColor();
631 _SearchBar::GetButtonTextColor(SearchBarButtonStatus status) const
633 Variant buttonTextColor;
637 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
638 buttonTextColor = GetProperty("buttonNormalTextColor");
640 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
641 buttonTextColor = GetProperty("buttonPressedTextColor");
643 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
644 buttonTextColor = GetProperty("buttonHighlightedTextColor");
646 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
647 buttonTextColor = GetProperty("buttonDisabledTextColor");
653 return buttonTextColor.ToColor();
656 SearchBarButtonStatus
657 _SearchBar::GetButtonStatus(void) const
659 SysTryReturn(NID_UI_CTRL, __pCancelButton, SEARCH_BAR_BUTTON_STATUS_NORMAL, E_SYSTEM,
660 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
662 SearchBarButtonStatus buttonStatus = SEARCH_BAR_BUTTON_STATUS_NORMAL;
664 if (__isButtonEnabled == false)
666 buttonStatus = SEARCH_BAR_BUTTON_STATUS_DISABLED;
673 _SearchBar::SetButtonText(const String& text)
675 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
676 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
678 result r = E_SUCCESS;
680 r = __pCancelButton->SetText(text);
681 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
682 "[E_SYSTEM] A system error has occurred. Failed to set text.");
688 _SearchBar::SetButtonActionId(int actionId)
690 return SetProperty("buttonActionId", Variant(actionId));
694 _SearchBar::SetButtonEnabled(bool enabled)
696 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
697 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
699 __pCancelButton->SetEnableState(enabled);
701 __isButtonEnabled = enabled;
707 _SearchBar::SetButtonColor(SearchBarButtonStatus status, const Color& color)
709 result r = E_SUCCESS;
713 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
714 r = SetProperty("buttonNormalColor", Variant(color));
716 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
717 r = SetProperty("buttonPressedColor", Variant(color));
719 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
720 r = SetProperty("buttonHighlightedColor", Variant(color));
722 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
723 r = SetProperty("buttonDisabledColor", Variant(color));
733 _SearchBar::SetButtonTextColor(SearchBarButtonStatus status, const Color& color)
735 result r = E_SUCCESS;
739 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
740 r = SetProperty("buttonNormalTextColor", Variant(color));
742 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
743 r = SetProperty("buttonPressedTextColor", Variant(color));
745 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
746 r = SetProperty("buttonHighlightedTextColor", Variant(color));
748 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
749 r = SetProperty("buttonDisabledTextColor", Variant(color));
759 _SearchBar::AppendCharacter(const Character& character)
761 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
762 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
763 SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM,
764 "[E_SYSTEM] A system error has occurred. The character is null.");
766 result r = E_SUCCESS;
768 r = __pEdit->AppendCharacter(character);
769 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
770 "[E_SYSTEM] A system error has occurred. Failed to set character.");
776 _SearchBar::AppendText(const String& text)
778 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
779 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
780 SysTryReturn(NID_UI_CTRL, text.IsEmpty() == false, E_SYSTEM, E_SYSTEM,
781 "[E_SYSTEM] A system error has occurred. The text is empty.");
783 result r = E_SUCCESS;
785 r = __pEdit->AppendText(text);
786 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
787 "[E_SYSTEM] A system error has occurred. Failed to set text.");
793 _SearchBar::SetText(const String& text)
795 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
796 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
798 result r = E_SUCCESS;
800 int limitLength = __pEdit->GetTextLimitLength();
801 int textLength = text.GetLength();
802 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_SYSTEM, E_SYSTEM,
803 "[E_SYSTEM] A system error has occurred. textLength exceeds the limitLength");
805 r = __pEdit->SetText(text);
806 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
807 "[E_SYSTEM] A system error has occurred. Failed to set text.");
813 _SearchBar::InsertCharacterAt(int index, const Character& character)
815 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
816 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
817 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
818 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
819 SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM,
820 "[E_SYSTEM] A system error has occurred. The character is null.");
822 result r = E_SUCCESS;
826 limitLength = __pEdit->GetTextLimitLength();
827 textLength = __pEdit->GetTextLength() + 1;
829 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
830 "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
832 SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
833 "[E_OUT_OF_RANGE] index(%d) is out of range of current textLength(%d).", index, __pEdit->GetTextLength());
835 r = __pEdit->InsertCharacterAt(index, character);
836 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
837 "[E_SYSTEM] A system error has occurred. Failed to set text.");
843 _SearchBar::InsertTextAt(int index, const String& text)
845 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
846 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
847 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
848 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
850 result r = E_SUCCESS;
854 limitLength = __pEdit->GetTextLimitLength();
855 textLength = __pEdit->GetTextLength() + text.GetLength();
857 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
858 "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
859 SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
860 "[E_OUT_OF_RANGE] index(%d) is out of range of current textLength(%d).", index, __pEdit->GetTextLength());
862 r = __pEdit->InsertTextAt(index, text);
863 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
864 "[E_SYSTEM] A system error has occurred. Failed to insert text.");
870 _SearchBar::DeleteCharacterAt(int index)
872 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
873 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
874 SysTryReturn(NID_UI_CTRL, index > -1, E_INVALID_ARG, E_INVALID_ARG,
875 "[E_INVALID_ARG] Invalid argument(s) is used. index = %d", index);
877 result r = E_SUCCESS;
879 textLength = __pEdit->GetTextLength();
881 SysTryReturn(NID_UI_CTRL, textLength > index, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
882 "[E_OUT_OF_RANGE] index(%d) is out of range. textLength(%d)", index, textLength);
884 r = __pEdit->DeleteCharacterAt(index);
885 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM,
886 "[E_SYSTEM] A system error has occured. Failed to delete character.");
892 _SearchBar::Clear(void)
894 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
895 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
897 return __pEdit->ClearText();
901 _SearchBar::GetTextLength(void) const
903 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
904 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
906 return __pEdit->GetTextLength();
910 _SearchBar::GetText(void) const
912 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
913 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
915 return __pEdit->GetText();
919 _SearchBar::GetText(int start, int end) const
921 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
922 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
924 return __pEdit->GetText(start, end);
928 _SearchBar::GetLimitLength(void) const
930 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
931 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
933 return __pEdit->GetTextLimitLength();
937 _SearchBar::SetLimitLength(int limitLength)
939 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
940 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
941 SysTryReturn(NID_UI_CTRL, limitLength > 0, E_INVALID_ARG, E_INVALID_ARG,
942 "[E_INVALID_ARG] Invalid argument(s) is used.limitLength = %d", limitLength);
944 String tempString = GetText();
946 int textLength = tempString.GetLength();
947 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_INVALID_ARG, E_INVALID_ARG,
948 "[E_INVALID_ARG] Invalid argument(s) is used. limitLength = %d, textLength = %d", limitLength, textLength);
950 result r = __pEdit->SetLimitLength(limitLength);
951 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
953 r = SetText(tempString);
954 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
960 _SearchBar::ShowKeypad(void) const
962 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
963 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
965 SearchBarMode mode = __pSearchBarPresenter->GetMode();
966 SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_INVALID_STATE, E_INVALID_STATE,
967 "[E_INVALID_STATE] The SearchBar is currently in Normal mode.");
968 return __pEdit->ShowKeypad();
972 _SearchBar::HideKeypad(void)
974 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
975 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
977 SearchBarMode mode = __pSearchBarPresenter->GetMode();
978 SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_SYSTEM, E_SYSTEM,
979 "[E_SYSTEM] A system error has occurred. The SearchBar is currently in Normal mode.");
981 result r = __pEdit->HideKeypad();
989 _SearchBar::GetSearchFieldTextSizeF(void) const
991 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
992 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
994 return __pEdit->GetTextSizeF();
998 _SearchBar::SetSearchFieldTextSize(float size)
1000 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1001 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1003 return __pEdit->SetTextSize(size);
1007 _SearchBar::GetBlockRange(int& start, int& end) const
1009 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1010 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1012 int startIndex = -1;
1015 __pEdit->GetBlockRange(startIndex, endIndex);
1016 SysTryReturn(NID_UI_CTRL, (startIndex > -1 && endIndex > 0), E_SYSTEM, E_SYSTEM,
1017 "[E_SYSTEM] A system error has occurred. Failed to get text block range.");
1026 _SearchBar::ReleaseBlock(void)
1028 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1029 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1031 result r = E_SUCCESS;
1036 r = GetBlockRange(start, end);
1037 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1039 return __pEdit->ReleaseTextBlock();
1043 _SearchBar::SetBlockRange(int start, int end)
1045 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1046 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1048 result r = E_SUCCESS;
1051 textLength = __pEdit->GetTextLength();
1053 SysTryReturn(NID_UI_CTRL, (start < end && start >= 0 && textLength >= end), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1054 "[E_OUT_OF_RANGE] start (%d) and end (%d) is out of range.", start, end - 1);
1056 r = SetCursorPosition(start);
1057 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1059 r = __pEdit->BeginTextBlock();
1060 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1061 "[E_SYSTEM] A system error has occurred. Failed to set text block range.");
1063 r = SetCursorPosition(end);
1064 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1065 "[E_SYSTEM] A system error has occurred. Failed to set cursor position.");
1071 _SearchBar::RemoveTextBlock(void)
1073 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1074 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1076 result r = E_SUCCESS;
1078 r = __pEdit->RemoveTextBlock();
1079 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1085 _SearchBar::GetColor(void) const
1087 Variant backgroundColor = GetProperty("color");
1089 return backgroundColor.ToColor();
1093 _SearchBar::GetSearchFieldColor(SearchFieldStatus status) const
1095 Variant searchFieldColor;
1099 case SEARCH_FIELD_STATUS_NORMAL:
1100 searchFieldColor = GetProperty("searchFieldNormalColor");
1102 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1103 searchFieldColor = GetProperty("searchFieldHighlightedColor");
1105 case SEARCH_FIELD_STATUS_DISABLED:
1106 searchFieldColor = GetProperty("searchFieldDisabledColor");
1112 return searchFieldColor.ToColor();
1117 _SearchBar::GetSearchFieldTextColor(SearchFieldStatus status) const
1119 Variant searchFieldTextColor;
1123 case SEARCH_FIELD_STATUS_NORMAL:
1124 searchFieldTextColor = GetProperty("searchFieldNormalTextColor");
1126 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1127 searchFieldTextColor = GetProperty("searchFieldHighlightedTextColor");
1129 case SEARCH_FIELD_STATUS_DISABLED:
1130 searchFieldTextColor = GetProperty("searchFieldDisabledTextColor");
1136 return searchFieldTextColor.ToColor();
1141 _SearchBar::SetBackgroundBitmap(const Bitmap& bitmap)
1143 Bitmap* pNewBitmap = _BitmapImpl::CloneN(bitmap);
1144 SysTryReturn(NID_UI_CTRL, pNewBitmap, E_SYSTEM, E_SYSTEM,
1145 "[E_SYSTEM] A system error has occurred. The creation of bitmap failed.");
1147 delete __pBackgroundBitmap;
1148 __pBackgroundBitmap = null;
1150 __pBackgroundBitmap = pNewBitmap;
1156 _SearchBar::GetBackgroundBitmap(void) const
1158 return __pBackgroundBitmap;
1162 _SearchBar::SetColor(const Color& color)
1164 return SetProperty("color", Variant(color));
1168 _SearchBar::SetSearchFieldColor(SearchFieldStatus status, const Color& color)
1170 result r = E_SUCCESS;
1174 case SEARCH_FIELD_STATUS_NORMAL:
1175 r = SetProperty("searchFieldNormalColor", Variant(color));
1177 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1178 r = SetProperty("searchFieldHighlightedColor", Variant(color));
1180 case SEARCH_FIELD_STATUS_DISABLED:
1181 r = SetProperty("searchFieldDisabledColor", Variant(color));
1192 _SearchBar::SetSearchFieldTextColor(SearchFieldStatus status, const Color& color)
1194 result r = E_SUCCESS;
1198 case SEARCH_FIELD_STATUS_NORMAL:
1199 r = SetProperty("searchFieldNormalTextColor", Variant(color));
1201 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1202 r = SetProperty("searchFieldHighlightedTextColor", Variant(color));
1204 case SEARCH_FIELD_STATUS_DISABLED:
1205 r = SetProperty("searchFieldDisabledTextColor", Variant(color));
1216 _SearchBar::GetGuideText(void) const
1218 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
1219 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1221 return __pEdit->GetGuideText();
1225 _SearchBar::SetGuideText(const String& guideText)
1227 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1228 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1230 __pEdit->SetGuideText(guideText);
1236 _SearchBar::GetGuideTextColor(void) const
1238 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1239 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1241 return __pEdit->GetGuideTextColor();
1245 _SearchBar::SetGuideTextColor(const Color& color)
1247 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1248 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1250 __isUserGuideTextColor = true;
1251 return __pEdit->SetGuideTextColor(color);
1255 _SearchBar::GetCursorPosition(void) const
1257 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
1258 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1260 return __pEdit->GetCursorPosition();
1264 _SearchBar::SetCursorPosition(int index)
1266 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1267 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1268 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1269 "[E_OUT_OF_RANGE] index(%d) is out of range.", GetErrorMessage(E_OUT_OF_RANGE), index);
1271 int textLength = -1;
1272 textLength = __pEdit->GetTextLength();
1274 SysTryReturn(NID_UI_CTRL, (index > -1 && index <= textLength), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1275 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
1277 return __pEdit->SetCursorPosition(index);
1281 _SearchBar::IsLowerCaseModeEnabled(void) const
1283 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1284 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1286 return __pEdit->IsLowerCaseModeEnabled();
1290 _SearchBar::SetLowerCaseModeEnabled(bool enable)
1292 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
1293 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1295 __pEdit->SetLowerCaseModeEnabled(enable);
1299 _SearchBar::GetEllipsisPosition(void) const
1301 SysTryReturn(NID_UI_CTRL, __pEdit, ELLIPSIS_POSITION_START, E_SYSTEM,
1302 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1304 return __pEdit->GetEllipsisPosition();
1308 _SearchBar::SetEllipsisPosition(EllipsisPosition position)
1310 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1311 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1312 __pEdit->SetEllipsisPosition(position);
1318 _SearchBar::GetKeypadAction(void) const
1320 return __keypadAction;
1324 _SearchBar::IsTextPredictionEnabled(void) const
1326 SysTryReturn(NID_UI_CTRL, __pEdit, false, E_SYSTEM,
1327 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1328 return __pEdit->IsTextPredictionEnabled();
1332 _SearchBar::SetTextPredictionEnabled(bool enable)
1334 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1335 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1336 return __pEdit->SetTextPredictionEnabled(enable);
1340 _SearchBar::SetCurrentLanguage(LanguageCode languageCode)
1342 return __pEdit->SetCurrentLanguage(languageCode);
1346 _SearchBar::GetCurrentLanguage(LanguageCode& language) const
1348 return __pEdit->GetCurrentLanguage(language);
1352 _SearchBar::AddActionEventListener(const _IActionEventListener& listener)
1354 result r = E_SUCCESS;
1356 if (__pActionEvent == null)
1358 __pActionEvent = _ActionEvent::CreateInstanceN(*this);
1359 r = GetLastResult();
1360 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1362 __pActionEvent->AddListener(listener);
1369 _SearchBar::RemoveActionEventListener(const _IActionEventListener& listener)
1371 SysTryReturn(NID_UI_CTRL, __pActionEvent, E_SYSTEM, E_SYSTEM,
1372 "[E_SYSTEM] A system error has occurred. The action event instance is null.");
1373 result r = E_SUCCESS;
1375 r = __pActionEvent->RemoveListener(listener);
1376 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1382 _SearchBar::AddKeypadEventListener(const _IKeypadEventListener& listener)
1384 result r = E_SUCCESS;
1386 if (__pKeypadEvent == null)
1388 __pKeypadEvent = _KeypadEvent::CreateInstanceN(*this);
1389 r = GetLastResult();
1390 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1392 r = __pKeypadEvent->AddListener(listener);
1393 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1400 _SearchBar::RemoveKeypadEventListener(const _IKeypadEventListener& listener)
1402 SysTryReturn(NID_UI_CTRL, __pKeypadEvent, E_SYSTEM, E_SYSTEM,
1403 "[E_SYSTEM] A system error has occurred. The keypad event instance is null.");
1404 result r = E_SUCCESS;
1406 r = __pKeypadEvent->RemoveListener(listener);
1407 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1413 _SearchBar::AddTextBlockEventListener(const _ITextBlockEventListener& listener)
1415 result r = E_SUCCESS;
1417 if (__pTextBlockEvent == null)
1419 __pTextBlockEvent = _TextBlockEvent::CreateInstanceN(*this);
1420 r = GetLastResult();
1421 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1423 r = __pTextBlockEvent->AddListener(listener);
1424 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1432 _SearchBar::RemoveTextBlockEventListener(const _ITextBlockEventListener& listener)
1434 SysTryReturn(NID_UI_CTRL, __pTextBlockEvent, E_SYSTEM, E_SYSTEM,
1435 "[E_SYSTEM] A system error has occurred. The text block event instance is null.");
1436 result r = E_SUCCESS;
1438 r = __pTextBlockEvent->RemoveListener(listener);
1439 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1446 _SearchBar::AddTextEventListener(const _ITextEventListener& listener)
1448 result r = E_SUCCESS;
1450 if (__pTextEvent == null)
1452 __pTextEvent = _TextEvent::CreateInstanceN(*this);
1453 r = GetLastResult();
1454 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1456 r = __pTextEvent->AddListener(listener);
1457 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1464 _SearchBar::RemoveTextEventListener(const _ITextEventListener& listener)
1466 SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM,
1467 "[E_SYSTEM] A system error has occurred. The text event instance is null.");
1468 result r = E_SUCCESS;
1470 r = __pTextEvent->RemoveListener(listener);
1471 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1477 _SearchBar::AddSearchBarEventListener(const _ISearchBarEventListener& listener)
1479 result r = E_SUCCESS;
1481 if (__pSearchBarEvent == null)
1483 __pSearchBarEvent = _SearchBarEvent::CreateInstanceN(*this);
1484 r = GetLastResult();
1485 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1487 r = __pSearchBarEvent->AddListener(listener);
1488 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1495 _SearchBar::RemoveSearchBarEventListener(const _ISearchBarEventListener& listener)
1497 SysTryReturn(NID_UI_CTRL, __pSearchBarEvent, E_SYSTEM, E_SYSTEM,
1498 "[E_SYSTEM] A system error has occurred. The searchbar event instance is null.");
1499 result r = E_SUCCESS;
1501 r = __pSearchBarEvent->RemoveListener(listener);
1502 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1508 _SearchBar::AddLanguageEventListener(const _ILanguageEventListener& listener)
1510 result r = E_SUCCESS;
1512 if (__pLanguageEvent == null)
1514 __pLanguageEvent = _LanguageEvent::CreateInstanceN(*this);
1515 r = GetLastResult();
1516 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1518 r = __pLanguageEvent->AddListener(listener);
1519 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1526 _SearchBar::RemoveLanguageEventListener(const _ILanguageEventListener& listener)
1528 SysTryReturn(NID_UI_CTRL, __pLanguageEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.");
1529 result r = E_SUCCESS;
1531 __pLanguageEvent->RemoveListener(listener);
1532 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1538 _SearchBar::OnBoundsChanged(void)
1540 if (__pSearchBarPresenter != null)
1542 __isupdateContentBounds = true;
1543 __pSearchBarPresenter->OnBoundsChanged();
1549 _SearchBar::OnChangeLayout(_ControlOrientation orientation)
1551 __isupdateContentBounds = true;
1556 _SearchBar::OnDraw(void)
1558 if (!__isUserGuideTextColor)
1560 SearchFieldStatus status = GetCurrentStatus();
1561 __pEdit->SetGuideTextColor(__guideTextColor[status]);
1564 if (__isupdateContentBounds)
1567 __isupdateContentBounds = false;
1569 __pSearchBarPresenter->Draw();
1573 _UiTouchEventDelivery
1574 _SearchBar::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1576 _Edit* pEdit = dynamic_cast <_Edit*>(const_cast <_Control*>(&source));
1579 return _UI_TOUCH_EVENT_DELIVERY_YES;
1582 if (GetMode() == SEARCH_BAR_MODE_INPUT)
1584 return _UI_TOUCH_EVENT_DELIVERY_YES;
1587 SetMode(SEARCH_BAR_MODE_INPUT);
1589 return _UI_TOUCH_EVENT_DELIVERY_YES;
1593 _SearchBar::OnActionPerformed(const _Control& source, int actionId)
1595 if (__actionId == actionId)
1597 __isCancelActionInProgress = true;
1598 SetMode(SEARCH_BAR_MODE_NORMAL);
1602 IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(__actionId);
1603 result r = GetLastResult();
1604 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1606 __pActionEvent->Fire(*pEventArg);
1608 __isCancelActionInProgress = false;
1615 _SearchBar::OnKeypadWillOpen(void)
1617 if (!__isKeypadOpening)
1621 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CREATED);
1622 result r = GetLastResult();
1623 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1625 __pKeypadEvent->Fire(*pEventArg);
1629 __isKeypadOpening = true;
1634 _SearchBar::OnKeypadOpened(void)
1638 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_OPEN);
1639 result r = GetLastResult();
1640 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1642 __pKeypadEvent->Fire(*pEventArg);
1645 __isKeypadOpening = false;
1651 _SearchBar::OnKeypadClosed(void)
1655 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CLOSE);
1656 result r = GetLastResult();
1657 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1659 __pKeypadEvent->Fire(*pEventArg);
1667 _SearchBar::OnKeypadBoundsChanged(void)
1671 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1672 result r = GetLastResult();
1673 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1675 __pKeypadEvent->Fire(*pEventArg);
1683 _SearchBar::OnKeypadActionPerformed(CoreKeypadAction keypadAction)
1687 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(keypadAction, CORE_KEYPAD_EVENT_STATUS_ENTERACTION);
1688 result r = GetLastResult();
1689 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1691 __pKeypadEvent->Fire(*pEventArg);
1696 // TextBlock callbacks
1698 _SearchBar::OnTextBlockSelected(_Control& source, int start, int end)
1700 if (__pTextBlockEvent)
1702 IEventArg* pEventArg = _TextBlockEvent::CreateTextBlockEventArgN(start, end);
1703 result r = GetLastResult();
1704 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1706 __pTextBlockEvent->Fire(*pEventArg);
1713 _SearchBar::OnTextValueChanged(const _Control& source)
1715 if (!__isCancelActionInProgress)
1717 SetContentDimming();
1718 if (__pTextEvent != null)
1720 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CHANGED);
1721 result r = GetLastResult();
1722 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1724 __pTextEvent->Fire(*pEventArg);
1731 _SearchBar::OnTextValueChangeCanceled(const _Control& source)
1733 if (__pTextEvent != null)
1735 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CANCELED);
1736 result r = GetLastResult();
1737 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1739 __pTextEvent->Fire(*pEventArg);
1745 _SearchBar::OnAttachedToMainTree(void)
1753 _SearchBar::OnFontChanged(Font* pFont)
1755 __pCancelButton->SetFont(pFont->GetFaceName());
1756 __pEdit->SetFont(*pFont);
1761 _SearchBar::OnFontInfoRequested(unsigned long& style, int& size)
1763 style = FONT_STYLE_PLAIN;
1764 size = __pCancelButton->GetTextSize();
1770 _SearchBar::OnFocusGained(const _Control& source)
1772 SetMode(SEARCH_BAR_MODE_INPUT);
1773 __pEdit->SetFocused();
1778 _SearchBar::OnFocusLost(const _Control& source)
1784 _SearchBar::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1786 if (!__pEdit->IsUsbKeyboardConnected())
1791 _KeyCode keyCode = keyInfo.GetKeyCode();
1793 if (keyCode == _KEY_RIGHT)
1795 if (__isButtonEnabled)
1797 __pEdit->SetFocused(false);
1798 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED);
1799 __pCancelButton->SetFocused();
1800 __pCancelButton->Invalidate(true);
1806 if (keyCode == _KEY_LEFT)
1808 if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_HIGHLIGHTED)
1810 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1811 __pCancelButton->SetFocused(false);
1812 __pCancelButton->Invalidate();
1816 if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_DISABLED) //Searchbar Button is disabled, left arrow key is pressed
1818 __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1819 SetButtonEnabled(false);
1822 __pEdit->SetFocused();
1831 _SearchBar::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
1837 _SearchBar::GetParentForm(void) const
1839 _Form* pForm = null;
1840 _Control* pControlCore = GetParent();
1844 if (pControlCore == null)
1846 SysLog(NID_UI_CTRL,"[E_SYSTEM] The parent form is null.");
1851 pForm = dynamic_cast <_Form*>(pControlCore);
1858 pControlCore = pControlCore->GetParent();
1861 return pControlCore;
1865 _SearchBar::GetSearchBarButton(void) const
1867 return __pCancelButton;
1871 _SearchBar::GetSearchField(void)
1877 _SearchBar::GetSearchBarContainer(void) const
1879 return __pContainer;
1883 _SearchBar::GetClippedGroupControl(void) const
1885 return __pClippedGroupControl;
1889 _SearchBar::IsUsableCancelButton(void) const
1891 return __isUsableCancelButton;
1895 _SearchBar::ConvertSearchBarStatus(SearchFieldStatus status)
1897 EditStatus editStatus = EDIT_STATUS_NORMAL;
1900 case SEARCH_FIELD_STATUS_NORMAL:
1901 editStatus = EDIT_STATUS_NORMAL;
1904 case SEARCH_FIELD_STATUS_DISABLED:
1905 editStatus = EDIT_STATUS_DISABLED;
1908 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1909 editStatus = EDIT_STATUS_HIGHLIGHTED;
1919 _SearchBar::ConvertSearchBarButtonStatus(SearchBarButtonStatus status)
1921 _ButtonStatus buttonStatus = _BUTTON_STATUS_NORMAL;
1925 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
1926 buttonStatus = _BUTTON_STATUS_NORMAL;
1929 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
1930 buttonStatus = _BUTTON_STATUS_PRESSED;
1933 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
1934 buttonStatus = _BUTTON_STATUS_HIGHLIGHTED;
1937 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
1938 buttonStatus = _BUTTON_STATUS_DISABLED;
1944 return buttonStatus;
1948 _SearchBar::SendSearchBarEvent(_SearchBarEventStatus status)
1950 result r = E_SUCCESS;
1951 if (__pSearchBarEvent)
1953 IEventArg* pEventArg = _SearchBarEvent::CreateSearchBarEventArgN(status);
1954 r = GetLastResult();
1955 SysTryReturn(NID_UI_CTRL, pEventArg, r, r, "[%s] Propagating.", GetErrorMessage(r));
1957 if (IsContentAreaVisible() == false)
1959 SetContentAreaVisible(false);
1962 __pSearchBarEvent->Fire(*pEventArg);
1969 _SearchBar::SetHeaderVisibleState(bool visible)
1971 if (__pSearchBarPresenter != null)
1973 __pSearchBarPresenter->SetHeaderVisibleState(visible);
1979 _SearchBar::SetPropertyButtonActionId(const Variant& actionId)
1981 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1982 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1983 SysTryReturn(NID_UI_CTRL, actionId.ToInt() > -1, E_INVALID_ARG, E_INVALID_ARG,
1984 "[E_INVALID_ARG] Invalid argument(s) is used. actionId.ToInt() = %d", actionId.ToInt());
1986 result r = E_SUCCESS;
1988 r = __pCancelButton->SetPropertyActionId(actionId);
1989 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1990 "[%s] A system error has occurred. Failed to set actionId.", GetErrorMessage(E_SYSTEM));
1992 __actionId = actionId.ToInt();
1998 _SearchBar::GetPropertyButtonActionId(void) const
2000 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(-1), E_SYSTEM,
2001 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2003 return Variant(__actionId);
2007 _SearchBar::SetPropertyButtonDisabledColor(const Variant& color)
2009 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2010 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2012 result r = E_SUCCESS;
2014 r = __pCancelButton->SetPropertyDisabledColor(color);
2015 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2016 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2018 __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = color.ToColor();
2024 _SearchBar::GetPropertyButtonDisabledColor(void) const
2026 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2027 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2029 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2033 _SearchBar::SetPropertyButtonHighlightedColor(const Variant& color)
2035 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2036 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2038 result r = E_SUCCESS;
2040 r = __pCancelButton->SetPropertyHighlightedColor(color);
2041 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2042 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2044 __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
2050 _SearchBar::GetPropertyButtonHighlightedColor(void) const
2052 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2053 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2055 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2059 _SearchBar::SetPropertyButtonNormalColor(const Variant& color)
2061 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2062 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2064 result r = E_SUCCESS;
2066 r = __pCancelButton->SetPropertyNormalColor(color);
2067 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2068 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2070 __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = color.ToColor();
2076 _SearchBar::GetPropertyButtonNormalColor(void) const
2078 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2079 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2081 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2085 _SearchBar::SetPropertyButtonPressedColor(const Variant& color)
2087 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2088 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2090 result r = E_SUCCESS;
2092 r = __pCancelButton->SetPropertyPressedColor(color);
2093 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2094 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2096 __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = color.ToColor();
2102 _SearchBar::GetPropertyButtonPressedColor(void) const
2104 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2105 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2107 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2111 _SearchBar::SetPropertyButtonDisabledTextColor(const Variant& textColor)
2113 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2114 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2116 result r = E_SUCCESS;
2118 r = __pCancelButton->SetPropertyDisabledTextColor(textColor);
2119 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2120 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2122 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = textColor.ToColor();
2128 _SearchBar::GetPropertyButtonDisabledTextColor(void) const
2130 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2131 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2133 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2137 _SearchBar::SetPropertyButtonHighlightedTextColor(const Variant& textColor)
2139 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2140 "[E_SYSTEM]] A system error has occurred. The cancel button instance is null.");
2142 result r = E_SUCCESS;
2144 r = __pCancelButton->SetPropertyHighlightedTextColor(textColor);
2145 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2146 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2148 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = textColor.ToColor();
2154 _SearchBar::GetPropertyButtonHighlightedTextColor(void) const
2156 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2157 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2159 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2163 _SearchBar::SetPropertyButtonNormalTextColor(const Variant& textColor)
2165 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2166 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2168 result r = E_SUCCESS;
2170 r = __pCancelButton->SetPropertyNormalTextColor(textColor);
2171 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2172 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2174 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = textColor.ToColor();
2180 _SearchBar::GetPropertyButtonNormalTextColor(void) const
2182 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2183 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2185 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2189 _SearchBar::SetPropertyButtonPressedTextColor(const Variant& textColor)
2191 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2192 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2194 result r = E_SUCCESS;
2196 r = __pCancelButton->SetPropertyPressedTextColor(textColor);
2197 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2198 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2200 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = textColor.ToColor();
2206 _SearchBar::GetPropertyButtonPressedTextColor(void) const
2208 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2209 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2211 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2215 _SearchBar::SetPropertySearchFieldDisabledColor(const Variant& color)
2217 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2218 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2220 result r = E_SUCCESS;
2222 r = __pEdit->SetPropertyDisabledColor(color);
2223 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2224 "[E_SYSTEM] A system error has occurred. Failed to set the edit disabled color.");
2226 __color[SEARCH_FIELD_STATUS_DISABLED] = color.ToColor();
2232 _SearchBar::GetPropertySearchFieldDisabledColor(void) const
2234 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2235 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2237 return Variant(__color[SEARCH_FIELD_STATUS_DISABLED]);
2241 _SearchBar::SetPropertySearchFieldHighlightedColor(const Variant& color)
2243 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2244 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2246 result r = E_SUCCESS;
2248 r = __pEdit->SetPropertyHighlightedColor(color);
2249 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2250 "[E_SYSTEM] A system error has occurred. Failed to set the edit highlighted color.");
2252 __color[SEARCH_FIELD_STATUS_HIGHLIGHTED] = color.ToColor();
2258 _SearchBar::GetPropertySearchFieldHighlightedColor(void) const
2260 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2261 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2263 return Variant(__color[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2267 _SearchBar::SetPropertySearchFieldNormalColor(const Variant& color)
2269 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2270 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2272 result r = E_SUCCESS;
2274 r = __pEdit->SetPropertyNormalColor(color);
2275 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2276 "[E_SYSTEM] A system error has occurred. Failed to set edit normal color.");
2278 __color[SEARCH_FIELD_STATUS_NORMAL] = color.ToColor();
2284 _SearchBar::GetPropertySearchFieldNormalColor(void) const
2286 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2287 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2289 return Variant(__color[SEARCH_FIELD_STATUS_NORMAL]);
2293 _SearchBar::SetPropertySearchFieldDisabledTextColor(const Variant& textColor)
2295 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2296 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2298 result r = E_SUCCESS;
2300 r = __pEdit->SetPropertyDisabledTextColor(textColor);
2301 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2302 "[E_SYSTEM] A system error has occurred. Failed to set edit disabled text color.");
2304 __textColor[SEARCH_FIELD_STATUS_DISABLED] = textColor.ToColor();
2310 _SearchBar::GetPropertySearchFieldDisabledTextColor(void) const
2312 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2313 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2315 return Variant(__textColor[SEARCH_FIELD_STATUS_DISABLED]);
2319 _SearchBar::SetPropertySearchFieldHighlightedTextColor(const Variant& textColor)
2321 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2322 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2324 result r = E_SUCCESS;
2326 r = __pEdit->SetPropertyHighlightedTextColor(textColor);
2327 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2328 "[E_SYSTEM] A system error has occurred. Failed to set edit highlighted text color.");
2330 __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED] = textColor.ToColor();
2336 _SearchBar::GetPropertySearchFieldHighlightedTextColor(void) const
2338 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2339 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2341 return Variant(__textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2345 _SearchBar::SetPropertySearchFieldNormalTextColor(const Variant& textColor)
2347 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2348 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2350 result r = E_SUCCESS;
2352 r = __pEdit->SetPropertyNormalTextColor(textColor);
2353 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2354 "[E_SYSTEM] A system error has occurred. Failed to set edit normal text color.");
2356 __textColor[SEARCH_FIELD_STATUS_NORMAL] = textColor.ToColor();
2362 _SearchBar::GetPropertySearchFieldNormalTextColor(void) const
2364 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2365 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2367 return Variant(__textColor[SEARCH_FIELD_STATUS_NORMAL]);
2371 _SearchBar::SetPropertyColor(const Variant& color)
2373 __backgroundColor = color.ToColor();
2379 _SearchBar::GetPropertyColor(void) const
2381 return Variant(__backgroundColor);
2385 _SearchBar::SetPropertyContentAreaSize(const Variant& size)
2387 FloatDimension contentAreaSize = size.ToFloatDimension();
2388 SysTryReturn(NID_UI_CTRL, contentAreaSize.width >= 0 && contentAreaSize.height >= 0, E_INVALID_ARG, E_INVALID_ARG,
2389 "[E_INVALID_ARG] Invalid argument(s) is used. contentAreaSize.width = %f, contenAreaSize.height = %f",
2390 contentAreaSize.width, contentAreaSize.height);
2392 result r = E_SUCCESS;
2395 FloatRectangle bounds = GetBoundsF();
2396 FloatRectangle contentAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
2398 contentAreaBounds.x = 0.0f;
2399 contentAreaBounds.y = bounds.height;
2400 contentAreaBounds.width = contentAreaSize.width;
2401 contentAreaBounds.height = contentAreaSize.height;
2403 __contentAreaBounds = contentAreaBounds;
2404 __isUserContainerBounds = true;
2409 r = __pContainer->SetBounds(__contentAreaBounds);
2410 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2417 _SearchBar::GetPropertyContentAreaSize(void) const
2419 FloatDimension contentAreaSize(__contentAreaBounds.width, __contentAreaBounds.height);
2421 return Variant(contentAreaSize);
2425 _SearchBar::CreateClippedGroupControl(void)
2427 result r = E_SUCCESS;
2428 FloatRectangle clippedGroupControlBounds(FloatPoint(0.0f, 0.0f), GetSizeF());
2429 __pClippedGroupControl = _Control::CreateControlN();
2430 r = GetLastResult();
2431 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2433 r = AttachChild(*__pClippedGroupControl);
2434 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
2435 "[E_SYSTEM] A system error has occurred. Failed to attach the parent of clipped control.");
2437 r = __pClippedGroupControl->SetBounds(clippedGroupControlBounds);
2438 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2440 __pClippedGroupControl->SetBackgroundColor(Color(0));
2442 __pClippedGroupControl->SetClipChildrenEnabled(true);
2447 delete __pClippedGroupControl;
2448 __pClippedGroupControl = null;
2455 _SearchBar::SetContentDimming(void)
2457 if (__pContainer != NULL)
2459 if (!GetTextLength())
2461 __contentColor.SetAlpha(_SEARCH_CONTENT_DIM_OPACITY);
2465 __contentColor.SetAlpha(0);
2467 __pContainer->SetBackgroundColor(__contentColor);
2473 _SearchBar::IsContentAttachable(const _Control* pContent)
2475 const _Window* pWindow = dynamic_cast <const _Window*>(pContent);
2476 const _ColorPicker* pColorPicker = dynamic_cast <const _ColorPicker*>(pContent);
2477 const _Form* pForm = dynamic_cast <const _Form*>(pContent);
2478 const _Keypad* pKeypad = dynamic_cast <const _Keypad*>(pContent);
2479 const _OverlayPanel* pOverlayPanel = dynamic_cast <const _OverlayPanel*>(pContent);
2481 bool isContentAttachable = true;
2483 isContentAttachable = ((pWindow == null) && (pColorPicker == null) &&
2484 (pForm == null) && (pKeypad == null) && (pOverlayPanel == null));
2485 return isContentAttachable;
2489 _SearchBar::ResizeCancelButton(void)
2491 result r = E_SUCCESS;
2493 float horizontalMargin = 0.0f;
2494 float buttonLeftMargin = 0.0f;
2495 float buttonRightMargin = 0.0f;
2496 float buttonMinWidth = 0.0f;
2497 float searchFieldMinWidth = 0.0f;
2498 float buttonVerticalMargin = 0.0f;
2499 float searchBarMinHeight = 0.0f;
2500 float buttonWidth = 0.0f;
2501 float buttonHeight = 0.0f;
2503 FloatRectangle cancelButtonBounds;
2504 FloatRectangle searchBarBounds = GetBoundsF();
2506 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2508 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2509 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2510 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2511 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2512 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2513 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2514 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2515 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2516 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2518 cancelButtonBounds.width = buttonWidth;
2519 cancelButtonBounds.height = buttonHeight;
2521 float buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth +
2522 cancelButtonBounds.width + buttonLeftMargin + buttonRightMargin);
2524 if (searchBarBounds.width < buttonResizableSearchBarWidth)
2526 cancelButtonBounds.width = searchBarBounds.width -(searchFieldMinWidth + buttonLeftMargin
2527 + buttonRightMargin + horizontalMargin);
2530 cancelButtonBounds.x = searchBarBounds.width - cancelButtonBounds.width - buttonRightMargin;
2531 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2533 if (searchBarBounds.height < searchBarMinHeight)
2535 cancelButtonBounds.y = buttonVerticalMargin;
2538 if (cancelButtonBounds.width < buttonMinWidth)
2540 cancelButtonBounds.width = buttonMinWidth;
2543 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2544 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2545 r = __pCancelButton->SetBounds(cancelButtonBounds);
2551 _SearchBar::RecalculateButtonBounds(void)
2553 result r = E_SUCCESS;
2555 float horizontalMargin = 0.0f;
2556 float verticalMargin = 0.0f;
2557 float buttonLeftMargin = 0.0f;
2558 float buttonRightMargin = 0.0f;
2559 float buttonMinWidth = 0.0f;
2560 float searchFieldMinWidth = 0.0f;
2561 float buttonVerticalMargin = 0.0f;
2562 float searchBarMinHeight = 0.0f;
2563 float buttonWidth = 0.0f;
2564 float buttonHeight = 0.0f;
2566 FloatRectangle cancelButtonBounds;
2567 FloatRectangle searchBarBounds = GetBoundsF();
2569 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2571 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2572 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin);
2573 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2574 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2575 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2576 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2577 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2578 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2579 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2580 GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2582 cancelButtonBounds.height = buttonHeight;
2584 FloatRectangle editBounds;
2586 float cancelButtonWidth = 0;
2587 cancelButtonWidth = __pCancelButton->GetTextExtentSizeF() + __pCancelButton->GetRightTouchMarginF() + __pCancelButton->GetLeftTouchMarginF() + __pCancelButton->GetRightMarginF() + __pCancelButton->GetLeftMarginF();
2588 editBounds.x = horizontalMargin;
2589 editBounds.y = verticalMargin;
2591 editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
2593 float searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2.0f);
2594 editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
2596 editBounds.width = searchBarBounds.width - cancelButtonWidth - horizontalMargin - buttonLeftMargin - buttonRightMargin;
2598 if (editBounds.width < searchFieldMinWidth)
2600 editBounds.width = searchFieldMinWidth;
2603 cancelButtonBounds.x = editBounds.width + horizontalMargin + buttonLeftMargin;
2604 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2606 if (searchBarBounds.height < searchBarMinHeight)
2608 cancelButtonBounds.y = buttonVerticalMargin;
2611 float remainingWidth = searchBarBounds.width - editBounds.width - horizontalMargin - buttonLeftMargin - buttonRightMargin;
2613 if (remainingWidth < buttonMinWidth)
2615 cancelButtonBounds.width = buttonMinWidth;
2619 cancelButtonBounds.width = searchBarBounds.width - cancelButtonBounds.x - buttonRightMargin;
2622 cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2623 cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2625 r = __pCancelButton->SetBounds(cancelButtonBounds);
2626 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2627 r = __pEdit->SetBounds(editBounds);
2628 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2634 _SearchBar::GetCurrentStatus(void)
2636 SearchFieldStatus searchFieldStatus = SEARCH_FIELD_STATUS_NORMAL;
2640 if (__pEdit->IsFocused())
2642 searchFieldStatus = SEARCH_FIELD_STATUS_HIGHLIGHTED;
2647 searchFieldStatus = SEARCH_FIELD_STATUS_DISABLED;
2650 return searchFieldStatus;
2654 _SearchBar::SetEditTextFilter(IEditTextFilter* pFilter)
2656 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2657 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2659 __pEdit->SetEditTextFilter(pFilter);
2665 _SearchBar::SendOpaqueCommand(const String& command)
2667 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2668 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2670 __pEdit->SendOpaqueCommand(command);
2675 }}} // Tizen::Ui::Controls