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