javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/src/swtdisplaybase.cpp
branchRCL_3
changeset 60 6c158198356e
parent 34 71c436fe3ce0
equal deleted inserted replaced
59:e5618cc85d74 60:6c158198356e
    14 #include <fbs.h>
    14 #include <fbs.h>
    15 #include <gulutil.h>
    15 #include <gulutil.h>
    16 #include <eikon.hrh>
    16 #include <eikon.hrh>
    17 #include <AknUtils.h>
    17 #include <AknUtils.h>
    18 #include <bautils.h>
    18 #include <bautils.h>
       
    19 #include <avkon.mbg>
       
    20 #include <AknsUtils.h>
       
    21 #include <AknsConstants.h>
       
    22 #include <aknconsts.h>
       
    23 #include <AknIconUtils.h>
    19 #include <swtlaffacade.h>
    24 #include <swtlaffacade.h>
    20 #include "s60commonutils.h"
    25 #include "s60commonutils.h"
    21 #include "swtfactory.h"
    26 #include "swtfactory.h"
    22 #include "swtdisplaybase.h"
    27 #include "swtdisplaybase.h"
    23 #include "eswtwidgetsexpanded.h"
    28 #include "eswtwidgetsexpanded.h"
    28 #include "swtimage.h"
    33 #include "swtimage.h"
    29 #include "swtmidremconobserver.h"
    34 #include "swtmidremconobserver.h"
    30 #include "swtjavabufferdrawer.h"
    35 #include "swtjavabufferdrawer.h"
    31 #include "swtfont.h"
    36 #include "swtfont.h"
    32 #include "swtuiutils.h"
    37 #include "swtuiutils.h"
    33 
    38 #include "imagescaler.h"
    34 
    39 
    35 #define ASSERT_JAVAUITHREAD() ASSERT(IsCurrentThreadJavaUi())
    40 #define ASSERT_JAVAUITHREAD() ASSERT(IsCurrentThreadJavaUi())
    36 #define ASSERT_NATIVEUITHREAD() ASSERT(IsCurrentThreadNativeUi())
    41 #define ASSERT_NATIVEUITHREAD() ASSERT(IsCurrentThreadNativeUi())
    37 
    42 
    38 
    43 
   361     }
   366     }
   362 }
   367 }
   363 
   368 
   364 /**
   369 /**
   365  * Constructs an uninitialised Image
   370  * Constructs an uninitialised Image
   366  *
       
   367  * @param aSize  The new image's size
   371  * @param aSize  The new image's size
   368  */
   372  */
   369 MSwtImage* ASwtDisplayBase::NewImageL(const TSize& aSize)
   373 MSwtImage* ASwtDisplayBase::NewImageL(const TSize& aSize)
   370 {
   374 {
   371     return CSwtImage::NewL(*this, aSize, *this);
   375     return CSwtImage::NewL(*this, aSize, *this);
   372 }
   376 }
   373 
   377 
   374 
       
   375 /**
   378 /**
   376  * Constructs an Image with initial data
   379  * Constructs an Image with initial data
   377  *
       
   378  * @param aData  The data to construct the image from
   380  * @param aData  The data to construct the image from
   379  */
   381  */
   380 MSwtImage* ASwtDisplayBase::NewImageFromDataL(const MSwtImageData& aData)
   382 MSwtImage* ASwtDisplayBase::NewImageFromDataL(const MSwtImageData& aData)
   381 {
   383 {
   382     return CSwtImage::NewL(this, aData, this);
   384     return CSwtImage::NewL(this, aData, this);
   383 }
   385 }
   384 
   386 
       
   387 /**
       
   388  * Constructs an image from native theme.
       
   389  * @param aId See TSwtThemeImageId
       
   390  */
       
   391 MSwtImage* ASwtDisplayBase::NewImageFromThemeL(const TInt aId)
       
   392 {
       
   393     CFbsBitmap* bmp = NULL;
       
   394     CFbsBitmap* mask = NULL;
       
   395     TSize size(0, 0);
       
   396     switch (aId)
       
   397     {
       
   398     case ESwtThemeImageSecurityTrusted:
       
   399         AknsUtils::CreateIconL(AknsUtils::SkinInstance(),
       
   400                                KAknsIIDQgnIndiMidpTrusted, bmp, mask,
       
   401                                AknIconUtils::AvkonIconFileName(),
       
   402                                EMbmAvkonQgn_indi_midp_trusted,
       
   403                                EMbmAvkonQgn_indi_midp_trusted_mask);
       
   404         size = CSwtLafFacade::GetLayoutRect(CSwtLafFacade::EListSingleGraphicPaneG1,
       
   405                                             TRect(),0).Rect().Size();
       
   406         break;
       
   407     case ESwtThemeImageSecurityUntrusted:
       
   408         AknsUtils::CreateIconL(AknsUtils::SkinInstance(),
       
   409                                KAknsIIDQgnIndiMidpUntrusted, bmp, mask,
       
   410                                AknIconUtils::AvkonIconFileName(),
       
   411                                EMbmAvkonQgn_indi_midp_untrusted,
       
   412                                EMbmAvkonQgn_indi_midp_untrusted_mask);
       
   413         size = CSwtLafFacade::GetLayoutRect(CSwtLafFacade::EListSingleGraphicPaneG1,
       
   414                                             TRect(),0).Rect().Size();
       
   415         break;
       
   416     default:
       
   417         return NULL;
       
   418     }
       
   419 
       
   420     if (!bmp)
       
   421     {
       
   422         return NULL;
       
   423     }
       
   424     else
       
   425     {
       
   426         if (size.iWidth > 0)
       
   427         {
       
   428             AknIconUtils::SetSize(bmp, size);
       
   429         }
       
   430         // bmp & mask ownership transferred to returned object
       
   431         return CSwtImage::NewL(*bmp, mask);
       
   432     }
       
   433 }
       
   434 
       
   435 /**
       
   436  * Constructs an Image from another Image.
       
   437  * @param aData  The data to construct the image from
       
   438  */
       
   439 MSwtImage* ASwtDisplayBase::ScaleImageL(const MSwtImage& aSrcImage,
       
   440                                         const TSize& aDestSize, TBool aKeepAspectRatio)
       
   441 {
       
   442     CFbsBitmap& srcBmp = const_cast<CFbsBitmap&>(aSrcImage.Bitmap());
       
   443     CFbsBitmap* srcMask = const_cast<CFbsBitmap*>(aSrcImage.MaskBitmap());
       
   444 
       
   445     CFbsBitmap* bmp = new(ELeave) CFbsBitmap;
       
   446     CleanupStack::PushL(bmp);
       
   447     User::LeaveIfError(bmp->Create(aDestSize, srcBmp.DisplayMode()));
       
   448 
       
   449     CFbsBitmap* mask = 0;
       
   450     if (srcMask)
       
   451     {
       
   452         mask = new(ELeave) CFbsBitmap;
       
   453         CleanupStack::PushL(mask);
       
   454         User::LeaveIfError(mask->Create(aDestSize, EGray256));
       
   455     }
       
   456 
       
   457     CImageScaler* scaler = CImageScaler::NewL();
       
   458     CleanupStack::PushL(scaler);
       
   459     scaler->Scale(srcBmp, *bmp, aKeepAspectRatio);
       
   460     if (srcMask)
       
   461     {
       
   462         scaler->Scale(*srcMask, *mask, aKeepAspectRatio);
       
   463     }
       
   464     CleanupStack::PopAndDestroy(scaler);
       
   465     if (mask)
       
   466     {
       
   467         CleanupStack::Pop(mask);
       
   468     }
       
   469     CleanupStack::Pop(bmp);
       
   470 
       
   471     // bmp & mask ownership transferred to returned object
       
   472     return CSwtImage::NewL(*bmp, mask);
       
   473 }
   385 
   474 
   386 //
   475 //
   387 // Own internal event methods
   476 // Own internal event methods
   388 //
   477 //
   389 
   478