Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_Form.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_Form.cpp
19  * @brief               This is the implementation file for the _Form class.
20  */
21
22 #include <new>
23 #include <FBaseErrorDefine.h>
24 #include <FBaseInteger.h>
25 #include <FBaseSysLog.h>
26 #include <FGrpFloatRectangle.h>
27 #include <FBase_Log.h>
28 #include <FGrp_BitmapImpl.h>
29 #include "FUi_ResourceManager.h"
30 #include "FUi_EcoreEvasMgr.h"
31 #include "FUi_EcoreEvas.h"
32 #include "FUi_CoordinateSystemUtils.h"
33 #include "FUi_DataBindingContext.h"
34 #include "FUi_AccessibilityContainer.h"
35 #include "FUi_AccessibilityManager.h"
36 #include "FUiCtrl_Form.h"
37 #include "FUiCtrl_Frame.h"
38 #include "FUiCtrl_FormPresenter.h"
39 #include "FUiCtrl_Toolbar.h"
40 #include "FUiCtrl_Tab.h"
41 #include "FUiCtrl_ActionEvent.h"
42 #include "FUiCtrl_OverlayRegionImpl.h"
43 #include "FUiCtrl_OverlayPanelImpl.h"
44 #include "FUiCtrl_IFormBackEventListener.h"
45 #include "FUiCtrl_Indicator.h"
46
47 using namespace Tizen::Ui::Animations;
48 using namespace Tizen::Ui;
49 using namespace Tizen::Base;  // Rotation
50 using namespace Tizen::Base::Runtime;
51 using namespace Tizen::Graphics;
52
53 namespace Tizen { namespace Ui { namespace Controls
54 {
55
56 _Form::_Form(void)
57         : __pFormPresenter(null)
58         , __pFormBackEventListener(null)
59         , __formStyle(0)
60         , __pActionEvent(null)
61         , __pHeader(null)
62         , __pFooter(null)
63         , __pTab(null)
64         , __pIndicator(null)
65         , __transparentIndicator(false)
66         , __transparentHeader(false)
67         , __transparentFooter(false)
68         , __transparentTab(false)
69         , __indicatorShowState(false)
70         , __deflated(false)
71         , __deflatedHeight(0)
72         , __overlayRegionCount(0)
73         , __ppOverlayerRegionImplArray(null)
74         , __softkeyCount(SOFTKEY_COUNT + 1)
75         , __updatedSoftkeyCount(0)
76 {
77         Color color;
78         result r = GET_COLOR_CONFIG(FORM::BG_NORMAL,color);
79         if (r == E_SUCCESS)
80         {
81                 SetBackgroundColor(color);
82         }
83         else
84         {
85                 SetBackgroundColor(0xff000000);
86         }
87
88         _FormPresenter* pPresenter = new (std::nothrow) _FormPresenter(*this);
89         SysTryReturnVoidResult(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
90
91         SetPresenter(*pPresenter);
92
93         for (int i = 0; i < __softkeyCount; i++)
94         {
95                 __actionId[_SOFTKEY_0 + i] = 0;
96                 __softkeyText[_SOFTKEY_0 + i] = String();
97                 __showSoftkey[_SOFTKEY_0 + i] = false;
98                 __enableSoftkey[_SOFTKEY_0 + i] = false;
99         }
100
101         for (int j = 0; j < SOFTKEY_COUNT+1; j++)
102         {
103                 __pSoftkeyNormalBitmap[_SOFTKEY_0 + j] = null;
104                 __pSoftkeyPressedBitmap[_SOFTKEY_0 + j] = null;
105         }
106
107         for (int j = 0; j < SOFTKEY_COUNT+1; j++)
108         {
109                 __pSoftkeyNormalEffectBitmap[_SOFTKEY_0 + j] = null;
110                 __pSoftkeyPressedEffectBitmap[_SOFTKEY_0 + j] = null;
111         }
112
113         for (int k = 0; k < SOFTKEY_COUNT; k++)
114         {
115                 __pSoftkeyNormalIcon[_SOFTKEY_0 + k] = null;
116                 __pSoftkeyPressedIcon[_SOFTKEY_0 + k] = null;
117         }
118
119         //create data binding context
120         _DataBindingContext* pContext = new (std::nothrow) _DataBindingContext(*this);
121         r = GetLastResult();
122         SysTryCatch(NID_UI_CTRL, pContext && GetLastResult() == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
123         SetDataBindingContext(pContext);
124
125         ClearLastResult();
126         GetAccessibilityContainer()->Activate(true);
127         return;
128
129 CATCH:
130         delete pContext;
131 }
132
133 _Form::~_Form(void)
134 {
135         delete __pFormPresenter;
136         __pFormPresenter = null;
137
138         if (__pActionEvent)
139         {
140                 delete __pActionEvent;
141                 __pActionEvent = null;
142         }
143
144         for (int i = 0; i < SOFTKEY_COUNT+1 ; i++)
145         {
146                 if (__pSoftkeyNormalBitmap[i])
147                 {
148                         delete __pSoftkeyNormalBitmap[i];
149                         __pSoftkeyNormalBitmap[i] = null;
150                 }
151         }
152
153         for (int i = 0; i < SOFTKEY_COUNT+1 ; i++)
154         {
155                 if (__pSoftkeyPressedBitmap[i])
156                 {
157                         delete __pSoftkeyPressedBitmap[i];
158                         __pSoftkeyPressedBitmap[i] = null;
159                 }
160         }
161
162         for (int i = 0; i < SOFTKEY_COUNT+1 ; i++)
163         {
164                 if (__pSoftkeyNormalEffectBitmap[i])
165                 {
166                         delete __pSoftkeyNormalEffectBitmap[i];
167                         __pSoftkeyNormalEffectBitmap[i] = null;
168                 }
169         }
170
171         for (int i = 0; i < SOFTKEY_COUNT+1 ; i++)
172         {
173                 if (__pSoftkeyPressedEffectBitmap[i])
174                 {
175                         delete __pSoftkeyPressedEffectBitmap[i];
176                         __pSoftkeyPressedEffectBitmap[i] = null;
177                 }
178         }
179
180         for (int i = 0; i < SOFTKEY_COUNT ; i++)
181         {
182                 if (__pSoftkeyNormalIcon[i])
183                 {
184                         delete __pSoftkeyNormalIcon[i];
185                         __pSoftkeyNormalIcon[i] = null;
186                 }
187
188                 if (__pSoftkeyPressedIcon[i])
189                 {
190                         delete __pSoftkeyPressedIcon[i];
191                         __pSoftkeyPressedIcon[i] = null;
192                 }
193         }
194
195         if (__ppOverlayerRegionImplArray != null)
196         {
197                 int maxCount = OverlayRegion::GetMaxCount();
198
199                 for (int i = 0; i < maxCount; i++)
200                 {
201                         if (__ppOverlayerRegionImplArray[i])
202                         {
203                                 OverlayRegion* _pOverlayRegion = __ppOverlayerRegionImplArray[i]->GetOverlayRegion();
204                                 delete _pOverlayRegion;
205                         }
206                 }
207
208                 delete[] __ppOverlayerRegionImplArray;
209         }
210
211         if (__pIndicator)
212         {
213                 delete __pIndicator;
214                 __pIndicator = null;
215         }
216
217         ClearLastResult();
218 }
219
220 _Form*
221 _Form::CreateFormN(void)
222 {
223         _Form* pForm = null;
224
225         pForm = new (std::nothrow) _Form;
226         SysTryReturn(NID_UI_CTRL, pForm, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
227         SysTryCatch(NID_UI_CTRL, GetLastResult() == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
228
229         pForm->SetTouchMoveAllowance(TOUCH_MOVE_ALLOWANCE_INSENSITIVE);
230
231         pForm->AcquireHandle();
232
233         SetLastResult(E_SUCCESS);
234
235         return pForm;
236
237 CATCH:
238         delete pForm;
239
240         return null;
241 }
242
243 result
244 _Form::SetPresenter(const _FormPresenter& formPresenter)
245 {
246         __pFormPresenter = const_cast <_FormPresenter*>(&formPresenter);
247
248         return E_SUCCESS;
249 }
250
251 void
252 _Form::OnDraw(void)
253 {
254         if (__pFormPresenter)
255         {
256                 __pFormPresenter->Draw();
257         }
258
259         if (__formStyle & FORM_STYLE_SOFTKEY_0 || __formStyle & FORM_STYLE_SOFTKEY_1 || __formStyle & FORM_STYLE_OPTIONKEY)
260         {
261                 if (__pFooter)
262                 {
263                         UpdateSoftkey(__formStyle);
264                 }
265         }
266         if(unlikely((_AccessibilityManager::IsActivated())))
267         {
268                 _AccessibilityManager::GetInstance()->RequestAutoReading();
269         }
270         return;
271 }
272
273 void
274 _Form::SetFormBackEventListener(_IFormBackEventListener* pFormBackEventListener)
275 {
276         SysTryReturnVoidResult(NID_UI_CTRL, __pFooter || __pHeader, E_INVALID_STATE, "[E_INVALID_STATE] Footer and Header aren't constructed.");
277         __pFormBackEventListener = pFormBackEventListener;
278         if (__pFooter)
279         {
280                 __pFooter->SetBackEventListener(*this, ID_BACK_BUTTON);
281         }
282         if (__pHeader)
283         {
284                 __pHeader->SetBackEventListener(*this, ID_BACK_BUTTON);
285         }
286
287         SetLastResult(E_SUCCESS);
288 }
289
290 unsigned long
291 _Form::GetFormStyle(void) const
292 {
293         return __formStyle;
294 }
295
296 _Toolbar*
297 _Form::GetFooter(void) const
298 {
299         return __pFooter;
300 }
301
302 _Toolbar*
303 _Form::GetHeader(void) const
304 {
305         return __pHeader;
306 }
307
308 _Tab*
309 _Form::GetTab(void) const
310 {
311         return __pTab;
312 }
313
314 _Indicator*
315 _Form::GetIndicator(void) const
316 {
317         return __pIndicator;
318 }
319
320 String
321 _Form::GetTitleText(void) const
322 {
323         if (__pHeader && (__formStyle & FORM_STYLE_TITLE))
324         {
325                 return __pHeader->GetTitleText();
326         }
327         else
328         {
329                 return String(L"");
330         }
331 }
332
333 HorizontalAlignment
334 _Form::GetTitleTextHorizontalAlignment(void) const
335 {
336         if (__pHeader && (__formStyle & FORM_STYLE_TITLE))
337         {
338                 return __pHeader->GetTitleTextHorizontalAlignment();
339         }
340         else
341         {
342                 SysLog(NID_UI_CTRL, "[E_SYSTEM] The title is not valid.");
343                 return ALIGNMENT_LEFT;
344         }
345 }
346
347 OverlayRegion*
348 _Form::GetOverlayRegionN(const Rectangle& rect, OverlayRegionType regionType)
349 {
350         _OverlayRegionImpl* pOverlayRegionImpl = null;
351         OverlayRegion* pOverlayRegion = null;
352         Color bgColor(0, 0, 0, 0);
353         int idx = 0;
354         int maxCount = 0;
355         _OverlayPanel* pOverlayPanel = null;
356         result r = E_SYSTEM;
357         bool modified = false;
358
359         ClearLastResult();
360
361         maxCount = OverlayRegion::GetMaxCount();
362         SysTryReturn(NID_UI_CTRL, maxCount > 0, null, E_SYSTEM, "[E_SYSTEM] maxCount [%d] is invalid", maxCount);
363
364         if (__ppOverlayerRegionImplArray == null)
365         {
366                 __ppOverlayerRegionImplArray = new (std::nothrow) _OverlayRegionImpl*[maxCount];
367                 SysTryReturn(NID_UI_CTRL, __ppOverlayerRegionImplArray != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Can not allocate memory for the OverlayRegionList.");
368
369                 for (int i = 0; i < maxCount; i++)
370                 {
371                         __ppOverlayerRegionImplArray[i] = null;
372                 }
373                 __overlayRegionCount = 0;
374         }
375
376         Rectangle clientRect(GetClientBounds());
377         Point overlayPosition(clientRect.x + rect.x, clientRect.y + rect.y);
378         Rectangle overlayRect(overlayPosition.x, overlayPosition.y, rect.width, rect.height);
379
380         Rectangle userPhyRect = _CoordinateSystemUtils::Transform(rect);
381         Rectangle devBounds = _CoordinateSystemUtils::Transform(overlayRect);
382
383         SysLog(NID_UI_CTRL, "rect [%d, %d, %d, %d] ", rect.x, rect.y, rect.width, rect.height);
384         SysLog(NID_UI_CTRL, "userPhyRect [%d, %d, %d, %d] ", userPhyRect.x, userPhyRect.y, userPhyRect.width, userPhyRect.height);
385         SysLog(NID_UI_CTRL, "overlayRect [%d, %d, %d, %d]", overlayPosition.x, overlayPosition.y, rect.width, rect.height);
386         SysLog(NID_UI_CTRL, "devBounds [%d, %d, %d, %d]", devBounds.x, devBounds.y, devBounds.width, devBounds.height);
387
388         // 1. width , height unit check
389         if (_OverlayRegionImpl::IsValidOverlayRect(overlayRect, devBounds, _CoordinateSystemUtils::Transform(clientRect), modified) != E_SUCCESS)
390         {
391                 SysTryReturn(NID_UI_CTRL, 0, null, E_INVALID_ARG, "[E_INVALID_ARG] IsValidOverlayRect is failed!");
392         }
393
394         if (modified)
395         {
396                 SysLog(NID_UI_CTRL, "devBounds modified [%d, %d, %d, %d]", devBounds.x, devBounds.y, devBounds.width, devBounds.height);
397         }
398
399         // 2. check for using OverlayPanel simutaneously
400         for (idx = 0 ; idx < GetChildCount() ; idx++)
401         {
402                 pOverlayPanel = dynamic_cast <_OverlayPanel*>(GetChild(idx));
403                 SysTryReturn(NID_UI_CTRL, pOverlayPanel == null, null, E_SYSTEM, "[E_SYSTEM] Using OverlayRegion mixed with OverlayPanel is not supported!");
404         }
405
406         // 3. find the empty slot idx
407         for (idx = 0; idx < maxCount; idx++)
408         {
409                 if (__ppOverlayerRegionImplArray[idx] == null)
410                 {
411                         break;
412                 }
413         }
414
415         SysTryReturn(NID_UI_CTRL, idx < maxCount, null, E_SYSTEM, "[E_SYSTEM] already used permitted maximum number of OverlayRegion!");
416
417         // 4. make OverlayRegion object
418         pOverlayRegionImpl = new (std::nothrow) _OverlayRegionImpl();
419         SysTryReturn(NID_UI_CTRL, pOverlayRegionImpl != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] failed to make the OverlayRegionImpl instance!");
420
421         r = pOverlayRegionImpl->Construct(this, regionType, overlayPosition, rect, devBounds);
422         if (r != E_SUCCESS)
423         {
424                 delete pOverlayRegionImpl;
425                 SysTryReturn(NID_UI_CTRL, 0, null, r, "[%s] Propagating.", GetErrorMessage(r));
426         }
427
428         pOverlayRegion = pOverlayRegionImpl->CreateOverlayRegionN();
429         if (pOverlayRegion == null)
430         {
431                 delete pOverlayRegionImpl;
432                 SysTryReturn(NID_UI_CTRL, 0, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
433         }
434
435         __ppOverlayerRegionImplArray[idx] = pOverlayRegionImpl;
436         pOverlayRegionImpl->SetFormArrayIndex(idx);
437
438         __overlayRegionCount++;
439
440         SetLastResult(E_SUCCESS);
441
442         return pOverlayRegion;
443 }
444
445 int
446 _Form::GetOverlayRegionCount(void) const
447 {
448         return __overlayRegionCount;
449 }
450
451 void
452 _Form::MoveOverlayRegion(bool top)
453 {
454         if (__ppOverlayerRegionImplArray == null)
455         {
456                 return;
457         }
458         for (int i = 0; i < OverlayRegion::GetMaxCount(); i++)
459         {
460                 if (__ppOverlayerRegionImplArray[i] != null)
461                 {
462                         if (top)
463                         {
464                                 __ppOverlayerRegionImplArray[i]->GoForeground();
465                         }
466                         else
467                         {
468                                 __ppOverlayerRegionImplArray[i]->GoBackground();
469                         }
470                 }
471         }
472 }
473
474 void
475 _Form::CreateSoftkey(unsigned long formStyle)
476 {
477         Bitmap* pTempBitmap = null;
478         Dimension softkeyDimension(0, 0);
479         Dimension softkeyDisplayDimension(0, 0);
480         Dimension optionkeyDimension(0, 0);
481         int softkeyTextSize = 0;
482         int leftSoftkeyLeftMargin = 0;
483         int rightSoftkeyLeftMargin = 0;
484         int softkeyTopMargin = 0;
485         Color softkeyNormalBackgroundColor;
486         Color softkeyPressedBackgroundColor;
487         Color softkeyNormalTextColor;
488         Color softkeyPressedTextColor;
489         Color softkeyNormalIconColor;
490         Color softkeyPressedIconColor;
491
492         GET_DIMENSION_CONFIG(FOOTER::SOFTKEY_RECT, GetOrientation(), softkeyDimension);
493         GET_DIMENSION_CONFIG(FOOTER::SOFTKEY_DISPLAY_RECT_WITH_TEXT, GetOrientation(), softkeyDisplayDimension);
494         GET_DIMENSION_CONFIG(FOOTER::OPTIONKEY_RECT, GetOrientation(), optionkeyDimension);
495         GET_SHAPE_CONFIG(FOOTER::SOFTKEY_TEXT_SIZE, GetOrientation(), softkeyTextSize);
496         GET_SHAPE_CONFIG(FOOTER::SOFTKEY_0_LEFT_MARGIN, GetOrientation(), leftSoftkeyLeftMargin);
497         GET_SHAPE_CONFIG(FOOTER::SOFTKEY_1_LEFT_MARGIN, GetOrientation(), rightSoftkeyLeftMargin);
498         GET_SHAPE_CONFIG(FOOTER::SOFTKEY_TOP_MARGIN, GetOrientation(), softkeyTopMargin);
499         GET_COLOR_CONFIG(FOOTER::SOFTKEY_BG_NORMAL, softkeyNormalBackgroundColor);
500         GET_COLOR_CONFIG(FOOTER::SOFTKEY_BG_PRESSED, softkeyPressedBackgroundColor);
501         GET_COLOR_CONFIG(FOOTER::SOFTKEY_TEXT_NORMAL, softkeyNormalTextColor);
502         GET_COLOR_CONFIG(FOOTER::SOFTKEY_TEXT_PRESSED, softkeyPressedTextColor);
503         GET_COLOR_CONFIG(FOOTER::SOFTKEY_ICON_NORMAL, softkeyNormalIconColor);
504         GET_COLOR_CONFIG(FOOTER::SOFTKEY_ICON_PRESSED, softkeyPressedIconColor);
505
506         result r = E_SUCCESS;
507
508         if (__pFooter != null)
509         {
510                 __pFooter->SetStyle(TOOLBAR_SOFTKEY);
511         }
512
513         if (formStyle & FORM_STYLE_SOFTKEY_0)
514         {
515                 r = GET_BITMAP_CONFIG_N(FOOTER::SOFTKEY_LEFT_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
516                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
517                 if (__pSoftkeyNormalBitmap[_SOFTKEY_0])
518                 {
519                         delete __pSoftkeyNormalBitmap[_SOFTKEY_0];
520                         __pSoftkeyNormalBitmap[_SOFTKEY_0] = null;
521                 }
522                 __pSoftkeyNormalBitmap[_SOFTKEY_0] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyNormalBackgroundColor);
523                 delete pTempBitmap;
524
525                 r = GET_BITMAP_CONFIG_N(FOOTER::SOFTKEY_LEFT_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
526                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
527                 if (__pSoftkeyPressedBitmap[_SOFTKEY_0])
528                 {
529                         delete __pSoftkeyPressedBitmap[_SOFTKEY_0];
530                         __pSoftkeyPressedBitmap[_SOFTKEY_0] = null;
531                 }
532                 __pSoftkeyPressedBitmap[_SOFTKEY_0] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyPressedBackgroundColor);
533                 delete pTempBitmap;
534
535                 r = GET_BITMAP_CONFIG_N(FOOTER::SOFTKEY_LEFT_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
536                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
537                 if (__pSoftkeyNormalEffectBitmap[_SOFTKEY_0])
538                 {
539                         delete __pSoftkeyNormalEffectBitmap[_SOFTKEY_0];
540                         __pSoftkeyNormalEffectBitmap[_SOFTKEY_0] = null;
541                 }
542                 __pSoftkeyNormalEffectBitmap[_SOFTKEY_0] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyNormalBackgroundColor);
543                 delete pTempBitmap;
544
545                 r = GET_BITMAP_CONFIG_N(FOOTER::SOFTKEY_LEFT_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
546                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
547                 if (__pSoftkeyPressedEffectBitmap[_SOFTKEY_0])
548                 {
549                         delete __pSoftkeyPressedEffectBitmap[_SOFTKEY_0];
550                         __pSoftkeyPressedEffectBitmap[_SOFTKEY_0] = null;
551                 }
552                 __pSoftkeyPressedEffectBitmap[_SOFTKEY_0] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyPressedBackgroundColor);
553                 delete pTempBitmap;
554
555                 r = GET_BITMAP_CONFIG_N(FOOTER::SOFTKEY_ICON_ADD_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
556                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
557
558                 if (__pSoftkeyNormalIcon[_SOFTKEY_0])
559                 {
560                         delete __pSoftkeyNormalIcon[_SOFTKEY_0];
561                         __pSoftkeyNormalIcon[_SOFTKEY_0] = null;
562                 }
563                 __pSoftkeyNormalIcon[_SOFTKEY_0] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyNormalIconColor);
564
565                 if (__pSoftkeyPressedIcon[_SOFTKEY_0])
566                 {
567                         delete __pSoftkeyPressedIcon[_SOFTKEY_0];
568                         __pSoftkeyPressedIcon[_SOFTKEY_0] = null;
569                 }
570                 __pSoftkeyPressedIcon[_SOFTKEY_0] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyPressedIconColor);
571
572                 delete pTempBitmap;
573
574                 _Button* pButton = _Button::CreateButtonN();
575
576                 if (pButton)
577                 {
578                         pButton->SetSize(softkeyDimension);
579                         pButton->SetTextSize(softkeyTextSize);
580                         pButton->SetUserDefinedTextArea(Rectangle(leftSoftkeyLeftMargin, softkeyTopMargin, softkeyDisplayDimension.width, softkeyDisplayDimension.height));
581                         pButton->SetTextColor(_BUTTON_STATUS_NORMAL, softkeyNormalTextColor);
582                         pButton->SetTextColor(_BUTTON_STATUS_PRESSED, softkeyPressedTextColor);
583                         __pFooter->SetButton(LEFT_BUTTON, pButton);
584                 }
585         }
586
587         if (formStyle & FORM_STYLE_SOFTKEY_1)
588         {
589                 r = GET_BITMAP_CONFIG_N(FOOTER::SOFTKEY_RIGHT_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
590                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
591                 if (__pSoftkeyNormalBitmap[_SOFTKEY_1])
592                 {
593                         delete __pSoftkeyNormalBitmap[_SOFTKEY_1];
594                         __pSoftkeyNormalBitmap[_SOFTKEY_1] = null;
595                 }
596                 __pSoftkeyNormalBitmap[_SOFTKEY_1] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyNormalBackgroundColor);
597                 delete pTempBitmap;
598
599                 r = GET_BITMAP_CONFIG_N(FOOTER::SOFTKEY_RIGHT_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
600                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
601                 if (__pSoftkeyPressedBitmap[_SOFTKEY_1])
602                 {
603                         delete __pSoftkeyPressedBitmap[_SOFTKEY_1];
604                         __pSoftkeyPressedBitmap[_SOFTKEY_1] = null;
605                 }
606                 __pSoftkeyPressedBitmap[_SOFTKEY_1] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyPressedBackgroundColor);
607                 delete pTempBitmap;
608
609                 r = GET_BITMAP_CONFIG_N(FOOTER::SOFTKEY_RIGHT_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
610                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
611                 if (__pSoftkeyNormalEffectBitmap[_SOFTKEY_1])
612                 {
613                         delete __pSoftkeyNormalEffectBitmap[_SOFTKEY_1];
614                         __pSoftkeyNormalEffectBitmap[_SOFTKEY_1] = null;
615                 }
616                 __pSoftkeyNormalEffectBitmap[_SOFTKEY_1] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyNormalBackgroundColor);
617                 delete pTempBitmap;
618
619                 r = GET_BITMAP_CONFIG_N(FOOTER::SOFTKEY_RIGHT_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
620                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
621                 if (__pSoftkeyPressedEffectBitmap[_SOFTKEY_1])
622                 {
623                         delete __pSoftkeyPressedEffectBitmap[_SOFTKEY_1];
624                         __pSoftkeyPressedEffectBitmap[_SOFTKEY_1] = null;
625                 }
626                 __pSoftkeyPressedEffectBitmap[_SOFTKEY_1] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyPressedBackgroundColor);
627                 delete pTempBitmap;
628
629                 r = GET_BITMAP_CONFIG_N(FOOTER::SOFTKEY_ICON_ZOOM_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
630                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
631
632                 if (__pSoftkeyNormalIcon[_SOFTKEY_1])
633                 {
634                         delete __pSoftkeyNormalIcon[_SOFTKEY_1];
635                         __pSoftkeyNormalIcon[_SOFTKEY_1] = null;
636                 }
637                 __pSoftkeyNormalIcon[_SOFTKEY_1] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyNormalIconColor);
638
639                 if (__pSoftkeyPressedIcon[_SOFTKEY_1])
640                 {
641                         delete __pSoftkeyPressedIcon[_SOFTKEY_1];
642                         __pSoftkeyPressedIcon[_SOFTKEY_1] = null;
643                 }
644                 __pSoftkeyPressedIcon[_SOFTKEY_1] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyPressedIconColor);
645
646                 delete pTempBitmap;
647
648                 _Button* pButton = _Button::CreateButtonN();
649                 if (pButton)
650                 {
651                         pButton->SetSize(softkeyDimension);
652                         pButton->SetTextSize(softkeyTextSize);
653                         pButton->SetUserDefinedTextArea(Rectangle(rightSoftkeyLeftMargin, softkeyTopMargin, softkeyDisplayDimension.width, softkeyDisplayDimension.height));
654                         pButton->SetTextColor(_BUTTON_STATUS_NORMAL, softkeyNormalTextColor);
655                         pButton->SetTextColor(_BUTTON_STATUS_PRESSED, softkeyPressedTextColor);
656                         __pFooter->SetButton(RIGHT_BUTTON, pButton);
657                 }
658         }
659
660         if (formStyle & FORM_STYLE_OPTIONKEY)
661         {
662                 r = GET_BITMAP_CONFIG_N(FOOTER::OPTIONKEY_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
663                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
664                 if (__pSoftkeyNormalBitmap[SOFTKEY_COUNT])
665                 {
666                         delete __pSoftkeyNormalBitmap[SOFTKEY_COUNT];
667                         __pSoftkeyNormalBitmap[SOFTKEY_COUNT] = null;
668                 }
669                 __pSoftkeyNormalBitmap[SOFTKEY_COUNT] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyNormalBackgroundColor);
670                 delete pTempBitmap;
671
672                 r = GET_BITMAP_CONFIG_N(FOOTER::OPTIONKEY_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
673                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
674                 if (__pSoftkeyPressedBitmap[SOFTKEY_COUNT])
675                 {
676                         delete __pSoftkeyPressedBitmap[SOFTKEY_COUNT];
677                         __pSoftkeyPressedBitmap[SOFTKEY_COUNT] = null;
678                 }
679                 __pSoftkeyPressedBitmap[SOFTKEY_COUNT] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyPressedBackgroundColor);
680                 delete pTempBitmap;
681
682                 r = GET_BITMAP_CONFIG_N(FOOTER::OPTIONKEY_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
683                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
684                 if (__pSoftkeyNormalEffectBitmap[SOFTKEY_COUNT])
685                 {
686                         delete __pSoftkeyNormalEffectBitmap[SOFTKEY_COUNT];
687                         __pSoftkeyNormalEffectBitmap[SOFTKEY_COUNT] = null;
688                 }
689                 __pSoftkeyNormalEffectBitmap[SOFTKEY_COUNT] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyNormalBackgroundColor);
690                 delete pTempBitmap;
691
692                 r = GET_BITMAP_CONFIG_N(FOOTER::OPTIONKEY_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
693                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
694                 if (__pSoftkeyPressedEffectBitmap[SOFTKEY_COUNT])
695                 {
696                         delete __pSoftkeyPressedEffectBitmap[SOFTKEY_COUNT];
697                         __pSoftkeyPressedEffectBitmap[SOFTKEY_COUNT] = null;
698                 }
699                 __pSoftkeyPressedEffectBitmap[SOFTKEY_COUNT] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyPressedBackgroundColor);
700                 delete pTempBitmap;
701
702                 _Button* pButton = _Button::CreateButtonN();
703                 if (pButton)
704                 {
705                         pButton->SetSize(optionkeyDimension);
706                         pButton->SetTextColor(_BUTTON_STATUS_NORMAL, softkeyNormalTextColor);
707                         pButton->SetTextColor(_BUTTON_STATUS_PRESSED, softkeyPressedTextColor);
708                         __pFooter->SetButton(MIDDLE_BUTTON, pButton);
709                 }
710         }
711 }
712
713 void
714 _Form::UpdateSoftkey(unsigned long formStyle)
715 {
716         int softkeyIconGap = 3;
717
718         if (__formStyle & FORM_STYLE_SOFTKEY_0)// && __updatedSoftkeyCount % 2 == 0)
719         {
720                 if (__pFooter->GetButton(LEFT_BUTTON))
721                 {
722                         __pFooter->GetButton(LEFT_BUTTON)->SetActionId(__actionId[_SOFTKEY_0]);
723
724                         if (__pSoftkeyNormalBitmap[_SOFTKEY_0])
725                         {
726                                 __pFooter->GetButton(LEFT_BUTTON)->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *__pSoftkeyNormalBitmap[_SOFTKEY_0]);
727                         }
728
729                         if (__pSoftkeyNormalEffectBitmap[_SOFTKEY_0])
730                         {
731                                 __pFooter->GetButton(LEFT_BUTTON)->SetBackgroundEffectBitmap(_BUTTON_STATUS_NORMAL, *__pSoftkeyNormalEffectBitmap[_SOFTKEY_0]);
732                         }
733
734                         if (__pSoftkeyPressedBitmap[_SOFTKEY_0])
735                         {
736                                 __pFooter->GetButton(LEFT_BUTTON)->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *__pSoftkeyPressedBitmap[_SOFTKEY_0]);
737                         }
738
739                         if (__pSoftkeyPressedEffectBitmap[_SOFTKEY_0])
740                         {
741                                 __pFooter->GetButton(LEFT_BUTTON)->SetBackgroundEffectBitmap(_BUTTON_STATUS_PRESSED, *__pSoftkeyPressedEffectBitmap[_SOFTKEY_0]);
742                         }
743
744                         if (__softkeyText[_SOFTKEY_0] != String())
745                         {
746                                 __pFooter->GetButton(LEFT_BUTTON)->SetText(__softkeyText[_SOFTKEY_0]);
747
748                                 __pFooter->RearrangeItems();
749                         }
750                         else
751                         {
752                                 if (__pSoftkeyNormalIcon[_SOFTKEY_0])
753                                 {
754                                         __pFooter->GetButton(LEFT_BUTTON)->SetBitmap(_BUTTON_STATUS_NORMAL,
755                                                         Point((__pFooter->GetButton(LEFT_BUTTON)->GetSize().width - __pSoftkeyNormalIcon[_SOFTKEY_0]->GetWidth()) / 2,
756                                                                         (__pFooter->GetButton(LEFT_BUTTON)->GetSize().height - __pSoftkeyNormalIcon[_SOFTKEY_0]->GetHeight()) / 2 + softkeyIconGap), *__pSoftkeyNormalIcon[_SOFTKEY_0]);
757                                 }
758
759                                 if (__pSoftkeyPressedIcon[_SOFTKEY_0])
760                                 {
761                                         __pFooter->GetButton(LEFT_BUTTON)->SetBitmap(_BUTTON_STATUS_PRESSED,
762                                                         Point((__pFooter->GetButton(LEFT_BUTTON)->GetSize().width - __pSoftkeyPressedIcon[_SOFTKEY_0]->GetWidth()) / 2,
763                                                                         (__pFooter->GetButton(LEFT_BUTTON)->GetSize().height - __pSoftkeyPressedIcon[_SOFTKEY_0]->GetHeight()) / 2 + softkeyIconGap), *__pSoftkeyPressedIcon[_SOFTKEY_0]);
764                                 }
765                         }
766                 }
767         }
768
769         if (__formStyle & FORM_STYLE_SOFTKEY_1)// && __updatedSoftkeyCount % 2 == 0)
770         {
771                 if (__pFooter->GetButton(RIGHT_BUTTON))
772                 {
773                         __pFooter->GetButton(RIGHT_BUTTON)->SetActionId(__actionId[_SOFTKEY_1]);
774
775                         if (__pSoftkeyNormalBitmap[_SOFTKEY_1])
776                         {
777                                 __pFooter->GetButton(RIGHT_BUTTON)->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *__pSoftkeyNormalBitmap[_SOFTKEY_1]);
778                         }
779
780                         if (__pSoftkeyNormalEffectBitmap[_SOFTKEY_1])
781                         {
782                                 __pFooter->GetButton(RIGHT_BUTTON)->SetBackgroundEffectBitmap(_BUTTON_STATUS_NORMAL, *__pSoftkeyNormalEffectBitmap[_SOFTKEY_1]);
783                         }
784
785                         if (__pSoftkeyPressedBitmap[_SOFTKEY_1])
786                         {
787                                 __pFooter->GetButton(RIGHT_BUTTON)->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *__pSoftkeyPressedBitmap[_SOFTKEY_1]);
788                         }
789
790                         if (__pSoftkeyPressedEffectBitmap[_SOFTKEY_1])
791                         {
792                                 __pFooter->GetButton(RIGHT_BUTTON)->SetBackgroundEffectBitmap(_BUTTON_STATUS_PRESSED, *__pSoftkeyPressedEffectBitmap[_SOFTKEY_1]);
793                         }
794
795                         if (__softkeyText[_SOFTKEY_1] != String())
796                         {
797                                 __pFooter->GetButton(RIGHT_BUTTON)->SetText(__softkeyText[_SOFTKEY_1]);
798
799                                 __pFooter->RearrangeItems();
800                         }
801                         else
802                         {
803                                 if (__pSoftkeyNormalIcon[_SOFTKEY_1])
804                                 {
805                                         __pFooter->GetButton(RIGHT_BUTTON)->SetBitmap(_BUTTON_STATUS_NORMAL,
806                                                         Point((__pFooter->GetButton(RIGHT_BUTTON)->GetSize().width - __pSoftkeyNormalIcon[_SOFTKEY_1]->GetWidth()) / 2,
807                                                                         (__pFooter->GetButton(RIGHT_BUTTON)->GetSize().height - __pSoftkeyNormalIcon[_SOFTKEY_1]->GetHeight()) / 2 + softkeyIconGap), *__pSoftkeyNormalIcon[_SOFTKEY_1]);
808                                 }
809
810                                 if (__pSoftkeyPressedIcon[_SOFTKEY_1])
811                                 {
812                                         __pFooter->GetButton(RIGHT_BUTTON)->SetBitmap(_BUTTON_STATUS_PRESSED,
813                                                         Point((__pFooter->GetButton(RIGHT_BUTTON)->GetSize().width - __pSoftkeyPressedIcon[_SOFTKEY_1]->GetWidth()) / 2,
814                                                                         (__pFooter->GetButton(RIGHT_BUTTON)->GetSize().height - __pSoftkeyPressedIcon[_SOFTKEY_1]->GetHeight()) / 2 + softkeyIconGap), *__pSoftkeyPressedIcon[_SOFTKEY_1]);
815                                 }
816                         }
817                 }
818         }
819
820         if (__formStyle & FORM_STYLE_OPTIONKEY)// && __updatedSoftkeyCount % 2 == 0)
821         {
822                 if (__pFooter->GetButton(MIDDLE_BUTTON))
823                 {
824                         __pFooter->GetButton(MIDDLE_BUTTON)->SetActionId(__actionId[SOFTKEY_COUNT]);
825
826                         if (__pSoftkeyNormalBitmap[SOFTKEY_COUNT])
827                         {
828                                 __pFooter->GetButton(MIDDLE_BUTTON)->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *__pSoftkeyNormalBitmap[SOFTKEY_COUNT]);
829                         }
830
831                         if (__pSoftkeyPressedBitmap[SOFTKEY_COUNT])
832                         {
833                                 __pFooter->GetButton(MIDDLE_BUTTON)->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *__pSoftkeyPressedBitmap[SOFTKEY_COUNT]);
834                         }
835
836                         if (__pSoftkeyNormalEffectBitmap[SOFTKEY_COUNT])
837                         {
838                                 __pFooter->GetButton(MIDDLE_BUTTON)->SetBackgroundEffectBitmap(_BUTTON_STATUS_NORMAL, *__pSoftkeyNormalEffectBitmap[SOFTKEY_COUNT]);
839                         }
840
841                         if (__pSoftkeyPressedEffectBitmap[SOFTKEY_COUNT])
842                         {
843                                 __pFooter->GetButton(MIDDLE_BUTTON)->SetBackgroundEffectBitmap(_BUTTON_STATUS_PRESSED, *__pSoftkeyPressedEffectBitmap[SOFTKEY_COUNT]);
844                         }
845                 }
846         }
847
848         //__updatedSoftkeyCount++;
849 }
850
851 String
852 _Form::GetDescription(void) const
853 {
854         String description = _Control::GetDescription();
855
856         String descriptionTemp(L"");
857
858         descriptionTemp.Format(LOG_LEN_MAX, L"_Form: style(%d) transparent(%d %d %d %d) deflated(%d) deflatedHeight(%d) overlayRegionCount(%d) softkeyCount(%d) updatedSoftkeyCount(%d)",
859                 __formStyle, __transparentIndicator, __transparentHeader, __transparentFooter, __transparentTab, __deflated, __deflatedHeight,
860                 __overlayRegionCount, __softkeyCount, __updatedSoftkeyCount);
861
862         description.Append(descriptionTemp);
863
864         return description;
865 }
866
867 Canvas*
868 _Form::GetClientAreaCanvasN(void) const
869 {
870         Canvas* pCanvas = GetCanvasN(GetClientBounds());
871         if ((pCanvas == null) || (GetLastResult() != E_SUCCESS))
872         {
873                 SysLog(NID_UI_CTRL, "[%s] Propagated.", GetErrorMessage(GetLastResult()));
874                 delete pCanvas;
875                 return null;
876         }
877
878         return pCanvas;
879 }
880
881 int
882 _Form::GetSoftkeyActionId(_Softkey softkey) const
883 {
884         if (CheckSoftkey(softkey) == false)
885         {
886                 return -1;
887         }
888
889         return __actionId[softkey];
890 }
891
892 int
893 _Form::GetOptionkeyActionId(void) const
894 {
895         if (HasOptionkey() == false)
896         {
897                 return -1;
898         }
899
900         return __actionId[SOFTKEY_COUNT];
901 }
902
903 String
904 _Form::GetSoftkeyText(_Softkey softkey) const
905 {
906         if (CheckSoftkey(softkey) == false)
907         {
908                 return String(L"");
909         }
910
911         return __softkeyText[softkey];
912 }
913
914 void
915 _Form::SetFormStyle(unsigned long formStyle)
916 {
917         result r = E_SUCCESS;
918
919         __formStyle = formStyle;
920
921         if (!__pIndicator)
922         {
923                 __pIndicator = CreateIndicatorN();
924                 SysTryReturnVoidResult(NID_UI_CTRL, __pIndicator != null, r, "[%s] Propagating.", GetErrorMessage(r));
925
926                 int indicatorwidth = GetClientBounds().width;
927                 int indicatorheight = 0;
928
929                 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorheight);
930
931                 __pIndicator->SetBounds(Rectangle(0, 0, indicatorwidth, indicatorheight));
932                 r = AttachSystemChild(*__pIndicator);
933                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
934
935                 r = GetLastResult();
936                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
937         }
938 }
939
940 result
941 _Form::SetActionBarsTranslucent(unsigned long actionBars, bool translucent)
942 {
943         SysTryReturn(
944                         NID_UI_CTRL,
945                         ((actionBars & FORM_ACTION_BAR_INDICATOR) || (actionBars & FORM_ACTION_BAR_HEADER) ||
946                                         (actionBars & FORM_ACTION_BAR_FOOTER) || (actionBars & FORM_ACTION_BAR_TAB)),
947                                         E_INVALID_OPERATION, E_INVALID_OPERATION,
948                                         ("[E_INVALID_OPERATION] The current state of the instance prohibits the execution of the specified operation."));
949
950         if ((!(__formStyle & FORM_STYLE_INDICATOR) && (actionBars & FORM_ACTION_BAR_INDICATOR))
951                 || (!(__formStyle & FORM_STYLE_HEADER) && (actionBars & FORM_ACTION_BAR_HEADER))
952                 || (!(__formStyle & FORM_STYLE_FOOTER) && (actionBars & FORM_ACTION_BAR_FOOTER))
953                 || (!(__formStyle & FORM_STYLE_TEXT_TAB) && (actionBars & FORM_ACTION_BAR_TAB)))
954         {
955                 SysLog(NID_UI_CTRL,
956                         "[E_INVALID_OPERATION] The current state of the instance prohibits the execution of the specified operation.");
957                 return E_INVALID_OPERATION;
958         }
959
960         result r = E_SUCCESS;
961
962         Color bgColor(0, 0, 0, 0);
963         if (actionBars & FORM_ACTION_BAR_INDICATOR)
964         {
965                 if (translucent)
966                 {
967                         r = SetIndicatorOpacity(_INDICATOR_OPACITY_TRANSLUCENT);
968                 }
969                 else
970                 {
971                         r = SetIndicatorOpacity(_INDICATOR_OPACITY_OPAQUE);
972                 }
973                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
974         }
975
976         if (actionBars & FORM_ACTION_BAR_HEADER)
977         {
978                 if (IsHeaderTranslucent() != translucent)
979                 {
980                         if (__pHeader)
981                         {
982                                 __pHeader->SetTransparent(translucent);
983                                 __transparentHeader = translucent;
984                         }
985                 }
986         }
987
988         if (IsIndicatorTranslucent() != IsHeaderTranslucent())
989         {
990                 if (IsIndicatorTranslucent())
991                 {
992                         r = SetIndicatorOpacity(_INDICATOR_OPACITY_OPAQUE);
993                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
994                 }
995         }
996
997         if (actionBars & FORM_ACTION_BAR_FOOTER)
998         {
999                 if (IsFooterTranslucent() != translucent)
1000                 {
1001                         if (__pFooter)
1002                         {
1003                                 __pFooter->SetTransparent(translucent);
1004                                 __transparentFooter = translucent;
1005                         }
1006                 }
1007         }
1008
1009         AdjustClientBounds();
1010
1011         return E_SUCCESS;
1012 }
1013
1014 result
1015 _Form::SetActionBarsVisible(unsigned long actionBars, bool visible)
1016 {
1017         SysTryReturn(
1018                 NID_UI_CTRL,
1019                 ((actionBars & FORM_ACTION_BAR_INDICATOR) || (actionBars & FORM_ACTION_BAR_HEADER) ||
1020                  (actionBars & FORM_ACTION_BAR_FOOTER)),
1021                 E_INVALID_OPERATION,
1022                 E_INVALID_OPERATION,
1023                 ("[E_INVALID_OPERATION] The current state of the instance prohibits the execution of the specified operation. "));
1024
1025         if ((!(__formStyle & FORM_STYLE_INDICATOR) && (actionBars & FORM_ACTION_BAR_INDICATOR))
1026                 || (!(__formStyle & FORM_STYLE_HEADER) && (actionBars & FORM_ACTION_BAR_HEADER))
1027                 || (!(__formStyle & FORM_STYLE_FOOTER) && (actionBars & FORM_ACTION_BAR_FOOTER)))
1028         {
1029                 SysLog(NID_UI_CTRL, "[E_INVALID_OPERATION] The current state of the instance prohibits the execution of the specified operation.");
1030                 return E_INVALID_OPERATION;
1031         }
1032
1033         Rectangle bounds = GetBounds();
1034         SetBounds(bounds);
1035
1036         if (actionBars & FORM_ACTION_BAR_INDICATOR)
1037         {
1038                 SetIndicatorShowState(visible);
1039         }
1040
1041         if (actionBars & FORM_ACTION_BAR_HEADER)
1042         {
1043                 if (IsHeaderVisible() != visible)
1044                 {
1045                         if (__pHeader)
1046                         {
1047                                 if (visible == true)
1048                                 {
1049                                         int adjHeight = 0;
1050                                         if (IsIndicatorVisible())
1051                                         {
1052                                                 Rectangle indicatorBounds = GetIndicatorBounds();
1053                                                 adjHeight = indicatorBounds.height;
1054                                         }
1055                                         Rectangle bounds = __pHeader->GetBounds();
1056                                         bounds.y = adjHeight;
1057
1058                                         SetHeaderBounds(bounds);
1059                                 }
1060                                 __pHeader->SetVisibleState(visible);
1061                         }
1062                 }
1063         }
1064
1065         if (actionBars & FORM_ACTION_BAR_FOOTER)
1066         {
1067                 if (__pFooter)
1068                 {
1069                         __pFooter->SetVisibleState(visible);
1070                 }
1071         }
1072
1073         AdjustClientBounds();
1074
1075         return E_SUCCESS;
1076 }
1077
1078 result
1079 _Form::SetTitleIcon(const Bitmap* pTitleBitmap)
1080 {
1081         SysTryReturn(NID_UI_CTRL, (__formStyle & FORM_STYLE_TITLE), E_INVALID_OPERATION,
1082                         E_INVALID_OPERATION, "[E_INVALID_OPERATION] This API is only for FORM_STYLE_TITLE.");
1083
1084         SysTryReturn(NID_UI_CTRL, __pHeader, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] The title is not valid.");
1085
1086         result r = __pHeader->SetTitleIcon(*pTitleBitmap);
1087         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1088
1089         return r;
1090 }
1091
1092 result
1093 _Form::SetTitleText(const String& title, HorizontalAlignment alignment)
1094 {
1095         SysTryReturn(NID_UI_CTRL, (__formStyle & FORM_STYLE_TITLE), E_INVALID_OPERATION,
1096                                 E_INVALID_OPERATION, "[E_INVALID_OPERATION] This API is only for FORM_STYLE_TITLE.");
1097
1098         SysTryReturn(NID_UI_CTRL, __pHeader, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] The title is not valid.");
1099
1100         result r = __pHeader->SetTitleText(title, alignment);
1101         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1102
1103         return r;
1104 }
1105
1106 result
1107 _Form::SetSoftkeyEnabled(_Softkey softkey, bool enable)
1108 {
1109         result r = E_SYSTEM;
1110
1111         if (CheckSoftkey(softkey) == false)
1112         {
1113                 return r;
1114         }
1115
1116         __enableSoftkey[softkey] = enable;
1117
1118         r = E_SUCCESS;
1119
1120         return r;
1121 }
1122
1123 result
1124 _Form::SetOptionkeyActionId(int actionId)
1125 {
1126         result r = E_SYSTEM;
1127
1128         if (HasOptionkey() == false)
1129         {
1130                 return r;
1131         }
1132
1133         __actionId[SOFTKEY_COUNT] = actionId;
1134
1135         r = E_SUCCESS;
1136
1137         return r;
1138 }
1139
1140 result
1141 _Form::SetSoftkeyActionId(_Softkey softkey, int actionId)
1142 {
1143         result r = E_SYSTEM;
1144
1145         if (CheckSoftkey(softkey) == false)
1146         {
1147                 return r;
1148         }
1149
1150         __actionId[softkey] = actionId;
1151
1152         r = E_SUCCESS;
1153
1154         return r;
1155 }
1156
1157 result
1158 _Form::SetSoftkeyText(_Softkey softkey, const String& text)
1159 {
1160         result r = E_SYSTEM;
1161
1162         if (CheckSoftkey(softkey) == false)
1163         {
1164                 return r;
1165         }
1166
1167         __softkeyText[softkey] = text;
1168
1169         r = E_SUCCESS;
1170
1171         return r;
1172 }
1173
1174 result
1175 _Form::SetSoftkeyIcon(_Softkey softkey, const Bitmap& normalBitmap, const Bitmap* pPressedBitmap)
1176 {
1177         result r = E_SYSTEM;
1178
1179         if (CheckSoftkey(softkey) == false)
1180         {
1181                 return r;
1182         }
1183
1184         int softkey_icon_size = 0;
1185
1186         GET_SHAPE_CONFIG(FOOTER::SOFTKEY_ICON_SIZE, GetOrientation(), softkey_icon_size);
1187
1188         Bitmap* pClonedNormalBitmap = _BitmapImpl::CloneN(normalBitmap);
1189
1190         if (pClonedNormalBitmap)
1191         {
1192                 if (__pSoftkeyNormalIcon[softkey] != null)
1193                 {
1194                         delete __pSoftkeyNormalIcon[softkey];
1195                 }
1196
1197                 __pSoftkeyNormalIcon[softkey] = pClonedNormalBitmap;
1198
1199                 __pSoftkeyNormalIcon[softkey]->Scale(Dimension(softkey_icon_size, softkey_icon_size));
1200
1201                 r = E_SUCCESS;
1202         }
1203
1204         if (pPressedBitmap != null)
1205         {
1206                 Bitmap* pClonedPressedBitmap = _BitmapImpl::CloneN(*pPressedBitmap);
1207
1208                 if (pClonedPressedBitmap)
1209                 {
1210                         if (__pSoftkeyPressedIcon[softkey] != null)
1211                         {
1212                                 delete __pSoftkeyPressedIcon[softkey];
1213                         }
1214
1215                         __pSoftkeyPressedIcon[softkey] = pClonedPressedBitmap;
1216
1217                         __pSoftkeyPressedIcon[softkey]->Scale(Dimension(softkey_icon_size, softkey_icon_size));
1218
1219                         r = E_SUCCESS;
1220                 }
1221         }
1222
1223         return r;
1224 }
1225
1226 bool
1227 _Form::HasFooter(void) const
1228 {
1229         if (__pFooter)
1230         {
1231                 return true;
1232         }
1233         else
1234         {
1235                 return false;
1236         }
1237 }
1238
1239 bool
1240 _Form::HasHeader(void) const
1241 {
1242         if (__pHeader)
1243         {
1244                 return true;
1245         }
1246         else
1247         {
1248                 return false;
1249         }
1250 }
1251
1252 bool
1253 _Form::HasIndicator(void) const
1254 {
1255         if (__pIndicator && (GetFormStyle() & FORM_STYLE_INDICATOR))
1256         {
1257                 return true;
1258         }
1259         else
1260         {
1261                 return false;
1262         }
1263 }
1264
1265 bool
1266 _Form::HasTitle(void) const
1267 {
1268         if (__pHeader && (__formStyle & FORM_STYLE_TITLE))
1269         {
1270                 return true;
1271         }
1272         else
1273         {
1274                 return false;
1275         }
1276 }
1277
1278 bool
1279 _Form::HasTab(void) const
1280 {
1281         if ((__pTab && (__formStyle & FORM_STYLE_TEXT_TAB))
1282 || (__pTab && (__formStyle & FORM_STYLE_ICON_TAB)))
1283         {
1284                 return true;
1285         }
1286         else
1287         {
1288                 return false;
1289         }
1290 }
1291
1292 bool
1293 _Form::IsIndicatorVisible(void) const
1294 {
1295         _Control* pParent = GetParent();
1296         _Frame* pFrame = dynamic_cast<_Frame*>(pParent);
1297
1298         bool visible = true;
1299
1300         if (pFrame && IsAttachedToMainTree())
1301         {
1302                 visible = __pIndicator->GetIndicatorShowState();
1303                 SysTryReturn(NID_UI_CTRL, GetLastResult() == E_SUCCESS, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1304         }
1305         else
1306         {
1307                 visible = __indicatorShowState;
1308         }
1309
1310         return visible;
1311 }
1312
1313 bool
1314 _Form::IsHeaderVisible(void) const
1315 {
1316         if (__pHeader)
1317         {
1318                 return __pHeader->IsVisible();
1319         }
1320         else
1321         {
1322                 SysLog(NID_UI_CTRL, "[E_SYSTEM] The header is not valid.");
1323                 return false;
1324         }
1325 }
1326
1327 bool
1328 _Form::IsFooterVisible(void) const
1329 {
1330         if (__pFooter)
1331         {
1332                 return __pFooter->IsVisible();
1333         }
1334         else
1335         {
1336                 SysLog(NID_UI_CTRL, "[E_SYSTEM] The footer is not valid.");
1337                 return false;
1338         }
1339 }
1340
1341 bool
1342 _Form::IsIndicatorTranslucent(void) const
1343 {
1344         _Control* pParent = GetParent();
1345         _Frame* pFrame = dynamic_cast<_Frame*>(pParent);
1346
1347         _IndicatorOpacity opacity = _INDICATOR_OPACITY_UNKNOWN;
1348
1349         bool transparent = false;
1350
1351         if (pFrame && IsAttachedToMainTree())
1352         {
1353                 FrameShowMode mode = pFrame->GetShowMode();
1354                 if (mode == FRAME_SHOW_MODE_FULL_SCREEN)
1355                 {
1356                         opacity = __pIndicator->GetIndicatorOpacity();
1357                         SysTryReturn(NID_UI_CTRL, GetLastResult() == E_SUCCESS, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1358
1359                         if (opacity == _INDICATOR_OPACITY_TRANSLUCENT)
1360                         {
1361                                 transparent = true;
1362                         }
1363                         else if (opacity == _INDICATOR_OPACITY_OPAQUE)
1364                         {
1365                                 transparent = false;
1366                         }
1367                 }
1368         }
1369         else
1370         {
1371                 transparent = __transparentIndicator;
1372         }
1373
1374         return transparent;
1375 }
1376
1377 bool
1378 _Form::IsHeaderTranslucent(void) const
1379 {
1380         return __transparentHeader;
1381 }
1382
1383 bool
1384 _Form::IsFooterTranslucent(void) const
1385 {
1386         return __transparentFooter;
1387 }
1388
1389 bool
1390 _Form::IsTabTranslucent(void) const
1391 {
1392         return __transparentTab;
1393 }
1394
1395 bool
1396 _Form::HasOptionkey(void) const
1397 {
1398         if (GetFormStyle() & FORM_STYLE_OPTIONKEY)
1399         {
1400                 return true;
1401         }
1402         else
1403         {
1404                 return false;
1405         }
1406 }
1407
1408 bool
1409 _Form::HasSoftkey(_Softkey softkey) const
1410 {
1411         unsigned long __formStyle = FORM_STYLE_NORMAL;
1412
1413         if (softkey == _SOFTKEY_0)
1414         {
1415                 __formStyle = FORM_STYLE_SOFTKEY_0;
1416         }
1417         else if (softkey == _SOFTKEY_1)
1418         {
1419                 __formStyle = FORM_STYLE_SOFTKEY_1;
1420         }
1421         else
1422         {
1423                 return false;
1424         }
1425
1426         if (GetFormStyle() & __formStyle)
1427         {
1428                 return true;
1429         }
1430         else
1431         {
1432                 return false;
1433         }
1434 }
1435
1436 bool
1437 _Form::IsSoftkeyEnabled(_Softkey softkey) const
1438 {
1439         if (CheckSoftkey(softkey) == false)
1440         {
1441                 return false;
1442         }
1443
1444         return __enableSoftkey[softkey];
1445 }
1446
1447 bool
1448 _Form::CheckSoftkey(_Softkey softkey) const
1449 {
1450         bool result = true;
1451
1452         if (HasSoftkey(softkey) == false)
1453         {
1454                 return false;
1455         }
1456
1457         if (softkey >= _SOFTKEY_COUNT)
1458         {
1459                 return false;
1460         }
1461
1462         return result;
1463 }
1464
1465 bool
1466 _Form::IsOrientationRoot(void) const
1467 {
1468         return true;
1469 }
1470
1471 Point
1472 _Form::TranslateToClientAreaPosition(const Point& position) const
1473 {
1474         Rectangle clientArea = GetClientBounds();
1475         return Point(position.x - clientArea.x, position.y - clientArea.y);
1476 }
1477
1478 Point
1479 _Form::TranslateFromClientAreaPosition(const Point& clientPosition) const
1480 {
1481         Rectangle clientArea = GetClientBounds();
1482         return Point(clientPosition.x + clientArea.x, clientPosition.y + clientArea.y);
1483 }
1484
1485 bool
1486 _Form::DeflateClientRectHeight(int height)
1487 {
1488         if (    height > 0)
1489         {
1490                 __deflated = true;
1491         }
1492         else
1493         {
1494                 __deflated = false;
1495         }
1496
1497         __deflatedHeight = height;
1498
1499         AdjustClientBounds();
1500
1501         if (__pFooter)
1502         {
1503                 int adjHeight = 0;
1504
1505                 if (!(__pFooter->GetVisibleState()) || IsFooterTranslucent())
1506                 {
1507                         adjHeight = GetToolbarHeight(false);
1508                 }
1509
1510                 Rectangle bounds(0, GetClientBounds().y + GetClientBounds().height-adjHeight,
1511                                                                                 GetClientBounds().width, GetToolbarHeight(false));
1512                 SetFooterBounds(bounds);
1513         }
1514
1515         return true;
1516 }
1517
1518 _Toolbar*
1519 _Form::CreateHeaderN(void)
1520 {
1521         _Toolbar* __pHeader = _Toolbar::CreateToolbarN(true);
1522         SysTryReturn(NID_UI_CTRL, __pHeader, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1523
1524         return __pHeader;
1525 }
1526
1527 _Toolbar*
1528 _Form::CreateFooterN(void)
1529 {
1530         _Toolbar* __pFooter = _Toolbar::CreateToolbarN(false);
1531         SysTryReturn(NID_UI_CTRL, __pFooter, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1532
1533         return __pFooter;
1534 }
1535
1536 _Tab*
1537 _Form::CreateTabN(void)
1538 {
1539         _Tab* __pTab = _Tab::CreateTabN();
1540         SysTryReturn(NID_UI_CTRL, __pTab, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1541
1542         return __pTab;
1543 }
1544
1545 _Indicator*
1546 _Form::CreateIndicatorN(void)
1547 {
1548         _Indicator* pIndicator = new (std::nothrow) _Indicator;
1549         SysTryReturn(NID_UI_CTRL, pIndicator, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1550
1551         return pIndicator;
1552 }
1553
1554 int
1555 _Form::GetToolbarHeight(bool header) const
1556 {
1557         int toolbarHeight = 0;
1558
1559         if (header && (__formStyle & FORM_STYLE_HEADER))
1560         {
1561                 if (__pHeader)
1562                 {
1563                         toolbarHeight = __pHeader->GetBounds().height;
1564                 }
1565         }
1566         else if (header && (__formStyle & FORM_STYLE_TITLE))
1567         {
1568                 GET_SHAPE_CONFIG(HEADER::HEIGHT, GetOrientation(), toolbarHeight);
1569         }
1570         else if (__formStyle & FORM_STYLE_SOFTKEY_0 || __formStyle & FORM_STYLE_SOFTKEY_1 || __formStyle & FORM_STYLE_OPTIONKEY)
1571         {
1572                 GET_SHAPE_CONFIG(FOOTER::SOFTKEY_HEIGHT, GetOrientation(), toolbarHeight);
1573         }
1574         else
1575         {
1576                 if (__pFooter)
1577                 {
1578                         toolbarHeight = __pFooter->GetBounds().height;
1579                 }
1580
1581                 //GET_SHAPE_CONFIG(L"FOOTER_HEIGHT", GetOrientation(), toolbarHeight);
1582         }
1583
1584         return toolbarHeight;
1585 }
1586
1587 int
1588 _Form::GetTabHeight(void) const
1589 {
1590         int height = 0;
1591
1592         if ((__formStyle & FORM_STYLE_TEXT_TAB) || (__formStyle & FORM_STYLE_ICON_TAB))
1593         {
1594                 GET_SHAPE_CONFIG(TAB::HEIGHT, GetOrientation(), height);
1595         }
1596
1597         return height;
1598 }
1599
1600 bool
1601 _Form::RemoveHeader(void)
1602 {
1603         result r = E_SUCCESS;
1604         if (__pHeader)
1605         {
1606                 r = DetachSystemChild(*__pHeader);
1607                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1608                 __pHeader = null;
1609
1610                 AdjustClientBounds();
1611         }
1612         else
1613         {
1614                 return false;
1615         }
1616
1617         return true;
1618 }
1619
1620 bool
1621 _Form::RemoveFooter(void)
1622 {
1623         result r = E_SUCCESS;
1624         if (__pFooter)
1625         {
1626                 r = DetachSystemChild(*__pFooter);
1627                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1628                 __pFooter = null;
1629
1630                 AdjustClientBounds();
1631         }
1632         else
1633         {
1634                 return false;
1635         }
1636
1637         return true;
1638 }
1639
1640 bool
1641 _Form::RemoveTab(void)
1642 {
1643         result r = E_SUCCESS;
1644         if (__pTab)
1645         {
1646                 r = DetachSystemChild(*__pTab);
1647                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1648                 __pTab = null;
1649
1650                 AdjustClientBounds();
1651         }
1652         else
1653         {
1654                 return false;
1655         }
1656
1657         return true;
1658 }
1659
1660 bool
1661 _Form::RemoveIndicator(void)
1662 {
1663         result r = E_SUCCESS;
1664         if (__pIndicator)
1665         {
1666                 r = DetachSystemChild(*__pIndicator);
1667                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1668                 __pIndicator = null;
1669         }
1670         else
1671         {
1672                 return false;
1673         }
1674
1675         return true;
1676 }
1677
1678 result
1679 _Form::SetHeaderBounds(Rectangle& bounds)
1680 {
1681         SysTryReturn(NID_UI_CTRL, __pHeader, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Header isn't constructed.");
1682
1683         bool movable = __pHeader->IsMovable();
1684         bool resizable = __pHeader->IsResizable();
1685
1686         __pHeader->SetMovable(true);
1687         __pHeader->SetResizable(true);
1688
1689         result r = E_SUCCESS;
1690         r = __pHeader->SetBounds(bounds);
1691         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1692
1693         __pHeader->SetMovable(movable);
1694         __pHeader->SetResizable(resizable);
1695
1696         AdjustClientBounds();
1697
1698         return r;
1699 }
1700
1701 result
1702 _Form::SetHeaderFloatBounds(FloatRectangle& bounds)
1703 {
1704         SysTryReturn(NID_UI_CTRL, __pHeader, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Header isn't constructed.");
1705
1706         bool movable = __pHeader->IsMovable();
1707         bool resizable = __pHeader->IsResizable();
1708
1709         __pHeader->SetMovable(true);
1710         __pHeader->SetResizable(true);
1711
1712         result r = E_SUCCESS;
1713         r = __pHeader->SetBounds(bounds);
1714         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1715
1716         __pHeader->SetMovable(movable);
1717         __pHeader->SetResizable(resizable);
1718
1719         AdjustClientBounds();
1720
1721         return r;
1722 }
1723
1724 result
1725 _Form::SetFooterBounds(Rectangle& bounds)
1726 {
1727         SysTryReturn(NID_UI_CTRL, __pFooter, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Footer isn't constructed.");
1728
1729         bool movable = __pFooter->IsMovable();
1730         bool resizable = __pFooter->IsResizable();
1731
1732         __pFooter->SetMovable(true);
1733         __pFooter->SetResizable(true);
1734
1735         result r = E_SUCCESS;
1736         r = __pFooter->SetBounds(bounds);
1737         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1738
1739         __pFooter->SetMovable(movable);
1740         __pFooter->SetResizable(resizable);
1741
1742         AdjustClientBounds();
1743
1744         return r;
1745 }
1746
1747 result
1748 _Form::SetTabBounds(Rectangle& bounds)
1749 {
1750         SysTryReturn(NID_UI_CTRL, __pTab, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Tab isn't constructed.");
1751
1752         bool movable = __pTab->IsMovable();
1753         bool resizable = __pTab->IsResizable();
1754
1755         __pTab->SetMovable(true);
1756         __pTab->SetResizable(true);
1757
1758         result r = E_SUCCESS;
1759         r = __pTab->SetBounds(bounds);
1760         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1761
1762         __pTab->SetMovable(movable);
1763         __pTab->SetResizable(resizable);
1764
1765         AdjustClientBounds();
1766
1767         return r;
1768 }
1769
1770 result
1771 _Form::AddActionEventListener(_IActionEventListener& listener)
1772 {
1773         if (__pActionEvent == null)
1774         {
1775                 __pActionEvent = _ActionEvent::CreateInstanceN(*this);
1776
1777                 SysTryReturn(NID_UI_CTRL, __pActionEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.")
1778         }
1779
1780         result r = __pActionEvent->AddListener(listener);
1781         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1782
1783         return E_SUCCESS;
1784 }
1785
1786 void
1787 _Form::AddOptionkeyActionListener(_IActionEventListener& listener)
1788 {
1789         if (HasOptionkey() == false)
1790         {
1791                 return ;
1792         }
1793 }
1794
1795 void
1796 _Form::AddSoftkeyActionListener(_Softkey softkey, _IActionEventListener& listener)
1797 {
1798         if (CheckSoftkey(softkey) == false)
1799         {
1800                 return ;
1801         }
1802 }
1803
1804 result
1805 _Form::RemoveActionEventListener(_IActionEventListener& listener)
1806 {
1807         SysTryReturn(NID_UI_CTRL, __pActionEvent, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] This instance isn't constructed.")
1808         // Todo : check fail case of RemoveListener
1809         result r = __pActionEvent->RemoveListener(listener);
1810         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1811
1812         return E_SUCCESS;
1813 }
1814
1815 void
1816 _Form::RemoveOptionkeyActionListener(_IActionEventListener& listener)
1817 {
1818         if (HasOptionkey() == false)
1819         {
1820                 return ;
1821         }
1822 }
1823
1824 void
1825 _Form::RemoveSoftkeyActionListener(_Softkey softkey, _IActionEventListener& listener)
1826 {
1827         if (CheckSoftkey(softkey) == false)
1828         {
1829                 return ;
1830         }
1831 }
1832
1833 void
1834 _Form::OnActionPerformed(const _Control& source, int actionId)
1835 {
1836         switch (actionId)
1837         {
1838         case ID_BACK_BUTTON:
1839                 if (__pFormBackEventListener)
1840                 {
1841                         __pFormBackEventListener->OnFormBackRequested(*this);
1842                 }
1843                 break;
1844
1845         default:
1846                 break;
1847         }
1848 }
1849
1850 void
1851 _Form::OnChildVisibleStateChanged(const _Control& child)
1852 {
1853         if (IsHeaderVisible())
1854         {
1855                 int adjHeight = 0;
1856                 if (IsIndicatorVisible())
1857                 {
1858                         Rectangle indicatorBounds = GetIndicatorBounds();
1859                         adjHeight = indicatorBounds.height;
1860                 }
1861                 Rectangle bounds = __pHeader->GetBounds();
1862                 bounds.y = adjHeight;
1863                 SetHeaderBounds(bounds);
1864         }
1865
1866         AdjustClientBounds();
1867 }
1868
1869 Rectangle
1870 _Form::GetIndicatorBounds(void) const
1871 {
1872         _Control* pParent = GetParent();
1873         _Frame* pFrame = dynamic_cast<_Frame*>(pParent);
1874
1875         if (pFrame)
1876         {
1877                 FrameShowMode mode = pFrame->GetShowMode();
1878                 if (mode != FRAME_SHOW_MODE_FULL_SCREEN)
1879                 {
1880                         return Rectangle(0, 0, 0, 0);
1881                 }
1882         }
1883
1884         int indicatorwidth = GetClientBounds().width;
1885         int indicatorheight = 0;
1886
1887         GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorheight);
1888
1889         Rectangle rect (0, 0, indicatorwidth, indicatorheight);
1890
1891         SetLastResult(E_SUCCESS);
1892
1893         return rect;
1894 }
1895
1896 FloatRectangle
1897 _Form::GetIndicatorFloatBounds(void) const
1898 {
1899         _Control* pParent = GetParent();
1900         _Frame* pFrame = dynamic_cast<_Frame*>(pParent);
1901
1902         if (pFrame)
1903         {
1904                 FrameShowMode mode = pFrame->GetShowMode();
1905                 if (mode != FRAME_SHOW_MODE_FULL_SCREEN)
1906                 {
1907                         return FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f);
1908                 }
1909         }
1910
1911         int indicatorwidth = GetClientBounds().width;
1912         int indicatorheight = 0;
1913
1914         GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorheight);
1915
1916         Rectangle rect (0, 0, indicatorwidth, indicatorheight);
1917
1918         Tizen::Graphics::FloatRectangle outputRect(rect.x, rect.y, rect.width, rect.height);
1919
1920         SetLastResult(E_SUCCESS);
1921
1922         return outputRect;
1923 }
1924
1925 void
1926 _Form::SetHeader(_Toolbar* pToolbar)
1927 {
1928         __pHeader = pToolbar;
1929 }
1930
1931 void
1932 _Form::SetFooter(_Toolbar* pToolbar)
1933 {
1934         __pFooter = pToolbar;
1935 }
1936
1937 void
1938 _Form::SetTab(_Tab* pTab)
1939 {
1940         __pTab = pTab;
1941 }
1942
1943 void
1944 _Form::SetTabStyle(int style)
1945 {
1946         __pTab->SetStyle(style);
1947 }
1948
1949 result
1950 _Form::SetIndicatorShowState(bool state)
1951 {
1952         result r = E_SUCCESS;
1953
1954         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
1955         SysTryReturn(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to get evas");
1956
1957         _Control* pParent = GetParent();
1958         if (!pParent)
1959         {
1960                 pParent = const_cast<_Control*>(pEcoreEvas->GetFrame());
1961         }
1962         _Frame* pFrame = dynamic_cast<_Frame*>(pParent);
1963
1964         if (pFrame && IsAttachedToMainTree())
1965         {
1966                 FrameShowMode mode = pFrame->GetShowMode();
1967                 if (mode == FRAME_SHOW_MODE_FULL_SCREEN)
1968                 {
1969                         r = __pIndicator->SetIndicatorShowState(state);
1970                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1971                 }
1972                 else
1973                 {
1974                         r = __pIndicator->SetIndicatorShowState(false);
1975                         return r;
1976                 }
1977         }
1978         else if (!pFrame && IsAttachedToMainTree())
1979         {
1980                 r = __pIndicator->SetIndicatorShowState(false);
1981         }
1982
1983         __indicatorShowState = state;
1984
1985         return r;
1986 }
1987
1988 result
1989 _Form::SetIndicatorOpacity(_IndicatorOpacity opacity)
1990 {
1991         result r = E_SUCCESS;
1992
1993         _Control* pParent = GetParent();
1994         _Frame* pFrame = dynamic_cast<_Frame*>(pParent);
1995
1996         if (pFrame && IsAttachedToMainTree())
1997         {
1998                 FrameShowMode mode = pFrame->GetShowMode();
1999                 if (mode == FRAME_SHOW_MODE_FULL_SCREEN)
2000                 {
2001                         r = __pIndicator->SetIndicatorOpacity(opacity);
2002                         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2003                 }
2004         }
2005
2006         if (opacity == _INDICATOR_OPACITY_TRANSLUCENT)
2007         {
2008                 __transparentIndicator = true;
2009         }
2010         else if (opacity == _INDICATOR_OPACITY_OPAQUE)
2011         {
2012                 __transparentIndicator = false;
2013         }
2014
2015         return r;
2016 }
2017
2018 result
2019 _Form::AddIndicatorObject(void)
2020 {
2021         result r = E_SUCCESS;
2022
2023         if (__pIndicator)
2024         {
2025                 r = __pIndicator->AddEvasObject(this);
2026         }
2027
2028         return r;
2029 }
2030
2031 result
2032 _Form::DeleteIndicatorObject(void)
2033 {
2034         result r = E_SUCCESS;
2035         if (__pIndicator)
2036         {
2037                 r = __pIndicator->DeleteEvasObject();
2038         }
2039
2040         return r;
2041 }
2042
2043 result
2044 _Form::AttachedToMainTree(void)
2045 {
2046         _Frame* pFrame = dynamic_cast<_Frame*>(GetParent());
2047         if (pFrame != null)
2048         {
2049                 FrameShowMode mode = pFrame->GetShowMode();
2050                 if (mode != FRAME_SHOW_MODE_FULL_SCREEN)
2051                 {
2052                         SetBounds(Rectangle(0, 0, pFrame->GetBounds().width, pFrame->GetBounds().height));
2053                 }
2054         }
2055
2056         result r = E_SUCCESS;
2057
2058         if (FORM_STYLE_INDICATOR & GetFormStyle())
2059         {
2060                 AddIndicatorObject();
2061
2062                 if (__indicatorShowState != IsIndicatorVisible())
2063                 {
2064                                 SetIndicatorShowState(__indicatorShowState);
2065                 }
2066
2067                 if (__transparentIndicator != IsIndicatorTranslucent())
2068                 {
2069                         if (__transparentIndicator == true)
2070                         {
2071                                 SetIndicatorOpacity(_INDICATOR_OPACITY_TRANSLUCENT);
2072                         }
2073                         else
2074                         {
2075                                 SetIndicatorOpacity(_INDICATOR_OPACITY_OPAQUE);
2076                         }
2077                 }
2078
2079                 r = GetLastResult();
2080                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2081         }
2082         else
2083         {
2084                 r = SetIndicatorShowState(false);
2085                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2086         }
2087
2088         return r;
2089 }
2090
2091 result
2092 _Form::DetachingFromMainTree(void)
2093 {
2094         result r = E_SUCCESS;
2095         r = DeleteIndicatorObject();
2096         return r;
2097 }
2098
2099 result
2100 _Form::AdjustClientBounds(void)
2101 {
2102         result r = E_SUCCESS;
2103
2104         Dimension size = GetSize();
2105         Rectangle clientBounds(0, 0, size.width, size.height);
2106
2107         if (__deflated)
2108         {
2109                 clientBounds.height -= __deflatedHeight;
2110         }
2111
2112         Rectangle indicatorBounds = GetIndicatorBounds();
2113
2114         _Control* pParent = GetParent();
2115         _Frame* pFrame = dynamic_cast<_Frame*>(pParent);
2116         if (pFrame)
2117         {
2118                 FrameShowMode mode = pFrame->GetShowMode();
2119                 if (mode == FRAME_SHOW_MODE_FULL_SCREEN)
2120                 {
2121                         if (FORM_STYLE_INDICATOR & __formStyle)
2122                         {
2123                                 if (IsIndicatorVisible() && !IsIndicatorTranslucent())
2124                                 {
2125                                         clientBounds.y += indicatorBounds.height;
2126                                         clientBounds.height -= indicatorBounds.height;
2127                                 }
2128                         }
2129                 }
2130         }
2131         else
2132         {
2133                 if (FORM_STYLE_INDICATOR & __formStyle)
2134                 {
2135                         if (IsIndicatorVisible() && !IsIndicatorTranslucent())
2136                         {
2137                                 clientBounds.y += indicatorBounds.height;
2138                                 clientBounds.height -= indicatorBounds.height;
2139                         }
2140                 }
2141         }
2142
2143         if (__pHeader)
2144         {
2145                 if (__pHeader->GetVisibleState() && !IsHeaderTranslucent())
2146                 {
2147                         clientBounds.y += GetToolbarHeight(true);
2148                         clientBounds.height -= GetToolbarHeight(true);
2149                 }
2150         }
2151
2152         if (__pTab)
2153         {
2154                 if (__pTab->GetVisibleState()) //&& !IsHeaderTranslucent())
2155                 {
2156                         clientBounds.y += GetTabHeight();
2157                         clientBounds.height -= GetTabHeight();
2158                 }
2159         }
2160
2161         if (__pFooter)
2162         {
2163                 if (FORM_STYLE_FOOTER & __formStyle || FORM_STYLE_SOFTKEY_0 & __formStyle || FORM_STYLE_SOFTKEY_1 & __formStyle
2164                                 || FORM_STYLE_OPTIONKEY & __formStyle)
2165                 {
2166                         if (__pFooter->GetVisibleState() && !IsFooterTranslucent())
2167                         {
2168                                         clientBounds.height -= GetToolbarHeight(false);
2169                         }
2170                 }
2171         }
2172
2173         if (clientBounds.height < 0)
2174         {
2175                 SysLog(NID_UI_CTRL, "[E_SYSTEM] The Client bounds is not valid. : client height(%d), indicator height(%d), header height(%d), footer height(%d)",
2176                                 clientBounds.height, indicatorBounds.height, GetToolbarHeight(true), GetToolbarHeight(false));
2177         }
2178
2179         SetClientBounds(clientBounds);
2180
2181         return r;
2182
2183 }
2184
2185 void
2186 _Form::OnBoundsChanged(void)
2187 {
2188         Rectangle toolbarBounds;
2189         FloatRectangle indicatorFloatBounds(0.0f, 0.0f, 0.0f, 0.0f);
2190
2191         int indicatorheight = 0;
2192
2193         GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorheight);
2194         if (__pIndicator)
2195                         __pIndicator->SetBounds(Rectangle(0, 0, GetClientBounds().width, indicatorheight));
2196         AdjustClientBounds();
2197
2198         if (HasHeader())
2199         {
2200                 indicatorFloatBounds = GetIndicatorFloatBounds();
2201
2202                 toolbarBounds = GetHeader()->GetBounds();
2203                 toolbarBounds.width = GetSize().width;
2204
2205                 FloatRectangle bounds(toolbarBounds.x, indicatorFloatBounds.height, toolbarBounds.width, toolbarBounds.height);
2206                 SetHeaderFloatBounds(bounds);
2207         }
2208
2209         if (HasFooter())
2210         {
2211                 toolbarBounds = GetFooter()->GetBounds();
2212                 toolbarBounds.width = GetSize().width;
2213                 toolbarBounds.y = GetSize().height - toolbarBounds.height;
2214                 SetFooterBounds(toolbarBounds);
2215         }
2216
2217         if (HasTab())
2218         {
2219                 toolbarBounds = GetTab()->GetBounds();
2220                 toolbarBounds.width = GetSize().width;
2221                 SetTabBounds(toolbarBounds);
2222         }
2223
2224         AdjustClientBounds();
2225 }
2226
2227 }}} // Tizen::Ui::Controls