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