2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file IvImageViewerForm.cpp
19 * @brief This is the implementation file for ImageViewerForm class.
23 #include "IvCommonUtil.h"
24 #include "IvImageInfo.h"
25 #include "IvImageViewerApp.h"
26 #include "IvImageViewerForm.h"
27 #include "IvImageViewerPresentationModel.h"
28 #include "IvResourceManager.h"
29 #include "IvSettingPresentationModel.h"
32 using namespace Tizen::App;
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Collection;
35 using namespace Tizen::Base::Runtime;
36 using namespace Tizen::Base::Utility;
37 using namespace Tizen::Content;
38 using namespace Tizen::Graphics;
39 using namespace Tizen::Io;
40 using namespace Tizen::Media;
41 using namespace Tizen::System;
42 using namespace Tizen::Ui;
43 using namespace Tizen::Ui::Controls;
44 using namespace Tizen::Ui::Scenes;
46 static const unsigned int COLOR_HEADER_CONTORL_PANEL = Color32<0, 0, 0, 100>::Value;
47 static const unsigned int COLOR_HEADER_BUTTON1 = Color32<0, 0, 0, 100>::Value;
48 static const unsigned int COLOR_DELETE_BUTTON_NORMAL = Color32<208, 82, 82>::Value;
49 static const unsigned int COLOR_DELETE_BUTTON_PRESSED = Color32<194, 71, 71>::Value;
50 static const unsigned int COLOR_DELETE_BUTTON_TEXT = Color32<248, 246, 239>::Value;
52 static const Rectangle RECT_DETAILS_CONTORL_LABEL (20, 0, 200, 48);
54 static const int W_PLAY_BUTTON = 160;
55 static const int H_PLAY_BUTTON = 160;
57 static const int GAP_W_POPUP_ITEM = 5;
58 static const int W_DELETE_POPUP = 600;
59 static const int H_DELETE_POPUP = 300;
60 static const int H_DELETE_LABEL = 180;
61 static const int Y_DELETE_BUTTON = 180;
62 static const int H_DELETE_BUTTON = 80;
64 static const Dimension DUMMY_IMAGE_DIMENSION (720, 1280);
65 static const Rectangle DUMMY_IMAGE_RECTANGLE (0, 0, 720, 1280);
67 static const int PAGE_NO_CONTENT_SEARCH = 1;
68 static const int COUNT_PER_PAGE_CONTENT_SEARCH = 10;
70 static const int FORMAT_BUFFER_SIZE = 256;
72 static const long long SINGLE_GIGA_BYTE = (1024 * 1024 * 1024);
73 static const long long SINGLE_MEGA_BYTE = (1024 * 1024);
74 static const long long SINGLE_KILO_BYTE = 1024;
76 static const int Y_RENAME_BUTTON = 100;
77 static const int H_RENAME_BUTTON = 64;
78 static const int W_RENAME_BUTTON = 64;
80 static const int GAP_W_END_OF_LABEL = 60;
81 static const int X_DETAIL_FILEINFO_LABEL = 20;
82 static const int H_DETAIL_FILEINFO_LABEL = 50;
83 static const int H_DETAIL_MAIN_TEXT = 48;
84 static const int H_DETAIL_SUB_TEXT = 42;
85 static const int GAP_H_DETAIL_TEXT = 26;
86 static const int H_DETAIL_FILEINFO_VALUE_LABEL = 56;
88 static const int X_MORE = 55;
90 static const int DETAIL_SUB_FONT_SIZE = 32;
91 static const int DETAIL_MAIN_FONT_SIZE = 36;
92 static const int DETAIL_COUNT_MAX = 9;
94 ImageViewerForm::ImageViewerForm(void)
95 : __initializeDisplayModeCurrent(APPCONTROL_MODE_NORMAL)
98 , __pScrollPanel(null)
99 , __pDetail_Label(null)
100 , __pLabelMessage(null)
101 , __pPlayButton(null)
102 , __pRenameButton(null)
103 , __pDetailFooterItem(null)
106 , __pContextMenuMore(null)
107 , __pContextMenuCopy(null)
108 , __pContextMenuSetAs(null)
109 , __pContextMenuShare(null)
110 , __pDeletePopup(null)
113 , __startSlide(false)
115 , __pPresentationModel(null)
117 AppLogDebug("ENTER");
118 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
121 ImageViewerForm::~ImageViewerForm(void)
123 AppLogDebug("ENTER");
124 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
128 ImageViewerForm::Initialize()
130 AppLogDebug("ENTER");
131 __pPresentationModel = ImageViewerPresentationModel::GetInstance();
133 if (__pPresentationModel->GetFileCount() > 0)
135 if (__pPresentationModel->GetType() == APPCONTROL_DATA_SLIDE_SHOW)
141 __pPresentationModel->AddFileUpdateListener(this);
143 __pSettingPresentationModel = SettingPresentationModel::GetInstance();
145 int startIndex = __pPresentationModel->GetStartIndex();
146 String filePath = __pPresentationModel->GetFilePathAt(startIndex);
148 if (filePath.StartsWith(WEB_URL_HTTP, 0) == true)
150 __initializeDisplayModeCurrent = APPCONTROL_MODE_WEB_LINK;
152 else if (__pPresentationModel->GetType() == APPCONTROL_DATA_MESSAGE)
154 __initializeDisplayModeCurrent = APPCONTROL_MODE_MESSAGE;
156 else if (__pPresentationModel->GetType() == APPCONTROL_DATA_EMAIL)
158 __initializeDisplayModeCurrent = APPCONTROL_MODE_EMAIL;
162 __initializeDisplayModeCurrent = APPCONTROL_MODE_NORMAL;
165 result r = Form::Construct(IDL_FORM_IMAGE_VIEWER);
167 if (filePath == EMPTY_SPACE)
169 MessageBox messageBox;
170 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_IV_POP_INVALID_IMAGE_FILE"), MSGBOX_STYLE_NONE,
173 messageBox.ShowAndWait(modalResult);
175 UiApp* pApp = UiApp::GetInstance();
179 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
185 ImageViewerForm::OnInitializing(void)
187 AppLogDebug("ENTER");
188 SetFormBackEventListener(this);
189 __pPresentationModel->AddListener(this);
192 InitializeDisplay(__initializeDisplayModeCurrent);
193 InitializePanelDetail();
196 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL
197 || __initializeDisplayModeCurrent == APPCONTROL_MODE_MESSAGE
198 || __initializeDisplayModeCurrent == APPCONTROL_MODE_EMAIL)
200 int index = __pPresentationModel->GetStartIndex();
201 __pGallery->UpdateGallery();
202 __pGallery->SetCurrentItemIndex(index);
205 String filePath = __pPresentationModel->GetFilePathAt(index);
206 __pPresentationModel->RequestImage(filePath);
208 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
215 __pTimer = new (std::nothrow) Timer();
216 __pTimer->Construct(*this);
219 result r = SetActionBarsTranslucent(FORM_ACTION_BAR_INDICATOR, true);
220 AddOrientationEventListener(*this);
221 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
227 ImageViewerForm::OnInitialized(void)
229 AppLogDebug("ENTER");
230 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
236 ImageViewerForm::OnOrientationChanged(const Control &source, OrientationStatus orientationStatus)
238 AppLogDebug("ENTER");
239 if (__detail == false)
241 ShowPanelDetail(true);
245 ShowPanelDetail(false);
248 Rectangle clientRect = GetClientAreaBounds();
249 Rectangle rect = GetBounds();
251 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
252 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
253 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
256 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
260 ImageViewerForm::InitializeDisplay(AppControlMode status)
262 AppLogDebug("ENTER");
264 String strItemIdxText;
266 __pHeader = GetHeader();
267 __pHeader->AddActionEventListener(*this);
269 __pFooter = GetFooter();
270 __pFooter->AddActionEventListener(*this);
271 __pFooter->RemoveAllItems();
273 GetHeaderString(0, strItemText, strItemIdxText);
274 Rectangle rect = GetClientAreaBounds();
275 __pHeader->SetTitleText(strItemText);
276 __pHeader->SetDescriptionText(strItemIdxText);
278 if (status == APPCONTROL_MODE_NORMAL)
280 __pPlayButton = new (std::nothrow) Button();
281 if (__pPlayButton != null)
283 Rectangle clientRect = GetClientAreaBounds();
285 __pPlayButton->Construct(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
286 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
287 __pPlayButton->SetActionId(ACTION_ID_CONTORL_BUTTON_PLAY);
288 AddControl(*__pPlayButton);
290 Bitmap* pNormalBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
291 __pPlayButton->SetNormalBackgroundBitmap(*pNormalBackgroundBitmap);
292 delete pNormalBackgroundBitmap;
294 Bitmap* pPressedBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
295 __pPlayButton->SetPressedBackgroundBitmap(*pPressedBackgroundBitmap);
296 delete pPressedBackgroundBitmap;
298 __pPlayButton->AddActionEventListener(*this);
299 __pPlayButton->SetShowState(false);
302 __pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
303 __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
304 __pFooter->SetBackButton();
306 FooterItem footerItem1;
307 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SHARE);
308 Bitmap* pFooterItemShareNomal =
309 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
310 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
312 FooterItem footerItem2;
313 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_DELETE);
314 Bitmap* pFooterItemDeleteNomal =
315 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_DELETE_NORMAL);
316 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemDeleteNomal);
318 __pFooter->AddItem(footerItem1);
319 __pFooter->AddItem(footerItem2);
321 delete pFooterItemShareNomal;
322 delete pFooterItemDeleteNomal;
324 ButtonItem buttonItemMore;
325 buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
326 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL,
327 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_NORMAL));
328 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED,
329 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_PRESSED));
330 __pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItemMore);
332 else if (status == APPCONTROL_MODE_WEB_LINK)
334 __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
335 __pFooter->SetBackButton();
337 FooterItem footerItem1;
338 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SHARE);
339 Bitmap* pFooterItemShareNomal =
340 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
341 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
343 FooterItem footerItem2;
344 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_DOWNLOAD);
345 Bitmap* pFooterItemDownlordNomal = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DOWNLOAD);
346 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemDownlordNomal);
348 __pFooter->AddItem(footerItem1);
349 __pFooter->AddItem(footerItem2);
351 delete pFooterItemShareNomal;
352 delete pFooterItemDownlordNomal;
354 ButtonItem buttonItemMore;
355 buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, ACTION_ID_FOOTER_MORE);
356 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL,
357 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_NORMAL));
358 buttonItemMore.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED,
359 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_MORE_PRESSED));
360 __pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItemMore);
362 __pFooter->AddItem(footerItem1);
363 __pFooter->AddItem(footerItem2);
365 else if (status == APPCONTROL_MODE_CROP)
367 FooterItem footerItem1;
368 footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SAVE);
369 Bitmap* pfooterItem1 = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_SAVE);
370 footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem1);
372 FooterItem footerItem2;
373 footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_BACK);
374 Bitmap* pfooterItem2 = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_X);
375 footerItem2.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem2);
377 __pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
378 __pFooter->AddItem(footerItem1);
379 __pFooter->AddItem(footerItem2);
384 else if (status == APPCONTROL_MODE_MESSAGE || status == APPCONTROL_MODE_EMAIL)
386 __pPlayButton = new (std::nothrow) Button();
387 if (__pPlayButton != null)
389 Rectangle clientRect = GetClientAreaBounds();
391 __pPlayButton->Construct(Rectangle(clientRect.width / 2 - W_PLAY_BUTTON / 2,
392 clientRect.height / 2 - W_PLAY_BUTTON / 2, W_PLAY_BUTTON, H_PLAY_BUTTON));
393 __pPlayButton->SetActionId(ACTION_ID_CONTORL_BUTTON_PLAY);
394 AddControl(*__pPlayButton);
396 Bitmap* pNormalBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
397 __pPlayButton->SetNormalBackgroundBitmap(*pNormalBackgroundBitmap);
398 delete pNormalBackgroundBitmap;
400 Bitmap* pPressedBackgroundBitmap = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_PLAY);
401 __pPlayButton->SetPressedBackgroundBitmap(*pPressedBackgroundBitmap);
402 delete pPressedBackgroundBitmap;
404 __pPlayButton->AddActionEventListener(*this);
405 __pPlayButton->SetShowState(false);
408 __pFooter->SetBackButton();
411 String filePath = __pPresentationModel->GetFilePathAt(0);
412 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
413 if (contentType == CONTENT_TYPE_VIDEO)
415 __pPlayButton->SetShowState(true);
417 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
421 ImageViewerForm::GetHeaderString(int index, String &fileName, String &page)
423 AppLogDebug("ENTER");
424 int allCount = __pPresentationModel->GetFileCount();
425 String pStr = __pPresentationModel->GetFilePathAt(index);
426 fileName = __pPresentationModel->GetFileName(pStr);
427 page.Format(FORMAT_BUFFER_SIZE, L"%d/%d", index + 1, allCount);
428 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
432 ImageViewerForm::DeleteImageFile()
434 AppLogDebug("ENTER");
435 int currentIndex = __pGallery->GetCurrentItemIndex();
437 String strItemText(EMPTY_SPACE);
438 String strItemIdxText(EMPTY_SPACE);
439 int countPath = __pPresentationModel->GetFileCount();
440 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
442 if (filePath.GetLength() == 0)
444 UiApp* pApp = UiApp::GetInstance();
446 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
451 result r = File::Remove(filePath);
454 MessageBox messageBox;
455 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_COM_POP_DELETE_FAILED"),
456 MSGBOX_STYLE_NONE, 3000);
458 messageBox.ShowAndWait(modalResult);
459 AppLogDebug("EXIT 4(%s)", GetErrorMessage(GetLastResult()));
464 if (filePath.StartsWith(Environment::GetMediaPath(), 0) == true
465 || filePath.StartsWith(Environment::GetExternalStoragePath(), 0) == true)
467 ContentManager::ScanFile(filePath);
470 __pPresentationModel->DeleteFilePathAt(currentIndex);
473 UiApp* pApp = UiApp::GetInstance();
475 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
479 else if ((countPath - 1) == currentIndex)
481 __pGallery->SetCurrentItemIndex(--currentIndex);
484 __pGallery->UpdateGallery();
485 filePath = __pPresentationModel->GetFilePathAt(currentIndex);
486 __pPresentationModel->RequestImage(filePath);
488 GetHeaderString(__pGallery->GetCurrentItemIndex(), strItemText, strItemIdxText);
489 __pHeader->SetTitleText(strItemText);
490 __pHeader->SetDescriptionText(strItemIdxText);
492 if (__visible == true)
494 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
496 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
498 __pPlayButton->SetShowState(false);
502 __pPlayButton->SetShowState(true);
506 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
512 ImageViewerForm::CallVideoPlayer(void)
514 AppLogDebug("ENTER");
515 int index = __pGallery->GetCurrentItemIndex();
516 String filePath = __pPresentationModel->GetFilePathAt(index);
517 filePath.Insert(APPCONTROL_DATA_URI_FILE, 0);
519 AppLogDebug("ENTER(%ls)", filePath.GetPointer());
521 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_VIDEO_PLAYER, APPCONTROL_OPERATION_ID_VIEW,
522 &filePath, null, this);
523 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
527 ImageViewerForm::CreateGallery(void)
529 AppLogDebug("ENTER");
530 Rectangle clientRect = GetClientAreaBounds();
531 Rectangle rect = GetBounds();
533 __pGallery = new (std::nothrow) Gallery();
534 __pGallery->Construct(Rectangle(0, -clientRect.y, rect.width, rect.height));
535 __pGallery->SetName(L"GalleryControl");
536 __pGallery->SetItemProvider(*this);
537 __pGallery->AddGalleryEventListener(*this);
538 AddControl(*__pGallery);
539 __pGallery->SetTextOfEmptyGallery(ResourceManager::GetString(L"IDS_COM_BODY_LOADING"));
541 SlideShowTransitionEffect effect = __pPresentationModel->GetTransitionEffectOfSlideShow();
545 case SLIDE_SHOW_TRANSITION_EFFECT_DISSOLVE:
546 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_DISSOLVE);
548 case SLIDE_SHOW_TRANSITION_EFFECT_ZOOM:
549 __pGallery->SetSlideShowAnimation(Controls::GALLERY_ANIMATION_ZOOM);
551 case SLIDE_SHOW_TRANSITION_EFFECT_SLIDE:
555 __pGallery->SetSlideShowViewDuration(__pPresentationModel->GetDurationOfSlideShow());
557 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
561 ImageViewerForm::InitializePanelDetail()
563 AppLogDebug("ENTER");
564 __pScrollPanel = new (std::nothrow) ScrollPanel();
566 String arrayId[DETAIL_COUNT_MAX] =
568 L"IDS_COM_BODY_DETAILS_NAME", L"IDS_IV_BODY_FILE_FORMAT", L"IDS_IV_BODY_DATE_CREATED",
569 L"IDS_COM_BODY_SIZE", L"IDS_IV_BODY_RESOLUTION", L"IDS_COM_BODY_LOCATION",
570 L"IDS_COM_BODY_LATITUDE", L"IDS_COM_BODY_LONGITUDE", L"IDS_IV_BODY_FILE_LOCATION"
573 if (__pScrollPanel == null)
575 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
577 return E_INVALID_STATE;
580 Rectangle clientRect = GetClientAreaBounds();
581 result r = __pScrollPanel->Construct(Rectangle(0, 0, clientRect.width, clientRect.height));
584 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
586 return E_INVALID_STATE;
589 __pDetail_Label = new (std::nothrow) Label();
590 __pDetail_Label->Construct(RECT_DETAILS_CONTORL_LABEL, ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"));
591 __pScrollPanel->AddControl(*__pDetail_Label);
592 __pDetail_Label->SetTextVerticalAlignment(ALIGNMENT_TOP);
593 __pDetail_Label->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
594 __pDetail_Label->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
595 __pDetail_Label->SetTextConfig(DETAIL_MAIN_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
597 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
599 __pDetail_FileInfo_Label[i] = new (std::nothrow) Label();
600 __pDetail_FileInfo_Label[i]->Construct(
601 Rectangle(X_DETAIL_FILEINFO_LABEL,
602 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT + H_DETAIL_SUB_TEXT) * i,
603 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_LABEL), ResourceManager::GetString(arrayId[i]));
604 __pScrollPanel->AddControl(*__pDetail_FileInfo_Label[i]);
606 __pDetail_FileInfo_Label[i]->SetTextVerticalAlignment(ALIGNMENT_TOP);
607 __pDetail_FileInfo_Label[i]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
608 __pDetail_FileInfo_Label[i]->SetTextColor(Color::GetColor(COLOR_ID_GREY));
609 __pDetail_FileInfo_Label[i]->SetTextConfig(DETAIL_SUB_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
611 __pDetail_FileInfo_Value_Label[i] = new (std::nothrow) Label();
613 if (i == DETAIL_COUNT_MAX - 1)
615 __pDetail_FileInfo_Value_Label[i]->Construct(
616 Rectangle(X_DETAIL_FILEINFO_LABEL,
617 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
618 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL * 3), L"");
622 __pDetail_FileInfo_Value_Label[i]->Construct(
623 Rectangle(X_DETAIL_FILEINFO_LABEL,
624 GAP_H_DETAIL_TEXT * (i + 1) + H_DETAIL_MAIN_TEXT + (H_DETAIL_MAIN_TEXT * i) + H_DETAIL_SUB_TEXT * (i + 1),
625 clientRect.width - GAP_W_END_OF_LABEL, H_DETAIL_FILEINFO_VALUE_LABEL), L"");
628 __pScrollPanel->AddControl(*__pDetail_FileInfo_Value_Label[i]);
630 __pDetail_FileInfo_Value_Label[i]->SetTextVerticalAlignment(ALIGNMENT_TOP);
631 __pDetail_FileInfo_Value_Label[i]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
632 __pDetail_FileInfo_Value_Label[i]->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
633 __pDetail_FileInfo_Value_Label[i]->SetTextConfig(DETAIL_MAIN_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
636 __pScrollPanel->SetBackgroundColor(COLOR_HEADER_CONTORL_PANEL);
637 __pScrollPanel->SetShowState(false);
639 __pRenameButton = new (std::nothrow) Button();
640 Rectangle rect = GetBounds();
641 __pRenameButton->Construct(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
642 __pRenameButton->SetActionId(ACTION_ID_PANEL_HEADER_DETAILS_RENAME);
643 __pRenameButton->AddActionEventListener(*this);
645 Bitmap* pIcon = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME);
646 Bitmap* pIconBackground =
647 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND);
648 Bitmap* pIconPressed =
649 ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_EDIT_NAME_NORMAL_BACKGROUND_PRESS);
651 if (pIcon != null && pIconPressed != null && pIconBackground != null)
653 __pRenameButton->SetNormalBackgroundBitmap(*pIconBackground);
654 __pRenameButton->SetPressedBackgroundBitmap(*pIconPressed);
655 Point iconPosition(0, 0);
656 __pRenameButton->SetNormalBitmap(iconPosition, *pIcon);
657 __pRenameButton->SetPressedBitmap(iconPosition, *pIconPressed);
661 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
662 __pRenameButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_HEADER_BUTTON1);
666 delete pIconBackground;
668 __pRenameButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_HEADER_BUTTON1);
669 __pScrollPanel->AddControl(*__pRenameButton);
672 AddControl(*__pScrollPanel);
673 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
679 ImageViewerForm::InitializePopup(void)
681 AppLogDebug("ENTER");
682 if (__pDeletePopup == null)
684 __pDeletePopup = new (std::nothrow) Popup();
685 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
687 Rectangle popupClientBounds = __pDeletePopup->GetClientAreaBounds();
689 Label* pLabel = new (std::nothrow) Label();
690 pLabel->Construct(Rectangle(0, 0, popupClientBounds.width, H_DELETE_LABEL),
691 ResourceManager::GetString(L"IDS_COM_BODY_DELETE") + L"?");
693 Button* pDeleteButton = new (std::nothrow) Button();
694 pDeleteButton->Construct(
695 Rectangle(0, Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
696 ResourceManager::GetString(L"IDS_COM_BODY_DELETE"));
697 pDeleteButton->SetColor(BUTTON_STATUS_NORMAL, COLOR_DELETE_BUTTON_NORMAL);
698 pDeleteButton->SetColor(BUTTON_STATUS_PRESSED, COLOR_DELETE_BUTTON_PRESSED);
699 pDeleteButton->SetTextColor(COLOR_DELETE_BUTTON_TEXT);
700 pDeleteButton->SetActionId(ACTION_ID_DELETE_POPUP_DEL);
701 pDeleteButton->AddActionEventListener(*this);
703 Button* pCancelButton = new (std::nothrow) Button();
704 pCancelButton->Construct(
705 Rectangle(popupClientBounds.width / 2 + GAP_W_POPUP_ITEM,
706 Y_DELETE_BUTTON, popupClientBounds.width / 2 - GAP_W_POPUP_ITEM, H_DELETE_BUTTON),
707 ResourceManager::GetString(L"IDS_COM_SK_CANCEL"));
708 pCancelButton->SetActionId(ACTION_ID_DELETE_POPUP_CANCEL);
709 pCancelButton->AddActionEventListener(*this);
711 __pDeletePopup->AddControl(*pLabel);
712 __pDeletePopup->AddControl(*pDeleteButton);
713 __pDeletePopup->AddControl(*pCancelButton);
717 __pDeletePopup->SetShowState(true);
718 __pDeletePopup->Show();
720 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
726 ImageViewerForm::InitializeContextMenuMore(void)
728 AppLogDebug("ENTER");
729 int currentIndex = __pGallery->GetCurrentItemIndex();
730 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
732 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
734 if (__pContextMenuMore != null)
736 delete __pContextMenuMore;
737 __pContextMenuMore = null;
740 __pContextMenuMore = new (std::nothrow) ContextMenu();
742 __pContextMenuMore->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height),
743 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
745 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
747 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SET_AS"),
748 ACTION_ID_CONTEXTMENU_SET_AS);
749 __pContextMenuMore->AddItem("Crop", ACTION_ID_FOOTER_BUTTON_CROP);
752 if (__pGallery->GetItemCount() > 1)
754 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SLIDE_SHOW"),
755 ACTION_ID_FOOTER_BUTTON_SLIDE);
757 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"),
758 ACTION_ID_FOOTER_BUTTON_DETAILS);
759 __pContextMenuMore->SetShowState(false);
760 __pContextMenuMore->AddActionEventListener(*this);
761 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
767 ImageViewerForm::InitializeContextMenuSetAs(void)
769 AppLogDebug("ENTER");
771 if (__pContextMenuSetAs != null)
773 delete __pContextMenuSetAs;
774 __pContextMenuSetAs = null;
777 __pContextMenuSetAs = new (std::nothrow) ContextMenu();
778 __pContextMenuSetAs->Construct(Point(X_MORE, GetClientAreaBounds().y + GetClientAreaBounds().height),
779 CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
781 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_HOME_SCREEN_WALLPAPER_ABB"),
782 ACTION_ID_CONTEXTMENU_HOME);
783 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_HEADER_LOCK_SCREEN_WALLPAPER_ABB"),
784 ACTION_ID_CONTEXTMENU_LOCK);
785 __pContextMenuSetAs->AddItem(ResourceManager::GetString(L"IDS_IV_BODY_CALLER_IMAGE"),
786 ACTION_ID_CONTEXTMENU_CALLER);
787 __pContextMenuSetAs->AddActionEventListener(*this);
788 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
794 ImageViewerForm::InitializeContextMenuShare(void)
796 AppLogDebug("ENTER");
797 if (__pContextMenuShare != null)
799 delete __pContextMenuShare;
800 __pContextMenuShare = null;
802 __pContextMenuShare = new (std::nothrow) ContextMenu();
803 __pContextMenuShare->Construct(Point((GetClientAreaBounds().width - (X_MORE * 4)) / 4 + X_MORE * 2,
804 GetClientAreaBounds().y + GetClientAreaBounds().height), CONTEXT_MENU_STYLE_LIST,
805 CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
807 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"),
808 ACTION_ID_CONTEXTMENU_MESSAGE);
809 __pContextMenuShare->AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), ACTION_ID_CONTEXTMENU_EMAIL);
810 __pContextMenuShare->AddActionEventListener(*this);
811 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
817 ImageViewerForm::GetFileSize(String filePath)
819 AppLogDebug("ENTER");
823 result r = File::GetAttributes(filePath, attr);
826 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
830 size = attr.GetFileSize();
831 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
837 ImageViewerForm::SetDetailInfo(void)
839 AppLogDebug("ENTER");
841 Rectangle clientRect = GetClientAreaBounds();
842 __pScrollPanel->SetBounds(0, 0, clientRect.width, clientRect.height);
844 int currentIndex = __pGallery->GetCurrentItemIndex();
845 String strFilePath = __pPresentationModel->GetFilePathAt(currentIndex);
847 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(strFilePath);
849 String strResult[DETAIL_COUNT_MAX] = {EMPTY_SPACE, };
851 strResult[0] = __pPresentationModel->GetFileName(strFilePath);
852 strResult[1] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
855 result r = File::GetAttributes(strFilePath, attr);
858 long long nSize = attr.GetFileSize();
859 DateTime dateTime = attr.GetDateTime();
860 strResult[2] = dateTime.ToString();
862 if (nSize > SINGLE_GIGA_BYTE)
864 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_GIGA_BYTE);
865 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_GB"));
867 else if (nSize > SINGLE_MEGA_BYTE)
869 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_MEGA_BYTE);
870 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_MB"));
872 else if (nSize > SINGLE_KILO_BYTE)
874 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize / SINGLE_KILO_BYTE);
875 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_KB"));
879 strResult[3].Format(FORMAT_BUFFER_SIZE, L"%lld ", nSize);
880 strResult[3].Append(ResourceManager::GetString(L"IDS_COM_BODY_B"));
885 strResult[2] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
886 strResult[3] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
889 strResult[4] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
890 strResult[5] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
891 strResult[6] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
892 strResult[7] = ResourceManager::GetString(L"IDS_COM_BODY_UNKNOWN");
893 strResult[8] = strFilePath;
894 String fileName = File::GetFileName(strFilePath);
895 strResult[8].Remove(strResult[8].GetLength() - fileName.GetLength(), fileName.GetLength());
897 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
899 strResult[0] = __downLordFileName;
901 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
903 ImageMetadata* pImgMeta = ContentManagerUtil::GetImageMetaN(strFilePath);
905 if (pImgMeta != null)
907 ImageContentInfo imageContentInfo;
908 r = imageContentInfo.Construct(&strFilePath);
911 strResult[1] = imageContentInfo.GetMediaFormat();
912 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pImgMeta->GetWidth(),
913 pImgMeta->GetHeight());
915 if (imageContentInfo.GetLocationTag() != EMPTY_SPACE)
917 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", imageContentInfo.GetLocationTag().GetPointer());
920 if (pImgMeta->GetLatitude() > 1.0 && pImgMeta->GetLongitude() > 1.0)
922 strResult[6].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLatitude());
923 strResult[7].Format(FORMAT_BUFFER_SIZE, L"%f", pImgMeta->GetLongitude());
929 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
931 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(strFilePath);
932 if (pVideoMeta != null)
934 VideoContentInfo videoContentInfo;
935 r = videoContentInfo.Construct(&strFilePath);
938 strResult[1] = videoContentInfo.GetMediaFormat();
939 strResult[4].Format(FORMAT_BUFFER_SIZE, L"%d x %d", pVideoMeta->GetWidth(),
940 pVideoMeta->GetHeight());
941 if (videoContentInfo.GetLocationTag() != EMPTY_SPACE)
943 strResult[5].Format(FORMAT_BUFFER_SIZE, L"%ls", videoContentInfo.GetLocationTag().GetPointer());
949 for (int i = 0; i < DETAIL_COUNT_MAX; ++i)
951 __pDetail_FileInfo_Value_Label[i]->SetText(strResult[i]);
952 __pDetail_FileInfo_Value_Label[i]->RequestRedraw();
955 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
957 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
961 Rectangle rect = GetBounds();
962 __pRenameButton->SetBounds(Rectangle(rect.width - W_RENAME_BUTTON - 20, Y_RENAME_BUTTON, W_RENAME_BUTTON, H_RENAME_BUTTON));
964 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
970 ImageViewerForm::ShowPanelDetail(bool showStatus)
972 AppLogDebug("ENTER");
976 __pScrollPanel->SetShowState(true);
981 __pScrollPanel->SetShowState(false);
984 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
990 ImageViewerForm::ChangeFooterItem(bool isChanged, Footer* pFooter, int position)
992 AppLogDebug("ENTER");
993 FooterItem footerItem;
994 footerItem.Construct(ACTION_ID_FOOTER_BUTTON_DETAILS);
995 Bitmap* pfooterItem = null;
999 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS_CLOSE);
1000 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1004 pfooterItem = ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_BUTTON_DETAILS);
1005 footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pfooterItem);
1008 pFooter->SetItemAt(position, footerItem);
1009 pFooter->Invalidate(true);
1012 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1018 ImageViewerForm::DownloadFile(void)
1020 AppLogDebug("ENTER");
1021 String DestPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1022 if (File::IsFileExist(DestPath) == false)
1024 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1028 ContentId contentId;
1029 ContentManager contentManager;
1030 contentManager.Construct();
1032 ImageContentInfo imageContentInfo;
1033 imageContentInfo.Construct(null);
1035 imageContentInfo.SetKeyword(L"platform, tizen");
1036 String sourcePath = DestPath;
1037 String destPath = Environment::GetMediaPath();
1038 destPath.Append(FOLDER_PATH_DOWNLOADS);
1039 destPath.Append(__downLordFileName);
1041 contentId = contentManager.CreateContent(sourcePath, destPath, true, &imageContentInfo);
1042 ImageViewerForm::OnFormBackRequested(*this);
1043 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1047 ImageViewerForm::GetItemCount(void)
1049 AppLogDebug("ENTER");
1050 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1052 return __pPresentationModel->GetFileCount();
1056 ImageViewerForm::CreateItem(int index)
1058 AppLogDebug("ENTER : index(%d)", index);
1059 GalleryItem* pGallery = new (std::nothrow) GalleryItem();
1061 String filePath = __pPresentationModel->GetFilePathAt(index);
1062 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(index);
1063 Bitmap* pBitmap = pImageInfo->GetBitmapN();
1064 if (pBitmap == null)
1066 pBitmap = GetQuickThumbnailN(filePath);
1068 if (pBitmap == null)
1070 pBitmap = new (std::nothrow) Bitmap();
1071 pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1074 pGallery->Construct(*pBitmap, filePath);
1076 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1082 ImageViewerForm::DeleteItem(int index, GalleryItem* pItem)
1084 AppLogDebug("ENTER index(%d)", index);
1085 ImageInfo* pImageInfo = __pPresentationModel->GetImageCacheAt(index);
1086 pImageInfo->ClearBitmap();
1088 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1094 ImageViewerForm::OnGalleryCurrentItemChanged(Gallery& view, int index)
1096 AppLogDebug("ENTER index(%d)", index);
1098 String filePath = __pPresentationModel->GetFilePathAt(index);
1099 AppLogDebug("ENTER index(%d) filePath(%ls)", index, filePath.GetPointer());
1100 __pPresentationModel->RequestImage(filePath);
1103 String strItemIdxText;
1104 GetHeaderString(__pGallery->GetCurrentItemIndex(), strItemText, strItemIdxText);
1105 __pHeader->SetTitleText(strItemText);
1106 __pHeader->SetDescriptionText(strItemIdxText);
1108 if (__visible == true)
1110 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1111 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1113 __pPlayButton->SetShowState(true);
1117 __pPlayButton->SetShowState(false);
1122 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1126 ImageViewerForm::OnGalleryItemClicked(Gallery& view, int index)
1128 AppLogDebug("ENTER");
1130 String filePath = __pPresentationModel->GetFilePathAt(index);
1131 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1133 if (__visible == true)
1135 if (contentType == CONTENT_TYPE_VIDEO)
1137 __pPlayButton->SetShowState(false);
1140 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER | FORM_ACTION_BAR_FOOTER, false);
1145 if (contentType == CONTENT_TYPE_VIDEO)
1147 __pPlayButton->SetShowState(true);
1150 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER | FORM_ACTION_BAR_FOOTER, true);
1153 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1154 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1157 Rectangle clientRect = GetClientAreaBounds();
1158 Rectangle rect = GetBounds();
1159 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1161 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1165 ImageViewerForm::OnGallerySlideShowStarted(Gallery& gallery)
1167 AppLogDebug("ENTER");
1168 PowerManager::KeepScreenOnState(true, false);
1169 if (__visible == true)
1171 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER | FORM_ACTION_BAR_FOOTER, false);
1173 int index = __pGallery->GetCurrentItemIndex();
1174 String filePath = __pPresentationModel->GetFilePathAt(index);
1175 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1177 if (contentType == CONTENT_TYPE_VIDEO)
1179 __pPlayButton->SetShowState(false);
1185 Rectangle clientRect = GetClientAreaBounds();
1186 Rectangle rect = GetBounds();
1187 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1189 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1193 ImageViewerForm::OnGallerySlideShowStopped(Gallery& gallery)
1195 AppLogDebug("ENTER");
1196 PowerManager::KeepScreenOnState(false, true);
1197 int index = __pGallery->GetCurrentItemIndex();
1199 if (__visible == false)
1201 SetActionBarsVisible(FORM_ACTION_BAR_INDICATOR | FORM_ACTION_BAR_HEADER | FORM_ACTION_BAR_FOOTER, true);
1203 String filePath = __pPresentationModel->GetFilePathAt(index);
1204 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1205 if (contentType == CONTENT_TYPE_VIDEO)
1207 __pPlayButton->SetShowState(true);
1210 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y - 1);
1211 __pPlayButton->SetPosition(__pPlayButton->GetPosition().x, __pPlayButton->GetPosition().y + 1);
1217 String strItemIdxText;
1218 GetHeaderString(index, strItemText, strItemIdxText);
1219 __pHeader->SetTitleText(strItemText);
1220 __pHeader->SetDescriptionText(strItemIdxText);
1222 Rectangle clientRect = GetClientAreaBounds();
1223 Rectangle rect = GetBounds();
1224 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1227 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1231 ImageViewerForm::OnUpdateContentList(void)
1236 ImageViewerForm::OnTerminating(void)
1238 AppLogDebug("ENTER");
1240 if (__pTimer != null)
1247 __pPresentationModel->ClearImageRequests();
1248 __pPresentationModel->RemoveListener(*this);
1249 __pPresentationModel->RemoveFileUpdateListener(*this);
1251 if (__pContextMenuCopy != null)
1253 delete __pContextMenuCopy;
1254 __pContextMenuCopy = null;
1257 if (__pContextMenuSetAs != null)
1259 delete __pContextMenuSetAs;
1260 __pContextMenuSetAs = null;
1263 if (__pDeletePopup != null)
1265 delete __pDeletePopup;
1266 __pDeletePopup = null;
1269 if (__pContextMenuShare != null)
1271 delete __pContextMenuShare;
1272 __pContextMenuShare = null;
1275 if (__pContextMenuMore != null)
1277 delete __pContextMenuMore;
1278 __pContextMenuMore = null;
1281 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1287 ImageViewerForm::OnActionPerformed(const Control& source, int actionId)
1289 AppLogDebug("ENTER actionId(%d)", actionId);
1290 SceneManager* pSceneManager = SceneManager::GetInstance();
1295 case ACTION_ID_FOOTER_MORE:
1297 InitializeContextMenuMore();
1299 __pContextMenuMore->SetShowState(true);
1300 __pContextMenuMore->Show();
1303 case ACTION_ID_CONTEXTMENU_SET_AS:
1304 InitializeContextMenuSetAs();
1306 __pContextMenuSetAs->SetShowState(true);
1307 __pContextMenuSetAs->Show();
1309 case ACTION_ID_FOOTER_BUTTON_SHARE:
1310 InitializeContextMenuShare();
1312 __pContextMenuShare->SetShowState(true);
1313 __pContextMenuShare->Show();
1315 case ACTION_ID_FOOTER_BUTTON_DELETE:
1316 __pDeletePopup->SetShowState(true);
1317 __pDeletePopup->Show();
1319 case ACTION_ID_FOOTER_BUTTON_SLIDE:
1321 int repeatValue = 0;
1323 if (__pPresentationModel->GetFileCount() > 1)
1325 __pGallery->UpdateGallery();
1326 if (__detail == false)
1328 ShowPanelDetail(false);
1331 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1332 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
1334 if (repeatValue == 0)
1336 __pGallery->StartSlideShow(false);
1340 __pGallery->StartSlideShow(true);
1345 case ACTION_ID_FOOTER_BUTTON_CROP:
1348 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1349 filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
1350 pList->Add(new (std::nothrow) String(filePath));
1351 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
1354 case ACTION_ID_FOOTER_BUTTON_DETAILS:
1356 ShowPanelDetail(__detail);
1359 case ACTION_ID_FOOTER_BUTTON_BACK:
1360 ImageViewerForm::OnFormBackRequested(*this);
1362 case ACTION_ID_FOOTER_BUTTON_DOWNLOAD:
1365 case ACTION_ID_FOOTER_BUTTON_SAVE:
1367 case ACTION_ID_PANEL_HEADER_DETAILS_RENAME:
1369 ArrayList* pSelectedIndex = new (std::nothrow) ArrayList(SingleObjectDeleter);
1370 pSelectedIndex->Construct();
1371 pSelectedIndex->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1372 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_NAME_EDITOR), pSelectedIndex);
1375 case ACTION_ID_CONTEXTMENU_HOME:
1377 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1378 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1379 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_HOME_SCREEN_WALLPAPER));
1380 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1381 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1384 case ACTION_ID_CONTEXTMENU_LOCK:
1386 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1387 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1388 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_LOCK_SCREEN_WALLPAPER));
1389 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1390 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1393 case ACTION_ID_CONTEXTMENU_CALLER:
1395 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1396 pDataList->Construct();
1397 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SELECTION_MODE),
1398 new (std::nothrow) String(APPCONTROL_DATA_SINGLE));
1399 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_ITEM_TYPE),
1400 new (std::nothrow) String(APPCONTROL_DATA_PERSON));
1401 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_SOCIAL_RESULT_TYPE),
1402 new (std::nothrow) String(APPCONTROL_DATA_ITEM_ID));
1404 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CONTACTS,
1405 APPCONTROL_OPERATION_ID_PICK, null, pDataList, this);
1408 case ACTION_ID_CONTEXTMENU_EMAIL:
1410 OnRequestEmailAction();
1413 case ACTION_ID_CONTEXTMENU_MESSAGE:
1415 OnRequestMessagesAction();
1418 case ACTION_ID_CONTEXTMENU_COPY:
1420 int currentIndex = __pGallery->GetCurrentItemIndex();
1421 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1424 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE, filePath);
1425 Clipboard* pClipboard = Clipboard::GetInstance();
1426 pClipboard->CopyItem(item);
1429 case ACTION_ID_DELETE_POPUP_DEL:
1431 __pDeletePopup->SetShowState(false);
1432 __pDeletePopup->Show();
1435 if (__detail == false)
1437 ShowPanelDetail(false);
1441 case ACTION_ID_DELETE_POPUP_CANCEL:
1443 __pDeletePopup->SetShowState(false);
1444 __pDeletePopup->Show();
1447 case ACTION_ID_CONTORL_BUTTON_PLAY:
1453 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1457 ImageViewerForm::OnFormBackRequested(Form& source)
1459 AppLogDebug("ENTER");
1460 if (__detail == false)
1462 ShowPanelDetail(false);
1466 UiApp* pApp = UiApp::GetInstance();
1469 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1473 ImageViewerForm::OnSceneActivatedN(const SceneId& previousSceneId,
1474 const SceneId& currentSceneId, IList* pArgs)
1476 AppLogDebug("ENTER");
1478 Rectangle clientRect = GetClientAreaBounds();
1479 Rectangle rect = GetBounds();
1481 __pGallery->SetBounds(Rectangle(0, -clientRect.y, rect.width, rect.height));
1482 __pScrollPanel->SetBounds(Rectangle(0, 0, clientRect.width, clientRect.height));
1483 __pPlayButton->SetBounds(Rectangle(clientRect.width / 2 - 80, clientRect.height / 2 - 80, 160, 160));
1485 if (previousSceneId == IDSCN_IMAGE_NAME_EDITOR && currentSceneId == IDSCN_IMAGE_VIEWER)
1488 String strItemText(EMPTY_SPACE);
1489 String strItemIdxText(EMPTY_SPACE);
1490 GetHeaderString(__pGallery->GetCurrentItemIndex(), strItemText, strItemIdxText);
1491 __pHeader->SetTitleText(strItemText);
1492 __pHeader->SetDescriptionText(strItemIdxText);
1496 if (__pGallery->GetCurrentItemIndex() < 0)
1498 SetFooterItemState(false);
1502 SetFooterItemState(true);
1505 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1509 ImageViewerForm::OnSceneDeactivated(const SceneId& currentSceneId,
1510 const SceneId& nextSceneId)
1512 AppLogDebug("ENTER");
1513 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1517 ImageViewerForm::OnImageDecodedN(const int index)
1519 AppLogDebug("ENTER");
1520 __pGallery->RefreshGallery(index, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1522 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1526 ImageViewerForm::OnAppControlCompleteResponseReceived(const AppId& appId,
1527 const String& operationId, AppCtrlResult appControlResult,
1528 const IMap* pExtraData)
1530 AppLogDebug("ENTER");
1532 if (appId == APPCONTROL_PROVIDER_ID_CONTACTS
1533 && operationId == APPCONTROL_OPERATION_ID_PICK
1534 && appControlResult == APP_CTRL_RESULT_SUCCEEDED)
1536 const String* pContactId =
1537 static_cast<const String*>(pExtraData->GetValue(String(APPCONTROL_KEY_SOCIAL_ITEM_ID)));
1538 SceneManager* pSceneManager = SceneManager::GetInstance();
1539 long long lresult = 0;
1540 if (pContactId != null && pContactId->GetLength() > 0)
1542 LongLong::Parse(*pContactId, lresult);
1544 ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1545 pList->Add(new (std::nothrow) Integer(__pGallery->GetCurrentItemIndex()));
1546 pList->Add(new (std::nothrow) Integer(SET_AT_TYPE_CALLER_IMAGE));
1547 pList->Add(new (std::nothrow) LongLong(lresult));
1548 __pPresentationModel->SetSetterIndex(__pGallery->GetCurrentItemIndex());
1549 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_SETTER), pList);
1552 ImageViewerApp* pImageViewerApp = static_cast<ImageViewerApp*>(ImageViewerApp::GetInstance());
1553 pImageViewerApp->SetFrameEnabled(true);
1554 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1558 ImageViewerForm::OnOverlayControlCreated(const Control& source)
1560 AppLogDebug("ENTER");
1561 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1565 ImageViewerForm::OnOverlayControlOpened(const Control& source)
1567 AppLogDebug("ENTER");
1568 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1572 ImageViewerForm::OnOverlayControlClosed(const Control& source)
1574 AppLogDebug("ENTER");
1575 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1579 ImageViewerForm::OnOtherControlSelected(const Control& source)
1581 AppLogDebug("ENTER");
1582 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1586 ImageViewerForm::InitShowGallery(void)
1588 AppLogDebug("ENTER");
1589 if (__pGallery != null && __pGallery->IsVisible() == false)
1591 Canvas* pCanvas = GetCanvasN();
1592 if (pCanvas == null || GetLastResult() != E_SUCCESS)
1594 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1600 __pGallery->SetShowState(true);
1603 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1607 ImageViewerForm::OnTimerExpired(Timer &timer)
1609 int repeatValue = 0;
1610 AppLogDebug("ENTER");
1611 if (__pPresentationModel->GetFileCount() > 1)
1613 __pSettingPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
1614 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
1616 if (repeatValue == 0)
1618 __pGallery->StartSlideShow(false);
1622 __pGallery->StartSlideShow(true);
1625 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1629 ImageViewerForm::OnContentTransferInProgress(RequestId requestId, int totalReceivedSize)
1631 AppLogDebug("ENTER");
1632 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1636 ImageViewerForm::OnContentUploadCompleted(RequestId requestId, result transferResult, const String& errorCode,
1637 const String& errorMessage)
1639 AppLogDebug("ENTER");
1640 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1644 ImageViewerForm::OnContentDownloadCompleted(RequestId requestId, ContentId contentId,
1645 result transferResult, const String& errorCode, const String& errorMessage)
1647 AppLogDebug("ENTER");
1648 AppLogTag("IV", "ImageViewerForm::OnContentDownloadCompleted");
1649 AppLogTag("IV", "DownloadCompleted Error [%s]", GetErrorMessage(transferResult));
1650 AppLogTag("IV", "errorCode [%ls] errorMessage [%ls]", errorCode.GetPointer(), errorMessage.GetPointer());
1651 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1655 ImageViewerForm::OnContentDownloadToBufferCompleted(RequestId reqId, ByteBuffer* pBuffer, result r,
1656 const String& errorCode, const String& errorMessage)
1658 AppLogDebug("ENTER");
1659 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1663 ImageViewerForm::OnContentTransferCanceled(RequestId reqId, result res, const String& errorCode,
1664 const String& errorMessage)
1666 AppLogDebug("ENTER");
1667 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1671 ImageViewerForm::RequestDecodeUrl(void)
1673 AppLogDebug("ENTER");
1675 String filePath = __pPresentationModel->GetFilePathAt(0);
1677 if (filePath.StartsWith(WEB_URL_HTTP, 0) == false)
1679 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1684 __downLordFileName = __pPresentationModel->GetFileName(filePath);
1686 Image* pImage = new (std::nothrow) Image();
1687 pImage->Construct();
1690 uri.SetUri(filePath);
1692 pImage->DecodeUrl(uri, BITMAP_PIXEL_FORMAT_RGB565, 720, 1280, reqId, *this, 5000);
1695 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1699 ImageViewerForm::OnImageDecodeUrlReceived (RequestId reqId, Bitmap *pBitmap,
1700 result r, const String errorCode, const String errorMessage)
1702 AppLogDebug("ENTER");
1703 Image* pImage = new (std::nothrow) Image();
1704 pImage->Construct();
1706 String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_WEB_FILE;
1707 r = pImage->EncodeToFile(*pBitmap, IMG_FORMAT_JPG, destPath, true);
1711 __pPresentationModel->GetImageCacheAt(0)->SetFilePath(destPath);
1712 __pPresentationModel->GetImageCacheAt(0)->SetBitmap(pBitmap);
1714 __pGallery->RefreshGallery(0, GALLERY_REFRESH_TYPE_ITEM_MODIFY);
1716 __pPresentationModel->RequestImage(destPath);
1720 AppLogDebug("ImageViewerForm::OnImageDecodeUrlReceived [%s]", GetErrorMessage(r));
1724 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1728 ImageViewerForm::OnRequestEmailAction(void)
1730 AppLogDebug("ENTER");
1731 int currentIndex = __pGallery->GetCurrentItemIndex();
1733 if (__pPresentationModel->GetFileCount() <= 0)
1735 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1739 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1741 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1742 pDataList->Construct();
1744 IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1745 pList->Add(new (std::nothrow) String(filePath));
1747 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pList);
1749 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_EMAIL, APPCONTROL_OPERATION_ID_COMPOSE,
1750 null, pDataList, this);
1751 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1755 ImageViewerForm::OnRequestMessagesAction(void)
1757 AppLogDebug("ENTER");
1758 int currentIndex = __pGallery->GetCurrentItemIndex();
1760 if (__pPresentationModel->GetFileCount() <= 0)
1762 AppLogDebug("EXIT 1(%s)", GetErrorMessage(GetLastResult()));
1766 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1768 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
1769 pDataList->Construct();
1770 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_MESSAGE_TYPE),
1771 new (std::nothrow) String(APPCONTROL_DATA_MMS));
1773 IList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
1774 pList->Add(new (std::nothrow) String(filePath));
1776 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pList);
1778 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_MESSAGES,
1779 APPCONTROL_OPERATION_ID_COMPOSE, null, pDataList, this);
1780 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1784 ImageViewerForm::SetFooterItemState(bool isEnable)
1786 AppLogDebug("ENTER");
1787 if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL)
1789 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
1790 __pFooter->SetItemEnabled(0, isEnable);
1791 __pFooter->SetItemEnabled(1, isEnable);
1793 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_WEB_LINK)
1795 __pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, isEnable);
1796 __pFooter->SetItemEnabled(0, isEnable);
1797 __pFooter->SetItemEnabled(1, isEnable);
1799 else if (__initializeDisplayModeCurrent == APPCONTROL_MODE_CROP)
1801 __pFooter->SetItemEnabled(0, isEnable);
1803 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1807 ImageViewerForm::GetQuickThumbnailN(String& filePath)
1809 AppLogDebug("ENTER");
1810 Bitmap* pBitmap = null;
1812 if (filePath.GetLength() > 4)
1816 ContentSearch contentSearch;
1817 ContentSearchResult* pResultItem = null;
1818 IList* pContentInfoList = null;
1820 ContentType contentType = ContentManagerUtil::CheckContentType(filePath);
1821 result r = contentSearch.Construct(contentType);
1822 AppLogDebug("r(%s)", GetErrorMessage(r));
1825 pBitmap = new (std::nothrow) Bitmap();
1826 r = pBitmap->Construct(DUMMY_IMAGE_DIMENSION, BITMAP_PIXEL_FORMAT_RGB565);
1837 queryString = CONTENT_QUERY_PREFIX_FILENAME;
1838 queryString.Append(L"'");
1839 queryString.Append(__pPresentationModel->GetFileName(filePath));
1840 queryString.Append(L"'");
1842 pContentInfoList = contentSearch.SearchN(PAGE_NO_CONTENT_SEARCH, COUNT_PER_PAGE_CONTENT_SEARCH,
1843 totalPage, totalCount, queryString, EMPTY_SPACE, SORT_ORDER_NONE);
1845 if ((pContentInfoList != null) && GetLastResult() == E_SUCCESS && (pContentInfoList->GetCount() > 0))
1847 IEnumerator* pEnum = pContentInfoList->GetEnumeratorN();
1848 while (pEnum->MoveNext() == E_SUCCESS)
1850 pResultItem = static_cast<ContentSearchResult*>(pEnum->GetCurrent());
1851 if (pResultItem == null)
1856 if (pResultItem->GetContentInfo()->GetContentPath().CompareTo(filePath) == 0)
1858 pBitmap = pResultItem->GetContentInfo()->GetThumbnailN();
1864 if (pContentInfoList != null)
1866 delete pContentInfoList;
1869 if (pBitmap != null)
1871 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1873 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
1875 ImageBuffer* imageBuffer = new (std::nothrow) ImageBuffer();
1876 result r = imageBuffer->Construct(filePath);
1879 if (imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_RIGHT_TOP
1880 || imageBuffer->GetExifOrientation() == EXIF_ORIENTATION_LEFT_BOTTOM)
1882 Dimension srcDim(imageBuffer->GetHeight(), imageBuffer->GetWidth());
1883 pBitmap->Scale(srcDim);
1887 Dimension srcDim(imageBuffer->GetWidth(), imageBuffer->GetHeight());
1888 pBitmap->Scale(srcDim);
1894 else if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_VIDEO)
1896 VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(filePath);
1898 if (pVideoMeta != null && GetLastResult() == E_SUCCESS)
1900 Dimension srcDim(pVideoMeta->GetWidth(), pVideoMeta->GetHeight());
1901 pBitmap->Scale(srcDim);
1909 mainCanvas.Construct(DUMMY_IMAGE_RECTANGLE);
1910 mainCanvas.FillRectangle(Color::GetColor(COLOR_ID_WHITE), DUMMY_IMAGE_RECTANGLE);
1911 pBitmap = new (std::nothrow) Bitmap();
1912 pBitmap->Construct(mainCanvas, DUMMY_IMAGE_RECTANGLE);
1915 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
1919 void ImageViewerForm::OnFormFileEventOccuered(const int index, const unsigned long eventId)
1921 AppLogDebug(" ENTER");
1922 bool eventDelete = (eventId & FILE_EVENT_TYPE_DELETE_SELF);
1923 bool eventMove = (eventId & 0x8000);// (eventId & FILE_EVENT_TYPE_MOVE_SELF);
1925 int currentIndex = __pGallery->GetCurrentItemIndex();
1926 int countPath = __pPresentationModel->GetFileCount();
1928 if (countPath == 0 && eventDelete)
1930 UiApp* pApp = UiApp::GetInstance();
1932 AppLogDebug("EXIT 2(%s)", GetErrorMessage(GetLastResult()));
1934 AppLogDebug(" countPath is %d", countPath);
1935 AppLogDebug(" currentIndex is %d", currentIndex);
1937 if (countPath == currentIndex && eventDelete)
1939 __pGallery->SetCurrentItemIndex(--currentIndex);
1943 currentIndex = index;
1944 __pGallery->SetCurrentItemIndex(currentIndex);
1947 String strItemText(EMPTY_SPACE);
1948 String strItemIdxText(EMPTY_SPACE);
1950 __pGallery->UpdateGallery();
1951 AppLogDebug(" UpdateGallery is %d", currentIndex);
1952 String filePath = __pPresentationModel->GetFilePathAt(currentIndex);
1953 __pPresentationModel->RequestImage(filePath);
1955 GetHeaderString(currentIndex, strItemText, strItemIdxText);
1956 __pHeader->SetTitleText(strItemText);
1957 __pHeader->SetDescriptionText(strItemIdxText);
1959 if (__visible == true)
1961 ImageViewerMediaType mediaType = CommonUtil::GetMediaType(filePath);
1963 if (mediaType == IMAGE_VIEWER_MEDIA_TYPE_IMAGE)
1965 __pPlayButton->SetShowState(false);
1969 __pPlayButton->SetShowState(true);
1972 if (__detail == false)
1974 __pScrollPanel->SetShowState(false);
1979 AppLogDebug("EXIT");