Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrlFooter.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 * @file         FUiCtrlFooter.cpp
19 * @brief        This is the implementation file for Footer class.
20 */
21
22 #include <FUiCtrlFooter.h>
23 #include <FBaseSysLog.h>
24 #include "FUiCtrl_FooterImpl.h"
25
26 using namespace Tizen::Graphics;
27
28 namespace Tizen { namespace Ui { namespace Controls
29 {
30
31 result
32 Footer::AddItem(const FooterItem& item)
33 {
34         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
35
36         SysAssertf(pFooterImpl != null,
37                                 "Not yet constructed. Construct() should be called before use.");
38
39         return pFooterImpl->AddItem(item);
40 }
41
42 result
43 Footer::InsertItemAt(int itemIndex, const FooterItem& item)
44 {
45         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
46
47         SysAssertf(pFooterImpl != null,
48                                         "Not yet constructed. Construct() should be called before use.");
49
50         return pFooterImpl->InsertItemAt(itemIndex, item);
51 }
52
53 bool
54 Footer::IsButtonSet(ButtonPosition position) const
55 {
56         ClearLastResult();
57
58         const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
59
60         SysAssertf(pFooterImpl != null,
61                                         "Not yet constructed. Construct() should be called before use.");
62
63         return pFooterImpl->IsButtonSet(position);
64 }
65
66 bool
67 Footer::IsBackButtonSet(void) const
68 {
69         ClearLastResult();
70
71         const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
72
73         SysAssertf(pFooterImpl != null,
74                                         "Not yet constructed. Construct() should be called before use.");
75
76         return pFooterImpl->IsBackButtonSet();
77 }
78
79 bool
80 Footer::IsTabEditModeEnabled(void) const
81 {
82         ClearLastResult();
83
84         const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
85
86         SysAssertf(pFooterImpl != null,
87                                         "Not yet constructed. Construct() should be called before use.");
88
89         return pFooterImpl->IsTabEditModeEnabled();
90 }
91
92 Color
93 Footer::GetButtonColor(ButtonItemStatus status) const
94 {
95         ClearLastResult();
96
97         const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
98
99         SysAssertf(pFooterImpl != null,
100                                         "Not yet constructed. Construct() should be called before use.");
101
102         return pFooterImpl->GetButtonColor(status);
103 }
104
105 Color
106 Footer::GetButtonTextColor(ButtonItemStatus status) const
107 {
108         ClearLastResult();
109
110         const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
111
112         SysAssertf(pFooterImpl != null,
113                                         "Not yet constructed. Construct() should be called before use.");
114
115         return pFooterImpl->GetButtonTextColor(status);
116 }
117
118 ButtonItemStatus
119 Footer::GetButtonStatus(ButtonPosition position) const
120 {
121         ClearLastResult();
122
123         const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
124
125         SysAssertf(pFooterImpl != null,
126                                         "Not yet constructed. Construct() should be called before use.");
127
128         return pFooterImpl->GetButtonStatus(position);
129 }
130
131 ButtonItemStatus
132 Footer::GetBackButtonStatus(void) const
133 {
134         ClearLastResult();
135
136         const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
137
138         SysAssertf(pFooterImpl != null,
139                                         "Not yet constructed. Construct() should be called before use.");
140
141         return pFooterImpl->GetBackButtonStatus();
142 }
143
144 Color
145 Footer::GetItemColor(FooterItemStatus status) const
146 {
147         ClearLastResult();
148
149         const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
150
151         SysAssertf(pFooterImpl != null,
152                                         "Not yet constructed. Construct() should be called before use.");
153
154         return pFooterImpl->GetItemColor(status);
155 }
156
157 int
158 Footer::GetItemCount(void) const
159 {
160         ClearLastResult();
161
162         const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
163
164         SysAssertf(pFooterImpl != null,
165                                         "Not yet constructed. Construct() should be called before use.");
166
167         return pFooterImpl->GetItemCount();
168 }
169
170 result
171 Footer::GetItemStatus(int itemIndex, FooterItemStatus& status) const
172 {
173         const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
174
175         SysAssertf(pFooterImpl != null,
176                                         "Not yet constructed. Construct() should be called before use.");
177
178         return pFooterImpl->GetItemStatus(itemIndex, status);
179 }
180
181 Color
182 Footer::GetItemTextColor(FooterItemStatus status) const
183 {
184         ClearLastResult();
185
186         const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
187
188         SysAssertf(pFooterImpl != null,
189                                         "Not yet constructed. Construct() should be called before use.");
190
191         return pFooterImpl->GetItemTextColor(status);
192 }
193
194 FooterStyle
195 Footer::GetStyle(void) const
196 {
197         ClearLastResult();
198
199         const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
200
201         SysAssertf(pFooterImpl != null,
202                                         "Not yet constructed. Construct() should be called before use.");
203
204         return pFooterImpl->GetStyle();
205 }
206
207 int
208 Footer::GetSelectedItemIndex(void) const
209 {
210         ClearLastResult();
211
212         const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
213
214         SysAssertf(pFooterImpl != null,
215                                         "Not yet constructed. Construct() should be called before use.");
216
217         return pFooterImpl->GetSelectedItemIndex();
218 }
219
220 Color
221 Footer::GetColor(void) const
222 {
223         ClearLastResult();
224
225         const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
226
227         SysAssertf(pFooterImpl != null,
228                                         "Not yet constructed. Construct() should be called before use.");
229
230         return pFooterImpl->GetColor();
231 }
232
233 result
234 Footer::RemoveAllButtons(void)
235 {
236         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
237
238         SysAssertf(pFooterImpl != null,
239                                         "Not yet constructed. Construct() should be called before use.");
240
241         return pFooterImpl->RemoveAllButtons();
242 }
243
244 result
245 Footer::RemoveButtonAt(ButtonPosition position)
246 {
247         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
248
249         SysAssertf(pFooterImpl != null,
250                                         "Not yet constructed. Construct() should be called before use.");
251
252         return pFooterImpl->RemoveButtonAt(position);
253 }
254
255 result
256 Footer::RemoveBackButton(void)
257 {
258         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
259
260         SysAssertf(pFooterImpl != null,
261                                         "Not yet constructed. Construct() should be called before use.");
262
263         return pFooterImpl->RemoveBackButton();
264 }
265
266 result
267 Footer::RemoveAllItems(void)
268 {
269         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
270
271         SysAssertf(pFooterImpl != null,
272                                         "Not yet constructed. Construct() should be called before use.");
273
274         return pFooterImpl->RemoveAllItems();
275 }
276
277 result
278 Footer::RemoveItemAt(int itemIndex)
279 {
280         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
281
282         SysAssertf(pFooterImpl != null,
283                                         "Not yet constructed. Construct() should be called before use.");
284
285         return pFooterImpl->RemoveItemAt(itemIndex);
286 }
287
288 result
289 Footer::SetBackgroundBitmap(const Bitmap* pBitmap)
290 {
291         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
292
293         SysAssertf(pFooterImpl != null,
294                                         "Not yet constructed. Construct() should be called before use.");
295
296         return pFooterImpl->SetBackgroundBitmap(pBitmap);
297 }
298
299 result
300 Footer::SetButton(ButtonPosition position, const ButtonItem& button)
301 {
302         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
303
304         SysAssertf(pFooterImpl != null,
305                                         "Not yet constructed. Construct() should be called before use.");
306
307         return pFooterImpl->SetButton(position, button);
308 }
309
310 result
311 Footer::SetButtonColor(ButtonItemStatus status, const Color& color)
312 {
313         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
314
315         SysAssertf(pFooterImpl != null,
316                                         "Not yet constructed. Construct() should be called before use.");
317
318         return pFooterImpl->SetButtonColor(status, color);
319 }
320
321 result
322 Footer::SetButtonTextColor(ButtonItemStatus status, const Color& color)
323 {
324         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
325
326         SysAssertf(pFooterImpl != null,
327                                         "Not yet constructed. Construct() should be called before use.");
328
329         return pFooterImpl->SetButtonTextColor(status, color);
330 }
331
332 result
333 Footer::SetButtonEnabled(ButtonPosition position, bool enable)
334 {
335         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
336
337         SysAssertf(pFooterImpl != null,
338                                         "Not yet constructed. Construct() should be called before use.");
339
340         return pFooterImpl->SetButtonEnabled(position, enable);
341 }
342
343 result
344 Footer::SetBackButtonEnabled(bool enable)
345 {
346         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
347
348         SysAssertf(pFooterImpl != null,
349                                         "Not yet constructed. Construct() should be called before use.");
350
351         return pFooterImpl->SetBackButtonEnabled(enable);
352 }
353
354 result
355 Footer::SetBackButton(void)
356 {
357         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
358
359         SysAssertf(pFooterImpl != null,
360                                         "Not yet constructed. Construct() should be called before use.");
361
362         return pFooterImpl->SetBackButton();
363 }
364
365 result
366 Footer::SetItemAt(int itemIndex, const FooterItem& item)
367 {
368         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
369
370         SysAssertf(pFooterImpl != null,
371                                         "Not yet constructed. Construct() should be called before use.");
372
373         return pFooterImpl->SetItemAt(itemIndex, item);
374 }
375
376 result
377 Footer::SetItemColor(FooterItemStatus status, const Color& color)
378 {
379         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
380
381         SysAssertf(pFooterImpl != null,
382                                         "Not yet constructed. Construct() should be called before use.");
383
384         return pFooterImpl->SetItemColor(status, color);
385 }
386
387 result
388 Footer::SetItemEnabled(int itemIndex, bool enabled)
389 {
390         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
391
392         SysAssertf(pFooterImpl != null,
393                                         "Not yet constructed. Construct() should be called before use.");
394
395         return pFooterImpl->SetItemEnabled(itemIndex, enabled);
396 }
397
398 result
399 Footer::SetItemBadgeIcon(int itemIndex, const Bitmap* pBadgeIcon)
400 {
401         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
402
403         SysAssertf(pFooterImpl != null,
404                                         "Not yet constructed. Construct() should be called before use.");
405
406         return pFooterImpl->SetItemBadgeIcon(itemIndex, pBadgeIcon);
407 }
408
409 result
410 Footer::SetItemTextColor(FooterItemStatus status, const Color& color)
411 {
412         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
413
414         SysAssertf(pFooterImpl != null,
415                                         "Not yet constructed. Construct() should be called before use.");
416
417         return pFooterImpl->SetItemTextColor(status, color);
418 }
419
420 result
421 Footer::SetItemSelected(int itemIndex)
422 {
423         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
424
425         SysAssertf(pFooterImpl != null,
426                                         "Not yet constructed. Construct() should be called before use.");
427
428         return pFooterImpl->SetItemSelected(itemIndex);
429 }
430
431 result
432 Footer::SetItemNumberedBadgeIcon(int itemIndex, int number)
433 {
434         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
435
436         SysAssertf(pFooterImpl != null,
437                                         "Not yet constructed. Construct() should be called before use.");
438
439         return pFooterImpl->SetItemNumberedBadgeIcon(itemIndex, number);
440 }
441
442 result
443 Footer::SetColor(const Color& color)
444 {
445         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
446
447         SysAssertf(pFooterImpl != null,
448                                         "Not yet constructed. Construct() should be called before use.");
449
450         return pFooterImpl->SetColor(color);
451 }
452
453 result
454 Footer::SetStyle(FooterStyle style)
455 {
456         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
457
458         SysAssertf(pFooterImpl != null,
459                                         "Not yet constructed. Construct() should be called before use.");
460
461         return pFooterImpl->SetStyle(style);
462 }
463
464 result
465 Footer::SetTabEditModeEnabled(bool enable)
466 {
467         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
468
469         SysAssertf(pFooterImpl != null,
470                                         "Not yet constructed. Construct() should be called before use.");
471
472         return pFooterImpl->SetTabEditModeEnabled(enable);
473 }
474
475 void
476 Footer::AddActionEventListener(IActionEventListener& listener)
477 {
478         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
479
480         SysAssertf(pFooterImpl != null,
481                                         "Not yet constructed. Construct() should be called before use.");
482
483         pFooterImpl->AddActionEventListener(listener);
484
485         return;
486 }
487
488 void
489 Footer::RemoveActionEventListener(IActionEventListener& listener)
490 {
491         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
492
493         SysAssertf(pFooterImpl != null,
494                                         "Not yet constructed. Construct() should be called before use.");
495
496         pFooterImpl->RemoveActionEventListener(listener);
497
498         return;
499 }
500
501 Footer::Footer(void)
502 {
503 }
504
505 Footer::~Footer(void)
506 {
507 }
508
509 result
510 Footer::Construct(void)
511 {
512         SysAssertf(_pControlImpl == null,
513                                 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
514
515         result r = E_SUCCESS;
516
517         _FooterImpl* pImpl = _FooterImpl::CreateFooterImplN(this);
518         r = GetLastResult();
519         SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
520
521         _pControlImpl = pImpl;
522
523         return r;
524 }
525
526 Rectangle
527 Footer::GetButtonBounds(ButtonPosition position) const
528 {
529         ClearLastResult();
530
531         const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
532
533         SysAssertf(pFooterImpl != null,
534                                         "Not yet constructed. Construct() should be called before use.");
535
536         return pFooterImpl->GetButtonBounds(position);
537 }
538
539 FloatRectangle
540 Footer::GetButtonBoundsF(ButtonPosition position) const
541 {
542         ClearLastResult();
543
544         const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
545
546         SysAssertf(pFooterImpl != null,
547                                         "Not yet constructed. Construct() should be called before use.");
548
549         return pFooterImpl->GetButtonBoundsF(position);
550 }
551
552 result
553 Footer::SetButtonBadgeIcon(ButtonPosition position, const Bitmap* pBadgeIcon)
554 {
555         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
556
557         SysAssertf(pFooterImpl != null,
558                                         "Not yet constructed. Construct() should be called before use.");
559
560         return pFooterImpl->SetButtonBadgeIcon(position, pBadgeIcon);
561 }
562
563 result
564 Footer::SetButtonNumberedBadgeIcon(ButtonPosition position, int number)
565 {
566         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this);
567
568         SysAssertf(pFooterImpl != null,
569                                         "Not yet constructed. Construct() should be called before use.");
570
571         return pFooterImpl->SetButtonNumberedBadgeIcon(position, number);
572 }
573
574 }}} // Tizen::Ui::Controls