src/gui/styles/qs60style_p.h
changeset 18 2f34d5167611
parent 3 41300fa6a67c
child 19 fcece45ef507
equal deleted inserted replaced
3:41300fa6a67c 18:2f34d5167611
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the QtGui module of the Qt Toolkit.
     7 ** This file is part of the QtGui module of the Qt Toolkit.
     8 **
     8 **
    72 typedef struct {
    72 typedef struct {
    73     unsigned short height;
    73     unsigned short height;
    74     unsigned short width;
    74     unsigned short width;
    75     int major_version;
    75     int major_version;
    76     int minor_version;
    76     int minor_version;
    77     bool mirroring; // TODO: (nice to have) Use Qt::LayoutDirection
       
    78     const char* layoutName;
    77     const char* layoutName;
    79 } layoutHeader;
    78 } layoutHeader;
    80 
    79 
    81 #ifdef Q_OS_SYMBIAN
    80 #ifdef Q_OS_SYMBIAN
    82 NONSHARABLE_CLASS (QS60StyleEnums)
    81 NONSHARABLE_CLASS (QS60StyleEnums)
    91     Q_ENUMS(SkinParts)
    90     Q_ENUMS(SkinParts)
    92     Q_ENUMS(ColorLists)
    91     Q_ENUMS(ColorLists)
    93 #endif // !Q_WS_S60
    92 #endif // !Q_WS_S60
    94 
    93 
    95 public:
    94 public:
       
    95 
       
    96     // S60 definitions within theme
       
    97     enum ThemeDefinitions {
       
    98         TD_AnimationData,
       
    99     };
       
   100 
       
   101     //Defines which values are contained within animation data (retrieved using TD_AnimationData).
       
   102     //Additionally defines the order in which the items are given out in QList<QVariant>.
       
   103     enum AnimationData {
       
   104         AD_Interval = 0,
       
   105         AD_NumberOfFrames,
       
   106         AD_AnimationPlayMode,  //currently not used as themes seem to contain invalid data
       
   107     };
       
   108 
       
   109     // Animation modes
       
   110     enum AnimationMode {
       
   111         AM_PlayOnce = 0, //animation is played exactly once
       
   112         AM_Looping,      //animation is repeated until stopped
       
   113         AM_Bounce        //animation is played repeatedly until stopped,
       
   114                          //but frames are played in reverse order every second time
       
   115                          //(no support yet)
       
   116     };
       
   117 
    96     // S60 look-and-feel font categories
   118     // S60 look-and-feel font categories
    97     enum FontCategories {
   119     enum FontCategories {
    98         FC_Undefined,
   120         FC_Undefined,
    99         FC_Primary,
   121         FC_Primary,
   100         FC_Secondary,
   122         FC_Secondary,
   102         FC_PrimarySmall,
   124         FC_PrimarySmall,
   103         FC_Digital
   125         FC_Digital
   104     };
   126     };
   105 
   127 
   106     enum SkinParts {
   128     enum SkinParts {
   107         SP_QgnGrafBarWait,
   129         SP_QgnGrafBarWaitAnim,
   108         SP_QgnGrafBarFrameCenter,
   130         SP_QgnGrafBarFrameCenter,
   109         SP_QgnGrafBarFrameSideL,
   131         SP_QgnGrafBarFrameSideL,
   110         SP_QgnGrafBarFrameSideR,
   132         SP_QgnGrafBarFrameSideR,
   111         SP_QgnGrafBarProgress,
   133         SP_QgnGrafBarProgress,
       
   134         SP_QgnGrafOrgBgGrid,
   112         SP_QgnGrafScrollArrowDown,
   135         SP_QgnGrafScrollArrowDown,
   113         SP_QgnGrafScrollArrowLeft,
   136         SP_QgnGrafScrollArrowLeft,
   114         SP_QgnGrafScrollArrowRight,
   137         SP_QgnGrafScrollArrowRight,
   115         SP_QgnGrafScrollArrowUp,
   138         SP_QgnGrafScrollArrowUp,
   116         SP_QgnGrafTabActiveL,
   139         SP_QgnGrafTabActiveL,
   285         CL_QsnParentColors,
   308         CL_QsnParentColors,
   286         CL_QsnTextColors
   309         CL_QsnTextColors
   287     };
   310     };
   288 };
   311 };
   289 
   312 
       
   313 #ifdef Q_WS_S60
       
   314 class CAknBitmapAnimation;
       
   315 NONSHARABLE_CLASS (AnimationData) : public QObject
       
   316 {
       
   317 public:
       
   318     AnimationData(const QS60StyleEnums::SkinParts part, int frames, int interval);
       
   319 
       
   320     const QS60StyleEnums::SkinParts m_id;
       
   321     int m_frames;
       
   322     int m_interval;
       
   323     QS60StyleEnums::AnimationMode m_mode;
       
   324 };
       
   325 
       
   326 
       
   327 NONSHARABLE_CLASS (AnimationDataV2) : public AnimationData
       
   328 {
       
   329 public:
       
   330     AnimationDataV2(const AnimationData &data);
       
   331     ~AnimationDataV2();
       
   332 
       
   333     CAknBitmapAnimation *m_animation;
       
   334     int m_currentFrame;
       
   335     bool m_resourceBased;
       
   336     int m_timerId;
       
   337 };
       
   338 
       
   339 
       
   340 class QS60StyleAnimation : public QObject
       
   341 {
       
   342 public:
       
   343     QS60StyleAnimation(const QS60StyleEnums::SkinParts part, int frames, int interval);
       
   344     ~QS60StyleAnimation();
       
   345 
       
   346 public:
       
   347     QS60StyleEnums::SkinParts animationId() const {return m_currentData->m_id;}
       
   348     int frameCount() const { return m_currentData->m_frames;}
       
   349     int interval() const {return m_currentData->m_interval;}
       
   350     QS60StyleEnums::AnimationMode playMode() const {return m_currentData->m_mode;}
       
   351     CAknBitmapAnimation* animationObject() const {return m_currentData->m_animation;}
       
   352     bool isResourceBased() const {return m_currentData->m_resourceBased;}
       
   353     int timerId() const {return m_currentData->m_timerId;}
       
   354     int currentFrame() const {return m_currentData->m_currentFrame;}
       
   355 
       
   356     void setFrameCount(int frameCount) {m_currentData->m_frames = frameCount;}
       
   357     void setInterval(int interval) {m_currentData->m_interval = interval;}
       
   358     void setAnimationObject(CAknBitmapAnimation* animation);
       
   359     void setResourceBased(bool resourceBased) {m_currentData->m_resourceBased = resourceBased;}
       
   360     void setTimerId(int timerId) {m_currentData->m_timerId = timerId;}
       
   361     void setCurrentFrame(int currentFrame) {m_currentData->m_currentFrame = currentFrame;}
       
   362 
       
   363     void resetToDefaults();
       
   364 
       
   365 private: //data members
       
   366     //TODO: consider changing these to non-pointers as the classes are rather small anyway
       
   367     AnimationData *m_defaultData;
       
   368     AnimationDataV2 *m_currentData;
       
   369 };
       
   370 
       
   371 #endif //Q_WS_S60
       
   372 
       
   373 
   290 class QFocusFrame;
   374 class QFocusFrame;
       
   375 class QProgressBar;
       
   376 class QS60StyleAnimation;
   291 
   377 
   292 // Private class
   378 // Private class
   293 #ifdef Q_OS_SYMBIAN
   379 #ifdef Q_OS_SYMBIAN
   294 NONSHARABLE_CLASS (QS60StylePrivate)
   380 NONSHARABLE_CLASS (QS60StylePrivate)
   295 #else
   381 #else
   341         SE_PanelBackground,
   427         SE_PanelBackground,
   342         SE_ScrollBarHandlePressedHorizontal, //only for 5.0+
   428         SE_ScrollBarHandlePressedHorizontal, //only for 5.0+
   343         SE_ScrollBarHandlePressedVertical,
   429         SE_ScrollBarHandlePressedVertical,
   344         SE_ButtonInactive,
   430         SE_ButtonInactive,
   345         SE_Editor,
   431         SE_Editor,
       
   432         SE_DropArea
   346     };
   433     };
   347 
   434 
   348     enum SkinFrameElements {
   435     enum SkinFrameElements {
   349         SF_ButtonNormal,
   436         SF_ButtonNormal,
   350         SF_ButtonPressed,
   437         SF_ButtonPressed,
   369         SF_PointWest =        0x0008,
   456         SF_PointWest =        0x0008,
   370 
   457 
   371         SF_StateEnabled =     0x0010, // Enabled = the default
   458         SF_StateEnabled =     0x0010, // Enabled = the default
   372         SF_StateDisabled =    0x0020,
   459         SF_StateDisabled =    0x0020,
   373         SF_ColorSkinned =     0x0040, // pixmap is colored with foreground pen color
   460         SF_ColorSkinned =     0x0040, // pixmap is colored with foreground pen color
       
   461         SF_Animation =        0x0080,
   374     };
   462     };
   375 
   463 
   376     enum CacheClearReason {
   464     enum CacheClearReason {
   377         CC_UndefinedChange = 0,
   465         CC_UndefinedChange = 0,
   378         CC_LayoutChange,
   466         CC_LayoutChange,
   399     static QColor lighterColor(const QColor &baseColor);
   487     static QColor lighterColor(const QColor &baseColor);
   400     //deduces if the given widget should have separately themeable background
   488     //deduces if the given widget should have separately themeable background
   401     static bool drawsOwnThemeBackground(const QWidget *widget);
   489     static bool drawsOwnThemeBackground(const QWidget *widget);
   402 
   490 
   403     QFont s60Font(QS60StyleEnums::FontCategories fontCategory,
   491     QFont s60Font(QS60StyleEnums::FontCategories fontCategory,
   404         int pointSize = -1) const;
   492         int pointSize = -1, bool resolveFontSize = true) const;
   405     // clears all style caches (fonts, colors, pixmaps)
   493     // clears all style caches (fonts, colors, pixmaps)
   406     void clearCaches(CacheClearReason reason = CC_UndefinedChange);
   494     void clearCaches(CacheClearReason reason = CC_UndefinedChange);
   407 
   495 
   408     // themed main background oprations
   496     // themed main background oprations
   409     void setBackgroundTexture(QApplication *application) const;
   497     void setBackgroundTexture(QApplication *application) const;
   410     static void deleteBackground();
   498     static void deleteBackground();
   411 
   499 
   412     static bool isTouchSupported();
   500     static bool isTouchSupported();
   413     static bool isToolBarBackground();
   501     static bool isToolBarBackground();
   414     static bool hasSliderGrooveGraphic();
   502     static bool hasSliderGrooveGraphic();
       
   503     static bool isSingleClickUi();
   415 
   504 
   416     // calculates average color based on button skin graphics (minus borders).
   505     // calculates average color based on button skin graphics (minus borders).
   417     QColor colorFromFrameGraphics(SkinFrameElements frame) const;
   506     QColor colorFromFrameGraphics(SkinFrameElements frame) const;
   418 
   507 
   419     //set theme palette for application
   508     //set theme palette for application
   451 
   540 
   452     static QSize naviPaneSize();
   541     static QSize naviPaneSize();
   453 
   542 
   454     //Checks that the current brush is transparent or has BrushStyle NoBrush,
   543     //Checks that the current brush is transparent or has BrushStyle NoBrush,
   455     //so that theme graphic background can be drawn.
   544     //so that theme graphic background can be drawn.
   456     static bool canDrawThemeBackground(const QBrush &backgroundBrush);
   545     static bool canDrawThemeBackground(const QBrush &backgroundBrush, const QWidget *widget);
       
   546 
       
   547     static int currentAnimationFrame(QS60StyleEnums::SkinParts part);
       
   548 #ifdef Q_WS_S60
       
   549 
       
   550     //No support for animations on emulated style
       
   551     void startAnimation(QS60StyleEnums::SkinParts animation);
       
   552     void stopAnimation(QS60StyleEnums::SkinParts animation);
       
   553     static QS60StyleAnimation* animationDefinition(QS60StyleEnums::SkinParts part);
       
   554 
       
   555 #endif
   457 
   556 
   458 private:
   557 private:
   459     static void drawPart(QS60StyleEnums::SkinParts part, QPainter *painter,
   558     static void drawPart(QS60StyleEnums::SkinParts part, QPainter *painter,
   460         const QRect &rect, SkinElementFlags flags = KDefaultSkinElementFlags);
   559         const QRect &rect, SkinElementFlags flags = KDefaultSkinElementFlags);
   461     static void drawRow(QS60StyleEnums::SkinParts start, QS60StyleEnums::SkinParts middle,
   560     static void drawRow(QS60StyleEnums::SkinParts start, QS60StyleEnums::SkinParts middle,
   482     static QSize partSize(QS60StyleEnums::SkinParts part,
   581     static QSize partSize(QS60StyleEnums::SkinParts part,
   483         SkinElementFlags flags = KDefaultSkinElementFlags);
   582         SkinElementFlags flags = KDefaultSkinElementFlags);
   484     static QPixmap part(QS60StyleEnums::SkinParts part, const QSize &size,
   583     static QPixmap part(QS60StyleEnums::SkinParts part, const QSize &size,
   485         QPainter *painter, SkinElementFlags flags = KDefaultSkinElementFlags);
   584         QPainter *painter, SkinElementFlags flags = KDefaultSkinElementFlags);
   486 
   585 
   487     static QFont s60Font_specific(QS60StyleEnums::FontCategories fontCategory, int pointSize);
   586     static QFont s60Font_specific(QS60StyleEnums::FontCategories fontCategory,
       
   587                                   int pointSize, bool resolveFontSize);
   488 
   588 
   489     static QSize screenSize();
   589     static QSize screenSize();
   490 
   590 
   491     // Contains background texture.
   591     // Contains background texture.
   492     static QPixmap *m_background;
   592     static QPixmap *m_background;
   494     // defined theme palette
   594     // defined theme palette
   495     static QPalette *m_themePalette;
   595     static QPalette *m_themePalette;
   496     QPalette m_originalPalette;
   596     QPalette m_originalPalette;
   497 
   597 
   498     QPointer<QFocusFrame> m_focusFrame;
   598     QPointer<QFocusFrame> m_focusFrame;
       
   599     static qint64 m_webPaletteKey;
       
   600 
       
   601 #ifdef Q_WS_S60
       
   602     //list of progress bars having animation running
       
   603     QList<QProgressBar *> m_bars;
       
   604 #endif
       
   605 
   499 };
   606 };
   500 
   607 
   501 QT_END_NAMESPACE
   608 QT_END_NAMESPACE
   502 
   609 
   503 #endif // QS60STYLE_P_H
   610 #endif // QS60STYLE_P_H