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 ** |
58 // |
58 // |
59 |
59 |
60 QT_BEGIN_NAMESPACE |
60 QT_BEGIN_NAMESPACE |
61 |
61 |
62 const int MAX_NON_CUSTOM_PIXELMETRICS = 92; |
62 const int MAX_NON_CUSTOM_PIXELMETRICS = 92; |
63 const int CUSTOMVALUESCOUNT = 4; |
63 const int CUSTOMVALUESCOUNT = 5; |
64 enum { |
64 |
65 PM_Custom_FrameCornerWidth = MAX_NON_CUSTOM_PIXELMETRICS, |
|
66 PM_Custom_FrameCornerHeight, |
|
67 PM_Custom_BoldLineWidth, |
|
68 PM_Custom_ThinLineWidth |
|
69 }; |
|
70 const int MAX_PIXELMETRICS = MAX_NON_CUSTOM_PIXELMETRICS + CUSTOMVALUESCOUNT; |
65 const int MAX_PIXELMETRICS = MAX_NON_CUSTOM_PIXELMETRICS + CUSTOMVALUESCOUNT; |
71 |
66 |
72 typedef struct { |
67 typedef struct { |
73 unsigned short height; |
68 unsigned short height; |
74 unsigned short width; |
69 unsigned short width; |
75 int major_version; |
70 int major_version; |
76 int minor_version; |
71 int minor_version; |
77 bool mirroring; // TODO: (nice to have) Use Qt::LayoutDirection |
|
78 const char* layoutName; |
72 const char* layoutName; |
79 } layoutHeader; |
73 } layoutHeader; |
80 |
74 |
81 #ifdef Q_OS_SYMBIAN |
75 #ifdef Q_OS_SYMBIAN |
82 NONSHARABLE_CLASS (QS60StyleEnums) |
76 NONSHARABLE_CLASS (QS60StyleEnums) |
91 Q_ENUMS(SkinParts) |
85 Q_ENUMS(SkinParts) |
92 Q_ENUMS(ColorLists) |
86 Q_ENUMS(ColorLists) |
93 #endif // !Q_WS_S60 |
87 #endif // !Q_WS_S60 |
94 |
88 |
95 public: |
89 public: |
|
90 |
|
91 // S60 definitions within theme |
|
92 enum ThemeDefinitions { |
|
93 TD_AnimationData, |
|
94 }; |
|
95 |
|
96 //Defines which values are contained within animation data (retrieved using TD_AnimationData). |
|
97 //Additionally defines the order in which the items are given out in QList<QVariant>. |
|
98 enum AnimationData { |
|
99 AD_Interval = 0, |
|
100 AD_NumberOfFrames, |
|
101 AD_AnimationPlayMode, //currently not used as themes seem to contain invalid data |
|
102 }; |
|
103 |
|
104 // Animation modes |
|
105 enum AnimationMode { |
|
106 AM_PlayOnce = 0, //animation is played exactly once |
|
107 AM_Looping, //animation is repeated until stopped |
|
108 AM_Bounce //animation is played repeatedly until stopped, |
|
109 //but frames are played in reverse order every second time |
|
110 //(no support yet) |
|
111 }; |
|
112 |
96 // S60 look-and-feel font categories |
113 // S60 look-and-feel font categories |
97 enum FontCategories { |
114 enum FontCategories { |
98 FC_Undefined, |
115 FC_Undefined, |
99 FC_Primary, |
116 FC_Primary, |
100 FC_Secondary, |
117 FC_Secondary, |
102 FC_PrimarySmall, |
119 FC_PrimarySmall, |
103 FC_Digital |
120 FC_Digital |
104 }; |
121 }; |
105 |
122 |
106 enum SkinParts { |
123 enum SkinParts { |
107 SP_QgnGrafBarWait, |
124 SP_QgnGrafBarWaitAnim, |
108 SP_QgnGrafBarFrameCenter, |
125 SP_QgnGrafBarFrameCenter, |
109 SP_QgnGrafBarFrameSideL, |
126 SP_QgnGrafBarFrameSideL, |
110 SP_QgnGrafBarFrameSideR, |
127 SP_QgnGrafBarFrameSideR, |
111 SP_QgnGrafBarProgress, |
128 SP_QgnGrafBarProgress, |
|
129 SP_QgnGrafOrgBgGrid, |
112 SP_QgnGrafScrollArrowDown, |
130 SP_QgnGrafScrollArrowDown, |
113 SP_QgnGrafScrollArrowLeft, |
131 SP_QgnGrafScrollArrowLeft, |
114 SP_QgnGrafScrollArrowRight, |
132 SP_QgnGrafScrollArrowRight, |
115 SP_QgnGrafScrollArrowUp, |
133 SP_QgnGrafScrollArrowUp, |
116 SP_QgnGrafTabActiveL, |
134 SP_QgnGrafTabActiveL, |
285 CL_QsnParentColors, |
303 CL_QsnParentColors, |
286 CL_QsnTextColors |
304 CL_QsnTextColors |
287 }; |
305 }; |
288 }; |
306 }; |
289 |
307 |
|
308 #ifdef Q_WS_S60 |
|
309 class CAknBitmapAnimation; |
|
310 NONSHARABLE_CLASS (AnimationData) : public QObject |
|
311 { |
|
312 public: |
|
313 AnimationData(const QS60StyleEnums::SkinParts part, int frames, int interval); |
|
314 |
|
315 const QS60StyleEnums::SkinParts m_id; |
|
316 int m_frames; |
|
317 int m_interval; |
|
318 QS60StyleEnums::AnimationMode m_mode; |
|
319 }; |
|
320 |
|
321 |
|
322 NONSHARABLE_CLASS (AnimationDataV2) : public AnimationData |
|
323 { |
|
324 public: |
|
325 AnimationDataV2(const AnimationData &data); |
|
326 ~AnimationDataV2(); |
|
327 |
|
328 CAknBitmapAnimation *m_animation; |
|
329 int m_currentFrame; |
|
330 bool m_resourceBased; |
|
331 int m_timerId; |
|
332 }; |
|
333 |
|
334 |
|
335 class QS60StyleAnimation : public QObject |
|
336 { |
|
337 public: |
|
338 QS60StyleAnimation(const QS60StyleEnums::SkinParts part, int frames, int interval); |
|
339 ~QS60StyleAnimation(); |
|
340 |
|
341 public: |
|
342 QS60StyleEnums::SkinParts animationId() const {return m_currentData->m_id;} |
|
343 int frameCount() const { return m_currentData->m_frames;} |
|
344 int interval() const {return m_currentData->m_interval;} |
|
345 QS60StyleEnums::AnimationMode playMode() const {return m_currentData->m_mode;} |
|
346 CAknBitmapAnimation* animationObject() const {return m_currentData->m_animation;} |
|
347 bool isResourceBased() const {return m_currentData->m_resourceBased;} |
|
348 int timerId() const {return m_currentData->m_timerId;} |
|
349 int currentFrame() const {return m_currentData->m_currentFrame;} |
|
350 |
|
351 void setFrameCount(int frameCount) {m_currentData->m_frames = frameCount;} |
|
352 void setInterval(int interval) {m_currentData->m_interval = interval;} |
|
353 void setAnimationObject(CAknBitmapAnimation* animation); |
|
354 void setResourceBased(bool resourceBased) {m_currentData->m_resourceBased = resourceBased;} |
|
355 void setTimerId(int timerId) {m_currentData->m_timerId = timerId;} |
|
356 void setCurrentFrame(int currentFrame) {m_currentData->m_currentFrame = currentFrame;} |
|
357 |
|
358 void resetToDefaults(); |
|
359 |
|
360 private: //data members |
|
361 //TODO: consider changing these to non-pointers as the classes are rather small anyway |
|
362 AnimationData *m_defaultData; |
|
363 AnimationDataV2 *m_currentData; |
|
364 }; |
|
365 |
|
366 #endif //Q_WS_S60 |
|
367 |
|
368 |
290 class QFocusFrame; |
369 class QFocusFrame; |
|
370 class QProgressBar; |
|
371 class QS60StyleAnimation; |
291 |
372 |
292 // Private class |
373 // Private class |
293 #ifdef Q_OS_SYMBIAN |
374 #ifdef Q_OS_SYMBIAN |
294 NONSHARABLE_CLASS (QS60StylePrivate) |
375 NONSHARABLE_CLASS (QS60StylePrivate) |
295 #else |
376 #else |
328 SE_TabBarTabSouthActive, |
409 SE_TabBarTabSouthActive, |
329 SE_TabBarTabSouthInactive, |
410 SE_TabBarTabSouthInactive, |
330 SE_TabBarTabWestActive, |
411 SE_TabBarTabWestActive, |
331 SE_TabBarTabWestInactive, |
412 SE_TabBarTabWestInactive, |
332 SE_ListHighlight, |
413 SE_ListHighlight, |
333 SE_OptionsMenu, |
414 SE_PopupBackground, |
334 SE_SettingsList, |
415 SE_SettingsList, |
335 SE_TableItem, |
416 SE_TableItem, |
336 SE_TableHeaderItem, |
417 SE_TableHeaderItem, |
337 SE_ToolTip, //own graphic available on 3.2+ releases, |
418 SE_ToolTip, //own graphic available on 3.2+ releases, |
338 SE_ToolBar, |
419 SE_ToolBar, |
339 SE_ToolBarButton, |
420 SE_ToolBarButton, |
340 SE_ToolBarButtonPressed, |
421 SE_ToolBarButtonPressed, |
341 SE_PanelBackground, |
422 SE_PanelBackground, |
342 SE_ScrollBarHandlePressedHorizontal, //only for 5.0+ |
423 SE_ScrollBarHandlePressedHorizontal, |
343 SE_ScrollBarHandlePressedVertical, |
424 SE_ScrollBarHandlePressedVertical, |
344 SE_ButtonInactive, |
425 SE_ButtonInactive, |
345 SE_Editor, |
426 SE_Editor, |
|
427 SE_DropArea |
346 }; |
428 }; |
347 |
429 |
348 enum SkinFrameElements { |
430 enum SkinFrameElements { |
349 SF_ButtonNormal, |
431 SF_ButtonNormal, |
350 SF_ButtonPressed, |
432 SF_ButtonPressed, |
351 SF_FrameLineEdit, |
433 SF_FrameLineEdit, |
352 SF_ListHighlight, |
434 SF_ListHighlight, |
353 SF_OptionsMenu, |
435 SF_PopupBackground, |
354 SF_SettingsList, |
436 SF_SettingsList, |
355 SF_TableItem, |
437 SF_TableItem, |
356 SF_TableHeaderItem, |
438 SF_TableHeaderItem, |
357 SF_ToolTip, |
439 SF_ToolTip, |
358 SF_ToolBar, |
440 SF_ToolBar, |
369 SF_PointWest = 0x0008, |
451 SF_PointWest = 0x0008, |
370 |
452 |
371 SF_StateEnabled = 0x0010, // Enabled = the default |
453 SF_StateEnabled = 0x0010, // Enabled = the default |
372 SF_StateDisabled = 0x0020, |
454 SF_StateDisabled = 0x0020, |
373 SF_ColorSkinned = 0x0040, // pixmap is colored with foreground pen color |
455 SF_ColorSkinned = 0x0040, // pixmap is colored with foreground pen color |
|
456 SF_Animation = 0x0080, |
374 }; |
457 }; |
375 |
458 |
376 enum CacheClearReason { |
459 enum CacheClearReason { |
377 CC_UndefinedChange = 0, |
460 CC_UndefinedChange = 0, |
378 CC_LayoutChange, |
461 CC_LayoutChange, |
399 static QColor lighterColor(const QColor &baseColor); |
482 static QColor lighterColor(const QColor &baseColor); |
400 //deduces if the given widget should have separately themeable background |
483 //deduces if the given widget should have separately themeable background |
401 static bool drawsOwnThemeBackground(const QWidget *widget); |
484 static bool drawsOwnThemeBackground(const QWidget *widget); |
402 |
485 |
403 QFont s60Font(QS60StyleEnums::FontCategories fontCategory, |
486 QFont s60Font(QS60StyleEnums::FontCategories fontCategory, |
404 int pointSize = -1) const; |
487 int pointSize = -1, bool resolveFontSize = true) const; |
405 // clears all style caches (fonts, colors, pixmaps) |
488 // clears all style caches (fonts, colors, pixmaps) |
406 void clearCaches(CacheClearReason reason = CC_UndefinedChange); |
489 void clearCaches(CacheClearReason reason = CC_UndefinedChange); |
407 |
490 |
408 // themed main background oprations |
491 // themed main background oprations |
409 void setBackgroundTexture(QApplication *application) const; |
492 void setBackgroundTexture(QApplication *application) const; |
410 static void deleteBackground(); |
493 static void deleteBackground(); |
411 |
494 |
412 static bool isTouchSupported(); |
495 static bool isTouchSupported(); |
413 static bool isToolBarBackground(); |
496 static bool isToolBarBackground(); |
414 static bool hasSliderGrooveGraphic(); |
497 static bool hasSliderGrooveGraphic(); |
|
498 static bool isSingleClickUi(); |
415 |
499 |
416 // calculates average color based on button skin graphics (minus borders). |
500 // calculates average color based on button skin graphics (minus borders). |
417 QColor colorFromFrameGraphics(SkinFrameElements frame) const; |
501 QColor colorFromFrameGraphics(SkinFrameElements frame) const; |
418 |
502 |
419 //set theme palette for application |
503 //set theme palette for application |
451 |
535 |
452 static QSize naviPaneSize(); |
536 static QSize naviPaneSize(); |
453 |
537 |
454 //Checks that the current brush is transparent or has BrushStyle NoBrush, |
538 //Checks that the current brush is transparent or has BrushStyle NoBrush, |
455 //so that theme graphic background can be drawn. |
539 //so that theme graphic background can be drawn. |
456 static bool canDrawThemeBackground(const QBrush &backgroundBrush); |
540 static bool canDrawThemeBackground(const QBrush &backgroundBrush, const QWidget *widget); |
|
541 |
|
542 static int currentAnimationFrame(QS60StyleEnums::SkinParts part); |
|
543 #ifdef Q_WS_S60 |
|
544 |
|
545 //No support for animations on emulated style |
|
546 void startAnimation(QS60StyleEnums::SkinParts animation); |
|
547 void stopAnimation(QS60StyleEnums::SkinParts animation); |
|
548 static QS60StyleAnimation* animationDefinition(QS60StyleEnums::SkinParts part); |
|
549 |
|
550 #endif |
457 |
551 |
458 private: |
552 private: |
459 static void drawPart(QS60StyleEnums::SkinParts part, QPainter *painter, |
553 static void drawPart(QS60StyleEnums::SkinParts part, QPainter *painter, |
460 const QRect &rect, SkinElementFlags flags = KDefaultSkinElementFlags); |
554 const QRect &rect, SkinElementFlags flags = KDefaultSkinElementFlags); |
461 static void drawRow(QS60StyleEnums::SkinParts start, QS60StyleEnums::SkinParts middle, |
555 static void drawRow(QS60StyleEnums::SkinParts start, QS60StyleEnums::SkinParts middle, |
482 static QSize partSize(QS60StyleEnums::SkinParts part, |
576 static QSize partSize(QS60StyleEnums::SkinParts part, |
483 SkinElementFlags flags = KDefaultSkinElementFlags); |
577 SkinElementFlags flags = KDefaultSkinElementFlags); |
484 static QPixmap part(QS60StyleEnums::SkinParts part, const QSize &size, |
578 static QPixmap part(QS60StyleEnums::SkinParts part, const QSize &size, |
485 QPainter *painter, SkinElementFlags flags = KDefaultSkinElementFlags); |
579 QPainter *painter, SkinElementFlags flags = KDefaultSkinElementFlags); |
486 |
580 |
487 static QFont s60Font_specific(QS60StyleEnums::FontCategories fontCategory, int pointSize); |
581 static QFont s60Font_specific(QS60StyleEnums::FontCategories fontCategory, |
|
582 int pointSize, bool resolveFontSize); |
488 |
583 |
489 static QSize screenSize(); |
584 static QSize screenSize(); |
490 |
585 |
491 // Contains background texture. |
586 // Contains background texture. |
492 static QPixmap *m_background; |
587 static QPixmap *m_background; |
494 // defined theme palette |
589 // defined theme palette |
495 static QPalette *m_themePalette; |
590 static QPalette *m_themePalette; |
496 QPalette m_originalPalette; |
591 QPalette m_originalPalette; |
497 |
592 |
498 QPointer<QFocusFrame> m_focusFrame; |
593 QPointer<QFocusFrame> m_focusFrame; |
|
594 static qint64 m_webPaletteKey; |
|
595 |
|
596 #ifdef Q_WS_S60 |
|
597 //list of progress bars having animation running |
|
598 QList<QProgressBar *> m_bars; |
|
599 #endif |
|
600 |
499 }; |
601 }; |
500 |
602 |
501 QT_END_NAMESPACE |
603 QT_END_NAMESPACE |
502 |
604 |
503 #endif // QS60STYLE_P_H |
605 #endif // QS60STYLE_P_H |