1 /* |
|
2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This abstract class implements MMMADisplayWindow functionality |
|
15 * in CFbsBitmap based displays. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // Include Files |
|
21 #include <logger.h> |
|
22 #include <bitdev.h> |
|
23 #include "cmmaanimationwindow.h" |
|
24 |
|
25 // Destructor (virtual by CBase) |
|
26 CMMAAnimationWindow::~CMMAAnimationWindow() |
|
27 { |
|
28 delete iBitContext; |
|
29 } |
|
30 |
|
31 CMMAAnimationWindow* CMMAAnimationWindow::NewL( |
|
32 MMAFunctionServer* aEventSource) |
|
33 { |
|
34 CMMAAnimationWindow* self = |
|
35 new(ELeave)CMMAAnimationWindow(aEventSource); |
|
36 return self; |
|
37 } |
|
38 |
|
39 CMMAAnimationWindow::CMMAAnimationWindow(MMAFunctionServer* aEventSource): |
|
40 iEventSource(aEventSource) |
|
41 { |
|
42 } |
|
43 |
|
44 void CMMAAnimationWindow::SetViewer(MIHLImageViewer* aViewer) |
|
45 { |
|
46 iViewer = aViewer; |
|
47 } |
|
48 |
|
49 void CMMAAnimationWindow::SetDestinationBitmapL(CFbsBitmap* aBitmap) |
|
50 { |
|
51 CMMABitmapWindow::SetDestinationBitmapL(aBitmap); |
|
52 User::LeaveIfError(iBitmapDevice->CreateBitmapContext(iBitContext)); |
|
53 } |
|
54 |
|
55 void CMMAAnimationWindow::DrawFrameL(const CFbsBitmap* aBitmap) |
|
56 { |
|
57 if (iBitmap) |
|
58 { |
|
59 iBitContext->BitBlt(iDrawRect.iTl, aBitmap); |
|
60 } |
|
61 } |
|
62 |
|
63 // Local wrapper function to SetDrawRect method |
|
64 LOCAL_C void StaticSetDrawRect( |
|
65 CMMAAnimationWindow* aWindow, |
|
66 const TRect* aRect) |
|
67 { |
|
68 aWindow->SetDrawRect(*aRect); |
|
69 } |
|
70 |
|
71 void CMMAAnimationWindow::SetDrawRect(const TRect& aRect) |
|
72 { |
|
73 iDrawRect = aRect; |
|
74 if (iViewer) |
|
75 { |
|
76 TReal zoomRatio = 1.0; |
|
77 if ((iViewer->SourceSize().iWidth - aRect.Width()) > |
|
78 (iViewer->SourceSize().iHeight - aRect.Height())) |
|
79 { |
|
80 // calculate zoom ratio from width |
|
81 zoomRatio = (TReal)aRect.Width() / (TReal)iViewer->SourceSize().iWidth; |
|
82 } |
|
83 else |
|
84 { |
|
85 // calculate zoom ratio from height |
|
86 zoomRatio = (TReal)aRect.Height() / (TReal)iViewer->SourceSize().iHeight; |
|
87 } |
|
88 |
|
89 iViewer->SetViewerSize(iDrawRect.Size()); |
|
90 iViewer->SetZoomRatio(zoomRatio); |
|
91 } |
|
92 } |
|
93 |
|
94 void CMMAAnimationWindow::SetDrawRectThread(const TRect& aRect) |
|
95 { |
|
96 iEventSource->ExecuteV(&StaticSetDrawRect, |
|
97 this, |
|
98 &aRect); |
|
99 } |
|
100 |
|
101 // END OF FILE |
|