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.
18 * @file FUiCtrl_Toolbar.cpp
19 * @brief This is the implementation file for the _Toolbar class.
22 #include <FBaseSysLog.h>
23 #include <FGrp_BitmapImpl.h>
24 #include "FUi_AccessibilityContainer.h"
25 #include "FUi_AccessibilityElement.h"
26 #include "FUi_AccessibilityManager.h"
27 #include "FUi_TouchLongPressGestureDetector.h"
28 #include "FUi_ResourceManager.h"
29 #include "FUiCtrl_ActionEvent.h"
30 #include "FUiCtrl_Toolbar.h"
31 #include "FUiCtrl_ToolbarPresenter.h"
32 #include "FUiCtrl_Label.h"
33 #include "FUiCtrl_Form.h"
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::Graphics;
38 using namespace Tizen::Ui;
40 namespace Tizen { namespace Ui { namespace Controls
43 IMPLEMENT_PROPERTY(_Toolbar);
45 _Toolbar::_Toolbar(void)
47 , __pToolbarPresenter(null)
48 , __pActionEventListener(null)
49 , __pBackEventListener(null)
50 , __pLongPressGesture(null)
51 , __pToolbarBackgroundBitmap(null)
54 , __descriptionText(L"")
55 , __titleTextAlignment(ALIGNMENT_LEFT)
57 , __pAnimationFrameList(null)
60 , __style(TOOLBAR_TITLE)
61 , __transparent(false)
62 , __isUserBackgroundBitmap(false)
63 , __titleTextArea(Rectangle(0, 0, 0, 0))
64 , __itemArea(Rectangle(0, 0, 0, 0))
65 , __pTitleTextElement(null)
67 _AccessibilityContainer* pContainer = null;
69 __pButtonItems[LEFT_BUTTON] = null;
70 __pButtonItems[RIGHT_BUTTON] = null;
71 __pButtonItems[BACK_BUTTON] = null;
72 __pButtonItems[MIDDLE_BUTTON] = null;
74 for (int i = 0; i < TOOLBAR_ANIMATION_POSITION_MAX; i++)
76 __pAnimation[i] = null;
81 GET_COLOR_CONFIG(FOOTER::BG_NORMAL, bgColor);
85 _Control::SetResizable(false);
87 _Control::SetMovable(false);
89 _ToolbarPresenter* pPresenter = new (std::nothrow) _ToolbarPresenter();
91 SetPresenter(*pPresenter);
93 pPresenter->Construct(*this);
95 pPresenter->Install();
97 pContainer = GetAccessibilityContainer();
101 pContainer->Activate(true);
104 for (int i = 0; i < TOOLBAR_ITEM_MAX_STATE_COUNT; i++)
106 __isItemBgColorSetByUser[i] = false;
107 __isItemTextColorSetByUser[i] = false;
110 for (int i = 0; i < TOOLBAR_BUTTON_MAX_STATE_COUNT; i++)
112 __isButtonBgColorSetByUser[i] = false;
113 __isButtonTextColorSetByUser[i] = false;
117 _Toolbar::~_Toolbar(void)
119 RemoveAllItems(); //__pMoreButton would be deleted in this function
122 if (__pToolbarPresenter)
124 delete __pToolbarPresenter;
125 __pToolbarPresenter = null;
128 if (__pActionEventListener)
130 __pActionEventListener = null;
133 if (__pBackEventListener)
135 __pBackEventListener = null;
138 if (__pLongPressGesture != null)
140 __pLongPressGesture->RemoveGestureListener(*this);
141 RemoveGestureDetector(*__pLongPressGesture);
143 delete __pLongPressGesture;
144 __pLongPressGesture = null;
147 if (__pToolbarBackgroundBitmap)
149 delete __pToolbarBackgroundBitmap;
150 __pToolbarBackgroundBitmap = null;
159 if (__pAnimationFrameList)
161 delete __pAnimationFrameList;
162 __pAnimationFrameList = null;
165 if (__pAnimation[TOOLBAR_ANIMATION_POSITION_TITLE])
167 DetachChild(*__pAnimation[TOOLBAR_ANIMATION_POSITION_TITLE]);
168 delete __pAnimation[TOOLBAR_ANIMATION_POSITION_TITLE];
169 __pAnimation[TOOLBAR_ANIMATION_POSITION_TITLE] = null;
172 if (__pTitleTextElement)
174 __pTitleTextElement->Activate(false);
175 __pTitleTextElement = null;
182 _Toolbar::CreateToolbarN(bool header)
184 _Toolbar* pToolbar = new (std::nothrow) _Toolbar();
185 SysTryReturn(NID_UI_CTRL, pToolbar, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
187 pToolbar->Initialize(header);
188 pToolbar->AcquireHandle();
194 _Toolbar::Initialize(bool header)
202 _Toolbar::InitToolbarColor(void)
204 if (__header == true)
206 if (__transparent) // header && transparent
208 GET_COLOR_CONFIG(HEADER::TRANSLUCENT_TITLE_TEXT_NORMAL, __transTitleTextColor);
209 GET_COLOR_CONFIG(HEADER::TRANSLUCENT_DESCRIPTION_TEXT_NORMAL, __transDescriptionTextColor);
211 if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
213 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_BG_NORMAL, __itemTransBackgroundColor[_BUTTON_STATUS_NORMAL]);
214 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_BG_DISABLED, __itemTransBackgroundColor[_BUTTON_STATUS_DISABLED]);
215 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_BG_PRESSED, __itemTransBackgroundColor[_BUTTON_STATUS_PRESSED]);
216 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_BG_HIGHLIGHTED, __itemTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
217 //GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_BG_SELECTED, __itemTransBackgroundColor[_BUTTON_STATUS_SELECTED]);
219 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_TEXT_NORMAL, __itemTransTextColor[_BUTTON_STATUS_NORMAL]);
220 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_TEXT_DISABLED, __itemTransTextColor[_BUTTON_STATUS_DISABLED]);
221 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_TEXT_PRESSED, __itemTransTextColor[_BUTTON_STATUS_PRESSED]);
222 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_TEXT_HIGHLIGHTED, __itemTransTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
223 //GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_TEXT_SELECTED, __itemTransTextColor[_BUTTON_STATUS_SELECTED]);
227 GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TRANSLUCENT_BG_NORMAL, __itemTransBackgroundColor[_BUTTON_STATUS_NORMAL]);
228 GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TRANSLUCENT_BG_DISABLED, __itemTransBackgroundColor[_BUTTON_STATUS_DISABLED]);
229 GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TRANSLUCENT_BG_PRESSED, __itemTransBackgroundColor[_BUTTON_STATUS_PRESSED]);
230 GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TRANSLUCENT_BG_HIGHLIGHTED, __itemTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
231 GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TRANSLUCENT_BG_SELECTED, __itemTransBackgroundColor[_BUTTON_STATUS_SELECTED]);
233 GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TRANSLUCENT_TEXT_NORMAL, __itemTransTextColor[_BUTTON_STATUS_NORMAL]);
234 GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TRANSLUCENT_TEXT_DISABLED, __itemTransTextColor[_BUTTON_STATUS_DISABLED]);
235 GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TRANSLUCENT_TEXT_PRESSED, __itemTransTextColor[_BUTTON_STATUS_PRESSED]);
236 GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TRANSLUCENT_TEXT_HIGHLIGHTED, __itemTransTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
237 GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TRANSLUCENT_TEXT_SELECTED, __itemTransTextColor[_BUTTON_STATUS_SELECTED]);
240 __itemTransBackgroundColor[_BUTTON_STATUS_NORMAL].SetAlpha(0x00);
241 __itemTransBackgroundColor[_BUTTON_STATUS_DISABLED].SetAlpha(0x00);
242 __itemTransBackgroundColor[_BUTTON_STATUS_PRESSED].SetAlpha(0xFF);
243 __itemTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED].SetAlpha(0x00);
244 __itemTransBackgroundColor[_BUTTON_STATUS_SELECTED].SetAlpha(0x00);
246 GET_COLOR_CONFIG(HEADER::BUTTON_TRANSLUCENT_BG_NORMAL, __buttonTransBackgroundColor[_BUTTON_STATUS_NORMAL]);
247 GET_COLOR_CONFIG(HEADER::BUTTON_TRANSLUCENT_BG_DISABLED, __buttonTransBackgroundColor[_BUTTON_STATUS_DISABLED]);
248 GET_COLOR_CONFIG(HEADER::BUTTON_TRANSLUCENT_BG_PRESSED, __buttonTransBackgroundColor[_BUTTON_STATUS_PRESSED]);
249 GET_COLOR_CONFIG(HEADER::BUTTON_TRANSLUCENT_BG_HIGHLIGHTED, __buttonTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
251 __buttonTransBackgroundColor[_BUTTON_STATUS_NORMAL].SetAlpha(0x00);
252 __buttonTransBackgroundColor[_BUTTON_STATUS_DISABLED].SetAlpha(0x00);
253 __buttonTransBackgroundColor[_BUTTON_STATUS_PRESSED].SetAlpha(0x00);
254 __buttonTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED].SetAlpha(0x00);
256 GET_COLOR_CONFIG(HEADER::BUTTON_TRANSLUCENT_TEXT_NORMAL, __buttonTransTextColor[_BUTTON_STATUS_NORMAL]);
257 GET_COLOR_CONFIG(HEADER::BUTTON_TRANSLUCENT_TEXT_DISABLED, __buttonTransTextColor[_BUTTON_STATUS_DISABLED]);
258 GET_COLOR_CONFIG(HEADER::BUTTON_TRANSLUCENT_TEXT_PRESSED, __buttonTransTextColor[_BUTTON_STATUS_PRESSED]);
259 GET_COLOR_CONFIG(HEADER::BUTTON_TRANSLUCENT_TEXT_HIGHLIGHTED, __buttonTransTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
261 else // header && not transparent
263 GET_COLOR_CONFIG(HEADER::TITLE_TEXT_NORMAL, __titleTextColor);
264 GET_COLOR_CONFIG(HEADER::TITLE_TEXT_NORMAL, __descriptionTextColor);
267 if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
269 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_NORMAL])
271 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_NORMAL, __itemBackgroundColor[_BUTTON_STATUS_NORMAL]);
273 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_DISABLED])
275 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_DISABLED, __itemBackgroundColor[_BUTTON_STATUS_DISABLED]);
277 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_PRESSED])
279 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_PRESSED, __itemBackgroundColor[_BUTTON_STATUS_PRESSED]);
281 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
283 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_HIGHLIGHTED, __itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
285 //if (!__isItemBgColorSetByUser[_BUTTON_STATUS_SELECTED])
287 // GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_SELECTED, __itemBackgroundColor[_BUTTON_STATUS_SELECTED]);
290 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_NORMAL])
292 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_NORMAL, __itemTextColor[_BUTTON_STATUS_NORMAL]);
294 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_DISABLED])
296 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_DISABLED, __itemTextColor[_BUTTON_STATUS_DISABLED]);
298 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_PRESSED])
300 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_PRESSED, __itemTextColor[_BUTTON_STATUS_PRESSED]);
302 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
304 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_HIGHLIGHTED, __itemTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
306 //if (!__isItemTextColorSetByUser[_BUTTON_STATUS_SELECTED])
308 // GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_SELECTED, __itemTextColor[_BUTTON_STATUS_SELECTED]);
313 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_NORMAL])
315 GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_BG_NORMAL, __itemBackgroundColor[_BUTTON_STATUS_NORMAL]);
317 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_DISABLED])
319 GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_BG_DISABLED, __itemBackgroundColor[_BUTTON_STATUS_DISABLED]);
321 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_PRESSED])
323 GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_BG_PRESSED, __itemBackgroundColor[_BUTTON_STATUS_PRESSED]);
325 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
327 GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_BG_HIGHLIGHTED, __itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
329 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_SELECTED])
331 GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_BG_SELECTED, __itemBackgroundColor[_BUTTON_STATUS_SELECTED]);
334 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_NORMAL])
336 GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TEXT_NORMAL, __itemTextColor[_BUTTON_STATUS_NORMAL]);
338 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_DISABLED])
340 GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TEXT_DISABLED, __itemTextColor[_BUTTON_STATUS_DISABLED]);
342 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_PRESSED])
344 GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TEXT_PRESSED, __itemTextColor[_BUTTON_STATUS_PRESSED]);
346 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
348 GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TEXT_HIGHLIGHTED, __itemTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
350 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_SELECTED])
352 GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TEXT_SELECTED, __itemTextColor[_BUTTON_STATUS_SELECTED]);
356 if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_NORMAL])
358 GET_COLOR_CONFIG(HEADER::BUTTON_BG_NORMAL, __buttonBackgroundColor[_BUTTON_STATUS_NORMAL]);
360 if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_DISABLED])
362 GET_COLOR_CONFIG(HEADER::BUTTON_BG_DISABLED, __buttonBackgroundColor[_BUTTON_STATUS_DISABLED]);
364 if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_PRESSED])
366 GET_COLOR_CONFIG(HEADER::BUTTON_BG_PRESSED, __buttonBackgroundColor[_BUTTON_STATUS_PRESSED]);
368 if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
370 GET_COLOR_CONFIG(HEADER::BUTTON_BG_HIGHLIGHTED, __buttonBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
373 if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_NORMAL])
375 GET_COLOR_CONFIG(HEADER::BUTTON_TEXT_NORMAL, __buttonTextColor[_BUTTON_STATUS_NORMAL]);
377 if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_DISABLED])
379 GET_COLOR_CONFIG(HEADER::BUTTON_TEXT_DISABLED, __buttonTextColor[_BUTTON_STATUS_DISABLED]);
381 if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_PRESSED])
383 GET_COLOR_CONFIG(HEADER::BUTTON_TEXT_PRESSED, __buttonTextColor[_BUTTON_STATUS_PRESSED]);
385 if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
387 GET_COLOR_CONFIG(HEADER::BUTTON_TEXT_HIGHLIGHTED, __buttonTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
393 if (__transparent) // footer && transparent
395 if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
397 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_BG_NORMAL, __itemTransBackgroundColor[_BUTTON_STATUS_NORMAL]);
398 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_BG_DISABLED, __itemTransBackgroundColor[_BUTTON_STATUS_DISABLED]);
399 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_BG_PRESSED, __itemTransBackgroundColor[_BUTTON_STATUS_PRESSED]);
400 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_BG_HIGHLIGHTED, __itemTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
401 //GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_BG_SELECTED, __itemTransBackgroundColor[_BUTTON_STATUS_SELECTED]);
403 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_TEXT_NORMAL, __itemTransTextColor[_BUTTON_STATUS_NORMAL]);
404 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_TEXT_DISABLED, __itemTransTextColor[_BUTTON_STATUS_DISABLED]);
405 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_TEXT_PRESSED, __itemTransTextColor[_BUTTON_STATUS_PRESSED]);
406 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_TEXT_HIGHLIGHTED, __itemTransTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
407 //GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_TEXT_SELECTED, __itemTransTextColor[_BUTTON_STATUS_SELECTED]);
411 GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TRANSLUCENT_BG_NORMAL, __itemTransBackgroundColor[_BUTTON_STATUS_NORMAL]);
412 GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TRANSLUCENT_BG_DISABLED, __itemTransBackgroundColor[_BUTTON_STATUS_DISABLED]);
413 GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TRANSLUCENT_BG_PRESSED, __itemTransBackgroundColor[_BUTTON_STATUS_PRESSED]);
414 GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TRANSLUCENT_BG_HIGHLIGHTED, __itemTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
415 GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TRANSLUCENT_BG_SELECTED, __itemTransBackgroundColor[_BUTTON_STATUS_SELECTED]);
417 GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TRANSLUCENT_TEXT_NORMAL, __itemTransTextColor[_BUTTON_STATUS_NORMAL]);
418 GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TRANSLUCENT_TEXT_DISABLED, __itemTransTextColor[_BUTTON_STATUS_DISABLED]);
419 GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TRANSLUCENT_TEXT_PRESSED, __itemTransTextColor[_BUTTON_STATUS_PRESSED]);
420 GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TRANSLUCENT_TEXT_HIGHLIGHTED, __itemTransTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
421 GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TRANSLUCENT_TEXT_SELECTED, __itemTransTextColor[_BUTTON_STATUS_SELECTED]);
424 __itemTransBackgroundColor[_BUTTON_STATUS_NORMAL].SetAlpha(0x00);
425 __itemTransBackgroundColor[_BUTTON_STATUS_DISABLED].SetAlpha(0x00);
426 __itemTransBackgroundColor[_BUTTON_STATUS_PRESSED].SetAlpha(0xFF);
427 __itemTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED].SetAlpha(0x00);
428 __itemTransBackgroundColor[_BUTTON_STATUS_SELECTED].SetAlpha(0x00);
431 GET_COLOR_CONFIG(FOOTER::BUTTON_TRANSLUCENT_BG_NORMAL, __buttonTransBackgroundColor[_BUTTON_STATUS_NORMAL]);
432 GET_COLOR_CONFIG(FOOTER::BUTTON_TRANSLUCENT_BG_DISABLED, __buttonTransBackgroundColor[_BUTTON_STATUS_DISABLED]);
433 GET_COLOR_CONFIG(FOOTER::BUTTON_TRANSLUCENT_BG_PRESSED, __buttonTransBackgroundColor[_BUTTON_STATUS_PRESSED]);
434 GET_COLOR_CONFIG(FOOTER::BUTTON_TRANSLUCENT_BG_HIGHLIGHTED, __buttonTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
436 __buttonTransBackgroundColor[_BUTTON_STATUS_NORMAL].SetAlpha(0x00);
437 __buttonTransBackgroundColor[_BUTTON_STATUS_DISABLED].SetAlpha(0x00);
438 __buttonTransBackgroundColor[_BUTTON_STATUS_PRESSED].SetAlpha(0x00);
439 __buttonTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED].SetAlpha(0x00);
441 GET_COLOR_CONFIG(FOOTER::BUTTON_TRANSLUCENT_TEXT_NORMAL, __buttonTransTextColor[_BUTTON_STATUS_NORMAL]);
442 GET_COLOR_CONFIG(FOOTER::BUTTON_TRANSLUCENT_TEXT_DISABLED, __buttonTransTextColor[_BUTTON_STATUS_DISABLED]);
443 GET_COLOR_CONFIG(FOOTER::BUTTON_TRANSLUCENT_TEXT_PRESSED, __buttonTransTextColor[_BUTTON_STATUS_PRESSED]);
444 GET_COLOR_CONFIG(FOOTER::BUTTON_TRANSLUCENT_TEXT_HIGHLIGHTED, __buttonTransTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
446 else // footer && not transparent
448 if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
450 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_NORMAL])
452 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_NORMAL, __itemBackgroundColor[_BUTTON_STATUS_NORMAL]);
454 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_DISABLED])
456 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_DISABLED, __itemBackgroundColor[_BUTTON_STATUS_DISABLED]);
458 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_PRESSED])
460 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_PRESSED, __itemBackgroundColor[_BUTTON_STATUS_PRESSED]);
462 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
464 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_HIGHLIGHTED, __itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
466 //if (!__isItemBgColorSetByUser[_BUTTON_STATUS_SELECTED])
468 // GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_SELECTED, __itemBackgroundColor[_BUTTON_STATUS_SELECTED]);
471 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_NORMAL])
473 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_NORMAL, __itemTextColor[_BUTTON_STATUS_NORMAL]);
475 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_DISABLED])
477 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_DISABLED, __itemTextColor[_BUTTON_STATUS_DISABLED]);
479 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_PRESSED])
481 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_PRESSED, __itemTextColor[_BUTTON_STATUS_PRESSED]);
483 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
485 GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_HIGHLIGHTED, __itemTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
487 //if (!__isItemTextColorSetByUser[_BUTTON_STATUS_SELECTED])
489 // GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_SELECTED, __itemTextColor[_BUTTON_STATUS_SELECTED]);
494 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_NORMAL])
496 GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_BG_NORMAL, __itemBackgroundColor[_BUTTON_STATUS_NORMAL]);
498 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_DISABLED])
500 GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_BG_DISABLED, __itemBackgroundColor[_BUTTON_STATUS_DISABLED]);
502 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_PRESSED])
504 GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_BG_PRESSED, __itemBackgroundColor[_BUTTON_STATUS_PRESSED]);
506 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
508 GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_BG_HIGHLIGHTED, __itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
510 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_SELECTED])
512 GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_BG_SELECTED, __itemBackgroundColor[_BUTTON_STATUS_SELECTED]);
515 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_NORMAL])
517 GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TEXT_NORMAL, __itemTextColor[_BUTTON_STATUS_NORMAL]);
519 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_DISABLED])
521 GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TEXT_DISABLED, __itemTextColor[_BUTTON_STATUS_DISABLED]);
523 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_PRESSED])
525 GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TEXT_PRESSED, __itemTextColor[_BUTTON_STATUS_PRESSED]);
527 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
529 GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TEXT_HIGHLIGHTED, __itemTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
531 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_SELECTED])
533 GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TEXT_SELECTED, __itemTextColor[_BUTTON_STATUS_SELECTED]);
537 if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_NORMAL])
539 GET_COLOR_CONFIG(FOOTER::BUTTON_BG_NORMAL, __buttonBackgroundColor[_BUTTON_STATUS_NORMAL]);
541 if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_DISABLED])
543 GET_COLOR_CONFIG(FOOTER::BUTTON_BG_DISABLED, __buttonBackgroundColor[_BUTTON_STATUS_DISABLED]);
545 if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_PRESSED])
547 GET_COLOR_CONFIG(FOOTER::BUTTON_BG_PRESSED, __buttonBackgroundColor[_BUTTON_STATUS_PRESSED]);
549 if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
551 GET_COLOR_CONFIG(FOOTER::BUTTON_BG_HIGHLIGHTED, __buttonBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
554 if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_NORMAL])
556 GET_COLOR_CONFIG(FOOTER::BUTTON_TEXT_NORMAL, __buttonTextColor[_BUTTON_STATUS_NORMAL]);
558 if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_DISABLED])
560 GET_COLOR_CONFIG(FOOTER::BUTTON_TEXT_DISABLED, __buttonTextColor[_BUTTON_STATUS_DISABLED]);
562 if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_PRESSED])
564 GET_COLOR_CONFIG(FOOTER::BUTTON_TEXT_PRESSED, __buttonTextColor[_BUTTON_STATUS_PRESSED]);
566 if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
568 GET_COLOR_CONFIG(FOOTER::BUTTON_TEXT_HIGHLIGHTED, __buttonTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
577 _Toolbar::InitializeLongPressGesture(void)
579 result r = E_SUCCESS;
581 __pLongPressGesture = new (std::nothrow) _TouchLongPressGestureDetector();
582 SysTryReturn(NID_UI_CTRL, __pLongPressGesture, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create touch long press gesture.");
584 __pLongPressGesture->SetDuration(300);
586 r = AddGestureDetector(*__pLongPressGesture);
587 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to add gesture detector", GetErrorMessage(r));
589 r = __pLongPressGesture->AddGestureListener(*(dynamic_cast<_ITouchLongPressGestureEventListener*>(this)));
590 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to add gesture listener", GetErrorMessage(r));
596 _Toolbar::Construct(void)
598 result r = E_SUCCESS;
604 _Toolbar::AddItem(_Button* pButton)
606 SysTryReturnResult(NID_UI_CTRL, (__itemCount < TAB_ITEM_MAX), E_MAX_EXCEEDED,
607 "[E_MAX_EXCEEDED] The number of items have exceeded the maximum limit.");
609 if (__pActionEventListener != null)
611 pButton->AddActionEventListener(*__pActionEventListener);
614 __pItems.push_back(pButton);
617 AttachChild(*pButton);
619 ApplyUserGUI(TOOLBAR_ITEM, pButton);
623 AddAccessibilityItem(pButton);
629 _Toolbar::GetBackgroundBitmap(void) const
631 result r = E_SUCCESS;
633 _Toolbar* pToolbar = const_cast<_Toolbar*>(this);
635 if (!pToolbar->__pToolbarBackgroundBitmap)
639 r = GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pToolbar->__pToolbarBackgroundBitmap);
640 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
644 r = GET_BITMAP_CONFIG_N(FOOTER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pToolbar->__pToolbarBackgroundBitmap);
645 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
649 return pToolbar->__pToolbarBackgroundBitmap;
653 _Toolbar::GetButton(ToolbarButton position) const
655 SysTryReturn(NID_UI_CTRL, (position >= LEFT_BUTTON && position < BUTTON_MAX), null, E_OUT_OF_RANGE,
656 ("[E_OUT_OF_RANGE] The position is out of range."));
658 return __pButtonItems[position];
662 _Toolbar::GetButtonColor(_ButtonStatus status) const
668 case _BUTTON_STATUS_NORMAL:
669 color = GetProperty("normalButtonColor");
671 case _BUTTON_STATUS_DISABLED:
672 color = GetProperty("disabledButtonColor");
674 case _BUTTON_STATUS_PRESSED:
675 color = GetProperty("pressedButtonColor");
677 case _BUTTON_STATUS_HIGHLIGHTED:
678 color = GetProperty("highlightedButtonColor");
681 color = GetProperty("normalButtonColor");
685 return color.ToColor();
689 _Toolbar::GetButtonStatus(ToolbarButton position) const
691 return __pButtonItems[position]->GetButtonStatus();
695 _Toolbar::GetButtonTextColor(_ButtonStatus status) const
701 case _BUTTON_STATUS_NORMAL:
702 color = GetProperty("normalButtonTextColor");
704 case _BUTTON_STATUS_DISABLED:
705 color = GetProperty("disabledButtonTextColor");
707 case _BUTTON_STATUS_PRESSED:
708 color = GetProperty("pressedButtonTextColor");
710 case _BUTTON_STATUS_HIGHLIGHTED:
711 color = GetProperty("highlightedButtonTextColor");
714 color = GetProperty("normalButtonTextColor");
718 return color.ToColor();
722 _Toolbar::GetColor(void) const
724 Variant color = GetProperty("color");
726 return color.ToColor();
730 _Toolbar::GetDescriptionText(void) const
732 Variant text = GetProperty("descriptionText");
734 return text.ToString();
738 _Toolbar::GetDescriptionTextColor(void) const
740 Variant color = GetProperty("descriptionTextColor");
742 return color.ToColor();
746 _Toolbar::GetFirstEnabledItemIndex(void) const
748 int firstEnabledItemIndex = -1;
750 for (int i = 0; i < __itemCount; i++)
752 if(__pItems.at(i)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
754 firstEnabledItemIndex = i;
759 return firstEnabledItemIndex;
763 _Toolbar::GetItem(int itemIndex) const
765 if (__pItems.at(itemIndex) == null)
767 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Unable to get item.");
771 return __pItems.at(itemIndex);
775 _Toolbar::GetItemColor(_ButtonStatus status) const
781 case _BUTTON_STATUS_NORMAL:
782 color = GetProperty("normalItemColor");
784 case _BUTTON_STATUS_DISABLED:
785 color = GetProperty("disabledItemColor");
787 case _BUTTON_STATUS_PRESSED:
788 color = GetProperty("pressedItemColor");
790 case _BUTTON_STATUS_HIGHLIGHTED:
791 color = GetProperty("highlightedItemColor");
793 case _BUTTON_STATUS_SELECTED:
794 color = GetProperty("selectedItemColor");
797 color = GetProperty("normalItemColor");
801 return color.ToColor();
805 _Toolbar::GetItemCount(void) const
811 _Toolbar::GetItemIndexFromPosition(const Point& point) const
813 if (__itemCount <= 0)
818 for (int i = 0; i < __itemCount; i++)
820 Rectangle bounds = __pItems.at(i)->GetBounds();
822 if (bounds.Contains(point) && __pItems.at(i)->GetVisibleState() == true)
832 _Toolbar::GetItemStatus(int itemIndex, _ButtonStatus& status) const
834 status = _BUTTON_STATUS_NORMAL;
836 SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex <= __itemCount), E_OUT_OF_RANGE,
837 "[E_OUT_OF_RANGE] The itemIndex is out of range.");
839 status = __pItems.at(itemIndex)->GetButtonStatus();
845 _Toolbar::GetItemTextColor(_ButtonStatus status) const
851 case _BUTTON_STATUS_NORMAL:
852 color = GetProperty("normalItemTextColor");
854 case _BUTTON_STATUS_DISABLED:
855 color = GetProperty("disabledItemTextColor");
857 case _BUTTON_STATUS_PRESSED:
858 color = GetProperty("pressedItemTextColor");
860 case _BUTTON_STATUS_HIGHLIGHTED:
861 color = GetProperty("highlightedItemTextColor");
863 case _BUTTON_STATUS_SELECTED:
864 color = GetProperty("selectedItemTextColor");
867 color = GetProperty("normalItemTextColor");
871 return color.ToColor();
875 _Toolbar::GetSelectedItemIndex(void) const
877 if (__pToolbarPresenter)
879 return __pToolbarPresenter->GetSelectedItemIndex();
886 _Toolbar::GetStyle(void) const
888 return ToolbarStyle(__style);
892 _Toolbar::GetTitleIcon(void) const
898 _Toolbar::GetTitleText(void) const
900 Variant text = GetProperty("titleText");
901 return text.ToString();
905 _Toolbar::GetTitleTextColor(void) const
907 Variant color = GetProperty("titleTextColor");
908 return color.ToColor();
912 _Toolbar::GetTitleTextHorizontalAlignment(void) const
914 return __titleTextAlignment;
918 _Toolbar::IsInitialDraw(void) const
920 if (__pToolbarPresenter)
921 return __pToolbarPresenter->IsInitialDraw();
927 _Toolbar::IsTabEditModeEnabled(void) const
929 if (__pToolbarPresenter)
931 return __pToolbarPresenter->IsTabEditModeEnabled();
938 _Toolbar::IsTransparent(void) const
940 return __transparent;
945 _Toolbar::GetWaitingAnimationStatus(ToolbarAnimationPosition animationPos) const
947 if (animationPos < TOOLBAR_ANIMATION_POSITION_TITLE || animationPos >= TOOLBAR_ANIMATION_POSITION_MAX)
949 return ANIMATION_STOPPED;
952 if (__pAnimation[animationPos] == null)
954 return ANIMATION_STOPPED;
957 return __pAnimation[animationPos]->GetStatus();
961 _Toolbar::InsertItemAt(int itemIndex, _Button* pButton)
963 SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex <= __itemCount), E_OUT_OF_RANGE,
964 "[E_OUT_OF_RANGE] The itemIndex is out of range.");
966 if (__pActionEventListener != null)
968 pButton->AddActionEventListener(*__pActionEventListener);
971 __pItems.insert(__pItems.begin() + itemIndex, pButton);
974 AttachChild(*pButton);
976 ApplyUserGUI(TOOLBAR_ITEM, pButton);
979 AddAccessibilityItem(pButton);
985 _Toolbar::IsButtonSet(ToolbarButton position) const
987 if (__pButtonItems[position] != null)
996 _Toolbar::MoveItem(const int srcIndex, const int destIndex)
998 if (srcIndex == destIndex)
1000 SetItemSelected(destIndex, true);
1005 if (srcIndex < 0 || destIndex < 0 || srcIndex > __itemCount || destIndex > __itemCount)
1007 return E_INVALID_OPERATION;
1010 _Button* pSrcButton = null;
1011 pSrcButton = GetItem(srcIndex);
1013 _Button* pDestButton = null;
1014 pDestButton = GetItem(destIndex);
1016 __pItems.erase(__pItems.begin() + destIndex);
1017 __pItems.insert(__pItems.begin() + destIndex, pSrcButton);
1019 __pItems.erase(__pItems.begin() + srcIndex);
1020 __pItems.insert(__pItems.begin() + srcIndex, pDestButton);
1022 for (int i = 0; i < __itemCount; i++)
1024 __pItems.at(i)->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1027 SetItemSelected(destIndex, true);
1037 _Toolbar::PauseWaitingAnimation(ToolbarAnimationPosition animationPos)
1039 SysTryReturnResult(NID_UI_CTRL,
1040 (TOOLBAR_ANIMATION_POSITION_TITLE <= animationPos && animationPos < TOOLBAR_ANIMATION_POSITION_MAX), E_INVALID_ARG,
1041 "[E_INVALID_ARG] The animationPos is invalid.");
1042 SysTryReturnResult(NID_UI_CTRL, (__pAnimation[animationPos]), E_INVALID_STATE,
1043 "[E_INVALID_STATE] __pAnimation isn't constructed.");
1045 __pAnimation[animationPos]->Pause();
1051 _Toolbar::PlayWaitingAnimation(ToolbarAnimationPosition animationPos)
1053 SysTryReturnResult(NID_UI_CTRL,
1054 (TOOLBAR_ANIMATION_POSITION_TITLE <= animationPos && animationPos < TOOLBAR_ANIMATION_POSITION_MAX), E_INVALID_ARG,
1055 "[E_INVALID_ARG] The animationPos is invalid.");
1057 if ((animationPos == TOOLBAR_ANIMATION_POSITION_TITLE && __style != TOOLBAR_TITLE)
1058 || (animationPos == TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT && __pButtonItems[LEFT_BUTTON] == null)
1059 || (animationPos == TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT && __pButtonItems[RIGHT_BUTTON] == null))
1061 return E_UNSUPPORTED_OPERATION;
1064 if (__pAnimation[animationPos])
1066 if (__pAnimation[animationPos]->GetStatus() == ANIMATION_PLAYING)
1073 SetAnimation(animationPos);
1076 if (__pAnimation[animationPos])
1078 __pAnimation[animationPos]->Play();
1085 _Toolbar::RemoveAllButtons(void)
1087 for (int i = 0; i < BUTTON_MAX; i++)
1089 _Button* pButtonItem = __pButtonItems[i];
1091 if (pButtonItem != null)
1093 if (i == LEFT_BUTTON)
1095 StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT);
1097 else if (i == RIGHT_BUTTON)
1099 StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT);
1102 if (pButtonItem->GetChildCount() != 0)
1104 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(pButtonItem->GetChild(0));
1105 SysTryReturnResult(NID_UI_CTRL, pTempBadgeIcon, E_INVALID_STATE, "[E_INVALID_STATE] Couldn't get a badge icon.");
1107 pButtonItem->DetachChild(*pTempBadgeIcon);
1109 delete pTempBadgeIcon;
1110 pTempBadgeIcon = null;
1113 DetachChild(*pButtonItem);
1117 __pButtonItems[i] = null;
1125 _Toolbar::RemoveAllItems(void)
1129 int itemCount = __pItems.size();
1131 _Button* pItem = null;
1133 // frees item nodes from the memory
1136 for (int i = itemCount - 1; i >= 0; i--)
1138 pItem = __pItems.at(i);
1142 if (pItem->GetChildCount() != 0)
1144 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(pItem->GetChild(0));
1145 SysTryReturnResult(NID_UI_CTRL, pTempBadgeIcon, E_INVALID_STATE, "[E_INVALID_STATE] Couldn't get a badge icon.");
1147 pItem->DetachChild(*pTempBadgeIcon);
1149 delete pTempBadgeIcon;
1150 pTempBadgeIcon = null;
1153 DetachChild(*pItem);
1164 if (__pToolbarPresenter)
1166 __pToolbarPresenter->SetInitialDrawState(true);
1169 SetItemSelected(-1);
1175 _Toolbar::RemoveButtonAt(ToolbarButton position)
1177 if (__pButtonItems[position] != null)
1179 if (position == LEFT_BUTTON)
1181 StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT);
1183 else if (position == RIGHT_BUTTON)
1185 StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT);
1188 DetachChild(*__pButtonItems[position]);
1189 delete __pButtonItems[position];
1190 __pButtonItems[position] = null;
1197 _Toolbar::RemoveItemAt(int itemIndex)
1199 SysTryReturnResult(NID_UI_CTRL, (__itemCount > 0 && itemIndex < __itemCount && itemIndex >= 0), E_INVALID_ARG,
1200 "[E_INVALID_ARG] itemIndex is invalid.");
1202 _Button* pItem = __pItems.at(itemIndex);
1204 SysTryReturnResult(NID_UI_CTRL, (pItem != null), E_INVALID_STATE, "[E_INVALID_ARG] No item at the designated index.");
1206 if (pItem->GetChildCount() != 0)
1208 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(pItem->GetChild(0));
1209 SysTryReturnResult(NID_UI_CTRL, pTempBadgeIcon, E_INVALID_STATE, "[E_INVALID_STATE] Couldn't get a badge icon.");
1211 pItem->DetachChild(*pTempBadgeIcon);
1213 delete pTempBadgeIcon;
1214 pTempBadgeIcon = null;
1217 // Free 'pItem' from the item nodes
1218 DetachChild(*pItem);
1224 __pItems.erase(__pItems.begin() + itemIndex);
1230 _Toolbar::SetBackgroundBitmap(const Bitmap& bitmap)
1232 result r = E_SYSTEM;
1234 Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap);
1238 if (__pToolbarBackgroundBitmap)
1240 delete __pToolbarBackgroundBitmap;
1243 __pToolbarBackgroundBitmap = pClonedBitmap;
1244 __isUserBackgroundBitmap = true;
1253 _Toolbar::IsUserBackgroundBitmap() const
1255 return __isUserBackgroundBitmap;
1259 _Toolbar::SetButton(ToolbarButton position, _Button* pButton)
1261 SysTryReturnResult(NID_UI_CTRL, (pButton), E_INVALID_ARG, "[E_INVALID_ARG] The pButton is invalid.");
1263 int buttonWidth = pButton->GetSize().width;
1265 int toolbarWidth = GetBounds().width;
1267 if (CalculateMinimumToolbarWidth() > toolbarWidth)
1269 toolbarWidth = CalculateMinimumToolbarWidth();
1272 int horizontalMargin = 0;
1273 int verticalMargin = 0;
1275 if (__header == true && __style != TOOLBAR_TEXT)
1277 int buttonItemGap = 0;
1278 int buttonTopMargin = 0;
1280 if (__style == TOOLBAR_TITLE)
1282 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_TOP_MARGIN, GetOrientation(), buttonTopMargin);
1284 else if (__style == TOOLBAR_HEADER_SEGMENTED)
1286 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_TOP_MARGIN_OF_SEGMENTED, GetOrientation(), buttonTopMargin);
1289 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_GAP, GetOrientation(), buttonItemGap);
1295 if (__pButtonItems[LEFT_BUTTON])
1297 pButton->SetPosition(Point(toolbarWidth - buttonWidth , buttonTopMargin));
1298 __pButtonItems[LEFT_BUTTON]->SetPosition(Point(toolbarWidth - buttonWidth *2 - buttonItemGap, buttonTopMargin));
1302 pButton->SetPosition(Point(toolbarWidth - buttonWidth , buttonTopMargin));
1306 if (__pButtonItems[RIGHT_BUTTON])
1308 pButton->SetPosition(Point(toolbarWidth - buttonWidth * 2 - buttonItemGap, buttonTopMargin));
1312 pButton->SetPosition(Point(toolbarWidth - buttonWidth, buttonTopMargin));
1320 else // footer or HEADER_STYLE_BUTTON
1325 pButton->SetPosition(Point(horizontalMargin, verticalMargin));
1329 pButton->SetPosition(Point(toolbarWidth - buttonWidth - horizontalMargin, verticalMargin));
1333 pButton->SetPosition(Point(toolbarWidth - buttonWidth, 0));
1334 if (__pBackEventListener)
1336 pButton->AddActionEventListener(*__pBackEventListener);
1337 pButton->SetActionId(__backActionId);
1342 pButton->SetPosition(Point((toolbarWidth - buttonWidth - horizontalMargin)/2, verticalMargin));
1350 if (position != BACK_BUTTON && __pActionEventListener != null)
1352 pButton->AddActionEventListener(*__pActionEventListener);
1355 if (__pButtonItems[position])
1357 if (position == LEFT_BUTTON)
1359 StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT);
1361 else if (position == RIGHT_BUTTON)
1363 StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT);
1366 if (__pButtonItems[position]->GetChildCount() != 0)
1368 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pButtonItems[position]->GetChild(0));
1369 SysTryReturnResult(NID_UI_CTRL, pTempBadgeIcon, E_INVALID_STATE, "[E_INVALID_STATE] Couldn't get a badge icon.");
1371 __pButtonItems[position]->DetachChild(*pTempBadgeIcon);
1373 delete pTempBadgeIcon;
1374 pTempBadgeIcon = null;
1377 DetachChild(*__pButtonItems[position]);
1379 delete __pButtonItems[position];
1380 __pButtonItems[position] = null;
1383 __pButtonItems[position] = pButton;
1385 AttachChild(*pButton);
1387 if (__style != TOOLBAR_SOFTKEY)
1389 ApplyUserGUI(TOOLBAR_BUTTON, __pButtonItems[position]);
1398 _Toolbar::SetButtonColor(_ButtonStatus status, const Color& color)
1402 case _BUTTON_STATUS_NORMAL:
1403 __isButtonBgColorSetByUser[_BUTTON_STATUS_NORMAL] = true;
1404 return SetProperty("normalButtonColor", Variant(color));
1406 case _BUTTON_STATUS_DISABLED:
1407 __isButtonBgColorSetByUser[_BUTTON_STATUS_DISABLED] = true;
1408 return SetProperty("disabledButtonColor", Variant(color));
1410 case _BUTTON_STATUS_PRESSED:
1411 __isButtonBgColorSetByUser[_BUTTON_STATUS_PRESSED] = true;
1412 return SetProperty("pressedButtonColor", Variant(color));
1414 case _BUTTON_STATUS_HIGHLIGHTED:
1415 __isButtonBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED] = true;
1416 return SetProperty("highlightedButtonColor", Variant(color));
1419 __isButtonBgColorSetByUser[_BUTTON_STATUS_NORMAL] = true;
1420 return SetProperty("normalButtonColor", Variant(color));
1426 _Toolbar::SetButtonEnabled(ToolbarButton position, bool enabled)
1428 SysTryReturnResult(NID_UI_CTRL, __pButtonItems[position], E_INVALID_OPERATION,
1429 "[E_INVALID_OPERATION] No button item is at the position.");
1433 __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1437 __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_DISABLED);
1444 _Toolbar::SetButtonTextColor(_ButtonStatus status, const Color& color)
1448 case _BUTTON_STATUS_NORMAL:
1449 __isButtonTextColorSetByUser[_BUTTON_STATUS_NORMAL] = true;
1450 return SetProperty("normalButtonTextColor", Variant(color));
1452 case _BUTTON_STATUS_DISABLED:
1453 __isButtonTextColorSetByUser[_BUTTON_STATUS_DISABLED] = true;
1454 return SetProperty("disabledButtonTextColor", Variant(color));
1456 case _BUTTON_STATUS_PRESSED:
1457 __isButtonTextColorSetByUser[_BUTTON_STATUS_PRESSED] = true;
1458 return SetProperty("pressedButtonTextColor", Variant(color));
1460 case _BUTTON_STATUS_HIGHLIGHTED:
1461 __isButtonTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED] = true;
1462 return SetProperty("highlightedButtonTextColor", Variant(color));
1465 __isButtonTextColorSetByUser[_BUTTON_STATUS_NORMAL] = true;
1466 return SetProperty("normalButtonTextColor", Variant(color));
1472 _Toolbar::SetButtonBadgeIcon(ToolbarButton position, const Bitmap* pBadgeIcon)
1476 childCount = __pButtonItems[position]->GetChildCount();
1478 if (childCount != 0)
1480 for(int i = 0; i < childCount; i++)
1482 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pButtonItems[position]->GetChild(i));
1486 __pButtonItems[position]->DetachChild(*pTempBadgeIcon);
1488 delete pTempBadgeIcon;
1489 pTempBadgeIcon = null;
1494 if (pBadgeIcon == null)
1499 Rectangle bounds = __pButtonItems[position]->GetBounds();
1501 _Label* pBadgeIconLabel = _Label::CreateLabelN();
1503 if (pBadgeIconLabel)
1505 pBadgeIconLabel->SetBounds(Rectangle((bounds.width - pBadgeIcon->GetWidth()), 0,
1506 pBadgeIcon->GetWidth(), pBadgeIcon->GetHeight()));
1507 pBadgeIconLabel->SetBackgroundBitmap(*pBadgeIcon);
1509 __pButtonItems[position]->AttachChild(*pBadgeIconLabel);
1510 __pButtonItems[position]->SetChildAlwaysOnTop(*pBadgeIconLabel);
1517 _Toolbar::SetButtonNumberedBadgeIcon(ToolbarButton position, int number)
1521 childCount = __pButtonItems[position]->GetChildCount();
1523 _Label* existingBadgeIcon = null;
1527 if (childCount != 0)
1529 for(int i = 0; i < childCount; i++)
1531 existingBadgeIcon = dynamic_cast<_Label*>(__pButtonItems[position]->GetChild(i));
1533 if (existingBadgeIcon)
1535 __pButtonItems[position]->DetachChild(*existingBadgeIcon);
1537 delete existingBadgeIcon;
1538 existingBadgeIcon = null;
1549 bool needToCreateNewIcon = true;
1551 if (childCount != 0)
1553 for(int i = 0; i < childCount; i++)
1555 existingBadgeIcon = dynamic_cast<_Label*>(__pButtonItems[position]->GetChild(i));
1557 if (existingBadgeIcon)
1559 if (existingBadgeIcon->GetText() == L"")
1561 __pButtonItems[position]->DetachChild(*existingBadgeIcon);
1563 delete existingBadgeIcon;
1564 existingBadgeIcon = null;
1566 needToCreateNewIcon = true;
1570 needToCreateNewIcon = false;
1576 if (needToCreateNewIcon)
1578 _Label* pLabel = _Label::CreateLabelN();
1580 SysTryReturnResult(NID_UI_CTRL, pLabel, E_INVALID_STATE,
1581 "[E_INVALID_STATE] The badge icon instance isn't constructed.");
1583 Bitmap* pNumberedBadgeIconBitmap = null;
1584 Bitmap* pNumberedBadgeIconEffectBitmap = null;
1585 Bitmap* pColorReplacedBitmap = null;
1586 Color badgeIconBgColor;
1587 Color badgeIconTextColor;
1589 GET_BITMAP_CONFIG_N(HEADER::BADGE_ICON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNumberedBadgeIconBitmap);
1590 GET_BITMAP_CONFIG_N(HEADER::BADGE_ICON_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNumberedBadgeIconEffectBitmap);
1592 GET_COLOR_CONFIG(HEADER::BADGE_ICON_BG_NORMAL, badgeIconBgColor);
1593 GET_COLOR_CONFIG(HEADER::BADGE_ICON_TEXT_NORMAL, badgeIconTextColor);
1595 if (pNumberedBadgeIconBitmap)
1597 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNumberedBadgeIconBitmap,
1598 Color::GetColor(COLOR_ID_MAGENTA), badgeIconBgColor);
1600 pLabel->SetBackgroundBitmap(*pColorReplacedBitmap);
1602 delete pColorReplacedBitmap;
1603 delete pNumberedBadgeIconBitmap;
1606 if (pNumberedBadgeIconEffectBitmap)
1608 pLabel->SetBackgroundEffectBitmap(*pNumberedBadgeIconEffectBitmap);
1610 delete pNumberedBadgeIconEffectBitmap;
1613 pLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
1614 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1615 pLabel->SetTextColor(badgeIconTextColor);
1616 pLabel->SetMargin(0, 0);
1618 __pButtonItems[position]->AttachChild(*pLabel);
1619 __pButtonItems[position]->SetChildAlwaysOnTop(*pLabel);
1621 existingBadgeIcon = pLabel;
1624 SysTryReturnResult(NID_UI_CTRL, (existingBadgeIcon), E_INVALID_STATE, "[E_INVALID_STATE] Failed to set a BadgeIcon.");
1626 Rectangle bounds = __pButtonItems[position]->GetBounds();
1628 Integer tempNumber(number);
1630 if (existingBadgeIcon)
1632 existingBadgeIcon->SetText(tempNumber.ToString());
1638 GET_SHAPE_CONFIG(HEADER::BADGE_FONT_SIZE, GetOrientation(), fontSize);
1639 GET_SHAPE_CONFIG(HEADER::BADGE_HEIGHT, GetOrientation(), height);
1641 existingBadgeIcon->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1645 GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_1DIGIT, GetOrientation(), width);
1646 existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height));
1648 else if (number < 100)
1650 GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_2DIGIT, GetOrientation(), width);
1651 existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height));
1653 else if (number < 1000)
1655 GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_3DIGIT, GetOrientation(), width);
1656 existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height));
1658 else if (number < 10000)
1660 GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_4DIGIT, GetOrientation(), width);
1661 existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height));
1665 GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_5DIGIT, GetOrientation(), width);
1666 existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height));
1675 _Toolbar::SetColor(const Color& color)
1677 return SetProperty("color", Variant(color));
1681 _Toolbar::SetDescriptionText(const String& text)
1683 return SetProperty("descriptionText", Variant(text));
1687 _Toolbar::SetDescriptionTextColor(const Color& color)
1689 return SetProperty("descriptionTextColor", Variant(color));
1693 _Toolbar::SetItemAt(int itemIndex, const _Button* pButton)
1695 SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < __itemCount), E_OUT_OF_RANGE,
1696 "[E_OUT_OF_RANGE] The itemIndex is out of range.");
1698 if (pButton->GetActionId() < TOOLBAR_ACTION_ID_MIN || pButton->GetActionId() > TOOLBAR_ACTION_ID_MAX)
1700 SysLog(NID_UI_CTRL, "[E_INVALID_ARG] The actionId is invalid.");
1701 return E_OUT_OF_RANGE;
1704 SysTryReturnResult(NID_UI_CTRL, (null != __pItems.at(itemIndex)), E_INVALID_OPERATION,
1705 "[E_INVALID_OPERATION] No button item is at the position.");
1707 if (__pItems.at(itemIndex)->GetChildCount() != 0)
1709 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pItems.at(itemIndex)->GetChild(0));
1710 SysTryReturnResult(NID_UI_CTRL, pTempBadgeIcon, E_INVALID_STATE, "[E_INVALID_STATE] Couldn't get a badge icon.");
1712 __pItems.at(itemIndex)->DetachChild(*pTempBadgeIcon);
1714 delete pTempBadgeIcon;
1715 pTempBadgeIcon = null;
1718 __pItems.at(itemIndex)->SetText(pButton->GetText());
1719 __pItems.at(itemIndex)->SetActionId(pButton->GetActionId());
1721 Bitmap* pIconBitmap = null;
1722 Point iconPosition = Point(0,0);
1724 pIconBitmap = const_cast<Bitmap*>(pButton->GetBitmap(_BUTTON_STATUS_NORMAL));
1728 iconPosition = pButton->GetBitmapPosition(_BUTTON_STATUS_NORMAL);
1730 __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_NORMAL, iconPosition, *pIconBitmap);
1731 __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_PRESSED, iconPosition, *pIconBitmap);
1732 __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_SELECTED, iconPosition, *pIconBitmap);
1733 __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_HIGHLIGHTED, iconPosition, *pIconBitmap);
1734 __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_DISABLED, iconPosition, *pIconBitmap);
1737 pIconBitmap = const_cast<Bitmap*>(pButton->GetBitmap(_BUTTON_STATUS_PRESSED));
1741 iconPosition = pButton->GetBitmapPosition(_BUTTON_STATUS_PRESSED);
1743 __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_PRESSED, iconPosition, *pIconBitmap);
1746 pIconBitmap = const_cast<Bitmap*>(pButton->GetBitmap(_BUTTON_STATUS_SELECTED));
1750 iconPosition = pButton->GetBitmapPosition(_BUTTON_STATUS_SELECTED);
1752 __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_SELECTED, iconPosition, *pIconBitmap);
1755 pIconBitmap = const_cast<Bitmap*>(pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED));
1759 iconPosition = pButton->GetBitmapPosition(_BUTTON_STATUS_HIGHLIGHTED);
1761 __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_HIGHLIGHTED, iconPosition, *pIconBitmap);
1764 pIconBitmap = const_cast<Bitmap*>(pButton->GetBitmap(_BUTTON_STATUS_DISABLED));
1768 iconPosition = pButton->GetBitmapPosition(_BUTTON_STATUS_DISABLED);
1770 __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_DISABLED, iconPosition, *pIconBitmap);
1773 ApplyUserGUI(TOOLBAR_ITEM, __pItems.at(itemIndex));
1777 RealignIcon(__pItems.at(itemIndex));
1785 _Toolbar::SetItemBadgeIcon(int itemIndex, const Bitmap* pBadgeIcon)
1787 SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < __itemCount), E_INVALID_ARG,
1788 "[E_INVALID_ARG] The itemIndex is invalid.");
1790 SysTryReturnResult(NID_UI_CTRL, (__pItems.at(itemIndex)), E_INVALID_STATE,
1791 "[E_INVALID_STATE] The badge icon instance isn't constructed.");
1793 if (__pItems.at(itemIndex)->GetChildCount() != 0)
1795 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pItems.at(itemIndex)->GetChild(0));
1799 __pItems.at(itemIndex)->DetachChild(*pTempBadgeIcon);
1801 delete pTempBadgeIcon;
1802 pTempBadgeIcon = null;
1806 if (pBadgeIcon == null)
1811 Rectangle bounds = __pItems.at(itemIndex)->GetBounds();
1813 _Label* pBadgeIconLabel = _Label::CreateLabelN();
1815 if (pBadgeIconLabel)
1817 pBadgeIconLabel->SetBounds(Rectangle((bounds.width - pBadgeIcon->GetWidth()), 0,
1818 pBadgeIcon->GetWidth(), pBadgeIcon->GetHeight()));
1819 pBadgeIconLabel->SetBackgroundBitmap(*pBadgeIcon);
1821 __pItems.at(itemIndex)->AttachChild(*pBadgeIconLabel);
1822 __pItems.at(itemIndex)->SetChildAlwaysOnTop(*pBadgeIconLabel);
1829 _Toolbar::SetItemColor(_ButtonStatus status, const Color& color)
1833 case _BUTTON_STATUS_NORMAL:
1834 __isItemBgColorSetByUser[_BUTTON_STATUS_NORMAL] = true;
1835 return SetProperty("normalItemColor", Variant(color));
1837 case _BUTTON_STATUS_DISABLED:
1838 __isItemBgColorSetByUser[_BUTTON_STATUS_DISABLED] = true;
1839 return SetProperty("disabledItemColor", Variant(color));
1841 case _BUTTON_STATUS_PRESSED:
1842 __isItemBgColorSetByUser[_BUTTON_STATUS_PRESSED] = true;
1843 return SetProperty("pressedItemColor", Variant(color));
1845 case _BUTTON_STATUS_HIGHLIGHTED:
1846 __isItemBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED] = true;
1847 return SetProperty("highlightedItemColor", Variant(color));
1849 case _BUTTON_STATUS_SELECTED:
1850 __isItemBgColorSetByUser[_BUTTON_STATUS_SELECTED] = true;
1851 return SetProperty("selectedItemColor", Variant(color));
1854 __isItemBgColorSetByUser[_BUTTON_STATUS_NORMAL] = true;
1855 return SetProperty("normalItemColor", Variant(color));
1861 _Toolbar::SetItemEnabled(int itemIndex, bool enabled)
1863 SysTryReturnResult(NID_UI_CTRL, (null != __pItems.at(itemIndex)), E_INVALID_OPERATION,
1864 "[E_INVALID_OPERATION] No button item is at the position.");
1868 return __pItems.at(itemIndex)->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1872 return __pItems.at(itemIndex)->SetButtonStatus(_BUTTON_STATUS_DISABLED);
1879 _Toolbar::SetItemNumberedBadgeIcon(int itemIndex, int number)
1881 SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < __itemCount), E_INVALID_ARG,
1882 "[E_INVALID_ARG] The itemIndex is invalid.");
1884 SysTryReturnResult(NID_UI_CTRL, (number >= 0 && number < 100000), E_INVALID_ARG,
1885 "[E_INVALID_ARG] The number is out of bounds.");
1887 SysTryReturnResult(NID_UI_CTRL, (__pItems.at(itemIndex)), E_INVALID_STATE,
1888 "[E_INVALID_STATE] The badge icon instance isn't constructed.");
1892 if (__pItems.at(itemIndex)->GetChildCount() != 0)
1894 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(itemIndex)->GetChild(0));
1896 if (existingBadgeIcon)
1898 __pItems.at(itemIndex)->DetachChild(*existingBadgeIcon);
1900 delete existingBadgeIcon;
1901 existingBadgeIcon = null;
1911 if (__pItems.at(itemIndex)->GetChildCount() == 0)
1913 _Label* pLabel = _Label::CreateLabelN();
1915 SysTryReturnResult(NID_UI_CTRL, pLabel, E_INVALID_STATE,
1916 "[E_INVALID_STATE] The badge icon instance isn't constructed.");
1918 Bitmap* pNumberedBadgeIconBitmap = null;
1919 Bitmap* pNumberedBadgeIconEffectBitmap = null;
1920 Bitmap* pColorReplacedBitmap = null;
1921 Color badgeIconBgColor;
1922 Color badgeIconTextColor;
1924 GET_BITMAP_CONFIG_N(HEADER::BADGE_ICON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNumberedBadgeIconBitmap);
1925 GET_BITMAP_CONFIG_N(HEADER::BADGE_ICON_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNumberedBadgeIconEffectBitmap);
1927 GET_COLOR_CONFIG(HEADER::BADGE_ICON_BG_NORMAL, badgeIconBgColor);
1928 GET_COLOR_CONFIG(HEADER::BADGE_ICON_TEXT_NORMAL, badgeIconTextColor);
1930 if (pNumberedBadgeIconBitmap)
1932 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNumberedBadgeIconBitmap,
1933 Color::GetColor(COLOR_ID_MAGENTA), badgeIconBgColor);
1935 pLabel->SetBackgroundBitmap(*pColorReplacedBitmap);
1937 delete pColorReplacedBitmap;
1938 delete pNumberedBadgeIconBitmap;
1941 if (pNumberedBadgeIconEffectBitmap)
1943 pLabel->SetBackgroundEffectBitmap(*pNumberedBadgeIconEffectBitmap);
1945 delete pNumberedBadgeIconEffectBitmap;
1948 pLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
1949 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1950 pLabel->SetTextColor(badgeIconTextColor);
1951 pLabel->SetMargin(0, 0);
1953 __pItems.at(itemIndex)->AttachChild(*pLabel);
1954 __pItems.at(itemIndex)->SetChildAlwaysOnTop(*pLabel);
1957 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(itemIndex)->GetChild(0));
1959 Rectangle bounds = __pItems.at(itemIndex)->GetBounds();
1961 Integer tempNumber(number);
1963 if (existingBadgeIcon)
1965 existingBadgeIcon->SetText(tempNumber.ToString());
1971 GET_SHAPE_CONFIG(HEADER::BADGE_FONT_SIZE, GetOrientation(), fontSize);
1972 GET_SHAPE_CONFIG(HEADER::BADGE_HEIGHT, GetOrientation(), height);
1974 existingBadgeIcon->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1978 GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_1DIGIT, GetOrientation(), width);
1979 existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height));
1981 else if (number < 100)
1983 GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_2DIGIT, GetOrientation(), width);
1984 existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height));
1986 else if (number < 1000)
1988 GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_3DIGIT, GetOrientation(), width);
1989 existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height));
1991 else if (number < 10000)
1993 GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_4DIGIT, GetOrientation(), width);
1994 existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height));
1998 GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_5DIGIT, GetOrientation(), width);
1999 existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height));
2008 _Toolbar::SetItemSelected(int itemIndex, bool fire)
2010 SysTryReturnResult(NID_UI_CTRL, (itemIndex >= -1 && itemIndex < __itemCount), E_INVALID_STATE,
2011 "[E_INVALID_STATE] Failed to process SetItemSelected()");
2013 result r = E_SUCCESS;
2015 int currentSelectedItemIndex = 0;
2016 currentSelectedItemIndex = GetSelectedItemIndex();
2018 if (__pToolbarPresenter)
2020 r = __pToolbarPresenter->SetItemSelected(itemIndex);
2023 if (itemIndex != -1 && itemIndex == currentSelectedItemIndex && __pItems.at(itemIndex) != null)
2025 __pItems.at(itemIndex)->SetButtonStatus(_BUTTON_STATUS_SELECTED, fire);
2026 __pItems.at(itemIndex)->Draw();
2031 if (__itemCount == 0 || __itemCount > TAB_ITEM_MAX || itemIndex == -1)
2036 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_INVALID_STATE, "[E_INVALID_STATE] Failed to process SetItemSelected()");
2038 if (__pItems.at(itemIndex) != null)
2040 __pItems.at(itemIndex)->SetButtonStatus(_BUTTON_STATUS_SELECTED, fire);
2043 if (__itemCount == 0 || __itemCount > TAB_ITEM_MAX || itemIndex == -1)
2048 if (currentSelectedItemIndex != -1 && __pItems.at(currentSelectedItemIndex) != null)
2050 __pItems.at(currentSelectedItemIndex)->SetButtonStatus(_BUTTON_STATUS_NORMAL);
2051 __pItems.at(currentSelectedItemIndex)->Draw();
2054 if (__pItems.at(itemIndex) != null)
2056 __pItems.at(itemIndex)->Draw();
2063 _Toolbar::SetItemTextColor(_ButtonStatus status, const Color& color)
2067 case _BUTTON_STATUS_NORMAL:
2068 __isItemTextColorSetByUser[_BUTTON_STATUS_NORMAL] = true;
2069 return SetProperty("normalItemTextColor", Variant(color));
2071 case _BUTTON_STATUS_DISABLED:
2072 __isItemTextColorSetByUser[_BUTTON_STATUS_DISABLED] = true;
2073 return SetProperty("disabledItemTextColor", Variant(color));
2075 case _BUTTON_STATUS_PRESSED:
2076 __isItemTextColorSetByUser[_BUTTON_STATUS_PRESSED] = true;
2077 return SetProperty("pressedItemTextColor", Variant(color));
2079 case _BUTTON_STATUS_HIGHLIGHTED:
2080 __isItemTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED] = true;
2081 return SetProperty("highlightedItemTextColor", Variant(color));
2083 case _BUTTON_STATUS_SELECTED:
2084 __isItemTextColorSetByUser[_BUTTON_STATUS_SELECTED] = true;
2085 return SetProperty("selectedItemTextColor", Variant(color));
2088 __isItemTextColorSetByUser[_BUTTON_STATUS_NORMAL] = true;
2089 return SetProperty("normalItemTextColor", Variant(color));
2095 _Toolbar::SetStyle(ToolbarStyle style)
2099 if (__pToolbarPresenter)
2101 __pToolbarPresenter->SetInitialDrawState(true);
2104 if (__style == TOOLBAR_TAB || __style == TOOLBAR_TAB_WITH_TITLE)
2106 SetTabEditModeEnabled(true);
2109 AdjustToolbarBounds();
2115 __descriptionText = L"";
2117 if(__pTitleTextElement)
2119 __pTitleTextElement->SetLabel(L"");
2127 _Toolbar::AdjustToolbarBounds(void)
2134 if (__header == true)
2136 if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE)
2138 GET_SHAPE_CONFIG(HEADER::WIDTH, GetOrientation(), width);
2139 GET_SHAPE_CONFIG(HEADER::TITLE_TOTAL_HEIGHT_WITH_SEGMENTED_ITEM, GetOrientation(), height);
2140 SetSize(Dimension(width, height));
2144 GET_SHAPE_CONFIG(HEADER::WIDTH, GetOrientation(), width);
2145 GET_SHAPE_CONFIG(HEADER::HEIGHT, GetOrientation(), height);
2146 SetSize(Dimension(width, height));
2151 GET_SHAPE_CONFIG(FOOTER::WIDTH, GetOrientation(), width);
2153 if (__style == TOOLBAR_SOFTKEY)
2155 GET_SHAPE_CONFIG(FOOTER::SOFTKEY_HEIGHT, GetOrientation(), height);
2159 GET_SHAPE_CONFIG(FOOTER::HEIGHT, GetOrientation(), height);
2162 SetSize(Dimension(width, height));
2165 SetResizable(false);
2167 _Form* pParent = dynamic_cast<_Form*>(GetParent());
2169 if (pParent != null)
2171 pParent->AdjustClientBounds();
2173 if (__header == false)
2175 Rectangle bounds(0, pParent->GetBounds().height - height, width, height);
2177 pParent->SetFooterBounds(bounds);
2185 _Toolbar::SetTabEditModeEnabled(bool enable)
2187 if (__pToolbarPresenter)
2189 return __pToolbarPresenter->SetTabEditModeEnabled(enable);
2196 _Toolbar::SetTitleIcon(const Bitmap& bitmap)
2198 result r = E_SYSTEM;
2200 Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap);
2206 delete __pTitleIcon;
2209 __pTitleIcon = pClonedBitmap;
2218 _Toolbar::SetTitleText(const String& text, HorizontalAlignment alignment)
2221 __titleTextAlignment = alignment;
2225 if (__pToolbarPresenter)
2227 return __pToolbarPresenter->SetTitleText(__titleText, __titleTextAlignment);
2230 if(__pTitleTextElement)
2232 __pTitleTextElement->SetLabel(__titleText + L", " + __descriptionText);
2238 _Toolbar::SetTitleTextColor(const Color& color)
2240 __titleTextColor = color;
2246 _Toolbar::SetTransparent(bool transparent)
2248 if (__style == TOOLBAR_SOFTKEY)
2253 __transparent = transparent;
2257 __isUserBackgroundBitmap = true;
2260 Bitmap* pMagentaBackgroundBitmap = null;
2262 if (__pToolbarBackgroundBitmap)
2264 delete __pToolbarBackgroundBitmap;
2265 __pToolbarBackgroundBitmap = null;
2268 GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pMagentaBackgroundBitmap);
2274 GET_COLOR_CONFIG(HEADER::TRANSLUCENT_BG_NORMAL, tempColor);
2276 if (pMagentaBackgroundBitmap)
2278 __pToolbarBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*(pMagentaBackgroundBitmap),
2279 Color::GetColor(COLOR_ID_MAGENTA), tempColor);
2281 if (__pToolbarBackgroundBitmap)
2283 __pToolbarBackgroundBitmap->SetAlphaConstant(0x7F);
2287 SetTitleTextColor(__transTitleTextColor);
2288 SetDescriptionTextColor(__transDescriptionTextColor);
2290 for (int i = 0; i < __itemCount ; i ++)
2292 if (__pItems.at(i) != null)
2294 ApplyUserGUI(TOOLBAR_ITEM, __pItems.at(i));
2298 for (int i = 0; i < BUTTON_MAX; i++)
2300 if (__pButtonItems[i] != null)
2302 ApplyUserGUI(TOOLBAR_BUTTON, __pButtonItems[i]);
2306 else // not transparent
2308 __pToolbarBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*(pMagentaBackgroundBitmap),
2309 Color::GetColor(COLOR_ID_MAGENTA), GetColor());
2311 SetTitleTextColor(__titleTextColor);
2312 SetDescriptionTextColor(__descriptionTextColor);
2314 for (int i = 0; i < __itemCount ; i ++)
2316 if (__pItems.at(i) != null)
2318 ApplyUserGUI(TOOLBAR_ITEM, __pItems.at(i));
2322 for (int i = 0; i < BUTTON_MAX; i++)
2324 if (__pButtonItems[i] != null)
2326 ApplyUserGUI(TOOLBAR_BUTTON, __pButtonItems[i]);
2331 delete pMagentaBackgroundBitmap;
2337 _Toolbar::SetWaitingAnimationPosition(ToolbarAnimationPosition animationPos, int x, int y)
2339 if (__pAnimation[animationPos])
2341 __pAnimation[animationPos]->SetPosition(Point(x, y));
2348 _Toolbar::StopWaitingAnimation(ToolbarAnimationPosition animationPos)
2350 SysTryReturnResult(NID_UI_CTRL,
2351 (TOOLBAR_ANIMATION_POSITION_TITLE <= animationPos && animationPos < TOOLBAR_ANIMATION_POSITION_MAX), E_INVALID_ARG,
2352 "[E_INVALID_ARG] The animationPos is invalid.");
2353 SysTryReturnResult(NID_UI_CTRL, (__pAnimation[animationPos]), E_INVALID_STATE,
2354 "[E_INVALID_STATE] __pAnimation isn't constructed.");
2356 __pAnimation[animationPos]->Stop();
2358 if (animationPos == TOOLBAR_ANIMATION_POSITION_TITLE)
2360 DetachChild(*__pAnimation[animationPos]);
2362 else if (animationPos == TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT && __pButtonItems[LEFT_BUTTON] != null)
2364 __pButtonItems[LEFT_BUTTON]->DetachChild(*__pAnimation[animationPos]);
2366 else if (animationPos == TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT && __pButtonItems[RIGHT_BUTTON] != null)
2368 __pButtonItems[RIGHT_BUTTON]->DetachChild(*__pAnimation[animationPos]);
2371 delete __pAnimation[animationPos];
2372 __pAnimation[animationPos] = null;
2378 _Toolbar::OnAnimationStopped(const _Control& source)
2382 if (&source == __pAnimation[TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT])
2384 __pAnimation[TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT]->Play();
2386 else if (&source == __pAnimation[TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT])
2388 __pAnimation[TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT]->Play();
2390 else if (__pAnimation[TOOLBAR_ANIMATION_POSITION_TITLE])
2392 __pAnimation[TOOLBAR_ANIMATION_POSITION_TITLE]->Play();
2399 _Toolbar::OnAttachedToMainTree(void)
2401 InitializeAccessibilityElement();
2407 _Toolbar::InitializeAccessibilityElement(void)
2409 if(likely(!(_AccessibilityManager::IsActivated())))
2414 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
2415 _AccessibilityElement* pButtonElement = null;
2416 if(pContainer == null)
2423 priorty = ACCESSIBILITY_PRIORTY_TOP;
2427 priorty = ACCESSIBILITY_PRIORTY_BOTTOM;
2429 pContainer->SetPriority(priorty);
2431 ToolbarStyle style = GetStyle();
2432 if(style == TOOLBAR_TITLE || style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE)
2434 if (__pTitleTextElement == null)
2436 __pTitleTextElement = new (std::nothrow) _AccessibilityElement(true);
2437 SysTryReturnVoidResult(NID_UI_CTRL, __pTitleTextElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
2438 pContainer->AddElement(*__pTitleTextElement);
2441 __pTitleTextElement->SetBounds(__pToolbarPresenter->GetTitleTextBounds());
2442 if( __descriptionText.IsEmpty())
2444 __pTitleTextElement->SetLabel(__titleText);
2448 __pTitleTextElement->SetLabel(__titleText + L"," + __descriptionText);
2450 __pTitleTextElement->SetTrait(L"Title");
2451 __pTitleTextElement->SetName(L"HeaderTitleText");
2455 if(__pTitleTextElement)
2457 pContainer->RemoveElement(*__pTitleTextElement);
2458 __pTitleTextElement = null;
2462 if (__pButtonItems[LEFT_BUTTON])
2464 _AccessibilityContainer* pButtonContainer = __pButtonItems[LEFT_BUTTON]->GetAccessibilityContainer();
2466 if (pButtonContainer)
2468 pButtonContainer->SetPriority(priorty);
2469 pContainer->AddChildContainer(*pButtonContainer);
2470 pButtonElement = pButtonContainer->GetChildElement(L"ButtonText");
2475 pButtonElement->SetName(L"LeftButton");
2476 pButtonElement->SetTrait(L"Button");
2477 pButtonElement = null;
2481 if (__pButtonItems[RIGHT_BUTTON])
2483 _AccessibilityContainer* pButtonContainer = __pButtonItems[RIGHT_BUTTON]->GetAccessibilityContainer();
2485 if (pButtonContainer)
2487 pButtonContainer->SetPriority(priorty);
2488 pContainer->AddChildContainer(*pButtonContainer);
2489 pButtonElement = pButtonContainer->GetChildElement(L"ButtonText");
2494 pButtonElement->SetName(L"RightButton");
2495 pButtonElement->SetTrait(L"Button");
2496 pButtonElement = null;
2500 if (__pButtonItems[BACK_BUTTON])
2502 _AccessibilityContainer* pButtonContainer = __pButtonItems[BACK_BUTTON]->GetAccessibilityContainer();
2504 if (pButtonContainer)
2506 pButtonContainer->SetPriority(priorty);
2507 pContainer->AddChildContainer(*pButtonContainer);
2508 pButtonElement = pButtonContainer->GetChildElement(L"ButtonText");
2513 pButtonElement->SetName(L"BackButton");
2514 pButtonElement->SetLabel(L"Back");
2515 pButtonElement->SetTrait(L"Back button");
2516 pButtonElement = null;
2520 if (__pButtonItems[MIDDLE_BUTTON])
2522 _AccessibilityContainer* pButtonContainer = __pButtonItems[MIDDLE_BUTTON]->GetAccessibilityContainer();
2524 if (pButtonContainer)
2526 pButtonContainer->SetPriority(priorty);
2527 pContainer->AddChildContainer(*pButtonContainer);
2528 pButtonElement = pButtonContainer->GetChildElement(L"ButtonText");
2533 pButtonElement->SetName(L"MiddleButton");
2534 pButtonElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON);
2535 pButtonElement = null;
2543 _Toolbar::AddAccessibilityItem(_Button* pButton)
2545 if(likely(!(_AccessibilityManager::IsActivated())))
2550 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
2551 if(pContainer == null)
2559 priorty = ACCESSIBILITY_PRIORTY_TOP;
2563 priorty = ACCESSIBILITY_PRIORTY_BOTTOM;
2565 pContainer->SetPriority(priorty);
2567 ToolbarStyle style = GetStyle();
2568 AccessibilityTraits trait = ACCESSIBILITY_TRAITS_BUTTON;
2569 String name = L"Button" + Integer::ToString(__itemCount);
2573 case TOOLBAR_HEADER_SEGMENTED_WITH_TITLE:
2575 case TOOLBAR_SEGMENTED:
2576 name = L"Segment" + Integer::ToString(__itemCount);
2577 trait = ACCESSIBILITY_TRAITS_SEGMENT;
2580 name = L"Tab" + Integer::ToString(__itemCount);
2581 trait = ACCESSIBILITY_TRAITS_TAB;
2587 if (pButton != null)
2589 _AccessibilityElement* pElement = null;
2590 _AccessibilityContainer* pButtonContainer = pButton->GetAccessibilityContainer();
2592 if (pButtonContainer)
2594 pButtonContainer->SetPriority(priorty);
2595 pContainer->AddChildContainer(*pButtonContainer);
2596 pElement = pButtonContainer->GetChildElement(L"ButtonText");
2601 pElement->SetName(name);
2602 pElement->SetTrait(trait);
2603 pElement->SetHint(L"Double tap to move to contents");
2611 _Toolbar::OnBoundsChanged(void)
2613 if(__pTitleTextElement)
2615 __pTitleTextElement->SetBounds(__pToolbarPresenter->GetTitleTextBounds());
2624 _Toolbar::OnFontChanged(Font* pFont)
2626 __pToolbarPresenter->OnFontChanged(pFont);
2632 _Toolbar::OnFontInfoRequested(unsigned long& style, int& size)
2634 __pToolbarPresenter->OnFontInfoRequested(style, size);
2640 _Toolbar::OnChangeLayout(_ControlOrientation orientationStatus)
2642 int toolbarWidth = GetBounds().width;
2644 if (CalculateMinimumToolbarWidth() > toolbarWidth)
2646 toolbarWidth = CalculateMinimumToolbarWidth();
2649 AdjustToolbarBounds();
2657 _Toolbar::OnDraw(void)
2661 if (__pToolbarPresenter)
2663 __pToolbarPresenter->Draw();
2665 InitializeAccessibilityElement();
2672 _Toolbar::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture)
2674 //if (__tabExpanded != true)
2679 //if (__pToolbarPresenter)
2681 // return __pToolbarPresenter->OnLongPressGestureDetected();
2688 _Toolbar::OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture)
2694 _Toolbar::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
2698 if (__pToolbarPresenter)
2700 return __pToolbarPresenter->OnTouchPressed(source, touchinfo);
2707 _Toolbar::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
2711 if (__pToolbarPresenter)
2713 return __pToolbarPresenter->OnTouchReleased(source, touchinfo);
2720 _Toolbar::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
2724 if (__pToolbarPresenter)
2726 return __pToolbarPresenter->OnTouchMoved(source, touchinfo);
2733 _Toolbar::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
2737 if (__pToolbarPresenter)
2739 return __pToolbarPresenter->OnTouchCanceled(source, touchinfo);
2746 _Toolbar::AddActionEventListener(const Controls::_IActionEventListener& listener)
2748 __pActionEventListener = const_cast<Controls::_IActionEventListener*>(&listener);
2750 for (int i = 0; i < __itemCount; i++)
2752 __pItems.at(i)->AddActionEventListener(listener);
2755 for (int j = 0; j < BUTTON_MAX; j++)
2757 if (__pButtonItems[j])
2759 __pButtonItems[j]->AddActionEventListener(listener);
2767 _Toolbar::RemoveActionEventListener(const Controls::_IActionEventListener& listener)
2769 __pActionEventListener = null;
2771 for (int i = 0; i < __itemCount; i++)
2773 __pItems.at(i)->RemoveActionEventListener(listener);
2776 for (int j = 0; j < MIDDLE_BUTTON; j++)
2778 if (__pButtonItems[j])
2780 __pButtonItems[j]->RemoveActionEventListener(listener);
2789 _Toolbar::SetBackEventListener(const Controls::_IActionEventListener& listener, int actionId)
2791 __backActionId = actionId;
2792 __pBackEventListener = const_cast<_IActionEventListener*>(&listener);
2798 _Toolbar::SetPresenter(const _ToolbarPresenter& toolbarPresenter)
2800 __pToolbarPresenter = const_cast<_ToolbarPresenter*>(&toolbarPresenter);
2806 _Toolbar::ApplyUserGUI(ButtonType buttonType, _Button* pButton)
2808 SysTryReturnResult(NID_UI_CTRL, pButton, E_INVALID_ARG, "[E_INVALID_ARG] The pButton is invalid.");
2810 if (TOOLBAR_BUTTON == buttonType)
2812 Bitmap* pNormalBackgroundBitmap = null;
2813 Bitmap* pColorReplacedBitmap = null;
2817 GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundBitmap);
2821 GET_BITMAP_CONFIG_N(FOOTER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundBitmap);
2826 pButton->SetTextColor(_BUTTON_STATUS_NORMAL, __buttonTransTextColor[_BUTTON_STATUS_NORMAL]);
2827 pButton->SetTextColor(_BUTTON_STATUS_PRESSED, __buttonTransTextColor[_BUTTON_STATUS_PRESSED]);
2828 pButton->SetTextColor(_BUTTON_STATUS_HIGHLIGHTED, __buttonTransTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
2829 pButton->SetTextColor(_BUTTON_STATUS_DISABLED, __buttonTransTextColor[_BUTTON_STATUS_DISABLED]);
2831 if (pNormalBackgroundBitmap)
2833 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap,
2834 Color::GetColor(COLOR_ID_MAGENTA), __buttonTransBackgroundColor[_BUTTON_STATUS_NORMAL]);
2835 pButton->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *pColorReplacedBitmap);
2836 delete pColorReplacedBitmap;
2838 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap,
2839 Color::GetColor(COLOR_ID_MAGENTA), __buttonTransBackgroundColor[_BUTTON_STATUS_PRESSED]);
2840 pButton->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *pColorReplacedBitmap);
2841 delete pColorReplacedBitmap;
2843 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap,
2844 Color::GetColor(COLOR_ID_MAGENTA), __buttonTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
2845 pButton->SetBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pColorReplacedBitmap);
2846 delete pColorReplacedBitmap;
2848 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap,
2849 Color::GetColor(COLOR_ID_MAGENTA), __buttonTransBackgroundColor[_BUTTON_STATUS_DISABLED]);
2850 pButton->SetBackgroundBitmap(_BUTTON_STATUS_DISABLED, *pColorReplacedBitmap);
2851 delete pColorReplacedBitmap;
2853 delete pNormalBackgroundBitmap;
2858 pButton->SetTextColor(_BUTTON_STATUS_NORMAL, __buttonTextColor[_BUTTON_STATUS_NORMAL]);
2859 pButton->SetTextColor(_BUTTON_STATUS_PRESSED, __buttonTextColor[_BUTTON_STATUS_PRESSED]);
2860 pButton->SetTextColor(_BUTTON_STATUS_HIGHLIGHTED, __buttonTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
2861 pButton->SetTextColor(_BUTTON_STATUS_DISABLED, __buttonTextColor[_BUTTON_STATUS_DISABLED]);
2863 if (pNormalBackgroundBitmap)
2865 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap,
2866 Color::GetColor(COLOR_ID_MAGENTA), __buttonBackgroundColor[_BUTTON_STATUS_NORMAL]);
2867 pButton->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *pColorReplacedBitmap);
2868 delete pColorReplacedBitmap;
2870 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap,
2871 Color::GetColor(COLOR_ID_MAGENTA), __buttonBackgroundColor[_BUTTON_STATUS_PRESSED]);
2872 pButton->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *pColorReplacedBitmap);
2873 delete pColorReplacedBitmap;
2875 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap,
2876 Color::GetColor(COLOR_ID_MAGENTA), __buttonBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
2877 pButton->SetBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pColorReplacedBitmap);
2878 delete pColorReplacedBitmap;
2880 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap,
2881 Color::GetColor(COLOR_ID_MAGENTA), __buttonBackgroundColor[_BUTTON_STATUS_DISABLED]);
2882 pButton->SetBackgroundBitmap(_BUTTON_STATUS_DISABLED, *pColorReplacedBitmap);
2883 delete pColorReplacedBitmap;
2885 delete pNormalBackgroundBitmap;
2889 else if (TOOLBAR_ITEM == buttonType)
2891 Bitmap* pNormalBackgroundBitmap = null;
2892 Bitmap* pPressedBackgroundBitmap = null;
2893 Bitmap* pNormalBackgroundEffectBitmap = null;
2894 Bitmap* pPressedBackgroundEffectBitmap = null;
2895 Bitmap* pColorReplacedBitmap = null;
2897 if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
2899 GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundBitmap);
2900 GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedBackgroundBitmap);
2901 GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundEffectBitmap);
2902 GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedBackgroundEffectBitmap);
2906 GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundBitmap);
2907 GET_BITMAP_CONFIG_N(HEADER::TAB_ITEM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedBackgroundBitmap);
2910 if (pNormalBackgroundEffectBitmap)
2912 pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_NORMAL, *pNormalBackgroundEffectBitmap);
2913 pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pNormalBackgroundEffectBitmap);
2914 pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_DISABLED, *pNormalBackgroundEffectBitmap);
2915 delete pNormalBackgroundEffectBitmap;
2918 if (pPressedBackgroundEffectBitmap)
2920 pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_PRESSED, *pPressedBackgroundEffectBitmap);
2921 pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_SELECTED, *pPressedBackgroundEffectBitmap);
2922 delete pPressedBackgroundEffectBitmap;
2927 pButton->SetTextColor(_BUTTON_STATUS_NORMAL, __itemTransTextColor[_BUTTON_STATUS_NORMAL]);
2928 pButton->SetTextColor(_BUTTON_STATUS_PRESSED, __itemTransTextColor[_BUTTON_STATUS_PRESSED]);
2929 pButton->SetTextColor(_BUTTON_STATUS_HIGHLIGHTED, __itemTransTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
2930 pButton->SetTextColor(_BUTTON_STATUS_DISABLED, __itemTransTextColor[_BUTTON_STATUS_DISABLED]);
2931 pButton->SetTextColor(_BUTTON_STATUS_SELECTED, __itemTransTextColor[_BUTTON_STATUS_SELECTED]);
2933 if (pNormalBackgroundBitmap)
2935 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap,
2936 Color::GetColor(COLOR_ID_MAGENTA), __itemTransBackgroundColor[_BUTTON_STATUS_NORMAL]);
2937 pButton->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *pColorReplacedBitmap);
2938 delete pColorReplacedBitmap;
2940 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap,
2941 Color::GetColor(COLOR_ID_MAGENTA), __itemTransBackgroundColor[_BUTTON_STATUS_SELECTED]);
2942 pButton->SetBackgroundBitmap(_BUTTON_STATUS_SELECTED, *pColorReplacedBitmap);
2943 delete pColorReplacedBitmap;
2945 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap,
2946 Color::GetColor(COLOR_ID_MAGENTA), __itemTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
2947 pButton->SetBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pColorReplacedBitmap);
2948 delete pColorReplacedBitmap;
2950 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap,
2951 Color::GetColor(COLOR_ID_MAGENTA), __itemTransBackgroundColor[_BUTTON_STATUS_DISABLED]);
2952 pButton->SetBackgroundBitmap(_BUTTON_STATUS_DISABLED, *pColorReplacedBitmap);
2953 delete pColorReplacedBitmap;
2955 delete pNormalBackgroundBitmap;
2958 if (pPressedBackgroundBitmap)
2960 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pPressedBackgroundBitmap,
2961 Color::GetColor(COLOR_ID_MAGENTA), __itemTransBackgroundColor[_BUTTON_STATUS_PRESSED]);
2963 pButton->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *pColorReplacedBitmap);
2964 delete pColorReplacedBitmap;
2966 delete pPressedBackgroundBitmap;
2971 pButton->SetTextColor(_BUTTON_STATUS_NORMAL, __itemTextColor[_BUTTON_STATUS_NORMAL]);
2972 pButton->SetTextColor(_BUTTON_STATUS_PRESSED, __itemTextColor[_BUTTON_STATUS_PRESSED]);
2973 pButton->SetTextColor(_BUTTON_STATUS_HIGHLIGHTED, __itemTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
2974 pButton->SetTextColor(_BUTTON_STATUS_DISABLED, __itemTextColor[_BUTTON_STATUS_DISABLED]);
2975 pButton->SetTextColor(_BUTTON_STATUS_SELECTED, __itemTextColor[_BUTTON_STATUS_SELECTED]);
2977 if (pNormalBackgroundBitmap)
2979 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap,
2980 Color::GetColor(COLOR_ID_MAGENTA), __itemBackgroundColor[_BUTTON_STATUS_NORMAL]);
2981 pButton->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *pColorReplacedBitmap);
2982 delete pColorReplacedBitmap;
2984 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap,
2985 Color::GetColor(COLOR_ID_MAGENTA), __itemBackgroundColor[_BUTTON_STATUS_SELECTED]);
2986 pButton->SetBackgroundBitmap(_BUTTON_STATUS_SELECTED, *pColorReplacedBitmap);
2987 delete pColorReplacedBitmap;
2989 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap,
2990 Color::GetColor(COLOR_ID_MAGENTA), __itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
2991 pButton->SetBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pColorReplacedBitmap);
2992 delete pColorReplacedBitmap;
2994 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap,
2995 Color::GetColor(COLOR_ID_MAGENTA), __itemBackgroundColor[_BUTTON_STATUS_DISABLED]);
2996 pButton->SetBackgroundBitmap(_BUTTON_STATUS_DISABLED, *pColorReplacedBitmap);
2997 delete pColorReplacedBitmap;
2999 delete pNormalBackgroundBitmap;
3002 if (pPressedBackgroundBitmap)
3004 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pPressedBackgroundBitmap,
3005 Color::GetColor(COLOR_ID_MAGENTA), __itemBackgroundColor[_BUTTON_STATUS_PRESSED]);
3007 pButton->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *pColorReplacedBitmap);
3008 delete pColorReplacedBitmap;
3010 delete pPressedBackgroundBitmap;
3019 _Toolbar::CalculateMinimumToolbarWidth(void)
3022 int itemMinimumWidth = 0;
3023 int horizontalMargin = 0;
3025 if (__header == true && __style == TOOLBAR_TEXT)
3027 if (IsButtonSet(LEFT_BUTTON))
3029 //if (__pButtonItems[LEFT_BUTTON]->GetText().IsEmpty())
3031 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_WIDTH, GetOrientation(), itemMinimumWidth);
3035 // GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_WIDTH_WITH_TEXT, GetOrientation(), itemMinimumWidth);
3038 totalWidth += itemMinimumWidth;
3040 if (IsButtonSet(RIGHT_BUTTON))
3042 //if (__pButtonItems[RIGHT_BUTTON]->GetText().IsEmpty())
3044 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_WIDTH, GetOrientation(), itemMinimumWidth);
3048 // GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_WIDTH_WITH_TEXT, GetOrientation(), itemMinimumWidth);
3051 totalWidth += itemMinimumWidth;
3054 else // footer or HEADER_TITLE_BUTTON
3056 if (IsButtonSet(LEFT_BUTTON))
3058 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_WIDTH, GetOrientation(), itemMinimumWidth);
3059 totalWidth += itemMinimumWidth;
3061 if (IsButtonSet(RIGHT_BUTTON))
3063 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_WIDTH, GetOrientation(), itemMinimumWidth);
3064 totalWidth += itemMinimumWidth;
3066 else if (IsButtonSet(BACK_BUTTON))
3068 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_WIDTH, GetOrientation(), itemMinimumWidth);
3069 totalWidth += itemMinimumWidth;
3073 if (__style == TOOLBAR_TITLE)
3075 GET_SHAPE_CONFIG(HEADER::TITLE_MINIMUM_WIDTH, GetOrientation(), itemMinimumWidth);
3076 totalWidth += itemMinimumWidth;
3078 else if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_HEADER_SEGMENTED)
3080 GET_SHAPE_CONFIG(HEADER::ITEM_MINIMUM_WIDTH, GetOrientation(), itemMinimumWidth);
3081 GET_SHAPE_CONFIG(HEADER::COMMON_MINIMUM_MARGIN, GetOrientation(), horizontalMargin);
3082 totalWidth += itemMinimumWidth * __itemCount + horizontalMargin * 2;
3084 else if (__style == TOOLBAR_SEGMENTED)
3086 GET_SHAPE_CONFIG(FOOTER::ITEM_MINIMUM_WIDTH, GetOrientation(), itemMinimumWidth);
3087 GET_SHAPE_CONFIG(FOOTER::COMMON_MINIMUM_MARGIN, GetOrientation(), horizontalMargin);
3088 totalWidth += itemMinimumWidth * __itemCount + horizontalMargin * 2;
3092 GET_SHAPE_CONFIG(FOOTER::ITEM_MINIMUM_WIDTH, GetOrientation(), itemMinimumWidth);
3094 if ((__style == TOOLBAR_TAB || __style == TOOLBAR_TAB_WITH_TITLE) && __itemCount > 4)
3096 totalWidth += itemMinimumWidth * 4;
3100 totalWidth += itemMinimumWidth * __itemCount;
3108 _Toolbar::RealignIcon(_Button* pButton)
3110 SysTryReturnResult(NID_UI_CTRL, pButton, E_INVALID_STATE, "[E_INVALID_STATE] pButton doesn't exist.");
3112 int buttonItemWidth = pButton->GetSize().width;
3113 int buttonItemHeight = pButton->GetSize().height;
3115 int buttonTextTopMargin = 0;
3116 int iconTextGap = 0;
3117 int contentLength = 0;
3118 int textExtentSize = pButton->GetTextExtentSize();
3119 int segmentedTextAreaHeight = 0;
3120 int revisedTopMargin = 5;
3122 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_LEFT_MARGIN, GetOrientation(), sideMargin);
3123 GET_SHAPE_CONFIG(HEADER::ICON_TEXT_GAP, GetOrientation(), iconTextGap);
3124 GET_SHAPE_CONFIG(HEADER::SEGMENTED_ITEM_HEIGHT, GetOrientation(), segmentedTextAreaHeight);
3126 if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
3128 GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_BUTTON_STYLE_SIDE_MARGIN, GetOrientation(), sideMargin);
3129 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_TOP_MARGIN, GetOrientation(), buttonTextTopMargin);
3131 else if (__style == TOOLBAR_HEADER_SEGMENTED || __style == TOOLBAR_SEGMENTED || __style == TOOLBAR_TAB)
3133 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_LEFT_MARGIN, GetOrientation(), sideMargin);
3135 buttonTextTopMargin = (buttonItemHeight - segmentedTextAreaHeight) / 2 - revisedTopMargin;
3137 else if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE)
3139 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_LEFT_MARGIN, GetOrientation(), sideMargin);
3141 buttonTextTopMargin = 0;
3144 if (pButton->GetText() != L"")
3146 int iconAreaWidth = 0;
3148 if (pButton->GetBitmap(_BUTTON_STATUS_NORMAL) != null)
3150 iconAreaWidth = pButton->GetBitmap(_BUTTON_STATUS_NORMAL)->GetWidth();
3151 contentLength = iconAreaWidth + iconTextGap + textExtentSize;
3153 if (contentLength > buttonItemWidth - sideMargin * 2)
3155 contentLength = buttonItemWidth - sideMargin * 2;
3158 pButton->SetBitmap(_BUTTON_STATUS_NORMAL,
3159 Point((buttonItemWidth - contentLength) / 2, (buttonItemHeight - (pButton->GetBitmap(_BUTTON_STATUS_NORMAL))->GetHeight()) / 2),
3160 *(pButton->GetBitmap(_BUTTON_STATUS_NORMAL)));
3162 if (pButton->GetBitmap(_BUTTON_STATUS_PRESSED) != null)
3164 iconAreaWidth = pButton->GetBitmap(_BUTTON_STATUS_PRESSED)->GetWidth();
3165 contentLength = iconAreaWidth + iconTextGap + textExtentSize;
3167 if (contentLength > buttonItemWidth - sideMargin * 2)
3169 contentLength = buttonItemWidth - sideMargin * 2;
3172 pButton->SetBitmap(_BUTTON_STATUS_PRESSED,
3173 Point((buttonItemWidth - contentLength) / 2, (buttonItemHeight - (pButton->GetBitmap(_BUTTON_STATUS_PRESSED))->GetHeight()) / 2),
3174 *(pButton->GetBitmap(_BUTTON_STATUS_PRESSED)));
3176 if (pButton->GetBitmap(_BUTTON_STATUS_SELECTED) != null)
3178 iconAreaWidth = pButton->GetBitmap(_BUTTON_STATUS_SELECTED)->GetWidth();
3179 contentLength = iconAreaWidth + iconTextGap + textExtentSize;
3181 if (contentLength > buttonItemWidth - sideMargin * 2)
3183 contentLength = buttonItemWidth - sideMargin * 2;
3186 pButton->SetBitmap(_BUTTON_STATUS_SELECTED,
3187 Point((buttonItemWidth - contentLength) / 2, (buttonItemHeight - (pButton->GetBitmap(_BUTTON_STATUS_SELECTED))->GetHeight()) / 2),
3188 *(pButton->GetBitmap(_BUTTON_STATUS_SELECTED)));
3190 if (pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED) != null)
3192 iconAreaWidth = pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED)->GetWidth();
3193 contentLength = iconAreaWidth + iconTextGap + textExtentSize;
3195 if (contentLength > buttonItemWidth - sideMargin * 2)
3197 contentLength = buttonItemWidth - sideMargin * 2;
3200 pButton->SetBitmap(_BUTTON_STATUS_HIGHLIGHTED,
3201 Point((buttonItemWidth - contentLength) / 2, (buttonItemHeight - (pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED))->GetHeight()) / 2),
3202 *(pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED)));
3204 if (pButton->GetBitmap(_BUTTON_STATUS_DISABLED) != null)
3206 iconAreaWidth = pButton->GetBitmap(_BUTTON_STATUS_DISABLED)->GetWidth();
3207 contentLength = iconAreaWidth + iconTextGap + textExtentSize;
3209 if (contentLength > buttonItemWidth - sideMargin * 2)
3211 contentLength = buttonItemWidth - sideMargin * 2;
3214 pButton->SetBitmap(_BUTTON_STATUS_DISABLED,
3215 Point((buttonItemWidth - contentLength) / 2, (buttonItemHeight - (pButton->GetBitmap(_BUTTON_STATUS_DISABLED))->GetHeight()) / 2),
3216 *(pButton->GetBitmap(_BUTTON_STATUS_DISABLED)));
3219 if (iconAreaWidth != 0)
3221 pButton->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
3222 pButton->SetUserDefinedTextArea(Rectangle((buttonItemWidth - contentLength) / 2 + iconAreaWidth + iconTextGap, buttonTextTopMargin, buttonItemWidth - iconAreaWidth - iconTextGap - sideMargin * 2, buttonItemHeight - buttonTextTopMargin * 2));
3226 pButton->SetUserDefinedTextArea(Rectangle(sideMargin, buttonTextTopMargin, buttonItemWidth - sideMargin * 2, buttonItemHeight - buttonTextTopMargin * 2));
3231 if (pButton->GetBitmap(_BUTTON_STATUS_NORMAL) != null)
3233 pButton->SetBitmap(_BUTTON_STATUS_NORMAL,
3234 Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_NORMAL))->GetWidth()) / 2,
3235 (buttonItemHeight - (pButton->GetBitmap(_BUTTON_STATUS_NORMAL))->GetHeight()) / 2),
3236 *(pButton->GetBitmap(_BUTTON_STATUS_NORMAL)));
3238 if (pButton->GetBitmap(_BUTTON_STATUS_PRESSED) != null)
3240 pButton->SetBitmap(_BUTTON_STATUS_PRESSED,
3241 Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_PRESSED))->GetWidth()) / 2,
3242 (buttonItemHeight - (pButton->GetBitmap(_BUTTON_STATUS_PRESSED))->GetHeight()) / 2),
3243 *(pButton->GetBitmap(_BUTTON_STATUS_PRESSED)));
3245 if (pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED) != null)
3247 pButton->SetBitmap(_BUTTON_STATUS_HIGHLIGHTED,
3248 Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED))->GetWidth()) / 2,
3249 (buttonItemHeight - (pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED))->GetHeight()) / 2),
3250 *(pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED)));
3252 if (pButton->GetBitmap(_BUTTON_STATUS_DISABLED) != null)
3254 pButton->SetBitmap(_BUTTON_STATUS_DISABLED,
3255 Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_DISABLED))->GetWidth()) / 2,
3256 (buttonItemHeight - (pButton->GetBitmap(_BUTTON_STATUS_DISABLED))->GetHeight()) / 2),
3257 *(pButton->GetBitmap(_BUTTON_STATUS_DISABLED)));
3259 if (pButton->GetBitmap(_BUTTON_STATUS_SELECTED) != null)
3261 pButton->SetBitmap(_BUTTON_STATUS_SELECTED,
3262 Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_SELECTED))->GetWidth()) / 2,
3263 (buttonItemHeight - (pButton->GetBitmap(_BUTTON_STATUS_SELECTED))->GetHeight()) / 2),
3264 *(pButton->GetBitmap(_BUTTON_STATUS_SELECTED)));
3267 pButton->SetMargin(buttonTextTopMargin, sideMargin);
3274 _Toolbar::RealignButtonIcon(_Button* pButton)
3276 SysTryReturnResult(NID_UI_CTRL, pButton, E_INVALID_STATE, "[E_INVALID_STATE] pButton doesn't exist.");
3278 int buttonItemWidth = pButton->GetSize().width;
3279 int iconTopMargin = 0;
3280 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_ICON_TOP_MARGIN, GetOrientation(), iconTopMargin);
3282 if (pButton->GetBitmap(_BUTTON_STATUS_NORMAL) != null)
3284 pButton->SetBitmap(_BUTTON_STATUS_NORMAL,
3285 Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_NORMAL))->GetWidth()) / 2, iconTopMargin), *(pButton->GetBitmap(_BUTTON_STATUS_NORMAL)));
3287 if (pButton->GetBitmap(_BUTTON_STATUS_PRESSED) != null)
3289 pButton->SetBitmap(_BUTTON_STATUS_PRESSED,
3290 Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_PRESSED))->GetWidth()) / 2, iconTopMargin), *(pButton->GetBitmap(_BUTTON_STATUS_PRESSED)));
3292 if (pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED) != null)
3294 pButton->SetBitmap(_BUTTON_STATUS_HIGHLIGHTED,
3295 Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED))->GetWidth()) / 2, iconTopMargin), *(pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED)));
3297 if (pButton->GetBitmap(_BUTTON_STATUS_DISABLED) != null)
3299 pButton->SetBitmap(_BUTTON_STATUS_DISABLED,
3300 Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_DISABLED))->GetWidth()) / 2, iconTopMargin), *(pButton->GetBitmap(_BUTTON_STATUS_DISABLED)));
3302 if (pButton->GetBitmap(_BUTTON_STATUS_SELECTED) != null)
3304 pButton->SetBitmap(_BUTTON_STATUS_SELECTED,
3305 Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_SELECTED))->GetWidth()) / 2, iconTopMargin), *(pButton->GetBitmap(_BUTTON_STATUS_SELECTED)));
3312 _Toolbar::RearrangeItems(void)
3314 __titleTextArea = _Control::GetBounds();
3316 const Dimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSize();
3317 const Dimension landscapeSize = Dimension(portraitSize.height, portraitSize.width);
3319 if (CalculateMinimumToolbarWidth() > __titleTextArea.width)
3321 __titleTextArea.width = CalculateMinimumToolbarWidth();
3324 if (GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
3326 if (__titleTextArea.width > portraitSize.width)
3328 __titleTextArea.width = portraitSize.width;
3333 if (__titleTextArea.width > landscapeSize.width)
3335 __titleTextArea.width = landscapeSize.width;
3339 __itemArea = __titleTextArea;
3341 if (__header == true && __style != TOOLBAR_TEXT)
3343 int headerLeftButtonWidth = 0;
3344 int headerRightButtonWidth = 0;
3345 int headerTopMargin = 0;
3347 int buttonItemGap = 0;
3348 int headerButtonItemHeight = 0;
3349 int headerLeftMargin = 0;
3350 int headerRightMargin = 0;
3351 int segmentedButtonWidth = 0;
3352 int segmentedButtonWidth2 = 0;
3353 int tabLeftMargin = 0;
3355 GET_SHAPE_CONFIG(HEADER::TOP_MARGIN, GetOrientation(), headerTopMargin);
3356 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_GAP, GetOrientation(), buttonItemGap);
3357 GET_SHAPE_CONFIG(HEADER::LEFT_MARGIN, GetOrientation(), headerLeftMargin);
3358 GET_SHAPE_CONFIG(HEADER::RIGHT_MARGIN, GetOrientation(), headerRightMargin);
3359 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_WIDTH_OF_SEGMENTED, GetOrientation(), segmentedButtonWidth);
3360 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_WIDTH_OF_SEGMENTED_2, GetOrientation(), segmentedButtonWidth2);
3361 GET_SHAPE_CONFIG(HEADER::TAB_LEFT_MARGIN, GetOrientation(), tabLeftMargin);
3363 if (__pButtonItems[LEFT_BUTTON])
3365 headerLeftButtonWidth = __pButtonItems[LEFT_BUTTON]->GetSize().width;
3368 if (__pButtonItems[RIGHT_BUTTON])
3370 headerRightButtonWidth = __pButtonItems[RIGHT_BUTTON]->GetSize().width;
3373 if (__style == TOOLBAR_HEADER_SEGMENTED || __style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE)
3375 if (__pButtonItems[LEFT_BUTTON])
3377 if (__pButtonItems[RIGHT_BUTTON])
3379 headerLeftButtonWidth = segmentedButtonWidth2;
3380 headerRightButtonWidth = segmentedButtonWidth2;
3384 headerLeftButtonWidth = segmentedButtonWidth;
3387 GET_SHAPE_CONFIG(HEADER::RIGHT_MARGIN_WITH_SEGMENTED_BUTTON, GetOrientation(), headerRightMargin);
3391 if (__pButtonItems[RIGHT_BUTTON])
3393 headerRightButtonWidth = segmentedButtonWidth;
3395 GET_SHAPE_CONFIG(HEADER::RIGHT_MARGIN_WITH_SEGMENTED_BUTTON, GetOrientation(), headerRightMargin);
3400 if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE)
3402 GET_SHAPE_CONFIG(HEADER::TITLE_HEIGHT_WITH_SEGMENTED_ITEM, GetOrientation(), vmargin);
3403 GET_SHAPE_CONFIG(HEADER::SEGMENTED_ITEM_HEIGHT, GetOrientation(), headerButtonItemHeight);
3407 if (__style == TOOLBAR_TITLE)
3409 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_TOP_MARGIN, GetOrientation(), vmargin);
3410 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_HEIGHT, GetOrientation(), headerButtonItemHeight);
3412 else if(__style == TOOLBAR_HEADER_SEGMENTED)
3414 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_TOP_MARGIN_OF_SEGMENTED, GetOrientation(), vmargin);
3415 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_HEIGHT_OF_SEGMENTED, GetOrientation(), headerButtonItemHeight);
3419 __titleTextArea.x = headerLeftMargin;
3420 __titleTextArea.y = headerTopMargin;
3422 if (__pButtonItems[RIGHT_BUTTON])
3424 if (__pButtonItems[LEFT_BUTTON])
3426 __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__titleTextArea.width - headerRightButtonWidth - headerRightMargin, vmargin,
3427 headerRightButtonWidth, headerButtonItemHeight));
3428 __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(__titleTextArea.width - headerRightButtonWidth - headerLeftButtonWidth - buttonItemGap - headerRightMargin, vmargin,
3429 headerLeftButtonWidth, headerButtonItemHeight));
3431 if (!(__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE))
3433 __titleTextArea.width -= (headerLeftButtonWidth + headerRightButtonWidth + buttonItemGap + headerLeftMargin);
3438 __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__titleTextArea.width - headerRightButtonWidth - headerRightMargin, vmargin,
3439 headerRightButtonWidth, headerButtonItemHeight));
3441 if (!(__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE))
3443 __titleTextArea.width -= (headerRightButtonWidth + headerLeftMargin);
3447 else if (__pButtonItems[LEFT_BUTTON])
3449 __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(__titleTextArea.width - headerLeftButtonWidth - headerRightMargin, vmargin,
3450 headerLeftButtonWidth, headerButtonItemHeight));
3452 if (!(__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE))
3454 __titleTextArea.width -= (headerLeftButtonWidth + headerLeftMargin);
3458 if (!(__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE))
3460 __titleTextArea.width -= (headerLeftMargin + headerRightMargin);
3462 else // TOOLBAR_HEADER_SEGMENTED_WITH_TITLE or TOOLBAR_TAB_WITH_TITLE
3464 __titleTextArea.width -= (headerLeftMargin + tabLeftMargin);
3467 if (__style == TOOLBAR_HEADER_SEGMENTED)
3469 if (__pButtonItems[RIGHT_BUTTON])
3471 RealignButtonIcon(__pButtonItems[RIGHT_BUTTON]);
3473 if (__pButtonItems[LEFT_BUTTON])
3475 RealignButtonIcon(__pButtonItems[LEFT_BUTTON]);
3478 else if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE)
3480 if (__pButtonItems[RIGHT_BUTTON])
3482 RealignIcon(__pButtonItems[RIGHT_BUTTON]);
3484 if (__pButtonItems[LEFT_BUTTON])
3486 RealignIcon(__pButtonItems[LEFT_BUTTON]);
3490 else // footer or edit or HEADER_STYLE_BUTTON
3492 int footerButtonItemWidth = 0;
3493 int footerButtonItemHeight = 0;
3494 int sipButtonItemTopMargin = 0;
3495 int footerLeftMargin = 0;
3496 Dimension softkeyDimension(0, 0);
3498 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_WIDTH, GetOrientation(), footerButtonItemWidth);
3499 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_HEIGHT, GetOrientation(), footerButtonItemHeight);
3500 GET_SHAPE_CONFIG(HEADER::SIP_BUTTON_ITEM_TOP_MARGIN, GetOrientation(), sipButtonItemTopMargin);
3501 GET_SHAPE_CONFIG(FOOTER::LEFT_MARGIN, GetOrientation(), footerLeftMargin);
3502 GET_DIMENSION_CONFIG(FOOTER::SOFTKEY_RECT_WITH_TEXT, GetOrientation(), softkeyDimension);
3504 if (__pButtonItems[MIDDLE_BUTTON])
3506 __pButtonItems[MIDDLE_BUTTON]->SetPosition(Point((__itemArea.width - __pButtonItems[MIDDLE_BUTTON]->GetSize().width) / 2,
3507 __itemArea.height - __pButtonItems[MIDDLE_BUTTON]->GetSize().height));
3510 if (__pButtonItems[RIGHT_BUTTON])
3512 if (__pButtonItems[LEFT_BUTTON])
3514 if (__pButtonItems[BACK_BUTTON]) //321
3516 if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip
3518 __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3519 sipButtonItemTopMargin, footerButtonItemWidth, footerButtonItemHeight));
3521 __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, sipButtonItemTopMargin,
3522 footerButtonItemWidth, footerButtonItemHeight));
3526 __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3527 (__itemArea.height - footerButtonItemHeight) / 2, footerButtonItemWidth, footerButtonItemHeight));
3529 __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, (__itemArea.height - footerButtonItemHeight) / 2,
3530 footerButtonItemWidth, footerButtonItemHeight));
3535 if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip
3537 __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3538 sipButtonItemTopMargin, footerButtonItemWidth, footerButtonItemHeight));
3540 __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, sipButtonItemTopMargin,
3541 footerButtonItemWidth, footerButtonItemHeight));
3545 if (__style != TOOLBAR_SOFTKEY)
3547 __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3548 (__itemArea.height - footerButtonItemHeight) / 2, footerButtonItemWidth, footerButtonItemHeight));
3552 if (__pButtonItems[RIGHT_BUTTON]->GetText() == L"")
3554 __pButtonItems[RIGHT_BUTTON]->SetPosition(Point(__itemArea.width - __pButtonItems[RIGHT_BUTTON]->GetSize().width,
3555 __itemArea.height - __pButtonItems[RIGHT_BUTTON]->GetSize().height));
3559 __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__itemArea.width - softkeyDimension.width, 0,
3560 softkeyDimension.width, softkeyDimension.height));
3564 if (__style != TOOLBAR_SOFTKEY)
3566 __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, (__itemArea.height - footerButtonItemHeight) / 2,
3567 footerButtonItemWidth, footerButtonItemHeight));
3571 if (__pButtonItems[LEFT_BUTTON]->GetText() == L"")
3573 __pButtonItems[LEFT_BUTTON]->SetPosition(Point(0, __itemArea.height - __pButtonItems[LEFT_BUTTON]->GetSize().height));
3577 __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(0, 0, softkeyDimension.width, softkeyDimension.height));
3585 if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip
3587 if (__pButtonItems[BACK_BUTTON])//31
3589 __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3590 sipButtonItemTopMargin, footerButtonItemWidth, footerButtonItemHeight));
3594 __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3595 sipButtonItemTopMargin, footerButtonItemWidth, footerButtonItemHeight));
3600 if (__pButtonItems[BACK_BUTTON])//31
3602 __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3603 (__itemArea.height - footerButtonItemHeight) / 2, footerButtonItemWidth, footerButtonItemHeight));
3607 if (__style != TOOLBAR_SOFTKEY)
3609 __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3610 (__itemArea.height - footerButtonItemHeight) / 2, footerButtonItemWidth, footerButtonItemHeight));
3614 if (__pButtonItems[RIGHT_BUTTON]->GetText() == L"")
3616 __pButtonItems[RIGHT_BUTTON]->SetPosition(Point(__itemArea.width - __pButtonItems[RIGHT_BUTTON]->GetSize().width,
3617 __itemArea.height - __pButtonItems[RIGHT_BUTTON]->GetSize().height));
3621 __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__itemArea.width - softkeyDimension.width, 0,
3622 softkeyDimension.width, softkeyDimension.height));
3629 else if (__pButtonItems[LEFT_BUTTON])
3631 if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip
3633 if (__pButtonItems[BACK_BUTTON]) //32
3635 __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3636 sipButtonItemTopMargin, footerButtonItemWidth, footerButtonItemHeight));
3638 __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, sipButtonItemTopMargin,
3639 footerButtonItemWidth, footerButtonItemHeight));
3643 __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, sipButtonItemTopMargin,
3644 footerButtonItemWidth, footerButtonItemHeight));
3649 if (__pButtonItems[BACK_BUTTON]) //32
3651 __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3652 (__itemArea.height - footerButtonItemHeight) / 2, footerButtonItemWidth, footerButtonItemHeight));
3654 __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, (__itemArea.height - footerButtonItemHeight) / 2,
3655 footerButtonItemWidth, footerButtonItemHeight));
3659 if (__style != TOOLBAR_SOFTKEY)
3661 __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, (__itemArea.height - footerButtonItemHeight) / 2,
3662 footerButtonItemWidth, footerButtonItemHeight));
3666 if (__pButtonItems[LEFT_BUTTON]->GetText() == L"")
3668 __pButtonItems[LEFT_BUTTON]->SetPosition(Point(0, __itemArea.height - __pButtonItems[LEFT_BUTTON]->GetSize().height));
3672 __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(0, 0, softkeyDimension.width, softkeyDimension.height));
3680 if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip
3682 if (__pButtonItems[BACK_BUTTON])
3684 __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3685 sipButtonItemTopMargin, footerButtonItemWidth, footerButtonItemHeight));
3690 if (__pButtonItems[BACK_BUTTON])
3692 __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3693 (__itemArea.height - footerButtonItemHeight) / 2, footerButtonItemWidth, footerButtonItemHeight));
3700 if (__pToolbarPresenter)
3702 __pToolbarPresenter->SetUsableAreaBounds(__titleTextArea);
3705 if (0 == __itemCount)
3712 case TOOLBAR_HEADER_SEGMENTED:
3714 case TOOLBAR_HEADER_SEGMENTED_WITH_TITLE:
3715 RearrangeHeaderSegmentedItems();
3718 case TOOLBAR_SEGMENTED:
3719 RearrangeFooterSegmentedItems();
3724 case TOOLBAR_TAB_WITH_TITLE:
3725 RearrangeTabItmes();
3729 RearrangeButtonItems();
3737 _Toolbar::RearrangeHeaderSegmentedItems(void)
3739 int segmentedItemHeight = 0;
3740 int tabLeftMargin = 0;
3741 int separatorWidth = 0;
3742 int segmentedRightMarginWithButton = 0;
3744 int blockWidth[__itemCount];
3747 GET_SHAPE_CONFIG(HEADER::TAB_LEFT_MARGIN, GetOrientation(), tabLeftMargin);
3748 GET_SHAPE_CONFIG(HEADER::SEPARATOR_WIDTH, GetOrientation(), separatorWidth);
3749 GET_SHAPE_CONFIG(HEADER::RIGHT_MARGIN_WITH_SEGMENTED_BUTTON, GetOrientation(), segmentedRightMarginWithButton);
3751 if (__style == TOOLBAR_HEADER_SEGMENTED)
3753 segmentedItemHeight = __titleTextArea.height;
3754 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_TOP_MARGIN_OF_SEGMENTED, GetOrientation(), vmargin);
3756 else if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE)
3758 GET_SHAPE_CONFIG(HEADER::SEGMENTED_ITEM_HEIGHT, GetOrientation(), segmentedItemHeight);
3759 GET_SHAPE_CONFIG(HEADER::TITLE_HEIGHT_WITH_SEGMENTED_ITEM, GetOrientation(), vmargin);
3762 if (__pButtonItems[LEFT_BUTTON])
3764 if (__pButtonItems[RIGHT_BUTTON])
3766 __itemArea.width -= (tabLeftMargin + tabLeftMargin + __pButtonItems[LEFT_BUTTON]->GetSize().width + separatorWidth
3767 + __pButtonItems[RIGHT_BUTTON]->GetSize().width + segmentedRightMarginWithButton);
3771 __itemArea.width -= (tabLeftMargin + tabLeftMargin + __pButtonItems[LEFT_BUTTON]->GetSize().width + segmentedRightMarginWithButton);
3776 if (__pButtonItems[RIGHT_BUTTON])
3778 __itemArea.width -= (tabLeftMargin + tabLeftMargin + __pButtonItems[RIGHT_BUTTON]->GetSize().width + segmentedRightMarginWithButton);
3782 __itemArea.width -= tabLeftMargin * 2;
3786 if (__itemCount == 1 || __itemCount == 2)
3788 blockWidth[0] = blockWidth[1] = (__itemArea.width - separatorWidth) / 2;
3790 for (int i = 0; i < __itemCount ; i++)
3792 __pItems.at(i)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] * i + separatorWidth * i, vmargin, blockWidth[i], segmentedItemHeight));
3794 if (__pItems.at(i)->GetChildCount() != 0)
3796 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
3798 if (existingBadgeIcon)
3800 existingBadgeIcon->SetPosition(Point(blockWidth[1] - existingBadgeIcon->GetSize().width, 0));
3801 existingBadgeIcon = null;
3806 else if (__itemCount == 3)
3808 blockWidth[0] = blockWidth[1] = blockWidth[2] = (__itemArea.width - separatorWidth * 2) / 3;
3810 __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, vmargin, blockWidth[0], segmentedItemHeight));
3811 __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + separatorWidth, vmargin, blockWidth[1], segmentedItemHeight));
3812 __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + separatorWidth * 2,
3813 vmargin, blockWidth[2], segmentedItemHeight));
3815 for (int i = 0; i < __itemCount; i++)
3817 if (__pItems.at(i)->GetChildCount() != 0)
3819 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
3821 if (existingBadgeIcon)
3823 existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0));
3824 existingBadgeIcon = null;
3829 else if (__itemCount == 4)
3831 blockWidth[0] = blockWidth[1] = blockWidth[2] = blockWidth[3] = (__itemArea.width - separatorWidth * 3) / 4;
3833 __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, vmargin, blockWidth[0], segmentedItemHeight));
3834 __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + separatorWidth, vmargin, blockWidth[1], segmentedItemHeight));
3835 __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + separatorWidth * 2,
3836 vmargin, blockWidth[2], segmentedItemHeight));
3837 __pItems.at(3)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + blockWidth[2] + separatorWidth * 3,
3838 vmargin, blockWidth[3], segmentedItemHeight));
3840 for (int i = 0; i < __itemCount ; i++)
3842 if (__pItems.at(i)->GetChildCount() != 0)
3844 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
3846 if (existingBadgeIcon)
3848 existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0));
3849 existingBadgeIcon = null;
3855 for (int i = 0; i < __itemCount; i++)
3857 if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE)
3859 GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_4_ITEM, GetOrientation(), fontSize);
3861 __pItems.at(i)->SetTextSize(fontSize, FONT_STYLE_BOLD);
3864 RealignIcon(__pItems.at(i));
3871 _Toolbar::RearrangeFooterSegmentedItems(void)
3873 int segmentedItemHeight = __itemArea.height;
3875 int tabLeftMargin = 0;
3876 int tabRightMargin = 0;
3877 int footerLeftMargin = 0;
3879 int separatorWidth = 0;
3880 int blockWidth[__itemCount];
3883 int itemButtonLeftGap = 0;
3884 int itemButtonRightGap = 0;
3886 GET_SHAPE_CONFIG(HEADER::TAB_LEFT_MARGIN, GetOrientation(), tabLeftMargin);
3887 GET_SHAPE_CONFIG(FOOTER::LEFT_MARGIN, GetOrientation(), footerLeftMargin);
3888 GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_ICON_SIZE, GetOrientation(), iconSize);
3889 GET_SHAPE_CONFIG(HEADER::SEPARATOR_WIDTH, GetOrientation(), separatorWidth);
3891 tabRightMargin = tabLeftMargin;
3893 if (__itemCount == 1 || __itemCount == 2)
3895 tabLeftMargin = footerLeftMargin;
3896 itemButtonLeftGap = footerLeftMargin;
3897 __itemArea.width -= ((tabLeftMargin + iconSize + itemButtonLeftGap) * 2);
3899 blockWidth[0] = blockWidth[1] = (__itemArea.width - separatorWidth) / 2;
3901 for (int i = 0; i < __itemCount ; i++)
3903 __pItems.at(i)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] * i + separatorWidth * i,
3904 (GetSize().height - segmentedItemHeight) / 2, blockWidth[i], segmentedItemHeight));
3906 if (__pItems.at(i)->GetChildCount() != 0)
3908 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
3910 if (existingBadgeIcon)
3912 existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0));
3913 existingBadgeIcon = null;
3918 GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_3_ITEM, GetOrientation(), fontSize);
3920 else if (__itemCount == 3)
3922 if (__pButtonItems[LEFT_BUTTON])
3924 if (__pButtonItems[RIGHT_BUTTON] || __pButtonItems[BACK_BUTTON])
3926 tabLeftMargin = footerLeftMargin;
3927 itemButtonLeftGap = footerLeftMargin;
3928 __itemArea.width -= ((tabLeftMargin + iconSize + itemButtonLeftGap) * 2);
3932 tabLeftMargin = footerLeftMargin;
3933 itemButtonLeftGap = footerLeftMargin;
3934 __itemArea.width -= (tabLeftMargin + iconSize + itemButtonLeftGap + tabRightMargin);
3939 if (__pButtonItems[RIGHT_BUTTON] || __pButtonItems[BACK_BUTTON])
3941 tabRightMargin = footerLeftMargin;
3942 itemButtonRightGap = footerLeftMargin;
3943 __itemArea.width -= (tabLeftMargin + itemButtonRightGap + iconSize + tabRightMargin);
3947 __itemArea.width -= tabLeftMargin * 2;
3953 blockWidth[0] = blockWidth[1] = blockWidth[2] = (__itemArea.width - separatorWidth * 2) / 3;
3955 __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap, (GetSize().height - segmentedItemHeight) / 2, blockWidth[0], segmentedItemHeight));
3956 __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] + separatorWidth, (GetSize().height - segmentedItemHeight) / 2, blockWidth[1], segmentedItemHeight));
3957 __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] + blockWidth[1] + separatorWidth * 2,
3958 (GetSize().height - segmentedItemHeight) / 2, blockWidth[2], segmentedItemHeight));
3960 for (int i = 0; i < __itemCount ; i++)
3962 if (__pItems.at(i)->GetChildCount() != 0)
3964 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
3966 if (existingBadgeIcon)
3968 existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0));
3969 existingBadgeIcon = null;
3974 GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_3_ITEM, GetOrientation(), fontSize);
3976 else if (__itemCount == 4)
3978 if (__pButtonItems[BACK_BUTTON])
3980 tabRightMargin = footerLeftMargin;
3981 itemButtonRightGap = footerLeftMargin;
3982 __itemArea.width -= (tabLeftMargin + itemButtonRightGap + iconSize + tabRightMargin);
3986 __itemArea.width -= tabLeftMargin * 2;
3989 blockWidth[0] = blockWidth[1] = blockWidth[2] = blockWidth[3] = (__itemArea.width - separatorWidth * 3) / 4;
3991 __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, (GetSize().height - segmentedItemHeight) / 2, blockWidth[0], segmentedItemHeight));
3992 __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + separatorWidth, (GetSize().height - segmentedItemHeight) / 2, blockWidth[1], segmentedItemHeight));
3993 __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + separatorWidth * 2,
3994 (GetSize().height - segmentedItemHeight) / 2, blockWidth[2], segmentedItemHeight));
3995 __pItems.at(3)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + blockWidth[2] + separatorWidth * 3,
3996 (GetSize().height - segmentedItemHeight) / 2, blockWidth[3], segmentedItemHeight));
3998 for (int i = 0; i < __itemCount ; i++)
4000 if (__pItems.at(i)->GetChildCount() != 0)
4002 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
4004 if (existingBadgeIcon)
4006 existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0));
4007 existingBadgeIcon = null;
4012 GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_4_ITEM, GetOrientation(), fontSize);
4015 for (int i = 0; i < __itemCount ; i++)
4017 __pItems.at(i)->SetTextSize(fontSize, FONT_STYLE_BOLD);
4019 RealignIcon(__pItems.at(i));
4026 _Toolbar::RearrangeTabItmes(void)
4028 int itemWidth[__itemCount];
4030 int segmentedItemHeight = 0;
4031 int tabLeftMargin = 0;
4033 int separatorWidth = 0;
4035 GET_SHAPE_CONFIG(HEADER::TAB_LEFT_MARGIN, GetOrientation(), tabLeftMargin);
4036 GET_SHAPE_CONFIG(HEADER::SEPARATOR_WIDTH, GetOrientation(), separatorWidth);
4038 if (__style == TOOLBAR_TAB)
4040 segmentedItemHeight = __itemArea.height;
4042 else if (__style == TOOLBAR_TAB_WITH_TITLE)
4044 GET_SHAPE_CONFIG(HEADER::SEGMENTED_ITEM_HEIGHT, GetOrientation(), segmentedItemHeight);
4045 GET_SHAPE_CONFIG(HEADER::TITLE_HEIGHT_WITH_SEGMENTED_ITEM, GetOrientation(), vmargin);
4048 if (__itemCount == 1)
4050 itemWidth[0] = __itemArea.width - tabLeftMargin * 2;
4051 __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, vmargin, itemWidth[0], segmentedItemHeight));
4053 if (__style == TOOLBAR_TAB)
4055 GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_3_ITEM, GetOrientation(), fontSize);
4057 else if (__style == TOOLBAR_TAB_WITH_TITLE)
4059 GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_4_ITEM, GetOrientation(), fontSize);
4062 else if (__itemCount == 2)
4064 itemWidth[0] = itemWidth[1] = (__itemArea.width - tabLeftMargin * 2 - separatorWidth) / 2;
4066 __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, vmargin, itemWidth[0], segmentedItemHeight));
4067 __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + itemWidth[0] + separatorWidth, vmargin, itemWidth[1], segmentedItemHeight));
4069 if (__style == TOOLBAR_TAB)
4071 GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_3_ITEM, GetOrientation(), fontSize);
4073 else if (__style == TOOLBAR_TAB_WITH_TITLE)
4075 GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_4_ITEM, GetOrientation(), fontSize);
4078 else if (__itemCount == 3)
4080 itemWidth[0] = itemWidth[1] = itemWidth[2] = (__itemArea.width - tabLeftMargin * 2 - separatorWidth * 2) / 3;
4082 __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, vmargin, itemWidth[0], segmentedItemHeight));
4083 __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + itemWidth[0] + separatorWidth, vmargin, itemWidth[1], segmentedItemHeight));
4084 __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + itemWidth[0] + itemWidth[1] + separatorWidth * 2, vmargin, itemWidth[2], segmentedItemHeight));
4086 if (__style == TOOLBAR_TAB)
4088 GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_3_ITEM, GetOrientation(), fontSize);
4090 else if (__style == TOOLBAR_TAB_WITH_TITLE)
4092 GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_4_ITEM, GetOrientation(), fontSize);
4097 itemWidth[0] = itemWidth[1] = itemWidth[2] = itemWidth[3] = (__itemArea.width - tabLeftMargin * 2 - separatorWidth * 3) / 4;
4099 __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, vmargin, itemWidth[0], segmentedItemHeight));
4100 __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + itemWidth[0] + separatorWidth, vmargin, itemWidth[1], segmentedItemHeight));
4101 __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + itemWidth[0] + itemWidth[1] + separatorWidth * 2,
4102 vmargin, itemWidth[2], segmentedItemHeight));
4103 __pItems.at(3)->SetBounds(Rectangle(tabLeftMargin + itemWidth[0] + itemWidth[1] + itemWidth[2] + separatorWidth * 3,
4104 vmargin, itemWidth[3], segmentedItemHeight));
4106 GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_4_ITEM, GetOrientation(), fontSize);
4109 for (int i = 4; i < __itemCount ; i++)
4111 itemWidth[i] = itemWidth[0];
4113 __pItems.at(i)->SetBounds(Rectangle(__pItems.at(i-1)->GetBounds().x + separatorWidth + itemWidth[i], vmargin, itemWidth[i], segmentedItemHeight));
4116 for (int i = 0; i < __itemCount ; i++)
4118 __pItems.at(i)->SetTextSize(fontSize, FONT_STYLE_BOLD);
4120 if (__pItems.at(i)->GetChildCount() != 0)
4122 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
4124 if (existingBadgeIcon)
4126 existingBadgeIcon->SetPosition(Point(__pItems.at(i)->GetSize().width - existingBadgeIcon->GetSize().width, 0));
4127 existingBadgeIcon = null;
4131 RealignIcon(__pItems.at(i));
4138 _Toolbar::RearrangeButtonItems(void)
4141 int maxItemLength = 0;
4142 int minItemLength = 0;
4143 int iconSizeWithText = 0;
4146 int itemButtonLeftGap = 0;
4147 int itemButtonRightGap = 0;
4148 int tabLeftMargin = 0;
4149 int tabRightMargin = 0;
4150 int sipFooterItemTopMargin = 0;
4151 int separatorWidth = 0;
4153 int footerLeftMargin = 0;
4154 int headerButtonItemHeight = 0;
4155 int headerLeftMargin = 0;
4156 int blockWidth[__itemCount];
4158 GET_SHAPE_CONFIG(HEADER::SIP_FOOTER_ITEM_TOP_MARGIN, GetOrientation(), sipFooterItemTopMargin);
4159 GET_SHAPE_CONFIG(HEADER::SEPARATOR_WIDTH, GetOrientation(), separatorWidth);
4160 GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_ICON_SIZE, GetOrientation(), iconSize);
4161 GET_SHAPE_CONFIG(FOOTER::LEFT_MARGIN, GetOrientation(), footerLeftMargin);
4162 GET_SHAPE_CONFIG(HEADER::TAB_LEFT_MARGIN, GetOrientation(), tabLeftMargin);
4163 GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_WIDTH_1_MAX, GetOrientation(), maxItemLength);
4164 GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_WIDTH_1_MIN, GetOrientation(), minItemLength);
4165 GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_BUTTON_STYLE_SIDE_MARGIN, GetOrientation(), sideMargin);
4166 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_TOP_MARGIN, GetOrientation(), vmargin);
4167 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_HEIGHT, GetOrientation(), headerButtonItemHeight);
4168 GET_SHAPE_CONFIG(HEADER::LEFT_MARGIN, GetOrientation(), headerLeftMargin);
4170 tabRightMargin = tabLeftMargin;
4172 if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
4174 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_HEIGHT, GetOrientation(), itemHeight);
4178 itemHeight = GetSize().height;
4181 if (__itemCount == 1)
4183 if (__style == TOOLBAR_TITLE) // item 1, HEADER_STYLE_TITLE_BUTTON
4185 blockWidth[0] = __titleTextArea.width;
4186 itemHeight = headerButtonItemHeight;
4187 __pItems.at(0)->SetBounds(Rectangle(headerLeftMargin, vmargin, blockWidth[0], itemHeight));
4188 __pItems.at(0)->SetMargin(0,0);
4192 if (!(__pItems.at(0)->GetBitmap(_BUTTON_STATUS_NORMAL) == null
4193 && __pItems.at(0)->GetBitmap(_BUTTON_STATUS_DISABLED) == null
4194 && __pItems.at(0)->GetBitmap(_BUTTON_STATUS_PRESSED) == null
4195 && __pItems.at(0)->GetBitmap(_BUTTON_STATUS_SELECTED) == null
4196 && __pItems.at(0)->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED) == null)) // at least 1 bitmap
4198 GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_BUTTON_STYLE_ICON_SIZE_WITH_TEXT, GetOrientation(), iconSizeWithText);
4201 blockWidth[0] = __pItems.at(0)->GetTextExtentSize() + iconSizeWithText + sideMargin * 3;
4203 if (blockWidth[0] > maxItemLength)
4205 blockWidth[0] = maxItemLength;
4207 if (blockWidth[0] < minItemLength)
4209 blockWidth[0] = minItemLength;
4212 if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip
4214 __pItems.at(0)->SetBounds(Rectangle((GetSize().width - blockWidth[0]) / 2, sipFooterItemTopMargin, blockWidth[0], itemHeight));
4218 __pItems.at(0)->SetBounds(Rectangle((GetSize().width - blockWidth[0]) / 2, (GetSize().height - itemHeight) / 2, blockWidth[0], itemHeight));
4222 for (int i = 0; i < __itemCount; i++)
4224 if (__pItems.at(i)->GetChildCount() != 0)
4226 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
4228 if (existingBadgeIcon)
4230 existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0));
4231 existingBadgeIcon = null;
4236 else if(__itemCount == 2)
4238 tabLeftMargin = footerLeftMargin;
4239 itemButtonLeftGap = footerLeftMargin;
4240 __itemArea.width -= ((tabLeftMargin + iconSize + itemButtonLeftGap) * 2);
4242 blockWidth[0] = blockWidth[1] = (__itemArea.width - separatorWidth) / 2;
4244 if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip
4246 __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap, sipFooterItemTopMargin, blockWidth[0], itemHeight));
4247 __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] + separatorWidth, sipFooterItemTopMargin, blockWidth[1], itemHeight));
4251 __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap, (GetSize().height - itemHeight) / 2, blockWidth[0], itemHeight));
4252 __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] + separatorWidth, (GetSize().height - itemHeight) / 2, blockWidth[1], itemHeight));
4255 for (int i = 0; i < __itemCount; i++)
4257 if (__pItems.at(i)->GetChildCount() != 0)
4259 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
4261 if (existingBadgeIcon)
4263 existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0));
4264 existingBadgeIcon = null;
4269 else if (__itemCount == 3)
4271 if (__pButtonItems[LEFT_BUTTON])
4273 if (__pButtonItems[RIGHT_BUTTON] || __pButtonItems[BACK_BUTTON])
4275 tabLeftMargin = footerLeftMargin;
4276 itemButtonLeftGap = footerLeftMargin;
4277 __itemArea.width -= ((tabLeftMargin + iconSize + itemButtonLeftGap) * 2);
4281 tabLeftMargin = footerLeftMargin;
4282 itemButtonLeftGap = footerLeftMargin;
4283 __itemArea.width -= (tabLeftMargin + iconSize + itemButtonLeftGap + tabRightMargin);
4288 if (__pButtonItems[RIGHT_BUTTON] || __pButtonItems[BACK_BUTTON])
4290 tabRightMargin = footerLeftMargin;
4291 itemButtonRightGap = footerLeftMargin;
4292 __itemArea.width -= (tabLeftMargin + itemButtonRightGap + iconSize + tabRightMargin);
4296 __itemArea.width -= tabLeftMargin * 2;
4302 blockWidth[0] = blockWidth[1] = blockWidth[2] = (__itemArea.width - separatorWidth * 2) / 3;
4304 if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip
4306 __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap, sipFooterItemTopMargin, blockWidth[0], itemHeight));
4307 __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] + separatorWidth, sipFooterItemTopMargin, blockWidth[1], itemHeight));
4308 __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] + blockWidth[1] + separatorWidth * 2,
4309 sipFooterItemTopMargin, blockWidth[2], itemHeight));
4313 __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap, (GetSize().height - itemHeight) / 2, blockWidth[0], itemHeight));
4314 __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] + separatorWidth, (GetSize().height - itemHeight) / 2, blockWidth[1], itemHeight));
4315 __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] + blockWidth[1] + separatorWidth * 2,
4316 (GetSize().height - itemHeight) / 2, blockWidth[2], itemHeight));
4319 for (int i = 0; i < __itemCount; i++)
4321 if (__pItems.at(i)->GetChildCount() != 0)
4323 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
4325 if (existingBadgeIcon)
4327 existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0));
4328 existingBadgeIcon = null;
4333 else if (__itemCount == 4)
4335 if (__pButtonItems[BACK_BUTTON])
4337 tabRightMargin = footerLeftMargin;
4338 itemButtonRightGap = footerLeftMargin;
4339 __itemArea.width -= (tabLeftMargin + itemButtonRightGap + iconSize + tabRightMargin);
4343 __itemArea.width -= tabLeftMargin * 2;
4346 blockWidth[0] = blockWidth[1] = blockWidth[2] = blockWidth[3] = (__itemArea.width - separatorWidth * 3) / 4;
4348 if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip
4350 __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, sipFooterItemTopMargin, blockWidth[0], itemHeight));
4351 __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + separatorWidth, sipFooterItemTopMargin, blockWidth[1], itemHeight));
4352 __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + separatorWidth * 2,
4353 sipFooterItemTopMargin, blockWidth[2], itemHeight));
4354 __pItems.at(3)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + blockWidth[2] + separatorWidth * 3,
4355 sipFooterItemTopMargin, blockWidth[3], itemHeight));
4359 __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, (GetSize().height - itemHeight) / 2, blockWidth[0], itemHeight));
4360 __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + separatorWidth, (GetSize().height - itemHeight) / 2, blockWidth[1], itemHeight));
4361 __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + separatorWidth * 2,
4362 (GetSize().height - itemHeight) / 2, blockWidth[2], itemHeight));
4363 __pItems.at(3)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + blockWidth[2] + separatorWidth * 3,
4364 (GetSize().height - itemHeight) / 2, blockWidth[3], itemHeight));
4367 for (int i = 0; i < __itemCount; i++)
4369 if (__pItems.at(i)->GetChildCount() != 0)
4371 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
4373 if (existingBadgeIcon)
4375 existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0));
4376 existingBadgeIcon = null;
4381 else if (__itemCount == 5)
4383 if (__pButtonItems[BACK_BUTTON])
4385 tabRightMargin = footerLeftMargin;
4386 itemButtonRightGap = footerLeftMargin;
4387 __itemArea.width -= (tabLeftMargin + itemButtonRightGap + iconSize + tabRightMargin);
4391 __itemArea.width -= tabLeftMargin * 2;
4394 blockWidth[0] = blockWidth[1] = blockWidth[2] = blockWidth[3] = blockWidth[4] = (__itemArea.width - separatorWidth * 4) / 5;
4396 if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip
4398 __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, sipFooterItemTopMargin, blockWidth[0], itemHeight));
4399 __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + separatorWidth, sipFooterItemTopMargin, blockWidth[1], itemHeight));
4400 __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + separatorWidth * 2,
4401 sipFooterItemTopMargin, blockWidth[2], itemHeight));
4402 __pItems.at(3)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + blockWidth[2] + separatorWidth * 3,
4403 sipFooterItemTopMargin, blockWidth[3], itemHeight));
4404 __pItems.at(4)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + blockWidth[2] + blockWidth[3] + separatorWidth * 4,
4405 sipFooterItemTopMargin, blockWidth[4], itemHeight));
4409 __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, (GetSize().height - itemHeight) / 2, blockWidth[0], itemHeight));
4410 __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + separatorWidth, (GetSize().height - itemHeight) / 2, blockWidth[1], itemHeight));
4411 __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + separatorWidth * 2,
4412 (GetSize().height - itemHeight) / 2, blockWidth[2], itemHeight));
4413 __pItems.at(3)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + blockWidth[2] + separatorWidth * 3,
4414 (GetSize().height - itemHeight) / 2, blockWidth[3], itemHeight));
4415 __pItems.at(4)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + blockWidth[2] + blockWidth[3] + separatorWidth * 4,
4416 (GetSize().height - itemHeight) / 2, blockWidth[4], itemHeight));
4419 for (int i = 0; i < __itemCount; i++)
4421 if (__pItems.at(i)->GetChildCount() != 0)
4423 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
4425 if (existingBadgeIcon)
4427 existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0));
4428 existingBadgeIcon = null;
4434 int buttonTextFontSize = 0;
4436 for (int i = 0; i < __itemCount; i++)
4438 if (__style == TOOLBAR_ICON_TEXT && (__pItems.at(i)->GetBitmap(_BUTTON_STATUS_NORMAL) || __pItems.at(i)->GetBitmap(_BUTTON_STATUS_PRESSED)))
4440 if (__itemCount == 1 || __itemCount == 2)
4442 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_3_WITH_ICON, GetOrientation(), buttonTextFontSize);
4444 else if (__itemCount == 3)
4446 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_3_WITH_ICON, GetOrientation(), buttonTextFontSize);
4448 else if (__itemCount == 4)
4450 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_4_WITH_ICON, GetOrientation(), buttonTextFontSize);
4452 else if (__itemCount == 5)
4454 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_5_WITH_ICON, GetOrientation(), buttonTextFontSize);
4459 if (__itemCount == 1 || __itemCount == 2)
4461 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_3, GetOrientation(), buttonTextFontSize);
4463 else if (__itemCount == 3)
4465 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_3, GetOrientation(), buttonTextFontSize);
4467 else if (__itemCount == 4)
4469 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_4, GetOrientation(), buttonTextFontSize);
4471 else if (__itemCount == 5)
4473 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_5, GetOrientation(), buttonTextFontSize);
4477 __pItems.at(i)->SetTextSize(buttonTextFontSize, FONT_STYLE_BOLD);
4479 RealignIcon(__pItems.at(i));
4486 _Toolbar::SetAnimation(ToolbarAnimationPosition animationPos)
4488 SysTryReturnResult(NID_UI_CTRL, (0 <= animationPos && animationPos < 3), E_INVALID_ARG,
4489 "[E_INVALID_ARG] The animationPos is invalid.");
4491 if (__pAnimation[animationPos])
4493 if (__pAnimation[animationPos]->GetStatus() == ANIMATION_PLAYING)
4499 Bitmap* pProcessingBitmap[PROCESSING_ANIMATION_COUNT];
4501 for (int i = 0; i < PROCESSING_ANIMATION_COUNT ; i++)
4503 pProcessingBitmap[i] = null;
4506 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_01, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[0]);
4507 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_02, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[1]);
4508 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_03, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[2]);
4509 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_04, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[3]);
4510 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_05, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[4]);
4511 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_06, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[5]);
4512 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_07, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[6]);
4513 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_08, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[7]);
4514 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_09, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[8]);
4515 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_10, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[9]);
4516 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_11, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[10]);
4517 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_12, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[11]);
4518 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_13, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[12]);
4519 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_14, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[13]);
4520 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_15, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[14]);
4521 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_16, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[15]);
4522 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_17, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[16]);
4523 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_18, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[17]);
4524 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_19, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[18]);
4525 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_20, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[19]);
4526 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_21, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[20]);
4527 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_22, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[21]);
4528 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_23, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[22]);
4529 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_24, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[23]);
4530 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_25, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[24]);
4531 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_26, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[25]);
4532 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_27, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[26]);
4533 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_28, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[27]);
4534 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_29, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[28]);
4535 GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_30, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[29]);
4537 // Create AnimationFrames
4538 long duration = 500 / PROCESSING_ANIMATION_COUNT;
4540 AnimationFrame* pAniFrame[PROCESSING_ANIMATION_COUNT];
4542 for (int i = 0; i < PROCESSING_ANIMATION_COUNT ; i++)
4544 pAniFrame[i] = new (std::nothrow) AnimationFrame(*pProcessingBitmap[i], duration);
4547 __pAnimationFrameList = new (std::nothrow) ArrayList();
4548 if (__pAnimationFrameList)
4550 __pAnimationFrameList->Construct();
4552 for (int i = 0; i < PROCESSING_ANIMATION_COUNT ; i++)
4554 __pAnimationFrameList->Add(*pAniFrame[i]);
4558 // Deallocate a Bitmap.
4559 for (int i = 0 ; i < PROCESSING_ANIMATION_COUNT ; i++)
4561 delete pProcessingBitmap[i];
4562 pProcessingBitmap[i] = null;
4565 delete __pAnimation[animationPos];
4566 __pAnimation[animationPos] = null;
4568 __pAnimation[animationPos] = _Animation::CreateAnimationN();
4570 int processingAnimationIconSize = 0;
4572 GET_SHAPE_CONFIG(HEADER::PROCESSING_ANIMATION_ICON_SIZE, GetOrientation(), processingAnimationIconSize);
4574 if (__pAnimation[animationPos])
4576 __pAnimation[animationPos]->SetSize(Dimension(processingAnimationIconSize, processingAnimationIconSize));
4578 if (__pAnimationFrameList)
4580 __pAnimation[animationPos]->SetAnimationFrames(*__pAnimationFrameList);
4582 __pAnimation[animationPos]->SetImageCount(PROCESSING_ANIMATION_COUNT);
4583 __pAnimation[animationPos]->SetRepeatCount(100);
4584 __pAnimation[animationPos]->AddAnimationEventListener(*this);
4587 if (animationPos == TOOLBAR_ANIMATION_POSITION_TITLE)
4589 AttachChild(*__pAnimation[animationPos]);
4591 else if (animationPos == TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT)
4593 __pButtonItems[LEFT_BUTTON]->AttachChild(*__pAnimation[animationPos]);
4595 SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT,
4596 (__pButtonItems[LEFT_BUTTON]->GetSize().width - processingAnimationIconSize) / 2,
4597 (__pButtonItems[LEFT_BUTTON]->GetSize().height - processingAnimationIconSize) / 2);
4599 else if (animationPos == TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT)
4601 __pButtonItems[RIGHT_BUTTON]->AttachChild(*__pAnimation[animationPos]);
4603 SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT,
4604 (__pButtonItems[RIGHT_BUTTON]->GetSize().width - processingAnimationIconSize) / 2,
4605 (__pButtonItems[RIGHT_BUTTON]->GetSize().height - processingAnimationIconSize) / 2);
4613 _Toolbar::SetColorReplacedBitmap(_Button* pButton, const _ButtonStatus status,
4614 const Color& color, const Bitmap* pBitmap)
4616 SysTryReturnResult(NID_UI_CTRL, pButton, E_INVALID_ARG, "[E_INVALID_ARG] The button pointer is null.");
4617 SysTryReturnResult(NID_UI_CTRL, pBitmap, E_INVALID_ARG, "[E_INVALID_ARG] The bitmap pointer is null.");
4619 Bitmap* __pColorReplacedBitmap = null;
4621 __pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBitmap, Color::GetColor(COLOR_ID_MAGENTA), color);
4623 if (__pColorReplacedBitmap)
4625 if (color.GetAlpha() != 0xFF)
4627 __pColorReplacedBitmap->SetAlphaConstant(color.GetAlpha());
4630 pButton->SetBackgroundBitmap(status, *__pColorReplacedBitmap);
4631 delete __pColorReplacedBitmap;
4638 _Toolbar::SetPropertyColor(const Variant& color)
4640 result r = E_SUCCESS;
4642 _Control::SetBackgroundColor(color.ToColor());
4648 _Toolbar::GetPropertyColor(void) const
4650 return Variant(_Control::GetBackgroundColor());
4654 _Toolbar::SetPropertyDescriptionText(const Variant& text)
4656 __descriptionText = text.ToString();
4658 result r = E_SUCCESS;
4660 if (__pToolbarPresenter)
4662 r = __pToolbarPresenter->SetDescriptionText(__descriptionText);
4665 if(__pTitleTextElement)
4669 __pTitleTextElement->SetLabel(__titleText);
4673 __pTitleTextElement->SetLabel(__titleText + L", " + __descriptionText);
4681 _Toolbar::GetPropertyDescriptionText(void) const
4683 return Variant(__descriptionText);
4687 _Toolbar::SetPropertyDescriptionTextColor(const Variant& color)
4689 __descriptionTextColor = color.ToColor();
4695 _Toolbar::GetPropertyDescriptionTextColor(void) const
4697 return Variant(__descriptionTextColor);
4701 _Toolbar::SetPropertyTitleText(const Variant& text)
4703 __titleText = text.ToString();
4705 if(__pTitleTextElement)
4707 __pTitleTextElement->SetLabel(__titleText);
4714 _Toolbar::GetPropertyTitleText(void) const
4716 return Variant(__titleText);
4720 _Toolbar::SetPropertyTitleTextColor(const Variant& color)
4722 __titleTextColor = color.ToColor();
4728 _Toolbar::GetPropertyTitleTextColor(void) const
4730 return Variant(__titleTextColor);
4734 _Toolbar::SetPropertyDisabledButtonColor(const Variant& color)
4736 __buttonBackgroundColor[_BUTTON_STATUS_DISABLED] = color.ToColor();
4738 Bitmap* __pBaseBackgroundBitmap = null;
4740 GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
4742 for (int i = 0; i < BUTTON_MAX; i++)
4744 if (__pButtonItems[i] != null)
4746 if (__pBaseBackgroundBitmap)
4748 SetColorReplacedBitmap(__pButtonItems[i], _BUTTON_STATUS_DISABLED, __buttonBackgroundColor[_BUTTON_STATUS_DISABLED], __pBaseBackgroundBitmap);
4753 delete __pBaseBackgroundBitmap;
4759 _Toolbar::GetPropertyDisabledButtonColor(void) const
4761 return Variant(__buttonBackgroundColor[_BUTTON_STATUS_DISABLED]);
4765 _Toolbar::SetPropertyDisabledButtonTextColor(const Variant& color)
4767 __buttonTextColor[_BUTTON_STATUS_DISABLED] = color.ToColor();
4769 for (int i = 0; i < BUTTON_MAX; i++)
4771 if (__pButtonItems[i] != null)
4773 __pButtonItems[i]->SetTextColor(_BUTTON_STATUS_DISABLED, __buttonTextColor[_BUTTON_STATUS_DISABLED]);
4781 _Toolbar::GetPropertyDisabledButtonTextColor(void) const
4783 return Variant(__buttonTextColor[_BUTTON_STATUS_DISABLED]);
4787 _Toolbar::SetPropertyHighlightedButtonColor(const Variant& color)
4789 __buttonBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
4791 Bitmap* __pBaseBackgroundBitmap = null;
4793 GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
4795 for (int i = 0; i < BUTTON_MAX; i++)
4797 if (__pButtonItems[i] != null)
4799 if (__pBaseBackgroundBitmap)
4801 SetColorReplacedBitmap(__pButtonItems[i], _BUTTON_STATUS_HIGHLIGHTED, __buttonBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED], __pBaseBackgroundBitmap);
4806 delete __pBaseBackgroundBitmap;
4812 _Toolbar::GetPropertyHighlightedButtonColor(void) const
4814 return Variant(__buttonBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
4818 _Toolbar::SetPropertyHighlightedButtonTextColor(const Variant& color)
4820 __buttonTextColor[_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
4822 for (int i = 0; i < BUTTON_MAX; i++)
4824 if (__pButtonItems[i] != null)
4826 __pButtonItems[i]->SetTextColor(_BUTTON_STATUS_HIGHLIGHTED, __buttonTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
4834 _Toolbar::GetPropertyHighlightedButtonTextColor(void) const
4836 return Variant(__buttonTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
4840 _Toolbar::SetPropertyNormalButtonColor(const Variant& color)
4842 __buttonBackgroundColor[_BUTTON_STATUS_NORMAL] = color.ToColor();
4844 Bitmap* __pBaseBackgroundBitmap = null;
4846 GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
4848 for (int i = 0; i < BUTTON_MAX; i++)
4850 if (__pButtonItems[i] != null)
4852 if (__pBaseBackgroundBitmap)
4854 SetColorReplacedBitmap(__pButtonItems[i], _BUTTON_STATUS_NORMAL, __buttonBackgroundColor[_BUTTON_STATUS_NORMAL], __pBaseBackgroundBitmap);
4859 delete __pBaseBackgroundBitmap;
4865 _Toolbar::GetPropertyNormalButtonColor(void) const
4867 return Variant(__buttonBackgroundColor[_BUTTON_STATUS_NORMAL]);
4871 _Toolbar::SetPropertyNormalButtonTextColor(const Variant& color)
4873 __buttonTextColor[_BUTTON_STATUS_NORMAL] = color.ToColor();
4875 for (int i = 0; i < BUTTON_MAX; i++)
4877 if (__pButtonItems[i] != null)
4879 __pButtonItems[i]->SetTextColor(_BUTTON_STATUS_NORMAL, __buttonTextColor[_BUTTON_STATUS_NORMAL]);
4887 _Toolbar::GetPropertyNormalButtonTextColor(void) const
4889 return Variant(__buttonTextColor[_BUTTON_STATUS_NORMAL]);
4893 _Toolbar::SetPropertyPressedButtonColor(const Variant& color)
4895 __buttonBackgroundColor[_BUTTON_STATUS_PRESSED] = color.ToColor();
4897 Bitmap* __pBaseBackgroundBitmap = null;
4899 GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
4901 for (int i = 0; i < BUTTON_MAX; i++)
4903 if (__pButtonItems[i] != null)
4905 if (__pBaseBackgroundBitmap)
4907 SetColorReplacedBitmap(__pButtonItems[i], _BUTTON_STATUS_PRESSED, __buttonBackgroundColor[_BUTTON_STATUS_PRESSED], __pBaseBackgroundBitmap);
4912 delete __pBaseBackgroundBitmap;
4918 _Toolbar::GetPropertyPressedButtonColor(void) const
4920 return Variant(__buttonBackgroundColor[_BUTTON_STATUS_PRESSED]);
4924 _Toolbar::SetPropertyPressedButtonTextColor(const Variant& color)
4926 __buttonTextColor[_BUTTON_STATUS_PRESSED] = color.ToColor();
4928 for (int i = 0; i < BUTTON_MAX; i++)
4930 if (__pButtonItems[i] != null)
4932 __pButtonItems[i]->SetTextColor(_BUTTON_STATUS_PRESSED, __buttonTextColor[_BUTTON_STATUS_PRESSED]);
4940 _Toolbar::GetPropertyPressedButtonTextColor(void) const
4942 return Variant(__buttonTextColor[_BUTTON_STATUS_PRESSED]);
4946 _Toolbar::SetPropertyDisabledItemColor(const Variant& color)
4948 __itemBackgroundColor[_BUTTON_STATUS_DISABLED] = color.ToColor();
4950 Bitmap* __pBaseBackgroundBitmap = null;
4952 if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
4954 GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
4958 GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
4961 for (int i = 0; i < __itemCount; i++)
4963 if (__pItems.at(i) != null)
4965 if (__pBaseBackgroundBitmap)
4967 SetColorReplacedBitmap(__pItems.at(i), _BUTTON_STATUS_DISABLED, __itemBackgroundColor[_BUTTON_STATUS_DISABLED], __pBaseBackgroundBitmap);
4972 delete __pBaseBackgroundBitmap;
4978 _Toolbar::GetPropertyDisabledItemColor(void) const
4980 return Variant(__itemBackgroundColor[_BUTTON_STATUS_DISABLED]);
4984 _Toolbar::SetPropertyDisabledItemTextColor(const Variant& color)
4986 __itemTextColor[_BUTTON_STATUS_DISABLED] = color.ToColor();
4988 for (int i = 0; i < __itemCount; i++)
4990 if (__pItems.at(i) != null)
4992 __pItems.at(i)->SetTextColor(_BUTTON_STATUS_DISABLED, __itemTextColor[_BUTTON_STATUS_DISABLED]);
5000 _Toolbar::GetPropertyDisabledItemTextColor(void) const
5002 return Variant(__itemTextColor[_BUTTON_STATUS_DISABLED]);
5006 _Toolbar::SetPropertyHighlightedItemColor(const Variant& color)
5008 __itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
5010 Bitmap* __pBaseBackgroundBitmap = null;
5012 if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
5014 GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
5018 GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
5021 for (int i = 0; i < __itemCount; i++)
5023 if (__pItems.at(i) != null)
5025 if (__pBaseBackgroundBitmap)
5027 SetColorReplacedBitmap(__pItems.at(i), _BUTTON_STATUS_HIGHLIGHTED, __itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED], __pBaseBackgroundBitmap);
5032 delete __pBaseBackgroundBitmap;
5038 _Toolbar::GetPropertyHighlightedItemColor(void) const
5040 return Variant(__itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
5044 _Toolbar::SetPropertyHighlightedItemTextColor(const Variant& color)
5046 __itemTextColor[_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
5048 for (int i = 0; i < __itemCount; i++)
5050 if (__pItems.at(i) != null)
5052 __pItems.at(i)->SetTextColor(_BUTTON_STATUS_HIGHLIGHTED, __itemTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
5060 _Toolbar::GetPropertyHighlightedItemTextColor(void) const
5062 return Variant(__itemTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
5066 _Toolbar::SetPropertyNormalItemColor(const Variant& color)
5068 __itemBackgroundColor[_BUTTON_STATUS_NORMAL] = color.ToColor();
5070 Bitmap* __pBaseBackgroundBitmap = null;
5072 if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
5074 GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
5078 GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
5081 for (int i = 0; i < __itemCount; i++)
5083 if (__pItems.at(i) != null)
5085 if (__pBaseBackgroundBitmap)
5087 SetColorReplacedBitmap(__pItems.at(i), _BUTTON_STATUS_NORMAL, __itemBackgroundColor[_BUTTON_STATUS_NORMAL], __pBaseBackgroundBitmap);
5092 delete __pBaseBackgroundBitmap;
5098 _Toolbar::GetPropertyNormalItemColor(void) const
5100 return Variant(__itemBackgroundColor[_BUTTON_STATUS_NORMAL]);
5104 _Toolbar::SetPropertyNormalItemTextColor(const Variant& color)
5106 __itemTextColor[_BUTTON_STATUS_NORMAL] = color.ToColor();
5108 for (int i = 0; i < __itemCount; i++)
5110 if (__pItems.at(i) != null)
5112 __pItems.at(i)->SetTextColor(_BUTTON_STATUS_NORMAL, __itemTextColor[_BUTTON_STATUS_NORMAL]);
5120 _Toolbar::GetPropertyNormalItemTextColor(void) const
5122 return Variant(__itemTextColor[_BUTTON_STATUS_NORMAL]);
5126 _Toolbar::SetPropertyPressedItemColor(const Variant& color)
5128 __itemBackgroundColor[_BUTTON_STATUS_PRESSED] = color.ToColor();
5130 Bitmap* __pBaseBackgroundBitmap = null;
5132 if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
5134 GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
5138 GET_BITMAP_CONFIG_N(HEADER::TAB_ITEM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
5141 for (int i = 0; i < __itemCount; i++)
5143 if (__pItems.at(i) != null)
5145 if (__pBaseBackgroundBitmap)
5147 SetColorReplacedBitmap(__pItems.at(i), _BUTTON_STATUS_PRESSED, __itemBackgroundColor[_BUTTON_STATUS_PRESSED], __pBaseBackgroundBitmap);
5152 delete __pBaseBackgroundBitmap;
5158 _Toolbar::GetPropertyPressedItemColor(void) const
5160 return Variant(__itemBackgroundColor[_BUTTON_STATUS_PRESSED]);
5164 _Toolbar::SetPropertyPressedItemTextColor(const Variant& color)
5166 __itemTextColor[_BUTTON_STATUS_PRESSED] = color.ToColor();
5168 for (int i = 0; i < __itemCount; i++)
5170 if (__pItems.at(i) != null)
5172 __pItems.at(i)->SetTextColor(_BUTTON_STATUS_PRESSED, __itemTextColor[_BUTTON_STATUS_PRESSED]);
5180 _Toolbar::GetPropertyPressedItemTextColor(void) const
5182 return Variant(__itemTextColor[_BUTTON_STATUS_PRESSED]);
5186 _Toolbar::SetPropertySelectedItemColor(const Variant& color)
5188 __itemBackgroundColor[_BUTTON_STATUS_SELECTED] = color.ToColor();
5190 Bitmap* __pBaseBackgroundBitmap = null;
5192 if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
5194 GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
5198 GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
5201 for (int i = 0; i < __itemCount; i++)
5203 if (__pItems.at(i) != null)
5205 if (__pBaseBackgroundBitmap)
5207 SetColorReplacedBitmap(__pItems.at(i), _BUTTON_STATUS_SELECTED, __itemBackgroundColor[_BUTTON_STATUS_SELECTED], __pBaseBackgroundBitmap);
5212 delete __pBaseBackgroundBitmap;
5218 _Toolbar::GetPropertySelectedItemColor(void) const
5220 return Variant(__itemBackgroundColor[_BUTTON_STATUS_SELECTED]);
5224 _Toolbar::SetPropertySelectedItemTextColor(const Variant& color)
5226 __itemTextColor[_BUTTON_STATUS_SELECTED] = color.ToColor();
5228 for (int i = 0; i < __itemCount; i++)
5230 if (__pItems.at(i) != null)
5232 __pItems.at(i)->SetTextColor(_BUTTON_STATUS_SELECTED, __itemTextColor[_BUTTON_STATUS_SELECTED]);
5240 _Toolbar::GetPropertySelectedItemTextColor(void) const
5242 return Variant(__itemTextColor[_BUTTON_STATUS_SELECTED]);
5246 _Toolbar::GetButtonBounds(ToolbarButton position) const
5248 return __pButtonItems[position]->GetBounds();
5251 }}} // Tizen::Ui::Controls