205 return popupRect; |
207 return popupRect; |
206 } |
208 } |
207 |
209 |
208 |
210 |
209 // --------------------------------------------------------------------------- |
211 // --------------------------------------------------------------------------- |
210 // CAknDiscreetPopupDrawer::Draw |
212 // CAknDiscreetPopupDrawer::PopupBitmap |
211 // Draws popup to given graphics context. |
213 // Provides popup bitmap. |
212 // --------------------------------------------------------------------------- |
214 // --------------------------------------------------------------------------- |
213 // |
215 // |
214 void CAknDiscreetPopupDrawer::Draw( CWindowGc& aGc, |
216 CFbsBitmap* CAknDiscreetPopupDrawer::PopupBitmap( const TSize& aSize ) |
215 const TRect& aRect ) const |
217 { |
216 { |
218 if ( !iPopupBitmap || aSize != iPopupBitmap->SizeInPixels() ) |
217 // draw background of the popup |
219 { |
218 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
220 TRAP_IGNORE( CreatePopupBitmapL( TRect( TPoint(), aSize ) ) ); |
219 AknsDrawUtils::DrawFrame( skin, aGc, aRect, aRect, |
221 } |
220 KAknsIIDQsnFrPopupPreview, KAknsIIDDefault ); |
222 return iPopupBitmap; |
221 |
223 } |
222 // Draw the texts |
224 |
223 TRgb textColor( EikonEnv()->ControlColor( EColorControlText, *iControl ) ); |
225 |
224 |
226 // --------------------------------------------------------------------------- |
225 if ( iAction ) |
227 // CAknDiscreetPopupDrawer::TransparentMask |
226 { |
228 // Provides transparent mask for a bitmap. |
227 aGc.SetUnderlineStyle( EUnderlineOn ); |
229 // --------------------------------------------------------------------------- |
228 AknsUtils::GetCachedColor( skin, |
230 // |
229 textColor, |
231 CFbsBitmap* CAknDiscreetPopupDrawer::TransparentMask( |
230 KAknsIIDQsnHighlightColors, |
232 const TSize& aSize, const TInt& aAlpha ) |
231 EAknsCIQsnHighlightColorsCG3 ); |
233 { |
232 } |
234 if ( !iTransparentMask || aSize != iTransparentMask->SizeInPixels() ) |
233 else |
235 { |
234 { |
236 TRAP_IGNORE( CreateTransparentMaskL( TRect( TPoint(), aSize ) ) ); |
235 AknsUtils::GetCachedColor( skin, |
237 } |
236 textColor, |
238 |
237 KAknsIIDQsnTextColors, |
239 TInt width( iTransparentMask->SizeInPixels().iWidth ); |
238 EAknsCIQsnTextColorsCG55 ); |
240 TInt height( iTransparentMask->SizeInPixels().iHeight ); |
239 } |
241 TUint8* address( ( TUint8* ) iTransparentMask->DataAddress() ); |
240 aGc.SetPenColor( textColor ); |
242 TInt dataStride( iTransparentMask->DataStride() - width ); |
241 DrawTexts( &aGc ); |
243 |
242 aGc.SetUnderlineStyle( EUnderlineOff ); |
244 for ( TInt i = 0; i < height; ++i ) |
243 |
245 { |
244 // draw the icon |
246 for ( TInt j = 0; j < width; j++ ) |
245 if ( iIcon && iIcon->Bitmap() && iIcon->Mask() ) |
247 { |
246 { |
248 *address = aAlpha; |
247 aGc.BitBltMasked( iIconRect.iTl, |
249 ++address; |
248 iIcon->Bitmap(), |
250 } |
249 iIcon->Bitmap()->SizeInPixels(), |
251 address += dataStride; |
250 iIcon->Mask(), |
252 } |
251 EFalse ); |
253 |
252 |
254 return iTransparentMask; |
253 } |
255 } |
254 else if( iIcon && iIcon->Bitmap() ) |
|
255 { |
|
256 aGc.BitBlt( iIconRect.iTl, iIcon->Bitmap() ); |
|
257 } |
|
258 } |
|
259 |
256 |
260 |
257 |
261 // --------------------------------------------------------------------------- |
258 // --------------------------------------------------------------------------- |
262 // CAknDiscreetPopupDrawer::CAknDiscreetPopupDrawer |
259 // CAknDiscreetPopupDrawer::CAknDiscreetPopupDrawer |
263 // --------------------------------------------------------------------------- |
260 // --------------------------------------------------------------------------- |
308 } |
307 } |
309 } |
308 } |
310 |
309 |
311 |
310 |
312 // --------------------------------------------------------------------------- |
311 // --------------------------------------------------------------------------- |
|
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 // --------------------------------------------------------------------------- |
313 // CAknDiscreetPopupDrawer::DrawTexts |
395 // CAknDiscreetPopupDrawer::DrawTexts |
314 // --------------------------------------------------------------------------- |
396 // --------------------------------------------------------------------------- |
315 // |
397 // |
316 void CAknDiscreetPopupDrawer::DrawTexts( CWindowGc* aGc ) const |
398 void CAknDiscreetPopupDrawer::DrawTexts( CFbsBitGc* aGc ) |
317 { |
399 { |
318 aGc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
400 aGc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
319 |
401 |
320 DrawBidiEnabledText( aGc, iTitleTextData, *iTitleText ); |
402 DrawBidiEnabledText( aGc, iTitleTextData, *iTitleText ); |
321 |
403 |
473 // --------------------------------------------------------------------------- |
555 // --------------------------------------------------------------------------- |
474 // CAknDiscreetPopupDrawer::DrawBidiEnabledText |
556 // CAknDiscreetPopupDrawer::DrawBidiEnabledText |
475 // --------------------------------------------------------------------------- |
557 // --------------------------------------------------------------------------- |
476 // |
558 // |
477 void CAknDiscreetPopupDrawer::DrawBidiEnabledText( |
559 void CAknDiscreetPopupDrawer::DrawBidiEnabledText( |
478 CWindowGc* aGc, |
560 CFbsBitGc* aGc, |
479 const TAknDiscreetPopupTextData& aTextData, |
561 TAknDiscreetPopupTextData& aTextData, |
480 const TDesC& aText ) const |
562 const TDesC& aText ) |
481 { |
563 { |
482 // Buffer for visually ordered text |
564 // Buffer for visually ordered text |
483 TBuf<KTextBufSize + KAknBidiExtraSpacePerLine> visualText; |
565 TBuf<KTextBufSize + KAknBidiExtraSpacePerLine> visualText; |
484 TInt clipWidth( aTextData.iTextRect.Width() ); |
566 TInt clipWidth( aTextData.iTextRect.Width() ); |
485 |
567 |