30b023254266ffb360b2df212314dc7540b78b05
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_SearchBar.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://floralicense.org/license/
10 //
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.
16 //
17
18 /**
19  * @file                FUiCtrl_SearchBar.cpp
20  * @brief               This is the implementation file for the _SearchBar class.
21  */
22
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"
43
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;
50
51 namespace Tizen { namespace Ui { namespace Controls
52 {
53
54 IMPLEMENT_PROPERTY(_SearchBar);
55
56 _SearchBar::_SearchBar(void)
57         : __pSearchBarPresenter(null)
58         , __pClippedGroupControl(null)
59         , __pEdit(null)
60         , __pCancelButton(null)
61         , __pContainer(null)
62         , __pContentControl(null)
63         , __actionId(0)
64         , __searchBarStyle(0)
65         , __isButtonEnabled(true)
66         , __isUsableCancelButton(false)
67         , __isUserContainerBounds(false)
68         , __isCancelActionInProgress(false)
69         , __keypadAction(CORE_KEYPAD_ACTION_SEARCH)
70         , __pBackgroundBitmap(null)
71         , __backgroundColor(Color())
72         , __contentColor(Color())
73         , __pActionEvent(null)
74         , __pKeypadEvent(null)
75         , __pTextBlockEvent(null)
76         , __pTextEvent(null)
77         , __pSearchBarEvent(null)
78         , __pLanguageEvent(null)
79 {
80         for (int i = 0; i < SEARCHBAR_BUTTON_COLOR_MAX; i++)
81         {
82                 __buttonColor[i] = Color(0);
83                 __buttonTextColor[i] = Color(0);
84         }
85
86         for (int i = 0; i < SEARCHBAR_COLOR_MAX; i++)
87         {
88                 __color[i] = Color(0);
89                 __textColor[i] = Color(0);
90                 __guideTextColor[i] = Color(0);
91         }
92
93         _AccessibilityContainer* pContainer = GetAccessibilityContainer();
94         if (pContainer)
95         {
96                 pContainer->Activate(true);
97         }
98 }
99
100 _SearchBar::~_SearchBar(void)
101 {
102
103         delete __pSearchBarPresenter;
104         __pSearchBarPresenter = null;
105
106         if (__pEdit)
107         {
108                 __pEdit->HideKeypad();
109
110                 __pClippedGroupControl->DetachChild(*__pEdit);
111
112                 delete __pEdit;
113                 __pEdit = null;
114         }
115
116         if (__pCancelButton)
117         {
118                 __pClippedGroupControl->DetachChild(*__pCancelButton);
119
120                 delete __pCancelButton;
121                 __pCancelButton = null;
122         }
123
124         if (__pClippedGroupControl)
125         {
126                 DetachChild(*__pClippedGroupControl);
127
128                 delete __pClippedGroupControl;
129                 __pClippedGroupControl = null;
130         }
131
132         if (__pContainer)
133         {
134                 DetachChild(*__pContainer);
135
136                 delete __pContainer;
137                 __pContainer = null;
138         }
139
140         if (__pActionEvent)
141         {
142                 delete __pActionEvent;
143                 __pActionEvent = null;
144         }
145
146         if (__pKeypadEvent)
147         {
148                 delete __pKeypadEvent;
149                 __pKeypadEvent = null;
150         }
151
152         if (__pTextBlockEvent)
153         {
154                 delete __pTextBlockEvent;
155                 __pTextBlockEvent = null;
156         }
157
158         if (__pTextEvent)
159         {
160                 delete __pTextEvent;
161                 __pTextEvent = null;
162         }
163
164         if (__pSearchBarEvent)
165         {
166                 delete __pSearchBarEvent;
167                 __pSearchBarEvent = null;
168         }
169
170         delete __pBackgroundBitmap;
171         __pBackgroundBitmap = null;
172 }
173
174 _SearchBar*
175 _SearchBar::CreateSearchBarN(void)
176 {
177         _SearchBar* pSearchBar = new (std::nothrow) _SearchBar;
178         SysTryReturn(NID_UI_CTRL, pSearchBar, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
179         if (GetLastResult() != E_SUCCESS)
180         {
181                 delete pSearchBar;
182                 return null;
183         }
184
185         pSearchBar->AcquireHandle();
186
187         return pSearchBar;
188 }
189
190 result
191 _SearchBar::Initialize(bool enableSearchBarButton, CoreKeypadAction keypadAction)
192 {
193         result r = E_SUCCESS;
194
195         // Setting Button color
196         GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_NORMAL, __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
197         GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_PRESSED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
198         GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_HIGHLIGHTED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
199         GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_DISABLED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
200
201         GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_NORMAL, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
202         GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_PRESSED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
203         GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_HIGHLIGHTED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
204         GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_DISABLED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
205
206         GET_COLOR_CONFIG(SEARCHBAR::CONTENT_AREA_BG_NORMAL, __contentColor);
207
208         for (int i = 0; i < SEARCHBAR_COLOR_MAX; i++)
209         {
210                 switch(i)
211                 {
212                 case SEARCH_FIELD_STATUS_DISABLED:
213                         GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_DISABLED, __color[i]);
214                         GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_DISABLED, __guideTextColor[i]);
215                         break;
216
217                 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
218                         GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]);
219                         GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_HIGHLIGHTED, __guideTextColor[i]);
220                         break;
221                 default:
222                         GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]);
223                         GET_COLOR_CONFIG(SEARCHBAR::GUIDE_TEXT_NORMAL, __guideTextColor[i]);
224                         break;
225                 }
226         }
227
228         __isUsableCancelButton = enableSearchBarButton;
229         __keypadAction = keypadAction;
230
231         GetVisualElement()->SetClipChildrenEnabled(false);
232
233         r = CreateClippedGroupControl();
234         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
235                      "[E_SYSTEM] A system error has occurred. The construction of parent control for clipped group control failed.");
236
237         r = CreateSearchField();
238         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
239                      "[E_SYSTEM] A system error has occurred. The edit construction failed.");
240         r = CreateCancelButton();
241         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
242                      "[E_SYSTEM] A system error has occurred. The cancel button construction failed.");
243
244         SetContentsArea();
245         r = CreateContentsArea();
246         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
247                      "[E_SYSTEM] A system error has occurred. The construction of parent for content failed.");
248
249         _SearchBarPresenter* pPresenter = new (std::nothrow) _SearchBarPresenter;
250         SysTryReturn(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
251
252         r = pPresenter->Construct(*this);
253         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
254
255         r = pPresenter->Install();
256         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
257
258         __pSearchBarPresenter = pPresenter;
259
260         return r;
261
262 CATCH:
263         delete pPresenter;
264         pPresenter = null;
265
266         return r;
267 }
268
269 result
270 _SearchBar::CreateSearchField(void)
271 {
272         result r = E_SUCCESS;
273
274         FloatRectangle editBounds;
275         int horizontalMargin = 0;
276         int verticalMargin = 0;
277         int iconHorizontalMargin = 0;
278         int textHorizontalMargin = 0;
279         int iconWidth = 0;
280         int textSize = 0;
281         int searchFieldMinWidth = 0;
282         int searchBarMinHeight = 0;
283
284         FloatRectangle searchBarBounds = GetBoundsF();
285         _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
286         _AccessibilityContainer* pSearchBarContainer = null;
287
288         GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
289         GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin);
290         GET_SHAPE_CONFIG(SEARCHBAR::ICON_HORIZONTAL_MARGIN, orientation, iconHorizontalMargin);
291         GET_SHAPE_CONFIG(SEARCHBAR::ICON_WIDTH, orientation, iconWidth);
292         GET_SHAPE_CONFIG(SEARCHBAR::TEXT_HORIZONTAL_MARGIN, orientation, textHorizontalMargin);
293         GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
294         GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
295
296         int searchFieldMinHeight = searchBarMinHeight - (verticalMargin * 2);
297
298         editBounds.x = _CoordinateSystemUtils::ConvertToFloat(horizontalMargin);
299         editBounds.y = _CoordinateSystemUtils::ConvertToFloat(verticalMargin);
300         editBounds.width = searchBarBounds.width - (editBounds.x * 2.0f);
301         editBounds.height = searchBarBounds.height - (editBounds.y * 2.0f);
302
303         editBounds.width = (editBounds.width > searchFieldMinWidth) ? editBounds.width : searchFieldMinWidth;
304         editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight;
305
306
307         __pEdit = _Edit::CreateEditN();
308         r = GetLastResult();
309         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
310
311         r = __pEdit->Initialize(EDIT_STYLE_NORMAL | EDIT_STYLE_SINGLE_LINE | EDIT_STYLE_CLEAR | EDIT_STYLE_NOSCROLL, INPUT_STYLE_OVERLAY,
312                                                         SEARCHBAR_TEXT_LENGTH_MAX);
313         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
314
315         __pEdit->SetKeypadCommandButtonVisible(false);
316         __pEdit->SetBounds(editBounds);
317         __pEdit->AddKeypadEventListener(*this);
318         __pEdit->AddTextBlockEventListener(*this);
319         __pEdit->AddTextEventListener(*this);
320
321         GET_SHAPE_CONFIG(SEARCHBAR::EDIT_TEXT_SIZE, orientation, textSize);
322         __pEdit->SetTextSize(textSize);
323
324         __pEdit->SetHorizontalMargin(iconHorizontalMargin + iconWidth + textHorizontalMargin, EDIT_TEXT_LEFT_MARGIN);
325         __pEdit->SetHorizontalMargin(textHorizontalMargin, EDIT_TEXT_RIGHT_MARGIN);
326         __pEdit->SetLimitLength(SEARCHBAR_TEXT_LENGTH_MAX);
327
328         for (int status = 0; status < SEARCHBAR_COLOR_MAX; status++)
329         {
330                 EditStatus editStatus = ConvertSearchBarStatus((SearchFieldStatus) status);
331                 __pEdit->SetColor(editStatus, __color[status]);
332         }
333
334         __pEdit->ReplaceDefaultBackgroundBitmapForSearchBar();
335         __pEdit->SetPressedGuideTextColor(__guideTextColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
336
337         __pEdit->SetKeypadAction(__keypadAction);
338
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.");
342
343         if (likely(!(_AccessibilityManager::IsActivated())))
344         {
345                 return E_SUCCESS;
346         }
347
348         pSearchBarContainer = GetAccessibilityContainer();
349         if (pSearchBarContainer)
350         {
351                 _AccessibilityContainer* pSearchFieldContainer = __pEdit->GetAccessibilityContainer();
352                 if (pSearchFieldContainer)
353                 {
354                         pSearchBarContainer->AddChildContainer(*pSearchFieldContainer);
355                 }
356         }
357
358         return E_SUCCESS;
359
360 CATCH:
361         delete __pEdit;
362         __pEdit = null;
363
364         return r;
365 }
366
367 result
368 _SearchBar::CreateCancelButton(void)
369 {
370         result r = E_SUCCESS;
371
372         int textSize = 0;
373         String cancelButtonText;
374
375         _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
376         _AccessibilityContainer* pSearchBarContainer = null;
377
378         __pCancelButton = _Button::CreateButtonN();
379         r = GetLastResult();
380         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
381
382         r = ResizeCancelButton();
383         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
384
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));
388
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));
392
393         __pCancelButton->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
394         __pCancelButton->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
395
396         r = __pCancelButton->SetActionId(__actionId);
397         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
398
399         r = __pCancelButton->AddActionEventListener(*this);
400         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
401
402         __pCancelButton->SetVisibleState(false);
403
404         for (int status = 0; status < SEARCHBAR_BUTTON_COLOR_MAX; status++)
405         {
406                 _ButtonStatus buttonStatus = ConvertSearchBarButtonStatus((SearchBarButtonStatus) status);
407
408                 r = __pCancelButton->SetColor(buttonStatus, __buttonColor[status]);
409                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
410
411                 r = __pCancelButton->SetTextColor(buttonStatus, __buttonTextColor[status]);
412                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
413         }
414
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.");
418
419         if (likely(!(_AccessibilityManager::IsActivated())))
420         {
421                 return E_SUCCESS;
422         }
423
424         pSearchBarContainer = GetAccessibilityContainer();
425         if (pSearchBarContainer)
426         {
427                 _AccessibilityContainer* pButtonContainer = __pCancelButton->GetAccessibilityContainer();
428                 if (pButtonContainer)
429                 {
430                         pSearchBarContainer->AddChildContainer(*pButtonContainer);
431                 }
432         }
433
434         return E_SUCCESS;
435
436 CATCH:
437         delete __pCancelButton;
438         __pCancelButton = null;
439
440         return r;
441 }
442
443 result
444 _SearchBar::CreateContentsArea(void)
445 {
446         result r = E_SUCCESS;
447
448         __pContainer = _Control::CreateControlN();
449
450         r = GetLastResult();
451         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
452
453         __pContainer->SetVisibleState(false);
454
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.");
458
459         return E_SUCCESS;
460
461 CATCH:
462         delete __pContainer;
463         __pContainer = null;
464
465         return r;
466 }
467
468 void
469 _SearchBar::SetContentsArea(void)
470 {
471         if (__isUserContainerBounds)
472         {
473                 return;
474         }
475
476         FloatDimension screenSize = _ControlManager::GetInstance()->GetScreenSizeF();
477         float width = screenSize.width;
478         float height = screenSize.height;
479
480         _Control* pParent = GetParentForm();
481         if (pParent != null)
482         {
483                 width = pParent->GetClientBoundsF().width;
484                 height = pParent->GetClientBoundsF().height;
485         }
486
487         __contentAreaBounds = GetBoundsF();
488         __contentAreaBounds.x = 0.0f;
489         __contentAreaBounds.y = __contentAreaBounds.height;
490         __contentAreaBounds.width = width;
491         __contentAreaBounds.height = height - __contentAreaBounds.height;
492
493         if (__pContainer)
494         {
495                 result r = E_SUCCESS;
496                 r = __pContainer->SetBounds(__contentAreaBounds);
497                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
498         }
499         return;
500 }
501
502 _Control*
503 _SearchBar::GetContent(void) const
504 {
505         return __pContentControl;
506 }
507
508 result
509 _SearchBar::SetContent(const _Control* pContent)
510 {
511         __pContentControl = const_cast <_Control*>(pContent);
512         result r = E_SUCCESS;
513
514         if (__pContainer)
515         {
516                 r = __pContainer->AttachChild(*__pContentControl);
517                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating");
518         }
519
520         return r;
521 }
522
523 result
524 _SearchBar::UpdateContentArea(bool invalidate)
525 {
526         return __pSearchBarPresenter->UpdateContentArea(invalidate);
527 }
528
529 result
530 _SearchBar::SetContentAreaVisible(bool visible)
531 {
532         SysTryReturn(NID_UI_CTRL, __pContainer, E_SYSTEM, E_SYSTEM,
533                      "[E_SYSTEM] A system error has occurred. The instance of parent to content is null.");
534
535         SearchBarMode searchBarMode = GetMode();
536         if (searchBarMode == SEARCH_BAR_MODE_INPUT)
537         {
538                 __pContainer->SetVisibleState(visible);
539         }
540
541         return __pSearchBarPresenter->SetContentAreaVisible(visible);
542 }
543
544 bool
545 _SearchBar::IsContentAreaVisible(void) const
546 {
547         return __pSearchBarPresenter->IsContentAreaVisible();
548 }
549
550 result
551 _SearchBar::SetContentAreaSize(const Dimension& size)
552 {
553         return SetProperty("contentAreaSize", Variant(size));
554 }
555
556 Dimension
557 _SearchBar::GetContentAreaSize(void) const
558 {
559         Variant size = GetProperty("contentAreaSize");
560
561         return size.ToDimension();
562 }
563
564 SearchBarMode
565 _SearchBar::GetMode(void) const
566 {
567         return __pSearchBarPresenter->GetMode();
568 }
569
570 bool
571 _SearchBar::IsModeLocked(void) const
572 {
573         return __pSearchBarPresenter->IsModeLocked();
574 }
575
576 result
577 _SearchBar::SetMode(SearchBarMode mode)
578 {
579         return __pSearchBarPresenter->SetMode(mode);
580 }
581
582 result
583 _SearchBar::SetModeLocked(bool modeLocked)
584 {
585         return __pSearchBarPresenter->SetModeLocked(modeLocked);
586 }
587
588 int
589 _SearchBar::GetButtonActionId(void) const
590 {
591         Variant actionId = GetProperty("buttonActionId");
592
593         return actionId.ToInt();
594 }
595
596 Color
597 _SearchBar::GetButtonColor(SearchBarButtonStatus status) const
598 {
599         Variant buttonColor;
600
601         switch (status)
602         {
603         case SEARCH_BAR_BUTTON_STATUS_NORMAL:
604                 buttonColor = GetProperty("buttonNormalColor");
605                 break;
606         case SEARCH_BAR_BUTTON_STATUS_PRESSED:
607                 buttonColor = GetProperty("buttonPressedColor");
608                 break;
609         case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
610                 buttonColor = GetProperty("buttonHighlightedColor");
611                 break;
612         case SEARCH_BAR_BUTTON_STATUS_DISABLED:
613                 buttonColor = GetProperty("buttonDisabledColor");
614                 break;
615         default:
616                 break;
617         }
618
619         return buttonColor.ToColor();
620 }
621
622 Color
623 _SearchBar::GetButtonTextColor(SearchBarButtonStatus status) const
624 {
625         Variant buttonTextColor;
626
627         switch (status)
628         {
629         case SEARCH_BAR_BUTTON_STATUS_NORMAL:
630                 buttonTextColor = GetProperty("buttonNormalTextColor");
631                 break;
632         case SEARCH_BAR_BUTTON_STATUS_PRESSED:
633                 buttonTextColor = GetProperty("buttonPressedTextColor");
634                 break;
635         case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
636                 buttonTextColor = GetProperty("buttonHighlightedTextColor");
637                 break;
638         case SEARCH_BAR_BUTTON_STATUS_DISABLED:
639                 buttonTextColor = GetProperty("buttonDisabledTextColor");
640                 break;
641         default:
642                 break;
643         }
644
645         return buttonTextColor.ToColor();
646 }
647
648 SearchBarButtonStatus
649 _SearchBar::GetButtonStatus(void) const
650 {
651         SysTryReturn(NID_UI_CTRL, __pCancelButton, SEARCH_BAR_BUTTON_STATUS_NORMAL, E_SYSTEM,
652                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
653
654         SearchBarButtonStatus buttonStatus = SEARCH_BAR_BUTTON_STATUS_NORMAL;
655
656         if (__isButtonEnabled == false)
657         {
658                 buttonStatus = SEARCH_BAR_BUTTON_STATUS_DISABLED;
659         }
660
661         return buttonStatus;
662 }
663
664 result
665 _SearchBar::SetButtonText(const String& text)
666 {
667         SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
668                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
669
670         result r = E_SUCCESS;
671
672         r = __pCancelButton->SetText(text);
673         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
674                      "[E_SYSTEM] A system error has occurred. Failed to set text.");
675
676         return r;
677 }
678
679 result
680 _SearchBar::SetButtonActionId(int actionId)
681 {
682         return SetProperty("buttonActionId", Variant(actionId));
683 }
684
685 result
686 _SearchBar::SetButtonEnabled(bool enabled)
687 {
688         SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
689                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
690
691         __pCancelButton->SetEnableState(enabled);
692
693         __isButtonEnabled = enabled;
694
695         return E_SUCCESS;
696 }
697
698 result
699 _SearchBar::SetButtonColor(SearchBarButtonStatus status, const Color& color)
700 {
701         result r = E_SUCCESS;
702
703         switch (status)
704         {
705         case SEARCH_BAR_BUTTON_STATUS_NORMAL:
706                 r = SetProperty("buttonNormalColor", Variant(color));
707                 break;
708         case SEARCH_BAR_BUTTON_STATUS_PRESSED:
709                 r = SetProperty("buttonPressedColor", Variant(color));
710                 break;
711         case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
712                 r = SetProperty("buttonHighlightedColor", Variant(color));
713                 break;
714         case SEARCH_BAR_BUTTON_STATUS_DISABLED:
715                 r = SetProperty("buttonDisabledColor", Variant(color));
716                 break;
717         default:
718                 break;
719         }
720
721         return r;
722 }
723
724 result
725 _SearchBar::SetButtonTextColor(SearchBarButtonStatus status, const Color& color)
726 {
727         result r = E_SUCCESS;
728
729         switch (status)
730         {
731         case SEARCH_BAR_BUTTON_STATUS_NORMAL:
732                 r = SetProperty("buttonNormalTextColor", Variant(color));
733                 break;
734         case SEARCH_BAR_BUTTON_STATUS_PRESSED:
735                 r = SetProperty("buttonPressedTextColor", Variant(color));
736                 break;
737         case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
738                 r = SetProperty("buttonHighlightedTextColor", Variant(color));
739                 break;
740         case SEARCH_BAR_BUTTON_STATUS_DISABLED:
741                 r = SetProperty("buttonDisabledTextColor", Variant(color));
742                 break;
743         default:
744                 break;
745         }
746
747         return r;
748 }
749
750 result
751 _SearchBar::AppendCharacter(const Character& character)
752 {
753         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
754                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
755         SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM,
756                      "[E_SYSTEM] A system error has occurred. The character is null.");
757
758         result r = E_SUCCESS;
759
760         r = __pEdit->AppendCharacter(character);
761         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
762                      "[E_SYSTEM] A system error has occurred. Failed to set character.");
763
764         return r;
765 }
766
767 result
768 _SearchBar::AppendText(const String& text)
769 {
770         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
771                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
772         SysTryReturn(NID_UI_CTRL, text.IsEmpty() == false, E_SYSTEM, E_SYSTEM,
773                      "[E_SYSTEM] A system error has occurred. The text is empty.");
774
775         result r = E_SUCCESS;
776
777         r = __pEdit->AppendText(text);
778         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
779                      "[E_SYSTEM] A system error has occurred. Failed to set text.");
780
781         return r;
782 }
783
784 result
785 _SearchBar::SetText(const String& text)
786 {
787         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
788                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
789
790         result r = E_SUCCESS;
791
792         int limitLength = __pEdit->GetTextLimitLength();
793         int textLength = text.GetLength();
794         SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_SYSTEM, E_SYSTEM,
795                      "[E_SYSTEM] A system error has occurred. textLength exceeds the limitLength");
796
797         r = __pEdit->SetText(text);
798         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
799                      "[E_SYSTEM] A system error has occurred. Failed to set text.");
800
801         return r;
802 }
803
804 result
805 _SearchBar::InsertCharacterAt(int index, const Character& character)
806 {
807         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
808                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
809         SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
810                      "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
811         SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM,
812                      "[E_SYSTEM] A system error has occurred. The character is null.");
813
814         result r = E_SUCCESS;
815
816         int textLength = 0;
817         int limitLength = 0;
818         limitLength = __pEdit->GetTextLimitLength();
819         textLength = __pEdit->GetTextLength() + 1;
820
821         SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
822                      "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
823
824         SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
825                      "[E_OUT_OF_RANGE] index(%d) is out of range of current textLength(%d).", index, __pEdit->GetTextLength());
826
827         r = __pEdit->InsertCharacterAt(index, character);
828         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
829                      "[E_SYSTEM] A system error has occurred. Failed to set text.");
830
831         return r;
832 }
833
834 result
835 _SearchBar::InsertTextAt(int index, const String& text)
836 {
837         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
838                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
839         SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
840                      "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
841
842         result r = E_SUCCESS;
843
844         int textLength = 0;
845         int limitLength = 0;
846         limitLength = __pEdit->GetTextLimitLength();
847         textLength = __pEdit->GetTextLength() + text.GetLength();
848
849         SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED,
850                      "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength);
851         SysTryReturn(NID_UI_CTRL, index <= __pEdit->GetTextLength(), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
852                      "[E_OUT_OF_RANGE] index(%d) is out of range of current textLength(%d).", index, __pEdit->GetTextLength());
853
854         r = __pEdit->InsertTextAt(index, text);
855         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
856                      "[E_SYSTEM] A system error has occurred. Failed to insert text.");
857
858         return r;
859 }
860
861 result
862 _SearchBar::DeleteCharacterAt(int index)
863 {
864         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
865                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
866         SysTryReturn(NID_UI_CTRL, index > -1, E_INVALID_ARG, E_INVALID_ARG,
867                      "[E_INVALID_ARG] Invalid argument(s) is used. index = %d", index);
868
869         result r = E_SUCCESS;
870         int textLength = 0;
871         textLength = __pEdit->GetTextLength();
872
873         SysTryReturn(NID_UI_CTRL, textLength > index, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
874                      "[E_OUT_OF_RANGE] index(%d) is out of range. textLength(%d)", index, textLength);
875
876         r = __pEdit->DeleteCharacterAt(index);
877         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM,
878                            "[E_SYSTEM] A system error has occured. Failed to delete character.");
879
880         return r;
881 }
882
883 result
884 _SearchBar::Clear(void)
885 {
886         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
887                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
888
889         return __pEdit->ClearText();
890 }
891
892 int
893 _SearchBar::GetTextLength(void) const
894 {
895         SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
896                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
897
898         return __pEdit->GetTextLength();
899 }
900
901 String
902 _SearchBar::GetText(void) const
903 {
904         SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
905                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
906
907         return __pEdit->GetText();
908 }
909
910 String
911 _SearchBar::GetText(int start, int end) const
912 {
913         SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
914                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
915
916         return __pEdit->GetText(start, end);
917 }
918
919 int
920 _SearchBar::GetLimitLength(void) const
921 {
922         SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
923                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
924
925         return __pEdit->GetTextLimitLength();
926 }
927
928 result
929 _SearchBar::SetLimitLength(int limitLength)
930 {
931         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
932                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
933         SysTryReturn(NID_UI_CTRL, limitLength > 0, E_INVALID_ARG, E_INVALID_ARG,
934                      "[E_INVALID_ARG] Invalid argument(s) is used.limitLength = %d", limitLength);
935
936         String tempString = GetText();
937
938         int textLength = tempString.GetLength();
939         SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_INVALID_ARG, E_INVALID_ARG,
940                      "[E_INVALID_ARG] Invalid argument(s) is used. limitLength = %d, textLength = %d", limitLength, textLength);
941
942         result r = __pEdit->SetLimitLength(limitLength);
943         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
944
945         r = SetText(tempString);
946         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
947
948         return E_SUCCESS;
949 }
950
951 result
952 _SearchBar::ShowKeypad(void) const
953 {
954         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
955                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
956
957         SearchBarMode mode = __pSearchBarPresenter->GetMode();
958         SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_INVALID_STATE, E_INVALID_STATE,
959                      "[E_INVALID_STATE] The SearchBar is currently in Normal mode.");
960         return __pEdit->ShowKeypad();
961 }
962
963 result
964 _SearchBar::HideKeypad(void)
965 {
966         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
967                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
968
969         SearchBarMode mode = __pSearchBarPresenter->GetMode();
970         SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_SYSTEM, E_SYSTEM,
971                      "[E_SYSTEM] A system error has occurred. The SearchBar is currently in Normal mode.");
972
973         result r = __pEdit->HideKeypad();
974
975         SetContentsArea();
976
977         return r;
978 }
979
980 float
981 _SearchBar::GetSearchFieldTextSizeF(void) const
982 {
983         SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
984                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
985
986         return __pEdit->GetTextSizeF();
987 }
988
989 result
990 _SearchBar::SetSearchFieldTextSize(float size)
991 {
992         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
993                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
994
995         return __pEdit->SetTextSize(size);
996 }
997
998 result
999 _SearchBar::GetBlockRange(int& start, int& end) const
1000 {
1001         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1002                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1003
1004         int startIndex = -1;
1005         int endIndex = -1;
1006
1007         __pEdit->GetBlockRange(startIndex, endIndex);
1008         SysTryReturn(NID_UI_CTRL, (startIndex > -1 && endIndex > 0), E_SYSTEM, E_SYSTEM,
1009                      "[E_SYSTEM] A system error has occurred. Failed to get text block range.");
1010
1011         start = startIndex;
1012         end = endIndex - 1;
1013
1014         return E_SUCCESS;
1015 }
1016
1017 result
1018 _SearchBar::ReleaseBlock(void)
1019 {
1020         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1021                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1022
1023         result r = E_SUCCESS;
1024
1025         int start = 0;
1026         int end = 0;
1027
1028         r = GetBlockRange(start, end);
1029         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1030
1031         return __pEdit->ReleaseTextBlock();
1032 }
1033
1034 result
1035 _SearchBar::SetBlockRange(int start, int end)
1036 {
1037         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1038                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1039
1040         result r = E_SUCCESS;
1041
1042         int textLength = 0;
1043         textLength = __pEdit->GetTextLength();
1044
1045         SysTryReturn(NID_UI_CTRL, (start < end && start >= 0 && textLength >= end), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1046                      "[E_OUT_OF_RANGE] start (%d) and end (%d) is out of range.", start, end - 1);
1047
1048         r = SetCursorPosition(start);
1049         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1050
1051         r = __pEdit->BeginTextBlock();
1052         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1053                      "[E_SYSTEM] A system error has occurred. Failed to set text block range.");
1054
1055         r = SetCursorPosition(end);
1056         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1057                      "[E_SYSTEM] A system error has occurred. Failed to set cursor position.");
1058
1059         return E_SUCCESS;
1060 }
1061
1062 result
1063 _SearchBar::RemoveTextBlock(void)
1064 {
1065         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1066                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1067
1068         result r = E_SUCCESS;
1069
1070         r = __pEdit->RemoveTextBlock();
1071         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1072
1073         return r;
1074 }
1075
1076 Color
1077 _SearchBar::GetColor(void) const
1078 {
1079         Variant backgroundColor = GetProperty("color");
1080
1081         return backgroundColor.ToColor();
1082 }
1083
1084 Color
1085 _SearchBar::GetSearchFieldColor(SearchFieldStatus status) const
1086 {
1087         Variant searchFieldColor;
1088
1089         switch (status)
1090         {
1091         case SEARCH_FIELD_STATUS_NORMAL:
1092                 searchFieldColor = GetProperty("searchFieldNormalColor");
1093                 break;
1094         case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1095                 searchFieldColor = GetProperty("searchFieldHighlightedColor");
1096                 break;
1097         case SEARCH_FIELD_STATUS_DISABLED:
1098                 searchFieldColor = GetProperty("searchFieldDisabledColor");
1099                 break;
1100         default:
1101                 break;
1102         }
1103
1104         return searchFieldColor.ToColor();
1105 }
1106
1107
1108 Color
1109 _SearchBar::GetSearchFieldTextColor(SearchFieldStatus status) const
1110 {
1111         Variant searchFieldTextColor;
1112
1113         switch (status)
1114         {
1115         case SEARCH_FIELD_STATUS_NORMAL:
1116                 searchFieldTextColor = GetProperty("searchFieldNormalTextColor");
1117                 break;
1118         case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1119                 searchFieldTextColor = GetProperty("searchFieldHighlightedTextColor");
1120                 break;
1121         case SEARCH_FIELD_STATUS_DISABLED:
1122                 searchFieldTextColor = GetProperty("searchFieldDisabledTextColor");
1123                 break;
1124         default:
1125                 break;
1126         }
1127
1128         return searchFieldTextColor.ToColor();
1129 }
1130
1131
1132 result
1133 _SearchBar::SetBackgroundBitmap(const Bitmap& bitmap)
1134 {
1135         Bitmap* pNewBitmap = _BitmapImpl::CloneN(bitmap);
1136         SysTryReturn(NID_UI_CTRL, pNewBitmap, E_SYSTEM, E_SYSTEM,
1137                      "[E_SYSTEM] A system error has occurred. The creation of bitmap failed.");
1138
1139         delete __pBackgroundBitmap;
1140         __pBackgroundBitmap = null;
1141
1142         __pBackgroundBitmap = pNewBitmap;
1143
1144         return E_SUCCESS;
1145 }
1146
1147 Bitmap*
1148 _SearchBar::GetBackgroundBitmap(void) const
1149 {
1150         return __pBackgroundBitmap;
1151 }
1152
1153 result
1154 _SearchBar::SetColor(const Color& color)
1155 {
1156         return SetProperty("color", Variant(color));
1157 }
1158
1159 result
1160 _SearchBar::SetSearchFieldColor(SearchFieldStatus status, const Color& color)
1161 {
1162         result r = E_SUCCESS;
1163
1164         switch (status)
1165         {
1166         case SEARCH_FIELD_STATUS_NORMAL:
1167                 r = SetProperty("searchFieldNormalColor", Variant(color));
1168                 break;
1169         case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1170                 r = SetProperty("searchFieldHighlightedColor", Variant(color));
1171                 break;
1172         case SEARCH_FIELD_STATUS_DISABLED:
1173                 r = SetProperty("searchFieldDisabledColor", Variant(color));
1174                 break;
1175         default:
1176                 break;
1177         }
1178
1179         return r;
1180 }
1181
1182
1183 result
1184 _SearchBar::SetSearchFieldTextColor(SearchFieldStatus status, const Color& color)
1185 {
1186         result r = E_SUCCESS;
1187
1188         switch (status)
1189         {
1190         case SEARCH_FIELD_STATUS_NORMAL:
1191                 r = SetProperty("searchFieldNormalTextColor", Variant(color));
1192                 break;
1193         case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1194                 r = SetProperty("searchFieldHighlightedTextColor", Variant(color));
1195                 break;
1196         case SEARCH_FIELD_STATUS_DISABLED:
1197                 r = SetProperty("searchFieldDisabledTextColor", Variant(color));
1198                 break;
1199         default:
1200                 break;
1201         }
1202
1203         return r;
1204 }
1205
1206
1207 String
1208 _SearchBar::GetGuideText(void) const
1209 {
1210         SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM,
1211                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1212
1213         return __pEdit->GetGuideText();
1214 }
1215
1216 result
1217 _SearchBar::SetGuideText(const String& guideText)
1218 {
1219         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1220                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1221
1222         __pEdit->SetGuideText(guideText);
1223
1224         return E_SUCCESS;
1225 }
1226
1227 Color
1228 _SearchBar::GetGuideTextColor(void) const
1229 {
1230         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1231                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1232
1233         return __pEdit->GetGuideTextColor();
1234 }
1235
1236 result
1237 _SearchBar::SetGuideTextColor(const Color& color)
1238 {
1239         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1240                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1241
1242         return __pEdit->SetGuideTextColor(color);
1243 }
1244
1245 int
1246 _SearchBar::GetCursorPosition(void) const
1247 {
1248         SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM,
1249                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1250
1251         return __pEdit->GetCursorPosition();
1252 }
1253
1254 result
1255 _SearchBar::SetCursorPosition(int index)
1256 {
1257         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1258                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1259         SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1260                      "[E_OUT_OF_RANGE] index(%d) is out of range.", GetErrorMessage(E_OUT_OF_RANGE), index);
1261
1262         int textLength = -1;
1263         textLength = __pEdit->GetTextLength();
1264
1265         SysTryReturn(NID_UI_CTRL, (index > -1 && index <= textLength), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
1266                      "[E_OUT_OF_RANGE] index(%d) is out of range.", index);
1267
1268         return __pEdit->SetCursorPosition(index);
1269 }
1270
1271 bool
1272 _SearchBar::IsLowerCaseModeEnabled(void) const
1273 {
1274         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1275                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1276
1277         return __pEdit->IsLowerCaseModeEnabled();
1278 }
1279
1280 void
1281 _SearchBar::SetLowerCaseModeEnabled(bool enable)
1282 {
1283         SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
1284                                "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1285
1286         __pEdit->SetLowerCaseModeEnabled(enable);
1287 }
1288
1289 EllipsisPosition
1290 _SearchBar::GetEllipsisPosition(void) const
1291 {
1292         SysTryReturn(NID_UI_CTRL, __pEdit, ELLIPSIS_POSITION_START, E_SYSTEM,
1293                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1294
1295         return __pEdit->GetEllipsisPosition();
1296 }
1297
1298 result
1299 _SearchBar::SetEllipsisPosition(EllipsisPosition position)
1300 {
1301         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1302                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1303         __pEdit->SetEllipsisPosition(position);
1304
1305         return E_SUCCESS;
1306 }
1307
1308 CoreKeypadAction
1309 _SearchBar::GetKeypadAction(void) const
1310 {
1311         return __keypadAction;
1312 }
1313
1314 bool
1315 _SearchBar::IsTextPredictionEnabled(void) const
1316 {
1317         SysTryReturn(NID_UI_CTRL, __pEdit, false, E_SYSTEM,
1318                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1319         return __pEdit->IsTextPredictionEnabled();
1320 }
1321
1322 result
1323 _SearchBar::SetTextPredictionEnabled(bool enable)
1324 {
1325         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
1326                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
1327         return __pEdit->SetTextPredictionEnabled(enable);
1328 }
1329
1330 result
1331 _SearchBar::SetCurrentLanguage(LanguageCode languageCode)
1332 {
1333         return __pEdit->SetCurrentLanguage(languageCode);
1334 }
1335
1336 result
1337 _SearchBar::GetCurrentLanguage(LanguageCode& language) const
1338 {
1339         return __pEdit->GetCurrentLanguage(language);
1340 }
1341
1342 result
1343 _SearchBar::AddActionEventListener(const _IActionEventListener& listener)
1344 {
1345         result r = E_SUCCESS;
1346
1347         if (__pActionEvent == null)
1348         {
1349                 __pActionEvent = _ActionEvent::CreateInstanceN(*this);
1350                 r = GetLastResult();
1351                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1352
1353                 __pActionEvent->AddListener(listener);
1354         }
1355
1356         return r;
1357 }
1358
1359 result
1360 _SearchBar::RemoveActionEventListener(const _IActionEventListener& listener)
1361 {
1362         SysTryReturn(NID_UI_CTRL, __pActionEvent, E_SYSTEM, E_SYSTEM,
1363                      "[E_SYSTEM] A system error has occurred. The action event instance is null.");
1364         result r = E_SUCCESS;
1365
1366         r = __pActionEvent->RemoveListener(listener);
1367         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1368
1369         return r;
1370 }
1371
1372 result
1373 _SearchBar::AddKeypadEventListener(const _IKeypadEventListener& listener)
1374 {
1375         result r = E_SUCCESS;
1376
1377         if (__pKeypadEvent == null)
1378         {
1379                 __pKeypadEvent = _KeypadEvent::CreateInstanceN(*this);
1380                 r = GetLastResult();
1381                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1382
1383                 r = __pKeypadEvent->AddListener(listener);
1384                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1385         }
1386
1387         return r;
1388 }
1389
1390 result
1391 _SearchBar::RemoveKeypadEventListener(const _IKeypadEventListener& listener)
1392 {
1393         SysTryReturn(NID_UI_CTRL, __pKeypadEvent, E_SYSTEM, E_SYSTEM,
1394                      "[E_SYSTEM] A system error has occurred. The keypad event instance is null.");
1395         result r = E_SUCCESS;
1396
1397         r = __pKeypadEvent->RemoveListener(listener);
1398         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1399
1400         return r;
1401 }
1402
1403 result
1404 _SearchBar::AddTextBlockEventListener(const _ITextBlockEventListener& listener)
1405 {
1406         result r = E_SUCCESS;
1407
1408         if (__pTextBlockEvent == null)
1409         {
1410                 __pTextBlockEvent = _TextBlockEvent::CreateInstanceN(*this);
1411                 r = GetLastResult();
1412                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1413
1414                 r = __pTextBlockEvent->AddListener(listener);
1415                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1416
1417         }
1418
1419         return r;
1420 }
1421
1422 result
1423 _SearchBar::RemoveTextBlockEventListener(const _ITextBlockEventListener& listener)
1424 {
1425         SysTryReturn(NID_UI_CTRL, __pTextBlockEvent, E_SYSTEM, E_SYSTEM,
1426                      "[E_SYSTEM] A system error has occurred. The text block event instance is null.");
1427         result r = E_SUCCESS;
1428
1429         r = __pTextBlockEvent->RemoveListener(listener);
1430         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1431
1432         return r;
1433 }
1434
1435
1436 result
1437 _SearchBar::AddTextEventListener(const _ITextEventListener& listener)
1438 {
1439         result r = E_SUCCESS;
1440
1441         if (__pTextEvent == null)
1442         {
1443                 __pTextEvent = _TextEvent::CreateInstanceN(*this);
1444                 r = GetLastResult();
1445                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1446
1447                 r = __pTextEvent->AddListener(listener);
1448                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1449         }
1450
1451         return r;
1452 }
1453
1454 result
1455 _SearchBar::RemoveTextEventListener(const _ITextEventListener& listener)
1456 {
1457         SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM,
1458                      "[E_SYSTEM] A system error has occurred. The text event instance is null.");
1459         result r = E_SUCCESS;
1460
1461         r = __pTextEvent->RemoveListener(listener);
1462         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1463
1464         return r;
1465 }
1466
1467 result
1468 _SearchBar::AddSearchBarEventListener(const _ISearchBarEventListener& listener)
1469 {
1470         result r = E_SUCCESS;
1471
1472         if (__pSearchBarEvent == null)
1473         {
1474                 __pSearchBarEvent = _SearchBarEvent::CreateInstanceN(*this);
1475                 r = GetLastResult();
1476                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1477
1478                 r = __pSearchBarEvent->AddListener(listener);
1479                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1480         }
1481
1482         return r;
1483 }
1484
1485 result
1486 _SearchBar::RemoveSearchBarEventListener(const _ISearchBarEventListener& listener)
1487 {
1488         SysTryReturn(NID_UI_CTRL, __pSearchBarEvent, E_SYSTEM, E_SYSTEM,
1489                      "[E_SYSTEM] A system error has occurred. The searchbar event instance is null.");
1490         result r = E_SUCCESS;
1491
1492         r = __pSearchBarEvent->RemoveListener(listener);
1493         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1494
1495         return r;
1496 }
1497
1498 result
1499 _SearchBar::AddLanguageEventListener(const _ILanguageEventListener& listener)
1500 {
1501         result r = E_SUCCESS;
1502
1503         if (__pLanguageEvent == null)
1504         {
1505                 __pLanguageEvent = _LanguageEvent::CreateInstanceN(*this);
1506                 r = GetLastResult();
1507                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1508
1509                 r = __pLanguageEvent->AddListener(listener);
1510                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1511         }
1512
1513         return r;
1514 }
1515
1516 result
1517 _SearchBar::RemoveLanguageEventListener(const _ILanguageEventListener& listener)
1518 {
1519         SysTryReturn(NID_UI_CTRL, __pLanguageEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.");
1520         result r = E_SUCCESS;
1521
1522         __pLanguageEvent->RemoveListener(listener);
1523         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
1524
1525         return r;
1526 }
1527
1528 void
1529 _SearchBar::OnBoundsChanged(void)
1530 {
1531         if (__pSearchBarPresenter != null)
1532         {
1533                 __pSearchBarPresenter->OnBoundsChanged();
1534         }
1535         return;
1536 }
1537
1538 void
1539 _SearchBar::OnChangeLayout(_ControlOrientation orientation)
1540 {
1541         SetContentsArea();
1542 }
1543
1544 void
1545 _SearchBar::OnDraw(void)
1546 {
1547         SearchFieldStatus searchFieldStatus = GetCurrentStatus();
1548         SetGuideTextColor(__guideTextColor[searchFieldStatus]);
1549
1550         __pSearchBarPresenter->Draw();
1551         return;
1552 }
1553
1554 _UiTouchEventDelivery
1555 _SearchBar::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1556 {
1557         _Edit* pEdit = dynamic_cast <_Edit*>(const_cast <_Control*>(&source));
1558         if (pEdit == null)
1559         {
1560                 return _UI_TOUCH_EVENT_DELIVERY_YES;
1561         }
1562
1563         if (GetMode() == SEARCH_BAR_MODE_INPUT)
1564         {
1565                 return _UI_TOUCH_EVENT_DELIVERY_YES;
1566         }
1567
1568         SetMode(SEARCH_BAR_MODE_INPUT);
1569
1570         return _UI_TOUCH_EVENT_DELIVERY_YES;
1571 }
1572
1573 void
1574 _SearchBar::OnActionPerformed(const _Control& source, int actionId)
1575 {
1576         if (__actionId == actionId)
1577         {
1578                 __isCancelActionInProgress = true;
1579                 SetMode(SEARCH_BAR_MODE_NORMAL);
1580
1581                 if (__pActionEvent)
1582                 {
1583                         IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(__actionId);
1584                         result r = GetLastResult();
1585                         SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1586
1587                         __pActionEvent->Fire(*pEventArg);
1588                 }
1589                 __isCancelActionInProgress = false;
1590         }
1591         return;
1592 }
1593
1594 // Keypad callbacks
1595 void
1596 _SearchBar::OnKeypadWillOpen(void)
1597 {
1598         if (__pKeypadEvent)
1599         {
1600                 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CREATED);
1601                 result r = GetLastResult();
1602                 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1603
1604                 __pKeypadEvent->Fire(*pEventArg);
1605         }
1606         return;
1607 }
1608
1609 void
1610 _SearchBar::OnKeypadOpened(void)
1611 {
1612         if (__pKeypadEvent)
1613         {
1614                 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_OPEN);
1615                 result r = GetLastResult();
1616                 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1617
1618                 __pKeypadEvent->Fire(*pEventArg);
1619         }
1620         return;
1621 }
1622
1623 void
1624 _SearchBar::OnKeypadClosed(void)
1625 {
1626         if (__pKeypadEvent)
1627         {
1628                 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CLOSE);
1629                 result r = GetLastResult();
1630                 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1631
1632                 __pKeypadEvent->Fire(*pEventArg);
1633         }
1634
1635         SetContentsArea();
1636         return;
1637 }
1638
1639 void
1640 _SearchBar::OnKeypadBoundsChanged(void)
1641 {
1642         if (__pKeypadEvent)
1643         {
1644                 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1645                 result r = GetLastResult();
1646                 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1647
1648                 __pKeypadEvent->Fire(*pEventArg);
1649         }
1650
1651         SetContentsArea();
1652         return;
1653 }
1654
1655 void
1656 _SearchBar::OnKeypadActionPerformed(CoreKeypadAction keypadAction)
1657 {
1658         if (__pKeypadEvent)
1659         {
1660                 IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(keypadAction, CORE_KEYPAD_EVENT_STATUS_ENTERACTION);
1661                 result r = GetLastResult();
1662                 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1663
1664                 __pKeypadEvent->Fire(*pEventArg);
1665         }
1666         return;
1667 }
1668
1669 // TextBlock callbacks
1670 void
1671 _SearchBar::OnTextBlockSelected(_Control& source, int start, int end)
1672 {
1673         if (__pTextBlockEvent)
1674         {
1675                 IEventArg* pEventArg = _TextBlockEvent::CreateTextBlockEventArgN(start, end);
1676                 result r = GetLastResult();
1677                 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1678
1679                 __pTextBlockEvent->Fire(*pEventArg);
1680         }
1681         return;
1682 }
1683
1684 // Text callbacks
1685 void
1686 _SearchBar::OnTextValueChanged(const _Control& source)
1687 {
1688         if (!__isCancelActionInProgress)
1689         {
1690                 SetContentDimming();
1691                 if (__pTextEvent != null)
1692                 {
1693                         IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CHANGED);
1694                         result r = GetLastResult();
1695                         SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1696
1697                         __pTextEvent->Fire(*pEventArg);
1698                 }
1699         }
1700         return;
1701 }
1702
1703 void
1704 _SearchBar::OnTextValueChangeCanceled(const _Control& source)
1705 {
1706         if (__pTextEvent != null)
1707         {
1708                 IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CANCELED);
1709                 result r = GetLastResult();
1710                 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1711
1712                 __pTextEvent->Fire(*pEventArg);
1713         }
1714         return;
1715 }
1716
1717 result
1718 _SearchBar::OnAttachedToMainTree(void)
1719 {
1720         SetContentsArea();
1721
1722         return E_SUCCESS;
1723 }
1724
1725 void
1726 _SearchBar::OnFontChanged(Font* pFont)
1727 {
1728         __pCancelButton->SetFont(pFont->GetFaceName());
1729         __pEdit->SetFont(*pFont);
1730         return;
1731 }
1732
1733 void
1734 _SearchBar::OnFontInfoRequested(unsigned long& style, int& size)
1735 {
1736         style = FONT_STYLE_PLAIN;
1737         size = __pCancelButton->GetTextSize();
1738
1739         return;
1740 }
1741
1742 bool
1743 _SearchBar::OnFocusGained(const _Control& source)
1744 {
1745         SetMode(SEARCH_BAR_MODE_INPUT);
1746         __pEdit->SetFocused();
1747         return false;
1748 }
1749
1750 bool
1751 _SearchBar::OnFocusLost(const _Control& source)
1752 {
1753         return false;
1754 }
1755
1756 bool
1757 _SearchBar::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1758 {
1759         if (!__pEdit->IsUsbKeyboardConnected())
1760         {
1761                 return false;
1762         }
1763
1764         _KeyCode keyCode = keyInfo.GetKeyCode();
1765
1766         if (keyCode == _KEY_RIGHT)
1767         {
1768                 if (__isButtonEnabled)
1769                 {
1770                         __pEdit->SetFocused(false);
1771                         __pCancelButton->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED);
1772                         __pCancelButton->SetFocused();
1773                         __pCancelButton->Invalidate(true);
1774                 }
1775
1776                 return true;
1777         }
1778
1779         if (keyCode == _KEY_LEFT)
1780         {
1781                 if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_HIGHLIGHTED)
1782                 {
1783                         __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1784                         __pCancelButton->SetFocused(false);
1785                         __pCancelButton->Invalidate();
1786
1787                 }
1788
1789                 if (__pCancelButton->GetButtonStatus() == _BUTTON_STATUS_DISABLED)      //Searchbar Button is disabled, left arrow key is pressed
1790                 {
1791                         __pCancelButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1792                         SetButtonEnabled(false);
1793                 }
1794
1795                 __pEdit->SetFocused();
1796
1797                 return true;
1798         }
1799
1800         return false;
1801 }
1802
1803 bool
1804 _SearchBar::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
1805 {
1806         return false;
1807 }
1808
1809 _Control*
1810 _SearchBar::GetParentForm(void) const
1811 {
1812         _Form* pForm = null;
1813         _Control* pControlCore = GetParent();
1814
1815         while (true)
1816         {
1817                 if (pControlCore == null)
1818                 {
1819                         SysLog(NID_UI_CTRL,"[E_SYSTEM] The parent form is null.");
1820
1821                         return null;
1822                 }
1823
1824                 pForm = dynamic_cast <_Form*>(pControlCore);
1825
1826                 if (pForm != null)
1827                 {
1828                         break;
1829                 }
1830
1831                 pControlCore = pControlCore->GetParent();
1832         }
1833
1834         return pControlCore;
1835 }
1836
1837 _Button*
1838 _SearchBar::GetSearchBarButton(void) const
1839 {
1840         return __pCancelButton;
1841 }
1842
1843 _Edit*
1844 _SearchBar::GetSearchField(void)
1845 {
1846         return __pEdit;
1847 }
1848
1849 _Control*
1850 _SearchBar::GetSearchBarContainer(void) const
1851 {
1852         return __pContainer;
1853 }
1854
1855 _Control*
1856 _SearchBar::GetClippedGroupControl(void) const
1857 {
1858         return __pClippedGroupControl;
1859 }
1860
1861 bool
1862 _SearchBar::IsUsableCancelButton(void) const
1863 {
1864         return __isUsableCancelButton;
1865 }
1866
1867 EditStatus
1868 _SearchBar::ConvertSearchBarStatus(SearchFieldStatus status)
1869 {
1870         EditStatus editStatus = EDIT_STATUS_NORMAL;
1871         switch (status)
1872         {
1873         case SEARCH_FIELD_STATUS_NORMAL:
1874                 editStatus = EDIT_STATUS_NORMAL;
1875                 break;
1876
1877         case SEARCH_FIELD_STATUS_DISABLED:
1878                 editStatus = EDIT_STATUS_DISABLED;
1879                 break;
1880
1881         case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1882                 editStatus = EDIT_STATUS_HIGHLIGHTED;
1883                 break;
1884         default:
1885                 break;
1886         }
1887
1888         return editStatus;
1889 }
1890
1891 _ButtonStatus
1892 _SearchBar::ConvertSearchBarButtonStatus(SearchBarButtonStatus status)
1893 {
1894         _ButtonStatus buttonStatus = _BUTTON_STATUS_NORMAL;
1895
1896         switch (status)
1897         {
1898         case SEARCH_BAR_BUTTON_STATUS_NORMAL:
1899                 buttonStatus = _BUTTON_STATUS_NORMAL;
1900                 break;
1901
1902         case SEARCH_BAR_BUTTON_STATUS_PRESSED:
1903                 buttonStatus = _BUTTON_STATUS_PRESSED;
1904                 break;
1905
1906         case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
1907                 buttonStatus = _BUTTON_STATUS_HIGHLIGHTED;
1908                 break;
1909
1910         case SEARCH_BAR_BUTTON_STATUS_DISABLED:
1911                 buttonStatus = _BUTTON_STATUS_DISABLED;
1912                 break;
1913         default:
1914                 break;
1915         }
1916
1917         return buttonStatus;
1918 }
1919
1920 result
1921 _SearchBar::SendSearchBarEvent(_SearchBarEventStatus status)
1922 {
1923         result r = E_SUCCESS;
1924         if (__pSearchBarEvent)
1925         {
1926                 IEventArg* pEventArg = _SearchBarEvent::CreateSearchBarEventArgN(status);
1927                 r = GetLastResult();
1928                 SysTryReturn(NID_UI_CTRL, pEventArg, r, r, "[%s] Propagating.", GetErrorMessage(r));
1929
1930                 if (IsContentAreaVisible() == false)
1931                 {
1932                         SetContentAreaVisible(false);
1933                 }
1934
1935                 __pSearchBarEvent->Fire(*pEventArg);
1936         }
1937
1938         return E_SUCCESS;
1939 }
1940
1941 void
1942 _SearchBar::SetHeaderVisibleState(bool visible)
1943 {
1944         if (__pSearchBarPresenter != null)
1945         {
1946                 __pSearchBarPresenter->SetHeaderVisibleState(visible);
1947         }
1948         return;
1949 }
1950
1951 result
1952 _SearchBar::SetPropertyButtonActionId(const Variant& actionId)
1953 {
1954         SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1955                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1956         SysTryReturn(NID_UI_CTRL, actionId.ToInt() > -1, E_INVALID_ARG, E_INVALID_ARG,
1957                      "[E_INVALID_ARG] Invalid argument(s) is used. actionId.ToInt() = %d", actionId.ToInt());
1958
1959         result r = E_SUCCESS;
1960
1961         r = __pCancelButton->SetPropertyActionId(actionId);
1962         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1963                      "[%s] A system error has occurred. Failed to set actionId.", GetErrorMessage(E_SYSTEM));
1964
1965         __actionId = actionId.ToInt();
1966
1967         return r;
1968 }
1969
1970 Variant
1971 _SearchBar::GetPropertyButtonActionId(void) const
1972 {
1973         SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(-1), E_SYSTEM,
1974                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1975
1976         return Variant(__actionId);
1977 }
1978
1979 result
1980 _SearchBar::SetPropertyButtonDisabledColor(const Variant& color)
1981 {
1982         SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1983                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1984
1985         result r = E_SUCCESS;
1986
1987         r = __pCancelButton->SetPropertyDisabledColor(color);
1988         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1989                      "[E_SYSTEM] A system error has occurred. Failed to set button color.");
1990
1991         __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = color.ToColor();
1992
1993         return r;
1994 }
1995
1996 Variant
1997 _SearchBar::GetPropertyButtonDisabledColor(void) const
1998 {
1999         SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2000                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2001
2002         return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2003 }
2004
2005 result
2006 _SearchBar::SetPropertyButtonHighlightedColor(const Variant& color)
2007 {
2008         SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2009                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2010
2011         result r = E_SUCCESS;
2012
2013         r = __pCancelButton->SetPropertyHighlightedColor(color);
2014         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2015                      "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2016
2017         __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
2018
2019         return r;
2020 }
2021
2022 Variant
2023 _SearchBar::GetPropertyButtonHighlightedColor(void) const
2024 {
2025         SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2026                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2027
2028         return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2029 }
2030
2031 result
2032 _SearchBar::SetPropertyButtonNormalColor(const Variant& color)
2033 {
2034         SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2035                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2036
2037         result r = E_SUCCESS;
2038
2039         r = __pCancelButton->SetPropertyNormalColor(color);
2040         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2041                      "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2042
2043         __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = color.ToColor();
2044
2045         return r;
2046 }
2047
2048 Variant
2049 _SearchBar::GetPropertyButtonNormalColor(void) const
2050 {
2051         SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2052                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2053
2054         return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2055 }
2056
2057 result
2058 _SearchBar::SetPropertyButtonPressedColor(const Variant& color)
2059 {
2060         SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2061                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2062
2063         result r = E_SUCCESS;
2064
2065         r = __pCancelButton->SetPropertyPressedColor(color);
2066         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2067                      "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2068
2069         __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = color.ToColor();
2070
2071         return r;
2072 }
2073
2074 Variant
2075 _SearchBar::GetPropertyButtonPressedColor(void) const
2076 {
2077         SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2078                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2079
2080         return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2081 }
2082
2083 result
2084 _SearchBar::SetPropertyButtonDisabledTextColor(const Variant& textColor)
2085 {
2086         SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2087                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2088
2089         result r = E_SUCCESS;
2090
2091         r = __pCancelButton->SetPropertyDisabledTextColor(textColor);
2092         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2093                      "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2094
2095         __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = textColor.ToColor();
2096
2097         return r;
2098 }
2099
2100 Variant
2101 _SearchBar::GetPropertyButtonDisabledTextColor(void) const
2102 {
2103         SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2104                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2105
2106         return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2107 }
2108
2109 result
2110 _SearchBar::SetPropertyButtonHighlightedTextColor(const Variant& textColor)
2111 {
2112         SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2113                      "[E_SYSTEM]] A system error has occurred. The cancel button instance is null.");
2114
2115         result r = E_SUCCESS;
2116
2117         r = __pCancelButton->SetPropertyHighlightedTextColor(textColor);
2118         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2119                      "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2120
2121         __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = textColor.ToColor();
2122
2123         return r;
2124 }
2125
2126 Variant
2127 _SearchBar::GetPropertyButtonHighlightedTextColor(void) const
2128 {
2129         SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2130                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2131
2132         return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2133 }
2134
2135 result
2136 _SearchBar::SetPropertyButtonNormalTextColor(const Variant& textColor)
2137 {
2138         SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2139                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2140
2141         result r = E_SUCCESS;
2142
2143         r = __pCancelButton->SetPropertyNormalTextColor(textColor);
2144         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2145                      "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2146
2147         __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = textColor.ToColor();
2148
2149         return r;
2150 }
2151
2152 Variant
2153 _SearchBar::GetPropertyButtonNormalTextColor(void) const
2154 {
2155         SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2156                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2157
2158         return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2159 }
2160
2161 result
2162 _SearchBar::SetPropertyButtonPressedTextColor(const Variant& textColor)
2163 {
2164         SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2165                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2166
2167         result r = E_SUCCESS;
2168
2169         r = __pCancelButton->SetPropertyPressedTextColor(textColor);
2170         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2171                      "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2172
2173         __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = textColor.ToColor();
2174
2175         return r;
2176 }
2177
2178 Variant
2179 _SearchBar::GetPropertyButtonPressedTextColor(void) const
2180 {
2181         SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2182                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2183
2184         return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2185 }
2186
2187 result
2188 _SearchBar::SetPropertySearchFieldDisabledColor(const Variant& color)
2189 {
2190         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2191                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2192
2193         result r = E_SUCCESS;
2194
2195         r = __pEdit->SetPropertyDisabledColor(color);
2196         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2197                      "[E_SYSTEM] A system error has occurred. Failed to set the edit disabled color.");
2198
2199         __color[SEARCH_FIELD_STATUS_DISABLED] = color.ToColor();
2200
2201         return r;
2202 }
2203
2204 Variant
2205 _SearchBar::GetPropertySearchFieldDisabledColor(void) const
2206 {
2207         SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2208                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2209
2210         return Variant(__color[SEARCH_FIELD_STATUS_DISABLED]);
2211 }
2212
2213 result
2214 _SearchBar::SetPropertySearchFieldHighlightedColor(const Variant& color)
2215 {
2216         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2217                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2218
2219         result r = E_SUCCESS;
2220
2221         r = __pEdit->SetPropertyHighlightedColor(color);
2222         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2223                      "[E_SYSTEM] A system error has occurred. Failed to set the edit highlighted color.");
2224
2225         __color[SEARCH_FIELD_STATUS_HIGHLIGHTED] = color.ToColor();
2226
2227         return r;
2228 }
2229
2230 Variant
2231 _SearchBar::GetPropertySearchFieldHighlightedColor(void) const
2232 {
2233         SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2234                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2235
2236         return Variant(__color[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2237 }
2238
2239 result
2240 _SearchBar::SetPropertySearchFieldNormalColor(const Variant& color)
2241 {
2242         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2243                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2244
2245         result r = E_SUCCESS;
2246
2247         r = __pEdit->SetPropertyNormalColor(color);
2248         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2249                      "[E_SYSTEM] A system error has occurred. Failed to set edit normal color.");
2250
2251         __color[SEARCH_FIELD_STATUS_NORMAL] = color.ToColor();
2252
2253         return r;
2254 }
2255
2256 Variant
2257 _SearchBar::GetPropertySearchFieldNormalColor(void) const
2258 {
2259         SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2260                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2261
2262         return Variant(__color[SEARCH_FIELD_STATUS_NORMAL]);
2263 }
2264
2265 result
2266 _SearchBar::SetPropertySearchFieldDisabledTextColor(const Variant& textColor)
2267 {
2268         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2269                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2270
2271         result r = E_SUCCESS;
2272
2273         r = __pEdit->SetPropertyDisabledTextColor(textColor);
2274         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2275                      "[E_SYSTEM] A system error has occurred. Failed to set edit disabled text color.");
2276
2277         __textColor[SEARCH_FIELD_STATUS_DISABLED] = textColor.ToColor();
2278
2279         return r;
2280 }
2281
2282 Variant
2283 _SearchBar::GetPropertySearchFieldDisabledTextColor(void) const
2284 {
2285         SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2286                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2287
2288         return Variant(__textColor[SEARCH_FIELD_STATUS_DISABLED]);
2289 }
2290
2291 result
2292 _SearchBar::SetPropertySearchFieldHighlightedTextColor(const Variant& textColor)
2293 {
2294         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2295                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2296
2297         result r = E_SUCCESS;
2298
2299         r = __pEdit->SetPropertyHighlightedTextColor(textColor);
2300         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2301                      "[E_SYSTEM] A system error has occurred. Failed to set edit highlighted text color.");
2302
2303         __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED] = textColor.ToColor();
2304
2305         return r;
2306 }
2307
2308 Variant
2309 _SearchBar::GetPropertySearchFieldHighlightedTextColor(void) const
2310 {
2311         SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2312                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2313
2314         return Variant(__textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2315 }
2316
2317 result
2318 _SearchBar::SetPropertySearchFieldNormalTextColor(const Variant& textColor)
2319 {
2320         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2321                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2322
2323         result r = E_SUCCESS;
2324
2325         r = __pEdit->SetPropertyNormalTextColor(textColor);
2326         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2327                      "[E_SYSTEM] A system error has occurred. Failed to set edit normal text color.");
2328
2329         __textColor[SEARCH_FIELD_STATUS_NORMAL] = textColor.ToColor();
2330
2331         return r;
2332 }
2333
2334 Variant
2335 _SearchBar::GetPropertySearchFieldNormalTextColor(void) const
2336 {
2337         SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2338                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2339
2340         return Variant(__textColor[SEARCH_FIELD_STATUS_NORMAL]);
2341 }
2342
2343 result
2344 _SearchBar::SetPropertyColor(const Variant& color)
2345 {
2346         __backgroundColor = color.ToColor();
2347
2348         return E_SUCCESS;
2349 }
2350
2351 Variant
2352 _SearchBar::GetPropertyColor(void) const
2353 {
2354         return Variant(__backgroundColor);
2355 }
2356
2357 result
2358 _SearchBar::SetPropertyContentAreaSize(const Variant& size)
2359 {
2360         FloatDimension contentAreaSize = size.ToFloatDimension();
2361         SysTryReturn(NID_UI_CTRL, contentAreaSize.width >= 0 && contentAreaSize.height >= 0, E_INVALID_ARG, E_INVALID_ARG,
2362                      "[E_INVALID_ARG] Invalid argument(s) is used. contentAreaSize.width = %f, contenAreaSize.height = %f",
2363                      contentAreaSize.width, contentAreaSize.height);
2364
2365         result r = E_SUCCESS;
2366
2367         // Todo
2368         FloatRectangle bounds = GetBoundsF();
2369         FloatRectangle contentAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
2370
2371         contentAreaBounds.x = 0.0f;
2372         contentAreaBounds.y = bounds.height;
2373         contentAreaBounds.width = contentAreaSize.width;
2374         contentAreaBounds.height = contentAreaSize.height;
2375
2376         __contentAreaBounds = contentAreaBounds;
2377         __isUserContainerBounds = true;
2378
2379         // set bounds
2380         if (__pContainer)
2381         {
2382                 r = __pContainer->SetBounds(__contentAreaBounds);
2383                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2384         }
2385
2386         return r;
2387 }
2388
2389 Variant
2390 _SearchBar::GetPropertyContentAreaSize(void) const
2391 {
2392         FloatDimension contentAreaSize(__contentAreaBounds.width, __contentAreaBounds.height);
2393
2394         return Variant(contentAreaSize);
2395 }
2396
2397 result
2398 _SearchBar::CreateClippedGroupControl(void)
2399 {
2400         result r = E_SUCCESS;
2401         FloatRectangle clippedGroupControlBounds(FloatPoint(0.0f, 0.0f), GetSizeF());
2402         __pClippedGroupControl = _Control::CreateControlN();
2403         r = GetLastResult();
2404         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2405
2406         r = AttachChild(*__pClippedGroupControl);
2407         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
2408                     "[E_SYSTEM] A system error has occurred. Failed to attach the parent of clipped control.");
2409
2410         r = __pClippedGroupControl->SetBounds(clippedGroupControlBounds);
2411         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2412
2413         __pClippedGroupControl->SetBackgroundColor(Color(0));
2414
2415         __pClippedGroupControl->SetClipChildrenEnabled(true);
2416
2417         return r;
2418
2419 CATCH:
2420         delete __pClippedGroupControl;
2421         __pClippedGroupControl = null;
2422
2423         return r;
2424
2425 }
2426
2427 void
2428 _SearchBar::SetContentDimming(void)
2429 {
2430         if (__pContainer != NULL)
2431         {
2432                 if (!GetTextLength())
2433                 {
2434                         __contentColor.SetAlpha(_SEARCH_CONTENT_DIM_OPACITY);
2435                 }
2436                 else
2437                 {
2438                         __contentColor.SetAlpha(0);
2439                 }
2440                 __pContainer->SetBackgroundColor(__contentColor);
2441         }
2442         return;
2443 }
2444
2445 bool
2446 _SearchBar::IsContentAttachable(const _Control* pContent)
2447 {
2448         const _Window* pWindow = dynamic_cast <const _Window*>(pContent);
2449         const _ColorPicker* pColorPicker = dynamic_cast <const _ColorPicker*>(pContent);
2450         const _Form* pForm = dynamic_cast <const _Form*>(pContent);
2451         const _Keypad* pKeypad = dynamic_cast <const _Keypad*>(pContent);
2452         const _OverlayPanel* pOverlayPanel = dynamic_cast <const _OverlayPanel*>(pContent);
2453
2454         bool isContentAttachable = true;
2455
2456         isContentAttachable = ((pWindow == null) && (pColorPicker == null) &&
2457                                (pForm == null) && (pKeypad == null) && (pOverlayPanel == null));
2458         return isContentAttachable;
2459 }
2460
2461 result
2462 _SearchBar::ResizeCancelButton(void)
2463 {
2464         result r = E_SUCCESS;
2465
2466         int horizontalMargin = 0;
2467         int buttonLeftMargin = 0;
2468         int buttonRightMargin = 0;
2469         int buttonMinWidth = 0;
2470         int searchFieldMinWidth = 0;
2471         int buttonVerticalMargin = 0;
2472         int searchBarMinHeight = 0;
2473         int buttonWidth = 0;
2474         int buttonHeight = 0;
2475
2476         FloatRectangle cancelButtonBounds;
2477         FloatRectangle searchBarBounds = GetBoundsF();
2478
2479         _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2480
2481         GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2482         GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2483         GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2484         GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2485         GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2486         GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2487         GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2488         GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2489         GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2490
2491         cancelButtonBounds.width = _CoordinateSystemUtils::ConvertToFloat(buttonWidth);
2492         cancelButtonBounds.height = _CoordinateSystemUtils::ConvertToFloat(buttonHeight);
2493
2494         float buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth +
2495                                              cancelButtonBounds.width + buttonLeftMargin + buttonRightMargin);
2496
2497         if (searchBarBounds.width < buttonResizableSearchBarWidth)
2498         {
2499                 cancelButtonBounds.width = searchBarBounds.width -(searchFieldMinWidth + buttonLeftMargin
2500                                                                    + buttonRightMargin + horizontalMargin);
2501         }
2502
2503         cancelButtonBounds.x = searchBarBounds.width - cancelButtonBounds.width - buttonRightMargin;
2504         cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2505
2506         if (searchBarBounds.height < searchBarMinHeight)
2507         {
2508                 cancelButtonBounds.y = buttonVerticalMargin;
2509         }
2510
2511         if (cancelButtonBounds.width < buttonMinWidth)
2512         {
2513                 cancelButtonBounds.width = buttonMinWidth;
2514         }
2515
2516         cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2517         cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2518         r = __pCancelButton->SetBounds(cancelButtonBounds);
2519
2520         return r;
2521
2522 }
2523
2524 SearchFieldStatus
2525 _SearchBar::GetCurrentStatus(void)
2526 {
2527         SearchFieldStatus searchFieldStatus = SEARCH_FIELD_STATUS_NORMAL;
2528
2529         if (IsEnabled())
2530         {
2531                 if (__pEdit->IsFocused())
2532                 {
2533                         searchFieldStatus = SEARCH_FIELD_STATUS_HIGHLIGHTED;
2534                 }
2535         }
2536         else
2537         {
2538                 searchFieldStatus = SEARCH_FIELD_STATUS_DISABLED;
2539         }
2540
2541         return searchFieldStatus;
2542 }
2543
2544 void
2545 _SearchBar::SetEditTextFilter(IEditTextFilter* pFilter)
2546 {
2547         SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2548                                "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2549
2550         __pEdit->SetEditTextFilter(pFilter);
2551
2552         return;
2553 }
2554
2555 void
2556 _SearchBar::SendOpaqueCommand(const String& command)
2557 {
2558         SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2559                                "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2560
2561         __pEdit->SendOpaqueCommand(command);
2562
2563         return;
2564 }
2565
2566 }}} // Tizen::Ui::Controls