25
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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: Call image control.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <telbubblecallimage.h>
|
|
20 |
#include <gdi.h>
|
|
21 |
|
|
22 |
// ======== LOCAL FUNCTIONS ========
|
|
23 |
|
|
24 |
/**
|
|
25 |
* Draws rounded rect. Used for drawing frame to caller image bitmap.
|
|
26 |
*/
|
|
27 |
void DrawRoundRect(CWindowGc& aGC, TPoint aTopLeft, TSize aSize )
|
|
28 |
{
|
|
29 |
const TRgb white( 255, 255, 255);
|
|
30 |
aGC.SetPenColor( white );
|
|
31 |
aGC.SetPenSize( TSize( 5, 5 ) );
|
|
32 |
|
|
33 |
TPoint bottomRight = aTopLeft + aSize;
|
|
34 |
TRect decoratorRect( aTopLeft, bottomRight );
|
|
35 |
// Make rect litle larger so that it will be outside of the caller image,
|
|
36 |
// so that bitmap's corners are hidden.
|
|
37 |
decoratorRect.Grow( 2, 2 );
|
|
38 |
const TSize ellipsesSize( 10, 10 );
|
|
39 |
aGC.DrawRoundRect( decoratorRect, ellipsesSize );
|
|
40 |
}
|
|
41 |
|
|
42 |
// ---------------------------------------------------------------------------
|
|
43 |
// Constructor
|
|
44 |
// ---------------------------------------------------------------------------
|
|
45 |
//
|
|
46 |
EXPORT_C CTelBubbleCallImage::CTelBubbleCallImage()
|
|
47 |
{
|
|
48 |
}
|
|
49 |
|
|
50 |
// ---------------------------------------------------------------------------
|
|
51 |
// NewL
|
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
EXPORT_C CTelBubbleCallImage* CTelBubbleCallImage::NewL()
|
|
55 |
{
|
|
56 |
CTelBubbleCallImage* self = new( ELeave )CTelBubbleCallImage();
|
|
57 |
CleanupStack::PushL( self );
|
|
58 |
self->ConstructL();
|
|
59 |
CleanupStack::Pop( self );
|
|
60 |
return self;
|
|
61 |
}
|
|
62 |
|
|
63 |
// ---------------------------------------------------------------------------
|
|
64 |
// Destructor
|
|
65 |
// ---------------------------------------------------------------------------
|
|
66 |
//
|
|
67 |
EXPORT_C CTelBubbleCallImage::~CTelBubbleCallImage()
|
|
68 |
{
|
|
69 |
if ( iImageOwnership )
|
|
70 |
{
|
|
71 |
delete iImage;
|
|
72 |
}
|
|
73 |
if ( iMaskOwnership )
|
|
74 |
{
|
|
75 |
delete iMask;
|
|
76 |
}
|
|
77 |
}
|
|
78 |
|
|
79 |
// ---------------------------------------------------------------------------
|
|
80 |
// CTelBubbleCallImage::ConstructL
|
|
81 |
// ---------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
EXPORT_C void CTelBubbleCallImage::ConstructL()
|
|
84 |
{
|
|
85 |
}
|
|
86 |
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
// CTelBubbleCallImage::SetImage
|
|
89 |
// ---------------------------------------------------------------------------
|
|
90 |
//
|
|
91 |
EXPORT_C void CTelBubbleCallImage::SetImage(
|
|
92 |
CFbsBitmap* aImage,
|
|
93 |
TBool aImageOwnership,
|
|
94 |
CFbsBitmap* aMask,
|
|
95 |
TBool aMaskOwnership )
|
|
96 |
{
|
|
97 |
if ( iImageOwnership )
|
|
98 |
{
|
|
99 |
delete iImage;
|
|
100 |
}
|
|
101 |
if ( iMaskOwnership )
|
|
102 |
{
|
|
103 |
delete iMask;
|
|
104 |
}
|
|
105 |
|
|
106 |
iImage = aImage;
|
|
107 |
iMask = aMask;
|
|
108 |
iImageOwnership = aImageOwnership;
|
|
109 |
iMaskOwnership = aMaskOwnership;
|
|
110 |
|
|
111 |
SizeChanged();
|
|
112 |
ImageChanged();
|
|
113 |
}
|
|
114 |
|
|
115 |
// ---------------------------------------------------------------------------
|
|
116 |
// CTelBubbleCallImage::ReleaseImage
|
|
117 |
// ---------------------------------------------------------------------------
|
|
118 |
//
|
|
119 |
EXPORT_C void CTelBubbleCallImage::ImageChanged()
|
|
120 |
{
|
|
121 |
}
|
|
122 |
|
|
123 |
// ---------------------------------------------------------------------------
|
|
124 |
// CTelBubbleCallImage::ReleaseImage
|
|
125 |
// ---------------------------------------------------------------------------
|
|
126 |
//
|
|
127 |
EXPORT_C void CTelBubbleCallImage::SetImagePlacingArea( TRect& aRect )
|
|
128 |
{
|
|
129 |
iImagePlacingArea = aRect;
|
|
130 |
}
|
|
131 |
|
|
132 |
// ---------------------------------------------------------------------------
|
|
133 |
// CTelBubbleCallImage::ReleaseImage
|
|
134 |
// ---------------------------------------------------------------------------
|
|
135 |
//
|
|
136 |
EXPORT_C const CFbsBitmap* CTelBubbleCallImage::Image() const
|
|
137 |
{
|
|
138 |
return iImage;
|
|
139 |
}
|
|
140 |
|
|
141 |
// ---------------------------------------------------------------------------
|
|
142 |
// CTelBubbleCallImage::ReleaseImage
|
|
143 |
// ---------------------------------------------------------------------------
|
|
144 |
//
|
|
145 |
EXPORT_C const CFbsBitmap* CTelBubbleCallImage::Mask() const
|
|
146 |
{
|
|
147 |
return iMask;
|
|
148 |
}
|
|
149 |
|
|
150 |
// ---------------------------------------------------------------------------
|
|
151 |
// CTelBubbleCallImage::IsFullScreenImage
|
|
152 |
// ---------------------------------------------------------------------------
|
|
153 |
//
|
|
154 |
EXPORT_C TBool CTelBubbleCallImage::IsFullScreenImage() const
|
|
155 |
{
|
|
156 |
TBool isFullScreen = ETrue;
|
|
157 |
|
|
158 |
if ( iImage )
|
|
159 |
{
|
|
160 |
TSize imageSize = iImage->SizeInPixels();
|
|
161 |
TSize thisSize( Rect().Size() );
|
|
162 |
isFullScreen = ( imageSize.iWidth >= thisSize.iWidth ) ||
|
|
163 |
( imageSize.iHeight >= thisSize.iHeight );
|
|
164 |
}
|
|
165 |
|
|
166 |
return isFullScreen;
|
|
167 |
}
|
|
168 |
|
|
169 |
// ---------------------------------------------------------------------------
|
|
170 |
// CTelBubbleCallImage::Offset
|
|
171 |
// ---------------------------------------------------------------------------
|
|
172 |
//
|
|
173 |
EXPORT_C const TPoint& CTelBubbleCallImage::Offset() const
|
|
174 |
{
|
|
175 |
return iOffset;
|
|
176 |
}
|
|
177 |
|
|
178 |
// ---------------------------------------------------------------------------
|
|
179 |
// CTelBubbleCallImage::SourceRect
|
|
180 |
// ---------------------------------------------------------------------------
|
|
181 |
//
|
|
182 |
EXPORT_C const TRect& CTelBubbleCallImage::SourceRect() const
|
|
183 |
{
|
|
184 |
return iSourceRect;
|
|
185 |
}
|
|
186 |
|
|
187 |
// ---------------------------------------------------------------------------
|
|
188 |
// CTelBubbleCallImage::ImagePlacingArea
|
|
189 |
// ---------------------------------------------------------------------------
|
|
190 |
//
|
|
191 |
EXPORT_C const TRect& CTelBubbleCallImage::ImagePlacingArea() const
|
|
192 |
{
|
|
193 |
return iImagePlacingArea;
|
|
194 |
}
|
|
195 |
|
|
196 |
// ---------------------------------------------------------------------------
|
|
197 |
// CTelBubbleCallImage::SizeChanged
|
|
198 |
// ---------------------------------------------------------------------------
|
|
199 |
//
|
|
200 |
EXPORT_C void CTelBubbleCallImage::SizeChanged()
|
|
201 |
{
|
|
202 |
if ( !iImage )
|
|
203 |
{
|
|
204 |
return;
|
|
205 |
}
|
|
206 |
|
|
207 |
// If bitmap is bigger than drawing area then clip from center of the image.
|
|
208 |
TRect rect = Rect();
|
|
209 |
iSourceRect = iImage->SizeInPixels();
|
|
210 |
|
|
211 |
TInt offsetX = ( iSourceRect.Width() > rect.Width() ) ?
|
|
212 |
((iSourceRect.Width() - rect.Width()) / 2) : 0;
|
|
213 |
TInt offsetY = ( iSourceRect.Height() > rect.Height() ) ?
|
|
214 |
((iSourceRect.Height() - rect.Height()) / 2) : 0;
|
|
215 |
|
|
216 |
iSourceRect.Shrink( offsetX, offsetY );
|
|
217 |
|
|
218 |
// If bitmap is smaller than the drawing area then center the image on it.
|
|
219 |
iOffset.iX = ( iSourceRect.Width() < rect.Width() ) ?
|
|
220 |
((rect.Width() - iSourceRect.Width()) / 2) : 0;
|
|
221 |
|
|
222 |
iOffset.iY = 0;
|
|
223 |
|
|
224 |
// lift the image higher if needed.
|
|
225 |
if ( iSourceRect.Height() < rect.Height() )
|
|
226 |
{
|
|
227 |
// check if it fits totally above the bubble
|
|
228 |
TInt height = iImagePlacingArea.iBr.iY - iImagePlacingArea.iTl.iY;
|
|
229 |
|
|
230 |
if ( iSourceRect.Height() < height )
|
|
231 |
{
|
|
232 |
// if it fits then center it above the bubble
|
|
233 |
iOffset.iY = ( height - iSourceRect.Height() ) / 2;
|
|
234 |
}
|
|
235 |
}
|
|
236 |
}
|
|
237 |
|
|
238 |
// ---------------------------------------------------------------------------
|
|
239 |
// CTelBubbleCallImage::Draw
|
|
240 |
// ---------------------------------------------------------------------------
|
|
241 |
//
|
|
242 |
EXPORT_C void CTelBubbleCallImage::Draw( const TRect& /*aRect*/ ) const
|
|
243 |
{
|
|
244 |
if ( iImage )
|
|
245 |
{
|
|
246 |
CWindowGc& gc = SystemGc();
|
|
247 |
|
|
248 |
const TPoint topLeft = Rect().iTl;
|
|
249 |
const TPoint bitmapTopLeft = topLeft + iOffset;
|
|
250 |
|
|
251 |
// if we have y offset then the image wont go under the bubble in any case and so
|
|
252 |
// no need for masking
|
|
253 |
if ( iMask && iOffset.iY == 0 )
|
|
254 |
{
|
|
255 |
gc.BitBltMasked( bitmapTopLeft,
|
|
256 |
iImage,
|
|
257 |
iSourceRect,
|
|
258 |
iMask,
|
|
259 |
EFalse );
|
|
260 |
}
|
|
261 |
else
|
|
262 |
{
|
|
263 |
gc.BitBlt( bitmapTopLeft,
|
|
264 |
iImage,
|
|
265 |
iSourceRect );
|
|
266 |
}
|
|
267 |
|
|
268 |
DrawRoundRect( gc, bitmapTopLeft, iSourceRect.Size() );
|
|
269 |
}
|
|
270 |
}
|
|
271 |
|
|
272 |
// end of file
|