src/gui/styles/qs60style_s60.cpp
branchRCL_3
changeset 8 3f74d0d4af4c
parent 5 d3bac044e0f0
child 14 c0432d11811c
equal deleted inserted replaced
6:dee5afe5301f 8:3f74d0d4af4c
    48 #include "private/qpixmap_s60_p.h"
    48 #include "private/qpixmap_s60_p.h"
    49 #include "private/qcore_symbian_p.h"
    49 #include "private/qcore_symbian_p.h"
    50 #include "qapplication.h"
    50 #include "qapplication.h"
    51 
    51 
    52 #include <w32std.h>
    52 #include <w32std.h>
    53 #include <aknsconstants.h>
    53 #include <AknsConstants.h>
    54 #include <aknconsts.h>
    54 #include <aknconsts.h>
    55 #include <aknsitemid.h>
    55 #include <AknsItemID.h>
    56 #include <aknsutils.h>
    56 #include <AknsUtils.h>
    57 #include <aknsdrawutils.h>
    57 #include <AknsDrawUtils.h>
    58 #include <aknsskininstance.h>
    58 #include <AknsSkinInstance.h>
    59 #include <aknsbasicbackgroundcontrolcontext.h>
    59 #include <AknsBasicBackgroundControlContext.h>
    60 #include <avkon.mbg>
    60 #include <avkon.mbg>
    61 #include <AknFontAccess.h>
    61 #include <AknFontAccess.h>
    62 #include <AknLayoutFont.h>
    62 #include <AknLayoutFont.h>
    63 #include <aknutils.h>
    63 #include <AknUtils.h>
    64 #include <aknnavi.h>
    64 #include <aknnavi.h>
    65 #include <gulicon.h>
    65 #include <gulicon.h>
    66 #include <AknBitmapAnimation.h>
    66 #include <AknBitmapAnimation.h>
    67 
    67 
    68 #if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN)
    68 #if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN)
   176     /* SP_QgnGrafBarWaitAnim */            {KAknsIIDQgnGrafBarWaitAnim,       EDrawAnimation,   ES60_All,    -1,-1},
   176     /* SP_QgnGrafBarWaitAnim */            {KAknsIIDQgnGrafBarWaitAnim,       EDrawAnimation,   ES60_All,    -1,-1},
   177     /* SP_QgnGrafBarFrameCenter */         {KAknsIIDQgnGrafBarFrameCenter,         EDrawIcon,   ES60_All,    -1,-1},
   177     /* SP_QgnGrafBarFrameCenter */         {KAknsIIDQgnGrafBarFrameCenter,         EDrawIcon,   ES60_All,    -1,-1},
   178     /* SP_QgnGrafBarFrameSideL */          {KAknsIIDQgnGrafBarFrameSideL,          EDrawIcon,   ES60_All,    -1,-1},
   178     /* SP_QgnGrafBarFrameSideL */          {KAknsIIDQgnGrafBarFrameSideL,          EDrawIcon,   ES60_All,    -1,-1},
   179     /* SP_QgnGrafBarFrameSideR */          {KAknsIIDQgnGrafBarFrameSideR,          EDrawIcon,   ES60_All,    -1,-1},
   179     /* SP_QgnGrafBarFrameSideR */          {KAknsIIDQgnGrafBarFrameSideR,          EDrawIcon,   ES60_All,    -1,-1},
   180     /* SP_QgnGrafBarProgress */            {KAknsIIDQgnGrafBarProgress,            EDrawIcon,   ES60_All,    -1,-1},
   180     /* SP_QgnGrafBarProgress */            {KAknsIIDQgnGrafBarProgress,            EDrawIcon,   ES60_All,    -1,-1},
       
   181     // No drop area for 3.x non-touch devices
       
   182     /* SP_QgnGrafOrgBgGrid */              {KAknsIIDNone,                          EDrawIcon,   ES60_3_X,    EAknsMajorGeneric ,0x1eba}, //KAknsIIDQgnGrafOrgBgGrid   
   181     /* SP_QgnGrafScrollArrowDown */        {KAknsIIDQgnGrafScrollArrowDown,     EDrawGulIcon,   ES60_All,    -1,-1},
   183     /* SP_QgnGrafScrollArrowDown */        {KAknsIIDQgnGrafScrollArrowDown,     EDrawGulIcon,   ES60_All,    -1,-1},
   182     /* SP_QgnGrafScrollArrowLeft */        {KAknsIIDQgnGrafScrollArrowLeft,     EDrawGulIcon,   ES60_All,    -1,-1},
   184     /* SP_QgnGrafScrollArrowLeft */        {KAknsIIDQgnGrafScrollArrowLeft,     EDrawGulIcon,   ES60_All,    -1,-1},
   183     /* SP_QgnGrafScrollArrowRight */       {KAknsIIDQgnGrafScrollArrowRight,    EDrawGulIcon,   ES60_All,    -1,-1},
   185     /* SP_QgnGrafScrollArrowRight */       {KAknsIIDQgnGrafScrollArrowRight,    EDrawGulIcon,   ES60_All,    -1,-1},
   184     /* SP_QgnGrafScrollArrowUp */          {KAknsIIDQgnGrafScrollArrowUp,       EDrawGulIcon,   ES60_All,    -1,-1},
   186     /* SP_QgnGrafScrollArrowUp */          {KAknsIIDQgnGrafScrollArrowUp,       EDrawGulIcon,   ES60_All,    -1,-1},
   185     /* SP_QgnGrafTabActiveL */             {KAknsIIDQgnGrafTabActiveL,             EDrawIcon,   ES60_All,    -1,-1},
   187     /* SP_QgnGrafTabActiveL */             {KAknsIIDQgnGrafTabActiveL,             EDrawIcon,   ES60_All,    -1,-1},
   751                 targetSize,
   753                 targetSize,
   752                 KAknsDrawParamDefault | KAknsDrawParamRGBOnly);
   754                 KAknsDrawParamDefault | KAknsDrawParamRGBOnly);
   753 
   755 
   754             if (drawn)
   756             if (drawn)
   755                 result = fromFbsBitmap(background, NULL, flags, targetSize);
   757                 result = fromFbsBitmap(background, NULL, flags, targetSize);
   756             // if drawing fails in skin server, just ignore the background (probably OOM occured)
   758             // if drawing fails in skin server, just ignore the background (probably OOM case)
   757 
   759 
   758             CleanupStack::PopAndDestroy(4, background); //background, dev, gc, bgContext
   760             CleanupStack::PopAndDestroy(4, background); //background, dev, gc, bgContext
   759     //        QS60WindowSurface::lockBitmapHeap();
   761     //        QS60WindowSurface::lockBitmapHeap();
   760             break;
   762             break;
   761         }
   763         }
   783                 constructedFromTheme = !animation->isResourceBased();
   785                 constructedFromTheme = !animation->isResourceBased();
   784             }
   786             }
   785 
   787 
   786             const int currentFrame = QS60StylePrivate::currentAnimationFrame(part);
   788             const int currentFrame = QS60StylePrivate::currentAnimationFrame(part);
   787             if (constructedFromTheme && aknAnimation && aknAnimation->BitmapAnimData()->FrameArray().Count() > 0) {
   789             if (constructedFromTheme && aknAnimation && aknAnimation->BitmapAnimData()->FrameArray().Count() > 0) {
   788                 //Animation was created succesfully and contains frames, just fetch current frame
   790                 //Animation was created successfully and contains frames, just fetch current frame
   789                 if(currentFrame >= aknAnimation->BitmapAnimData()->FrameArray().Count())
   791                 if(currentFrame >= aknAnimation->BitmapAnimData()->FrameArray().Count())
   790                     User::Leave(KErrOverflow);
   792                     User::Leave(KErrOverflow);
   791                 const CBitmapFrameData* frameData = aknAnimation->BitmapAnimData()->FrameArray().At(currentFrame);
   793                 const CBitmapFrameData* frameData = aknAnimation->BitmapAnimData()->FrameArray().At(currentFrame);
   792                 if (frameData) {
   794                 if (frameData) {
   793                     animationFrame = frameData->Bitmap();
   795                     animationFrame = frameData->Bitmap();
   855     CleanupStack::PushL(bitmapDev);
   857     CleanupStack::PushL(bitmapDev);
   856     CFbsBitGc* bitmapGc = NULL;
   858     CFbsBitGc* bitmapGc = NULL;
   857     User::LeaveIfError(bitmapDev->CreateContext(bitmapGc));
   859     User::LeaveIfError(bitmapDev->CreateContext(bitmapGc));
   858     CleanupStack::PushL(bitmapGc);
   860     CleanupStack::PushL(bitmapGc);
   859 
   861 
   860 #ifndef Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE
       
   861     frame->LockHeap();
   862     frame->LockHeap();
   862     memset(frame->DataAddress(), 0, frame->SizeInPixels().iWidth * frame->SizeInPixels().iHeight * 4);  // 4: argb bytes
   863     memset(frame->DataAddress(), 0, frame->SizeInPixels().iWidth * frame->SizeInPixels().iHeight * 4);  // 4: argb bytes
   863     frame->UnlockHeap();
   864     frame->UnlockHeap();
   864 #endif
       
   865 
   865 
   866     const TRect outerRect(TPoint(0, 0), targetSize);
   866     const TRect outerRect(TPoint(0, 0), targetSize);
   867     const TRect innerRect = innerRectFromElement(frameElement, outerRect);
   867     const TRect innerRect = innerRectFromElement(frameElement, outerRect);
   868 
   868 
   869     TAknsItemID frameSkinID, centerSkinID;
   869     TAknsItemID frameSkinID, centerSkinID;
   974     }
   974     }
   975 }
   975 }
   976 
   976 
   977 TRect QS60StyleModeSpecifics::innerRectFromElement(QS60StylePrivate::SkinFrameElements frameElement, const TRect &outerRect)
   977 TRect QS60StyleModeSpecifics::innerRectFromElement(QS60StylePrivate::SkinFrameElements frameElement, const TRect &outerRect)
   978 {
   978 {
   979     TInt widthShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth);
   979     TInt widthShrink = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth);
   980     TInt heightShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerHeight);
   980     TInt heightShrink = QS60StylePrivate::pixelMetric(PM_FrameCornerHeight);
   981     switch(frameElement) {
   981     switch(frameElement) {
   982         case QS60StylePrivate::SF_PanelBackground:
   982         case QS60StylePrivate::SF_PanelBackground:
   983             // panel should have slightly slimmer border to enable thin line of background graphics between closest component
   983             // panel should have slightly slimmer border to enable thin line of background graphics between closest component
   984             widthShrink = widthShrink-2;
   984             widthShrink = widthShrink - 2;
   985             heightShrink = heightShrink-2;
   985             heightShrink = heightShrink - 2;
   986             break;
   986             break;
   987         case QS60StylePrivate::SF_ToolTip:
   987         case QS60StylePrivate::SF_ToolTip:
   988             widthShrink = widthShrink>>1;
   988             widthShrink = widthShrink >> 1;
   989             heightShrink = heightShrink>>1;
   989             heightShrink = heightShrink >> 1;
   990             break;
   990             break;
   991         case QS60StylePrivate::SF_ListHighlight:
   991         case QS60StylePrivate::SF_ListHighlight:
   992             widthShrink = widthShrink-2;
   992             widthShrink = widthShrink - 2;
   993             heightShrink = heightShrink-2;
   993             heightShrink = heightShrink - 2;
       
   994             break;
       
   995         case QS60StylePrivate::SF_PopupBackground:
       
   996             widthShrink = widthShrink + 5;
       
   997             heightShrink = heightShrink + 5;
   994             break;
   998             break;
   995         default:
   999         default:
   996             break;
  1000             break;
   997     }
  1001     }
   998     TRect innerRect(outerRect);
  1002     TRect innerRect(outerRect);
  1092 
  1096 
  1093         activeLayoutIndex = (currentRelease == QSysInfo::SV_S60_3_1 || currentRelease == QSysInfo::SV_S60_3_2) ? 0 : 2;
  1097         activeLayoutIndex = (currentRelease == QSysInfo::SV_S60_3_1 || currentRelease == QSysInfo::SV_S60_3_2) ? 0 : 2;
  1094         activeLayoutIndex += (!landscape) ? 1 : 0;
  1098         activeLayoutIndex += (!landscape) ? 1 : 0;
  1095     }
  1099     }
  1096 
  1100 
  1097     m_pmPointer = data[activeLayoutIndex];
  1101     setCurrentLayout(activeLayoutIndex);
  1098 }
  1102 }
  1099 
  1103 
  1100 Q_GLOBAL_STATIC(QList<QS60StyleAnimation *>, m_animations)
  1104 Q_GLOBAL_STATIC(QList<QS60StyleAnimation *>, m_animations)
  1101 
  1105 
  1102 QS60StylePrivate::QS60StylePrivate()
  1106 QS60StylePrivate::QS60StylePrivate()
  1117         &KAknsIIDQsnLineColors,
  1121         &KAknsIIDQsnLineColors,
  1118         &KAknsIIDQsnOtherColors,
  1122         &KAknsIIDQsnOtherColors,
  1119         &KAknsIIDQsnParentColors,
  1123         &KAknsIIDQsnParentColors,
  1120         &KAknsIIDQsnTextColors
  1124         &KAknsIIDQsnTextColors
  1121     };
  1125     };
  1122     Q_ASSERT((int)list <= (int)sizeof(idMap)/sizeof(idMap[0]));
  1126     Q_ASSERT((int)list < (int)sizeof(idMap)/sizeof(idMap[0]));
  1123     const QColor color = QS60StyleModeSpecifics::colorValue(*idMap[(int) list], index - 1);
  1127     const QColor color = QS60StyleModeSpecifics::colorValue(*idMap[(int) list], index - 1);
  1124     return option ? QS60StylePrivate::stateColor(color, option) : color;
  1128     return option ? QS60StylePrivate::stateColor(color, option) : color;
  1125 }
  1129 }
  1126 
  1130 
  1127 // In some cases, the AVKON UI themegraphic is already in 'disabled state'.
  1131 // In some cases, the AVKON UI themegraphic is already in 'disabled state'.