2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
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.
19 * @file FUiCtrl_SearchBar.h
20 * @brief This is the header file for the _SearchBar class.
22 * This header file contains the declarations of the %_SearchBar class.
25 #ifndef _FUI_CTRL_INTERNAL_SEARCH_BAR_H_
26 #define _FUI_CTRL_INTERNAL_SEARCH_BAR_H_
28 #include <FUiCtrlSearchBar.h>
29 #include "FUi_Control.h"
30 #include "FUiCtrl_Button.h"
31 #include "FUiCtrl_Edit.h"
32 #include "FUiCtrl_IActionEventListener.h"
33 #include "FUiCtrl_IKeypadEventListener.h"
34 #include "FUiCtrl_ILanguageEventListener.h"
35 #include "FUiCtrl_ITextBlockEventListener.h"
36 #include "FUiCtrl_ITextEventListener.h"
37 #include "FUiCtrl_ISearchBarEventListener.h"
38 #include "FUiCtrl_KeypadEvent.h"
39 #include "FUiCtrl_LanguageEvent.h"
40 #include "FUiCtrl_SearchBarEvent.h"
42 const int SEARCHBAR_COLOR_MAX = 3;
43 const int SEARCHBAR_BUTTON_COLOR_MAX = 4;
44 const int SEARCHBAR_TEXT_LENGTH_MAX = 500;
45 const int SEARCHBAR_DEFAULT_OPACITY = 100;
47 namespace Tizen { namespace Ui { namespace Animations
50 }}} // Tizen::Ui::Animations
52 namespace Tizen { namespace Ui { namespace Controls
56 class _SearchBarPresenter;
58 class _TextBlockEvent;
68 , public _IActionEventListener
69 , public _IKeypadEventListener
70 , public _ITextBlockEventListener
71 , public _ITextEventListener
72 , virtual public Tizen::Base::Runtime::IEventListener
73 , virtual public Tizen::Ui::_IUiEventListener
74 , virtual public Tizen::Ui::_IUiEventPreviewer
76 DECLARE_CLASS_BEGIN(_SearchBar, _Control);
77 DECLARE_PROPERTY("buttonActionId", GetPropertyButtonActionId, SetPropertyButtonActionId);
78 DECLARE_PROPERTY("buttonDisabledColor", GetPropertyButtonDisabledColor, SetPropertyButtonDisabledColor);
79 DECLARE_PROPERTY("buttonHighlightedColor", GetPropertyButtonHighlightedColor, SetPropertyButtonHighlightedColor);
80 DECLARE_PROPERTY("buttonNormalColor", GetPropertyButtonNormalColor, SetPropertyButtonNormalColor);
81 DECLARE_PROPERTY("buttonPressedColor", GetPropertyButtonPressedColor, SetPropertyButtonPressedColor);
82 DECLARE_PROPERTY("buttonDisabledTextColor", GetPropertyButtonDisabledTextColor, SetPropertyButtonDisabledTextColor);
83 DECLARE_PROPERTY("buttonHighlightedTextColor", GetPropertyButtonHighlightedTextColor, SetPropertyButtonHighlightedTextColor);
84 DECLARE_PROPERTY("buttonNormalTextColor", GetPropertyButtonNormalTextColor, SetPropertyButtonNormalTextColor);
85 DECLARE_PROPERTY("buttonPressedTextColor", GetPropertyButtonPressedTextColor, SetPropertyButtonPressedTextColor);
86 DECLARE_PROPERTY("searchFieldDisabledColor", GetPropertySearchFieldDisabledColor, SetPropertySearchFieldDisabledColor);
87 DECLARE_PROPERTY("searchFieldHighlightedColor", GetPropertySearchFieldHighlightedColor, SetPropertySearchFieldHighlightedColor);
88 DECLARE_PROPERTY("searchFieldNormalColor", GetPropertySearchFieldNormalColor, SetPropertySearchFieldNormalColor);
89 DECLARE_PROPERTY("searchFieldDisabledTextColor", GetPropertySearchFieldDisabledTextColor, SetPropertySearchFieldDisabledTextColor);
90 DECLARE_PROPERTY("searchFieldHighlightedTextColor", GetPropertySearchFieldHighlightedTextColor, SetPropertySearchFieldHighlightedTextColor);
91 DECLARE_PROPERTY("searchFieldNormalTextColor", GetPropertySearchFieldNormalTextColor, SetPropertySearchFieldNormalTextColor);
92 DECLARE_PROPERTY("color", GetPropertyColor, SetPropertyColor);
93 DECLARE_PROPERTY("contentAreaSize", GetPropertyContentAreaSize, SetPropertyContentAreaSize);
96 result SetPropertyButtonActionId(const Tizen::Ui::Variant& actionId);
97 Tizen::Ui::Variant GetPropertyButtonActionId(void) const;
98 result SetPropertyButtonDisabledColor(const Tizen::Ui::Variant& color);
99 Tizen::Ui::Variant GetPropertyButtonDisabledColor(void) const;
100 result SetPropertyButtonHighlightedColor(const Tizen::Ui::Variant& color);
101 Tizen::Ui::Variant GetPropertyButtonHighlightedColor(void) const;
102 result SetPropertyButtonNormalColor(const Tizen::Ui::Variant& color);
103 Tizen::Ui::Variant GetPropertyButtonNormalColor(void) const;
104 result SetPropertyButtonPressedColor(const Tizen::Ui::Variant& color);
105 Tizen::Ui::Variant GetPropertyButtonPressedColor(void) const;
106 result SetPropertyButtonDisabledTextColor(const Tizen::Ui::Variant& textColor);
107 Tizen::Ui::Variant GetPropertyButtonDisabledTextColor(void) const;
108 result SetPropertyButtonHighlightedTextColor(const Tizen::Ui::Variant& textColor);
109 Tizen::Ui::Variant GetPropertyButtonHighlightedTextColor(void) const;
110 result SetPropertyButtonNormalTextColor(const Tizen::Ui::Variant& textColor);
111 Tizen::Ui::Variant GetPropertyButtonNormalTextColor(void) const;
112 result SetPropertyButtonPressedTextColor(const Tizen::Ui::Variant& textColor);
113 Tizen::Ui::Variant GetPropertyButtonPressedTextColor(void) const;
114 result SetPropertySearchFieldDisabledColor(const Tizen::Ui::Variant& color);
115 Tizen::Ui::Variant GetPropertySearchFieldDisabledColor(void) const;
116 result SetPropertySearchFieldHighlightedColor(const Tizen::Ui::Variant& color);
117 Tizen::Ui::Variant GetPropertySearchFieldHighlightedColor(void) const;
118 result SetPropertySearchFieldNormalColor(const Tizen::Ui::Variant& color);
119 Tizen::Ui::Variant GetPropertySearchFieldNormalColor(void) const;
120 result SetPropertySearchFieldDisabledTextColor(const Tizen::Ui::Variant& textColor);
121 Tizen::Ui::Variant GetPropertySearchFieldDisabledTextColor(void) const;
122 result SetPropertySearchFieldHighlightedTextColor(const Tizen::Ui::Variant& textColor);
123 Tizen::Ui::Variant GetPropertySearchFieldHighlightedTextColor(void) const;
124 result SetPropertySearchFieldNormalTextColor(const Tizen::Ui::Variant& textColor);
125 Tizen::Ui::Variant GetPropertySearchFieldNormalTextColor(void) const;
126 result SetPropertyColor(const Tizen::Ui::Variant& color);
127 Tizen::Ui::Variant GetPropertyColor(void) const;
128 result SetPropertyContentAreaSize(const Tizen::Ui::Variant& size);
129 Tizen::Ui::Variant GetPropertyContentAreaSize(void) const;
133 virtual ~_SearchBar(void);
135 static _SearchBar* CreateSearchBarN(void);
136 result Initialize(bool enableSearchBarButton = true, CoreKeypadAction keypadAction = CORE_KEYPAD_ACTION_SEARCH);
137 Tizen::Ui::_Control* GetContent(void) const;
138 result SetContent(const Tizen::Ui::_Control* pContent);
139 result UpdateContentArea(bool invalidate = true);
140 result SetContentAreaVisible(bool visible);
141 bool IsContentAreaVisible(void) const;
142 result SetContentAreaSize(const Tizen::Graphics::Dimension& size);
143 Tizen::Graphics::Dimension GetContentAreaSize(void) const;
144 SearchBarMode GetMode(void) const;
145 bool IsModeLocked(void) const;
146 result SetMode(SearchBarMode mode);
147 result SetModeLocked(bool modeLocked);
148 int GetButtonActionId(void) const;
149 Tizen::Graphics::Color GetButtonColor(SearchBarButtonStatus status) const;
150 Tizen::Graphics::Color GetButtonTextColor(SearchBarButtonStatus status) const;
151 SearchBarButtonStatus GetButtonStatus(void) const;
152 result SetButtonText(const Tizen::Base::String& text);
153 result SetButtonActionId(int actionId);
154 result SetButtonEnabled(bool enabled);
155 result SetButtonColor(SearchBarButtonStatus status, const Tizen::Graphics::Color& color);
156 result SetButtonTextColor(SearchBarButtonStatus status, const Tizen::Graphics::Color& color);
157 result AppendCharacter(const Tizen::Base::Character& character);
158 result AppendText(const Tizen::Base::String& text);
159 result SetText(const Tizen::Base::String& text);
160 result InsertCharacterAt(int index, const Tizen::Base::Character& character);
161 result InsertTextAt(int index, const Tizen::Base::String& text);
162 result DeleteCharacterAt(int index);
164 int GetTextLength(void) const;
165 Tizen::Base::String GetText(void) const;
166 Tizen::Base::String GetText(int start, int end) const;
167 int GetLimitLength(void) const;
168 result SetLimitLength(int limitLength);
169 result ShowKeypad(void) const;
170 result HideKeypad(void);
171 float GetSearchFieldTextSizeF(void) const;
172 result SetSearchFieldTextSize(float size);
173 result GetBlockRange(int& start, int& end) const;
174 result ReleaseBlock(void);
175 result SetBlockRange(int start, int end);
176 result RemoveTextBlock(void);
177 Tizen::Graphics::Color GetColor(void) const;
178 Tizen::Graphics::Color GetSearchFieldColor(SearchFieldStatus status) const;
179 Tizen::Graphics::Color GetSearchFieldTextColor(SearchFieldStatus status) const;
180 result SetBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap);
181 result SetColor(const Tizen::Graphics::Color& color);
182 result SetSearchFieldColor(SearchFieldStatus status, const Tizen::Graphics::Color& color);
183 result SetSearchFieldTextColor(SearchFieldStatus status, const Tizen::Graphics::Color& color);
184 Tizen::Base::String GetGuideText(void) const;
185 result SetGuideText(const Tizen::Base::String& guideText);
186 Tizen::Graphics::Color GetGuideTextColor(void) const;
187 result SetGuideTextColor(const Tizen::Graphics::Color& color);
188 int GetCursorPosition(void) const;
189 result SetCursorPosition(int index);
190 bool IsLowerCaseModeEnabled(void) const;
191 void SetLowerCaseModeEnabled(bool enable);
192 EllipsisPosition GetEllipsisPosition(void) const;
193 result SetEllipsisPosition(EllipsisPosition position);
194 CoreKeypadAction GetKeypadAction(void) const;
195 bool IsTextPredictionEnabled(void) const;
196 result SetTextPredictionEnabled(bool enable);
198 result GetCurrentLanguage(Tizen::Locales::LanguageCode& language) const;
199 result SetCurrentLanguage(Tizen::Locales::LanguageCode languageCode);
201 result AddActionEventListener(const _IActionEventListener& listener);
202 result RemoveActionEventListener(const _IActionEventListener& listener);
203 result AddKeypadEventListener(const _IKeypadEventListener& listener);
204 result RemoveKeypadEventListener(const _IKeypadEventListener& listener);
205 result AddTextBlockEventListener(const _ITextBlockEventListener& listener);
206 result RemoveTextBlockEventListener(const _ITextBlockEventListener& listener);
207 result AddTextEventListener(const _ITextEventListener& listener);
208 result RemoveTextEventListener(const _ITextEventListener& listener);
209 result AddSearchBarEventListener(const _ISearchBarEventListener& listener);
210 result RemoveSearchBarEventListener(const _ISearchBarEventListener& listener);
211 result AddLanguageEventListener(const _ILanguageEventListener& listener);
212 result RemoveLanguageEventListener(const _ILanguageEventListener& listener);
214 void SetContentsArea(void);
216 Tizen::Graphics::Bitmap* GetBackgroundBitmap(void) const;
217 bool IsUsableCancelButton(void) const;
219 _Button* GetSearchBarButton(void) const;
220 _Edit* GetSearchField(void);
221 _Control* GetSearchBarContainer(void) const;
222 _Control* GetClippedGroupControl(void) const;
224 result SendSearchBarEvent(_SearchBarEventStatus status);
225 void SetHeaderVisibleState(bool visible);
226 void SetContentDimming(void);
227 bool IsContentAttachable(const _Control* pContent);
228 result ResizeCancelButton(void);
229 SearchFieldStatus GetCurrentStatus(void);
230 void SetEditTextFilter(IEditTextFilter* pFilter);
231 void SendOpaqueCommand (const Tizen::Base::String& command);
233 virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
235 virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId);
237 virtual void OnKeypadWillOpen(void);
238 virtual void OnKeypadOpened(void);
239 virtual void OnKeypadClosed(void);
240 virtual void OnKeypadBoundsChanged(void);
241 virtual void OnKeypadActionPerformed(CoreKeypadAction keypadAction);
243 virtual void OnTextBlockSelected(Tizen::Ui::_Control& source, int start, int end);
245 virtual void OnTextValueChanged(const Tizen::Ui::_Control& source);
246 virtual void OnTextValueChangeCanceled(const Tizen::Ui::_Control& source);
248 virtual void OnBoundsChanged(void);
249 virtual void OnChangeLayout(_ControlOrientation orientation);
250 virtual result OnAttachedToMainTree(void);
251 virtual void OnFontChanged(Tizen::Graphics::Font* pFont);
252 virtual void OnFontInfoRequested(unsigned long& style, int& size);
253 virtual bool OnFocusGained(const _Control& source);
254 virtual bool OnFocusLost(const _Control& source);
256 virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
257 virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo);
260 virtual void OnDraw(void);
263 _SearchBar(const _SearchBar&);
264 _SearchBar& operator =(const _SearchBar&);
266 _ButtonStatus ConvertSearchBarButtonStatus(SearchBarButtonStatus status);
267 EditStatus ConvertSearchBarStatus(SearchFieldStatus status);
269 result CreateSearchField(void);
270 result CreateCancelButton(void);
271 result CreateFrontButton(void);
272 result CreateContentsArea(void);
273 result CreateClippedGroupControl(void);
274 //Tizen::Graphics::Font* CreateEditFontN(const Tizen::Graphics::Font* pFont);
276 Tizen::Ui::_Control* GetParentForm(void) const;
278 _SearchBarPresenter* __pSearchBarPresenter;
280 _Control* __pClippedGroupControl;
282 _Button* __pCancelButton;
283 _Control* __pContainer;
284 _Control* __pContentControl;
287 int __searchBarStyle;
289 bool __isButtonEnabled;
290 bool __isUsableCancelButton;
291 bool __isUserContainerBounds;
292 bool __isCancelActionInProgress;
294 CoreKeypadAction __keypadAction;
296 Tizen::Graphics::Bitmap* __pBackgroundBitmap;
297 Tizen::Graphics::Color __backgroundColor;
298 Tizen::Graphics::Color __contentColor;
300 Tizen::Graphics::Color __color[SEARCHBAR_COLOR_MAX];
301 Tizen::Graphics::Color __textColor[SEARCHBAR_COLOR_MAX];
302 Tizen::Graphics::Color __buttonColor[SEARCHBAR_BUTTON_COLOR_MAX];
303 Tizen::Graphics::Color __buttonTextColor[SEARCHBAR_BUTTON_COLOR_MAX];
304 Tizen::Graphics::Color __guideTextColor[SEARCHBAR_COLOR_MAX];
306 Tizen::Graphics::FloatRectangle __contentAreaBounds;
308 _ActionEvent* __pActionEvent;
309 _KeypadEvent* __pKeypadEvent;
310 _TextBlockEvent* __pTextBlockEvent;
311 _TextEvent* __pTextEvent;
312 _SearchBarEvent* __pSearchBarEvent;
313 _LanguageEvent* __pLanguageEvent;
314 static const byte _SEARCH_CONTENT_DIM_OPACITY = 128; //50% opacity
318 }}} // Tizen::Ui::Controls
320 #endif // _FUI_CTRL_INTERNAL_SEARCH_BAR_H_