--- a/uifw/AvKon/src/akndiscreetpopupdrawer.cpp Tue Aug 31 15:28:30 2010 +0300
+++ b/uifw/AvKon/src/akndiscreetpopupdrawer.cpp Wed Sep 01 12:16:19 2010 +0100
@@ -25,6 +25,7 @@
#include "akndiscreetpopupdrawer.h"
+#include "akntrace.h"
const TInt KTextBufSize( 255 );
const TInt KMaxNumOfLines( 2 );
@@ -76,6 +77,7 @@
const TInt& aMaskId,
const TBool& aAction )
{
+ _AKNTRACE_FUNC_ENTER;
CAknDiscreetPopupDrawer* self =
CAknDiscreetPopupDrawer::NewLC( aControl,
aTitleText,
@@ -87,6 +89,7 @@
aMaskId,
aAction );
CleanupStack::Pop( self );
+ _AKNTRACE_FUNC_EXIT;
return self;
}
@@ -125,8 +128,6 @@
//
CAknDiscreetPopupDrawer::~CAknDiscreetPopupDrawer()
{
- delete iPopupBitmap;
- delete iTransparentMask;
delete iIcon;
delete iBodyText;
delete iTitleText;
@@ -209,50 +210,62 @@
// ---------------------------------------------------------------------------
-// CAknDiscreetPopupDrawer::PopupBitmap
-// Provides popup bitmap.
-// ---------------------------------------------------------------------------
-//
-CFbsBitmap* CAknDiscreetPopupDrawer::PopupBitmap( const TSize& aSize )
- {
- if ( !iPopupBitmap || aSize != iPopupBitmap->SizeInPixels() )
- {
- TRAP_IGNORE( CreatePopupBitmapL( TRect( TPoint(), aSize ) ) );
- }
- return iPopupBitmap;
- }
-
-
-// ---------------------------------------------------------------------------
-// CAknDiscreetPopupDrawer::TransparentMask
-// Provides transparent mask for a bitmap.
+// CAknDiscreetPopupDrawer::Draw
+// Draws popup to given graphics context.
// ---------------------------------------------------------------------------
//
-CFbsBitmap* CAknDiscreetPopupDrawer::TransparentMask(
- const TSize& aSize, const TInt& aAlpha )
+void CAknDiscreetPopupDrawer::Draw( CWindowGc& aGc,
+ const TRect& aRect ) const
{
- if ( !iTransparentMask || aSize != iTransparentMask->SizeInPixels() )
- {
- TRAP_IGNORE( CreateTransparentMaskL( TRect( TPoint(), aSize ) ) );
- }
-
- TInt width( iTransparentMask->SizeInPixels().iWidth );
- TInt height( iTransparentMask->SizeInPixels().iHeight );
- TUint8* address( ( TUint8* ) iTransparentMask->DataAddress() );
- TInt dataStride( iTransparentMask->DataStride() - width );
+ // draw background of the popup
+ MAknsSkinInstance* skin = AknsUtils::SkinInstance();
+ TAknLayoutRect innerLayout;
+ // Use bg_popup_preview_window_pane_g1() for getting innerRect,
+ // no need to create a new layout id for discreet popup.
+ innerLayout.LayoutRect( aRect,
+ AknLayoutScalable_Avkon::bg_popup_preview_window_pane_g1() );
+ TRect innerRect = innerLayout.Rect();
+
+ AknsDrawUtils::DrawFrame( skin, aGc, aRect, innerRect,
+ KAknsIIDQsnFrPopupPreview, KAknsIIDDefault );
- for ( TInt i = 0; i < height; ++i )
+ // Draw the texts
+ TRgb textColor( EikonEnv()->ControlColor( EColorControlText, *iControl ) );
+
+ if ( iAction )
+ {
+ aGc.SetUnderlineStyle( EUnderlineOn );
+ AknsUtils::GetCachedColor( skin,
+ textColor,
+ KAknsIIDQsnHighlightColors,
+ EAknsCIQsnHighlightColorsCG3 );
+ }
+ else
{
- for ( TInt j = 0; j < width; j++ )
- {
- *address = aAlpha;
- ++address;
- }
- address += dataStride;
+ AknsUtils::GetCachedColor( skin,
+ textColor,
+ KAknsIIDQsnTextColors,
+ EAknsCIQsnTextColorsCG55 );
}
-
- return iTransparentMask;
- }
+ aGc.SetPenColor( textColor );
+ DrawTexts( &aGc );
+ aGc.SetUnderlineStyle( EUnderlineOff );
+
+ // draw the icon
+ if ( iIcon && iIcon->Bitmap() && iIcon->Mask() )
+ {
+ aGc.BitBltMasked( iIconRect.iTl,
+ iIcon->Bitmap(),
+ iIcon->Bitmap()->SizeInPixels(),
+ iIcon->Mask(),
+ EFalse );
+
+ }
+ else if( iIcon && iIcon->Bitmap() )
+ {
+ aGc.BitBlt( iIconRect.iTl, iIcon->Bitmap() );
+ }
+ }
// ---------------------------------------------------------------------------
@@ -268,8 +281,6 @@
iTitleText( NULL ),
iBodyText( NULL ),
iIcon( aIcon ),
- iPopupBitmap( NULL ),
- iTransparentMask( NULL ),
iPopupLayoutType( KLayoutUnresolved ),
iAction( aAction )
{
@@ -291,11 +302,14 @@
if ( aTitleText == KNullDesC && aBodyText != KNullDesC )
{
iTitleText = aBodyText.AllocL();
+ _AKNTRACE( _L("CAknDiscreetPopupDrawer::ConstructL, iTitleText : %S"), iTitleText );
}
else
{
iTitleText = aTitleText.AllocL();
iBodyText = aBodyText.AllocL();
+ _AKNTRACE( _L("CAknDiscreetPopupDrawer::ConstructL, iTitleText : %S"), iTitleText );
+ _AKNTRACE( _L("CAknDiscreetPopupDrawer::ConstructL, iBodyText : %S"), iBodyText );
}
if ( !iIcon )
@@ -309,93 +323,10 @@
// ---------------------------------------------------------------------------
-// CAknDiscreetPopupDrawer::CreatePopupBitmap
-// ---------------------------------------------------------------------------
-//
-void CAknDiscreetPopupDrawer::CreatePopupBitmapL( const TRect& aRect )
- {
- delete iPopupBitmap;
- iPopupBitmap = NULL;
-
- // create a bitmap to draw to
- CFbsBitmap* bitmap = new ( ELeave ) CFbsBitmap;
- CleanupStack::PushL( bitmap );
-
- bitmap->Create(
- aRect.Size(), CCoeEnv::Static()->ScreenDevice()->DisplayMode() );
- CFbsBitGc* fbsBitGc = CFbsBitGc::NewL();
- CleanupStack::PushL( fbsBitGc );
- CFbsBitmapDevice* bmpDevice = CFbsBitmapDevice::NewL( bitmap );
- CleanupStack::PushL( bmpDevice );
- fbsBitGc->Activate( bmpDevice );
-
- // draw background of the popup
- MAknsSkinInstance* skin = AknsUtils::SkinInstance();
- AknsDrawUtils::DrawFrame( skin, *fbsBitGc, aRect, aRect,
- KAknsIIDQsnFrPopupPreview, KAknsIIDDefault, KAknsDrawParamDefault );
-
- // Draw the texts
- TRgb textColor( EikonEnv()->ControlColor( EColorControlText, *iControl ) );
- if ( iAction )
- {
- fbsBitGc->SetUnderlineStyle( EUnderlineOn );
- AknsUtils::GetCachedColor( skin,
- textColor,
- KAknsIIDQsnHighlightColors,
- EAknsCIQsnHighlightColorsCG3 );
- }
- else
- {
- AknsUtils::GetCachedColor( skin,
- textColor,
- KAknsIIDQsnTextColors,
- EAknsCIQsnTextColorsCG55 );
- }
- fbsBitGc->SetPenColor( textColor );
- DrawTexts( fbsBitGc );
- fbsBitGc->SetUnderlineStyle( EUnderlineOff );
-
- // draw the icon
- if ( iIcon && iIcon->Bitmap() && iIcon->Mask() )
- {
- fbsBitGc->BitBltMasked( iIconRect.iTl,
- iIcon->Bitmap(),
- iIcon->Bitmap()->SizeInPixels(),
- iIcon->Mask(),
- EFalse );
-
- }
- else if( iIcon && iIcon->Bitmap() )
- {
- fbsBitGc->BitBlt( iIconRect.iTl, iIcon->Bitmap() );
- }
-
- CleanupStack::PopAndDestroy( bmpDevice );
- CleanupStack::PopAndDestroy( fbsBitGc );
- CleanupStack::Pop( bitmap );
-
- iPopupBitmap = bitmap;
- }
-
-
-// ---------------------------------------------------------------------------
-// CAknDiscreetPopupDrawer::CreateTransparentMaskL
-// ---------------------------------------------------------------------------
-//
-void CAknDiscreetPopupDrawer::CreateTransparentMaskL( const TRect& aRect )
- {
- delete iTransparentMask;
- iTransparentMask = NULL;
- iTransparentMask = new ( ELeave ) CFbsBitmap;
- iTransparentMask->Create( aRect.Size(), EGray256 );
- }
-
-
-// ---------------------------------------------------------------------------
// CAknDiscreetPopupDrawer::DrawTexts
// ---------------------------------------------------------------------------
//
-void CAknDiscreetPopupDrawer::DrawTexts( CFbsBitGc* aGc )
+void CAknDiscreetPopupDrawer::DrawTexts( CWindowGc* aGc ) const
{
aGc->SetBrushStyle( CGraphicsContext::ENullBrush );
@@ -424,7 +355,7 @@
TBool withIcon( iIcon && iIcon->Bitmap() );
TBool twoRowsText(
iTitleText->Des() != KNullDesC
- && iBodyText->Des() != KNullDesC );
+ && iBodyText && iBodyText->Des() != KNullDesC );
// Two rows of text
if ( twoRowsText )
@@ -471,7 +402,7 @@
// Provides control eikon env.
// ---------------------------------------------------------------------------
//
-CEikonEnv* CAknDiscreetPopupDrawer::EikonEnv()
+CEikonEnv* CAknDiscreetPopupDrawer::EikonEnv() const
{
if ( iControl )
{
@@ -557,9 +488,9 @@
// ---------------------------------------------------------------------------
//
void CAknDiscreetPopupDrawer::DrawBidiEnabledText(
- CFbsBitGc* aGc,
- TAknDiscreetPopupTextData& aTextData,
- const TDesC& aText )
+ CWindowGc* aGc,
+ const TAknDiscreetPopupTextData& aTextData,
+ const TDesC& aText ) const
{
// Buffer for visually ordered text
TBuf<KTextBufSize + KAknBidiExtraSpacePerLine> visualText;