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