Tizen 2.1 base
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_SearchBarImpl.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_SearchBarImpl.cpp
20  * @brief       This is the implementation file for _SearchBarImpl class.
21  */
22
23 #include <FApp_AppInfo.h>
24 #include <FBaseSysLog.h>
25 #include <FLclLocale.h>
26 #include "FUi_ResourceSizeInfo.h"
27 #include "FUi_ResourceManager.h"
28 #include "FUi_UiBuilder.h"
29 #include "FUiCtrl_PublicActionEvent.h"
30 #include "FUiCtrl_PublicTextBlockEvent.h"
31 #include "FUiCtrl_PublicTextEvent.h"
32 #include "FUiCtrl_SearchBarImpl.h"
33
34 using namespace Tizen::App;
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Runtime;
37 using namespace Tizen::Locales;
38 using namespace Tizen::Graphics;
39 using namespace Tizen::Ui;
40
41 namespace Tizen { namespace Ui { namespace Controls
42 {
43
44 _SearchBarImpl::_SearchBarImpl(SearchBar* pPublic, _SearchBar* pCore)
45         : _ControlImpl(pPublic, pCore)
46         , __pSearchBar(pCore)
47         , __pContentControl(null)
48         , __pPublicActionEvent(null)
49         , __pPublicKeypadEvent(null)
50         , __pPublicTextBlockEvent(null)
51         , __pPublicTextEvent(null)
52         , __pPublicSearchBarEvent(null)
53         , __pPublicLanguageEvent(null)
54 {
55         ClearLastResult();
56 }
57
58 _SearchBarImpl::~_SearchBarImpl(void)
59 {
60         if (__pSearchBar)
61         {
62                 SetContent(null);
63         }
64
65         if (__pPublicActionEvent)
66         {
67                 delete __pPublicActionEvent;
68                 __pPublicActionEvent = null;
69         }
70
71         if (__pPublicKeypadEvent)
72         {
73                 delete __pPublicKeypadEvent;
74                 __pPublicKeypadEvent = null;
75         }
76
77         if (__pPublicTextBlockEvent)
78         {
79                 delete __pPublicTextBlockEvent;
80                 __pPublicTextBlockEvent = null;
81         }
82
83         if (__pPublicTextEvent)
84         {
85                 delete __pPublicTextEvent;
86                 __pPublicTextEvent = null;
87         }
88
89         if (__pPublicSearchBarEvent)
90         {
91                 delete __pPublicSearchBarEvent;
92                 __pPublicSearchBarEvent = null;
93         }
94 }
95
96 _SearchBarImpl*
97 _SearchBarImpl::CreateSearchBarImplN(SearchBar* pControl, const Rectangle& bounds, bool enableSearchBarButton, KeypadAction keypadAction)
98 {
99         ClearLastResult();
100         result r = E_SUCCESS;
101
102         r = GET_SIZE_INFO(SearchBar).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
103         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_INVALID_ARG,
104                      "[E_INVALID_ARG] Invalid argument(s) is used. The given size is not valid.");
105
106         _SearchBar* pCore = _SearchBar::CreateSearchBarN();
107         r = GetLastResult();
108         SysTryReturn(NID_UI_CTRL, pCore != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
109
110         _SearchBarImpl* pImpl = new (std::nothrow) _SearchBarImpl(pControl, pCore);
111
112         r = CheckConstruction(pCore, pImpl);
113         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
114
115         r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(SearchBar), bounds, pCore->GetOrientation());
116         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
117
118         r = pImpl->Initialize(enableSearchBarButton, keypadAction);
119         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
120
121         return pImpl;
122 CATCH:
123         delete pImpl;
124         return null;
125 }
126
127 const char*
128 _SearchBarImpl::GetPublicClassName(void) const
129 {
130         return "Tizen::Ui::Controls::SearchBar";
131 }
132
133 const SearchBar&
134 _SearchBarImpl::GetPublic(void) const
135 {
136         return static_cast <const SearchBar&>(_ControlImpl::GetPublic());
137 }
138
139 SearchBar&
140 _SearchBarImpl::GetPublic(void)
141 {
142         return static_cast <SearchBar&>(_ControlImpl::GetPublic());
143 }
144
145 const _SearchBar&
146 _SearchBarImpl::GetCore(void) const
147 {
148         return static_cast <const _SearchBar&>(_ControlImpl::GetCore());
149 }
150
151 _SearchBar&
152 _SearchBarImpl::GetCore(void)
153 {
154         return static_cast <_SearchBar&>(_ControlImpl::GetCore());
155 }
156
157 _SearchBarImpl*
158 _SearchBarImpl::GetInstance(SearchBar& searchBar)
159 {
160         return (static_cast<_SearchBarImpl*>(searchBar._pControlImpl));
161 }
162
163 const _SearchBarImpl*
164 _SearchBarImpl::GetInstance(const SearchBar& searchBar)
165 {
166         return (static_cast<const _SearchBarImpl*>(searchBar._pControlImpl));
167 }
168
169
170 result
171 _SearchBarImpl::Initialize(bool enableSearchBarButton, KeypadAction keypadAction)
172 {
173         ClearLastResult();
174
175         result r = E_SUCCESS;
176
177         CoreKeypadAction coreKeypadAction = CORE_KEYPAD_ACTION_SEARCH;
178         switch (keypadAction)
179         {
180         case KEYPAD_ACTION_ENTER:
181                 coreKeypadAction = CORE_KEYPAD_ACTION_ENTER;
182                 break;
183
184         case KEYPAD_ACTION_GO:
185                 coreKeypadAction = CORE_KEYPAD_ACTION_GO;
186                 break;
187
188         case KEYPAD_ACTION_NEXT:
189                 coreKeypadAction = CORE_KEYPAD_ACTION_NEXT;
190                 break;
191
192         case KEYPAD_ACTION_SEND:
193                 coreKeypadAction = CORE_KEYPAD_ACTION_SEND;
194                 break;
195
196         case KEYPAD_ACTION_SEARCH:
197                 coreKeypadAction = CORE_KEYPAD_ACTION_SEARCH;
198                 break;
199
200         case KEYPAD_ACTION_LOGIN:
201                 coreKeypadAction = CORE_KEYPAD_ACTION_LOGIN;
202                 break;
203
204         case KEYPAD_ACTION_SIGN_IN:
205                 coreKeypadAction = CORE_KEYPAD_ACTION_SIGN_IN;
206                 break;
207
208         case KEYPAD_ACTION_JOIN:
209                 coreKeypadAction = CORE_KEYPAD_ACTION_JOIN;
210                 break;
211
212         case KEYPAD_ACTION_DONE:
213                 coreKeypadAction = CORE_KEYPAD_ACTION_DONE;
214                 break;
215
216         default:
217                 break;
218         }
219
220         r = __pSearchBar->Initialize(enableSearchBarButton, coreKeypadAction);
221         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
222
223         __pPublicActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
224         r = GetLastResult();
225         SysTryReturn(NID_UI_CTRL, __pPublicActionEvent, r, r, "[%s] Propagating.", GetErrorMessage(r));
226
227         r = __pSearchBar->AddActionEventListener(*this);
228         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
229
230         __pPublicKeypadEvent = _PublicKeypadEvent::CreateInstanceN(GetPublic());
231         r = GetLastResult();
232         SysTryReturn(NID_UI_CTRL, __pPublicKeypadEvent, r, r, "[%s] Propagating.", GetErrorMessage(r));
233
234         r = __pSearchBar->AddKeypadEventListener(*this);
235         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
236
237         __pPublicTextBlockEvent = _PublicTextBlockEvent::CreateInstanceN(GetPublic());
238         r = GetLastResult();
239         SysTryReturn(NID_UI_CTRL, __pPublicTextBlockEvent, r, r, "[%s] Propagating.", GetErrorMessage(r));
240
241         r = __pSearchBar->AddTextBlockEventListener(*this);
242         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
243
244         __pPublicTextEvent = _PublicTextEvent::CreateInstanceN(GetPublic());
245         r = GetLastResult();
246         SysTryReturn(NID_UI_CTRL, __pPublicTextEvent, r, r, "[%s] Propagating.", GetErrorMessage(r));
247
248         r = __pSearchBar->AddTextEventListener(*this);
249         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
250
251         __pPublicSearchBarEvent = _PublicSearchBarEvent::CreateInstanceN(GetPublic());
252         r = GetLastResult();
253         SysTryReturn(NID_UI_CTRL, __pPublicSearchBarEvent, r, r, "[%s] Propagating.", GetErrorMessage(r));
254
255         r = __pSearchBar->AddSearchBarEventListener(*this);
256         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
257
258         __pPublicLanguageEvent = _PublicLanguageEvent::CreateInstanceN(GetPublic());
259         r = GetLastResult();
260         SysTryReturn(NID_UI_CTRL, __pPublicLanguageEvent, r, r, "[%s] Propagating.", GetErrorMessage(r));
261
262         r = __pSearchBar->AddLanguageEventListener(*this);
263         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
264
265         return r;
266 }
267
268 Control*
269 _SearchBarImpl::GetContent(void) const
270 {
271         ClearLastResult();
272
273         return __pContentControl;
274 }
275
276 result
277 _SearchBarImpl::SetContent(const Control* pContent)
278 {
279         ClearLastResult();
280
281         result r = E_SUCCESS;
282         if (pContent != null)
283         {
284                 const _Control& content = _ControlImpl::GetInstance(*pContent)->GetCore();
285                 bool isContentAttachable = __pSearchBar->IsContentAttachable(&content);
286                 SysTryReturn(NID_UI_CTRL, isContentAttachable, E_INVALID_ARG, E_INVALID_ARG,
287                              "[E_INVALID_ARG] Invalid argument(s) is used. The content cannot be set.");
288         }
289
290         if (__pContentControl != null)
291         {
292                 _Control& contentControl = _ControlImpl::GetInstance(*__pContentControl)->GetCore();
293
294                 if (pContent != null)
295                 {
296                         const _Control& content = _ControlImpl::GetInstance(*pContent)->GetCore();
297
298                         if (contentControl.GetHandle() == content.GetHandle())
299                         {
300                                 return r;
301                         }
302                 }
303
304                 _Control* pContainer = __pSearchBar->GetSearchBarContainer();
305
306                 if (pContainer)
307                 {
308                         pContainer->DetachChild(contentControl);
309
310                         if(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
311                         {
312                                 delete __pContentControl;
313                         }
314                         __pContentControl = null;
315                 }
316         }
317
318         if (pContent != null && __pContentControl == null)
319         {
320                 __pContentControl = const_cast <Control*>(pContent);
321                 _Control& control = _ControlImpl::GetInstance(*__pContentControl)->GetCore();
322
323                 r = __pSearchBar->SetContent(&control);
324         }
325
326         return r;
327 }
328
329 result
330 _SearchBarImpl::UpdateContentArea(bool invalidate)
331 {
332         ClearLastResult();
333
334         return __pSearchBar->UpdateContentArea(invalidate);
335 }
336
337 result
338 _SearchBarImpl::SetContentAreaVisible(bool visible)
339 {
340         ClearLastResult();
341
342         return __pSearchBar->SetContentAreaVisible(visible);
343 }
344
345 bool
346 _SearchBarImpl::IsContentAreaVisible(void) const
347 {
348         ClearLastResult();
349
350         return __pSearchBar->IsContentAreaVisible();
351 }
352
353 result
354 _SearchBarImpl::SetContentAreaSize(const Dimension& size)
355 {
356         ClearLastResult();
357
358         Variant var(size);
359
360         return __pSearchBar->SetPropertyContentAreaSize(var);
361 }
362
363 Dimension
364 _SearchBarImpl::GetContentAreaSize(void) const
365 {
366         ClearLastResult();
367
368         return __pSearchBar->GetPropertyContentAreaSize().ToDimension();
369 }
370
371 SearchBarMode
372 _SearchBarImpl::GetMode(void) const
373 {
374         ClearLastResult();
375
376         return __pSearchBar->GetMode();
377 }
378
379 bool
380 _SearchBarImpl::IsModeLocked(void) const
381 {
382         ClearLastResult();
383
384         return __pSearchBar->IsModeLocked();
385 }
386
387 result
388 _SearchBarImpl::SetMode(SearchBarMode mode)
389 {
390         ClearLastResult();
391
392         return __pSearchBar->SetMode(mode);
393 }
394
395 result
396 _SearchBarImpl::SetModeLocked(bool modeLocked)
397 {
398         ClearLastResult();
399
400         return __pSearchBar->SetModeLocked(modeLocked);
401 }
402
403 int
404 _SearchBarImpl::GetButtonActionId(void) const
405 {
406         ClearLastResult();
407
408         return __pSearchBar->GetPropertyButtonActionId().ToInt();
409 }
410
411 Color
412 _SearchBarImpl::GetButtonColor(SearchBarButtonStatus status) const
413 {
414         ClearLastResult();
415
416         Variant buttonColor;
417
418         switch (status)
419         {
420         case SEARCH_BAR_BUTTON_STATUS_NORMAL:
421                 buttonColor = __pSearchBar->GetPropertyButtonNormalColor();
422                 break;
423         case SEARCH_BAR_BUTTON_STATUS_PRESSED:
424                 buttonColor = __pSearchBar->GetPropertyButtonPressedColor();
425                 break;
426         case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
427                 buttonColor = __pSearchBar->GetPropertyButtonHighlightedColor();
428                 break;
429         case SEARCH_BAR_BUTTON_STATUS_DISABLED:
430                 buttonColor = __pSearchBar->GetPropertyButtonDisabledColor();
431                 break;
432         default:
433                 break;
434         }
435
436         return buttonColor.ToColor();
437 }
438
439 Color
440 _SearchBarImpl::GetButtonTextColor(SearchBarButtonStatus status) const
441 {
442         ClearLastResult();
443
444         Variant buttonTextColor;
445
446         switch (status)
447         {
448         case SEARCH_BAR_BUTTON_STATUS_NORMAL:
449                 buttonTextColor = __pSearchBar->GetPropertyButtonNormalTextColor();
450                 break;
451         case SEARCH_BAR_BUTTON_STATUS_PRESSED:
452                 buttonTextColor = __pSearchBar->GetPropertyButtonPressedTextColor();
453                 break;
454         case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
455                 buttonTextColor = __pSearchBar->GetPropertyButtonHighlightedTextColor();
456                 break;
457         case SEARCH_BAR_BUTTON_STATUS_DISABLED:
458                 buttonTextColor = __pSearchBar->GetPropertyButtonDisabledTextColor();
459                 break;
460         default:
461                 break;
462         }
463
464         return buttonTextColor.ToColor();
465 }
466
467 SearchBarButtonStatus
468 _SearchBarImpl::GetButtonStatus(void) const
469 {
470         ClearLastResult();
471
472         return __pSearchBar->GetButtonStatus();
473 }
474
475 result
476 _SearchBarImpl::SetButton(const String& text, int actionId)
477 {
478         ClearLastResult();
479
480         result r = E_SUCCESS;
481         Variant var(actionId);
482
483         r = __pSearchBar->SetButtonText(text);
484         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
485
486         r = __pSearchBar->SetPropertyButtonActionId(var);
487
488         return r;
489 }
490
491 result
492 _SearchBarImpl::SetButtonEnabled(bool enabled)
493 {
494         ClearLastResult();
495
496         return __pSearchBar->SetButtonEnabled(enabled);
497 }
498
499 result
500 _SearchBarImpl::SetButtonColor(SearchBarButtonStatus status, const Color& color)
501 {
502         ClearLastResult();
503
504         result r = E_SUCCESS;
505         Variant var(color);
506
507         switch (status)
508         {
509         case SEARCH_BAR_BUTTON_STATUS_NORMAL:
510                 r = __pSearchBar->SetPropertyButtonNormalColor(var);
511                 break;
512         case SEARCH_BAR_BUTTON_STATUS_PRESSED:
513                 r = __pSearchBar->SetPropertyButtonPressedColor(var);
514                 break;
515         case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
516                 r = __pSearchBar->SetPropertyButtonHighlightedColor(var);
517                 break;
518         case SEARCH_BAR_BUTTON_STATUS_DISABLED:
519                 r = __pSearchBar->SetPropertyButtonDisabledColor(var);
520                 break;
521         default:
522                 break;
523         }
524
525         return r;
526 }
527
528 result
529 _SearchBarImpl::SetButtonTextColor(SearchBarButtonStatus status, const Color& color)
530 {
531         ClearLastResult();
532
533         result r = E_SUCCESS;
534         Variant var(color);
535
536         switch (status)
537         {
538         case SEARCH_BAR_BUTTON_STATUS_NORMAL:
539                 r = __pSearchBar->SetPropertyButtonNormalTextColor(var);
540                 break;
541         case SEARCH_BAR_BUTTON_STATUS_PRESSED:
542                 r = __pSearchBar->SetPropertyButtonPressedTextColor(var);
543                 break;
544         case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED:
545                 r = __pSearchBar->SetPropertyButtonHighlightedTextColor(var);
546                 break;
547         case SEARCH_BAR_BUTTON_STATUS_DISABLED:
548                 r = __pSearchBar->SetPropertyButtonDisabledTextColor(var);
549                 break;
550         default:
551                 break;
552         }
553
554         return r;
555 }
556
557 result
558 _SearchBarImpl::AppendCharacter(const Character& character)
559 {
560         ClearLastResult();
561
562         return __pSearchBar->AppendCharacter(character);
563 }
564
565 result
566 _SearchBarImpl::AppendText(const String& text)
567 {
568         ClearLastResult();
569
570         return __pSearchBar->AppendText(text);
571 }
572
573 result
574 _SearchBarImpl::SetText(const String& text)
575 {
576         ClearLastResult();
577
578         return __pSearchBar->SetText(text);
579 }
580
581 result
582 _SearchBarImpl::InsertCharacterAt(int index, const Character& character)
583 {
584         ClearLastResult();
585
586         return __pSearchBar->InsertCharacterAt(index, character);
587 }
588
589 result
590 _SearchBarImpl::InsertTextAt(int index, const String& text)
591 {
592         ClearLastResult();
593
594         return __pSearchBar->InsertTextAt(index, text);
595 }
596
597 result
598 _SearchBarImpl::DeleteCharacterAt(int index)
599 {
600         ClearLastResult();
601
602         return __pSearchBar->DeleteCharacterAt(index);
603 }
604
605 result
606 _SearchBarImpl::Clear(void)
607 {
608         ClearLastResult();
609
610         return __pSearchBar->Clear();
611 }
612
613 int
614 _SearchBarImpl::GetTextLength(void) const
615 {
616         ClearLastResult();
617
618         return __pSearchBar->GetTextLength();
619 }
620
621 String
622 _SearchBarImpl::GetText(void) const
623 {
624         ClearLastResult();
625
626         return __pSearchBar->GetText();
627 }
628
629 String
630 _SearchBarImpl::GetText(int start, int end) const
631 {
632         ClearLastResult();
633
634         return __pSearchBar->GetText(start, end);
635 }
636
637 int
638 _SearchBarImpl::GetLimitLength(void) const
639 {
640         ClearLastResult();
641
642         return __pSearchBar->GetLimitLength();
643 }
644
645 result
646 _SearchBarImpl::SetLimitLength(int limitLength)
647 {
648         ClearLastResult();
649
650         return __pSearchBar->SetLimitLength(limitLength);
651 }
652
653 result
654 _SearchBarImpl::ShowKeypad(void) const
655 {
656         ClearLastResult();
657
658         return __pSearchBar->ShowKeypad();
659 }
660
661 result
662 _SearchBarImpl::HideKeypad(void) const
663 {
664         ClearLastResult();
665
666         return __pSearchBar->HideKeypad();
667 }
668
669 int
670 _SearchBarImpl::GetSearchFieldTextSize(void) const
671 {
672         ClearLastResult();
673
674         return __pSearchBar->GetSearchFieldTextSize();
675 }
676
677 result
678 _SearchBarImpl::SetSearchFieldTextSize(int size)
679 {
680         ClearLastResult();
681
682         return __pSearchBar->SetSearchFieldTextSize(size);
683 }
684
685 result
686 _SearchBarImpl::GetBlockRange(int& start, int& end) const
687 {
688         ClearLastResult();
689
690         return __pSearchBar->GetBlockRange(start, end);
691 }
692
693 result
694 _SearchBarImpl::ReleaseBlock(void)
695 {
696         ClearLastResult();
697
698         return __pSearchBar->ReleaseBlock();
699 }
700
701 result
702 _SearchBarImpl::SetBlockRange(int start, int end)
703 {
704         ClearLastResult();
705
706         int tempTextLength = 0;
707
708         tempTextLength = __pSearchBar->GetTextLength();
709         SysTryReturnResult(NID_UI_CTRL, tempTextLength > start && tempTextLength > end, E_INVALID_ARG,
710                            "Invalid argument(s) is used. tempTextLength(%d),start(%d), end(%d)",
711                            tempTextLength, start, end);
712
713         SysTryReturnResult(NID_UI_CTRL, (start <= end && start >= 0), E_INVALID_ARG,
714                            "Invalid argument(s) is used. start(%d), end(%d)", start, end);
715
716         return __pSearchBar->SetBlockRange(start, end);
717 }
718
719 result
720 _SearchBarImpl::RemoveTextBlock(void)
721 {
722         ClearLastResult();
723         result r = __pSearchBar->RemoveTextBlock();
724         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
725                      "[E_SYSTEM] A system error has occured. Unable to remove the text block.")
726
727         return r;
728 }
729
730 Color
731 _SearchBarImpl::GetColor(void) const
732 {
733         ClearLastResult();
734
735         return __pSearchBar->GetPropertyColor().ToColor();
736 }
737
738 Color
739 _SearchBarImpl::GetSearchFieldColor(SearchFieldStatus status) const
740 {
741         ClearLastResult();
742
743         Variant searchFieldColor;
744
745         switch (status)
746         {
747         case SEARCH_FIELD_STATUS_NORMAL:
748                 searchFieldColor = __pSearchBar->GetPropertySearchFieldNormalColor();
749                 break;
750         case SEARCH_FIELD_STATUS_HIGHLIGHTED:
751                 searchFieldColor = __pSearchBar->GetPropertySearchFieldHighlightedColor();
752                 break;
753         case SEARCH_FIELD_STATUS_DISABLED:
754                 searchFieldColor = __pSearchBar->GetPropertySearchFieldDisabledColor();
755                 break;
756         default:
757                 break;
758         }
759
760         return searchFieldColor.ToColor();
761 }
762
763 Color
764 _SearchBarImpl::GetSearchFieldTextColor(SearchFieldStatus status) const
765 {
766         ClearLastResult();
767
768         Color color;
769         _Edit* pEdit = __pSearchBar->GetSearchField();
770         if (pEdit)
771         {
772                 switch (status)
773                 {
774                 case SEARCH_FIELD_STATUS_NORMAL:
775                         color = pEdit->GetTextColor(EDIT_TEXT_COLOR_NORMAL);
776                         break;
777                 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
778                         color = pEdit->GetTextColor(EDIT_TEXT_COLOR_HIGHLIGHTED);
779                         break;
780                 case SEARCH_FIELD_STATUS_DISABLED:
781                         color = pEdit->GetTextColor(EDIT_TEXT_COLOR_DISABLED);
782                         break;
783                 default:
784                         break;
785                 }
786         }
787         return color;
788 }
789
790 result
791 _SearchBarImpl::SetBackgroundBitmap(const Bitmap& bitmap)
792 {
793         ClearLastResult();
794
795         return __pSearchBar->SetBackgroundBitmap(bitmap);
796 }
797
798 result
799 _SearchBarImpl::SetColor(const Color& color)
800 {
801         ClearLastResult();
802
803         Variant var(color);
804
805         return __pSearchBar->SetPropertyColor(var);
806 }
807
808 result
809 _SearchBarImpl::SetSearchFieldColor(SearchFieldStatus status, const Color& color)
810 {
811         ClearLastResult();
812
813         result r = E_SUCCESS;
814         Variant var(color);
815
816         switch (status)
817         {
818         case SEARCH_FIELD_STATUS_NORMAL:
819                 r = __pSearchBar->SetPropertySearchFieldNormalColor(var);
820                 break;
821         case SEARCH_FIELD_STATUS_HIGHLIGHTED:
822                 r = __pSearchBar->SetPropertySearchFieldHighlightedColor(var);
823                 break;
824         case SEARCH_FIELD_STATUS_DISABLED:
825                 r = __pSearchBar->SetPropertySearchFieldDisabledColor(var);
826                 break;
827         default:
828                 break;
829         }
830
831         return r;
832 }
833
834 result
835 _SearchBarImpl::SetSearchFieldTextColor(SearchFieldStatus status, const Color& color)
836 {
837         ClearLastResult();
838
839         result r = E_SUCCESS;
840         _Edit* pEdit = __pSearchBar->GetSearchField();
841         if (pEdit)
842         {
843                 switch (status)
844                 {
845                 case SEARCH_FIELD_STATUS_NORMAL:
846                         r = pEdit->SetTextColor(EDIT_TEXT_COLOR_NORMAL, color);
847                         break;
848                 case SEARCH_FIELD_STATUS_HIGHLIGHTED:
849                         r = pEdit->SetTextColor(EDIT_TEXT_COLOR_HIGHLIGHTED, color);
850                         break;
851                 case SEARCH_FIELD_STATUS_DISABLED:
852                         r = pEdit->SetTextColor(EDIT_TEXT_COLOR_DISABLED, color);
853                         break;
854                 default:
855                         break;
856                 }
857         }
858
859         return r;
860 }
861
862 String
863 _SearchBarImpl::GetGuideText(void) const
864 {
865         ClearLastResult();
866
867         return __pSearchBar->GetGuideText();
868 }
869
870 result
871 _SearchBarImpl::SetGuideText(const String& guideText)
872 {
873         ClearLastResult();
874
875         return __pSearchBar->SetGuideText(guideText);
876 }
877
878 Color
879 _SearchBarImpl::GetGuideTextColor(void) const
880 {
881         ClearLastResult();
882
883         return __pSearchBar->GetGuideTextColor();
884 }
885
886 result
887 _SearchBarImpl::SetGuideTextColor(const Color& color)
888 {
889         ClearLastResult();
890
891         return __pSearchBar->SetGuideTextColor(color);
892 }
893
894 int
895 _SearchBarImpl::GetCursorPosition(void) const
896 {
897         ClearLastResult();
898
899         return __pSearchBar->GetCursorPosition();
900 }
901
902 result
903 _SearchBarImpl::SetCursorPosition(int index)
904 {
905         ClearLastResult();
906
907         return __pSearchBar->SetCursorPosition(index);
908 }
909
910 bool
911 _SearchBarImpl::IsLowerCaseModeEnabled(void) const
912 {
913         ClearLastResult();
914
915         return __pSearchBar->IsLowerCaseModeEnabled();
916 }
917
918 void
919 _SearchBarImpl::SetLowerCaseModeEnabled(bool enable)
920 {
921         ClearLastResult();
922
923         return __pSearchBar->SetLowerCaseModeEnabled(enable);
924 }
925
926 EllipsisPosition
927 _SearchBarImpl::GetEllipsisPosition(void) const
928 {
929         ClearLastResult();
930
931         return __pSearchBar->GetEllipsisPosition();
932 }
933
934 result
935 _SearchBarImpl::SetEllipsisPosition(EllipsisPosition position)
936 {
937         ClearLastResult();
938
939         return __pSearchBar->SetEllipsisPosition(position);
940 }
941
942 KeypadAction
943 _SearchBarImpl::GetKeypadAction(void) const
944 {
945         ClearLastResult();
946
947         CoreKeypadAction coreKeypadAction = __pSearchBar->GetKeypadAction();
948         KeypadAction publicKeypadAction = ConvertKeypadAction(coreKeypadAction);
949
950         return publicKeypadAction;
951 }
952
953 bool
954 _SearchBarImpl::IsTextPredictionEnabled(void) const
955 {
956         return __pSearchBar->IsTextPredictionEnabled();
957 }
958
959 result
960 _SearchBarImpl::SetTextPredictionEnabled(bool enable)
961 {
962         return __pSearchBar->SetTextPredictionEnabled(enable);
963 }
964
965 result
966 _SearchBarImpl::SetCurrentLanguage(LanguageCode languageCode)
967 {
968         return __pSearchBar->SetCurrentLanguage(languageCode);
969 }
970
971 result
972 _SearchBarImpl::GetCurrentLanguage(LanguageCode& language) const
973 {
974         return __pSearchBar->GetCurrentLanguage(language);
975 }
976
977 result
978 _SearchBarImpl::AddActionEventListener(IActionEventListener& listener)
979 {
980         ClearLastResult();
981
982         SysTryReturn(NID_UI_CTRL, __pPublicActionEvent, E_SYSTEM, E_SYSTEM,
983                      "[E_SYSTEM] A system error has occurred.");
984
985         result r = __pPublicActionEvent->AddListener(listener);
986         SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM,
987                            "A system error has occurred. The same listener instance already exists in the event listener list.");
988         return r;
989 }
990
991 result
992 _SearchBarImpl::RemoveActionEventListener(IActionEventListener& listener)
993 {
994         ClearLastResult();
995
996         SysTryReturn(NID_UI_CTRL, __pPublicActionEvent, E_SYSTEM, E_SYSTEM,
997                      "[E_SYSTEM] A system error has occurred.");
998
999         result r = __pPublicActionEvent->RemoveListener(listener);
1000         SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM,
1001                            "A system error has occurred. The specified listener does not exist in the event listener list.");
1002         return r;
1003 }
1004
1005 result
1006 _SearchBarImpl::AddKeypadEventListener(IKeypadEventListener& listener)
1007 {
1008         ClearLastResult();
1009
1010         SysTryReturn(NID_UI_CTRL, __pPublicKeypadEvent, E_SYSTEM, E_SYSTEM,
1011                      "[E_SYSTEM] A system error has occurred.");
1012
1013         result r = __pPublicKeypadEvent->AddListener(listener);
1014         SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM,
1015                            "A system error has occurred. The same listener instance already exists in the event listener list.");
1016
1017         return r;
1018 }
1019
1020
1021 result
1022 _SearchBarImpl::RemoveKeypadEventListener(IKeypadEventListener& listener)
1023 {
1024         ClearLastResult();
1025
1026         SysTryReturn(NID_UI_CTRL, __pPublicKeypadEvent, E_SYSTEM, E_SYSTEM,
1027                      "[E_SYSTEM] A system error has occurred.");
1028
1029         result r = __pPublicKeypadEvent->RemoveListener(listener);
1030         SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM,
1031                            "A system error has occurred. The specified listener does not exist in the event listener list.");
1032
1033         return r;
1034 }
1035
1036 result
1037 _SearchBarImpl::AddTextBlockEventListener(ITextBlockEventListener& listener)
1038 {
1039         ClearLastResult();
1040
1041         SysTryReturn(NID_UI_CTRL, __pPublicTextBlockEvent, E_SYSTEM, E_SYSTEM,
1042                      "[E_SYSTEM] A system error has occurred.");
1043
1044         result r = __pPublicTextBlockEvent->AddListener(listener);
1045         SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM,
1046                            "A system error has occurred. The same listener instance already exists in the event listener list.");
1047
1048         return r;
1049 }
1050
1051 result
1052 _SearchBarImpl::RemoveTextBlockEventListener(ITextBlockEventListener& listener)
1053 {
1054         ClearLastResult();
1055
1056         SysTryReturn(NID_UI_CTRL, __pPublicTextBlockEvent, E_SYSTEM, E_SYSTEM,
1057                      "[E_SYSTEM] A system error has occurred.");
1058
1059         result r = __pPublicTextBlockEvent->RemoveListener(listener);
1060         SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM,
1061                            "A system error has occurred. The specified listener does not exist in the event listener list.");
1062
1063         return r;
1064 }
1065
1066
1067 result
1068 _SearchBarImpl::AddTextEventListener(ITextEventListener& listener)
1069 {
1070         ClearLastResult();
1071
1072         SysTryReturn(NID_UI_CTRL, __pPublicTextEvent, E_SYSTEM, E_SYSTEM,
1073                      "[E_SYSTEM] A system error has occurred.");
1074
1075         result r = __pPublicTextEvent->AddListener(listener);
1076         SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM,
1077                            "A system error has occurred. The same listener instance already exists in the event listener list.");
1078
1079         return r;
1080 }
1081
1082 result
1083 _SearchBarImpl::RemoveTextEventListener(ITextEventListener& listener)
1084 {
1085         ClearLastResult();
1086
1087         SysTryReturn(NID_UI_CTRL, __pPublicTextEvent, E_SYSTEM, E_SYSTEM,
1088                      "[E_SYSTEM] A system error has occurred.");
1089
1090         result r = __pPublicTextEvent->RemoveListener(listener);
1091         SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM,
1092                            "A system error has occurred. The specified listener does not exist in the event listener list.");
1093
1094         return r;
1095 }
1096
1097 result
1098 _SearchBarImpl::AddSearchBarEventListener(const ISearchBarEventListener& listener)
1099 {
1100         ClearLastResult();
1101
1102         SysTryReturn(NID_UI_CTRL, __pPublicSearchBarEvent, E_SYSTEM, E_SYSTEM,
1103                      "[E_SYSTEM] A system error has occurred.");
1104
1105         result r = __pPublicSearchBarEvent->AddListener(listener);
1106         SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM,
1107                            "A system error has occurred. The same listener instance already exists in the event listener list.");
1108
1109         return r;
1110 }
1111
1112 result
1113 _SearchBarImpl::RemoveSearchBarEventListener(const ISearchBarEventListener& listener)
1114 {
1115         ClearLastResult();
1116
1117         SysTryReturn(NID_UI_CTRL, __pPublicSearchBarEvent, E_SYSTEM, E_SYSTEM,
1118                      "[E_SYSTEM] A system error has occurred.");
1119
1120         result r = __pPublicSearchBarEvent->RemoveListener(listener);
1121         SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM,
1122                            "A system error has occurred. The specified listener does not exist in the event listener list.");
1123
1124         return r;
1125 }
1126
1127 result
1128 _SearchBarImpl::AddLanguageEventListener(ILanguageEventListener& listener)
1129 {
1130         ClearLastResult();
1131
1132         SysAssertf(__pPublicLanguageEvent != null, "Not yet constructed. Construct() should be called before use.");
1133
1134         return __pPublicLanguageEvent->AddListener(listener);
1135 }
1136
1137 result
1138 _SearchBarImpl::RemoveLanguageEventListener(ILanguageEventListener& listener)
1139 {
1140         ClearLastResult();
1141
1142         SysAssertf(__pPublicLanguageEvent != null, "Not yet constructed. Construct() should be called before use.");
1143
1144         return __pPublicLanguageEvent->RemoveListener(listener);
1145 }
1146
1147 void
1148 _SearchBarImpl::OnActionPerformed(const _Control& source, int actionId)
1149 {
1150         ClearLastResult();
1151
1152         if (__pPublicActionEvent != null)
1153         {
1154                 IEventArg* pEventArg = _PublicActionEvent::CreateActionEventArgN(actionId);
1155                 result r = GetLastResult();
1156                 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1157
1158                 __pPublicActionEvent->Fire(*pEventArg);
1159         }
1160         return;
1161 }
1162
1163 void
1164 _SearchBarImpl::OnKeypadWillOpen(void)
1165 {
1166         ClearLastResult();
1167
1168         if (__pPublicKeypadEvent != null)
1169         {
1170                 IEventArg* pEventArg = _PublicKeypadEvent::CreateKeypadEventArgN(
1171                         GetPublic(), KEYPAD_ACTION_SEARCH, KEYPAD_EVENT_STATUS_CREATED);
1172                 result r = GetLastResult();
1173                 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1174
1175                 __pPublicKeypadEvent->Fire(*pEventArg);
1176         }
1177         return;
1178 }
1179
1180 void
1181 _SearchBarImpl::OnKeypadOpened(void)
1182 {
1183         ClearLastResult();
1184
1185         if (__pPublicKeypadEvent != null)
1186         {
1187                 IEventArg* pEventArg = _PublicKeypadEvent::CreateKeypadEventArgN(
1188                         GetPublic(), KEYPAD_ACTION_SEARCH, KEYPAD_EVENT_STATUS_OPEN);
1189                 result r = GetLastResult();
1190                 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1191
1192                 __pPublicKeypadEvent->Fire(*pEventArg);
1193         }
1194         return;
1195 }
1196
1197
1198 void
1199 _SearchBarImpl::OnKeypadClosed(void)
1200 {
1201         ClearLastResult();
1202
1203         if (__pPublicKeypadEvent != null)
1204         {
1205                 IEventArg* pEventArg = _PublicKeypadEvent::CreateKeypadEventArgN(
1206                         GetPublic(), KEYPAD_ACTION_SEARCH, KEYPAD_EVENT_STATUS_CLOSE);
1207                 result r = GetLastResult();
1208                 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1209
1210                 __pPublicKeypadEvent->Fire(*pEventArg);
1211         }
1212         return;
1213 }
1214
1215 void
1216 _SearchBarImpl::OnKeypadBoundsChanged(void)
1217 {
1218         ClearLastResult();
1219
1220         if (__pPublicKeypadEvent != null)
1221         {
1222                 IEventArg* pEventArg = _PublicKeypadEvent::CreateKeypadEventArgN(
1223                         GetPublic(), KEYPAD_ACTION_SEARCH, KEYPAD_EVENT_STATUS_BOUNDS_CHANGED);
1224                 result r = GetLastResult();
1225                 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1226
1227                 __pPublicKeypadEvent->Fire(*pEventArg);
1228         }
1229         return;
1230 }
1231
1232 void
1233 _SearchBarImpl::OnKeypadActionPerformed(CoreKeypadAction keypadAction)
1234 {
1235         ClearLastResult();
1236
1237         if (__pPublicKeypadEvent != null)
1238         {
1239                 KeypadAction publicKeypadAction = ConvertKeypadAction(keypadAction);
1240
1241                 IEventArg* pEventArg = _PublicKeypadEvent::CreateKeypadEventArgN(
1242                         GetPublic(), publicKeypadAction, KEYPAD_EVENT_STATUS_ENTERACTION);
1243                 result r = GetLastResult();
1244                 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1245
1246                 __pPublicKeypadEvent->Fire(*pEventArg);
1247         }
1248         return;
1249 }
1250
1251 void
1252 _SearchBarImpl::OnTextBlockSelected(_Control& source, int start, int end)
1253 {
1254         ClearLastResult();
1255
1256         if (__pPublicTextBlockEvent != null)
1257         {
1258                 IEventArg* pEventArg = _PublicTextBlockEvent::CreateTextBlockEventArgN(start, end);
1259                 result r = GetLastResult();
1260                 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1261
1262                 __pPublicTextBlockEvent->Fire(*pEventArg);
1263         }
1264         return;
1265 }
1266
1267 void
1268 _SearchBarImpl::OnTextValueChanged(const _Control& source)
1269 {
1270         ClearLastResult();
1271
1272         if (__pPublicTextEvent != null)
1273         {
1274                 IEventArg* pEventArg = _PublicTextEvent::CreateTextEventArgN(TEXT_EVENT_CHANGED);
1275                 result r = GetLastResult();
1276                 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1277
1278                 __pPublicTextEvent->Fire(*pEventArg);
1279         }
1280         return;
1281 }
1282
1283 void
1284 _SearchBarImpl::OnTextValueChangeCanceled(const _Control& source)
1285 {
1286         ClearLastResult();
1287
1288         if (__pPublicTextEvent != null)
1289         {
1290                 IEventArg* pEventArg = _PublicTextEvent::CreateTextEventArgN(TEXT_EVENT_CANCELED);
1291                 result r = GetLastResult();
1292                 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1293
1294                 __pPublicTextEvent->Fire(*pEventArg);
1295         }
1296         return;
1297 }
1298
1299 void
1300 _SearchBarImpl::OnSearchBarModeChanged(_SearchBar& source, SearchBarMode mode)
1301 {
1302         ClearLastResult();
1303
1304         if ((_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()) && __pSearchBar != null)
1305         {
1306                 if (mode == SEARCH_BAR_MODE_NORMAL)
1307                 {
1308                         __pSearchBar->SetHeaderVisibleState(true);
1309                 }
1310                 else
1311                 {
1312                         __pSearchBar->SetHeaderVisibleState(false);
1313                 }
1314                 __pSearchBar->SetContentsArea();
1315         }
1316
1317         if (__pPublicSearchBarEvent != null)
1318         {
1319                 IEventArg* pEventArg = _PublicSearchBarEvent::CreateSearchBarEventArgN(SEARCH_BAR_EVENT_MODE_CHANGE);
1320                 result r = GetLastResult();
1321                 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1322
1323                 __pPublicSearchBarEvent->Fire(*pEventArg);
1324         }
1325         return;
1326 }
1327
1328 void
1329 _SearchBarImpl::OnLanguageChanged(LanguageCode oldLanguage, LanguageCode newLanguage)
1330 {
1331         if (__pPublicLanguageEvent)
1332         {
1333                 IEventArg* pKLanguageEventArg = _PublicLanguageEvent::CreateLanguageEventArgN(GetPublic(), oldLanguage, newLanguage);
1334                 result r = GetLastResult();
1335                 SysTryReturnVoidResult(NID_UI_CTRL, pKLanguageEventArg, r, "[%s] Propagating.", GetErrorMessage(r));
1336
1337                 __pPublicLanguageEvent->Fire(*pKLanguageEventArg);
1338         }
1339         else
1340         {
1341                 SysLog(NID_UI_CTRL, "Event is not created.");
1342         }
1343         return;
1344 }
1345
1346 KeypadAction
1347 _SearchBarImpl::ConvertKeypadAction(CoreKeypadAction keypadAction) const
1348 {
1349         KeypadAction publicKeypadAction = KEYPAD_ACTION_SEARCH;
1350         switch (keypadAction)
1351         {
1352         case CORE_KEYPAD_ACTION_ENTER:
1353                 publicKeypadAction = KEYPAD_ACTION_ENTER;
1354                 break;
1355
1356         case CORE_KEYPAD_ACTION_GO:
1357                 publicKeypadAction = KEYPAD_ACTION_GO;
1358                 break;
1359
1360         case CORE_KEYPAD_ACTION_NEXT:
1361                 publicKeypadAction = KEYPAD_ACTION_NEXT;
1362                 break;
1363
1364         case CORE_KEYPAD_ACTION_SEND:
1365                 publicKeypadAction = KEYPAD_ACTION_SEND;
1366                 break;
1367
1368         case CORE_KEYPAD_ACTION_SEARCH:
1369                 publicKeypadAction = KEYPAD_ACTION_SEARCH;
1370                 break;
1371
1372         case CORE_KEYPAD_ACTION_LOGIN:
1373                 publicKeypadAction = KEYPAD_ACTION_LOGIN;
1374                 break;
1375
1376         case CORE_KEYPAD_ACTION_SIGN_IN:
1377                 publicKeypadAction = KEYPAD_ACTION_SIGN_IN;
1378                 break;
1379
1380         case CORE_KEYPAD_ACTION_JOIN:
1381                 publicKeypadAction = KEYPAD_ACTION_JOIN;
1382                 break;
1383
1384         case CORE_KEYPAD_ACTION_DONE:
1385                 publicKeypadAction = KEYPAD_ACTION_DONE;
1386                 break;
1387
1388         default:
1389                 break;
1390         }
1391
1392         return publicKeypadAction;
1393 }
1394
1395 class _SearchBarMaker
1396         : public _UiBuilderControlMaker
1397 {
1398 public:
1399         _SearchBarMaker(_UiBuilder* pUibuilder)
1400                 : _UiBuilderControlMaker(pUibuilder){}
1401         virtual ~_SearchBarMaker(void){}
1402         static _UiBuilderControlMaker*
1403         GetInstance(_UiBuilder* pUibuilder)
1404         {
1405                 _SearchBarMaker* pSearchBarMaker = new (std::nothrow) _SearchBarMaker(pUibuilder);
1406                 return pSearchBarMaker;
1407         };
1408
1409 protected:
1410         virtual Control*
1411         Make(_UiBuilderControl* pControl)
1412         {
1413                 result r = E_SUCCESS;
1414
1415                 Rectangle rect;
1416                 SearchBar* pSearchBar = null;
1417                 _UiBuilderControlLayout* pControlProperty = null;
1418                 bool showSearchBarButton = true;
1419                 KeypadAction keypadAction = KEYPAD_ACTION_ENTER;
1420                 Color color;
1421                 int opacity = SEARCHBAR_DEFAULT_OPACITY;
1422                 EllipsisPosition ellipsisPosition = ELLIPSIS_POSITION_END;
1423                 String text;
1424                 String guideText;
1425                 int limitLength = SEARCHBAR_TEXT_LENGTH_MAX;
1426                 int buttonActionId = -1;
1427                 String buttonText;
1428                 int searchFieldTextSize = 0;
1429                 bool lowercaseEnable = false;
1430                 String elementString;
1431
1432                 GetProperty(pControl, &pControlProperty);
1433                 if (pControlProperty == null)
1434                 {
1435                         return null;
1436                 }
1437
1438                 pSearchBar = new (std::nothrow) SearchBar;
1439                 if (pSearchBar == null)
1440                 {
1441                         return null;
1442                 }
1443
1444                 rect = pControlProperty->GetRect();
1445                 if (pControl->GetElement("showSearchBarButton", elementString))
1446                 {
1447                         if (elementString.Equals(L"false", false))
1448                         {
1449                                 showSearchBarButton = false;
1450                         }
1451                 }
1452
1453                 if (pControl->GetElement("keypadAction", elementString))
1454                 {
1455                         if (elementString.Equals(L"KEYPAD_ACTION_ENTER", false))
1456                         {
1457                                 keypadAction = KEYPAD_ACTION_ENTER;
1458                         }
1459                         else if (elementString.Equals(L"KEYPAD_ACTION_GO", false))
1460                         {
1461                                 keypadAction = KEYPAD_ACTION_GO;
1462                         }
1463                         else if (elementString.Equals(L"KEYPAD_ACTION_NEXT", false))
1464                         {
1465                                 keypadAction = KEYPAD_ACTION_NEXT;
1466                         }
1467                         else if (elementString.Equals(L"KEYPAD_ACTION_SEND", false))
1468                         {
1469                                 keypadAction = KEYPAD_ACTION_SEND;
1470                         }
1471                         else if (elementString.Equals(L"KEYPAD_ACTION_SEARCH", false))
1472                         {
1473                                 keypadAction = KEYPAD_ACTION_SEARCH;
1474                         }
1475                         else if (elementString.Equals(L"KEYPAD_ACTION_LOGIN", false))
1476                         {
1477                                 keypadAction = KEYPAD_ACTION_LOGIN;
1478                         }
1479                         else if (elementString.Equals(L"KEYPAD_ACTION_SIGN_IN", false))
1480                         {
1481                                 keypadAction = KEYPAD_ACTION_SIGN_IN;
1482                         }
1483                         else if (elementString.Equals(L"KEYPAD_ACTION_JOIN", false))
1484                         {
1485                                 keypadAction = KEYPAD_ACTION_JOIN;
1486                         }
1487                         else if (elementString.Equals(L"KEYPAD_ACTION_DONE", false))
1488                         {
1489                                 keypadAction = KEYPAD_ACTION_DONE;
1490                         }
1491                 }
1492
1493                 r = pSearchBar->Construct(rect, showSearchBarButton, keypadAction);
1494                 if (r != E_SUCCESS)
1495                 {
1496                         delete pSearchBar;
1497                         return null;
1498                 }
1499
1500                 if (showSearchBarButton)
1501                 {
1502                         if (pControl->GetElement("buttonActionId", elementString))
1503                         {
1504                                 Base::Integer::Parse(elementString, buttonActionId);
1505                         }
1506
1507                         if (pControl->GetElement("buttonText", elementString))
1508                         {
1509                                 r = pSearchBar->SetButton(elementString, buttonActionId);
1510                         }
1511                 }
1512
1513                 if (pControl->GetElement("text", elementString))
1514                 {
1515                         r = pSearchBar->SetText(elementString);
1516                 }
1517
1518                 if (pControl->GetElement("guideText", elementString))
1519                 {
1520                         r = pSearchBar->SetGuideText(elementString);
1521                 }
1522
1523                 if (pControl->GetElement("searchFieldTextSize", elementString))
1524                 {
1525                         Base::Integer::Parse(elementString, searchFieldTextSize);
1526                         _ICoordinateSystemTransformer* pTransform = GetTransformer();
1527                         if (pTransform)
1528                         {
1529                                 searchFieldTextSize = pTransform->Transform(searchFieldTextSize);
1530                         }
1531                         r = pSearchBar->SetSearchFieldTextSize(searchFieldTextSize);
1532                 }
1533
1534                 if (pControl->GetElement("limitLength", elementString))
1535                 {
1536                         Base::Integer::Parse(elementString, limitLength);
1537                         r = pSearchBar->SetLimitLength(limitLength);
1538                 }
1539
1540                 if (pControl->GetElement("lowerCaseMode", elementString))
1541                 {
1542                         if (elementString.Equals(L"true", false))
1543                         {
1544                                 lowercaseEnable = true;
1545                         }
1546                         else
1547                         {
1548                                 lowercaseEnable = false;
1549                         }
1550
1551                         pSearchBar->SetLowerCaseModeEnabled(lowercaseEnable);
1552                 }
1553
1554                 if (pControl->GetElement("ellipsisPosition", elementString))
1555                 {
1556                         if (elementString.Equals(L"ELLIPSIS_POSITION_START", false))
1557                         {
1558                                 ellipsisPosition = ELLIPSIS_POSITION_START;
1559                         }
1560                         else if (elementString.Equals(L"ELLIPSIS_POSITION_MIDDLE", false))
1561                         {
1562                                 ellipsisPosition = ELLIPSIS_POSITION_MIDDLE;
1563                         }
1564                         else
1565                         {
1566                                 ellipsisPosition = ELLIPSIS_POSITION_END;
1567                         }
1568
1569                         r = pSearchBar->SetEllipsisPosition(ellipsisPosition);
1570                 }
1571
1572                 if (pControl->GetElement("backgroundBitmapPath", elementString))
1573                 {
1574                         Bitmap* pBackgroundBitmap = null;
1575                         pBackgroundBitmap = LoadBitmapN(elementString);
1576                         if (pBackgroundBitmap != null)
1577                         {
1578                                 pSearchBar->SetBackgroundBitmap(*pBackgroundBitmap);
1579                                 delete pBackgroundBitmap;
1580                         }
1581                 }
1582
1583                 if (pControl->GetElement("colorOpacity", elementString))
1584                 {
1585                         Base::Integer::Parse(elementString, opacity);
1586                 }
1587                 if (pControl->GetElement("color", elementString))
1588                 {
1589                         ConvertStringToColor32(elementString, opacity, color);
1590                         r = pSearchBar->SetColor(color);
1591                 }
1592
1593                 opacity = SEARCHBAR_DEFAULT_OPACITY;
1594                 if (pControl->GetElement("normalButtonColor", elementString))
1595                 {
1596                         ConvertStringToColor32(elementString, opacity, color);
1597                         r = pSearchBar->SetButtonColor(SEARCH_BAR_BUTTON_STATUS_NORMAL, color);
1598                 }
1599
1600                 if (pControl->GetElement("normalButtonTextColor", elementString))
1601                 {
1602                         ConvertStringToColor32(elementString, opacity, color);
1603                         r = pSearchBar->SetButtonTextColor(SEARCH_BAR_BUTTON_STATUS_NORMAL, color);
1604                 }
1605
1606                 if (pControl->GetElement("normalSearchFieldColor", elementString))
1607                 {
1608                         ConvertStringToColor32(elementString, opacity, color);
1609                         r = pSearchBar->SetSearchFieldColor(SEARCH_FIELD_STATUS_NORMAL, color);
1610                 }
1611
1612                 if (pControl->GetElement("normalSearchFieldTextColor", elementString))
1613                 {
1614                         ConvertStringToColor32(elementString, opacity, color);
1615                         r = pSearchBar->SetSearchFieldTextColor(SEARCH_FIELD_STATUS_NORMAL, color);
1616                 }
1617
1618                 if (pControl->GetElement("disabledButtonColor", elementString))
1619                 {
1620                         ConvertStringToColor32(elementString, opacity, color);
1621                         r = pSearchBar->SetButtonColor(SEARCH_BAR_BUTTON_STATUS_DISABLED, color);
1622                 }
1623
1624                 if (pControl->GetElement("disabledButtonTextColor", elementString))
1625                 {
1626                         ConvertStringToColor32(elementString, opacity, color);
1627                         r = pSearchBar->SetButtonTextColor(SEARCH_BAR_BUTTON_STATUS_DISABLED, color);
1628                 }
1629
1630                 if (pControl->GetElement("disabledSearchFieldColor", elementString))
1631                 {
1632                         ConvertStringToColor32(elementString, opacity, color);
1633                         r = pSearchBar->SetSearchFieldColor(SEARCH_FIELD_STATUS_DISABLED, color);
1634                 }
1635
1636                 if (pControl->GetElement("disabledSearchFieldTextColor", elementString))
1637                 {
1638                         ConvertStringToColor32(elementString, opacity, color);
1639                         r = pSearchBar->SetSearchFieldColor(SEARCH_FIELD_STATUS_DISABLED, color);
1640                 }
1641
1642                 if (pControl->GetElement("highlightedButtonColor", elementString))
1643                 {
1644                         ConvertStringToColor32(elementString, opacity, color);
1645                         r = pSearchBar->SetButtonColor(SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED, color);
1646                 }
1647
1648                 if (pControl->GetElement("highlightedButtonTextColor", elementString))
1649                 {
1650                         ConvertStringToColor32(elementString, opacity, color);
1651                         r = pSearchBar->SetButtonTextColor(SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED, color);
1652                 }
1653
1654                 if (pControl->GetElement("highlightedSearchFieldColor", elementString))
1655                 {
1656                         ConvertStringToColor32(elementString, opacity, color);
1657                         r = pSearchBar->SetSearchFieldColor(SEARCH_FIELD_STATUS_HIGHLIGHTED, color);
1658                 }
1659
1660                 if (pControl->GetElement("highlightedSearchFieldTextColor", elementString))
1661                 {
1662                         ConvertStringToColor32(elementString, opacity, color);
1663                         r = pSearchBar->SetSearchFieldColor(SEARCH_FIELD_STATUS_HIGHLIGHTED, color);
1664                 }
1665
1666                 if (pControl->GetElement("pressedButtonColor", elementString))
1667                 {
1668                         ConvertStringToColor32(elementString, opacity, color);
1669                         r = pSearchBar->SetButtonColor(SEARCH_BAR_BUTTON_STATUS_PRESSED, color);
1670                 }
1671
1672                 if (pControl->GetElement("pressedButtonTextColor", elementString))
1673                 {
1674                         ConvertStringToColor32(elementString, opacity, color);
1675                         r = pSearchBar->SetButtonTextColor(SEARCH_BAR_BUTTON_STATUS_PRESSED, color);
1676                 }
1677
1678                 if (pControl->GetElement("guideTextColor", elementString))
1679                 {
1680                         ConvertStringToColor32(elementString, opacity, color);
1681                         r = pSearchBar->SetGuideTextColor(color);
1682                 }
1683
1684                 return pSearchBar;
1685         }
1686 };
1687
1688 _SearchBarRegister::_SearchBarRegister(void)
1689 {
1690         _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
1691         pUiBuilderControlTableManager->RegisterControl(L"SearchBar", _SearchBarMaker::GetInstance);
1692 }
1693
1694 _SearchBarRegister::~_SearchBarRegister(void)
1695 {
1696         _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
1697         pUiBuilderControlTableManager->UnregisterControl(L"SearchBar");
1698 }
1699 static _SearchBarRegister SearchBarRegisterToUiBuilder;
1700 }}} // Tizen::Ui::Controls