merge with master
[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 _Control*
1757 _SearchBar::GetParentForm(void) const
1758 {
1759         _Form* pForm = null;
1760         _Control* pControlCore = GetParent();
1761
1762         while (true)
1763         {
1764                 if (pControlCore == null)
1765                 {
1766                         SysLog(NID_UI_CTRL,"[E_SYSTEM] The parent form is null.");
1767
1768                         return null;
1769                 }
1770
1771                 pForm = dynamic_cast <_Form*>(pControlCore);
1772
1773                 if (pForm != null)
1774                 {
1775                         break;
1776                 }
1777
1778                 pControlCore = pControlCore->GetParent();
1779         }
1780
1781         return pControlCore;
1782 }
1783
1784 _Button*
1785 _SearchBar::GetSearchBarButton(void) const
1786 {
1787         return __pCancelButton;
1788 }
1789
1790 _Edit*
1791 _SearchBar::GetSearchField(void)
1792 {
1793         return __pEdit;
1794 }
1795
1796 _Control*
1797 _SearchBar::GetSearchBarContainer(void) const
1798 {
1799         return __pContainer;
1800 }
1801
1802 _Control*
1803 _SearchBar::GetClippedGroupControl(void) const
1804 {
1805         return __pClippedGroupControl;
1806 }
1807
1808 bool
1809 _SearchBar::IsUsableCancelButton(void) const
1810 {
1811         return __isUsableCancelButton;
1812 }
1813
1814 EditStatus
1815 _SearchBar::ConvertSearchBarStatus(SearchFieldStatus status)
1816 {
1817         EditStatus editStatus = EDIT_STATUS_NORMAL;
1818         switch (status)
1819         {
1820         case SEARCH_FIELD_STATUS_NORMAL:
1821                 editStatus = EDIT_STATUS_NORMAL;
1822                 break;
1823
1824         case SEARCH_FIELD_STATUS_DISABLED:
1825                 editStatus = EDIT_STATUS_DISABLED;
1826                 break;
1827
1828         case SEARCH_FIELD_STATUS_HIGHLIGHTED:
1829                 editStatus = EDIT_STATUS_HIGHLIGHTED;
1830                 break;
1831         default:
1832                 break;
1833         }
1834
1835         return editStatus;
1836 }
1837
1838 _ButtonStatus
1839 _SearchBar::ConvertSearchBarButtonStatus(SearchBarButtonStatus status)
1840 {
1841         _ButtonStatus buttonStatus = _BUTTON_STATUS_NORMAL;
1842
1843         switch (status)
1844         {
1845         case SEARCH_BAR_BUTTON_STATUS_NORMAL:
1846                 buttonStatus = _BUTTON_STATUS_NORMAL;
1847                 break;
1848
1849         case SEARCH_BAR_BUTTON_STATUS_PRESSED:
1850                 buttonStatus = _BUTTON_STATUS_PRESSED;
1851                 break;
1852
1853         case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
1854                 buttonStatus = _BUTTON_STATUS_HIGHLIGHTED;
1855                 break;
1856
1857         case SEARCH_BAR_BUTTON_STATUS_DISABLED:
1858                 buttonStatus = _BUTTON_STATUS_DISABLED;
1859                 break;
1860         default:
1861                 break;
1862         }
1863
1864         return buttonStatus;
1865 }
1866
1867 result
1868 _SearchBar::SendSearchBarEvent(_SearchBarEventStatus status)
1869 {
1870         result r = E_SUCCESS;
1871         if (__pSearchBarEvent)
1872         {
1873                 IEventArg* pEventArg = _SearchBarEvent::CreateSearchBarEventArgN(status);
1874                 r = GetLastResult();
1875                 SysTryReturn(NID_UI_CTRL, pEventArg, r, r, "[%s] Propagating.", GetErrorMessage(r));
1876
1877                 if (IsContentAreaVisible() == false)
1878                 {
1879                         SetContentAreaVisible(false);
1880                 }
1881
1882                 __pSearchBarEvent->Fire(*pEventArg);
1883         }
1884
1885         return E_SUCCESS;
1886 }
1887
1888 void
1889 _SearchBar::SetHeaderVisibleState(bool visible)
1890 {
1891         if (__pSearchBarPresenter != null)
1892         {
1893                 __pSearchBarPresenter->SetHeaderVisibleState(visible);
1894         }
1895         return;
1896 }
1897
1898 result
1899 _SearchBar::SetPropertyButtonActionId(const Variant& actionId)
1900 {
1901         SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1902                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1903         SysTryReturn(NID_UI_CTRL, actionId.ToInt() > -1, E_INVALID_ARG, E_INVALID_ARG,
1904                      "[E_INVALID_ARG] Invalid argument(s) is used. actionId.ToInt() = %d", actionId.ToInt());
1905
1906         result r = E_SUCCESS;
1907
1908         r = __pCancelButton->SetPropertyActionId(actionId);
1909         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1910                      "[%s] A system error has occurred. Failed to set actionId.", GetErrorMessage(E_SYSTEM));
1911
1912         __actionId = actionId.ToInt();
1913
1914         return r;
1915 }
1916
1917 Variant
1918 _SearchBar::GetPropertyButtonActionId(void) const
1919 {
1920         SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(-1), E_SYSTEM,
1921                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1922
1923         return Variant(__actionId);
1924 }
1925
1926 result
1927 _SearchBar::SetPropertyButtonDisabledColor(const Variant& color)
1928 {
1929         SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1930                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1931
1932         result r = E_SUCCESS;
1933
1934         r = __pCancelButton->SetPropertyDisabledColor(color);
1935         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1936                      "[E_SYSTEM] A system error has occurred. Failed to set button color.");
1937
1938         __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = color.ToColor();
1939
1940         return r;
1941 }
1942
1943 Variant
1944 _SearchBar::GetPropertyButtonDisabledColor(void) const
1945 {
1946         SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
1947                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1948
1949         return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
1950 }
1951
1952 result
1953 _SearchBar::SetPropertyButtonHighlightedColor(const Variant& color)
1954 {
1955         SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1956                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1957
1958         result r = E_SUCCESS;
1959
1960         r = __pCancelButton->SetPropertyHighlightedColor(color);
1961         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1962                      "[E_SYSTEM] A system error has occurred. Failed to set button color.");
1963
1964         __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
1965
1966         return r;
1967 }
1968
1969 Variant
1970 _SearchBar::GetPropertyButtonHighlightedColor(void) const
1971 {
1972         SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
1973                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1974
1975         return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
1976 }
1977
1978 result
1979 _SearchBar::SetPropertyButtonNormalColor(const Variant& color)
1980 {
1981         SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
1982                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
1983
1984         result r = E_SUCCESS;
1985
1986         r = __pCancelButton->SetPropertyNormalColor(color);
1987         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1988                      "[E_SYSTEM] A system error has occurred. Failed to set button color.");
1989
1990         __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = color.ToColor();
1991
1992         return r;
1993 }
1994
1995 Variant
1996 _SearchBar::GetPropertyButtonNormalColor(void) const
1997 {
1998         SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
1999                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2000
2001         return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2002 }
2003
2004 result
2005 _SearchBar::SetPropertyButtonPressedColor(const Variant& color)
2006 {
2007         SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2008                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2009
2010         result r = E_SUCCESS;
2011
2012         r = __pCancelButton->SetPropertyPressedColor(color);
2013         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2014                      "[E_SYSTEM] A system error has occurred. Failed to set button color.");
2015
2016         __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = color.ToColor();
2017
2018         return r;
2019 }
2020
2021 Variant
2022 _SearchBar::GetPropertyButtonPressedColor(void) const
2023 {
2024         SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2025                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2026
2027         return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2028 }
2029
2030 result
2031 _SearchBar::SetPropertyButtonDisabledTextColor(const Variant& textColor)
2032 {
2033         SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2034                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2035
2036         result r = E_SUCCESS;
2037
2038         r = __pCancelButton->SetPropertyDisabledTextColor(textColor);
2039         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2040                      "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2041
2042         __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = textColor.ToColor();
2043
2044         return r;
2045 }
2046
2047 Variant
2048 _SearchBar::GetPropertyButtonDisabledTextColor(void) const
2049 {
2050         SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2051                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2052
2053         return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]);
2054 }
2055
2056 result
2057 _SearchBar::SetPropertyButtonHighlightedTextColor(const Variant& textColor)
2058 {
2059         SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2060                      "[E_SYSTEM]] A system error has occurred. The cancel button instance is null.");
2061
2062         result r = E_SUCCESS;
2063
2064         r = __pCancelButton->SetPropertyHighlightedTextColor(textColor);
2065         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2066                      "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2067
2068         __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = textColor.ToColor();
2069
2070         return r;
2071 }
2072
2073 Variant
2074 _SearchBar::GetPropertyButtonHighlightedTextColor(void) const
2075 {
2076         SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2077                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2078
2079         return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]);
2080 }
2081
2082 result
2083 _SearchBar::SetPropertyButtonNormalTextColor(const Variant& textColor)
2084 {
2085         SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2086                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2087
2088         result r = E_SUCCESS;
2089
2090         r = __pCancelButton->SetPropertyNormalTextColor(textColor);
2091         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2092                      "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2093
2094         __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = textColor.ToColor();
2095
2096         return r;
2097 }
2098
2099 Variant
2100 _SearchBar::GetPropertyButtonNormalTextColor(void) const
2101 {
2102         SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2103                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2104
2105         return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]);
2106 }
2107
2108 result
2109 _SearchBar::SetPropertyButtonPressedTextColor(const Variant& textColor)
2110 {
2111         SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
2112                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2113
2114         result r = E_SUCCESS;
2115
2116         r = __pCancelButton->SetPropertyPressedTextColor(textColor);
2117         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2118                      "[E_SYSTEM] A system error has occurred. Failed to set button text color.");
2119
2120         __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = textColor.ToColor();
2121
2122         return r;
2123 }
2124
2125 Variant
2126 _SearchBar::GetPropertyButtonPressedTextColor(void) const
2127 {
2128         SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM,
2129                      "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
2130
2131         return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]);
2132 }
2133
2134 result
2135 _SearchBar::SetPropertySearchFieldDisabledColor(const Variant& color)
2136 {
2137         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2138                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2139
2140         result r = E_SUCCESS;
2141
2142         r = __pEdit->SetPropertyDisabledColor(color);
2143         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2144                      "[E_SYSTEM] A system error has occurred. Failed to set the edit disabled color.");
2145
2146         __color[SEARCH_FIELD_STATUS_DISABLED] = color.ToColor();
2147
2148         return r;
2149 }
2150
2151 Variant
2152 _SearchBar::GetPropertySearchFieldDisabledColor(void) const
2153 {
2154         SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2155                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2156
2157         return Variant(__color[SEARCH_FIELD_STATUS_DISABLED]);
2158 }
2159
2160 result
2161 _SearchBar::SetPropertySearchFieldHighlightedColor(const Variant& color)
2162 {
2163         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2164                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2165
2166         result r = E_SUCCESS;
2167
2168         r = __pEdit->SetPropertyHighlightedColor(color);
2169         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2170                      "[E_SYSTEM] A system error has occurred. Failed to set the edit highlighted color.");
2171
2172         __color[SEARCH_FIELD_STATUS_HIGHLIGHTED] = color.ToColor();
2173
2174         return r;
2175 }
2176
2177 Variant
2178 _SearchBar::GetPropertySearchFieldHighlightedColor(void) const
2179 {
2180         SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2181                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2182
2183         return Variant(__color[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2184 }
2185
2186 result
2187 _SearchBar::SetPropertySearchFieldNormalColor(const Variant& color)
2188 {
2189         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2190                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2191
2192         result r = E_SUCCESS;
2193
2194         r = __pEdit->SetPropertyNormalColor(color);
2195         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2196                      "[E_SYSTEM] A system error has occurred. Failed to set edit normal color.");
2197
2198         __color[SEARCH_FIELD_STATUS_NORMAL] = color.ToColor();
2199
2200         return r;
2201 }
2202
2203 Variant
2204 _SearchBar::GetPropertySearchFieldNormalColor(void) const
2205 {
2206         SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2207                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2208
2209         return Variant(__color[SEARCH_FIELD_STATUS_NORMAL]);
2210 }
2211
2212 result
2213 _SearchBar::SetPropertySearchFieldDisabledTextColor(const Variant& textColor)
2214 {
2215         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2216                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2217
2218         result r = E_SUCCESS;
2219
2220         r = __pEdit->SetPropertyDisabledTextColor(textColor);
2221         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2222                      "[E_SYSTEM] A system error has occurred. Failed to set edit disabled text color.");
2223
2224         __textColor[SEARCH_FIELD_STATUS_DISABLED] = textColor.ToColor();
2225
2226         return r;
2227 }
2228
2229 Variant
2230 _SearchBar::GetPropertySearchFieldDisabledTextColor(void) const
2231 {
2232         SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2233                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2234
2235         return Variant(__textColor[SEARCH_FIELD_STATUS_DISABLED]);
2236 }
2237
2238 result
2239 _SearchBar::SetPropertySearchFieldHighlightedTextColor(const Variant& textColor)
2240 {
2241         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2242                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2243
2244         result r = E_SUCCESS;
2245
2246         r = __pEdit->SetPropertyHighlightedTextColor(textColor);
2247         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2248                      "[E_SYSTEM] A system error has occurred. Failed to set edit highlighted text color.");
2249
2250         __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED] = textColor.ToColor();
2251
2252         return r;
2253 }
2254
2255 Variant
2256 _SearchBar::GetPropertySearchFieldHighlightedTextColor(void) const
2257 {
2258         SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2259                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2260
2261         return Variant(__textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]);
2262 }
2263
2264 result
2265 _SearchBar::SetPropertySearchFieldNormalTextColor(const Variant& textColor)
2266 {
2267         SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM,
2268                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2269
2270         result r = E_SUCCESS;
2271
2272         r = __pEdit->SetPropertyNormalTextColor(textColor);
2273         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
2274                      "[E_SYSTEM] A system error has occurred. Failed to set edit normal text color.");
2275
2276         __textColor[SEARCH_FIELD_STATUS_NORMAL] = textColor.ToColor();
2277
2278         return r;
2279 }
2280
2281 Variant
2282 _SearchBar::GetPropertySearchFieldNormalTextColor(void) const
2283 {
2284         SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM,
2285                      "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2286
2287         return Variant(__textColor[SEARCH_FIELD_STATUS_NORMAL]);
2288 }
2289
2290 result
2291 _SearchBar::SetPropertyColor(const Variant& color)
2292 {
2293         __backgroundColor = color.ToColor();
2294
2295         return E_SUCCESS;
2296 }
2297
2298 Variant
2299 _SearchBar::GetPropertyColor(void) const
2300 {
2301         return Variant(__backgroundColor);
2302 }
2303
2304 result
2305 _SearchBar::SetPropertyContentAreaSize(const Variant& size)
2306 {
2307         FloatDimension contentAreaSize = size.ToFloatDimension();
2308         SysTryReturn(NID_UI_CTRL, contentAreaSize.width >= 0 && contentAreaSize.height >= 0, E_INVALID_ARG, E_INVALID_ARG,
2309                      "[E_INVALID_ARG] Invalid argument(s) is used. contentAreaSize.width = %f, contenAreaSize.height = %f",
2310                      contentAreaSize.width, contentAreaSize.height);
2311
2312         result r = E_SUCCESS;
2313
2314         // Todo
2315         FloatRectangle bounds = GetBoundsF();
2316         FloatRectangle contentAreaBounds(0.0f, 0.0f, 0.0f, 0.0f);
2317
2318         contentAreaBounds.x = 0.0f;
2319         contentAreaBounds.y = bounds.height;
2320         contentAreaBounds.width = contentAreaSize.width;
2321         contentAreaBounds.height = contentAreaSize.height;
2322
2323         __contentAreaBounds = contentAreaBounds;
2324         __isUserContainerBounds = true;
2325
2326         // set bounds
2327         if (__pContainer)
2328         {
2329                 r = __pContainer->SetBounds(__contentAreaBounds);
2330                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2331         }
2332
2333         return r;
2334 }
2335
2336 Variant
2337 _SearchBar::GetPropertyContentAreaSize(void) const
2338 {
2339         FloatDimension contentAreaSize(__contentAreaBounds.width, __contentAreaBounds.height);
2340
2341         return Variant(contentAreaSize);
2342 }
2343
2344 result
2345 _SearchBar::CreateClippedGroupControl(void)
2346 {
2347         result r = E_SUCCESS;
2348         FloatRectangle clippedGroupControlBounds(FloatPoint(0.0f, 0.0f), GetSizeF());
2349         __pClippedGroupControl = _Control::CreateControlN();
2350         r = GetLastResult();
2351         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
2352
2353         r = AttachChild(*__pClippedGroupControl);
2354         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
2355                     "[E_SYSTEM] A system error has occurred. Failed to attach the parent of clipped control.");
2356
2357         r = __pClippedGroupControl->SetBounds(clippedGroupControlBounds);
2358         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2359
2360         __pClippedGroupControl->SetBackgroundColor(Color(0));
2361
2362         __pClippedGroupControl->SetClipChildrenEnabled(true);
2363
2364         return r;
2365
2366 CATCH:
2367         delete __pClippedGroupControl;
2368         __pClippedGroupControl = null;
2369
2370         return r;
2371
2372 }
2373
2374 void
2375 _SearchBar::SetContentDimming(void)
2376 {
2377         if (__pContainer != NULL)
2378         {
2379                 if (!GetTextLength())
2380                 {
2381                         __contentColor.SetAlpha(_SEARCH_CONTENT_DIM_OPACITY);
2382                 }
2383                 else
2384                 {
2385                         __contentColor.SetAlpha(0);
2386                 }
2387                 __pContainer->SetBackgroundColor(__contentColor);
2388         }
2389         return;
2390 }
2391
2392 bool
2393 _SearchBar::IsContentAttachable(const _Control* pContent)
2394 {
2395         const _Window* pWindow = dynamic_cast <const _Window*>(pContent);
2396         const _ColorPicker* pColorPicker = dynamic_cast <const _ColorPicker*>(pContent);
2397         const _Form* pForm = dynamic_cast <const _Form*>(pContent);
2398         const _Keypad* pKeypad = dynamic_cast <const _Keypad*>(pContent);
2399         const _OverlayPanel* pOverlayPanel = dynamic_cast <const _OverlayPanel*>(pContent);
2400
2401         bool isContentAttachable = true;
2402
2403         isContentAttachable = ((pWindow == null) && (pColorPicker == null) &&
2404                                (pForm == null) && (pKeypad == null) && (pOverlayPanel == null));
2405         return isContentAttachable;
2406 }
2407
2408 result
2409 _SearchBar::ResizeCancelButton(void)
2410 {
2411         result r = E_SUCCESS;
2412
2413         int horizontalMargin = 0;
2414         int buttonLeftMargin = 0;
2415         int buttonRightMargin = 0;
2416         int buttonMinWidth = 0;
2417         int searchFieldMinWidth = 0;
2418         int buttonVerticalMargin = 0;
2419         int searchBarMinHeight = 0;
2420         int buttonWidth = 0;
2421         int buttonHeight = 0;
2422
2423         FloatRectangle cancelButtonBounds;
2424         FloatRectangle searchBarBounds = GetBoundsF();
2425
2426         _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
2427
2428         GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin);
2429         GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin);
2430         GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin);
2431         GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth);
2432         GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, buttonHeight);
2433         GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth);
2434         GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth);
2435         GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, buttonVerticalMargin);
2436         GET_SHAPE_CONFIG(SEARCHBAR::MIN_HEIGHT, orientation, searchBarMinHeight);
2437
2438         cancelButtonBounds.width = _CoordinateSystemUtils::ConvertToFloat(buttonWidth);
2439         cancelButtonBounds.height = _CoordinateSystemUtils::ConvertToFloat(buttonHeight);
2440
2441         float buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth +
2442                                              cancelButtonBounds.width + buttonLeftMargin + buttonRightMargin);
2443
2444         if (searchBarBounds.width < buttonResizableSearchBarWidth)
2445         {
2446                 cancelButtonBounds.width = searchBarBounds.width -(searchFieldMinWidth + buttonLeftMargin
2447                                                                    + buttonRightMargin + horizontalMargin);
2448         }
2449
2450         cancelButtonBounds.x = searchBarBounds.width - cancelButtonBounds.width - buttonRightMargin;
2451         cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2.0f;
2452
2453         if (searchBarBounds.height < searchBarMinHeight)
2454         {
2455                 cancelButtonBounds.y = buttonVerticalMargin;
2456         }
2457
2458         if (cancelButtonBounds.width < buttonMinWidth)
2459         {
2460                 cancelButtonBounds.width = buttonMinWidth;
2461         }
2462
2463         cancelButtonBounds.width = (cancelButtonBounds.width > 0.0f) ? cancelButtonBounds.width : 0.0f;
2464         cancelButtonBounds.height = (cancelButtonBounds.height > 0.0f) ? cancelButtonBounds.height : 0.0f;
2465         r = __pCancelButton->SetBounds(cancelButtonBounds);
2466
2467         return r;
2468
2469 }
2470
2471 SearchFieldStatus
2472 _SearchBar::GetCurrentStatus(void)
2473 {
2474         SearchFieldStatus searchFieldStatus = SEARCH_FIELD_STATUS_NORMAL;
2475
2476         if (IsEnabled())
2477         {
2478                 if (__pEdit->IsFocused())
2479                 {
2480                         searchFieldStatus = SEARCH_FIELD_STATUS_HIGHLIGHTED;
2481                 }
2482         }
2483         else
2484         {
2485                 searchFieldStatus = SEARCH_FIELD_STATUS_DISABLED;
2486         }
2487
2488         return searchFieldStatus;
2489 }
2490
2491 void
2492 _SearchBar::SetEditTextFilter(IEditTextFilter* pFilter)
2493 {
2494         SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2495                                "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2496
2497         __pEdit->SetEditTextFilter(pFilter);
2498
2499         return;
2500 }
2501
2502 void
2503 _SearchBar::SendOpaqueCommand(const String& command)
2504 {
2505         SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM,
2506                                "[E_SYSTEM] A system error has occurred. The edit instance is null.");
2507
2508         __pEdit->SendOpaqueCommand(command);
2509
2510         return;
2511 }
2512
2513 }}} // Tizen::Ui::Controls