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