Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_ProgressPopupPresenter.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 /**
19  * @file                FUiCtrl_ProgressPopupPresenter.cpp
20  * @brief       This is the implementation file for the _ProgressPopupPresenter class.
21  */
22
23
24 #include <FBaseErrorDefine.h>
25 #include <FBaseSysLog.h>
26 #include <FGrp_BitmapImpl.h>
27 #include <FGrp_CanvasImpl.h>
28 #include <FGrp_TextTextSimple.h>
29 #include "FUi_ResourceManager.h"
30 #include "FUi_UiTouchEvent.h"
31 #include "FUiCtrl_ProgressPopupPresenter.h"
32 #include "FUiCtrl_ProgressPopup.h"
33
34
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::Base::Runtime;
38 using namespace Tizen::Graphics;
39 using namespace Tizen::Graphics::_Text;
40 using namespace Tizen::Ui;
41 using namespace Tizen::Ui::Animations;
42
43
44 namespace Tizen { namespace Ui { namespace Controls
45 {
46
47
48 _ProgressPopupPresenter::_ProgressPopupPresenter(void)
49         : __pProgressPopup(null)
50         , __pTitleTextObject(null)
51         , __pBodyTextObject(null)
52         , __titleBounds(0, 0, 0, 0)
53         , __textBounds(0, 0, 0, 0)
54         , __animationBounds(0, 0, 0, 0)
55         , __pAnimation(null)
56         , __pAnimationFrameList(null)
57         , __fontStyle(0)
58         , __fontSize(0)
59         , __textObjectHeight(0)
60         , __currentIndex(0)
61         , __buttonPressState(false)
62         , __cancelButton(false)
63         , __translucent(false)
64 {
65         for (int i = 0; i < MAX_PROCESS_IMAGE_COUNT; i++)
66         {
67                 __pProcessImage[i] = null;
68         }
69 }
70
71 _ProgressPopupPresenter::~_ProgressPopupPresenter(void)
72 {
73         for (int i = 0; i < MAX_PROCESS_IMAGE_COUNT; i++)
74         {
75                 delete __pProcessImage[i];
76                 __pProcessImage[i] = null;
77         }
78
79         if (__pTitleTextObject != null)
80         {
81                 __pTitleTextObject->RemoveAll();
82                 delete __pTitleTextObject;
83                 __pTitleTextObject = null;
84         }
85
86         if (__pBodyTextObject != null)
87         {
88                 __pBodyTextObject->RemoveAll();
89                 delete __pBodyTextObject;
90                 __pBodyTextObject = null;
91         }
92
93         if (__pAnimationFrameList != null)
94         {
95                 __pAnimationFrameList->RemoveAll(true);
96                 delete __pAnimationFrameList;
97                 __pAnimationFrameList = null;
98         }
99
100         if (__pAnimation != null)
101         {
102                 delete __pAnimation;
103                 __pAnimation = null;
104         }
105
106 }
107
108 result
109 _ProgressPopupPresenter::Initialize(_ProgressPopup& ProgressPopup, bool cancelButton, bool translucent, const Rectangle& animationRect)
110 {
111         result r = E_SUCCESS;
112
113         __cancelButton = cancelButton;
114         __translucent = translucent;
115         __pProgressPopup = &ProgressPopup;
116
117         return r;
118 }
119
120 void
121 _ProgressPopupPresenter::SetTitleTextObject(void)
122 {
123         int titleTextSize = 0;
124         int defaultWidth = 0;
125         int titleHeight = 0;
126         int titleTopMargin = 0;
127         int titleLeftMargin = 0;
128         int titleRightMargin = 0;
129
130         int transTopMargin = 0;
131         int transLeftMargin = 0;
132         int transRightMargin = 0;
133
134         GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_SIZE, __pProgressPopup->GetOrientation(), titleTextSize);
135         GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, __pProgressPopup->GetOrientation(), defaultWidth);
136         GET_SHAPE_CONFIG(POPUP::TITLE_HEIGHT, __pProgressPopup->GetOrientation(), titleHeight);
137         GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_TOP_MARGIN, __pProgressPopup->GetOrientation(), titleTopMargin);
138         GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_LEFT_MARGIN, __pProgressPopup->GetOrientation(), titleLeftMargin);
139         GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_RIGHT_MARGIN, __pProgressPopup->GetOrientation(), titleRightMargin);
140
141         GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_TOP_MARGIN, __pProgressPopup->GetOrientation(), transTopMargin);
142         GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_LEFT_MARGIN, __pProgressPopup->GetOrientation(), transLeftMargin);
143         GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_RIGHT_MARGIN, __pProgressPopup->GetOrientation(), transRightMargin);
144
145         if (__pProgressPopup->HasTitle())
146         {
147                 result r = E_SUCCESS;
148
149                 __pTitleTextObject = new (std::nothrow) TextObject();
150                 SysTryReturnVoidResult(NID_UI_CTRL, __pTitleTextObject != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
151
152                 r = SetFontInfo(FONT_STYLE_PLAIN, titleTextSize);
153                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set font.", GetErrorMessage(r));
154
155                 __pTitleTextObject->Construct();
156                 TextSimple* pSimpleTextForTitleText = new (std::nothrow) TextSimple(const_cast <wchar_t*>(__pProgressPopup->GetTitleText().GetPointer()),
157                                                                                                                                                                 __pProgressPopup->GetTitleText().GetLength(),
158                                                                                                                                                                 TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
159                 SysTryCatch(NID_UI_CTRL, pSimpleTextForTitleText != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
160
161                 __pTitleTextObject->AppendElement(*pSimpleTextForTitleText);
162                 __pTitleTextObject->SetForegroundColor(__pProgressPopup->GetTitleTextColor(), 0, __pTitleTextObject->GetTextLength());
163                 __pTitleTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
164                 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
165                 __pTitleTextObject->SetTextObjectEllipsisType(TEXT_OBJECT_ELLIPSIS_TYPE_TAIL);
166
167                 __pTitleTextObject->SetFont(_pFont, 0, __pTitleTextObject->GetTextLength());
168                 __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT);
169                 __pTitleTextObject->SetBounds(Rectangle(titleLeftMargin + transLeftMargin,
170                                                                                         titleTopMargin,
171                                                                                         defaultWidth - (titleLeftMargin + titleRightMargin + transLeftMargin + transRightMargin),
172                                                                                         titleHeight - titleTopMargin));
173                 __pTitleTextObject->Compose();
174
175                 __titleBounds = Rectangle(titleLeftMargin + transLeftMargin,
176                                                                 titleTopMargin,
177                                                                 defaultWidth - (titleLeftMargin + titleRightMargin + transLeftMargin + transRightMargin),
178                                                                 titleHeight - titleTopMargin);
179
180         }
181
182         return;
183 CATCH:
184         delete __pTitleTextObject;
185         __pTitleTextObject = null;
186
187         return;
188 }
189
190 void
191 _ProgressPopupPresenter::SetTextObject(void)
192 {
193         int bodyTextSize = 0;
194         int defaultWidth = 0;
195         int titleHeight = 0;
196         int maxHeight = 0;
197         int btnBottomMargin = 0;
198         int textLeftMargin = 0;
199         int textRightMargin = 0;
200         int bottomHeight = 0;
201         int transTopMargin = 0;
202         int transBottomMargin = 0;
203         int transLeftMargin = 0;
204         int transRightMargin = 0;
205         int animationWidth = 0;
206         int textTopMargin = 0;
207         int textBottomMargin = 0;
208         int noTitleHeight = 0;
209
210         GET_SHAPE_CONFIG(POPUP::TITLE_HEIGHT, __pProgressPopup->GetOrientation(), titleHeight);
211         GET_SHAPE_CONFIG(POPUP::PROCESS_ANIMATION_NO_TITLE_TOP_MARGIN, __pProgressPopup->GetOrientation(), noTitleHeight);
212         GET_SHAPE_CONFIG(POPUP::PROCESS_ANIMATION_WIDTH, __pProgressPopup->GetOrientation(), animationWidth);
213
214         GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_TOP_MARGIN, __pProgressPopup->GetOrientation(), transTopMargin);
215         GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_BOTTOM_MARGIN, __pProgressPopup->GetOrientation(), transBottomMargin);
216         GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_LEFT_MARGIN, __pProgressPopup->GetOrientation(), transLeftMargin);
217         GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_RIGHT_MARGIN, __pProgressPopup->GetOrientation(), transRightMargin);
218
219         GET_SHAPE_CONFIG(MESSAGEBOX::PROCESS_TEXT_TOP_MARGIN, __pProgressPopup->GetOrientation(), textTopMargin);
220         GET_SHAPE_CONFIG(MESSAGEBOX::PROCESS_TEXT_BOTTOM_MARGIN, __pProgressPopup->GetOrientation(), textBottomMargin);
221         GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_LEFT_MARGIN, __pProgressPopup->GetOrientation(), textLeftMargin);
222         GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_RIGHT_MARGIN, __pProgressPopup->GetOrientation(), textRightMargin);
223         GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_SIZE, __pProgressPopup->GetOrientation(), bodyTextSize);
224
225         GET_SHAPE_CONFIG(MESSAGEBOX::MAX_HEIGHT, __pProgressPopup->GetOrientation(), maxHeight);
226         GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, __pProgressPopup->GetOrientation(), defaultWidth);
227         GET_SHAPE_CONFIG(MESSAGEBOX::BOTTOM_HEIGHT, __pProgressPopup->GetOrientation(), bottomHeight);
228         GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_BOTTOM_MARGIN, __pProgressPopup->GetOrientation(), btnBottomMargin);
229
230
231         if (__pProgressPopup->HasTitle())
232         {
233                 noTitleHeight = 0;
234         }
235         else
236         {
237                 titleHeight = 0;
238         }
239
240         if (__pProgressPopup->HasText())
241         {
242                 result r = E_SUCCESS;
243
244                 __pBodyTextObject = new (std::nothrow) TextObject();
245                 SysTryReturnVoidResult(NID_UI_CTRL, __pBodyTextObject != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
246
247                 if (__pProgressPopup->HasButton())
248                 {
249                         GET_SHAPE_CONFIG(MESSAGEBOX::BOTTOM_HEIGHT, __pProgressPopup->GetOrientation(), bottomHeight);
250                 }
251
252                 r = SetFontInfo(FONT_STYLE_PLAIN, bodyTextSize);
253                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set font.", GetErrorMessage(r));
254
255                 __pBodyTextObject->Construct();
256                 TextSimple* pSimpleTextForBodyText = new (std::nothrow) TextSimple(const_cast <wchar_t*>(__pProgressPopup->GetText().GetPointer()),
257                                                                                                                                                                 __pProgressPopup->GetText().GetLength(),
258                                                                                                                                                                 TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
259                 SysTryCatch(NID_UI_CTRL, pSimpleTextForBodyText != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
260
261                 __pBodyTextObject->AppendElement(*pSimpleTextForBodyText);
262                 __pBodyTextObject->SetForegroundColor(__pProgressPopup->GetTextColor(), 0, __pBodyTextObject->GetTextLength());
263                 __pBodyTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
264                 __pBodyTextObject->SetFont(_pFont, 0, __pBodyTextObject->GetTextLength());
265                 __pBodyTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT);
266                 __pBodyTextObject->SetBounds(Rectangle(textLeftMargin + transLeftMargin,
267                                                                                                 titleHeight + animationWidth + noTitleHeight,
268                                                                                                 defaultWidth - (textLeftMargin + textRightMargin + transLeftMargin + transRightMargin),
269                                                                                                 maxHeight - titleHeight - bottomHeight - animationWidth));
270                 __pBodyTextObject->Compose();
271
272                 // Calculate Text bounds
273                 __textObjectHeight = __pBodyTextObject->GetTotalHeight();
274
275                 int totalHeightExceptTextObj = titleHeight + animationWidth + textTopMargin + textBottomMargin + bottomHeight + (transTopMargin + transBottomMargin);
276                 int tmpH = maxHeight - (totalHeightExceptTextObj + __textObjectHeight);
277
278                 __textObjectHeight = (tmpH > 0) ? __textObjectHeight : __textObjectHeight + tmpH;
279
280                 __textBounds.SetBounds(textLeftMargin + transLeftMargin,
281                                                                 titleHeight + textTopMargin + transTopMargin + animationWidth + noTitleHeight,
282                                                                 defaultWidth - (textLeftMargin + textRightMargin + transLeftMargin + transRightMargin),
283                                                                 __textObjectHeight);
284
285                 __pBodyTextObject->SetBounds(__textBounds);
286         }
287
288         return;
289
290 CATCH:
291         delete __pBodyTextObject;
292         __pBodyTextObject = null;
293
294         return;
295 }
296
297 result
298 _ProgressPopupPresenter::PlayProcessAnimation(void)
299 {
300         if (__pAnimation != null)
301         {
302                 if (__pAnimation->GetStatus() == ANIMATION_PLAYING)
303                 {
304                         return E_SUCCESS;
305                 }
306         }
307         else
308         {
309                 SetProcessAnimation();
310         }
311
312         if (__pAnimation != null)
313         {
314                 __pAnimation->Play();
315         }
316
317         return E_SUCCESS;
318
319 }
320
321 result
322 _ProgressPopupPresenter::StopProcessAnimation(void)
323 {
324         __pAnimation->Stop();
325
326         __pProgressPopup->DetachChild(*__pAnimation);
327
328         delete __pAnimation;
329         __pAnimation = null;
330
331         return E_SUCCESS;
332 }
333
334 result
335 _ProgressPopupPresenter::SetProcessAnimation(void)
336 {
337         result r = E_SUCCESS;
338
339         if (__pAnimation != null)
340         {
341                 if (__pAnimation->GetStatus() == ANIMATION_PLAYING)
342                 {
343                         return r;
344                 }
345         }
346
347         // Create AnimationFrames
348         long duration = 1500 / 30;
349         Rectangle animationBounds;
350         AnimationFrame* pAniFrame[MAX_PROCESS_IMAGE_COUNT];
351
352         r = LoadImages();
353         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
354
355         for (int i = 0; i < MAX_PROCESS_IMAGE_COUNT; i++)
356         {
357                 pAniFrame[i] = null;
358
359                 pAniFrame[i] = new (std::nothrow) AnimationFrame(*__pProcessImage[i], duration);
360                 SysTryCatch(NID_UI_CTRL, pAniFrame[i] != null, ,E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
361         }
362
363         __pAnimationFrameList = new (std::nothrow) ArrayList();
364         SysTryCatch(NID_UI_CTRL, __pAnimationFrameList != null, ,E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
365
366         if (__pAnimationFrameList != null)
367         {
368                 __pAnimationFrameList->Construct();
369
370                 for (int i = 0; i < MAX_PROCESS_IMAGE_COUNT; i++)
371                 {
372                         r = __pAnimationFrameList->Add(*pAniFrame[i]);
373                         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
374                 }
375         }
376
377         delete __pAnimation;
378         __pAnimation = null;
379
380         __pAnimation = _Animation::CreateAnimationN();
381
382         if (__pAnimation)
383         {
384                 if (__pAnimationFrameList)
385                 {
386                         __pAnimation->SetAnimationFrames(*__pAnimationFrameList);
387                 }
388
389                 __pAnimation->SetImageCount(MAX_PROCESS_IMAGE_COUNT);
390                 __pAnimation->SetRepeatCount(ANIMATION_REPEAT_COUNT);
391                 __pAnimation->AddAnimationEventListener(*this);
392
393                 animationBounds = __pProgressPopup->GetAnimationRect();
394                 if (__pProgressPopup->HasTitle() || __pProgressPopup->HasText() || __pProgressPopup->HasButton())
395                 {
396                         __pAnimation->SetBounds(FloatRectangle(animationBounds.x, animationBounds.y, animationBounds.width, animationBounds.height));
397                 }
398                 else
399                 {
400                         __pAnimation->GetVisualElement()->SetOpacity(0.6f);
401                         __pAnimation->SetBounds(FloatRectangle(0, 0, animationBounds.width, animationBounds.height));
402                 }
403
404                 __pProgressPopup->AttachChild(*__pAnimation);
405         }
406
407         return r;
408
409 CATCH:
410         for (int i = 0; i < MAX_PROCESS_IMAGE_COUNT; i++)
411         {
412                 delete __pProcessImage[i];
413                 __pProcessImage[i] = null;
414         }
415
416         return r;
417 }
418
419 void
420 _ProgressPopupPresenter::OnAnimationStopped(const _Control & source)
421 {
422         if (&source == __pAnimation)
423         {
424                 __pAnimation->Play();
425         }
426 }
427
428 void
429 _ProgressPopupPresenter::OnFontChanged(Font* pFont)
430 {
431         _pFont = pFont;
432 }
433
434 void
435 _ProgressPopupPresenter::OnFontInfoRequested(unsigned long& style, int& size)
436 {
437         style = __fontStyle;
438         size = __fontSize;
439 }
440
441 result
442 _ProgressPopupPresenter::SetFontInfo(unsigned long style, int size)
443 {
444         __fontStyle = style;
445         __fontSize = size;
446
447         _pFont = __pProgressPopup->GetFallbackFont();
448         SysTryReturnResult(NID_UI_CTRL, _pFont != null, GetLastResult(), "Failed to get a font.");
449
450         return E_SUCCESS;
451 }
452
453 void
454 _ProgressPopupPresenter::Draw(void)
455 {
456         result r = E_SUCCESS;
457
458         int titleTextSize = 0;
459         int bodyTextSize = 0;
460         int defaultWidth = 0;
461         int titleHeight = 0;
462
463         int btnHeight = 0;
464         int btnTopMargin = 0;
465         int btnBottomMargin = 0;
466
467         int transTopMargin = 0;
468         int titleTopMargin = 0;
469         int animationWidth = 0;
470
471         GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_SIZE, __pProgressPopup->GetOrientation(), titleTextSize);
472         GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_SIZE, __pProgressPopup->GetOrientation(), bodyTextSize);
473
474         GET_SHAPE_CONFIG(POPUP::TITLE_HEIGHT, __pProgressPopup->GetOrientation(), titleHeight);
475         GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_TOP_MARGIN, __pProgressPopup->GetOrientation(), transTopMargin);
476         GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_TOP_MARGIN, __pProgressPopup->GetOrientation(), titleTopMargin);
477         GET_SHAPE_CONFIG(POPUP::PROCESS_ANIMATION_WIDTH, __pProgressPopup->GetOrientation(), animationWidth);
478
479         GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, __pProgressPopup->GetOrientation(), defaultWidth);
480         GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_HEIGHT, __pProgressPopup->GetOrientation(), btnHeight);
481         GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_TOP_MARGIN, __pProgressPopup->GetOrientation(), btnTopMargin);
482         GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_BOTTOM_MARGIN, __pProgressPopup->GetOrientation(), btnBottomMargin);
483
484         Canvas* pCanvas = __pProgressPopup->GetCanvasN();
485         SysTryReturnVoidResult(NID_UI_CTRL, (pCanvas != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create canvas.");
486
487         pCanvas->SetBackgroundColor(Color(0x00000000));
488         pCanvas->Clear();
489
490         bool hasBgBitmap = (__pProgressPopup->GetBackgroundBitmap() != null);
491
492         int totalH = __pProgressPopup->GetTotalHeight();
493
494         // Draw BG
495         if (hasBgBitmap && (__pProgressPopup->HasTitle() || __pProgressPopup->HasText() || __pProgressPopup->HasButton()))
496         {
497                 Rectangle bounds(0, 0, defaultWidth, totalH);
498
499                 const Bitmap* pBackgroundBitmap = __pProgressPopup->GetBackgroundBitmap();
500                 if (pBackgroundBitmap->IsNinePatchedBitmap() == true)
501                 {
502                         pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundBitmap);
503                 }
504                 else
505                 {
506                         pCanvas->DrawBitmap(bounds, *pBackgroundBitmap);
507                 }
508         }
509
510         // Draw Title text
511         if (__pTitleTextObject != null)
512         {
513                 r = SetFontInfo(FONT_STYLE_PLAIN, titleTextSize);
514                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set font.", GetErrorMessage(r));
515
516                 __pTitleTextObject->SetFont(_pFont, 0, __pTitleTextObject->GetTextLength());
517                 __pTitleTextObject->SetBounds(__titleBounds);
518                 __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
519         }
520
521         // Draw Body text
522         if (__pBodyTextObject != null)
523         {
524                 r = SetFontInfo(FONT_STYLE_PLAIN, bodyTextSize);
525                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
526
527                 __pBodyTextObject->SetFont(_pFont, 0, __pBodyTextObject->GetTextLength());
528
529                 __pBodyTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
530         }
531
532         //fall thtrough
533 CATCH:
534         delete pCanvas;
535
536         return;
537 }
538
539 result
540 _ProgressPopupPresenter::DoModal(int& modalResult)
541 {
542         __pProgressPopup->Open();
543
544         ProcessEvent();
545
546         __pProgressPopup->Close();
547
548         modalResult = __pProgressPopup->GetPopupReturnValue();
549
550         return E_SUCCESS;
551 }
552
553 int
554 _ProgressPopupPresenter::GetBodyTextHeight(void) const
555 {
556         return (__pBodyTextObject == null) ? 0 : __pBodyTextObject->GetTotalHeight();
557 }
558
559 Rectangle
560 _ProgressPopupPresenter::GetTitleBounds(void) const
561 {
562         return __titleBounds;
563 }
564
565 Rectangle
566 _ProgressPopupPresenter::GetTextBounds(void) const
567 {
568         return __textBounds;
569 }
570
571 Rectangle
572 _ProgressPopupPresenter::GetButtonBounds(void) const
573 {
574         int width = 0;
575         int height = 0;
576         int x = 0;
577         int y = 0;
578
579         int defaultWidth = 0;
580         int titleHeight = 0;
581         int btnHeight = 0;
582         int btnSideMargin1 = 0;
583         int btnTopMargin = 0;
584         int transTopMargin = 0;
585         int animationWidth = 0;
586         int noTitleHeight = 0;
587         int textTopMargin = 0;
588         int textBottomMargin = 0;
589
590         GET_SHAPE_CONFIG(POPUP::TITLE_HEIGHT, __pProgressPopup->GetOrientation(), titleHeight);
591         GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_TOP_MARGIN, __pProgressPopup->GetOrientation(), transTopMargin);
592         GET_SHAPE_CONFIG(POPUP::PROCESS_ANIMATION_WIDTH, __pProgressPopup->GetOrientation(), animationWidth);
593         GET_SHAPE_CONFIG(POPUP::PROCESS_ANIMATION_NO_TITLE_TOP_MARGIN, __pProgressPopup->GetOrientation(), noTitleHeight);
594         GET_SHAPE_CONFIG(POPUP::PROCESS_TEXT_TOP_MARGIN, __pProgressPopup->GetOrientation(), textTopMargin);
595         GET_SHAPE_CONFIG(POPUP::PROCESS_TEXT_BOTTOM_MARGIN, __pProgressPopup->GetOrientation(), textBottomMargin);
596
597         GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, __pProgressPopup->GetOrientation(), defaultWidth);
598         GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_HEIGHT, __pProgressPopup->GetOrientation(), btnHeight);
599         GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_SIDE_MARGIN_01, __pProgressPopup->GetOrientation(), btnSideMargin1);
600         GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_TOP_MARGIN, __pProgressPopup->GetOrientation(), btnTopMargin);
601
602         if (!__pProgressPopup->HasButton())
603         {
604                 return Rectangle(0, 0, 0, 0);
605         }
606
607         if (__pProgressPopup->HasTitle())
608         {
609                 noTitleHeight = 0;
610         }
611         else
612         {
613                 titleHeight = 0;
614         }
615
616         if (!__pProgressPopup->HasText())
617         {
618                 textTopMargin = 0;
619                 textBottomMargin = 0;
620         }
621
622         width = defaultWidth - (btnSideMargin1 * 2);
623         height = btnHeight;
624         x = btnSideMargin1;
625
626         y = transTopMargin
627                 + titleHeight
628                 + noTitleHeight
629                 + animationWidth
630                 + textTopMargin
631                 + textBottomMargin
632                 + GetBodyTextHeight()
633                 + btnTopMargin;
634
635         return Rectangle(x, y, width, height);
636 }
637
638 bool
639 _ProgressPopupPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
640 {
641         __buttonPressState = true;
642
643         return true;
644 }
645
646 bool
647 _ProgressPopupPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
648 {
649         __buttonPressState = false;
650
651         return true;
652 }
653
654 bool
655 _ProgressPopupPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
656 {
657         Point touchPoint = touchinfo.GetCurrentPosition();
658
659         return true;
660 }
661
662 result
663 _ProgressPopupPresenter::LoadImages(void)
664 {
665         result r = E_SUCCESS;
666
667         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_01, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[0]);
668         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
669
670         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_02, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[1]);
671         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
672
673         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_03, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[2]);
674         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
675
676         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_04, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[3]);
677         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
678
679         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_05, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[4]);
680         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
681
682         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_06, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[5]);
683         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
684
685         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_07, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[6]);
686         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
687
688         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_08, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[7]);
689         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
690
691         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_09, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[8]);
692         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
693
694         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_10, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[9]);
695         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
696
697         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_11, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[10]);
698         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
699
700         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_12, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[11]);
701         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
702
703         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_13, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[12]);
704         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
705
706         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_14, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[13]);
707         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
708
709         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_15, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[14]);
710         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
711
712         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_16, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[15]);
713         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
714
715         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_17, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[16]);
716         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
717
718         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_18, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[17]);
719         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
720
721         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_19, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[18]);
722         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
723
724         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_20, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[19]);
725         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
726
727         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_21, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[20]);
728         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
729
730         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_22, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[21]);
731         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
732
733         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_23, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[22]);
734         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
735
736         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_24, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[23]);
737         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
738
739         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_25, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[24]);
740         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
741
742         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_26, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[25]);
743         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
744
745         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_27, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[26]);
746         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
747
748         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_28, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[27]);
749         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
750
751         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_29, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[28]);
752         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
753
754         r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_30, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[29]);
755         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
756
757         return r;
758 }
759
760
761 }}} // Tizen::Ui::Controls
762
763