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"
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Ui;
45 using namespace Tizen::Ui::Animations;
46 using namespace Tizen::Base;
47 using namespace Tizen::Base::Runtime;
48 using namespace Tizen::Locales;
50 namespace Tizen { namespace Ui { namespace Controls
53 IMPLEMENT_PROPERTY(_SearchBar);
55 _SearchBar::_SearchBar(void)
56 : __pSearchBarPresenter(null)
57 , __pClippedGroupControl(null)
59 , __pCancelButton(null)
61 , __pContentControl(null)
64 , __isButtonEnabled(true)
65 , __isUsableCancelButton(false)
66 , __isUserContainerBounds(false)
67 , __isCancelActionInProgress(false)
68 , __keypadAction(CORE_KEYPAD_ACTION_SEARCH)
69 , __pBackgroundBitmap(null)
70 , __backgroundColor(Color())
71 , __contentColor(Color())
72 , __pActionEvent(null)
73 , __pKeypadEvent(null)
74 , __pTextBlockEvent(null)
76 , __pSearchBarEvent(null)
77 , __pLanguageEvent(null)
79 for (int i = 0; i < SEARCHBAR_BUTTON_COLOR_MAX; i++)
81 __buttonColor[i] = Color(0);
82 __buttonTextColor[i] = Color(0);
85 for (int i = 0; i < SEARCHBAR_COLOR_MAX; i++)
87 __color[i] = Color(0);
88 __textColor[i] = Color(0);
91 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
94 pContainer->Activate(true);
98 _SearchBar::~_SearchBar(void)
101 delete __pSearchBarPresenter;
102 __pSearchBarPresenter = null;
106 __pEdit->HideKeypad();
108 __pClippedGroupControl->DetachChild(*__pEdit);
116 __pClippedGroupControl->DetachChild(*__pCancelButton);
118 delete __pCancelButton;
119 __pCancelButton = null;
122 if (__pClippedGroupControl)
124 DetachChild(*__pClippedGroupControl);
126 delete __pClippedGroupControl;
127 __pClippedGroupControl = null;
132 DetachChild(*__pContainer);
140 delete __pActionEvent;
141 __pActionEvent = null;
146 delete __pKeypadEvent;
147 __pKeypadEvent = null;
150 if (__pTextBlockEvent)
152 delete __pTextBlockEvent;
153 __pTextBlockEvent = null;
162 if (__pSearchBarEvent)
164 delete __pSearchBarEvent;
165 __pSearchBarEvent = null;
168 delete __pBackgroundBitmap;
169 __pBackgroundBitmap = null;
173 _SearchBar::CreateSearchBarN(void)
175 _SearchBar* pSearchBar = new (std::nothrow) _SearchBar;
176 SysTryReturn(NID_UI_CTRL, pSearchBar, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
177 if (GetLastResult() != E_SUCCESS)
183 pSearchBar->AcquireHandle();
189 _SearchBar::Initialize(bool enableSearchBarButton, CoreKeypadAction keypadAction)
191 result r = E_SUCCESS;
193 // Setting Button color
194 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_NORMAL, __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
195 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_PRESSED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
196 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_HIGHLIGHTED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
197 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_DISABLED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
199 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_NORMAL, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
200 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_PRESSED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
201 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_HIGHLIGHTED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
202 GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_DISABLED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
204 GET_COLOR_CONFIG(SEARCHBAR::CONTENT_AREA_BG_NORMAL, __contentColor);
206 for (int i = 0; i < SEARCHBAR_COLOR_MAX; i++)
210 case SEARCH_FIELD_STATUS_DISABLED:
211 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_DISABLED, __color[i]);
212 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_DISABLED, __textColor[i]);
215 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
216 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]);
217 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_HIGHLIGHTED, __textColor[i]);
220 GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]);
221 GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_NORMAL, __textColor[i]);
226 __isUsableCancelButton = enableSearchBarButton;
227 __keypadAction = keypadAction;
229 GetVisualElement()->SetClipChildrenEnabled(false);
231 r = CreateClippedGroupControl();
232 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
233 "[E_SYSTEM] A system error has occurred. The construction of parent control for clipped group control failed.");
235 r = CreateSearchField();
236 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
237 "[E_SYSTEM] A system error has occurred. The edit construction failed.");
238 r = CreateCancelButton();
239 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
240 "[E_SYSTEM] A system error has occurred. The cancel button construction failed.");
243 r = CreateContentsArea();
244 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
245 "[E_SYSTEM] A system error has occurred. The construction of parent for content failed.");
247 _SearchBarPresenter* pPresenter = new (std::nothrow) _SearchBarPresenter;
248 SysTryReturn(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
250 r = pPresenter->Construct(*this);
251 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
253 r = pPresenter->Install();
254 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
256 __pSearchBarPresenter = pPresenter;
268 _SearchBar::CreateSearchField(void)
270 result r = E_SUCCESS;
272 Rectangle editBounds;
273 int horizontalMargin = 0;
274 int verticalMargin = 0;
275 int iconHorizontalMargin = 0;
276 int textHorizontalMargin = 0;
279 int searchFieldMinWidth = 0;
280 int searchFieldMinHeight = 0;
282 Rectangle searchBarBounds = GetBounds();
283 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
284 _AccessibilityContainer* pSearchBarContainer = null;
286 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
287 GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin);
288 GET_SHAPE_CONFIG(SEARCHBAR::ICON_HORIZONTAL_MARGIN, orientation, iconHorizontalMargin);
289 GET_SHAPE_CONFIG(SEARCHBAR::ICON_WIDTH, orientation, iconWidth);
290 GET_SHAPE_CONFIG(SEARCHBAR::TEXT_HORIZONTAL_MARGIN, orientation, textHorizontalMargin);
291 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
292 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_HEIGHT, orientation, searchFieldMinHeight);
294 editBounds.x = horizontalMargin;
295 editBounds.y = verticalMargin;
296 editBounds.width = searchBarBounds.width - (editBounds.x * 2);
297 editBounds.height = searchBarBounds.height - (editBounds.y * 2);
299 editBounds.width = (editBounds.width > searchFieldMinWidth) ? editBounds.width : searchFieldMinWidth;
300 editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
303 __pEdit = _Edit::CreateEditN();
305 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
307 r = __pEdit->Initialize(EDIT_STYLE_NORMAL | EDIT_STYLE_SINGLE_LINE | EDIT_STYLE_CLEAR | EDIT_STYLE_NOSCROLL, INPUT_STYLE_OVERLAY,
308 SEARCHBAR_TEXT_LENGTH_MAX);
309 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
311 __pEdit->SetKeypadCommandButtonVisible(false);
312 __pEdit->SetBounds(editBounds);
314 __pEdit->AddKeypadEventListener(*this);
315 __pEdit->AddTextBlockEventListener(*this);
316 __pEdit->AddTextEventListener(*this);
318 GET_SHAPE_CONFIG(SEARCHBAR::EDIT_TEXT_SIZE, orientation, textSize);
319 __pEdit->SetTextSize(textSize);
321 __pEdit->SetHorizontalMargin(iconHorizontalMargin + iconWidth + textHorizontalMargin, EDIT_TEXT_LEFT_MARGIN);
322 __pEdit->SetHorizontalMargin(textHorizontalMargin, EDIT_TEXT_RIGHT_MARGIN);
323 __pEdit->SetLimitLength(SEARCHBAR_TEXT_LENGTH_MAX);
325 for (int status = 0; status < SEARCHBAR_COLOR_MAX; status++)
327 EditStatus editStatus = ConvertSearchBarStatus((SearchFieldStatus) status);
328 __pEdit->SetColor(editStatus, __color[status]);
331 __pEdit->SetTextColor(EDIT_TEXT_COLOR_NORMAL, __textColor[SEARCH_FIELD_STATUS_NORMAL]);
332 __pEdit->SetTextColor(EDIT_TEXT_COLOR_DISABLED, __textColor[SEARCH_FIELD_STATUS_DISABLED]);
333 __pEdit->SetTextColor(EDIT_TEXT_COLOR_HIGHLIGHTED, __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
335 __pEdit->ReplaceDefaultBackgroundBitmapForSearchBar();
337 __pEdit->SetKeypadAction(__keypadAction);
339 r = __pClippedGroupControl->AttachChild(*__pEdit);
340 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
341 "[E_SYSTEM] A system error has occurred. Failed to attach edit as child.");
343 if(likely(!(_AccessibilityManager::IsActivated())))
348 pSearchBarContainer = GetAccessibilityContainer();
349 if (pSearchBarContainer)
351 _AccessibilityContainer* pSearchFieldContainer = __pEdit->GetAccessibilityContainer();
352 if (pSearchFieldContainer)
354 pSearchBarContainer->AddChildContainer(*pSearchFieldContainer);
368 _SearchBar::CreateCancelButton(void)
370 result r = E_SUCCESS;
373 String cancelButtonText;
375 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
376 _AccessibilityContainer* pSearchBarContainer = null;
378 __pCancelButton = _Button::CreateButtonN();
380 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
382 r = ResizeCancelButton();
383 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
385 GET_STRING_CONFIG(IDS_COM_SK_CANCEL, cancelButtonText);
386 r = __pCancelButton->SetText(cancelButtonText);
387 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
389 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_TEXT_SIZE, orientation, textSize);
390 r = __pCancelButton->SetTextSize(textSize);
391 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
393 __pCancelButton->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
394 __pCancelButton->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
396 r = __pCancelButton->SetActionId(__actionId);
397 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
399 r = __pCancelButton->AddActionEventListener(*this);
400 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
402 __pCancelButton->SetVisibleState(false);
404 for (int status = 0; status < SEARCHBAR_BUTTON_COLOR_MAX; status++)
406 _ButtonStatus buttonStatus = ConvertSearchBarButtonStatus((SearchBarButtonStatus) status);
408 r = __pCancelButton->SetColor(buttonStatus, __buttonColor[status]);
409 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
411 r = __pCancelButton->SetTextColor(buttonStatus, __buttonTextColor[status]);
412 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
415 r = __pClippedGroupControl->AttachChild(*__pCancelButton);
416 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
417 "[E_SYSTEM] A system error has occurred. Failed to attach button as child.");
419 if(likely(!(_AccessibilityManager::IsActivated())))
424 pSearchBarContainer = GetAccessibilityContainer();
425 if (pSearchBarContainer)
427 _AccessibilityContainer* pButtonContainer = __pCancelButton->GetAccessibilityContainer();
428 if (pButtonContainer)
430 pSearchBarContainer->AddChildContainer(*pButtonContainer);
437 delete __pCancelButton;
438 __pCancelButton = null;
444 _SearchBar::CreateContentsArea(void)
446 result r = E_SUCCESS;
448 __pContainer = _Control::CreateControlN();
451 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
453 __pContainer->SetVisibleState(false);
455 r = AttachChild(*__pContainer);
456 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
457 "[E_SYSTEM] A system error has occurred. Failed to attach the parent of content.");
469 _SearchBar::SetContentsArea(void)
471 if (__isUserContainerBounds)
476 Dimension screenSize = _ControlManager::GetInstance()->GetScreenSize();
477 int width = screenSize.width;
478 int height = screenSize.height;
479 _Control* pParent = GetParentForm();
482 width = pParent->GetClientBounds().width;
483 height = pParent->GetClientBounds().height;
486 __contentAreaBounds = GetBounds();
487 __contentAreaBounds.x = 0;
488 __contentAreaBounds.y = __contentAreaBounds.height;
489 __contentAreaBounds.width = width;
490 __contentAreaBounds.height = height - __contentAreaBounds.height;
494 result r = E_SUCCESS;
495 r = __pContainer->SetBounds(__contentAreaBounds);
496 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
500 _Form* pForm = dynamic_cast<_Form*>(pParent);
503 pForm->Invalidate(true);
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_MAX_EXCEEDED, E_MAX_EXCEEDED,
803 "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
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, textLength >= index, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
833 "[E_OUT_OF_RANGE] index(%d) is out of range textLength(%d).", index, textLength);
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);
852 limitLength = __pEdit->GetTextLimitLength();
853 textLength = __pEdit->GetTextLength() + text.GetLength();
855 SysTryReturn(NID_UI_CTRL, limitLength > textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
856 "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
857 SysTryReturn(NID_UI_CTRL, textLength >= index, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
858 "[E_OUT_OF_RANGE] index(%d) is out of range textLength(%d).", index, textLength);
860 return __pEdit->InsertTextAt(index, text);
864 _SearchBar::DeleteCharacterAt(int index)
866 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
867 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
868 SysTryReturn(NID_UI_CTRL, index > -1, E_INVALID_ARG, E_INVALID_ARG,
869 "[E_INVALID_ARG] Invalid argument(s) is used. index = %d", index);
872 textLength = __pEdit->GetTextLength();
874 SysTryReturn(NID_UI_CTRL, textLength > index, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
875 "[E_OUT_OF_RANGE] index(%d) is out of range. textLength(%d)", index, textLength);
877 return __pEdit->DeleteCharacterAt(index);
881 _SearchBar::Clear(void)
883 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
884 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
886 return __pEdit->ClearText();
890 _SearchBar::GetTextLength(void) const
892 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
893 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
895 return __pEdit->GetTextLength();
899 _SearchBar::GetText(void) const
901 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
902 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
904 return __pEdit->GetText();
908 _SearchBar::GetText(int start, int end) const
910 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
911 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
913 return __pEdit->GetText(start, end);
917 _SearchBar::GetLimitLength(void) const
919 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
920 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
922 return __pEdit->GetTextLimitLength();
926 _SearchBar::SetLimitLength(int limitLength)
928 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
929 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
930 SysTryReturn(NID_UI_CTRL, limitLength > 0, E_INVALID_ARG, E_INVALID_ARG,
931 "[E_INVALID_ARG] Invalid argument(s) is used.limitLength = %d", limitLength);
933 String tempString = GetText();
935 int textLength = tempString.GetLength();
936 SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_INVALID_ARG, E_INVALID_ARG,
937 "[E_INVALID_ARG] Invalid argument(s) is used. limitLength = %d, textLength = %d", limitLength, textLength);
939 result r = __pEdit->SetLimitLength(limitLength);
940 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
942 r = SetText(tempString);
943 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
949 _SearchBar::ShowKeypad(void) const
951 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
952 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
954 SearchBarMode mode = __pSearchBarPresenter->GetMode();
955 SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_INVALID_STATE, E_INVALID_STATE,
956 "[E_INVALID_STATE] The SearchBar is currently in Normal mode.");
957 return __pEdit->ShowKeypad();
961 _SearchBar::HideKeypad(void)
963 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
964 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
966 SearchBarMode mode = __pSearchBarPresenter->GetMode();
967 SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_SYSTEM, E_SYSTEM,
968 "[E_SYSTEM] A system error has occurred. The SearchBar is currently in Normal mode.");
970 result r = __pEdit->HideKeypad();
978 _SearchBar::GetSearchFieldTextSize(void) const
980 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
981 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
983 return __pEdit->GetTextSize();
987 _SearchBar::SetSearchFieldTextSize(int size)
989 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
990 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
992 return __pEdit->SetTextSize(size);
996 _SearchBar::GetBlockRange(int& start, int& end) const
998 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
999 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1001 int startIndex = -1;
1004 __pEdit->GetBlockRange(startIndex, endIndex);
1005 SysTryReturn(NID_UI_CTRL, (startIndex > -1 && endIndex > -1), E_SYSTEM, E_SYSTEM,
1006 "[E_SYSTEM] A system error has occurred. Failed to get text block range.");
1015 _SearchBar::ReleaseBlock(void)
1017 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1018 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1020 result r = E_SUCCESS;
1025 r = GetBlockRange(start, end);
1026 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1028 return __pEdit->ReleaseTextBlock();
1032 _SearchBar::SetBlockRange(int start, int end)
1034 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1035 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1037 result r = E_SUCCESS;
1040 textLength = __pEdit->GetTextLength();
1041 SysTryReturn(NID_UI_CTRL, (textLength > start && textLength > end), E_INVALID_ARG, E_INVALID_ARG,
1042 "[E_INVALID_ARG] Invalid argument(s) is used. textLength = %d, start = %d, end = %d", start, end);
1043 SysTryReturn(NID_UI_CTRL, (start <= end && start >= 0), E_INVALID_ARG, E_INVALID_ARG,
1044 "[E_INVALID_ARG] Invalid argument(s) is used. start = %d, end = %d", start, end);
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;
1071 r = GetBlockRange(start, end);
1072 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1074 for (int index = start; index < end; index++)
1076 r = __pEdit->DeleteCharacterAt(start);
1077 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1084 _SearchBar::GetColor(void) const
1086 Variant backgroundColor = GetProperty("color");
1088 return backgroundColor.ToColor();
1092 _SearchBar::GetSearchFieldColor(SearchFieldStatus status) const
1094 Variant searchFieldColor;
1098 case SEARCH_FIELD_STATUS_NORMAL:
1099 searchFieldColor = GetProperty("searchFieldNormalColor");
1101 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1102 searchFieldColor = GetProperty("searchFieldHighlightedColor");
1104 case SEARCH_FIELD_STATUS_DISABLED:
1105 searchFieldColor = GetProperty("searchFieldDisabledColor");
1111 return searchFieldColor.ToColor();
1116 _SearchBar::GetSearchFieldTextColor(SearchFieldStatus status) const
1118 Variant searchFieldTextColor;
1122 case SEARCH_FIELD_STATUS_NORMAL:
1123 searchFieldTextColor = GetProperty("searchFieldNormalTextColor");
1125 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1126 searchFieldTextColor = GetProperty("searchFieldHighlightedTextColor");
1128 case SEARCH_FIELD_STATUS_DISABLED:
1129 searchFieldTextColor = GetProperty("searchFieldDisabledTextColor");
1135 return searchFieldTextColor.ToColor();
1140 _SearchBar::SetBackgroundBitmap(const Bitmap& bitmap)
1142 Bitmap* pNewBitmap = _BitmapImpl::CloneN(bitmap);
1143 SysTryReturn(NID_UI_CTRL, pNewBitmap, E_SYSTEM, E_SYSTEM,
1144 "[E_SYSTEM] A system error has occurred. The creation of bitmap failed.");
1146 delete __pBackgroundBitmap;
1147 __pBackgroundBitmap = null;
1149 __pBackgroundBitmap = pNewBitmap;
1155 _SearchBar::GetBackgroundBitmap(void) const
1157 return __pBackgroundBitmap;
1161 _SearchBar::SetColor(const Color& color)
1163 return SetProperty("color", Variant(color));
1167 _SearchBar::SetSearchFieldColor(SearchFieldStatus status, const Color& color)
1169 result r = E_SUCCESS;
1173 case SEARCH_FIELD_STATUS_NORMAL:
1174 r = SetProperty("searchFieldNormalColor", Variant(color));
1176 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1177 r = SetProperty("searchFieldHighlightedColor", Variant(color));
1179 case SEARCH_FIELD_STATUS_DISABLED:
1180 r = SetProperty("searchFieldDisabledColor", Variant(color));
1191 _SearchBar::SetSearchFieldTextColor(SearchFieldStatus status, const Color& color)
1193 result r = E_SUCCESS;
1197 case SEARCH_FIELD_STATUS_NORMAL:
1198 r = SetProperty("searchFieldNormalTextColor", Variant(color));
1200 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1201 r = SetProperty("searchFieldHighlightedTextColor", Variant(color));
1203 case SEARCH_FIELD_STATUS_DISABLED:
1204 r = SetProperty("searchFieldDisabledTextColor", Variant(color));
1215 _SearchBar::GetGuideText(void) const
1217 SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
1218 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1220 return __pEdit->GetGuideText();
1224 _SearchBar::SetGuideText(const String& guideText)
1226 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1227 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1229 __pEdit->SetGuideText(guideText);
1235 _SearchBar::GetGuideTextColor(void) const
1237 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1238 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1240 return __pEdit->GetGuideTextColor();
1244 _SearchBar::SetGuideTextColor(const Color& color)
1246 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1247 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1249 return __pEdit->SetGuideTextColor(color);
1253 _SearchBar::GetCursorPosition(void) const
1255 SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
1256 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1258 return __pEdit->GetCursorPosition();
1262 _SearchBar::SetCursorPosition(int index)
1264 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1265 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1266 SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1267 "[E_OUT_OF_RANGE] index(%d) is out of range.", GetErrorMessage(E_OUT_OF_RANGE), index);
1269 int textLength = -1;
1270 textLength = __pEdit->GetTextLength();
1272 SysTryReturn(NID_UI_CTRL, (index > -1 && index <= textLength), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1273 "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
1275 return __pEdit->SetCursorPosition(index);
1279 _SearchBar::IsLowerCaseModeEnabled(void) const
1281 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1282 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1284 return __pEdit->IsLowerCaseModeEnabled();
1288 _SearchBar::SetLowerCaseModeEnabled(bool enable)
1290 SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
1291 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1293 __pEdit->SetLowerCaseModeEnabled(enable);
1297 _SearchBar::GetEllipsisPosition(void) const
1299 SysTryReturn(NID_UI_CTRL, __pEdit, ELLIPSIS_POSITION_START, ELLIPSIS_POSITION_START,
1300 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1302 return __pEdit->GetEllipsisPosition();
1306 _SearchBar::SetEllipsisPosition(EllipsisPosition position)
1308 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1309 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1310 __pEdit->SetEllipsisPosition(position);
1316 _SearchBar::GetKeypadAction(void) const
1318 return __keypadAction;
1322 _SearchBar::IsTextPredictionEnabled(void) const
1324 SysTryReturn(NID_UI_CTRL, __pEdit, false, E_SYSTEM,
1325 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1326 return __pEdit->IsTextPredictionEnabled();
1330 _SearchBar::SetTextPredictionEnabled(bool enable)
1332 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1333 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1334 return __pEdit->SetTextPredictionEnabled(enable);
1338 _SearchBar::SetCurrentLanguage(LanguageCode languageCode)
1340 return __pEdit->SetCurrentLanguage(languageCode);
1344 _SearchBar::GetCurrentLanguage(LanguageCode& language) const
1346 return __pEdit->GetCurrentLanguage(language);
1350 _SearchBar::AddActionEventListener(const _IActionEventListener& listener)
1352 result r = E_SUCCESS;
1354 if (__pActionEvent == null)
1356 __pActionEvent = _ActionEvent::CreateInstanceN(*this);
1357 r = GetLastResult();
1358 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1360 __pActionEvent->AddListener(listener);
1367 _SearchBar::RemoveActionEventListener(const _IActionEventListener& listener)
1369 SysTryReturn(NID_UI_CTRL, __pActionEvent, E_SYSTEM, E_SYSTEM,
1370 "[E_SYSTEM] A system error has occurred. The action event instance is null.");
1371 result r = E_SUCCESS;
1373 r = __pActionEvent->RemoveListener(listener);
1374 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1380 _SearchBar::AddKeypadEventListener(const _IKeypadEventListener& listener)
1382 result r = E_SUCCESS;
1384 if (__pKeypadEvent == null)
1386 __pKeypadEvent = _KeypadEvent::CreateInstanceN(*this);
1387 r = GetLastResult();
1388 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1390 r = __pKeypadEvent->AddListener(listener);
1391 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1398 _SearchBar::RemoveKeypadEventListener(const _IKeypadEventListener& listener)
1400 SysTryReturn(NID_UI_CTRL, __pKeypadEvent, E_SYSTEM, E_SYSTEM,
1401 "[E_SYSTEM] A system error has occurred. The keypad event instance is null.");
1402 result r = E_SUCCESS;
1404 r = __pKeypadEvent->RemoveListener(listener);
1405 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1411 _SearchBar::AddTextBlockEventListener(const _ITextBlockEventListener& listener)
1413 result r = E_SUCCESS;
1415 if (__pTextBlockEvent == null)
1417 __pTextBlockEvent = _TextBlockEvent::CreateInstanceN(*this);
1418 r = GetLastResult();
1419 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1421 r = __pTextBlockEvent->AddListener(listener);
1422 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1430 _SearchBar::RemoveTextBlockEventListener(const _ITextBlockEventListener& listener)
1432 SysTryReturn(NID_UI_CTRL, __pTextBlockEvent, E_SYSTEM, E_SYSTEM,
1433 "[E_SYSTEM] A system error has occurred. The text block event instance is null.");
1434 result r = E_SUCCESS;
1436 r = __pTextBlockEvent->RemoveListener(listener);
1437 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1444 _SearchBar::AddTextEventListener(const _ITextEventListener& listener)
1446 result r = E_SUCCESS;
1448 if (__pTextEvent == null)
1450 __pTextEvent = _TextEvent::CreateInstanceN(*this);
1451 r = GetLastResult();
1452 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1454 r = __pTextEvent->AddListener(listener);
1455 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1462 _SearchBar::RemoveTextEventListener(const _ITextEventListener& listener)
1464 SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM,
1465 "[E_SYSTEM] A system error has occurred. The text event instance is null.");
1466 result r = E_SUCCESS;
1468 r = __pTextEvent->RemoveListener(listener);
1469 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1475 _SearchBar::AddSearchBarEventListener(const _ISearchBarEventListener& listener)
1477 result r = E_SUCCESS;
1479 if (__pSearchBarEvent == null)
1481 __pSearchBarEvent = _SearchBarEvent::CreateInstanceN(*this);
1482 r = GetLastResult();
1483 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1485 r = __pSearchBarEvent->AddListener(listener);
1486 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1493 _SearchBar::RemoveSearchBarEventListener(const _ISearchBarEventListener& listener)
1495 SysTryReturn(NID_UI_CTRL, __pSearchBarEvent, E_SYSTEM, E_SYSTEM,
1496 "[E_SYSTEM] A system error has occurred. The searchbar event instance is null.");
1497 result r = E_SUCCESS;
1499 r = __pSearchBarEvent->RemoveListener(listener);
1500 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1506 _SearchBar::AddLanguageEventListener(const _ILanguageEventListener& listener)
1508 result r = E_SUCCESS;
1510 if (__pLanguageEvent == null)
1512 __pLanguageEvent = _LanguageEvent::CreateInstanceN(*this);
1513 r = GetLastResult();
1514 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1516 r = __pLanguageEvent->AddListener(listener);
1517 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1524 _SearchBar::RemoveLanguageEventListener(const _ILanguageEventListener& listener)
1526 SysTryReturn(NID_UI_CTRL, __pLanguageEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.");
1527 result r = E_SUCCESS;
1529 __pLanguageEvent->RemoveListener(listener);
1530 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1536 _SearchBar::OnBoundsChanged(void)
1538 if (__pSearchBarPresenter != null)
1540 __pSearchBarPresenter->OnBoundsChanged();
1546 _SearchBar::OnDraw(void)
1548 __pSearchBarPresenter->Draw();
1552 _UiTouchEventDelivery
1553 _SearchBar::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1555 _Edit* pEdit = dynamic_cast <_Edit*>(const_cast <_Control*>(&source));
1558 return _UI_TOUCH_EVENT_DELIVERY_YES;
1561 if (GetMode() == SEARCH_BAR_MODE_INPUT)
1563 return _UI_TOUCH_EVENT_DELIVERY_YES;
1566 SetMode(SEARCH_BAR_MODE_INPUT);
1568 return _UI_TOUCH_EVENT_DELIVERY_YES;
1572 _SearchBar::OnActionPerformed(const _Control& source, int actionId)
1574 if (__actionId == actionId)
1576 __isCancelActionInProgress = true;
1577 SetMode(SEARCH_BAR_MODE_NORMAL);
1581 IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(__actionId);
1582 result r = GetLastResult();
1583 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1585 __pActionEvent->Fire(*pEventArg);
1587 __isCancelActionInProgress = false;
1594 _SearchBar::OnKeypadWillOpen(void)
1598 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CREATED);
1599 result r = GetLastResult();
1600 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1602 __pKeypadEvent->Fire(*pEventArg);
1608 _SearchBar::OnKeypadOpened(void)
1612 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_OPEN);
1613 result r = GetLastResult();
1614 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1616 __pKeypadEvent->Fire(*pEventArg);
1622 _SearchBar::OnKeypadClosed(void)
1626 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CLOSE);
1627 result r = GetLastResult();
1628 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1630 __pKeypadEvent->Fire(*pEventArg);
1636 _SearchBar::OnKeypadBoundsChanged(void)
1640 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1641 result r = GetLastResult();
1642 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1644 __pKeypadEvent->Fire(*pEventArg);
1650 _SearchBar::OnKeypadActionPerformed(CoreKeypadAction keypadAction)
1654 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(keypadAction, CORE_KEYPAD_EVENT_STATUS_ENTERACTION);
1655 result r = GetLastResult();
1656 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1658 __pKeypadEvent->Fire(*pEventArg);
1663 // TextBlock callbacks
1665 _SearchBar::OnTextBlockSelected(_Control& source, int start, int end)
1667 if (__pTextBlockEvent)
1669 IEventArg* pEventArg = _TextBlockEvent::CreateTextBlockEventArgN(start, end);
1670 result r = GetLastResult();
1671 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1673 __pTextBlockEvent->Fire(*pEventArg);
1680 _SearchBar::OnTextValueChanged(const _Control& source)
1682 if (!__isCancelActionInProgress)
1684 SetContentDimming();
1685 if (__pTextEvent != null)
1687 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CHANGED);
1688 result r = GetLastResult();
1689 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1691 __pTextEvent->Fire(*pEventArg);
1698 _SearchBar::OnTextValueChangeCanceled(const _Control& source)
1700 if (__pTextEvent != null)
1702 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CANCELED);
1703 result r = GetLastResult();
1704 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1706 __pTextEvent->Fire(*pEventArg);
1712 _SearchBar::OnAttachedToMainTree(void)
1720 _SearchBar::OnFontChanged(Font* pFont)
1722 __pCancelButton->SetFont(pFont->GetFaceName());
1723 __pEdit->SetFont(*pFont);
1728 _SearchBar::OnFontInfoRequested(unsigned long& style, int& size)
1730 style = FONT_STYLE_PLAIN;
1731 size = __pCancelButton->GetTextSize();
1737 _SearchBar::OnFocusGained(const _Control& source)
1739 SetMode(SEARCH_BAR_MODE_INPUT);
1740 __pEdit->SetFocused();
1745 _SearchBar::OnFocusLost(const _Control& source)
1751 _SearchBar::GetParentForm(void) const
1753 _Form* pForm = null;
1754 _Control* pControlCore = GetParent();
1758 if (pControlCore == null)
1760 SysLog(NID_UI_CTRL,"[E_SYSTEM] The parent form is null.");
1765 pForm = dynamic_cast <_Form*>(pControlCore);
1772 pControlCore = pControlCore->GetParent();
1775 return pControlCore;
1779 _SearchBar::GetSearchBarButton(void) const
1781 return __pCancelButton;
1785 _SearchBar::GetSearchField(void)
1791 _SearchBar::GetSearchBarContainer(void) const
1793 return __pContainer;
1797 _SearchBar::GetClippedGroupControl(void) const
1799 return __pClippedGroupControl;
1803 _SearchBar::IsUsableCancelButton(void) const
1805 return __isUsableCancelButton;
1809 _SearchBar::ConvertSearchBarStatus(SearchFieldStatus status)
1811 EditStatus editStatus = EDIT_STATUS_NORMAL;
1814 case SEARCH_FIELD_STATUS_NORMAL:
1815 editStatus = EDIT_STATUS_NORMAL;
1818 case SEARCH_FIELD_STATUS_DISABLED:
1819 editStatus = EDIT_STATUS_DISABLED;
1822 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1823 editStatus = EDIT_STATUS_HIGHLIGHTED;
1833 _SearchBar::ConvertSearchBarButtonStatus(SearchBarButtonStatus status)
1835 _ButtonStatus buttonStatus = _BUTTON_STATUS_NORMAL;
1839 case SEARCH_BAR_BUTTON_STATUS_NORMAL:
1840 buttonStatus = _BUTTON_STATUS_NORMAL;
1843 case SEARCH_BAR_BUTTON_STATUS_PRESSED:
1844 buttonStatus = _BUTTON_STATUS_PRESSED;
1847 case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
1848 buttonStatus = _BUTTON_STATUS_HIGHLIGHTED;
1851 case SEARCH_BAR_BUTTON_STATUS_DISABLED:
1852 buttonStatus = _BUTTON_STATUS_DISABLED;
1858 return buttonStatus;
1862 _SearchBar::SendSearchBarEvent(_SearchBarEventStatus status)
1864 result r = E_SUCCESS;
1865 if (__pSearchBarEvent)
1867 IEventArg* pEventArg = _SearchBarEvent::CreateSearchBarEventArgN(status);
1868 r = GetLastResult();
1869 SysTryReturn(NID_UI_CTRL, pEventArg, r, r, "[%s] Propagating.", GetErrorMessage(r));
1871 if (IsContentAreaVisible() == false)
1873 SetContentAreaVisible(false);
1876 __pSearchBarEvent->Fire(*pEventArg);
1883 _SearchBar::SetHeaderVisibleState(bool visible)
1885 if (__pSearchBarPresenter != null)
1887 __pSearchBarPresenter->SetHeaderVisibleState(visible);
1893 _SearchBar::SetPropertyButtonActionId(const Variant& actionId)
1895 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1896 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1897 SysTryReturn(NID_UI_CTRL, actionId.ToInt() > -1, E_INVALID_ARG, E_INVALID_ARG,
1898 "[E_INVALID_ARG] Invalid argument(s) is used. actionId.ToInt() = %d", actionId.ToInt());
1900 result r = E_SUCCESS;
1902 r = __pCancelButton->SetPropertyActionId(actionId);
1903 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1904 "[%s] A system error has occurred. Failed to set actionId.", GetErrorMessage(E_SYSTEM));
1906 __actionId = actionId.ToInt();
1912 _SearchBar::GetPropertyButtonActionId(void) const
1914 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(-1), E_SYSTEM,
1915 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1917 return Variant(__actionId);
1921 _SearchBar::SetPropertyButtonDisabledColor(const Variant& color)
1923 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1924 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1926 result r = E_SUCCESS;
1928 r = __pCancelButton->SetPropertyDisabledColor(color);
1929 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1930 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
1932 __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = color.ToColor();
1938 _SearchBar::GetPropertyButtonDisabledColor(void) const
1940 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
1941 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1943 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
1947 _SearchBar::SetPropertyButtonHighlightedColor(const Variant& color)
1949 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1950 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1952 result r = E_SUCCESS;
1954 r = __pCancelButton->SetPropertyHighlightedColor(color);
1955 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1956 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
1958 __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
1964 _SearchBar::GetPropertyButtonHighlightedColor(void) const
1966 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
1967 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1969 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
1973 _SearchBar::SetPropertyButtonNormalColor(const Variant& color)
1975 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1976 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1978 result r = E_SUCCESS;
1980 r = __pCancelButton->SetPropertyNormalColor(color);
1981 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1982 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
1984 __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = color.ToColor();
1990 _SearchBar::GetPropertyButtonNormalColor(void) const
1992 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
1993 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1995 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
1999 _SearchBar::SetPropertyButtonPressedColor(const Variant& color)
2001 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2002 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2004 result r = E_SUCCESS;
2006 r = __pCancelButton->SetPropertyPressedColor(color);
2007 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2008 "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2010 __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = color.ToColor();
2016 _SearchBar::GetPropertyButtonPressedColor(void) const
2018 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2019 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2021 return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2025 _SearchBar::SetPropertyButtonDisabledTextColor(const Variant& textColor)
2027 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2028 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2030 result r = E_SUCCESS;
2032 r = __pCancelButton->SetPropertyDisabledTextColor(textColor);
2033 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2034 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2036 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = textColor.ToColor();
2042 _SearchBar::GetPropertyButtonDisabledTextColor(void) const
2044 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2045 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2047 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2051 _SearchBar::SetPropertyButtonHighlightedTextColor(const Variant& textColor)
2053 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2054 "[E_SYSTEM]] A system error has occurred. The cancel button instance is null.");
2056 result r = E_SUCCESS;
2058 r = __pCancelButton->SetPropertyHighlightedTextColor(textColor);
2059 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2060 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2062 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = textColor.ToColor();
2068 _SearchBar::GetPropertyButtonHighlightedTextColor(void) const
2070 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2071 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2073 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2077 _SearchBar::SetPropertyButtonNormalTextColor(const Variant& textColor)
2079 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2080 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2082 result r = E_SUCCESS;
2084 r = __pCancelButton->SetPropertyNormalTextColor(textColor);
2085 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2086 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2088 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = textColor.ToColor();
2094 _SearchBar::GetPropertyButtonNormalTextColor(void) const
2096 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2097 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2099 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2103 _SearchBar::SetPropertyButtonPressedTextColor(const Variant& textColor)
2105 SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2106 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2108 result r = E_SUCCESS;
2110 r = __pCancelButton->SetPropertyPressedTextColor(textColor);
2111 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2112 "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2114 __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = textColor.ToColor();
2120 _SearchBar::GetPropertyButtonPressedTextColor(void) const
2122 SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2123 "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2125 return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2129 _SearchBar::SetPropertySearchFieldDisabledColor(const Variant& color)
2131 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2132 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2134 result r = E_SUCCESS;
2136 r = __pEdit->SetPropertyDisabledColor(color);
2137 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2138 "[E_SYSTEM] A system error has occurred. Failed to set the edit disabled color.");
2140 __color[SEARCH_FIELD_STATUS_DISABLED] = color.ToColor();
2146 _SearchBar::GetPropertySearchFieldDisabledColor(void) const
2148 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2149 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2151 return Variant(__color[SEARCH_FIELD_STATUS_DISABLED]);
2155 _SearchBar::SetPropertySearchFieldHighlightedColor(const Variant& color)
2157 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2158 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2160 result r = E_SUCCESS;
2162 r = __pEdit->SetPropertyHighlightedColor(color);
2163 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2164 "[E_SYSTEM] A system error has occurred. Failed to set the edit highlighted color.");
2166 __color[SEARCH_FIELD_STATUS_HIGHLIGHTED] = color.ToColor();
2172 _SearchBar::GetPropertySearchFieldHighlightedColor(void) const
2174 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2175 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2177 return Variant(__color[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2181 _SearchBar::SetPropertySearchFieldNormalColor(const Variant& color)
2183 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2184 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2186 result r = E_SUCCESS;
2188 r = __pEdit->SetPropertyNormalColor(color);
2189 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2190 "[E_SYSTEM] A system error has occurred. Failed to set edit normal color.");
2192 __color[SEARCH_FIELD_STATUS_NORMAL] = color.ToColor();
2198 _SearchBar::GetPropertySearchFieldNormalColor(void) const
2200 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2201 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2203 return Variant(__color[SEARCH_FIELD_STATUS_NORMAL]);
2207 _SearchBar::SetPropertySearchFieldDisabledTextColor(const Variant& textColor)
2209 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2210 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2212 result r = E_SUCCESS;
2214 r = __pEdit->SetPropertyDisabledTextColor(textColor);
2215 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2216 "[E_SYSTEM] A system error has occurred. Failed to set edit disabled text color.");
2218 __textColor[SEARCH_FIELD_STATUS_DISABLED] = textColor.ToColor();
2224 _SearchBar::GetPropertySearchFieldDisabledTextColor(void) const
2226 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2227 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2229 return Variant(__textColor[SEARCH_FIELD_STATUS_DISABLED]);
2233 _SearchBar::SetPropertySearchFieldHighlightedTextColor(const Variant& textColor)
2235 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2236 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2238 result r = E_SUCCESS;
2240 r = __pEdit->SetPropertyHighlightedTextColor(textColor);
2241 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2242 "[E_SYSTEM] A system error has occurred. Failed to set edit highlighted text color.");
2244 __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED] = textColor.ToColor();
2250 _SearchBar::GetPropertySearchFieldHighlightedTextColor(void) const
2252 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2253 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2255 return Variant(__textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2259 _SearchBar::SetPropertySearchFieldNormalTextColor(const Variant& textColor)
2261 SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2262 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2264 result r = E_SUCCESS;
2266 r = __pEdit->SetPropertyNormalTextColor(textColor);
2267 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2268 "[E_SYSTEM] A system error has occurred. Failed to set edit normal text color.");
2270 __textColor[SEARCH_FIELD_STATUS_NORMAL] = textColor.ToColor();
2276 _SearchBar::GetPropertySearchFieldNormalTextColor(void) const
2278 SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2279 "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2281 return Variant(__textColor[SEARCH_FIELD_STATUS_NORMAL]);
2285 _SearchBar::SetPropertyColor(const Variant& color)
2287 __backgroundColor = color.ToColor();
2293 _SearchBar::GetPropertyColor(void) const
2295 return Variant(__backgroundColor);
2299 _SearchBar::SetPropertyContentAreaSize(const Variant& size)
2301 Dimension contentAreaSize = size.ToDimension();
2302 SysTryReturn(NID_UI_CTRL, contentAreaSize.width >= 0 && contentAreaSize.height >= 0, E_INVALID_ARG, E_INVALID_ARG,
2303 "[E_INVALID_ARG] Invalid argument(s) is used. contentAreaSize.width = %d, contenAreaSize.height = %d",
2304 contentAreaSize.width, contentAreaSize.height);
2306 result r = E_SUCCESS;
2309 Rectangle bounds = GetBounds();
2310 Rectangle contentAreaBounds(0, 0, 0, 0);
2312 contentAreaBounds.x = 0;
2313 contentAreaBounds.y = bounds.height;
2314 contentAreaBounds.width = contentAreaSize.width;
2315 contentAreaBounds.height = contentAreaSize.height;
2317 __contentAreaBounds = contentAreaBounds;
2318 __isUserContainerBounds = true;
2323 r = __pContainer->SetBounds(__contentAreaBounds);
2324 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2331 _SearchBar::GetPropertyContentAreaSize(void) const
2333 Dimension contentAreaSize(__contentAreaBounds.width, __contentAreaBounds.height);
2335 return Variant(contentAreaSize);
2339 _SearchBar::CreateClippedGroupControl(void)
2341 result r = E_SUCCESS;
2342 Rectangle clippedGroupControlBounds(Point(0, 0), GetSize());
2344 __pClippedGroupControl = _Control::CreateControlN();
2345 r = GetLastResult();
2346 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2348 r = AttachChild(*__pClippedGroupControl);
2349 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
2350 "[E_SYSTEM] A system error has occurred. Failed to attach the parent of clipped control.");
2352 r = __pClippedGroupControl->SetBounds(clippedGroupControlBounds);
2353 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2355 __pClippedGroupControl->SetBackgroundColor(Color(0));
2357 __pClippedGroupControl->SetClipChildrenEnabled(true);
2362 delete __pClippedGroupControl;
2363 __pClippedGroupControl = null;
2370 _SearchBar::SetContentDimming(void)
2372 if(__pContainer != NULL)
2374 if (!GetTextLength())
2376 __contentColor.SetAlpha(_SEARCH_CONTENT_DIM_OPACITY);
2380 __contentColor.SetAlpha(0);
2382 __pContainer->SetBackgroundColor(__contentColor);
2388 _SearchBar::IsContentAttachable(const _Control* pContent)
2390 const _Window* pWindow = dynamic_cast <const _Window*>(pContent);
2391 const _ColorPicker* pColorPicker = dynamic_cast <const _ColorPicker*>(pContent);
2392 const _Form* pForm = dynamic_cast <const _Form*>(pContent);
2393 const _Keypad* pKeypad = dynamic_cast <const _Keypad*>(pContent);
2394 const _OverlayPanel* pOverlayPanel = dynamic_cast <const _OverlayPanel*>(pContent);
2396 bool isContentAttachable = true;
2398 isContentAttachable = ((pWindow == null) && (pColorPicker == null) &&
2399 (pForm == null) && (pKeypad == null) && (pOverlayPanel == null));
2400 return isContentAttachable;
2404 _SearchBar::ResizeCancelButton(void)
2406 result r = E_SUCCESS;
2408 int horizontalMargin = 0;
2409 int buttonLeftMargin = 0;
2410 int buttonRightMargin = 0;
2411 int buttonMinWidth = 0;
2412 int searchFieldMinWidth = 0;
2414 Rectangle cancelButtonBounds;
2415 Rectangle searchBarBounds = GetBounds();
2417 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2419 GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2420 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2421 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2422 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, cancelButtonBounds.width);
2423 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, cancelButtonBounds.height);
2424 GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2425 GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2427 int buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth +
2428 cancelButtonBounds.width + buttonLeftMargin + buttonRightMargin);
2430 if(searchBarBounds.width < buttonResizableSearchBarWidth)
2432 cancelButtonBounds.width = searchBarBounds.width -(searchFieldMinWidth + buttonLeftMargin
2433 + buttonRightMargin + horizontalMargin);
2436 cancelButtonBounds.x = searchBarBounds.width - cancelButtonBounds.width - buttonRightMargin;
2437 cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2;
2440 if(cancelButtonBounds.width < buttonMinWidth)
2442 cancelButtonBounds.width = buttonMinWidth;
2445 cancelButtonBounds.width = (cancelButtonBounds.width > 0) ? cancelButtonBounds.width : 0;
2446 cancelButtonBounds.height = (cancelButtonBounds.height > 0) ? cancelButtonBounds.height : 0;
2448 r = __pCancelButton->SetBounds(cancelButtonBounds);
2454 }}} // Tizen::Ui::Controls