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