207 return popupRect; |
208 return popupRect; |
208 } |
209 } |
209 |
210 |
210 |
211 |
211 // --------------------------------------------------------------------------- |
212 // --------------------------------------------------------------------------- |
212 // CAknDiscreetPopupDrawer::PopupBitmap |
213 // CAknDiscreetPopupDrawer::Draw |
213 // Provides popup bitmap. |
214 // Draws popup to given graphics context. |
214 // --------------------------------------------------------------------------- |
215 // --------------------------------------------------------------------------- |
215 // |
216 // |
216 CFbsBitmap* CAknDiscreetPopupDrawer::PopupBitmap( const TSize& aSize ) |
217 void CAknDiscreetPopupDrawer::Draw( CWindowGc& aGc, |
217 { |
218 const TRect& aRect ) const |
218 if ( !iPopupBitmap || aSize != iPopupBitmap->SizeInPixels() ) |
219 { |
219 { |
220 // draw background of the popup |
220 TRAP_IGNORE( CreatePopupBitmapL( TRect( TPoint(), aSize ) ) ); |
221 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
221 } |
222 TAknLayoutRect innerLayout; |
222 return iPopupBitmap; |
223 // Use bg_popup_preview_window_pane_g1() for getting innerRect, |
223 } |
224 // no need to create a new layout id for discreet popup. |
224 |
225 innerLayout.LayoutRect( aRect, |
225 |
226 AknLayoutScalable_Avkon::bg_popup_preview_window_pane_g1() ); |
226 // --------------------------------------------------------------------------- |
227 TRect innerRect = innerLayout.Rect(); |
227 // CAknDiscreetPopupDrawer::TransparentMask |
228 |
228 // Provides transparent mask for a bitmap. |
229 AknsDrawUtils::DrawFrame( skin, aGc, aRect, innerRect, |
229 // --------------------------------------------------------------------------- |
230 KAknsIIDQsnFrPopupPreview, KAknsIIDDefault ); |
230 // |
231 |
231 CFbsBitmap* CAknDiscreetPopupDrawer::TransparentMask( |
232 // Draw the texts |
232 const TSize& aSize, const TInt& aAlpha ) |
233 TRgb textColor( EikonEnv()->ControlColor( EColorControlText, *iControl ) ); |
233 { |
234 |
234 if ( !iTransparentMask || aSize != iTransparentMask->SizeInPixels() ) |
235 if ( iAction ) |
235 { |
236 { |
236 TRAP_IGNORE( CreateTransparentMaskL( TRect( TPoint(), aSize ) ) ); |
237 aGc.SetUnderlineStyle( EUnderlineOn ); |
237 } |
238 AknsUtils::GetCachedColor( skin, |
238 |
239 textColor, |
239 TInt width( iTransparentMask->SizeInPixels().iWidth ); |
240 KAknsIIDQsnHighlightColors, |
240 TInt height( iTransparentMask->SizeInPixels().iHeight ); |
241 EAknsCIQsnHighlightColorsCG3 ); |
241 TUint8* address( ( TUint8* ) iTransparentMask->DataAddress() ); |
242 } |
242 TInt dataStride( iTransparentMask->DataStride() - width ); |
243 else |
243 |
244 { |
244 for ( TInt i = 0; i < height; ++i ) |
245 AknsUtils::GetCachedColor( skin, |
245 { |
246 textColor, |
246 for ( TInt j = 0; j < width; j++ ) |
247 KAknsIIDQsnTextColors, |
247 { |
248 EAknsCIQsnTextColorsCG55 ); |
248 *address = aAlpha; |
249 } |
249 ++address; |
250 aGc.SetPenColor( textColor ); |
250 } |
251 DrawTexts( &aGc ); |
251 address += dataStride; |
252 aGc.SetUnderlineStyle( EUnderlineOff ); |
252 } |
253 |
253 |
254 // draw the icon |
254 return iTransparentMask; |
255 if ( iIcon && iIcon->Bitmap() && iIcon->Mask() ) |
255 } |
256 { |
|
257 aGc.BitBltMasked( iIconRect.iTl, |
|
258 iIcon->Bitmap(), |
|
259 iIcon->Bitmap()->SizeInPixels(), |
|
260 iIcon->Mask(), |
|
261 EFalse ); |
|
262 |
|
263 } |
|
264 else if( iIcon && iIcon->Bitmap() ) |
|
265 { |
|
266 aGc.BitBlt( iIconRect.iTl, iIcon->Bitmap() ); |
|
267 } |
|
268 } |
256 |
269 |
257 |
270 |
258 // --------------------------------------------------------------------------- |
271 // --------------------------------------------------------------------------- |
259 // CAknDiscreetPopupDrawer::CAknDiscreetPopupDrawer |
272 // CAknDiscreetPopupDrawer::CAknDiscreetPopupDrawer |
260 // --------------------------------------------------------------------------- |
273 // --------------------------------------------------------------------------- |
289 { |
300 { |
290 // Body text to title text if title text is empty |
301 // Body text to title text if title text is empty |
291 if ( aTitleText == KNullDesC && aBodyText != KNullDesC ) |
302 if ( aTitleText == KNullDesC && aBodyText != KNullDesC ) |
292 { |
303 { |
293 iTitleText = aBodyText.AllocL(); |
304 iTitleText = aBodyText.AllocL(); |
|
305 _AKNTRACE( _L("CAknDiscreetPopupDrawer::ConstructL, iTitleText : %S"), iTitleText ); |
294 } |
306 } |
295 else |
307 else |
296 { |
308 { |
297 iTitleText = aTitleText.AllocL(); |
309 iTitleText = aTitleText.AllocL(); |
298 iBodyText = aBodyText.AllocL(); |
310 iBodyText = aBodyText.AllocL(); |
|
311 _AKNTRACE( _L("CAknDiscreetPopupDrawer::ConstructL, iTitleText : %S"), iTitleText ); |
|
312 _AKNTRACE( _L("CAknDiscreetPopupDrawer::ConstructL, iBodyText : %S"), iBodyText ); |
299 } |
313 } |
300 |
314 |
301 if ( !iIcon ) |
315 if ( !iIcon ) |
302 { |
316 { |
303 iIcon = CreatePopupIconL( aSkinId, |
317 iIcon = CreatePopupIconL( aSkinId, |
307 } |
321 } |
308 } |
322 } |
309 |
323 |
310 |
324 |
311 // --------------------------------------------------------------------------- |
325 // --------------------------------------------------------------------------- |
312 // CAknDiscreetPopupDrawer::CreatePopupBitmap |
|
313 // --------------------------------------------------------------------------- |
|
314 // |
|
315 void CAknDiscreetPopupDrawer::CreatePopupBitmapL( const TRect& aRect ) |
|
316 { |
|
317 delete iPopupBitmap; |
|
318 iPopupBitmap = NULL; |
|
319 |
|
320 // create a bitmap to draw to |
|
321 CFbsBitmap* bitmap = new ( ELeave ) CFbsBitmap; |
|
322 CleanupStack::PushL( bitmap ); |
|
323 |
|
324 bitmap->Create( |
|
325 aRect.Size(), CCoeEnv::Static()->ScreenDevice()->DisplayMode() ); |
|
326 CFbsBitGc* fbsBitGc = CFbsBitGc::NewL(); |
|
327 CleanupStack::PushL( fbsBitGc ); |
|
328 CFbsBitmapDevice* bmpDevice = CFbsBitmapDevice::NewL( bitmap ); |
|
329 CleanupStack::PushL( bmpDevice ); |
|
330 fbsBitGc->Activate( bmpDevice ); |
|
331 |
|
332 // draw background of the popup |
|
333 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
334 AknsDrawUtils::DrawFrame( skin, *fbsBitGc, aRect, aRect, |
|
335 KAknsIIDQsnFrPopupPreview, KAknsIIDDefault, KAknsDrawParamDefault ); |
|
336 |
|
337 // Draw the texts |
|
338 TRgb textColor( EikonEnv()->ControlColor( EColorControlText, *iControl ) ); |
|
339 if ( iAction ) |
|
340 { |
|
341 fbsBitGc->SetUnderlineStyle( EUnderlineOn ); |
|
342 AknsUtils::GetCachedColor( skin, |
|
343 textColor, |
|
344 KAknsIIDQsnHighlightColors, |
|
345 EAknsCIQsnHighlightColorsCG3 ); |
|
346 } |
|
347 else |
|
348 { |
|
349 AknsUtils::GetCachedColor( skin, |
|
350 textColor, |
|
351 KAknsIIDQsnTextColors, |
|
352 EAknsCIQsnTextColorsCG55 ); |
|
353 } |
|
354 fbsBitGc->SetPenColor( textColor ); |
|
355 DrawTexts( fbsBitGc ); |
|
356 fbsBitGc->SetUnderlineStyle( EUnderlineOff ); |
|
357 |
|
358 // draw the icon |
|
359 if ( iIcon && iIcon->Bitmap() && iIcon->Mask() ) |
|
360 { |
|
361 fbsBitGc->BitBltMasked( iIconRect.iTl, |
|
362 iIcon->Bitmap(), |
|
363 iIcon->Bitmap()->SizeInPixels(), |
|
364 iIcon->Mask(), |
|
365 EFalse ); |
|
366 |
|
367 } |
|
368 else if( iIcon && iIcon->Bitmap() ) |
|
369 { |
|
370 fbsBitGc->BitBlt( iIconRect.iTl, iIcon->Bitmap() ); |
|
371 } |
|
372 |
|
373 CleanupStack::PopAndDestroy( bmpDevice ); |
|
374 CleanupStack::PopAndDestroy( fbsBitGc ); |
|
375 CleanupStack::Pop( bitmap ); |
|
376 |
|
377 iPopupBitmap = bitmap; |
|
378 } |
|
379 |
|
380 |
|
381 // --------------------------------------------------------------------------- |
|
382 // CAknDiscreetPopupDrawer::CreateTransparentMaskL |
|
383 // --------------------------------------------------------------------------- |
|
384 // |
|
385 void CAknDiscreetPopupDrawer::CreateTransparentMaskL( const TRect& aRect ) |
|
386 { |
|
387 delete iTransparentMask; |
|
388 iTransparentMask = NULL; |
|
389 iTransparentMask = new ( ELeave ) CFbsBitmap; |
|
390 iTransparentMask->Create( aRect.Size(), EGray256 ); |
|
391 } |
|
392 |
|
393 |
|
394 // --------------------------------------------------------------------------- |
|
395 // CAknDiscreetPopupDrawer::DrawTexts |
326 // CAknDiscreetPopupDrawer::DrawTexts |
396 // --------------------------------------------------------------------------- |
327 // --------------------------------------------------------------------------- |
397 // |
328 // |
398 void CAknDiscreetPopupDrawer::DrawTexts( CFbsBitGc* aGc ) |
329 void CAknDiscreetPopupDrawer::DrawTexts( CWindowGc* aGc ) const |
399 { |
330 { |
400 aGc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
331 aGc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
401 |
332 |
402 DrawBidiEnabledText( aGc, iTitleTextData, *iTitleText ); |
333 DrawBidiEnabledText( aGc, iTitleTextData, *iTitleText ); |
403 |
334 |
555 // --------------------------------------------------------------------------- |
486 // --------------------------------------------------------------------------- |
556 // CAknDiscreetPopupDrawer::DrawBidiEnabledText |
487 // CAknDiscreetPopupDrawer::DrawBidiEnabledText |
557 // --------------------------------------------------------------------------- |
488 // --------------------------------------------------------------------------- |
558 // |
489 // |
559 void CAknDiscreetPopupDrawer::DrawBidiEnabledText( |
490 void CAknDiscreetPopupDrawer::DrawBidiEnabledText( |
560 CFbsBitGc* aGc, |
491 CWindowGc* aGc, |
561 TAknDiscreetPopupTextData& aTextData, |
492 const TAknDiscreetPopupTextData& aTextData, |
562 const TDesC& aText ) |
493 const TDesC& aText ) const |
563 { |
494 { |
564 // Buffer for visually ordered text |
495 // Buffer for visually ordered text |
565 TBuf<KTextBufSize + KAknBidiExtraSpacePerLine> visualText; |
496 TBuf<KTextBufSize + KAknBidiExtraSpacePerLine> visualText; |
566 TInt clipWidth( aTextData.iTextRect.Width() ); |
497 TInt clipWidth( aTextData.iTextRect.Width() ); |
567 |
498 |