Fork for IVI: mesa fixing
[profile/ivi/uifw.git] / src / ui / controls / FUiCtrl_Toolbar.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file                FUiCtrl_Toolbar.cpp
19  * @brief               This is the implementation file for the _Toolbar class.
20  */
21
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"
34
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::Graphics;
38 using namespace Tizen::Ui;
39
40 namespace Tizen { namespace Ui { namespace Controls
41 {
42
43 IMPLEMENT_PROPERTY(_Toolbar);
44
45 _Toolbar::_Toolbar(void)
46         : __header(false)
47         , __pToolbarPresenter(null)
48         , __pActionEventListener(null)
49         , __pBackEventListener(null)
50         , __pLongPressGesture(null)
51         , __pToolbarBackgroundBitmap(null)
52         , __pTitleIcon(null)
53         , __titleText(L"")
54         , __descriptionText(L"")
55         , __titleTextAlignment(ALIGNMENT_LEFT)
56         , __pItems(null)
57         , __pAnimationFrameList(null)
58         , __backActionId(-1)
59         , __itemCount(0)
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)
66 {
67         _AccessibilityContainer* pContainer = null;
68
69         __pButtonItems[LEFT_BUTTON] = null;
70         __pButtonItems[RIGHT_BUTTON] = null;
71         __pButtonItems[BACK_BUTTON] = null;
72         __pButtonItems[MIDDLE_BUTTON] = null;
73
74         for (int i = 0; i < TOOLBAR_ANIMATION_POSITION_MAX; i++)
75         {
76                 __pAnimation[i] = null;
77         }
78
79         Color bgColor;
80
81         GET_COLOR_CONFIG(FOOTER::BG_NORMAL, bgColor);
82
83         SetColor(bgColor);
84
85         _Control::SetResizable(false);
86
87         _Control::SetMovable(false);
88
89         _ToolbarPresenter* pPresenter = new (std::nothrow) _ToolbarPresenter();
90
91         SetPresenter(*pPresenter);
92
93         pPresenter->Construct(*this);
94
95         pPresenter->Install();
96
97         pContainer = GetAccessibilityContainer();
98
99         if(pContainer)
100         {
101                 pContainer->Activate(true);
102         }
103
104         for (int i = 0; i < TOOLBAR_ITEM_MAX_STATE_COUNT; i++)
105         {
106                 __isItemBgColorSetByUser[i] = false;
107                 __isItemTextColorSetByUser[i] = false;
108         }
109
110         for (int i = 0; i < TOOLBAR_BUTTON_MAX_STATE_COUNT; i++)
111         {
112                 __isButtonBgColorSetByUser[i] = false;
113                 __isButtonTextColorSetByUser[i] = false;
114         }
115 }
116
117 _Toolbar::~_Toolbar(void)
118 {
119         RemoveAllItems();               //__pMoreButton would be deleted in this function
120         RemoveAllButtons();
121
122         if (__pToolbarPresenter)
123         {
124                 delete __pToolbarPresenter;
125                 __pToolbarPresenter = null;
126         }
127
128         if (__pActionEventListener)
129         {
130                 __pActionEventListener = null;
131         }
132
133         if (__pBackEventListener)
134         {
135                 __pBackEventListener = null;
136         }
137
138         if (__pLongPressGesture != null)
139         {
140                 __pLongPressGesture->RemoveGestureListener(*this);
141                 RemoveGestureDetector(*__pLongPressGesture);
142
143                 delete __pLongPressGesture;
144                 __pLongPressGesture = null;
145         }
146
147         if (__pToolbarBackgroundBitmap)
148         {
149                 delete __pToolbarBackgroundBitmap;
150                 __pToolbarBackgroundBitmap = null;
151         }
152
153         if (__pTitleIcon)
154         {
155                 delete __pTitleIcon;
156                 __pTitleIcon = null;
157         }
158
159         if (__pAnimationFrameList)
160         {
161                 delete __pAnimationFrameList;
162                 __pAnimationFrameList = null;
163         }
164
165         if (__pAnimation[TOOLBAR_ANIMATION_POSITION_TITLE])
166         {
167                 DetachChild(*__pAnimation[TOOLBAR_ANIMATION_POSITION_TITLE]);
168                 delete __pAnimation[TOOLBAR_ANIMATION_POSITION_TITLE];
169                 __pAnimation[TOOLBAR_ANIMATION_POSITION_TITLE] = null;
170         }
171
172         if (__pTitleTextElement)
173         {
174                 __pTitleTextElement->Activate(false);
175                 __pTitleTextElement = null;
176         }
177
178         ClearLastResult();
179 }
180
181 _Toolbar*
182 _Toolbar::CreateToolbarN(bool header)
183 {
184         _Toolbar* pToolbar = new (std::nothrow) _Toolbar();
185         SysTryReturn(NID_UI_CTRL, pToolbar, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
186
187         pToolbar->Initialize(header);
188         pToolbar->AcquireHandle();
189
190         return pToolbar;
191 }
192
193 result
194 _Toolbar::Initialize(bool header)
195 {
196         __header = header;
197
198         return E_SUCCESS;
199 }
200
201 result
202 _Toolbar::InitToolbarColor(void)
203 {
204         if (__header == true)
205         {
206                 if (__transparent) // header && transparent
207                 {
208                         GET_COLOR_CONFIG(HEADER::TRANSLUCENT_TITLE_TEXT_NORMAL, __transTitleTextColor);
209                         GET_COLOR_CONFIG(HEADER::TRANSLUCENT_DESCRIPTION_TEXT_NORMAL, __transDescriptionTextColor);
210
211                         if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
212                         {
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]);
218
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]);
224                         }
225                         else
226                         {
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]);
232
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]);
238                         }
239
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);
245
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]);
250
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);
255
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]);
260                 }
261                 else // header && not transparent
262                 {
263                         GET_COLOR_CONFIG(HEADER::TITLE_TEXT_NORMAL, __titleTextColor);
264                         GET_COLOR_CONFIG(HEADER::TITLE_TEXT_NORMAL, __descriptionTextColor);
265
266
267                         if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
268                         {
269                                 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_NORMAL])
270                                 {
271                                         GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_NORMAL, __itemBackgroundColor[_BUTTON_STATUS_NORMAL]);
272                                 }
273                                 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_DISABLED])
274                                 {
275                                         GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_DISABLED, __itemBackgroundColor[_BUTTON_STATUS_DISABLED]);
276                                 }
277                                 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_PRESSED])
278                                 {
279                                         GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_PRESSED, __itemBackgroundColor[_BUTTON_STATUS_PRESSED]);
280                                 }
281                                 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
282                                 {
283                                         GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_HIGHLIGHTED, __itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
284                                 }
285                                 //if (!__isItemBgColorSetByUser[_BUTTON_STATUS_SELECTED])
286                                 //{
287                                 //      GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_SELECTED, __itemBackgroundColor[_BUTTON_STATUS_SELECTED]);
288                                 //}
289
290                                 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_NORMAL])
291                                 {
292                                         GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_NORMAL, __itemTextColor[_BUTTON_STATUS_NORMAL]);
293                                 }
294                                 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_DISABLED])
295                                 {
296                                         GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_DISABLED, __itemTextColor[_BUTTON_STATUS_DISABLED]);
297                                 }
298                                 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_PRESSED])
299                                 {
300                                         GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_PRESSED, __itemTextColor[_BUTTON_STATUS_PRESSED]);
301                                 }
302                                 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
303                                 {
304                                         GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_HIGHLIGHTED, __itemTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
305                                 }
306                                 //if (!__isItemTextColorSetByUser[_BUTTON_STATUS_SELECTED])
307                                 //{
308                                 //      GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_SELECTED, __itemTextColor[_BUTTON_STATUS_SELECTED]);
309                                 //}
310                         }
311                         else
312                         {
313                                 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_NORMAL])
314                                 {
315                                         GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_BG_NORMAL, __itemBackgroundColor[_BUTTON_STATUS_NORMAL]);
316                                 }
317                                 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_DISABLED])
318                                 {
319                                         GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_BG_DISABLED, __itemBackgroundColor[_BUTTON_STATUS_DISABLED]);
320                                 }
321                                 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_PRESSED])
322                                 {
323                                         GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_BG_PRESSED, __itemBackgroundColor[_BUTTON_STATUS_PRESSED]);
324                                 }
325                                 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
326                                 {
327                                         GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_BG_HIGHLIGHTED, __itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
328                                 }
329                                 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_SELECTED])
330                                 {
331                                         GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_BG_SELECTED, __itemBackgroundColor[_BUTTON_STATUS_SELECTED]);
332                                 }
333
334                                 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_NORMAL])
335                                 {
336                                         GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TEXT_NORMAL, __itemTextColor[_BUTTON_STATUS_NORMAL]);
337                                 }
338                                 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_DISABLED])
339                                 {
340                                         GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TEXT_DISABLED, __itemTextColor[_BUTTON_STATUS_DISABLED]);
341                                 }
342                                 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_PRESSED])
343                                 {
344                                         GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TEXT_PRESSED, __itemTextColor[_BUTTON_STATUS_PRESSED]);
345                                 }
346                                 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
347                                 {
348                                         GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TEXT_HIGHLIGHTED, __itemTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
349                                 }
350                                 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_SELECTED])
351                                 {
352                                         GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TEXT_SELECTED, __itemTextColor[_BUTTON_STATUS_SELECTED]);
353                                 }
354                         }
355
356                         if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_NORMAL])
357                         {
358                                 GET_COLOR_CONFIG(HEADER::BUTTON_BG_NORMAL, __buttonBackgroundColor[_BUTTON_STATUS_NORMAL]);
359                         }
360                         if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_DISABLED])
361                         {
362                                 GET_COLOR_CONFIG(HEADER::BUTTON_BG_DISABLED, __buttonBackgroundColor[_BUTTON_STATUS_DISABLED]);
363                         }
364                         if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_PRESSED])
365                         {
366                                 GET_COLOR_CONFIG(HEADER::BUTTON_BG_PRESSED, __buttonBackgroundColor[_BUTTON_STATUS_PRESSED]);
367                         }
368                         if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
369                         {
370                                 GET_COLOR_CONFIG(HEADER::BUTTON_BG_HIGHLIGHTED, __buttonBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
371                         }
372
373                         if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_NORMAL])
374                         {
375                                 GET_COLOR_CONFIG(HEADER::BUTTON_TEXT_NORMAL, __buttonTextColor[_BUTTON_STATUS_NORMAL]);
376                         }
377                         if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_DISABLED])
378                         {
379                                 GET_COLOR_CONFIG(HEADER::BUTTON_TEXT_DISABLED, __buttonTextColor[_BUTTON_STATUS_DISABLED]);
380                         }
381                         if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_PRESSED])
382                         {
383                                 GET_COLOR_CONFIG(HEADER::BUTTON_TEXT_PRESSED, __buttonTextColor[_BUTTON_STATUS_PRESSED]);
384                         }
385                         if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
386                         {
387                                 GET_COLOR_CONFIG(HEADER::BUTTON_TEXT_HIGHLIGHTED, __buttonTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
388                         }
389                 }
390         }
391         else
392         {
393                 if (__transparent) // footer && transparent
394                 {
395                         if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
396                         {
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]);
402
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]);
408                         }
409                         else
410                         {
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]);
416
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]);
422                         }
423
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);
429
430
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]);
435
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);
440
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]);
445                 }
446                 else // footer && not transparent
447                 {
448                         if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
449                         {
450                                 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_NORMAL])
451                                 {
452                                         GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_NORMAL, __itemBackgroundColor[_BUTTON_STATUS_NORMAL]);
453                                 }
454                                 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_DISABLED])
455                                 {
456                                         GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_DISABLED, __itemBackgroundColor[_BUTTON_STATUS_DISABLED]);
457                                 }
458                                 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_PRESSED])
459                                 {
460                                         GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_PRESSED, __itemBackgroundColor[_BUTTON_STATUS_PRESSED]);
461                                 }
462                                 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
463                                 {
464                                         GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_HIGHLIGHTED, __itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
465                                 }
466                                 //if (!__isItemBgColorSetByUser[_BUTTON_STATUS_SELECTED])
467                                 //{
468                                 //      GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_SELECTED, __itemBackgroundColor[_BUTTON_STATUS_SELECTED]);
469                                 //}
470
471                                 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_NORMAL])
472                                 {
473                                         GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_NORMAL, __itemTextColor[_BUTTON_STATUS_NORMAL]);
474                                 }
475                                 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_DISABLED])
476                                 {
477                                         GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_DISABLED, __itemTextColor[_BUTTON_STATUS_DISABLED]);
478                                 }
479                                 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_PRESSED])
480                                 {
481                                         GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_PRESSED, __itemTextColor[_BUTTON_STATUS_PRESSED]);
482                                 }
483                                 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
484                                 {
485                                         GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_HIGHLIGHTED, __itemTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
486                                 }
487                                 //if (!__isItemTextColorSetByUser[_BUTTON_STATUS_SELECTED])
488                                 //{
489                                 //      GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_SELECTED, __itemTextColor[_BUTTON_STATUS_SELECTED]);
490                                 //}
491                         }
492                         else
493                         {
494                                 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_NORMAL])
495                                 {
496                                         GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_BG_NORMAL, __itemBackgroundColor[_BUTTON_STATUS_NORMAL]);
497                                 }
498                                 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_DISABLED])
499                                 {
500                                         GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_BG_DISABLED, __itemBackgroundColor[_BUTTON_STATUS_DISABLED]);
501                                 }
502                                 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_PRESSED])
503                                 {
504                                         GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_BG_PRESSED, __itemBackgroundColor[_BUTTON_STATUS_PRESSED]);
505                                 }
506                                 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
507                                 {
508                                         GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_BG_HIGHLIGHTED, __itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
509                                 }
510                                 if (!__isItemBgColorSetByUser[_BUTTON_STATUS_SELECTED])
511                                 {
512                                         GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_BG_SELECTED, __itemBackgroundColor[_BUTTON_STATUS_SELECTED]);
513                                 }
514
515                                 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_NORMAL])
516                                 {
517                                         GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TEXT_NORMAL, __itemTextColor[_BUTTON_STATUS_NORMAL]);
518                                 }
519                                 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_DISABLED])
520                                 {
521                                         GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TEXT_DISABLED, __itemTextColor[_BUTTON_STATUS_DISABLED]);
522                                 }
523                                 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_PRESSED])
524                                 {
525                                         GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TEXT_PRESSED, __itemTextColor[_BUTTON_STATUS_PRESSED]);
526                                 }
527                                 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
528                                 {
529                                         GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TEXT_HIGHLIGHTED, __itemTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
530                                 }
531                                 if (!__isItemTextColorSetByUser[_BUTTON_STATUS_SELECTED])
532                                 {
533                                         GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TEXT_SELECTED, __itemTextColor[_BUTTON_STATUS_SELECTED]);
534                                 }
535                         }
536
537                         if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_NORMAL])
538                         {
539                                 GET_COLOR_CONFIG(FOOTER::BUTTON_BG_NORMAL, __buttonBackgroundColor[_BUTTON_STATUS_NORMAL]);
540                         }
541                         if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_DISABLED])
542                         {
543                                 GET_COLOR_CONFIG(FOOTER::BUTTON_BG_DISABLED, __buttonBackgroundColor[_BUTTON_STATUS_DISABLED]);
544                         }
545                         if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_PRESSED])
546                         {
547                                 GET_COLOR_CONFIG(FOOTER::BUTTON_BG_PRESSED, __buttonBackgroundColor[_BUTTON_STATUS_PRESSED]);
548                         }
549                         if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
550                         {
551                                 GET_COLOR_CONFIG(FOOTER::BUTTON_BG_HIGHLIGHTED, __buttonBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
552                         }
553
554                         if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_NORMAL])
555                         {
556                                 GET_COLOR_CONFIG(FOOTER::BUTTON_TEXT_NORMAL, __buttonTextColor[_BUTTON_STATUS_NORMAL]);
557                         }
558                         if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_DISABLED])
559                         {
560                                 GET_COLOR_CONFIG(FOOTER::BUTTON_TEXT_DISABLED, __buttonTextColor[_BUTTON_STATUS_DISABLED]);
561                         }
562                         if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_PRESSED])
563                         {
564                                 GET_COLOR_CONFIG(FOOTER::BUTTON_TEXT_PRESSED, __buttonTextColor[_BUTTON_STATUS_PRESSED]);
565                         }
566                         if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED])
567                         {
568                                 GET_COLOR_CONFIG(FOOTER::BUTTON_TEXT_HIGHLIGHTED, __buttonTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
569                         }
570                 }
571         }
572
573         return E_SUCCESS;
574 }
575
576 result
577 _Toolbar::InitializeLongPressGesture(void)
578 {
579         result r = E_SUCCESS;
580
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.");
583
584         __pLongPressGesture->SetDuration(300);
585
586         r = AddGestureDetector(*__pLongPressGesture);
587         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to add gesture detector", GetErrorMessage(r));
588
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));
591
592         return r;
593 }
594
595 result
596 _Toolbar::Construct(void)
597 {
598         result r = E_SUCCESS;
599
600         return r;
601 }
602
603 result
604 _Toolbar::AddItem(_Button* pButton)
605 {
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.");
608
609         if (__pActionEventListener != null)
610         {
611                 pButton->AddActionEventListener(*__pActionEventListener);
612         }
613
614         __pItems.push_back(pButton);
615         __itemCount++;
616
617         AttachChild(*pButton);
618
619         ApplyUserGUI(TOOLBAR_ITEM, pButton);
620
621         RearrangeItems();
622
623         AddAccessibilityItem(pButton);
624
625         return E_SUCCESS;
626 }
627
628 Bitmap*
629 _Toolbar::GetBackgroundBitmap(void) const
630 {
631         result r = E_SUCCESS;
632
633         _Toolbar* pToolbar = const_cast<_Toolbar*>(this);
634
635         if (!pToolbar->__pToolbarBackgroundBitmap)
636         {
637                 if(__header == true)
638                 {
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));
641                 }
642                 else
643                 {
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));
646                 }
647         }
648
649         return pToolbar->__pToolbarBackgroundBitmap;
650 }
651
652 _Button*
653 _Toolbar::GetButton(ToolbarButton position) const
654 {
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."));
657
658         return __pButtonItems[position];
659 }
660
661 Color
662 _Toolbar::GetButtonColor(_ButtonStatus status) const
663 {
664         Variant color;
665
666         switch (status)
667         {
668         case _BUTTON_STATUS_NORMAL:
669                 color = GetProperty("normalButtonColor");
670                 break;
671         case _BUTTON_STATUS_DISABLED:
672                 color = GetProperty("disabledButtonColor");
673                 break;
674         case _BUTTON_STATUS_PRESSED:
675                 color = GetProperty("pressedButtonColor");
676                 break;
677         case _BUTTON_STATUS_HIGHLIGHTED:
678                 color = GetProperty("highlightedButtonColor");
679                 break;
680         default:
681                 color = GetProperty("normalButtonColor");
682                 break;
683         }
684
685         return color.ToColor();
686 }
687
688 _ButtonStatus
689 _Toolbar::GetButtonStatus(ToolbarButton position) const
690 {
691         return __pButtonItems[position]->GetButtonStatus();
692 }
693
694 Color
695 _Toolbar::GetButtonTextColor(_ButtonStatus status) const
696 {
697         Variant color;
698
699         switch (status)
700         {
701         case _BUTTON_STATUS_NORMAL:
702                 color = GetProperty("normalButtonTextColor");
703                 break;
704         case _BUTTON_STATUS_DISABLED:
705                 color = GetProperty("disabledButtonTextColor");
706                 break;
707         case _BUTTON_STATUS_PRESSED:
708                 color = GetProperty("pressedButtonTextColor");
709                 break;
710         case _BUTTON_STATUS_HIGHLIGHTED:
711                 color = GetProperty("highlightedButtonTextColor");
712                 break;
713         default:
714                 color = GetProperty("normalButtonTextColor");
715                 break;
716         }
717
718         return color.ToColor();
719 }
720
721 Color
722 _Toolbar::GetColor(void) const
723 {
724         Variant color = GetProperty("color");
725
726         return color.ToColor();
727 }
728
729 String
730 _Toolbar::GetDescriptionText(void) const
731 {
732         Variant text = GetProperty("descriptionText");
733
734         return text.ToString();
735 }
736
737 Color
738 _Toolbar::GetDescriptionTextColor(void) const
739 {
740         Variant color = GetProperty("descriptionTextColor");
741
742         return color.ToColor();
743 }
744
745 int
746 _Toolbar::GetFirstEnabledItemIndex(void) const
747 {
748         int firstEnabledItemIndex = -1;
749
750         for (int i = 0; i < __itemCount; i++)
751         {
752                 if(__pItems.at(i)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
753                 {
754                         firstEnabledItemIndex = i;
755                         break;
756                 }
757         }
758
759         return firstEnabledItemIndex;
760 }
761
762 _Button*
763 _Toolbar::GetItem(int itemIndex) const
764 {
765         if (__pItems.at(itemIndex) == null)
766         {
767                 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Unable to get item.");
768                 return null;
769         }
770
771         return __pItems.at(itemIndex);
772 }
773
774 Color
775 _Toolbar::GetItemColor(_ButtonStatus status) const
776 {
777         Variant color;
778
779         switch (status)
780         {
781         case _BUTTON_STATUS_NORMAL:
782                 color = GetProperty("normalItemColor");
783                 break;
784         case _BUTTON_STATUS_DISABLED:
785                 color = GetProperty("disabledItemColor");
786                 break;
787         case _BUTTON_STATUS_PRESSED:
788                 color = GetProperty("pressedItemColor");
789                 break;
790         case _BUTTON_STATUS_HIGHLIGHTED:
791                 color = GetProperty("highlightedItemColor");
792                 break;
793         case _BUTTON_STATUS_SELECTED:
794                 color = GetProperty("selectedItemColor");
795                 break;
796         default:
797                 color = GetProperty("normalItemColor");
798                 break;
799         }
800
801         return color.ToColor();
802 }
803
804 int
805 _Toolbar::GetItemCount(void) const
806 {
807         return __itemCount;
808 }
809
810 int
811 _Toolbar::GetItemIndexFromPosition(const Point& point) const
812 {
813         if (__itemCount <= 0)
814         {
815                 return -1;
816         }
817
818         for (int i = 0; i < __itemCount; i++)
819         {
820                 Rectangle bounds = __pItems.at(i)->GetBounds();
821
822                 if (bounds.Contains(point) && __pItems.at(i)->GetVisibleState() == true)
823                 {
824                         return i;
825                 }
826         }
827
828         return -1;
829 }
830
831 result
832 _Toolbar::GetItemStatus(int itemIndex, _ButtonStatus& status) const
833 {
834         status = _BUTTON_STATUS_NORMAL;
835
836         SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex <= __itemCount), E_OUT_OF_RANGE,
837                                 "[E_OUT_OF_RANGE] The itemIndex is out of range.");
838
839         status = __pItems.at(itemIndex)->GetButtonStatus();
840
841         return E_SUCCESS;
842 }
843
844 Color
845 _Toolbar::GetItemTextColor(_ButtonStatus status) const
846 {
847         Variant color;
848
849         switch (status)
850         {
851         case _BUTTON_STATUS_NORMAL:
852                 color = GetProperty("normalItemTextColor");
853                 break;
854         case _BUTTON_STATUS_DISABLED:
855                 color = GetProperty("disabledItemTextColor");
856                 break;
857         case _BUTTON_STATUS_PRESSED:
858                 color = GetProperty("pressedItemTextColor");
859                 break;
860         case _BUTTON_STATUS_HIGHLIGHTED:
861                 color = GetProperty("highlightedItemTextColor");
862                 break;
863         case _BUTTON_STATUS_SELECTED:
864                 color = GetProperty("selectedItemTextColor");
865                 break;
866         default:
867                 color = GetProperty("normalItemTextColor");
868                 break;
869         }
870
871         return color.ToColor();
872 }
873
874 int
875 _Toolbar::GetSelectedItemIndex(void) const
876 {
877         if (__pToolbarPresenter)
878         {
879                 return __pToolbarPresenter->GetSelectedItemIndex();
880         }
881
882         return 0;
883 }
884
885 ToolbarStyle
886 _Toolbar::GetStyle(void) const
887 {
888         return ToolbarStyle(__style);
889 }
890
891 Bitmap*
892 _Toolbar::GetTitleIcon(void) const
893 {
894         return __pTitleIcon;
895 }
896
897 String
898 _Toolbar::GetTitleText(void) const
899 {
900         Variant text = GetProperty("titleText");
901         return text.ToString();
902 }
903
904 Color
905 _Toolbar::GetTitleTextColor(void) const
906 {
907         Variant color = GetProperty("titleTextColor");
908         return color.ToColor();
909 }
910
911 HorizontalAlignment
912 _Toolbar::GetTitleTextHorizontalAlignment(void) const
913 {
914         return __titleTextAlignment;
915 }
916
917 bool
918 _Toolbar::IsInitialDraw(void) const
919 {
920         if (__pToolbarPresenter)
921                 return __pToolbarPresenter->IsInitialDraw();
922         else
923                 return false;
924 }
925
926 bool
927 _Toolbar::IsTabEditModeEnabled(void) const
928 {
929         if (__pToolbarPresenter)
930         {
931                 return __pToolbarPresenter->IsTabEditModeEnabled();
932         }
933
934         return false;
935 }
936
937 bool
938 _Toolbar::IsTransparent(void) const
939 {
940         return __transparent;
941 }
942
943
944 AnimationStatus
945 _Toolbar::GetWaitingAnimationStatus(ToolbarAnimationPosition animationPos) const
946 {
947         if (animationPos < TOOLBAR_ANIMATION_POSITION_TITLE || animationPos >= TOOLBAR_ANIMATION_POSITION_MAX)
948         {
949                 return ANIMATION_STOPPED;
950         }
951
952         if (__pAnimation[animationPos] == null)
953         {
954                 return ANIMATION_STOPPED;
955         }
956
957         return __pAnimation[animationPos]->GetStatus();
958 }
959
960 result
961 _Toolbar::InsertItemAt(int itemIndex, _Button* pButton)
962 {
963         SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex <= __itemCount), E_OUT_OF_RANGE,
964                                 "[E_OUT_OF_RANGE] The itemIndex is out of range.");
965
966         if (__pActionEventListener != null)
967         {
968                 pButton->AddActionEventListener(*__pActionEventListener);
969         }
970
971         __pItems.insert(__pItems.begin() + itemIndex, pButton);
972         __itemCount++;
973
974         AttachChild(*pButton);
975
976         ApplyUserGUI(TOOLBAR_ITEM, pButton);
977
978         RearrangeItems();
979         AddAccessibilityItem(pButton);
980
981         return E_SUCCESS;
982 }
983
984 bool
985 _Toolbar::IsButtonSet(ToolbarButton position) const
986 {
987         if (__pButtonItems[position] != null)
988         {
989                 return true;
990         }
991
992         return false;
993 }
994
995 result
996 _Toolbar::MoveItem(const int srcIndex, const int destIndex)
997 {
998         if (srcIndex == destIndex)
999         {
1000                 SetItemSelected(destIndex, true);
1001
1002                 return E_SUCCESS;
1003         }
1004
1005         if (srcIndex < 0 || destIndex < 0 || srcIndex > __itemCount || destIndex > __itemCount)
1006         {
1007                 return E_INVALID_OPERATION;
1008         }
1009
1010         _Button* pSrcButton = null;
1011         pSrcButton = GetItem(srcIndex);
1012
1013         _Button* pDestButton = null;
1014         pDestButton = GetItem(destIndex);
1015
1016         __pItems.erase(__pItems.begin() + destIndex);
1017         __pItems.insert(__pItems.begin() + destIndex, pSrcButton);
1018
1019         __pItems.erase(__pItems.begin() + srcIndex);
1020         __pItems.insert(__pItems.begin() + srcIndex, pDestButton);
1021
1022         for (int i = 0; i < __itemCount; i++)
1023         {
1024                 __pItems.at(i)->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1025         }
1026
1027         SetItemSelected(destIndex, true);
1028
1029         RearrangeItems();
1030
1031         Invalidate(true);
1032
1033         return E_SUCCESS;
1034 }
1035
1036 result
1037 _Toolbar::PauseWaitingAnimation(ToolbarAnimationPosition animationPos)
1038 {
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.");
1044
1045         __pAnimation[animationPos]->Pause();
1046
1047         return E_SUCCESS;
1048 }
1049
1050 result
1051 _Toolbar::PlayWaitingAnimation(ToolbarAnimationPosition animationPos)
1052 {
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.");
1056
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))
1060         {
1061                 return E_UNSUPPORTED_OPERATION;
1062         }
1063
1064         if (__pAnimation[animationPos])
1065         {
1066                 if (__pAnimation[animationPos]->GetStatus() == ANIMATION_PLAYING)
1067                 {
1068                         return E_SUCCESS;
1069                 }
1070         }
1071         else
1072         {
1073                 SetAnimation(animationPos);
1074         }
1075
1076         if (__pAnimation[animationPos])
1077         {
1078                 __pAnimation[animationPos]->Play();
1079         }
1080
1081         return E_SUCCESS;
1082 }
1083
1084 result
1085 _Toolbar::RemoveAllButtons(void)
1086 {
1087         for (int i = 0; i < BUTTON_MAX; i++)
1088         {
1089                 _Button* pButtonItem = __pButtonItems[i];
1090
1091                 if (pButtonItem != null)
1092                 {
1093                          if (i == LEFT_BUTTON)
1094                         {
1095                                  StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT);
1096                         }
1097                         else if (i == RIGHT_BUTTON)
1098                         {
1099                                 StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT);
1100                         }
1101
1102                         if (pButtonItem->GetChildCount() != 0)
1103                         {
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.");
1106
1107                                 pButtonItem->DetachChild(*pTempBadgeIcon);
1108
1109                                 delete pTempBadgeIcon;
1110                                 pTempBadgeIcon = null;
1111                         }
1112
1113                         DetachChild(*pButtonItem);
1114                         delete pButtonItem;
1115                         pButtonItem = null;
1116
1117                         __pButtonItems[i] = null;
1118                 }
1119         }
1120
1121         return E_SUCCESS;
1122 }
1123
1124 result
1125 _Toolbar::RemoveAllItems(void)
1126 {
1127         __itemCount = 0;
1128
1129         int itemCount = __pItems.size();
1130
1131         _Button* pItem = null;
1132
1133         // frees item nodes from the memory
1134         if (itemCount > 0)
1135         {
1136                 for (int i = itemCount - 1; i >= 0; i--)
1137                 {
1138                         pItem = __pItems.at(i);
1139
1140                         if (pItem != null)
1141                         {
1142                                 if (pItem->GetChildCount() != 0)
1143                                 {
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.");
1146
1147                                         pItem->DetachChild(*pTempBadgeIcon);
1148
1149                                         delete pTempBadgeIcon;
1150                                         pTempBadgeIcon = null;
1151                                 }
1152
1153                                 DetachChild(*pItem);
1154                                 delete pItem;
1155
1156                                 pItem = null;
1157                         }
1158                 }
1159         }
1160
1161         // clears vector
1162         __pItems.clear();
1163
1164         if (__pToolbarPresenter)
1165         {
1166                 __pToolbarPresenter->SetInitialDrawState(true);
1167         }
1168
1169         SetItemSelected(-1);
1170
1171         return E_SUCCESS;
1172 }
1173
1174 result
1175 _Toolbar::RemoveButtonAt(ToolbarButton position)
1176 {
1177         if (__pButtonItems[position] != null)
1178         {
1179                 if (position == LEFT_BUTTON)
1180                 {
1181                         StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT);
1182                 }
1183                 else if (position == RIGHT_BUTTON)
1184                 {
1185                         StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT);
1186                 }
1187
1188                 DetachChild(*__pButtonItems[position]);
1189                 delete __pButtonItems[position];
1190                 __pButtonItems[position] = null;
1191         }
1192
1193         return E_SUCCESS;
1194 }
1195
1196 result
1197 _Toolbar::RemoveItemAt(int itemIndex)
1198 {
1199         SysTryReturnResult(NID_UI_CTRL, (__itemCount > 0 && itemIndex < __itemCount && itemIndex >= 0), E_INVALID_ARG,
1200                                 "[E_INVALID_ARG] itemIndex is invalid.");
1201
1202         _Button* pItem = __pItems.at(itemIndex);
1203
1204         SysTryReturnResult(NID_UI_CTRL, (pItem != null), E_INVALID_STATE, "[E_INVALID_ARG] No item at the designated index.");
1205
1206         if (pItem->GetChildCount() != 0)
1207         {
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.");
1210
1211                 pItem->DetachChild(*pTempBadgeIcon);
1212
1213                 delete pTempBadgeIcon;
1214                 pTempBadgeIcon = null;
1215         }
1216
1217         // Free 'pItem' from the item nodes
1218         DetachChild(*pItem);
1219         delete pItem;
1220         pItem = null;
1221
1222         __itemCount--;
1223
1224         __pItems.erase(__pItems.begin() + itemIndex);
1225
1226         return E_SUCCESS;
1227 }
1228
1229 result
1230 _Toolbar::SetBackgroundBitmap(const Bitmap& bitmap)
1231 {
1232         result r = E_SYSTEM;
1233
1234         Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap);
1235
1236         if (pClonedBitmap)
1237         {
1238                 if (__pToolbarBackgroundBitmap)
1239                 {
1240                         delete __pToolbarBackgroundBitmap;
1241                 }
1242
1243                 __pToolbarBackgroundBitmap = pClonedBitmap;
1244                 __isUserBackgroundBitmap = true;
1245
1246                 r = E_SUCCESS;
1247         }
1248
1249         return r;
1250 }
1251
1252 bool
1253 _Toolbar::IsUserBackgroundBitmap() const
1254 {
1255         return __isUserBackgroundBitmap;
1256 }
1257
1258 result
1259 _Toolbar::SetButton(ToolbarButton position, _Button* pButton)
1260 {
1261         SysTryReturnResult(NID_UI_CTRL, (pButton), E_INVALID_ARG, "[E_INVALID_ARG] The pButton is invalid.");
1262
1263         int buttonWidth = pButton->GetSize().width;
1264
1265         int toolbarWidth = GetBounds().width;
1266
1267         if (CalculateMinimumToolbarWidth() > toolbarWidth)
1268         {
1269                 toolbarWidth = CalculateMinimumToolbarWidth();
1270         }
1271
1272         int horizontalMargin = 0;
1273         int verticalMargin = 0;
1274
1275         if (__header == true && __style != TOOLBAR_TEXT)
1276         {
1277                 int buttonItemGap = 0;
1278                 int buttonTopMargin = 0;
1279
1280                 if (__style == TOOLBAR_TITLE)
1281                 {
1282                         GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_TOP_MARGIN, GetOrientation(), buttonTopMargin);
1283                 }
1284                 else if (__style == TOOLBAR_HEADER_SEGMENTED)
1285                 {
1286                         GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_TOP_MARGIN_OF_SEGMENTED, GetOrientation(), buttonTopMargin);
1287                 }
1288
1289                 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_GAP, GetOrientation(), buttonItemGap);
1290
1291
1292                 switch (position)
1293                 {
1294                 case RIGHT_BUTTON:
1295                         if (__pButtonItems[LEFT_BUTTON])
1296                         {
1297                                 pButton->SetPosition(Point(toolbarWidth - buttonWidth , buttonTopMargin));
1298                                 __pButtonItems[LEFT_BUTTON]->SetPosition(Point(toolbarWidth - buttonWidth *2 - buttonItemGap, buttonTopMargin));
1299                         }
1300                         else
1301                         {
1302                                 pButton->SetPosition(Point(toolbarWidth - buttonWidth , buttonTopMargin));
1303                         }
1304                         break;
1305                 case LEFT_BUTTON:
1306                         if (__pButtonItems[RIGHT_BUTTON])
1307                         {
1308                                 pButton->SetPosition(Point(toolbarWidth - buttonWidth * 2 - buttonItemGap, buttonTopMargin));
1309                         }
1310                         else
1311                         {
1312                                 pButton->SetPosition(Point(toolbarWidth - buttonWidth, buttonTopMargin));
1313                         }
1314                         break;
1315
1316                 default:
1317                         break;
1318                 }
1319         }
1320         else // footer or HEADER_STYLE_BUTTON
1321         {
1322                 switch (position)
1323                 {
1324                         case LEFT_BUTTON:
1325                                 pButton->SetPosition(Point(horizontalMargin, verticalMargin));
1326                                 break;
1327
1328                         case RIGHT_BUTTON:
1329                                 pButton->SetPosition(Point(toolbarWidth - buttonWidth - horizontalMargin, verticalMargin));
1330                                 break;
1331
1332                         case BACK_BUTTON:
1333                                 pButton->SetPosition(Point(toolbarWidth - buttonWidth, 0));
1334                                 if (__pBackEventListener)
1335                                 {
1336                                         pButton->AddActionEventListener(*__pBackEventListener);
1337                                         pButton->SetActionId(__backActionId);
1338                                 }
1339                                 break;
1340
1341                         case MIDDLE_BUTTON:
1342                                 pButton->SetPosition(Point((toolbarWidth - buttonWidth - horizontalMargin)/2, verticalMargin));
1343                                 break;
1344
1345                         default:
1346                                 break;
1347                 }
1348         }
1349
1350         if (position != BACK_BUTTON && __pActionEventListener != null)
1351         {
1352                 pButton->AddActionEventListener(*__pActionEventListener);
1353         }
1354
1355         if (__pButtonItems[position])
1356         {
1357                 if (position == LEFT_BUTTON)
1358                 {
1359                         StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT);
1360                 }
1361                 else if (position == RIGHT_BUTTON)
1362                 {
1363                         StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT);
1364                 }
1365
1366                 if (__pButtonItems[position]->GetChildCount() != 0)
1367                 {
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.");
1370
1371                         __pButtonItems[position]->DetachChild(*pTempBadgeIcon);
1372
1373                         delete pTempBadgeIcon;
1374                         pTempBadgeIcon = null;
1375                 }
1376
1377                 DetachChild(*__pButtonItems[position]);
1378
1379                 delete __pButtonItems[position];
1380                 __pButtonItems[position] = null;
1381         }
1382
1383         __pButtonItems[position] = pButton;
1384
1385         AttachChild(*pButton);
1386
1387         if (__style != TOOLBAR_SOFTKEY)
1388         {
1389                 ApplyUserGUI(TOOLBAR_BUTTON, __pButtonItems[position]);
1390         }
1391
1392         RearrangeItems();
1393
1394         return E_SUCCESS;
1395 }
1396
1397 result
1398 _Toolbar::SetButtonColor(_ButtonStatus status, const Color& color)
1399 {
1400         switch (status)
1401         {
1402         case _BUTTON_STATUS_NORMAL:
1403                 __isButtonBgColorSetByUser[_BUTTON_STATUS_NORMAL] = true;
1404                 return SetProperty("normalButtonColor", Variant(color));
1405                 break;
1406         case _BUTTON_STATUS_DISABLED:
1407                 __isButtonBgColorSetByUser[_BUTTON_STATUS_DISABLED] = true;
1408                 return SetProperty("disabledButtonColor", Variant(color));
1409                 break;
1410         case _BUTTON_STATUS_PRESSED:
1411                 __isButtonBgColorSetByUser[_BUTTON_STATUS_PRESSED] = true;
1412                 return SetProperty("pressedButtonColor", Variant(color));
1413                 break;
1414         case _BUTTON_STATUS_HIGHLIGHTED:
1415                 __isButtonBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED] = true;
1416                 return SetProperty("highlightedButtonColor", Variant(color));
1417                 break;
1418         default:
1419                 __isButtonBgColorSetByUser[_BUTTON_STATUS_NORMAL] = true;
1420                 return SetProperty("normalButtonColor", Variant(color));
1421                 break;
1422         }
1423 }
1424
1425 result
1426 _Toolbar::SetButtonEnabled(ToolbarButton position, bool enabled)
1427 {
1428         SysTryReturnResult(NID_UI_CTRL, __pButtonItems[position], E_INVALID_OPERATION,
1429                                 "[E_INVALID_OPERATION] No button item is at the position.");
1430
1431         if (enabled)
1432         {
1433                 __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1434         }
1435         else
1436         {
1437                 __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_DISABLED);
1438         }
1439
1440         return E_SUCCESS;
1441 }
1442
1443 result
1444 _Toolbar::SetButtonTextColor(_ButtonStatus status, const Color& color)
1445 {
1446         switch (status)
1447         {
1448         case _BUTTON_STATUS_NORMAL:
1449                 __isButtonTextColorSetByUser[_BUTTON_STATUS_NORMAL] = true;
1450                 return SetProperty("normalButtonTextColor", Variant(color));
1451                 break;
1452         case _BUTTON_STATUS_DISABLED:
1453                 __isButtonTextColorSetByUser[_BUTTON_STATUS_DISABLED] = true;
1454                 return SetProperty("disabledButtonTextColor", Variant(color));
1455                 break;
1456         case _BUTTON_STATUS_PRESSED:
1457                 __isButtonTextColorSetByUser[_BUTTON_STATUS_PRESSED] = true;
1458                 return SetProperty("pressedButtonTextColor", Variant(color));
1459                 break;
1460         case _BUTTON_STATUS_HIGHLIGHTED:
1461                 __isButtonTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED] = true;
1462                 return SetProperty("highlightedButtonTextColor", Variant(color));
1463                 break;
1464         default:
1465                 __isButtonTextColorSetByUser[_BUTTON_STATUS_NORMAL] = true;
1466                 return SetProperty("normalButtonTextColor", Variant(color));
1467                 break;
1468         }
1469 }
1470
1471 result
1472 _Toolbar::SetButtonBadgeIcon(ToolbarButton position, const Bitmap* pBadgeIcon)
1473 {
1474         int childCount = 0;
1475
1476         childCount = __pButtonItems[position]->GetChildCount();
1477
1478         if (childCount != 0)
1479         {
1480                 for(int i = 0; i < childCount; i++)
1481                 {
1482                         _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pButtonItems[position]->GetChild(i));
1483
1484                         if (pTempBadgeIcon)
1485                         {
1486                                 __pButtonItems[position]->DetachChild(*pTempBadgeIcon);
1487
1488                                 delete pTempBadgeIcon;
1489                                 pTempBadgeIcon = null;
1490                         }
1491                 }
1492         }
1493
1494         if (pBadgeIcon == null)
1495         {
1496                 return E_SUCCESS;
1497         }
1498
1499         Rectangle bounds = __pButtonItems[position]->GetBounds();
1500
1501         _Label* pBadgeIconLabel = _Label::CreateLabelN();
1502
1503         if (pBadgeIconLabel)
1504         {
1505                 pBadgeIconLabel->SetBounds(Rectangle((bounds.width - pBadgeIcon->GetWidth()), 0,
1506                                 pBadgeIcon->GetWidth(), pBadgeIcon->GetHeight()));
1507                 pBadgeIconLabel->SetBackgroundBitmap(*pBadgeIcon);
1508
1509                 __pButtonItems[position]->AttachChild(*pBadgeIconLabel);
1510                 __pButtonItems[position]->SetChildAlwaysOnTop(*pBadgeIconLabel);
1511         }
1512
1513         return E_SUCCESS;
1514 }
1515
1516 result
1517 _Toolbar::SetButtonNumberedBadgeIcon(ToolbarButton position, int number)
1518 {
1519         int childCount = 0;
1520
1521         childCount = __pButtonItems[position]->GetChildCount();
1522
1523         _Label* existingBadgeIcon = null;
1524
1525         if (number == 0)
1526         {
1527                 if (childCount != 0)
1528                 {
1529                         for(int i = 0; i < childCount; i++)
1530                         {
1531                                 existingBadgeIcon = dynamic_cast<_Label*>(__pButtonItems[position]->GetChild(i));
1532
1533                                 if (existingBadgeIcon)
1534                                 {
1535                                         __pButtonItems[position]->DetachChild(*existingBadgeIcon);
1536
1537                                         delete existingBadgeIcon;
1538                                         existingBadgeIcon = null;
1539                                 }
1540                         }
1541                 }
1542                 else
1543                 {
1544                         return E_SUCCESS;
1545                 }
1546         }
1547         else
1548         {
1549                 bool needToCreateNewIcon = true;
1550
1551                 if (childCount != 0)
1552                 {
1553                         for(int i = 0; i < childCount; i++)
1554                         {
1555                                 existingBadgeIcon = dynamic_cast<_Label*>(__pButtonItems[position]->GetChild(i));
1556
1557                                 if (existingBadgeIcon)
1558                                 {
1559                                         if (existingBadgeIcon->GetText() == L"")
1560                                         {
1561                                                 __pButtonItems[position]->DetachChild(*existingBadgeIcon);
1562
1563                                                 delete existingBadgeIcon;
1564                                                 existingBadgeIcon = null;
1565
1566                                                 needToCreateNewIcon = true;
1567                                         }
1568                                         else
1569                                         {
1570                                                 needToCreateNewIcon = false;
1571                                         }
1572                                 }
1573                         }
1574                 }
1575
1576                 if (needToCreateNewIcon)
1577                 {
1578                         _Label* pLabel = _Label::CreateLabelN();
1579
1580                         SysTryReturnResult(NID_UI_CTRL, pLabel, E_INVALID_STATE,
1581                                                 "[E_INVALID_STATE] The badge icon instance isn't constructed.");
1582
1583                         Bitmap* pNumberedBadgeIconBitmap = null;
1584                         Bitmap* pNumberedBadgeIconEffectBitmap = null;
1585                         Bitmap* pColorReplacedBitmap = null;
1586                         Color badgeIconBgColor;
1587                         Color badgeIconTextColor;
1588
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);
1591
1592                         GET_COLOR_CONFIG(HEADER::BADGE_ICON_BG_NORMAL, badgeIconBgColor);
1593                         GET_COLOR_CONFIG(HEADER::BADGE_ICON_TEXT_NORMAL, badgeIconTextColor);
1594
1595                         if (pNumberedBadgeIconBitmap)
1596                         {
1597                                 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNumberedBadgeIconBitmap,
1598                                                 Color::GetColor(COLOR_ID_MAGENTA), badgeIconBgColor);
1599
1600                                 pLabel->SetBackgroundBitmap(*pColorReplacedBitmap);
1601
1602                                 delete pColorReplacedBitmap;
1603                                 delete pNumberedBadgeIconBitmap;
1604                         }
1605
1606                         if (pNumberedBadgeIconEffectBitmap)
1607                         {
1608                                 pLabel->SetBackgroundEffectBitmap(*pNumberedBadgeIconEffectBitmap);
1609
1610                                 delete pNumberedBadgeIconEffectBitmap;
1611                         }
1612
1613                         pLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
1614                         pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1615                         pLabel->SetTextColor(badgeIconTextColor);
1616                         pLabel->SetMargin(0, 0);
1617
1618                         __pButtonItems[position]->AttachChild(*pLabel);
1619                         __pButtonItems[position]->SetChildAlwaysOnTop(*pLabel);
1620
1621                         existingBadgeIcon = pLabel;
1622                 }
1623
1624                 SysTryReturnResult(NID_UI_CTRL, (existingBadgeIcon), E_INVALID_STATE, "[E_INVALID_STATE] Failed to set a BadgeIcon.");
1625
1626                 Rectangle bounds = __pButtonItems[position]->GetBounds();
1627
1628                 Integer tempNumber(number);
1629
1630                 if (existingBadgeIcon)
1631                 {
1632                         existingBadgeIcon->SetText(tempNumber.ToString());
1633
1634                         int fontSize = 0;
1635                         int height = 0;
1636                         int width = 0;
1637
1638                         GET_SHAPE_CONFIG(HEADER::BADGE_FONT_SIZE, GetOrientation(), fontSize);
1639                         GET_SHAPE_CONFIG(HEADER::BADGE_HEIGHT, GetOrientation(), height);
1640
1641                         existingBadgeIcon->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1642
1643                         if (number < 10)
1644                         {
1645                                 GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_1DIGIT, GetOrientation(), width);
1646                                 existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height));
1647                         }
1648                         else if (number < 100)
1649                         {
1650                                 GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_2DIGIT, GetOrientation(), width);
1651                                 existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height));
1652                         }
1653                         else if (number < 1000)
1654                         {
1655                                 GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_3DIGIT, GetOrientation(), width);
1656                                 existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height));
1657                         }
1658                         else if (number < 10000)
1659                         {
1660                                 GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_4DIGIT, GetOrientation(), width);
1661                                 existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height));
1662                         }
1663                         else
1664                         {
1665                                 GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_5DIGIT, GetOrientation(), width);
1666                                 existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height));
1667                         }
1668                 }
1669         }
1670
1671         return E_SUCCESS;
1672 }
1673
1674 result
1675 _Toolbar::SetColor(const Color& color)
1676 {
1677         return SetProperty("color", Variant(color));
1678 }
1679
1680 result
1681 _Toolbar::SetDescriptionText(const String& text)
1682 {
1683         return SetProperty("descriptionText", Variant(text));
1684 }
1685
1686 result
1687 _Toolbar::SetDescriptionTextColor(const Color& color)
1688 {
1689         return SetProperty("descriptionTextColor", Variant(color));
1690 }
1691
1692 result
1693 _Toolbar::SetItemAt(int itemIndex, const _Button* pButton)
1694 {
1695         SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < __itemCount), E_OUT_OF_RANGE,
1696                                 "[E_OUT_OF_RANGE] The itemIndex is out of range.");
1697
1698         if (pButton->GetActionId() < TOOLBAR_ACTION_ID_MIN || pButton->GetActionId() > TOOLBAR_ACTION_ID_MAX)
1699         {
1700                 SysLog(NID_UI_CTRL, "[E_INVALID_ARG] The actionId is invalid.");
1701                 return E_OUT_OF_RANGE;
1702         }
1703
1704         SysTryReturnResult(NID_UI_CTRL, (null != __pItems.at(itemIndex)), E_INVALID_OPERATION,
1705                                 "[E_INVALID_OPERATION] No button item is at the position.");
1706
1707         if (__pItems.at(itemIndex)->GetChildCount() != 0)
1708         {
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.");
1711
1712                 __pItems.at(itemIndex)->DetachChild(*pTempBadgeIcon);
1713
1714                 delete pTempBadgeIcon;
1715                 pTempBadgeIcon = null;
1716         }
1717
1718         __pItems.at(itemIndex)->SetText(pButton->GetText());
1719         __pItems.at(itemIndex)->SetActionId(pButton->GetActionId());
1720
1721         Bitmap* pIconBitmap = null;
1722         Point iconPosition = Point(0,0);
1723
1724         pIconBitmap = const_cast<Bitmap*>(pButton->GetBitmap(_BUTTON_STATUS_NORMAL));
1725
1726         if (pIconBitmap)
1727         {
1728                 iconPosition = pButton->GetBitmapPosition(_BUTTON_STATUS_NORMAL);
1729
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);
1735         }
1736
1737         pIconBitmap = const_cast<Bitmap*>(pButton->GetBitmap(_BUTTON_STATUS_PRESSED));
1738
1739         if (pIconBitmap)
1740         {
1741                 iconPosition = pButton->GetBitmapPosition(_BUTTON_STATUS_PRESSED);
1742
1743                 __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_PRESSED, iconPosition, *pIconBitmap);
1744         }
1745
1746         pIconBitmap = const_cast<Bitmap*>(pButton->GetBitmap(_BUTTON_STATUS_SELECTED));
1747
1748         if (pIconBitmap)
1749         {
1750                 iconPosition = pButton->GetBitmapPosition(_BUTTON_STATUS_SELECTED);
1751
1752                 __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_SELECTED, iconPosition, *pIconBitmap);
1753         }
1754
1755         pIconBitmap = const_cast<Bitmap*>(pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED));
1756
1757         if (pIconBitmap)
1758         {
1759                 iconPosition = pButton->GetBitmapPosition(_BUTTON_STATUS_HIGHLIGHTED);
1760
1761                 __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_HIGHLIGHTED, iconPosition, *pIconBitmap);
1762         }
1763
1764         pIconBitmap = const_cast<Bitmap*>(pButton->GetBitmap(_BUTTON_STATUS_DISABLED));
1765
1766         if (pIconBitmap)
1767         {
1768                 iconPosition = pButton->GetBitmapPosition(_BUTTON_STATUS_DISABLED);
1769
1770                 __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_DISABLED, iconPosition, *pIconBitmap);
1771         }
1772
1773         ApplyUserGUI(TOOLBAR_ITEM, __pItems.at(itemIndex));
1774
1775         RearrangeItems();
1776
1777         RealignIcon(__pItems.at(itemIndex));
1778
1779         delete pButton;
1780
1781         return E_SUCCESS;
1782 }
1783
1784 result
1785 _Toolbar::SetItemBadgeIcon(int itemIndex, const Bitmap* pBadgeIcon)
1786 {
1787         SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < __itemCount), E_INVALID_ARG,
1788                                 "[E_INVALID_ARG] The itemIndex is invalid.");
1789
1790         SysTryReturnResult(NID_UI_CTRL, (__pItems.at(itemIndex)), E_INVALID_STATE,
1791                                 "[E_INVALID_STATE] The badge icon instance isn't constructed.");
1792
1793         if (__pItems.at(itemIndex)->GetChildCount() != 0)
1794         {
1795                 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pItems.at(itemIndex)->GetChild(0));
1796
1797                 if (pTempBadgeIcon)
1798                 {
1799                         __pItems.at(itemIndex)->DetachChild(*pTempBadgeIcon);
1800
1801                         delete pTempBadgeIcon;
1802                         pTempBadgeIcon = null;
1803                 }
1804         }
1805
1806         if (pBadgeIcon == null)
1807         {
1808                 return E_SUCCESS;
1809         }
1810
1811         Rectangle bounds = __pItems.at(itemIndex)->GetBounds();
1812
1813         _Label* pBadgeIconLabel = _Label::CreateLabelN();
1814
1815         if (pBadgeIconLabel)
1816         {
1817                 pBadgeIconLabel->SetBounds(Rectangle((bounds.width - pBadgeIcon->GetWidth()), 0,
1818                                 pBadgeIcon->GetWidth(), pBadgeIcon->GetHeight()));
1819                 pBadgeIconLabel->SetBackgroundBitmap(*pBadgeIcon);
1820
1821                 __pItems.at(itemIndex)->AttachChild(*pBadgeIconLabel);
1822                 __pItems.at(itemIndex)->SetChildAlwaysOnTop(*pBadgeIconLabel);
1823         }
1824
1825         return E_SUCCESS;
1826 }
1827
1828 result
1829 _Toolbar::SetItemColor(_ButtonStatus status, const Color& color)
1830 {
1831         switch (status)
1832         {
1833         case _BUTTON_STATUS_NORMAL:
1834                 __isItemBgColorSetByUser[_BUTTON_STATUS_NORMAL] = true;
1835                 return SetProperty("normalItemColor", Variant(color));
1836                 break;
1837         case _BUTTON_STATUS_DISABLED:
1838                 __isItemBgColorSetByUser[_BUTTON_STATUS_DISABLED] = true;
1839                 return SetProperty("disabledItemColor", Variant(color));
1840                 break;
1841         case _BUTTON_STATUS_PRESSED:
1842                 __isItemBgColorSetByUser[_BUTTON_STATUS_PRESSED] = true;
1843                 return SetProperty("pressedItemColor", Variant(color));
1844                 break;
1845         case _BUTTON_STATUS_HIGHLIGHTED:
1846                 __isItemBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED] = true;
1847                 return SetProperty("highlightedItemColor", Variant(color));
1848                 break;
1849         case _BUTTON_STATUS_SELECTED:
1850                 __isItemBgColorSetByUser[_BUTTON_STATUS_SELECTED] = true;
1851                 return SetProperty("selectedItemColor", Variant(color));
1852                 break;
1853         default:
1854                 __isItemBgColorSetByUser[_BUTTON_STATUS_NORMAL] = true;
1855                 return SetProperty("normalItemColor", Variant(color));
1856                 break;
1857         }
1858 }
1859
1860 result
1861 _Toolbar::SetItemEnabled(int itemIndex, bool enabled)
1862 {
1863         SysTryReturnResult(NID_UI_CTRL, (null != __pItems.at(itemIndex)), E_INVALID_OPERATION,
1864                                 "[E_INVALID_OPERATION] No button item is at the position.");
1865
1866         if (enabled)
1867         {
1868                 return __pItems.at(itemIndex)->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1869         }
1870         else
1871         {
1872                 return __pItems.at(itemIndex)->SetButtonStatus(_BUTTON_STATUS_DISABLED);
1873         }
1874
1875         return E_SUCCESS;
1876 }
1877
1878 result
1879 _Toolbar::SetItemNumberedBadgeIcon(int itemIndex, int number)
1880 {
1881         SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < __itemCount), E_INVALID_ARG,
1882                                 "[E_INVALID_ARG] The itemIndex is invalid.");
1883
1884         SysTryReturnResult(NID_UI_CTRL, (number >= 0 && number < 100000), E_INVALID_ARG,
1885                                 "[E_INVALID_ARG] The number is out of bounds.");
1886
1887         SysTryReturnResult(NID_UI_CTRL, (__pItems.at(itemIndex)), E_INVALID_STATE,
1888                                 "[E_INVALID_STATE] The badge icon instance isn't constructed.");
1889
1890         if (number == 0)
1891         {
1892                 if (__pItems.at(itemIndex)->GetChildCount() != 0)
1893                 {
1894                         _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(itemIndex)->GetChild(0));
1895
1896                         if (existingBadgeIcon)
1897                         {
1898                                 __pItems.at(itemIndex)->DetachChild(*existingBadgeIcon);
1899
1900                                 delete existingBadgeIcon;
1901                                 existingBadgeIcon = null;
1902                         }
1903                 }
1904                 else
1905                 {
1906                         return E_SUCCESS;
1907                 }
1908         }
1909         else
1910         {
1911                 if (__pItems.at(itemIndex)->GetChildCount() == 0)
1912                 {
1913                         _Label* pLabel = _Label::CreateLabelN();
1914
1915                         SysTryReturnResult(NID_UI_CTRL, pLabel, E_INVALID_STATE,
1916                                                 "[E_INVALID_STATE] The badge icon instance isn't constructed.");
1917
1918                         Bitmap* pNumberedBadgeIconBitmap = null;
1919                         Bitmap* pNumberedBadgeIconEffectBitmap = null;
1920                         Bitmap* pColorReplacedBitmap = null;
1921                         Color badgeIconBgColor;
1922                         Color badgeIconTextColor;
1923
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);
1926
1927                         GET_COLOR_CONFIG(HEADER::BADGE_ICON_BG_NORMAL, badgeIconBgColor);
1928                         GET_COLOR_CONFIG(HEADER::BADGE_ICON_TEXT_NORMAL, badgeIconTextColor);
1929
1930                         if (pNumberedBadgeIconBitmap)
1931                         {
1932                                 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNumberedBadgeIconBitmap,
1933                                                 Color::GetColor(COLOR_ID_MAGENTA), badgeIconBgColor);
1934
1935                                 pLabel->SetBackgroundBitmap(*pColorReplacedBitmap);
1936
1937                                 delete pColorReplacedBitmap;
1938                                 delete pNumberedBadgeIconBitmap;
1939                         }
1940
1941                         if (pNumberedBadgeIconEffectBitmap)
1942                         {
1943                                 pLabel->SetBackgroundEffectBitmap(*pNumberedBadgeIconEffectBitmap);
1944
1945                                 delete pNumberedBadgeIconEffectBitmap;
1946                         }
1947
1948                         pLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
1949                         pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
1950                         pLabel->SetTextColor(badgeIconTextColor);
1951                         pLabel->SetMargin(0, 0);
1952
1953                         __pItems.at(itemIndex)->AttachChild(*pLabel);
1954                         __pItems.at(itemIndex)->SetChildAlwaysOnTop(*pLabel);
1955                 }
1956
1957                 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(itemIndex)->GetChild(0));
1958
1959                 Rectangle bounds = __pItems.at(itemIndex)->GetBounds();
1960
1961                 Integer tempNumber(number);
1962
1963                 if (existingBadgeIcon)
1964                 {
1965                         existingBadgeIcon->SetText(tempNumber.ToString());
1966
1967                         int fontSize = 0;
1968                         int height = 0;
1969                         int width = 0;
1970
1971                         GET_SHAPE_CONFIG(HEADER::BADGE_FONT_SIZE, GetOrientation(), fontSize);
1972                         GET_SHAPE_CONFIG(HEADER::BADGE_HEIGHT, GetOrientation(), height);
1973
1974                         existingBadgeIcon->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1975
1976                         if (number < 10)
1977                         {
1978                                 GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_1DIGIT, GetOrientation(), width);
1979                                 existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height));
1980                         }
1981                         else if (number < 100)
1982                         {
1983                                 GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_2DIGIT, GetOrientation(), width);
1984                                 existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height));
1985                         }
1986                         else if (number < 1000)
1987                         {
1988                                 GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_3DIGIT, GetOrientation(), width);
1989                                 existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height));
1990                         }
1991                         else if (number < 10000)
1992                         {
1993                                 GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_4DIGIT, GetOrientation(), width);
1994                                 existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height));
1995                         }
1996                         else
1997                         {
1998                                 GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_5DIGIT, GetOrientation(), width);
1999                                 existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height));
2000                         }
2001                 }
2002         }
2003
2004         return E_SUCCESS;
2005 }
2006
2007 result
2008 _Toolbar::SetItemSelected(int itemIndex, bool fire)
2009 {
2010         SysTryReturnResult(NID_UI_CTRL, (itemIndex >= -1 && itemIndex < __itemCount), E_INVALID_STATE,
2011                                         "[E_INVALID_STATE] Failed to process SetItemSelected()");
2012
2013         result r = E_SUCCESS;
2014
2015         int currentSelectedItemIndex = 0;
2016         currentSelectedItemIndex = GetSelectedItemIndex();
2017
2018         if (__pToolbarPresenter)
2019         {
2020                 r = __pToolbarPresenter->SetItemSelected(itemIndex);
2021         }
2022
2023         if (itemIndex != -1 && itemIndex == currentSelectedItemIndex && __pItems.at(itemIndex) != null)
2024         {
2025                 __pItems.at(itemIndex)->SetButtonStatus(_BUTTON_STATUS_SELECTED, fire);
2026                 __pItems.at(itemIndex)->Draw();
2027
2028                 return r;
2029         }
2030
2031         if (__itemCount == 0 || __itemCount > TAB_ITEM_MAX || itemIndex == -1)
2032         {
2033                 return r;
2034         }
2035
2036         SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_INVALID_STATE, "[E_INVALID_STATE] Failed to process SetItemSelected()");
2037
2038         if (__pItems.at(itemIndex) != null)
2039         {
2040                 __pItems.at(itemIndex)->SetButtonStatus(_BUTTON_STATUS_SELECTED, fire);
2041         }
2042
2043         if (__itemCount == 0 || __itemCount > TAB_ITEM_MAX || itemIndex == -1)
2044         {
2045                 return r;
2046         }
2047
2048         if (currentSelectedItemIndex != -1 && __pItems.at(currentSelectedItemIndex) != null)
2049         {
2050                 __pItems.at(currentSelectedItemIndex)->SetButtonStatus(_BUTTON_STATUS_NORMAL);
2051                 __pItems.at(currentSelectedItemIndex)->Draw();
2052         }
2053
2054         if (__pItems.at(itemIndex) != null)
2055         {
2056                 __pItems.at(itemIndex)->Draw();
2057         }
2058
2059         return r;
2060 }
2061
2062 result
2063 _Toolbar::SetItemTextColor(_ButtonStatus status, const Color& color)
2064 {
2065         switch(status)
2066         {
2067         case _BUTTON_STATUS_NORMAL:
2068                 __isItemTextColorSetByUser[_BUTTON_STATUS_NORMAL] = true;
2069                 return SetProperty("normalItemTextColor", Variant(color));
2070                 break;
2071         case _BUTTON_STATUS_DISABLED:
2072                 __isItemTextColorSetByUser[_BUTTON_STATUS_DISABLED] = true;
2073                 return SetProperty("disabledItemTextColor", Variant(color));
2074                 break;
2075         case _BUTTON_STATUS_PRESSED:
2076                 __isItemTextColorSetByUser[_BUTTON_STATUS_PRESSED] = true;
2077                 return SetProperty("pressedItemTextColor", Variant(color));
2078                 break;
2079         case _BUTTON_STATUS_HIGHLIGHTED:
2080                 __isItemTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED] = true;
2081                 return SetProperty("highlightedItemTextColor", Variant(color));
2082                 break;
2083         case _BUTTON_STATUS_SELECTED:
2084                 __isItemTextColorSetByUser[_BUTTON_STATUS_SELECTED] = true;
2085                 return SetProperty("selectedItemTextColor", Variant(color));
2086                 break;
2087         default:
2088                 __isItemTextColorSetByUser[_BUTTON_STATUS_NORMAL] = true;
2089                 return SetProperty("normalItemTextColor", Variant(color));
2090                 break;
2091         }
2092 }
2093
2094 result
2095 _Toolbar::SetStyle(ToolbarStyle style)
2096 {
2097         __style = style;
2098
2099         if (__pToolbarPresenter)
2100         {
2101                 __pToolbarPresenter->SetInitialDrawState(true);
2102         }
2103
2104         if (__style == TOOLBAR_TAB || __style == TOOLBAR_TAB_WITH_TITLE)
2105         {
2106                 SetTabEditModeEnabled(true);
2107         }
2108
2109         AdjustToolbarBounds();
2110
2111         InitToolbarColor();
2112
2113         __titleText = L"";
2114
2115         __descriptionText = L"";
2116
2117         if(__pTitleTextElement)
2118         {
2119                 __pTitleTextElement->SetLabel(L"");
2120         }
2121
2122
2123         return E_SUCCESS;
2124 }
2125
2126 result
2127 _Toolbar::AdjustToolbarBounds(void)
2128 {
2129         int width = 0;
2130         int height = 0;
2131
2132         SetResizable(true);
2133
2134         if (__header == true)
2135         {
2136                 if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE)
2137                 {
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));
2141                 }
2142                 else
2143                 {
2144                         GET_SHAPE_CONFIG(HEADER::WIDTH, GetOrientation(), width);
2145                         GET_SHAPE_CONFIG(HEADER::HEIGHT, GetOrientation(), height);
2146                         SetSize(Dimension(width, height));
2147                 }
2148         }
2149         else
2150         {
2151                 GET_SHAPE_CONFIG(FOOTER::WIDTH, GetOrientation(), width);
2152
2153                 if (__style == TOOLBAR_SOFTKEY)
2154                 {
2155                         GET_SHAPE_CONFIG(FOOTER::SOFTKEY_HEIGHT, GetOrientation(), height);
2156                 }
2157                 else
2158                 {
2159                         GET_SHAPE_CONFIG(FOOTER::HEIGHT, GetOrientation(), height);
2160                 }
2161
2162                 SetSize(Dimension(width, height));
2163         }
2164
2165         SetResizable(false);
2166
2167         _Form* pParent = dynamic_cast<_Form*>(GetParent());
2168
2169         if (pParent != null)
2170         {
2171                 pParent->AdjustClientBounds();
2172
2173                 if (__header == false)
2174                 {
2175                         Rectangle bounds(0, pParent->GetBounds().height - height, width, height);
2176
2177                         pParent->SetFooterBounds(bounds);
2178                 }
2179         }
2180
2181         return E_SUCCESS;
2182 }
2183
2184 result
2185 _Toolbar::SetTabEditModeEnabled(bool enable)
2186 {
2187         if (__pToolbarPresenter)
2188         {
2189                 return __pToolbarPresenter->SetTabEditModeEnabled(enable);
2190         }
2191
2192         return E_SUCCESS;
2193 }
2194
2195 result
2196 _Toolbar::SetTitleIcon(const Bitmap& bitmap)
2197 {
2198         result r = E_SYSTEM;
2199
2200         Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap);
2201
2202         if (pClonedBitmap)
2203         {
2204                 if (__pTitleIcon)
2205                 {
2206                         delete __pTitleIcon;
2207                 }
2208
2209                 __pTitleIcon = pClonedBitmap;
2210
2211                 r = E_SUCCESS;
2212         }
2213
2214         return r;
2215 }
2216
2217 result
2218 _Toolbar::SetTitleText(const String& text, HorizontalAlignment alignment)
2219 {
2220         __titleText = text;
2221         __titleTextAlignment = alignment;
2222
2223         RearrangeItems();
2224
2225         if (__pToolbarPresenter)
2226         {
2227                 return __pToolbarPresenter->SetTitleText(__titleText, __titleTextAlignment);
2228         }
2229
2230         if(__pTitleTextElement)
2231         {
2232                 __pTitleTextElement->SetLabel(__titleText + L", " + __descriptionText);
2233         }
2234         return E_SUCCESS;
2235 }
2236
2237 result
2238 _Toolbar::SetTitleTextColor(const Color& color)
2239 {
2240         __titleTextColor = color;
2241
2242         return E_SUCCESS;
2243 }
2244
2245 result
2246 _Toolbar::SetTransparent(bool transparent)
2247 {
2248         if (__style == TOOLBAR_SOFTKEY)
2249         {
2250                 return E_SUCCESS;
2251         }
2252
2253         __transparent = transparent;
2254
2255         InitToolbarColor();
2256
2257         __isUserBackgroundBitmap = true;
2258
2259
2260         Bitmap* pMagentaBackgroundBitmap = null;
2261
2262         if (__pToolbarBackgroundBitmap)
2263         {
2264                 delete __pToolbarBackgroundBitmap;
2265                 __pToolbarBackgroundBitmap = null;
2266         }
2267
2268         GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pMagentaBackgroundBitmap);
2269
2270         if (__transparent)
2271         {
2272                 Color tempColor;
2273
2274                 GET_COLOR_CONFIG(HEADER::TRANSLUCENT_BG_NORMAL, tempColor);
2275
2276                 if (pMagentaBackgroundBitmap)
2277                 {
2278                         __pToolbarBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*(pMagentaBackgroundBitmap),
2279                                         Color::GetColor(COLOR_ID_MAGENTA), tempColor);
2280
2281                         if (__pToolbarBackgroundBitmap)
2282                         {
2283                                 __pToolbarBackgroundBitmap->SetAlphaConstant(0x7F);
2284                         }
2285                 }
2286
2287                 SetTitleTextColor(__transTitleTextColor);
2288                 SetDescriptionTextColor(__transDescriptionTextColor);
2289
2290                 for (int i = 0; i < __itemCount ; i ++)
2291                 {
2292                         if (__pItems.at(i) != null)
2293                         {
2294                                 ApplyUserGUI(TOOLBAR_ITEM, __pItems.at(i));
2295                         }
2296                 }
2297
2298                 for (int i = 0; i < BUTTON_MAX; i++)
2299                 {
2300                         if (__pButtonItems[i] != null)
2301                         {
2302                                 ApplyUserGUI(TOOLBAR_BUTTON, __pButtonItems[i]);
2303                         }
2304                 }
2305         }
2306         else // not transparent
2307         {
2308                 __pToolbarBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*(pMagentaBackgroundBitmap),
2309                                 Color::GetColor(COLOR_ID_MAGENTA), GetColor());
2310
2311                 SetTitleTextColor(__titleTextColor);
2312                 SetDescriptionTextColor(__descriptionTextColor);
2313
2314                 for (int i = 0; i < __itemCount ; i ++)
2315                 {
2316                         if (__pItems.at(i) != null)
2317                         {
2318                                 ApplyUserGUI(TOOLBAR_ITEM, __pItems.at(i));
2319                         }
2320                 }
2321
2322                 for (int i = 0; i < BUTTON_MAX; i++)
2323                 {
2324                         if (__pButtonItems[i] != null)
2325                         {
2326                                 ApplyUserGUI(TOOLBAR_BUTTON, __pButtonItems[i]);
2327                         }
2328                 }
2329         }
2330
2331         delete pMagentaBackgroundBitmap;
2332
2333         return E_SUCCESS;
2334 }
2335
2336 result
2337 _Toolbar::SetWaitingAnimationPosition(ToolbarAnimationPosition animationPos, int x, int y)
2338 {
2339         if (__pAnimation[animationPos])
2340         {
2341                 __pAnimation[animationPos]->SetPosition(Point(x, y));
2342         }
2343
2344         return E_SUCCESS;
2345 }
2346
2347 result
2348 _Toolbar::StopWaitingAnimation(ToolbarAnimationPosition animationPos)
2349 {
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.");
2355
2356         __pAnimation[animationPos]->Stop();
2357
2358         if (animationPos == TOOLBAR_ANIMATION_POSITION_TITLE)
2359         {
2360                 DetachChild(*__pAnimation[animationPos]);
2361         }
2362         else if (animationPos == TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT && __pButtonItems[LEFT_BUTTON] != null)
2363         {
2364                 __pButtonItems[LEFT_BUTTON]->DetachChild(*__pAnimation[animationPos]);
2365         }
2366         else if (animationPos == TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT && __pButtonItems[RIGHT_BUTTON] != null)
2367         {
2368                 __pButtonItems[RIGHT_BUTTON]->DetachChild(*__pAnimation[animationPos]);
2369         }
2370
2371         delete __pAnimation[animationPos];
2372         __pAnimation[animationPos] = null;
2373
2374         return E_SUCCESS;
2375 }
2376
2377 void
2378 _Toolbar::OnAnimationStopped(const _Control& source)
2379 {
2380         ClearLastResult();
2381
2382         if (&source == __pAnimation[TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT])
2383         {
2384                 __pAnimation[TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT]->Play();
2385         }
2386         else if (&source == __pAnimation[TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT])
2387         {
2388                 __pAnimation[TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT]->Play();
2389         }
2390         else if (__pAnimation[TOOLBAR_ANIMATION_POSITION_TITLE])
2391         {
2392                 __pAnimation[TOOLBAR_ANIMATION_POSITION_TITLE]->Play();
2393         }
2394
2395         return;
2396 }
2397
2398 result
2399 _Toolbar::OnAttachedToMainTree(void)
2400 {
2401         InitializeAccessibilityElement();
2402
2403         return E_SUCCESS;
2404 }
2405
2406 void
2407 _Toolbar::InitializeAccessibilityElement(void)
2408 {
2409         if(likely(!(_AccessibilityManager::IsActivated())))
2410         {
2411                 return;
2412         }
2413
2414         _AccessibilityContainer* pContainer = GetAccessibilityContainer();
2415         _AccessibilityElement* pButtonElement = null;
2416         if(pContainer == null)
2417         {
2418                 return;
2419         }
2420         int priorty = 0;
2421         if(__header)
2422         {
2423                 priorty = ACCESSIBILITY_PRIORTY_TOP;
2424         }
2425         else
2426         {
2427                 priorty = ACCESSIBILITY_PRIORTY_BOTTOM;
2428         }
2429         pContainer->SetPriority(priorty);
2430
2431         ToolbarStyle style = GetStyle();
2432         if(style == TOOLBAR_TITLE || style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE)
2433         {
2434                 if (__pTitleTextElement == null)
2435                 {
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);
2439                 }
2440
2441                 __pTitleTextElement->SetBounds(__pToolbarPresenter->GetTitleTextBounds());
2442                 if( __descriptionText.IsEmpty())
2443                 {
2444                         __pTitleTextElement->SetLabel(__titleText);
2445                 }
2446                 else
2447                 {
2448                         __pTitleTextElement->SetLabel(__titleText + L"," + __descriptionText);
2449                 }
2450                 __pTitleTextElement->SetTrait(L"Title");
2451                 __pTitleTextElement->SetName(L"HeaderTitleText");
2452         }
2453         else
2454         {
2455                 if(__pTitleTextElement)
2456                 {
2457                         pContainer->RemoveElement(*__pTitleTextElement);
2458                         __pTitleTextElement = null;
2459                 }
2460         }
2461
2462         if (__pButtonItems[LEFT_BUTTON])
2463         {
2464                 _AccessibilityContainer* pButtonContainer = __pButtonItems[LEFT_BUTTON]->GetAccessibilityContainer();
2465
2466                 if (pButtonContainer)
2467                 {
2468                         pButtonContainer->SetPriority(priorty);
2469                         pContainer->AddChildContainer(*pButtonContainer);
2470                         pButtonElement = pButtonContainer->GetChildElement(L"ButtonText");
2471                 }
2472
2473                 if(pButtonElement)
2474                 {
2475                         pButtonElement->SetName(L"LeftButton");
2476                         pButtonElement->SetTrait(L"Button");
2477                         pButtonElement = null;
2478                 }
2479         }
2480
2481         if (__pButtonItems[RIGHT_BUTTON])
2482         {
2483                 _AccessibilityContainer* pButtonContainer = __pButtonItems[RIGHT_BUTTON]->GetAccessibilityContainer();
2484
2485                 if (pButtonContainer)
2486                 {
2487                         pButtonContainer->SetPriority(priorty);
2488                         pContainer->AddChildContainer(*pButtonContainer);
2489                         pButtonElement = pButtonContainer->GetChildElement(L"ButtonText");
2490                 }
2491
2492                 if(pButtonElement)
2493                 {
2494                         pButtonElement->SetName(L"RightButton");
2495                         pButtonElement->SetTrait(L"Button");
2496                         pButtonElement = null;
2497                 }
2498         }
2499
2500         if (__pButtonItems[BACK_BUTTON])
2501         {
2502                 _AccessibilityContainer* pButtonContainer = __pButtonItems[BACK_BUTTON]->GetAccessibilityContainer();
2503
2504                 if (pButtonContainer)
2505                 {
2506                         pButtonContainer->SetPriority(priorty);
2507                         pContainer->AddChildContainer(*pButtonContainer);
2508                         pButtonElement = pButtonContainer->GetChildElement(L"ButtonText");
2509                 }
2510
2511                 if(pButtonElement)
2512                 {
2513                         pButtonElement->SetName(L"BackButton");
2514                         pButtonElement->SetLabel(L"Back");
2515                         pButtonElement->SetTrait(L"Back button");
2516                         pButtonElement = null;
2517                 }
2518         }
2519
2520         if (__pButtonItems[MIDDLE_BUTTON])
2521         {
2522                 _AccessibilityContainer* pButtonContainer = __pButtonItems[MIDDLE_BUTTON]->GetAccessibilityContainer();
2523
2524                 if (pButtonContainer)
2525                 {
2526                         pButtonContainer->SetPriority(priorty);
2527                         pContainer->AddChildContainer(*pButtonContainer);
2528                         pButtonElement = pButtonContainer->GetChildElement(L"ButtonText");
2529                 }
2530
2531                 if(pButtonElement)
2532                 {
2533                         pButtonElement->SetName(L"MiddleButton");
2534                         pButtonElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON);
2535                         pButtonElement = null;
2536                 }
2537         }
2538
2539         return;
2540 }
2541
2542 void
2543 _Toolbar::AddAccessibilityItem(_Button* pButton)
2544 {
2545         if(likely(!(_AccessibilityManager::IsActivated())))
2546         {
2547                 return;
2548         }
2549
2550         _AccessibilityContainer* pContainer = GetAccessibilityContainer();
2551         if(pContainer == null)
2552         {
2553                 return;
2554         }
2555
2556         int priorty = 0;
2557         if(__header)
2558         {
2559                 priorty = ACCESSIBILITY_PRIORTY_TOP;
2560         }
2561         else
2562         {
2563                 priorty = ACCESSIBILITY_PRIORTY_BOTTOM;
2564         }
2565         pContainer->SetPriority(priorty);
2566
2567         ToolbarStyle style = GetStyle();
2568         AccessibilityTraits trait = ACCESSIBILITY_TRAITS_BUTTON;
2569         String name = L"Button" + Integer::ToString(__itemCount);
2570
2571         switch (style)
2572         {
2573                 case TOOLBAR_HEADER_SEGMENTED_WITH_TITLE:
2574                         //fall through
2575                 case TOOLBAR_SEGMENTED:
2576                         name = L"Segment" + Integer::ToString(__itemCount);
2577                         trait = ACCESSIBILITY_TRAITS_SEGMENT;
2578                         break;
2579                 case TOOLBAR_TAB:
2580                         name = L"Tab" + Integer::ToString(__itemCount);
2581                         trait = ACCESSIBILITY_TRAITS_TAB;
2582                         break;
2583                 default:
2584                         break;
2585         }
2586
2587         if (pButton != null)
2588         {
2589                 _AccessibilityElement* pElement = null;
2590                 _AccessibilityContainer* pButtonContainer = pButton->GetAccessibilityContainer();
2591
2592                 if (pButtonContainer)
2593                 {
2594                         pButtonContainer->SetPriority(priorty);
2595                         pContainer->AddChildContainer(*pButtonContainer);
2596                         pElement = pButtonContainer->GetChildElement(L"ButtonText");
2597                 }
2598
2599                 if(pElement)
2600                 {
2601                         pElement->SetName(name);
2602                         pElement->SetTrait(trait);
2603                         pElement->SetHint(L"Double tap to move to contents");
2604                 }
2605         }
2606
2607         return;
2608 }
2609
2610 void
2611 _Toolbar::OnBoundsChanged(void)
2612 {
2613         if(__pTitleTextElement)
2614         {
2615                 __pTitleTextElement->SetBounds(__pToolbarPresenter->GetTitleTextBounds());
2616         }
2617
2618         RearrangeItems();
2619
2620         return;
2621 }
2622
2623 void
2624 _Toolbar::OnFontChanged(Font* pFont)
2625 {
2626         __pToolbarPresenter->OnFontChanged(pFont);
2627
2628         return;
2629 }
2630
2631 void
2632 _Toolbar::OnFontInfoRequested(unsigned long& style, int& size)
2633 {
2634         __pToolbarPresenter->OnFontInfoRequested(style, size);
2635
2636         return;
2637 }
2638
2639 void
2640 _Toolbar::OnChangeLayout(_ControlOrientation orientationStatus)
2641 {
2642         int toolbarWidth = GetBounds().width;
2643
2644         if (CalculateMinimumToolbarWidth() > toolbarWidth)
2645         {
2646                 toolbarWidth = CalculateMinimumToolbarWidth();
2647         }
2648
2649         AdjustToolbarBounds();
2650
2651         RearrangeItems();
2652
2653         return;
2654 }
2655
2656 void
2657 _Toolbar::OnDraw(void)
2658 {
2659         ClearLastResult();
2660
2661         if (__pToolbarPresenter)
2662         {
2663                 __pToolbarPresenter->Draw();
2664
2665                 InitializeAccessibilityElement();
2666         }
2667
2668         return;
2669 }
2670
2671 bool
2672 _Toolbar::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture)
2673 {
2674         //if (__tabExpanded != true)
2675         //{
2676         //      return true;
2677         //}
2678
2679         //if (__pToolbarPresenter)
2680         //{
2681         //      return __pToolbarPresenter->OnLongPressGestureDetected();
2682         //}
2683
2684         return true;
2685 }
2686
2687 bool
2688 _Toolbar::OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture)
2689 {
2690         return false;
2691 }
2692
2693 bool
2694 _Toolbar::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
2695 {
2696         ClearLastResult();
2697
2698         if (__pToolbarPresenter)
2699         {
2700                 return __pToolbarPresenter->OnTouchPressed(source, touchinfo);
2701         }
2702
2703         return true;
2704 }
2705
2706 bool
2707 _Toolbar::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
2708 {
2709         ClearLastResult();
2710
2711         if (__pToolbarPresenter)
2712         {
2713                 return __pToolbarPresenter->OnTouchReleased(source, touchinfo);
2714         }
2715
2716         return true;
2717 }
2718
2719 bool
2720 _Toolbar::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
2721 {
2722         ClearLastResult();
2723
2724         if (__pToolbarPresenter)
2725         {
2726                 return __pToolbarPresenter->OnTouchMoved(source, touchinfo);
2727         }
2728
2729         return true;
2730 }
2731
2732 bool
2733 _Toolbar::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
2734 {
2735         ClearLastResult();
2736
2737         if (__pToolbarPresenter)
2738         {
2739                 return __pToolbarPresenter->OnTouchCanceled(source, touchinfo);
2740         }
2741
2742         return true;
2743 }
2744
2745 void
2746 _Toolbar::AddActionEventListener(const Controls::_IActionEventListener& listener)
2747 {
2748         __pActionEventListener = const_cast<Controls::_IActionEventListener*>(&listener);
2749
2750         for (int i = 0; i < __itemCount; i++)
2751         {
2752                 __pItems.at(i)->AddActionEventListener(listener);
2753         }
2754
2755         for (int j = 0; j < BUTTON_MAX; j++)
2756         {
2757                 if (__pButtonItems[j])
2758                 {
2759                         __pButtonItems[j]->AddActionEventListener(listener);
2760                 }
2761         }
2762
2763         return;
2764 }
2765
2766 void
2767 _Toolbar::RemoveActionEventListener(const Controls::_IActionEventListener& listener)
2768 {
2769         __pActionEventListener = null;
2770
2771         for (int i = 0; i < __itemCount; i++)
2772         {
2773                 __pItems.at(i)->RemoveActionEventListener(listener);
2774         }
2775
2776         for (int j = 0; j < MIDDLE_BUTTON; j++)
2777         {
2778                 if (__pButtonItems[j])
2779                 {
2780                         __pButtonItems[j]->RemoveActionEventListener(listener);
2781                 }
2782         }
2783
2784         return;
2785
2786 }
2787
2788 void
2789 _Toolbar::SetBackEventListener(const Controls::_IActionEventListener& listener, int actionId)
2790 {
2791         __backActionId = actionId;
2792         __pBackEventListener = const_cast<_IActionEventListener*>(&listener);
2793
2794         return;
2795 }
2796
2797 result
2798 _Toolbar::SetPresenter(const _ToolbarPresenter& toolbarPresenter)
2799 {
2800         __pToolbarPresenter = const_cast<_ToolbarPresenter*>(&toolbarPresenter);
2801
2802         return E_SUCCESS;
2803 }
2804
2805 result
2806 _Toolbar::ApplyUserGUI(ButtonType buttonType, _Button* pButton)
2807 {
2808         SysTryReturnResult(NID_UI_CTRL, pButton, E_INVALID_ARG, "[E_INVALID_ARG] The pButton is invalid.");
2809
2810         if (TOOLBAR_BUTTON == buttonType)
2811         {
2812                 Bitmap* pNormalBackgroundBitmap = null;
2813                 Bitmap* pColorReplacedBitmap = null;
2814
2815                 if (__header)
2816                 {
2817                         GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundBitmap);
2818                 }
2819                 else
2820                 {
2821                         GET_BITMAP_CONFIG_N(FOOTER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundBitmap);
2822                 }
2823
2824                 if (__transparent)
2825                 {
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]);
2830
2831                         if (pNormalBackgroundBitmap)
2832                         {
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;
2837
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;
2842
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;
2847
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;
2852
2853                                 delete pNormalBackgroundBitmap;
2854                         }
2855                 }
2856                 else
2857                 {
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]);
2862
2863                         if (pNormalBackgroundBitmap)
2864                         {
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;
2869
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;
2874
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;
2879
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;
2884
2885                                 delete pNormalBackgroundBitmap;
2886                         }
2887                 }
2888         }
2889         else if (TOOLBAR_ITEM == buttonType)
2890         {
2891                 Bitmap* pNormalBackgroundBitmap = null;
2892                 Bitmap* pPressedBackgroundBitmap = null;
2893                 Bitmap* pNormalBackgroundEffectBitmap = null;
2894                 Bitmap* pPressedBackgroundEffectBitmap = null;
2895                 Bitmap* pColorReplacedBitmap = null;
2896
2897                 if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
2898                 {
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);
2903                 }
2904                 else
2905                 {
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);
2908                 }
2909
2910                 if (pNormalBackgroundEffectBitmap)
2911                 {
2912                         pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_NORMAL, *pNormalBackgroundEffectBitmap);
2913                         pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pNormalBackgroundEffectBitmap);
2914                         pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_DISABLED, *pNormalBackgroundEffectBitmap);
2915                         delete pNormalBackgroundEffectBitmap;
2916                 }
2917
2918                 if (pPressedBackgroundEffectBitmap)
2919                 {
2920                         pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_PRESSED, *pPressedBackgroundEffectBitmap);
2921                         pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_SELECTED, *pPressedBackgroundEffectBitmap);
2922                         delete pPressedBackgroundEffectBitmap;
2923                 }
2924
2925                 if (__transparent)
2926                 {
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]);
2932
2933                         if (pNormalBackgroundBitmap)
2934                         {
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;
2939
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;
2944
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;
2949
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;
2954
2955                                 delete pNormalBackgroundBitmap;
2956                         }
2957
2958                         if (pPressedBackgroundBitmap)
2959                         {
2960                                 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pPressedBackgroundBitmap,
2961                                                 Color::GetColor(COLOR_ID_MAGENTA), __itemTransBackgroundColor[_BUTTON_STATUS_PRESSED]);
2962
2963                                 pButton->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *pColorReplacedBitmap);
2964                                 delete pColorReplacedBitmap;
2965
2966                                 delete pPressedBackgroundBitmap;
2967                         }
2968                 }
2969                 else
2970                 {
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]);
2976
2977                         if (pNormalBackgroundBitmap)
2978                         {
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;
2983
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;
2988
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;
2993
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;
2998
2999                                 delete pNormalBackgroundBitmap;
3000                         }
3001
3002                         if (pPressedBackgroundBitmap)
3003                         {
3004                                 pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pPressedBackgroundBitmap,
3005                                                 Color::GetColor(COLOR_ID_MAGENTA), __itemBackgroundColor[_BUTTON_STATUS_PRESSED]);
3006
3007                                 pButton->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *pColorReplacedBitmap);
3008                                 delete pColorReplacedBitmap;
3009
3010                                 delete pPressedBackgroundBitmap;
3011                         }
3012                 }
3013         }
3014
3015         return E_SUCCESS;
3016 }
3017
3018 int
3019 _Toolbar::CalculateMinimumToolbarWidth(void)
3020 {
3021         int totalWidth = 0;
3022         int itemMinimumWidth = 0;
3023         int horizontalMargin = 0;
3024
3025         if (__header == true && __style == TOOLBAR_TEXT)
3026         {
3027                 if (IsButtonSet(LEFT_BUTTON))
3028                 {
3029                         //if (__pButtonItems[LEFT_BUTTON]->GetText().IsEmpty())
3030                         //{
3031                                 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_WIDTH, GetOrientation(), itemMinimumWidth);
3032                         //}
3033                         //else
3034                         //{
3035                         //      GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_WIDTH_WITH_TEXT, GetOrientation(), itemMinimumWidth);
3036                         //}
3037
3038                         totalWidth += itemMinimumWidth;
3039                 }
3040                 if (IsButtonSet(RIGHT_BUTTON))
3041                 {
3042                         //if (__pButtonItems[RIGHT_BUTTON]->GetText().IsEmpty())
3043                         //{
3044                                 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_WIDTH, GetOrientation(), itemMinimumWidth);
3045                         //}
3046                         //else
3047                         //{
3048                         //      GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_WIDTH_WITH_TEXT, GetOrientation(), itemMinimumWidth);
3049                         //}
3050
3051                         totalWidth += itemMinimumWidth;
3052                 }
3053         }
3054         else // footer or HEADER_TITLE_BUTTON
3055         {
3056                 if (IsButtonSet(LEFT_BUTTON))
3057                 {
3058                         GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_WIDTH, GetOrientation(), itemMinimumWidth);
3059                         totalWidth += itemMinimumWidth;
3060                 }
3061                 if (IsButtonSet(RIGHT_BUTTON))
3062                 {
3063                         GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_WIDTH, GetOrientation(), itemMinimumWidth);
3064                         totalWidth += itemMinimumWidth;
3065                 }
3066                 else if (IsButtonSet(BACK_BUTTON))
3067                 {
3068                         GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_WIDTH, GetOrientation(), itemMinimumWidth);
3069                         totalWidth += itemMinimumWidth;
3070                 }
3071         }
3072
3073         if (__style == TOOLBAR_TITLE)
3074         {
3075                 GET_SHAPE_CONFIG(HEADER::TITLE_MINIMUM_WIDTH, GetOrientation(), itemMinimumWidth);
3076                 totalWidth += itemMinimumWidth;
3077         }
3078         else if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_HEADER_SEGMENTED)
3079         {
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;
3083         }
3084         else if (__style == TOOLBAR_SEGMENTED)
3085         {
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;
3089         }
3090         else
3091         {
3092                 GET_SHAPE_CONFIG(FOOTER::ITEM_MINIMUM_WIDTH, GetOrientation(), itemMinimumWidth);
3093
3094                 if ((__style == TOOLBAR_TAB || __style == TOOLBAR_TAB_WITH_TITLE) && __itemCount > 4)
3095                 {
3096                         totalWidth += itemMinimumWidth * 4;
3097                 }
3098                 else
3099                 {
3100                         totalWidth += itemMinimumWidth * __itemCount;
3101                 }
3102         }
3103
3104         return totalWidth;
3105 }
3106
3107 result
3108 _Toolbar::RealignIcon(_Button* pButton)
3109 {
3110         SysTryReturnResult(NID_UI_CTRL, pButton, E_INVALID_STATE, "[E_INVALID_STATE] pButton doesn't exist.");
3111
3112         int buttonItemWidth = pButton->GetSize().width;
3113         int buttonItemHeight = pButton->GetSize().height;
3114         int sideMargin = 0;
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;
3121
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);
3125
3126         if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
3127         {
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);
3130         }
3131         else if (__style == TOOLBAR_HEADER_SEGMENTED || __style == TOOLBAR_SEGMENTED || __style == TOOLBAR_TAB)
3132         {
3133                 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_LEFT_MARGIN, GetOrientation(), sideMargin);
3134
3135                 buttonTextTopMargin = (buttonItemHeight - segmentedTextAreaHeight) / 2 - revisedTopMargin;
3136         }
3137         else if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE)
3138         {
3139                 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_LEFT_MARGIN, GetOrientation(), sideMargin);
3140
3141                 buttonTextTopMargin = 0;
3142         }
3143
3144         if (pButton->GetText() != L"")
3145         {
3146                 int iconAreaWidth = 0;
3147
3148                 if (pButton->GetBitmap(_BUTTON_STATUS_NORMAL) != null)
3149                 {
3150                         iconAreaWidth = pButton->GetBitmap(_BUTTON_STATUS_NORMAL)->GetWidth();
3151                         contentLength = iconAreaWidth + iconTextGap + textExtentSize;
3152
3153                         if (contentLength > buttonItemWidth - sideMargin * 2)
3154                         {
3155                                 contentLength = buttonItemWidth - sideMargin * 2;
3156                         }
3157
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)));
3161                 }
3162                 if (pButton->GetBitmap(_BUTTON_STATUS_PRESSED) != null)
3163                 {
3164                         iconAreaWidth = pButton->GetBitmap(_BUTTON_STATUS_PRESSED)->GetWidth();
3165                         contentLength = iconAreaWidth + iconTextGap + textExtentSize;
3166
3167                         if (contentLength > buttonItemWidth - sideMargin * 2)
3168                         {
3169                                 contentLength = buttonItemWidth - sideMargin * 2;
3170                         }
3171
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)));
3175                 }
3176                 if (pButton->GetBitmap(_BUTTON_STATUS_SELECTED) != null)
3177                 {
3178                         iconAreaWidth = pButton->GetBitmap(_BUTTON_STATUS_SELECTED)->GetWidth();
3179                         contentLength = iconAreaWidth + iconTextGap + textExtentSize;
3180
3181                         if (contentLength > buttonItemWidth - sideMargin * 2)
3182                         {
3183                                 contentLength = buttonItemWidth - sideMargin * 2;
3184                         }
3185
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)));
3189                 }
3190                 if (pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED) != null)
3191                 {
3192                         iconAreaWidth = pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED)->GetWidth();
3193                         contentLength = iconAreaWidth + iconTextGap + textExtentSize;
3194
3195                         if (contentLength > buttonItemWidth - sideMargin * 2)
3196                         {
3197                                 contentLength = buttonItemWidth - sideMargin * 2;
3198                         }
3199
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)));
3203                 }
3204                 if (pButton->GetBitmap(_BUTTON_STATUS_DISABLED) != null)
3205                 {
3206                         iconAreaWidth = pButton->GetBitmap(_BUTTON_STATUS_DISABLED)->GetWidth();
3207                         contentLength = iconAreaWidth + iconTextGap + textExtentSize;
3208
3209                         if (contentLength > buttonItemWidth - sideMargin * 2)
3210                         {
3211                                 contentLength = buttonItemWidth - sideMargin * 2;
3212                         }
3213
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)));
3217                 }
3218
3219                 if (iconAreaWidth != 0)
3220                 {
3221                         pButton->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
3222                         pButton->SetUserDefinedTextArea(Rectangle((buttonItemWidth - contentLength) / 2 + iconAreaWidth + iconTextGap, buttonTextTopMargin, buttonItemWidth - iconAreaWidth - iconTextGap - sideMargin * 2, buttonItemHeight - buttonTextTopMargin * 2));
3223                 }
3224                 else
3225                 {
3226                         pButton->SetUserDefinedTextArea(Rectangle(sideMargin, buttonTextTopMargin, buttonItemWidth - sideMargin * 2, buttonItemHeight - buttonTextTopMargin * 2));
3227                 }
3228         }
3229         else
3230         {
3231                 if (pButton->GetBitmap(_BUTTON_STATUS_NORMAL) != null)
3232                 {
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)));
3237                 }
3238                 if (pButton->GetBitmap(_BUTTON_STATUS_PRESSED) != null)
3239                 {
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)));
3244                 }
3245                 if (pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED) != null)
3246                 {
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)));
3251                 }
3252                 if (pButton->GetBitmap(_BUTTON_STATUS_DISABLED) != null)
3253                 {
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)));
3258                 }
3259                 if (pButton->GetBitmap(_BUTTON_STATUS_SELECTED) != null)
3260                 {
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)));
3265                 }
3266
3267                 pButton->SetMargin(buttonTextTopMargin, sideMargin);
3268         }
3269
3270         return E_SUCCESS;
3271 }
3272
3273 result
3274 _Toolbar::RealignButtonIcon(_Button* pButton)
3275 {
3276         SysTryReturnResult(NID_UI_CTRL, pButton, E_INVALID_STATE, "[E_INVALID_STATE] pButton doesn't exist.");
3277
3278         int buttonItemWidth = pButton->GetSize().width;
3279         int iconTopMargin = 0;
3280         GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_ICON_TOP_MARGIN, GetOrientation(), iconTopMargin);
3281
3282         if (pButton->GetBitmap(_BUTTON_STATUS_NORMAL) != null)
3283         {
3284                 pButton->SetBitmap(_BUTTON_STATUS_NORMAL,
3285                                 Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_NORMAL))->GetWidth()) / 2, iconTopMargin), *(pButton->GetBitmap(_BUTTON_STATUS_NORMAL)));
3286         }
3287         if (pButton->GetBitmap(_BUTTON_STATUS_PRESSED) != null)
3288         {
3289                 pButton->SetBitmap(_BUTTON_STATUS_PRESSED,
3290                                 Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_PRESSED))->GetWidth()) / 2, iconTopMargin), *(pButton->GetBitmap(_BUTTON_STATUS_PRESSED)));
3291         }
3292         if (pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED) != null)
3293         {
3294                 pButton->SetBitmap(_BUTTON_STATUS_HIGHLIGHTED,
3295                                 Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED))->GetWidth()) / 2, iconTopMargin), *(pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED)));
3296         }
3297         if (pButton->GetBitmap(_BUTTON_STATUS_DISABLED) != null)
3298         {
3299                 pButton->SetBitmap(_BUTTON_STATUS_DISABLED,
3300                                 Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_DISABLED))->GetWidth()) / 2, iconTopMargin), *(pButton->GetBitmap(_BUTTON_STATUS_DISABLED)));
3301         }
3302         if (pButton->GetBitmap(_BUTTON_STATUS_SELECTED) != null)
3303         {
3304                 pButton->SetBitmap(_BUTTON_STATUS_SELECTED,
3305                                 Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_SELECTED))->GetWidth()) / 2, iconTopMargin), *(pButton->GetBitmap(_BUTTON_STATUS_SELECTED)));
3306         }
3307
3308         return E_SUCCESS;
3309 }
3310
3311 result
3312 _Toolbar::RearrangeItems(void)
3313 {
3314         __titleTextArea = _Control::GetBounds();
3315
3316         const Dimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSize();
3317         const Dimension landscapeSize = Dimension(portraitSize.height, portraitSize.width);
3318
3319         if (CalculateMinimumToolbarWidth() > __titleTextArea.width)
3320         {
3321                 __titleTextArea.width = CalculateMinimumToolbarWidth();
3322         }
3323
3324         if (GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
3325         {
3326                 if (__titleTextArea.width > portraitSize.width)
3327                 {
3328                         __titleTextArea.width = portraitSize.width;
3329                 }
3330         }
3331         else
3332         {
3333                 if (__titleTextArea.width > landscapeSize.width)
3334                 {
3335                         __titleTextArea.width = landscapeSize.width;
3336                 }
3337         }
3338
3339         __itemArea = __titleTextArea;
3340
3341         if (__header == true && __style != TOOLBAR_TEXT)
3342         {
3343                 int headerLeftButtonWidth = 0;
3344                 int headerRightButtonWidth = 0;
3345                 int headerTopMargin = 0;
3346                 int vmargin = 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;
3354
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);
3362
3363                 if (__pButtonItems[LEFT_BUTTON])
3364                 {
3365                         headerLeftButtonWidth = __pButtonItems[LEFT_BUTTON]->GetSize().width;
3366                 }
3367
3368                 if (__pButtonItems[RIGHT_BUTTON])
3369                 {
3370                         headerRightButtonWidth = __pButtonItems[RIGHT_BUTTON]->GetSize().width;
3371                 }
3372
3373                 if (__style == TOOLBAR_HEADER_SEGMENTED || __style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE)
3374                 {
3375                         if (__pButtonItems[LEFT_BUTTON])
3376                         {
3377                                 if (__pButtonItems[RIGHT_BUTTON])
3378                                 {
3379                                         headerLeftButtonWidth = segmentedButtonWidth2;
3380                                         headerRightButtonWidth = segmentedButtonWidth2;
3381                                 }
3382                                 else
3383                                 {
3384                                         headerLeftButtonWidth = segmentedButtonWidth;
3385                                 }
3386
3387                                 GET_SHAPE_CONFIG(HEADER::RIGHT_MARGIN_WITH_SEGMENTED_BUTTON, GetOrientation(), headerRightMargin);
3388                         }
3389                         else
3390                         {
3391                                 if (__pButtonItems[RIGHT_BUTTON])
3392                                 {
3393                                         headerRightButtonWidth = segmentedButtonWidth;
3394
3395                                         GET_SHAPE_CONFIG(HEADER::RIGHT_MARGIN_WITH_SEGMENTED_BUTTON, GetOrientation(), headerRightMargin);
3396                                 }
3397                         }
3398                 }
3399
3400                 if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE)
3401                 {
3402                         GET_SHAPE_CONFIG(HEADER::TITLE_HEIGHT_WITH_SEGMENTED_ITEM, GetOrientation(), vmargin);
3403                         GET_SHAPE_CONFIG(HEADER::SEGMENTED_ITEM_HEIGHT, GetOrientation(), headerButtonItemHeight);
3404                 }
3405                 else
3406                 {
3407                         if (__style == TOOLBAR_TITLE)
3408                         {
3409                                 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_TOP_MARGIN, GetOrientation(), vmargin);
3410                                 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_HEIGHT, GetOrientation(), headerButtonItemHeight);
3411                         }
3412                         else if(__style == TOOLBAR_HEADER_SEGMENTED)
3413                         {
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);
3416                         }
3417                 }
3418
3419                 __titleTextArea.x = headerLeftMargin;
3420                 __titleTextArea.y = headerTopMargin;
3421
3422                 if (__pButtonItems[RIGHT_BUTTON])
3423                 {
3424                         if (__pButtonItems[LEFT_BUTTON])
3425                         {
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));
3430
3431                                 if (!(__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE))
3432                                 {
3433                                         __titleTextArea.width -= (headerLeftButtonWidth + headerRightButtonWidth + buttonItemGap + headerLeftMargin);
3434                                 }
3435                         }
3436                         else
3437                         {
3438                                 __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__titleTextArea.width - headerRightButtonWidth - headerRightMargin, vmargin,
3439                                                 headerRightButtonWidth, headerButtonItemHeight));
3440
3441                                 if (!(__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE))
3442                                 {
3443                                         __titleTextArea.width -= (headerRightButtonWidth + headerLeftMargin);
3444                                 }
3445                         }
3446                 }
3447                 else if (__pButtonItems[LEFT_BUTTON])
3448                 {
3449                         __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(__titleTextArea.width - headerLeftButtonWidth - headerRightMargin, vmargin,
3450                                         headerLeftButtonWidth, headerButtonItemHeight));
3451
3452                         if (!(__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE))
3453                         {
3454                                 __titleTextArea.width -= (headerLeftButtonWidth + headerLeftMargin);
3455                         }
3456                 }
3457
3458                 if (!(__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE))
3459                 {
3460                         __titleTextArea.width -= (headerLeftMargin + headerRightMargin);
3461                 }
3462                 else // TOOLBAR_HEADER_SEGMENTED_WITH_TITLE or TOOLBAR_TAB_WITH_TITLE
3463                 {
3464                         __titleTextArea.width -= (headerLeftMargin + tabLeftMargin);
3465                 }
3466
3467                 if (__style == TOOLBAR_HEADER_SEGMENTED)
3468                 {
3469                         if (__pButtonItems[RIGHT_BUTTON])
3470                         {
3471                                 RealignButtonIcon(__pButtonItems[RIGHT_BUTTON]);
3472                         }
3473                         if (__pButtonItems[LEFT_BUTTON])
3474                         {
3475                                 RealignButtonIcon(__pButtonItems[LEFT_BUTTON]);
3476                         }
3477                 }
3478                 else if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE)
3479                 {
3480                         if (__pButtonItems[RIGHT_BUTTON])
3481                         {
3482                                 RealignIcon(__pButtonItems[RIGHT_BUTTON]);
3483                         }
3484                         if (__pButtonItems[LEFT_BUTTON])
3485                         {
3486                                 RealignIcon(__pButtonItems[LEFT_BUTTON]);
3487                         }
3488                 }
3489         }
3490         else  // footer or edit or HEADER_STYLE_BUTTON
3491         {
3492                 int footerButtonItemWidth = 0;
3493                 int footerButtonItemHeight = 0;
3494                 int sipButtonItemTopMargin = 0;
3495                 int footerLeftMargin = 0;
3496                 Dimension softkeyDimension(0, 0);
3497
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);
3503
3504                 if (__pButtonItems[MIDDLE_BUTTON])
3505                 {
3506                         __pButtonItems[MIDDLE_BUTTON]->SetPosition(Point((__itemArea.width - __pButtonItems[MIDDLE_BUTTON]->GetSize().width) / 2,
3507                                         __itemArea.height - __pButtonItems[MIDDLE_BUTTON]->GetSize().height));
3508                 }
3509
3510                 if (__pButtonItems[RIGHT_BUTTON])
3511                 {
3512                         if (__pButtonItems[LEFT_BUTTON])
3513                         {
3514                                 if (__pButtonItems[BACK_BUTTON]) //321
3515                                 {
3516                                         if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip
3517                                         {
3518                                                 __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3519                                                                 sipButtonItemTopMargin, footerButtonItemWidth, footerButtonItemHeight));
3520
3521                                                 __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, sipButtonItemTopMargin,
3522                                                                 footerButtonItemWidth, footerButtonItemHeight));
3523                                         }
3524                                         else
3525                                         {
3526                                                 __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3527                                                                 (__itemArea.height - footerButtonItemHeight) / 2, footerButtonItemWidth, footerButtonItemHeight));
3528
3529                                                 __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, (__itemArea.height - footerButtonItemHeight) / 2,
3530                                                                 footerButtonItemWidth, footerButtonItemHeight));
3531                                         }
3532                                 }
3533                                 else //21
3534                                 {
3535                                         if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip
3536                                         {
3537                                                 __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3538                                                                 sipButtonItemTopMargin, footerButtonItemWidth, footerButtonItemHeight));
3539
3540                                                 __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, sipButtonItemTopMargin,
3541                                                                 footerButtonItemWidth, footerButtonItemHeight));
3542                                         }
3543                                         else
3544                                         {
3545                                                 if (__style != TOOLBAR_SOFTKEY)
3546                                                 {
3547                                                         __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3548                                                                                                                         (__itemArea.height - footerButtonItemHeight) / 2, footerButtonItemWidth, footerButtonItemHeight));
3549                                                 }
3550                                                 else
3551                                                 {
3552                                                         if (__pButtonItems[RIGHT_BUTTON]->GetText() == L"")
3553                                                         {
3554                                                                 __pButtonItems[RIGHT_BUTTON]->SetPosition(Point(__itemArea.width - __pButtonItems[RIGHT_BUTTON]->GetSize().width,
3555                                                                                 __itemArea.height - __pButtonItems[RIGHT_BUTTON]->GetSize().height));
3556                                                         }
3557                                                         else
3558                                                         {
3559                                                                 __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__itemArea.width - softkeyDimension.width, 0,
3560                                                                                 softkeyDimension.width, softkeyDimension.height));
3561                                                         }
3562                                                 }
3563
3564                                                 if (__style != TOOLBAR_SOFTKEY)
3565                                                 {
3566                                                         __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, (__itemArea.height - footerButtonItemHeight) / 2,
3567                                                                                                                         footerButtonItemWidth, footerButtonItemHeight));
3568                                                 }
3569                                                 else
3570                                                 {
3571                                                         if (__pButtonItems[LEFT_BUTTON]->GetText() == L"")
3572                                                         {
3573                                                                 __pButtonItems[LEFT_BUTTON]->SetPosition(Point(0, __itemArea.height - __pButtonItems[LEFT_BUTTON]->GetSize().height));
3574                                                         }
3575                                                         else
3576                                                         {
3577                                                                 __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(0, 0, softkeyDimension.width, softkeyDimension.height));
3578                                                         }
3579                                                 }
3580                                         }
3581                                 }
3582                         }
3583                         else
3584                         {
3585                                 if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip
3586                                 {
3587                                         if (__pButtonItems[BACK_BUTTON])//31
3588                                         {
3589                                                 __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3590                                                                 sipButtonItemTopMargin, footerButtonItemWidth, footerButtonItemHeight));
3591                                         }
3592                                         else //1
3593                                         {
3594                                                 __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3595                                                                 sipButtonItemTopMargin, footerButtonItemWidth, footerButtonItemHeight));
3596                                         }
3597                                 }
3598                                 else
3599                                 {
3600                                         if (__pButtonItems[BACK_BUTTON])//31
3601                                         {
3602                                                 __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3603                                                                 (__itemArea.height - footerButtonItemHeight) / 2, footerButtonItemWidth, footerButtonItemHeight));
3604                                         }
3605                                         else //1
3606                                         {
3607                                                 if (__style != TOOLBAR_SOFTKEY)
3608                                                 {
3609                                                         __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3610                                                                                                                 (__itemArea.height - footerButtonItemHeight) / 2, footerButtonItemWidth, footerButtonItemHeight));
3611                                                 }
3612                                                 else
3613                                                 {
3614                                                         if (__pButtonItems[RIGHT_BUTTON]->GetText() == L"")
3615                                                         {
3616                                                                 __pButtonItems[RIGHT_BUTTON]->SetPosition(Point(__itemArea.width - __pButtonItems[RIGHT_BUTTON]->GetSize().width,
3617                                                                                 __itemArea.height - __pButtonItems[RIGHT_BUTTON]->GetSize().height));
3618                                                         }
3619                                                         else
3620                                                         {
3621                                                                 __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__itemArea.width - softkeyDimension.width, 0,
3622                                                                                                                                                 softkeyDimension.width, softkeyDimension.height));
3623                                                         }
3624                                                 }
3625                                         }
3626                                 }
3627                         }
3628                 }
3629                 else if (__pButtonItems[LEFT_BUTTON])
3630                 {
3631                         if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip
3632                         {
3633                                 if (__pButtonItems[BACK_BUTTON]) //32
3634                                 {
3635                                         __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3636                                                         sipButtonItemTopMargin, footerButtonItemWidth, footerButtonItemHeight));
3637
3638                                         __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, sipButtonItemTopMargin,
3639                                                                 footerButtonItemWidth, footerButtonItemHeight));
3640                                 }
3641                                 else //2
3642                                 {
3643                                         __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, sipButtonItemTopMargin,
3644                                                         footerButtonItemWidth, footerButtonItemHeight));
3645                                 }
3646                         }
3647                         else
3648                         {
3649                                 if (__pButtonItems[BACK_BUTTON]) //32
3650                                 {
3651                                         __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3652                                                         (__itemArea.height - footerButtonItemHeight) / 2, footerButtonItemWidth, footerButtonItemHeight));
3653
3654                                         __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, (__itemArea.height - footerButtonItemHeight) / 2,
3655                                                                 footerButtonItemWidth, footerButtonItemHeight));
3656                                 }
3657                                 else //2
3658                                 {
3659                                         if (__style != TOOLBAR_SOFTKEY)
3660                                         {
3661                                                 __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, (__itemArea.height - footerButtonItemHeight) / 2,
3662                                                                 footerButtonItemWidth, footerButtonItemHeight));
3663                                         }
3664                                         else
3665                                         {
3666                                                 if (__pButtonItems[LEFT_BUTTON]->GetText() == L"")
3667                                                 {
3668                                                         __pButtonItems[LEFT_BUTTON]->SetPosition(Point(0, __itemArea.height - __pButtonItems[LEFT_BUTTON]->GetSize().height));
3669                                                 }
3670                                                 else
3671                                                 {
3672                                                         __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(0, 0, softkeyDimension.width, softkeyDimension.height));
3673                                                 }
3674                                         }
3675                                 }
3676                         }
3677                 }
3678                 else
3679                 {
3680                         if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip
3681                         {
3682                                 if (__pButtonItems[BACK_BUTTON])
3683                                 {
3684                                         __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3685                                                         sipButtonItemTopMargin, footerButtonItemWidth, footerButtonItemHeight));
3686                                 }
3687                         }
3688                         else
3689                         {
3690                                 if (__pButtonItems[BACK_BUTTON])
3691                                 {
3692                                         __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin,
3693                                                         (__itemArea.height - footerButtonItemHeight) / 2, footerButtonItemWidth, footerButtonItemHeight));
3694                                 }
3695                         }
3696                 }
3697         }
3698
3699
3700         if (__pToolbarPresenter)
3701         {
3702                 __pToolbarPresenter->SetUsableAreaBounds(__titleTextArea);
3703         }
3704
3705         if (0 == __itemCount)
3706         {
3707                 return E_SUCCESS;
3708         }
3709
3710         switch (__style)
3711         {
3712         case TOOLBAR_HEADER_SEGMENTED:
3713                 //fall through
3714         case TOOLBAR_HEADER_SEGMENTED_WITH_TITLE:
3715                 RearrangeHeaderSegmentedItems();
3716                 break;
3717
3718         case TOOLBAR_SEGMENTED:
3719                 RearrangeFooterSegmentedItems();
3720                 break;
3721
3722         case TOOLBAR_TAB:
3723                 //fall through
3724         case TOOLBAR_TAB_WITH_TITLE:
3725                 RearrangeTabItmes();
3726                 break;
3727
3728         default:
3729                 RearrangeButtonItems();
3730                 break;
3731         }
3732
3733         return E_SUCCESS;
3734 }
3735
3736 result
3737 _Toolbar::RearrangeHeaderSegmentedItems(void)
3738 {
3739         int segmentedItemHeight = 0;
3740         int tabLeftMargin = 0;
3741         int separatorWidth = 0;
3742         int segmentedRightMarginWithButton = 0;
3743         int vmargin = 0;
3744         int blockWidth[__itemCount];
3745         int fontSize = 0;
3746
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);
3750
3751         if (__style == TOOLBAR_HEADER_SEGMENTED)
3752         {
3753                 segmentedItemHeight = __titleTextArea.height;
3754                 GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_TOP_MARGIN_OF_SEGMENTED, GetOrientation(), vmargin);
3755         }
3756         else if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE)
3757         {
3758                 GET_SHAPE_CONFIG(HEADER::SEGMENTED_ITEM_HEIGHT, GetOrientation(), segmentedItemHeight);
3759                 GET_SHAPE_CONFIG(HEADER::TITLE_HEIGHT_WITH_SEGMENTED_ITEM, GetOrientation(), vmargin);
3760         }
3761
3762         if (__pButtonItems[LEFT_BUTTON])
3763         {
3764                 if (__pButtonItems[RIGHT_BUTTON])
3765                 {
3766                         __itemArea.width -= (tabLeftMargin + tabLeftMargin + __pButtonItems[LEFT_BUTTON]->GetSize().width + separatorWidth
3767                                         + __pButtonItems[RIGHT_BUTTON]->GetSize().width + segmentedRightMarginWithButton);
3768                 }
3769                 else
3770                 {
3771                         __itemArea.width -= (tabLeftMargin + tabLeftMargin + __pButtonItems[LEFT_BUTTON]->GetSize().width + segmentedRightMarginWithButton);
3772                 }
3773         }
3774         else
3775         {
3776                 if (__pButtonItems[RIGHT_BUTTON])
3777                 {
3778                         __itemArea.width -= (tabLeftMargin + tabLeftMargin + __pButtonItems[RIGHT_BUTTON]->GetSize().width + segmentedRightMarginWithButton);
3779                 }
3780                 else
3781                 {
3782                         __itemArea.width -= tabLeftMargin * 2;
3783                 }
3784         }
3785
3786         if (__itemCount == 1 || __itemCount == 2)
3787         {
3788                 blockWidth[0] = blockWidth[1] = (__itemArea.width - separatorWidth) / 2;
3789
3790                 for (int i = 0; i < __itemCount ; i++)
3791                 {
3792                         __pItems.at(i)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] * i + separatorWidth * i, vmargin, blockWidth[i], segmentedItemHeight));
3793
3794                         if (__pItems.at(i)->GetChildCount() != 0)
3795                         {
3796                                 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
3797
3798                                 if (existingBadgeIcon)
3799                                 {
3800                                         existingBadgeIcon->SetPosition(Point(blockWidth[1] - existingBadgeIcon->GetSize().width, 0));
3801                                         existingBadgeIcon = null;
3802                                 }
3803                         }
3804                 }
3805         }
3806         else if (__itemCount == 3)
3807         {
3808                 blockWidth[0] = blockWidth[1] = blockWidth[2] = (__itemArea.width - separatorWidth * 2) / 3;
3809
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));
3814
3815                 for (int i = 0; i < __itemCount; i++)
3816                 {
3817                         if (__pItems.at(i)->GetChildCount() != 0)
3818                         {
3819                                 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
3820
3821                                 if (existingBadgeIcon)
3822                                 {
3823                                         existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0));
3824                                         existingBadgeIcon = null;
3825                                 }
3826                         }
3827                 }
3828         }
3829         else if (__itemCount == 4)
3830         {
3831                 blockWidth[0] = blockWidth[1] = blockWidth[2] = blockWidth[3] = (__itemArea.width - separatorWidth * 3) / 4;
3832
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));
3839
3840                 for (int i = 0; i < __itemCount ; i++)
3841                 {
3842                         if (__pItems.at(i)->GetChildCount() != 0)
3843                         {
3844                                 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
3845
3846                                 if (existingBadgeIcon)
3847                                 {
3848                                         existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0));
3849                                         existingBadgeIcon = null;
3850                                 }
3851                         }
3852                 }
3853         }
3854
3855         for (int i = 0; i < __itemCount; i++)
3856         {
3857                 if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE)
3858                 {
3859                         GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_4_ITEM, GetOrientation(), fontSize);
3860
3861                         __pItems.at(i)->SetTextSize(fontSize, FONT_STYLE_BOLD);
3862                 }
3863
3864                 RealignIcon(__pItems.at(i));
3865         }
3866
3867         return E_SUCCESS;
3868 }
3869
3870 result
3871 _Toolbar::RearrangeFooterSegmentedItems(void)
3872 {
3873         int segmentedItemHeight = __itemArea.height;
3874
3875         int tabLeftMargin = 0;
3876         int tabRightMargin = 0;
3877         int footerLeftMargin = 0;
3878         int iconSize = 0;
3879         int separatorWidth = 0;
3880         int blockWidth[__itemCount];
3881         int fontSize = 0;
3882
3883         int itemButtonLeftGap = 0;
3884         int itemButtonRightGap = 0;
3885
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);
3890
3891         tabRightMargin = tabLeftMargin;
3892
3893         if (__itemCount == 1 || __itemCount == 2)
3894         {
3895                 tabLeftMargin = footerLeftMargin;
3896                 itemButtonLeftGap = footerLeftMargin;
3897                 __itemArea.width -= ((tabLeftMargin + iconSize + itemButtonLeftGap) * 2);
3898
3899                 blockWidth[0] = blockWidth[1] = (__itemArea.width - separatorWidth) / 2;
3900
3901                 for (int i = 0; i < __itemCount ; i++)
3902                 {
3903                         __pItems.at(i)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] * i + separatorWidth * i,
3904                                         (GetSize().height - segmentedItemHeight) / 2, blockWidth[i], segmentedItemHeight));
3905
3906                         if (__pItems.at(i)->GetChildCount() != 0)
3907                         {
3908                                 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
3909
3910                                 if (existingBadgeIcon)
3911                                 {
3912                                         existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0));
3913                                         existingBadgeIcon = null;
3914                                 }
3915                         }
3916                 }
3917
3918                 GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_3_ITEM, GetOrientation(), fontSize);
3919         }
3920         else if (__itemCount == 3)
3921         {
3922                 if (__pButtonItems[LEFT_BUTTON])
3923                 {
3924                         if (__pButtonItems[RIGHT_BUTTON] || __pButtonItems[BACK_BUTTON])
3925                         {
3926                                 tabLeftMargin = footerLeftMargin;
3927                                 itemButtonLeftGap = footerLeftMargin;
3928                                 __itemArea.width -= ((tabLeftMargin + iconSize + itemButtonLeftGap) * 2);
3929                         }
3930                         else
3931                         {
3932                                 tabLeftMargin = footerLeftMargin;
3933                                 itemButtonLeftGap = footerLeftMargin;
3934                                 __itemArea.width -= (tabLeftMargin + iconSize + itemButtonLeftGap + tabRightMargin);
3935                         }
3936                 }
3937                 else
3938                 {
3939                         if (__pButtonItems[RIGHT_BUTTON] || __pButtonItems[BACK_BUTTON])
3940                         {
3941                                 tabRightMargin = footerLeftMargin;
3942                                 itemButtonRightGap = footerLeftMargin;
3943                                 __itemArea.width -= (tabLeftMargin + itemButtonRightGap + iconSize + tabRightMargin);
3944                         }
3945                         else
3946                         {
3947                                 __itemArea.width -= tabLeftMargin * 2;
3948                         }
3949
3950                         iconSize = 0;
3951                 }
3952
3953                 blockWidth[0] = blockWidth[1] = blockWidth[2] = (__itemArea.width - separatorWidth * 2) / 3;
3954
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));
3959
3960                 for (int i = 0; i < __itemCount ; i++)
3961                 {
3962                         if (__pItems.at(i)->GetChildCount() != 0)
3963                         {
3964                                 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
3965
3966                                 if (existingBadgeIcon)
3967                                 {
3968                                         existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0));
3969                                         existingBadgeIcon = null;
3970                                 }
3971                         }
3972                 }
3973
3974                 GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_3_ITEM, GetOrientation(), fontSize);
3975         }
3976         else if (__itemCount == 4)
3977         {
3978                 if (__pButtonItems[BACK_BUTTON])
3979                 {
3980                         tabRightMargin = footerLeftMargin;
3981                         itemButtonRightGap = footerLeftMargin;
3982                         __itemArea.width -= (tabLeftMargin + itemButtonRightGap + iconSize + tabRightMargin);
3983                 }
3984                 else
3985                 {
3986                         __itemArea.width -= tabLeftMargin * 2;
3987                 }
3988
3989                 blockWidth[0] = blockWidth[1] = blockWidth[2] = blockWidth[3] = (__itemArea.width - separatorWidth * 3) / 4;
3990
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));
3997
3998                 for (int i = 0; i < __itemCount ; i++)
3999                 {
4000                         if (__pItems.at(i)->GetChildCount() != 0)
4001                         {
4002                                 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
4003
4004                                 if (existingBadgeIcon)
4005                                 {
4006                                         existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0));
4007                                         existingBadgeIcon = null;
4008                                 }
4009                         }
4010                 }
4011
4012                 GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_4_ITEM, GetOrientation(), fontSize);
4013         }
4014
4015         for (int i = 0; i < __itemCount ; i++)
4016         {
4017                 __pItems.at(i)->SetTextSize(fontSize, FONT_STYLE_BOLD);
4018
4019                 RealignIcon(__pItems.at(i));
4020         }
4021
4022         return E_SUCCESS;
4023 }
4024
4025 result
4026 _Toolbar::RearrangeTabItmes(void)
4027 {
4028         int itemWidth[__itemCount];
4029         int fontSize = 0;
4030         int segmentedItemHeight = 0;
4031         int tabLeftMargin = 0;
4032         int vmargin = 0;
4033         int separatorWidth = 0;
4034
4035         GET_SHAPE_CONFIG(HEADER::TAB_LEFT_MARGIN, GetOrientation(), tabLeftMargin);
4036         GET_SHAPE_CONFIG(HEADER::SEPARATOR_WIDTH, GetOrientation(), separatorWidth);
4037
4038         if (__style == TOOLBAR_TAB)
4039         {
4040                 segmentedItemHeight = __itemArea.height;
4041         }
4042         else if (__style == TOOLBAR_TAB_WITH_TITLE)
4043         {
4044                 GET_SHAPE_CONFIG(HEADER::SEGMENTED_ITEM_HEIGHT, GetOrientation(), segmentedItemHeight);
4045                 GET_SHAPE_CONFIG(HEADER::TITLE_HEIGHT_WITH_SEGMENTED_ITEM, GetOrientation(), vmargin);
4046         }
4047
4048         if (__itemCount == 1)
4049         {
4050                 itemWidth[0] = __itemArea.width - tabLeftMargin * 2;
4051                 __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, vmargin, itemWidth[0], segmentedItemHeight));
4052
4053                 if (__style == TOOLBAR_TAB)
4054                 {
4055                         GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_3_ITEM, GetOrientation(), fontSize);
4056                 }
4057                 else if (__style == TOOLBAR_TAB_WITH_TITLE)
4058                 {
4059                         GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_4_ITEM, GetOrientation(), fontSize);
4060                 }
4061         }
4062         else if (__itemCount == 2)
4063         {
4064                 itemWidth[0] = itemWidth[1] = (__itemArea.width - tabLeftMargin * 2 - separatorWidth) / 2;
4065
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));
4068
4069                 if (__style == TOOLBAR_TAB)
4070                 {
4071                         GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_3_ITEM, GetOrientation(), fontSize);
4072                 }
4073                 else if (__style == TOOLBAR_TAB_WITH_TITLE)
4074                 {
4075                         GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_4_ITEM, GetOrientation(), fontSize);
4076                 }
4077         }
4078         else if (__itemCount == 3)
4079         {
4080                 itemWidth[0] = itemWidth[1] = itemWidth[2] = (__itemArea.width - tabLeftMargin * 2 - separatorWidth * 2) / 3;
4081
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));
4085
4086                 if (__style == TOOLBAR_TAB)
4087                 {
4088                         GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_3_ITEM, GetOrientation(), fontSize);
4089                 }
4090                 else if (__style == TOOLBAR_TAB_WITH_TITLE)
4091                 {
4092                         GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_4_ITEM, GetOrientation(), fontSize);
4093                 }
4094         }
4095         else
4096         {
4097                 itemWidth[0] = itemWidth[1] = itemWidth[2] = itemWidth[3] = (__itemArea.width - tabLeftMargin * 2 - separatorWidth * 3) / 4;
4098
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));
4105
4106                 GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_4_ITEM, GetOrientation(), fontSize);
4107         }
4108
4109         for (int i = 4; i < __itemCount ; i++)
4110         {
4111                 itemWidth[i] = itemWidth[0];
4112
4113                 __pItems.at(i)->SetBounds(Rectangle(__pItems.at(i-1)->GetBounds().x + separatorWidth + itemWidth[i], vmargin, itemWidth[i], segmentedItemHeight));
4114         }
4115
4116         for (int i = 0; i < __itemCount ; i++)
4117         {
4118                 __pItems.at(i)->SetTextSize(fontSize, FONT_STYLE_BOLD);
4119
4120                 if (__pItems.at(i)->GetChildCount() != 0)
4121                 {
4122                         _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
4123
4124                         if (existingBadgeIcon)
4125                         {
4126                                 existingBadgeIcon->SetPosition(Point(__pItems.at(i)->GetSize().width - existingBadgeIcon->GetSize().width, 0));
4127                                 existingBadgeIcon = null;
4128                         }
4129                 }
4130
4131                 RealignIcon(__pItems.at(i));
4132         }
4133
4134         return E_SUCCESS;
4135 }
4136
4137 result
4138 _Toolbar::RearrangeButtonItems(void)
4139 {
4140         int itemHeight = 0;
4141         int maxItemLength = 0;
4142         int minItemLength = 0;
4143         int iconSizeWithText = 0;
4144         int sideMargin = 0;
4145         int vmargin = 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;
4152         int iconSize = 0;
4153         int footerLeftMargin = 0;
4154         int headerButtonItemHeight = 0;
4155         int headerLeftMargin = 0;
4156         int blockWidth[__itemCount];
4157
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);
4169
4170         tabRightMargin = tabLeftMargin;
4171
4172         if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
4173         {
4174                 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_HEIGHT, GetOrientation(), itemHeight);
4175         }
4176         else
4177         {
4178                 itemHeight = GetSize().height;
4179         }
4180
4181         if (__itemCount == 1)
4182         {
4183                 if (__style == TOOLBAR_TITLE) // item 1, HEADER_STYLE_TITLE_BUTTON
4184                 {
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);
4189                 }
4190                 else
4191                 {
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
4197                         {
4198                                 GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_BUTTON_STYLE_ICON_SIZE_WITH_TEXT, GetOrientation(), iconSizeWithText);
4199                         }
4200
4201                         blockWidth[0] = __pItems.at(0)->GetTextExtentSize() + iconSizeWithText + sideMargin * 3;
4202
4203                         if (blockWidth[0] > maxItemLength)
4204                         {
4205                                 blockWidth[0] = maxItemLength;
4206                         }
4207                         if (blockWidth[0] < minItemLength)
4208                         {
4209                                 blockWidth[0] = minItemLength;
4210                         }
4211
4212                         if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip
4213                         {
4214                                 __pItems.at(0)->SetBounds(Rectangle((GetSize().width - blockWidth[0]) / 2, sipFooterItemTopMargin, blockWidth[0], itemHeight));
4215                         }
4216                         else
4217                         {
4218                                 __pItems.at(0)->SetBounds(Rectangle((GetSize().width - blockWidth[0]) / 2, (GetSize().height - itemHeight) / 2, blockWidth[0], itemHeight));
4219                         }
4220                 }
4221
4222                 for (int i = 0; i < __itemCount; i++)
4223                 {
4224                         if (__pItems.at(i)->GetChildCount() != 0)
4225                         {
4226                                 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
4227
4228                                 if (existingBadgeIcon)
4229                                 {
4230                                         existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0));
4231                                         existingBadgeIcon = null;
4232                                 }
4233                         }
4234                 }
4235         }
4236         else if(__itemCount == 2)
4237         {
4238                 tabLeftMargin = footerLeftMargin;
4239                 itemButtonLeftGap = footerLeftMargin;
4240                 __itemArea.width -= ((tabLeftMargin + iconSize + itemButtonLeftGap) * 2);
4241
4242                 blockWidth[0] = blockWidth[1] = (__itemArea.width - separatorWidth) / 2;
4243
4244                 if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip
4245                 {
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));
4248                 }
4249                 else
4250                 {
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));
4253                 }
4254
4255                 for (int i = 0; i < __itemCount; i++)
4256                 {
4257                         if (__pItems.at(i)->GetChildCount() != 0)
4258                         {
4259                                 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
4260
4261                                 if (existingBadgeIcon)
4262                                 {
4263                                         existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0));
4264                                         existingBadgeIcon = null;
4265                                 }
4266                         }
4267                 }
4268         }
4269         else if (__itemCount == 3)
4270         {
4271                 if (__pButtonItems[LEFT_BUTTON])
4272                 {
4273                         if (__pButtonItems[RIGHT_BUTTON] || __pButtonItems[BACK_BUTTON])
4274                         {
4275                                 tabLeftMargin = footerLeftMargin;
4276                                 itemButtonLeftGap = footerLeftMargin;
4277                                 __itemArea.width -= ((tabLeftMargin + iconSize + itemButtonLeftGap) * 2);
4278                         }
4279                         else
4280                         {
4281                                 tabLeftMargin = footerLeftMargin;
4282                                 itemButtonLeftGap = footerLeftMargin;
4283                                 __itemArea.width -= (tabLeftMargin + iconSize + itemButtonLeftGap + tabRightMargin);
4284                         }
4285                 }
4286                 else
4287                 {
4288                         if (__pButtonItems[RIGHT_BUTTON] || __pButtonItems[BACK_BUTTON])
4289                         {
4290                                 tabRightMargin = footerLeftMargin;
4291                                 itemButtonRightGap = footerLeftMargin;
4292                                 __itemArea.width -= (tabLeftMargin + itemButtonRightGap + iconSize + tabRightMargin);
4293                         }
4294                         else
4295                         {
4296                                 __itemArea.width -= tabLeftMargin * 2;
4297                         }
4298
4299                         iconSize = 0;
4300                 }
4301
4302                 blockWidth[0] = blockWidth[1] = blockWidth[2] = (__itemArea.width - separatorWidth * 2) / 3;
4303
4304                 if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip
4305                 {
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));
4310                 }
4311                 else
4312                 {
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));
4317                 }
4318
4319                 for (int i = 0; i < __itemCount; i++)
4320                 {
4321                         if (__pItems.at(i)->GetChildCount() != 0)
4322                         {
4323                                 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
4324
4325                                 if (existingBadgeIcon)
4326                                 {
4327                                         existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0));
4328                                         existingBadgeIcon = null;
4329                                 }
4330                         }
4331                 }
4332         }
4333         else if (__itemCount == 4)
4334         {
4335                 if (__pButtonItems[BACK_BUTTON])
4336                 {
4337                         tabRightMargin = footerLeftMargin;
4338                         itemButtonRightGap = footerLeftMargin;
4339                         __itemArea.width -= (tabLeftMargin + itemButtonRightGap + iconSize + tabRightMargin);
4340                 }
4341                 else
4342                 {
4343                         __itemArea.width -= tabLeftMargin * 2;
4344                 }
4345
4346                 blockWidth[0] = blockWidth[1] = blockWidth[2] = blockWidth[3] = (__itemArea.width - separatorWidth * 3) / 4;
4347
4348                 if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip
4349                 {
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));
4356                 }
4357                 else
4358                 {
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));
4365                 }
4366
4367                 for (int i = 0; i < __itemCount; i++)
4368                 {
4369                         if (__pItems.at(i)->GetChildCount() != 0)
4370                         {
4371                                 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
4372
4373                                 if (existingBadgeIcon)
4374                                 {
4375                                         existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0));
4376                                         existingBadgeIcon = null;
4377                                 }
4378                         }
4379                 }
4380         }
4381         else if (__itemCount == 5)
4382         {
4383                 if (__pButtonItems[BACK_BUTTON])
4384                 {
4385                         tabRightMargin = footerLeftMargin;
4386                         itemButtonRightGap = footerLeftMargin;
4387                         __itemArea.width -= (tabLeftMargin + itemButtonRightGap + iconSize + tabRightMargin);
4388                 }
4389                 else
4390                 {
4391                         __itemArea.width -= tabLeftMargin * 2;
4392                 }
4393
4394                 blockWidth[0] = blockWidth[1] = blockWidth[2] = blockWidth[3] = blockWidth[4] = (__itemArea.width - separatorWidth * 4) / 5;
4395
4396                 if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip
4397                 {
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));
4406                 }
4407                 else
4408                 {
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));
4417                 }
4418
4419                 for (int i = 0; i < __itemCount; i++)
4420                 {
4421                         if (__pItems.at(i)->GetChildCount() != 0)
4422                         {
4423                                 _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0));
4424
4425                                 if (existingBadgeIcon)
4426                                 {
4427                                         existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0));
4428                                         existingBadgeIcon = null;
4429                                 }
4430                         }
4431                 }
4432         }
4433
4434         int buttonTextFontSize = 0;
4435
4436         for (int i = 0; i < __itemCount; i++)
4437         {
4438                 if (__style == TOOLBAR_ICON_TEXT && (__pItems.at(i)->GetBitmap(_BUTTON_STATUS_NORMAL) || __pItems.at(i)->GetBitmap(_BUTTON_STATUS_PRESSED)))
4439                 {
4440                         if (__itemCount == 1 || __itemCount == 2)
4441                         {
4442                                 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_3_WITH_ICON, GetOrientation(), buttonTextFontSize);
4443                         }
4444                         else if (__itemCount == 3)
4445                         {
4446                                 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_3_WITH_ICON, GetOrientation(), buttonTextFontSize);
4447                         }
4448                         else if (__itemCount == 4)
4449                         {
4450                                 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_4_WITH_ICON, GetOrientation(), buttonTextFontSize);
4451                         }
4452                         else if (__itemCount == 5)
4453                         {
4454                                 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_5_WITH_ICON, GetOrientation(), buttonTextFontSize);
4455                         }
4456                 }
4457                 else
4458                 {
4459                         if (__itemCount == 1 || __itemCount == 2)
4460                         {
4461                                 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_3, GetOrientation(), buttonTextFontSize);
4462                         }
4463                         else if (__itemCount == 3)
4464                         {
4465                                 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_3, GetOrientation(), buttonTextFontSize);
4466                         }
4467                         else if (__itemCount == 4)
4468                         {
4469                                 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_4, GetOrientation(), buttonTextFontSize);
4470                         }
4471                         else if (__itemCount == 5)
4472                         {
4473                                 GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_5, GetOrientation(), buttonTextFontSize);
4474                         }
4475                 }
4476
4477                 __pItems.at(i)->SetTextSize(buttonTextFontSize, FONT_STYLE_BOLD);
4478
4479                 RealignIcon(__pItems.at(i));
4480         }
4481
4482         return E_SUCCESS;
4483 }
4484
4485 result
4486 _Toolbar::SetAnimation(ToolbarAnimationPosition animationPos)
4487 {
4488         SysTryReturnResult(NID_UI_CTRL, (0 <= animationPos && animationPos < 3), E_INVALID_ARG,
4489                                 "[E_INVALID_ARG] The animationPos is invalid.");
4490
4491         if (__pAnimation[animationPos])
4492         {
4493                 if (__pAnimation[animationPos]->GetStatus() == ANIMATION_PLAYING)
4494                 {
4495                         return E_SUCCESS;
4496                 }
4497         }
4498
4499         Bitmap* pProcessingBitmap[PROCESSING_ANIMATION_COUNT];
4500
4501         for (int i = 0; i < PROCESSING_ANIMATION_COUNT ; i++)
4502         {
4503                 pProcessingBitmap[i] = null;
4504         }
4505
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]);
4536
4537         // Create AnimationFrames
4538         long duration = 500 / PROCESSING_ANIMATION_COUNT;
4539
4540         AnimationFrame* pAniFrame[PROCESSING_ANIMATION_COUNT];
4541
4542         for (int i = 0; i < PROCESSING_ANIMATION_COUNT ; i++)
4543         {
4544                 pAniFrame[i] = new (std::nothrow) AnimationFrame(*pProcessingBitmap[i], duration);
4545         }
4546
4547         __pAnimationFrameList = new (std::nothrow) ArrayList();
4548         if (__pAnimationFrameList)
4549         {
4550                 __pAnimationFrameList->Construct();
4551
4552                 for (int i = 0; i < PROCESSING_ANIMATION_COUNT ; i++)
4553                 {
4554                         __pAnimationFrameList->Add(*pAniFrame[i]);
4555                 }
4556         }
4557
4558         // Deallocate a Bitmap.
4559         for (int i = 0 ; i < PROCESSING_ANIMATION_COUNT ; i++)
4560         {
4561                 delete pProcessingBitmap[i];
4562                 pProcessingBitmap[i] = null;
4563         }
4564
4565         delete __pAnimation[animationPos];
4566         __pAnimation[animationPos] = null;
4567
4568         __pAnimation[animationPos] = _Animation::CreateAnimationN();
4569
4570         int processingAnimationIconSize = 0;
4571
4572         GET_SHAPE_CONFIG(HEADER::PROCESSING_ANIMATION_ICON_SIZE, GetOrientation(), processingAnimationIconSize);
4573
4574         if (__pAnimation[animationPos])
4575         {
4576                 __pAnimation[animationPos]->SetSize(Dimension(processingAnimationIconSize, processingAnimationIconSize));
4577
4578                 if (__pAnimationFrameList)
4579                 {
4580                         __pAnimation[animationPos]->SetAnimationFrames(*__pAnimationFrameList);
4581                 }
4582                 __pAnimation[animationPos]->SetImageCount(PROCESSING_ANIMATION_COUNT);
4583                 __pAnimation[animationPos]->SetRepeatCount(100);
4584                 __pAnimation[animationPos]->AddAnimationEventListener(*this);
4585
4586
4587                 if (animationPos == TOOLBAR_ANIMATION_POSITION_TITLE)
4588                 {
4589                         AttachChild(*__pAnimation[animationPos]);
4590                 }
4591                 else if (animationPos == TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT)
4592                 {
4593                         __pButtonItems[LEFT_BUTTON]->AttachChild(*__pAnimation[animationPos]);
4594
4595                         SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT,
4596                                         (__pButtonItems[LEFT_BUTTON]->GetSize().width - processingAnimationIconSize) / 2,
4597                                         (__pButtonItems[LEFT_BUTTON]->GetSize().height - processingAnimationIconSize) / 2);
4598                 }
4599                 else if (animationPos == TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT)
4600                 {
4601                         __pButtonItems[RIGHT_BUTTON]->AttachChild(*__pAnimation[animationPos]);
4602
4603                         SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT,
4604                                         (__pButtonItems[RIGHT_BUTTON]->GetSize().width - processingAnimationIconSize) / 2,
4605                                         (__pButtonItems[RIGHT_BUTTON]->GetSize().height - processingAnimationIconSize) / 2);
4606                 }
4607         }
4608
4609         return E_SUCCESS;
4610 }
4611
4612 result
4613 _Toolbar::SetColorReplacedBitmap(_Button* pButton, const _ButtonStatus status,
4614                 const Color& color, const Bitmap* pBitmap)
4615 {
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.");
4618
4619         Bitmap* __pColorReplacedBitmap = null;
4620
4621         __pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBitmap, Color::GetColor(COLOR_ID_MAGENTA), color);
4622
4623         if (__pColorReplacedBitmap)
4624         {
4625                 if (color.GetAlpha() != 0xFF)
4626                 {
4627                         __pColorReplacedBitmap->SetAlphaConstant(color.GetAlpha());
4628                 }
4629
4630                 pButton->SetBackgroundBitmap(status, *__pColorReplacedBitmap);
4631                 delete __pColorReplacedBitmap;
4632         }
4633
4634         return E_SUCCESS;
4635 }
4636
4637 result
4638 _Toolbar::SetPropertyColor(const Variant& color)
4639 {
4640         result r = E_SUCCESS;
4641
4642         _Control::SetBackgroundColor(color.ToColor());
4643
4644         return r;
4645 }
4646
4647 Variant
4648 _Toolbar::GetPropertyColor(void) const
4649 {
4650         return Variant(_Control::GetBackgroundColor());
4651 }
4652
4653 result
4654 _Toolbar::SetPropertyDescriptionText(const Variant& text)
4655 {
4656         __descriptionText = text.ToString();
4657
4658         result r = E_SUCCESS;
4659
4660         if (__pToolbarPresenter)
4661         {
4662                 r = __pToolbarPresenter->SetDescriptionText(__descriptionText);
4663         }
4664
4665         if(__pTitleTextElement)
4666         {
4667                 if (text.IsEmpty())
4668                 {
4669                         __pTitleTextElement->SetLabel(__titleText);
4670                 }
4671                 else
4672                 {
4673                         __pTitleTextElement->SetLabel(__titleText + L", " + __descriptionText);
4674                 }
4675         }
4676
4677         return r;
4678 }
4679
4680 Variant
4681 _Toolbar::GetPropertyDescriptionText(void) const
4682 {
4683         return Variant(__descriptionText);
4684 }
4685
4686 result
4687 _Toolbar::SetPropertyDescriptionTextColor(const Variant& color)
4688 {
4689         __descriptionTextColor = color.ToColor();
4690
4691         return E_SUCCESS;
4692 }
4693
4694 Variant
4695 _Toolbar::GetPropertyDescriptionTextColor(void) const
4696 {
4697         return Variant(__descriptionTextColor);
4698 }
4699
4700 result
4701 _Toolbar::SetPropertyTitleText(const Variant& text)
4702 {
4703         __titleText = text.ToString();
4704
4705         if(__pTitleTextElement)
4706         {
4707                 __pTitleTextElement->SetLabel(__titleText);
4708         }
4709
4710         return E_SUCCESS;
4711 }
4712
4713 Variant
4714 _Toolbar::GetPropertyTitleText(void) const
4715 {
4716         return Variant(__titleText);
4717 }
4718
4719 result
4720 _Toolbar::SetPropertyTitleTextColor(const Variant& color)
4721 {
4722         __titleTextColor = color.ToColor();
4723
4724         return E_SUCCESS;
4725 }
4726
4727 Variant
4728 _Toolbar::GetPropertyTitleTextColor(void) const
4729 {
4730         return Variant(__titleTextColor);
4731 }
4732
4733 result
4734 _Toolbar::SetPropertyDisabledButtonColor(const Variant& color)
4735 {
4736         __buttonBackgroundColor[_BUTTON_STATUS_DISABLED] = color.ToColor();
4737
4738         Bitmap* __pBaseBackgroundBitmap = null;
4739
4740         GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
4741
4742         for (int i = 0; i < BUTTON_MAX; i++)
4743         {
4744                 if (__pButtonItems[i] != null)
4745                 {
4746                         if (__pBaseBackgroundBitmap)
4747                         {
4748                                 SetColorReplacedBitmap(__pButtonItems[i], _BUTTON_STATUS_DISABLED, __buttonBackgroundColor[_BUTTON_STATUS_DISABLED], __pBaseBackgroundBitmap);
4749                         }
4750                 }
4751         }
4752
4753         delete __pBaseBackgroundBitmap;
4754
4755         return E_SUCCESS;
4756 }
4757
4758 Variant
4759 _Toolbar::GetPropertyDisabledButtonColor(void) const
4760 {
4761         return Variant(__buttonBackgroundColor[_BUTTON_STATUS_DISABLED]);
4762 }
4763
4764 result
4765 _Toolbar::SetPropertyDisabledButtonTextColor(const Variant& color)
4766 {
4767         __buttonTextColor[_BUTTON_STATUS_DISABLED] = color.ToColor();
4768
4769         for (int i = 0; i < BUTTON_MAX; i++)
4770         {
4771                 if (__pButtonItems[i] != null)
4772                 {
4773                         __pButtonItems[i]->SetTextColor(_BUTTON_STATUS_DISABLED, __buttonTextColor[_BUTTON_STATUS_DISABLED]);
4774                 }
4775         }
4776
4777         return E_SUCCESS;
4778 }
4779
4780 Variant
4781 _Toolbar::GetPropertyDisabledButtonTextColor(void) const
4782 {
4783         return Variant(__buttonTextColor[_BUTTON_STATUS_DISABLED]);
4784 }
4785
4786 result
4787 _Toolbar::SetPropertyHighlightedButtonColor(const Variant& color)
4788 {
4789         __buttonBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
4790
4791         Bitmap* __pBaseBackgroundBitmap = null;
4792
4793         GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
4794
4795         for (int i = 0; i < BUTTON_MAX; i++)
4796         {
4797                 if (__pButtonItems[i] != null)
4798                 {
4799                         if (__pBaseBackgroundBitmap)
4800                         {
4801                                 SetColorReplacedBitmap(__pButtonItems[i], _BUTTON_STATUS_HIGHLIGHTED, __buttonBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED], __pBaseBackgroundBitmap);
4802                         }
4803                 }
4804         }
4805
4806         delete __pBaseBackgroundBitmap;
4807
4808         return E_SUCCESS;
4809 }
4810
4811 Variant
4812 _Toolbar::GetPropertyHighlightedButtonColor(void) const
4813 {
4814         return Variant(__buttonBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
4815 }
4816
4817 result
4818 _Toolbar::SetPropertyHighlightedButtonTextColor(const Variant& color)
4819 {
4820         __buttonTextColor[_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
4821
4822         for (int i = 0; i < BUTTON_MAX; i++)
4823         {
4824                 if (__pButtonItems[i] != null)
4825                 {
4826                         __pButtonItems[i]->SetTextColor(_BUTTON_STATUS_HIGHLIGHTED, __buttonTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
4827                 }
4828         }
4829
4830         return E_SUCCESS;
4831 }
4832
4833 Variant
4834 _Toolbar::GetPropertyHighlightedButtonTextColor(void) const
4835 {
4836         return Variant(__buttonTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
4837 }
4838
4839 result
4840 _Toolbar::SetPropertyNormalButtonColor(const Variant& color)
4841 {
4842         __buttonBackgroundColor[_BUTTON_STATUS_NORMAL] = color.ToColor();
4843
4844         Bitmap* __pBaseBackgroundBitmap = null;
4845
4846         GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
4847
4848         for (int i = 0; i < BUTTON_MAX; i++)
4849         {
4850                 if (__pButtonItems[i] != null)
4851                 {
4852                         if (__pBaseBackgroundBitmap)
4853                         {
4854                                 SetColorReplacedBitmap(__pButtonItems[i], _BUTTON_STATUS_NORMAL, __buttonBackgroundColor[_BUTTON_STATUS_NORMAL], __pBaseBackgroundBitmap);
4855                         }
4856                 }
4857         }
4858
4859         delete __pBaseBackgroundBitmap;
4860
4861         return E_SUCCESS;
4862 }
4863
4864 Variant
4865 _Toolbar::GetPropertyNormalButtonColor(void) const
4866 {
4867         return Variant(__buttonBackgroundColor[_BUTTON_STATUS_NORMAL]);
4868 }
4869
4870 result
4871 _Toolbar::SetPropertyNormalButtonTextColor(const Variant& color)
4872 {
4873         __buttonTextColor[_BUTTON_STATUS_NORMAL] = color.ToColor();
4874
4875         for (int i = 0; i < BUTTON_MAX; i++)
4876         {
4877                 if (__pButtonItems[i] != null)
4878                 {
4879                         __pButtonItems[i]->SetTextColor(_BUTTON_STATUS_NORMAL, __buttonTextColor[_BUTTON_STATUS_NORMAL]);
4880                 }
4881         }
4882
4883         return E_SUCCESS;
4884 }
4885
4886 Variant
4887 _Toolbar::GetPropertyNormalButtonTextColor(void) const
4888 {
4889         return Variant(__buttonTextColor[_BUTTON_STATUS_NORMAL]);
4890 }
4891
4892 result
4893 _Toolbar::SetPropertyPressedButtonColor(const Variant& color)
4894 {
4895         __buttonBackgroundColor[_BUTTON_STATUS_PRESSED] = color.ToColor();
4896
4897         Bitmap* __pBaseBackgroundBitmap = null;
4898
4899         GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
4900
4901         for (int i = 0; i < BUTTON_MAX; i++)
4902         {
4903                 if (__pButtonItems[i] != null)
4904                 {
4905                         if (__pBaseBackgroundBitmap)
4906                         {
4907                                 SetColorReplacedBitmap(__pButtonItems[i], _BUTTON_STATUS_PRESSED, __buttonBackgroundColor[_BUTTON_STATUS_PRESSED], __pBaseBackgroundBitmap);
4908                         }
4909                 }
4910         }
4911
4912         delete __pBaseBackgroundBitmap;
4913
4914         return E_SUCCESS;
4915 }
4916
4917 Variant
4918 _Toolbar::GetPropertyPressedButtonColor(void) const
4919 {
4920         return Variant(__buttonBackgroundColor[_BUTTON_STATUS_PRESSED]);
4921 }
4922
4923 result
4924 _Toolbar::SetPropertyPressedButtonTextColor(const Variant& color)
4925 {
4926         __buttonTextColor[_BUTTON_STATUS_PRESSED] = color.ToColor();
4927
4928         for (int i = 0; i < BUTTON_MAX; i++)
4929         {
4930                 if (__pButtonItems[i] != null)
4931                 {
4932                         __pButtonItems[i]->SetTextColor(_BUTTON_STATUS_PRESSED, __buttonTextColor[_BUTTON_STATUS_PRESSED]);
4933                 }
4934         }
4935
4936         return E_SUCCESS;
4937 }
4938
4939 Variant
4940 _Toolbar::GetPropertyPressedButtonTextColor(void) const
4941 {
4942         return Variant(__buttonTextColor[_BUTTON_STATUS_PRESSED]);
4943 }
4944
4945 result
4946 _Toolbar::SetPropertyDisabledItemColor(const Variant& color)
4947 {
4948         __itemBackgroundColor[_BUTTON_STATUS_DISABLED] = color.ToColor();
4949
4950         Bitmap* __pBaseBackgroundBitmap = null;
4951
4952         if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
4953         {
4954                 GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
4955         }
4956         else
4957         {
4958                 GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
4959         }
4960
4961         for (int i = 0; i < __itemCount; i++)
4962         {
4963                 if (__pItems.at(i) != null)
4964                 {
4965                         if (__pBaseBackgroundBitmap)
4966                         {
4967                                 SetColorReplacedBitmap(__pItems.at(i), _BUTTON_STATUS_DISABLED, __itemBackgroundColor[_BUTTON_STATUS_DISABLED], __pBaseBackgroundBitmap);
4968                         }
4969                 }
4970         }
4971
4972         delete __pBaseBackgroundBitmap;
4973
4974         return E_SUCCESS;
4975 }
4976
4977 Variant
4978 _Toolbar::GetPropertyDisabledItemColor(void) const
4979 {
4980         return Variant(__itemBackgroundColor[_BUTTON_STATUS_DISABLED]);
4981 }
4982
4983 result
4984 _Toolbar::SetPropertyDisabledItemTextColor(const Variant& color)
4985 {
4986         __itemTextColor[_BUTTON_STATUS_DISABLED] = color.ToColor();
4987
4988         for (int i = 0; i < __itemCount; i++)
4989         {
4990                 if (__pItems.at(i) != null)
4991                 {
4992                         __pItems.at(i)->SetTextColor(_BUTTON_STATUS_DISABLED, __itemTextColor[_BUTTON_STATUS_DISABLED]);
4993                 }
4994         }
4995
4996         return E_SUCCESS;
4997 }
4998
4999 Variant
5000 _Toolbar::GetPropertyDisabledItemTextColor(void) const
5001 {
5002         return Variant(__itemTextColor[_BUTTON_STATUS_DISABLED]);
5003 }
5004
5005 result
5006 _Toolbar::SetPropertyHighlightedItemColor(const Variant& color)
5007 {
5008         __itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
5009
5010         Bitmap* __pBaseBackgroundBitmap = null;
5011
5012         if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
5013         {
5014                 GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
5015         }
5016         else
5017         {
5018                 GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
5019         }
5020
5021         for (int i = 0; i < __itemCount; i++)
5022         {
5023                 if (__pItems.at(i) != null)
5024                 {
5025                         if (__pBaseBackgroundBitmap)
5026                         {
5027                                 SetColorReplacedBitmap(__pItems.at(i), _BUTTON_STATUS_HIGHLIGHTED, __itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED], __pBaseBackgroundBitmap);
5028                         }
5029                 }
5030         }
5031
5032         delete __pBaseBackgroundBitmap;
5033
5034         return E_SUCCESS;
5035 }
5036
5037 Variant
5038 _Toolbar::GetPropertyHighlightedItemColor(void) const
5039 {
5040         return Variant(__itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]);
5041 }
5042
5043 result
5044 _Toolbar::SetPropertyHighlightedItemTextColor(const Variant& color)
5045 {
5046         __itemTextColor[_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
5047
5048         for (int i = 0; i < __itemCount; i++)
5049         {
5050                 if (__pItems.at(i) != null)
5051                 {
5052                         __pItems.at(i)->SetTextColor(_BUTTON_STATUS_HIGHLIGHTED, __itemTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
5053                 }
5054         }
5055
5056         return E_SUCCESS;
5057 }
5058
5059 Variant
5060 _Toolbar::GetPropertyHighlightedItemTextColor(void) const
5061 {
5062         return Variant(__itemTextColor[_BUTTON_STATUS_HIGHLIGHTED]);
5063 }
5064
5065 result
5066 _Toolbar::SetPropertyNormalItemColor(const Variant& color)
5067 {
5068         __itemBackgroundColor[_BUTTON_STATUS_NORMAL] = color.ToColor();
5069
5070         Bitmap* __pBaseBackgroundBitmap = null;
5071
5072         if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
5073         {
5074                 GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
5075         }
5076         else
5077         {
5078                 GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
5079         }
5080
5081         for (int i = 0; i < __itemCount; i++)
5082         {
5083                 if (__pItems.at(i) != null)
5084                 {
5085                         if (__pBaseBackgroundBitmap)
5086                         {
5087                                 SetColorReplacedBitmap(__pItems.at(i), _BUTTON_STATUS_NORMAL, __itemBackgroundColor[_BUTTON_STATUS_NORMAL], __pBaseBackgroundBitmap);
5088                         }
5089                 }
5090         }
5091
5092         delete __pBaseBackgroundBitmap;
5093
5094         return E_SUCCESS;
5095 }
5096
5097 Variant
5098 _Toolbar::GetPropertyNormalItemColor(void) const
5099 {
5100         return Variant(__itemBackgroundColor[_BUTTON_STATUS_NORMAL]);
5101 }
5102
5103 result
5104 _Toolbar::SetPropertyNormalItemTextColor(const Variant& color)
5105 {
5106         __itemTextColor[_BUTTON_STATUS_NORMAL] = color.ToColor();
5107
5108         for (int i = 0; i < __itemCount; i++)
5109         {
5110                 if (__pItems.at(i) != null)
5111                 {
5112                         __pItems.at(i)->SetTextColor(_BUTTON_STATUS_NORMAL, __itemTextColor[_BUTTON_STATUS_NORMAL]);
5113                 }
5114         }
5115
5116         return E_SUCCESS;
5117 }
5118
5119 Variant
5120 _Toolbar::GetPropertyNormalItemTextColor(void) const
5121 {
5122         return Variant(__itemTextColor[_BUTTON_STATUS_NORMAL]);
5123 }
5124
5125 result
5126 _Toolbar::SetPropertyPressedItemColor(const Variant& color)
5127 {
5128         __itemBackgroundColor[_BUTTON_STATUS_PRESSED] = color.ToColor();
5129
5130         Bitmap* __pBaseBackgroundBitmap = null;
5131
5132         if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
5133         {
5134                 GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
5135         }
5136         else
5137         {
5138                 GET_BITMAP_CONFIG_N(HEADER::TAB_ITEM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
5139         }
5140
5141         for (int i = 0; i < __itemCount; i++)
5142         {
5143                 if (__pItems.at(i) != null)
5144                 {
5145                         if (__pBaseBackgroundBitmap)
5146                         {
5147                                 SetColorReplacedBitmap(__pItems.at(i), _BUTTON_STATUS_PRESSED, __itemBackgroundColor[_BUTTON_STATUS_PRESSED], __pBaseBackgroundBitmap);
5148                         }
5149                 }
5150         }
5151
5152         delete __pBaseBackgroundBitmap;
5153
5154         return E_SUCCESS;
5155 }
5156
5157 Variant
5158 _Toolbar::GetPropertyPressedItemColor(void) const
5159 {
5160         return Variant(__itemBackgroundColor[_BUTTON_STATUS_PRESSED]);
5161 }
5162
5163 result
5164 _Toolbar::SetPropertyPressedItemTextColor(const Variant& color)
5165 {
5166         __itemTextColor[_BUTTON_STATUS_PRESSED] = color.ToColor();
5167
5168         for (int i = 0; i < __itemCount; i++)
5169         {
5170                 if (__pItems.at(i) != null)
5171                 {
5172                         __pItems.at(i)->SetTextColor(_BUTTON_STATUS_PRESSED, __itemTextColor[_BUTTON_STATUS_PRESSED]);
5173                 }
5174         }
5175
5176         return E_SUCCESS;
5177 }
5178
5179 Variant
5180 _Toolbar::GetPropertyPressedItemTextColor(void) const
5181 {
5182         return Variant(__itemTextColor[_BUTTON_STATUS_PRESSED]);
5183 }
5184
5185 result
5186 _Toolbar::SetPropertySelectedItemColor(const Variant& color)
5187 {
5188         __itemBackgroundColor[_BUTTON_STATUS_SELECTED] = color.ToColor();
5189
5190         Bitmap* __pBaseBackgroundBitmap = null;
5191
5192         if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT)
5193         {
5194                 GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
5195         }
5196         else
5197         {
5198                 GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap);
5199         }
5200
5201         for (int i = 0; i < __itemCount; i++)
5202         {
5203                 if (__pItems.at(i) != null)
5204                 {
5205                         if (__pBaseBackgroundBitmap)
5206                         {
5207                                 SetColorReplacedBitmap(__pItems.at(i), _BUTTON_STATUS_SELECTED, __itemBackgroundColor[_BUTTON_STATUS_SELECTED], __pBaseBackgroundBitmap);
5208                         }
5209                 }
5210         }
5211
5212         delete __pBaseBackgroundBitmap;
5213
5214         return E_SUCCESS;
5215 }
5216
5217 Variant
5218 _Toolbar::GetPropertySelectedItemColor(void) const
5219 {
5220         return Variant(__itemBackgroundColor[_BUTTON_STATUS_SELECTED]);
5221 }
5222
5223 result
5224 _Toolbar::SetPropertySelectedItemTextColor(const Variant& color)
5225 {
5226         __itemTextColor[_BUTTON_STATUS_SELECTED] = color.ToColor();
5227
5228         for (int i = 0; i < __itemCount; i++)
5229         {
5230                 if (__pItems.at(i) != null)
5231                 {
5232                         __pItems.at(i)->SetTextColor(_BUTTON_STATUS_SELECTED, __itemTextColor[_BUTTON_STATUS_SELECTED]);
5233                 }
5234         }
5235
5236         return E_SUCCESS;
5237 }
5238
5239 Variant
5240 _Toolbar::GetPropertySelectedItemTextColor(void) const
5241 {
5242         return Variant(__itemTextColor[_BUTTON_STATUS_SELECTED]);
5243 }
5244
5245 Rectangle
5246 _Toolbar::GetButtonBounds(ToolbarButton position) const
5247 {
5248         return __pButtonItems[position]->GetBounds();
5249 }
5250
5251 }}} // Tizen::Ui::Controls