|
1 /* |
|
2 * Copyright (c) 2002 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 <jdebug.h> |
|
22 #include <bitdev.h> |
|
23 #include <AknIconUtils.h> |
|
24 #include "cmmabitmapwindow.h" |
|
25 |
|
26 // Destructor (virtual by CBase) |
|
27 CMMABitmapWindow::~CMMABitmapWindow() |
|
28 { |
|
29 delete iBitmap; |
|
30 delete iBitmapDevice; |
|
31 delete iBitmapContext; |
|
32 } |
|
33 |
|
34 CMMABitmapWindow* CMMABitmapWindow::NewL() |
|
35 { |
|
36 CMMABitmapWindow* self = new(ELeave)CMMABitmapWindow(); |
|
37 return self; |
|
38 } |
|
39 |
|
40 CMMABitmapWindow::CMMABitmapWindow(): |
|
41 iDrawRect(0, 0, 0, 0), |
|
42 iClientRect(0, 0, 0, 0) |
|
43 { |
|
44 } |
|
45 |
|
46 void CMMABitmapWindow::SetDestinationBitmapL(CFbsBitmap* aBitmap) |
|
47 { |
|
48 CFbsBitmap* bitmap = new(ELeave)CFbsBitmap(); |
|
49 CleanupStack::PushL(bitmap); |
|
50 User::LeaveIfError(bitmap->Duplicate(aBitmap->Handle())); |
|
51 |
|
52 // create context for bitmap |
|
53 CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(aBitmap); |
|
54 CleanupStack::PushL(bitmapDevice); |
|
55 |
|
56 |
|
57 CGraphicsContext* bitmapContext = NULL; |
|
58 User::LeaveIfError(bitmapDevice->CreateContext(bitmapContext)); |
|
59 |
|
60 CleanupStack::Pop(bitmapDevice); // bitmapDevice |
|
61 CleanupStack::Pop(bitmap); // bitmap |
|
62 |
|
63 delete iBitmap; |
|
64 iBitmap = bitmap; |
|
65 delete iBitmapDevice; |
|
66 iBitmapDevice = bitmapDevice; |
|
67 delete iBitmapContext; |
|
68 iBitmapContext = bitmapContext; |
|
69 |
|
70 if (iDrawRect.IsEmpty()) |
|
71 { |
|
72 iDrawRect.SetSize(iBitmap->SizeInPixels()); |
|
73 } |
|
74 } |
|
75 |
|
76 void CMMABitmapWindow::DrawFrameL(const CFbsBitmap* aBitmap) |
|
77 { |
|
78 if (iBitmap) |
|
79 { |
|
80 // leave in this function will panic thread |
|
81 CFbsBitmap* bitmap = new(ELeave)CFbsBitmap(); |
|
82 CleanupStack::PushL(bitmap); |
|
83 User::LeaveIfError(bitmap->Duplicate(aBitmap->Handle())); |
|
84 // set incoming bitmap display mode to 16MA |
|
85 if (EColor16MU == bitmap->DisplayMode()) |
|
86 { |
|
87 bitmap->SetDisplayMode(EColor16MA); |
|
88 } |
|
89 AknIconUtils::ScaleBitmapL(iDrawRect, iBitmap, bitmap); |
|
90 CleanupStack::PopAndDestroy(bitmap); |
|
91 } |
|
92 } |
|
93 |
|
94 void CMMABitmapWindow::SetDrawRect(const TRect& aRect) |
|
95 { |
|
96 iDrawRect = aRect; |
|
97 } |
|
98 |
|
99 void CMMABitmapWindow::SetDrawRectThread(const TRect& aRect) |
|
100 { |
|
101 // Bitmap window's rect can be set in any thread. |
|
102 SetDrawRect(aRect); |
|
103 } |
|
104 |
|
105 const TRect& CMMABitmapWindow::DrawRect() |
|
106 { |
|
107 return iDrawRect; |
|
108 } |
|
109 |
|
110 TSize CMMABitmapWindow::WindowSize() |
|
111 { |
|
112 if (!iBitmap) |
|
113 { |
|
114 // bitmap not ready returning currently set draw rect |
|
115 return iDrawRect.Size(); |
|
116 } |
|
117 return iBitmap->SizeInPixels(); |
|
118 } |
|
119 |
|
120 void CMMABitmapWindow::SetPosition(const TPoint& /*aPosition*/) |
|
121 { |
|
122 // ignored, this is done by framework |
|
123 } |
|
124 |
|
125 void CMMABitmapWindow::SetVisible(TBool /*aVisible*/, TBool /*aUseEventServer*/) |
|
126 { |
|
127 // ignored, this is done by framework |
|
128 } |
|
129 |
|
130 void CMMABitmapWindow::SetWindowRect(const TRect& aRect ,MMMADisplay::TThreadType /*aThreadType*/) |
|
131 { |
|
132 iClientRect = aRect; |
|
133 } |
|
134 |
|
135 const TRect& CMMABitmapWindow::WindowRect() |
|
136 { |
|
137 return iClientRect; |
|
138 } |
|
139 |
|
140 // END OF FILE |