changeset 19 | fcece45ef507 |
parent 18 | 2f34d5167611 |
child 22 | 79de32ba3296 |
18:2f34d5167611 | 19:fcece45ef507 |
---|---|
48 #include "qpixmapcache.h" |
48 #include "qpixmapcache.h" |
49 |
49 |
50 #include "qcalendarwidget.h" |
50 #include "qcalendarwidget.h" |
51 #include "qdial.h" |
51 #include "qdial.h" |
52 #include "qdialog.h" |
52 #include "qdialog.h" |
53 #include "qmessagebox.h" |
|
53 #include "qgroupbox.h" |
54 #include "qgroupbox.h" |
54 #include "qheaderview.h" |
55 #include "qheaderview.h" |
55 #include "qlist.h" |
56 #include "qlist.h" |
56 #include "qlistwidget.h" |
57 #include "qlistwidget.h" |
57 #include "qlistview.h" |
58 #include "qlistview.h" |
59 #include "qmenubar.h" |
60 #include "qmenubar.h" |
60 #include "qpushbutton.h" |
61 #include "qpushbutton.h" |
61 #include "qscrollarea.h" |
62 #include "qscrollarea.h" |
62 #include "qscrollbar.h" |
63 #include "qscrollbar.h" |
63 #include "qtabbar.h" |
64 #include "qtabbar.h" |
64 #include "qtablewidget.h" |
|
65 #include "qtableview.h" |
65 #include "qtableview.h" |
66 #include "qtextedit.h" |
66 #include "qtextedit.h" |
67 #include "qtoolbar.h" |
67 #include "qtoolbar.h" |
68 #include "qtoolbutton.h" |
68 #include "qtoolbutton.h" |
69 #include "qfocusframe.h" |
69 #include "qfocusframe.h" |
90 |
90 |
91 static const qreal goldenRatio = 1.618; |
91 static const qreal goldenRatio = 1.618; |
92 |
92 |
93 const layoutHeader QS60StylePrivate::m_layoutHeaders[] = { |
93 const layoutHeader QS60StylePrivate::m_layoutHeaders[] = { |
94 // *** generated layout data *** |
94 // *** generated layout data *** |
95 {240,320,1,16,"QVGA Landscape"}, |
95 {240,320,1,17,"QVGA Landscape"}, |
96 {320,240,1,16,"QVGA Portrait"}, |
96 {320,240,1,17,"QVGA Portrait"}, |
97 {360,640,1,16,"NHD Landscape"}, |
97 {360,640,1,17,"NHD Landscape"}, |
98 {640,360,1,16,"NHD Portrait"}, |
98 {640,360,1,17,"NHD Portrait"}, |
99 {352,800,1,12,"E90 Landscape"} |
99 {352,800,1,12,"E90 Landscape"} |
100 // *** End of generated data *** |
100 // *** End of generated data *** |
101 }; |
101 }; |
102 const int QS60StylePrivate::m_numberOfLayouts = |
102 const int QS60StylePrivate::m_numberOfLayouts = |
103 (int)sizeof(QS60StylePrivate::m_layoutHeaders)/sizeof(QS60StylePrivate::m_layoutHeaders[0]); |
103 (int)sizeof(QS60StylePrivate::m_layoutHeaders)/sizeof(QS60StylePrivate::m_layoutHeaders[0]); |
104 |
104 |
105 const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = { |
105 const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = { |
106 // *** generated pixel metrics *** |
106 // *** generated pixel metrics *** |
107 {5,0,-909,0,0,2,0,0,-1,7,12,19,13,13,6,200,-909,-909,-909,20,13,2,0,0,21,7,18,-909,3,3,1,-909,-909,0,1,0,0,12,20,15,15,18,18,1,115,18,0,-909,-909,-909,-909,0,0,16,2,-909,0,0,-909,16,-909,-909,-909,-909,32,18,55,24,55,4,4,4,9,13,-909,5,51,11,5,0,3,3,6,8,3,3,-909,2,-909,-909,-909,-909,5,5,3,1}, |
107 {5,0,-909,0,0,2,0,0,-1,7,12,19,13,13,6,200,-909,-909,-909,20,13,2,0,0,21,7,18,0,3,3,1,-909,-909,0,1,0,0,12,20,15,15,18,18,1,115,18,0,-909,-909,-909,-909,0,0,16,2,-909,0,0,-909,16,-909,-909,-909,-909,32,18,55,24,55,4,4,4,9,13,-909,5,51,11,5,0,3,3,6,8,3,3,-909,2,-909,-909,-909,-909,5,5,3,1, 106}, |
108 {5,0,-909,0,0,1,0,0,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,-909,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,3,3,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,2,-909,-909,-909,-909,6,6,3,1}, |
108 {5,0,-909,0,0,1,0,0,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,0,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,3,3,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,2,-909,-909,-909,-909,6,6,3,1, 106}, |
109 {7,0,-909,0,0,2,0,0,-1,25,69,28,19,19,9,258,-909,-909,-909,23,19,26,0,0,32,25,72,-909,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,13,13,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1}, |
109 {7,0,-909,0,0,2,0,0,-1,25,69,28,19,19,9,258,-909,-909,-909,23,19,26,0,0,32,25,72,0,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,13,13,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1, 135}, |
110 {7,0,-909,0,0,2,0,0,-1,25,68,28,19,19,9,258,-909,-909,-909,31,19,6,0,0,32,25,60,-909,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,12,12,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1}, |
110 {7,0,-909,0,0,2,0,0,-1,25,68,28,19,19,9,258,-909,-909,-909,31,19,6,0,0,32,25,60,0,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,12,12,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1, 135}, |
111 {7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,-909,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1} |
111 {7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,0,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1, 106} |
112 // *** End of generated data *** |
112 // *** End of generated data *** |
113 }; |
113 }; |
114 |
114 |
115 const short *QS60StylePrivate::m_pmPointer = QS60StylePrivate::data[0]; |
115 const short *QS60StylePrivate::m_pmPointer = QS60StylePrivate::data[0]; |
116 |
116 |
125 const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameElementsData[] = { |
125 const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameElementsData[] = { |
126 {SE_ButtonNormal, QS60StyleEnums::SP_QsnFrButtonTbCenter}, |
126 {SE_ButtonNormal, QS60StyleEnums::SP_QsnFrButtonTbCenter}, |
127 {SE_ButtonPressed, QS60StyleEnums::SP_QsnFrButtonTbCenterPressed}, |
127 {SE_ButtonPressed, QS60StyleEnums::SP_QsnFrButtonTbCenterPressed}, |
128 {SE_FrameLineEdit, QS60StyleEnums::SP_QsnFrInputCenter}, |
128 {SE_FrameLineEdit, QS60StyleEnums::SP_QsnFrInputCenter}, |
129 {SE_ListHighlight, QS60StyleEnums::SP_QsnFrListCenter}, |
129 {SE_ListHighlight, QS60StyleEnums::SP_QsnFrListCenter}, |
130 {SE_OptionsMenu, QS60StyleEnums::SP_QsnFrPopupCenter}, |
130 {SE_PopupBackground, QS60StyleEnums::SP_QsnFrPopupCenter}, |
131 {SE_SettingsList, QS60StyleEnums::SP_QsnFrSetOptCenter}, |
131 {SE_SettingsList, QS60StyleEnums::SP_QsnFrSetOptCenter}, |
132 {SE_TableItem, QS60StyleEnums::SP_QsnFrCaleCenter}, |
132 {SE_TableItem, QS60StyleEnums::SP_QsnFrCaleCenter}, |
133 {SE_TableHeaderItem, QS60StyleEnums::SP_QsnFrCaleHeadingCenter}, |
133 {SE_TableHeaderItem, QS60StyleEnums::SP_QsnFrCaleHeadingCenter}, |
134 {SE_ToolTip, QS60StyleEnums::SP_QsnFrPopupPreviewCenter}, |
134 {SE_ToolTip, QS60StyleEnums::SP_QsnFrPopupPreviewCenter}, |
135 {SE_ToolBar, QS60StyleEnums::SP_QsnFrPopupSubCenter}, |
135 {SE_ToolBar, QS60StyleEnums::SP_QsnFrPopupSubCenter}, |
248 QS60StyleEnums::SP_QgnGrafTabPassiveL, Qt::Vertical, painter, rect, flags | SF_PointWest); |
248 QS60StyleEnums::SP_QgnGrafTabPassiveL, Qt::Vertical, painter, rect, flags | SF_PointWest); |
249 break; |
249 break; |
250 case SE_ListHighlight: |
250 case SE_ListHighlight: |
251 drawFrame(SF_ListHighlight, painter, rect, flags | SF_PointNorth); |
251 drawFrame(SF_ListHighlight, painter, rect, flags | SF_PointNorth); |
252 break; |
252 break; |
253 case SE_OptionsMenu: |
253 case SE_PopupBackground: |
254 drawFrame(SF_OptionsMenu, painter, rect, flags | SF_PointNorth); |
254 drawFrame(SF_PopupBackground, painter, rect, flags | SF_PointNorth); |
255 break; |
255 break; |
256 case SE_SettingsList: |
256 case SE_SettingsList: |
257 drawFrame(SF_SettingsList, painter, rect, flags | SF_PointNorth); |
257 drawFrame(SF_SettingsList, painter, rect, flags | SF_PointNorth); |
258 break; |
258 break; |
259 case SE_TableItem: |
259 case SE_TableItem: |
305 drawPart(part, painter, rect, flags); |
305 drawPart(part, painter, rect, flags); |
306 } |
306 } |
307 |
307 |
308 short QS60StylePrivate::pixelMetric(int metric) |
308 short QS60StylePrivate::pixelMetric(int metric) |
309 { |
309 { |
310 //If it is a custom value, need to strip away the base to map to internal |
|
311 //pixel metric value table |
|
312 if (metric & QStyle::PM_CustomBase) { |
|
313 metric -= QStyle::PM_CustomBase; |
|
314 metric += MAX_NON_CUSTOM_PIXELMETRICS - 1; |
|
315 } |
|
316 |
|
310 Q_ASSERT(metric < MAX_PIXELMETRICS); |
317 Q_ASSERT(metric < MAX_PIXELMETRICS); |
311 const short returnValue = m_pmPointer[metric]; |
318 const short returnValue = m_pmPointer[metric]; |
312 return returnValue; |
319 return returnValue; |
313 } |
320 } |
314 |
321 |
405 // Returns Qt::black if there is an issue with the graphics (image is NULL, or no bits() found). |
412 // Returns Qt::black if there is an issue with the graphics (image is NULL, or no bits() found). |
406 QColor QS60StylePrivate::colorFromFrameGraphics(SkinFrameElements frame) const |
413 QColor QS60StylePrivate::colorFromFrameGraphics(SkinFrameElements frame) const |
407 { |
414 { |
408 const bool cachedColorExists = m_colorCache.contains(frame); |
415 const bool cachedColorExists = m_colorCache.contains(frame); |
409 if (!cachedColorExists) { |
416 if (!cachedColorExists) { |
410 const int frameCornerWidth = pixelMetric(PM_Custom_FrameCornerWidth); |
417 const int frameCornerWidth = pixelMetric(PM_FrameCornerWidth); |
411 const int frameCornerHeight = pixelMetric(PM_Custom_FrameCornerHeight); |
418 const int frameCornerHeight = pixelMetric(PM_FrameCornerHeight); |
412 Q_ASSERT(2 * frameCornerWidth < 32); |
419 Q_ASSERT(2 * frameCornerWidth < 32); |
413 Q_ASSERT(2 * frameCornerHeight < 32); |
420 Q_ASSERT(2 * frameCornerHeight < 32); |
414 |
421 |
415 const QImage frameImage = QS60StylePrivate::frame(frame, QSize(32, 32)).toImage(); |
422 const QImage frameImage = QS60StylePrivate::frame(frame, QSize(32, 32)).toImage(); |
416 Q_ASSERT(frameImage.bytesPerLine() > 0); |
423 Q_ASSERT(frameImage.bytesPerLine() > 0); |
628 fontCategory = QS60StyleEnums::FC_Primary; |
635 fontCategory = QS60StyleEnums::FC_Primary; |
629 } else if (qobject_cast<QHeaderView *>(widget)){ |
636 } else if (qobject_cast<QHeaderView *>(widget)){ |
630 fontCategory = QS60StyleEnums::FC_Secondary; |
637 fontCategory = QS60StyleEnums::FC_Secondary; |
631 } else if (qobject_cast<QGroupBox *>(widget)){ |
638 } else if (qobject_cast<QGroupBox *>(widget)){ |
632 fontCategory = QS60StyleEnums::FC_Title; |
639 fontCategory = QS60StyleEnums::FC_Title; |
640 } else if (qobject_cast<QMessageBox *>(widget)){ |
|
641 fontCategory = QS60StyleEnums::FC_Primary; |
|
633 } |
642 } |
634 if (fontCategory != QS60StyleEnums::FC_Undefined) { |
643 if (fontCategory != QS60StyleEnums::FC_Undefined) { |
635 const bool resolveFontSize = widget->testAttribute(Qt::WA_SetFont) |
644 const bool resolveFontSize = widget->testAttribute(Qt::WA_SetFont) |
636 && (widget->font().resolve() & QFont::SizeResolved); |
645 && (widget->font().resolve() & QFont::SizeResolved); |
637 const QFont suggestedFont = |
646 const QFont suggestedFont = |
757 widgetPalette.setColor(QPalette::ButtonText, |
766 widgetPalette.setColor(QPalette::ButtonText, |
758 s60Color(QS60StyleEnums::CL_QsnTextColors, 8, 0)); |
767 s60Color(QS60StyleEnums::CL_QsnTextColors, 8, 0)); |
759 QApplication::setPalette(widgetPalette, "QMenuBar"); |
768 QApplication::setPalette(widgetPalette, "QMenuBar"); |
760 widgetPalette = *palette; |
769 widgetPalette = *palette; |
761 |
770 |
771 widgetPalette.setColor(QPalette::Text, |
|
772 s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0)); |
|
773 widgetPalette.setColor(QPalette::HighlightedText, |
|
774 s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0)); |
|
775 QApplication::setPalette(widgetPalette, "QMenu"); |
|
776 widgetPalette = *palette; |
|
777 |
|
762 widgetPalette.setColor(QPalette::WindowText, |
778 widgetPalette.setColor(QPalette::WindowText, |
763 s60Color(QS60StyleEnums::CL_QsnTextColors, 4, 0)); |
779 s60Color(QS60StyleEnums::CL_QsnTextColors, 4, 0)); |
780 widgetPalette.setColor(QPalette::HighlightedText, |
|
781 s60Color(QS60StyleEnums::CL_QsnTextColors, 3, 0)); |
|
764 QApplication::setPalette(widgetPalette, "QTabBar"); |
782 QApplication::setPalette(widgetPalette, "QTabBar"); |
765 widgetPalette = *palette; |
783 widgetPalette = *palette; |
766 |
784 |
785 widgetPalette.setColor(QPalette::HighlightedText, |
|
786 s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0)); |
|
787 QApplication::setPalette(widgetPalette, "QListView"); |
|
788 widgetPalette = *palette; |
|
789 |
|
767 widgetPalette.setColor(QPalette::Text, |
790 widgetPalette.setColor(QPalette::Text, |
768 s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0)); |
791 s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0)); |
792 widgetPalette.setColor(QPalette::HighlightedText, |
|
793 s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0)); |
|
769 QApplication::setPalette(widgetPalette, "QTableView"); |
794 QApplication::setPalette(widgetPalette, "QTableView"); |
770 widgetPalette = *palette; |
795 widgetPalette = *palette; |
771 |
796 |
772 widgetPalette.setColor(QPalette::Text, |
797 widgetPalette.setColor(QPalette::Text, |
773 s60Color(QS60StyleEnums::CL_QsnTextColors, 27, 0)); |
798 s60Color(QS60StyleEnums::CL_QsnTextColors, 27, 0)); |
787 s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); |
812 s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); |
788 QApplication::setPalette(widgetPalette, "QComboBox"); |
813 QApplication::setPalette(widgetPalette, "QComboBox"); |
789 widgetPalette = *palette; |
814 widgetPalette = *palette; |
790 |
815 |
791 widgetPalette.setColor(QPalette::WindowText, s60Color(QS60StyleEnums::CL_QsnTextColors, 7, 0)); |
816 widgetPalette.setColor(QPalette::WindowText, s60Color(QS60StyleEnums::CL_QsnTextColors, 7, 0)); |
817 widgetPalette.setColor(QPalette::HighlightedText, |
|
818 s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0)); |
|
792 QApplication::setPalette(widgetPalette, "QRadioButton"); |
819 QApplication::setPalette(widgetPalette, "QRadioButton"); |
793 QApplication::setPalette(widgetPalette, "QCheckBox"); |
820 QApplication::setPalette(widgetPalette, "QCheckBox"); |
794 widgetPalette = *palette; |
821 widgetPalette = *palette; |
795 |
822 |
796 widgetPalette.setColor(QPalette::WindowText, mainAreaTextColor); |
823 widgetPalette.setColor(QPalette::WindowText, mainAreaTextColor); |
848 pixelMetric(QStyle::PM_SliderControlThickness), Qt::IgnoreAspectRatio); |
875 pixelMetric(QStyle::PM_SliderControlThickness), Qt::IgnoreAspectRatio); |
849 break; |
876 break; |
850 |
877 |
851 case QS60StyleEnums::SP_QgnGrafBarFrameSideL: |
878 case QS60StyleEnums::SP_QgnGrafBarFrameSideL: |
852 case QS60StyleEnums::SP_QgnGrafBarFrameSideR: |
879 case QS60StyleEnums::SP_QgnGrafBarFrameSideR: |
853 result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth)); |
880 result.setWidth(pixelMetric(PM_FrameCornerWidth)); |
854 break; |
881 break; |
855 |
882 |
856 case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed: |
883 case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed: |
857 case QS60StyleEnums::SP_QsnCpScrollBgBottom: |
884 case QS60StyleEnums::SP_QsnCpScrollBgBottom: |
858 case QS60StyleEnums::SP_QsnCpScrollBgTop: |
885 case QS60StyleEnums::SP_QsnCpScrollBgTop: |
875 switch (m_frameElementsData[i].center - part) { |
902 switch (m_frameElementsData[i].center - part) { |
876 case 8: /* CornerTl */ |
903 case 8: /* CornerTl */ |
877 case 7: /* CornerTr */ |
904 case 7: /* CornerTr */ |
878 case 6: /* CornerBl */ |
905 case 6: /* CornerBl */ |
879 case 5: /* CornerBr */ |
906 case 5: /* CornerBr */ |
880 result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth)); |
907 result.setWidth(pixelMetric(PM_FrameCornerWidth)); |
881 // Falltrough intended... |
908 // Falltrough intended... |
882 case 4: /* SideT */ |
909 case 4: /* SideT */ |
883 case 3: /* SideB */ |
910 case 3: /* SideB */ |
884 result.setHeight(pixelMetric(PM_Custom_FrameCornerHeight)); |
911 result.setHeight(pixelMetric(PM_FrameCornerHeight)); |
885 break; |
912 break; |
886 case 2: /* SideL */ |
913 case 2: /* SideL */ |
887 case 1: /* SideR */ |
914 case 1: /* SideR */ |
888 result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth)); |
915 result.setWidth(pixelMetric(PM_FrameCornerWidth)); |
889 break; |
916 break; |
890 case 0: /* center */ |
917 case 0: /* center */ |
891 default: |
918 default: |
892 break; |
919 break; |
893 } |
920 } |
982 const QS60StylePrivate::SkinElements grooveElement = horizontal ? |
1009 const QS60StylePrivate::SkinElements grooveElement = horizontal ? |
983 QS60StylePrivate::SE_SliderGrooveHorizontal : |
1010 QS60StylePrivate::SE_SliderGrooveHorizontal : |
984 QS60StylePrivate::SE_SliderGrooveVertical; |
1011 QS60StylePrivate::SE_SliderGrooveVertical; |
985 QS60StylePrivate::drawSkinElement(grooveElement, painter, sliderGroove, flags); |
1012 QS60StylePrivate::drawSkinElement(grooveElement, painter, sliderGroove, flags); |
986 } else { |
1013 } else { |
987 const QRect sliderGroove = subControlRect(control, optionSlider, SC_SliderGroove, widget); |
|
988 const QPoint sliderGrooveCenter = sliderGroove.center(); |
1014 const QPoint sliderGrooveCenter = sliderGroove.center(); |
989 const bool horizontal = optionSlider->orientation == Qt::Horizontal; |
1015 const bool horizontal = optionSlider->orientation == Qt::Horizontal; |
990 painter->save(); |
1016 painter->save(); |
991 if (widget) |
1017 if (widget) |
992 painter->setPen(widget->palette().windowText().color()); |
1018 painter->setPen(widget->palette().windowText().color()); |
1109 break; } |
1135 break; } |
1110 toolButton.rect = button; |
1136 toolButton.rect = button; |
1111 drawPrimitive(pe, &toolButton, painter, widget); |
1137 drawPrimitive(pe, &toolButton, painter, widget); |
1112 } |
1138 } |
1113 |
1139 |
1114 if (toolBtn->text.length()>0 || |
1140 if (toolBtn->text.length() > 0 || |
1115 !toolBtn->icon.isNull()) { |
1141 !toolBtn->icon.isNull()) { |
1116 const int frameWidth = pixelMetric(PM_DefaultFrameWidth, option, widget); |
1142 const int frameWidth = pixelMetric(PM_DefaultFrameWidth, option, widget); |
1117 toolButton.rect = button.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth); |
1143 toolButton.rect = button.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth); |
1118 drawControl(CE_ToolButtonLabel, &toolButton, painter, widget); |
1144 drawControl(CE_ToolButtonLabel, &toolButton, painter, widget); |
1119 } |
1145 } |
1239 switch (element) { |
1265 switch (element) { |
1240 case CE_CheckBox: |
1266 case CE_CheckBox: |
1241 case CE_RadioButton: |
1267 case CE_RadioButton: |
1242 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
1268 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
1243 bool isRadio = (element == CE_RadioButton); |
1269 bool isRadio = (element == CE_RadioButton); |
1270 QStyleOptionButton subopt = *btn; |
|
1271 |
|
1244 // Highlight needs to be drawn first, as it goes "underneath" the text and indicator. |
1272 // Highlight needs to be drawn first, as it goes "underneath" the text and indicator. |
1245 if (btn->state & State_HasFocus) { |
1273 if (btn->state & State_HasFocus) { |
1246 QStyleOptionFocusRect fropt; |
1274 QStyleOptionFocusRect fropt; |
1247 fropt.QStyleOption::operator=(*btn); |
1275 fropt.QStyleOption::operator=(*btn); |
1248 fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect |
1276 fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect |
1249 : SE_CheckBoxFocusRect, btn, widget); |
1277 : SE_CheckBoxFocusRect, btn, widget); |
1250 drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); |
1278 drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); |
1279 |
|
1280 subopt.palette.setColor(QPalette::Active, QPalette::WindowText, |
|
1281 subopt.palette.highlightedText().color()); |
|
1251 } |
1282 } |
1252 QStyleOptionButton subopt = *btn; |
|
1253 |
1283 |
1254 subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator |
1284 subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator |
1255 : SE_CheckBoxIndicator, btn, widget); |
1285 : SE_CheckBoxIndicator, btn, widget); |
1256 drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, |
1286 drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, |
1257 &subopt, painter, widget); |
1287 &subopt, painter, widget); |
1347 else |
1377 else |
1348 editRect.translate(comboBox->iconSize.width() + 4, 0); |
1378 editRect.translate(comboBox->iconSize.width() + 4, 0); |
1349 } |
1379 } |
1350 if (!comboBox->currentText.isEmpty() && !comboBox->editable) { |
1380 if (!comboBox->currentText.isEmpty() && !comboBox->editable) { |
1351 QCommonStyle::drawItemText(painter, |
1381 QCommonStyle::drawItemText(painter, |
1352 editRect.adjusted(QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth), 0, -1, 0), |
1382 editRect.adjusted(QS60StylePrivate::pixelMetric(PM_FrameCornerWidth), 0, -1, 0), |
1353 visualAlignment(comboBox->direction, Qt::AlignLeft | Qt::AlignVCenter), |
1383 visualAlignment(comboBox->direction, Qt::AlignLeft | Qt::AlignVCenter), |
1354 comboBox->palette, comboBox->state & State_Enabled, comboBox->currentText); |
1384 comboBox->palette, comboBox->state & State_Enabled, comboBox->currentText); |
1355 } |
1385 } |
1356 painter->restore(); |
1386 painter->restore(); |
1357 } |
1387 } |
1406 drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget); |
1436 drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget); |
1407 } |
1437 } |
1408 } else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget);} |
1438 } else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget);} |
1409 |
1439 |
1410 // draw the focus rect |
1440 // draw the focus rect |
1411 if (isSelected | hasFocus) { |
1441 if (isSelected || hasFocus ) { |
1412 QRect highlightRect = option->rect.adjusted(1,1,-1,-1); |
1442 QRect highlightRect = option->rect.adjusted(1,1,-1,-1); |
1413 QAbstractItemView::SelectionBehavior selectionBehavior = |
1443 QAbstractItemView::SelectionBehavior selectionBehavior = |
1414 itemView ? itemView->selectionBehavior() : QAbstractItemView::SelectItems; |
1444 itemView ? itemView->selectionBehavior() : QAbstractItemView::SelectItems; |
1415 if (selectionBehavior != QAbstractItemView::SelectItems) { |
1445 if (selectionBehavior != QAbstractItemView::SelectItems) { |
1416 // set highlight rect so that it is continuous from cell to cell, yet sligthly |
1446 // set highlight rect so that it is continuous from cell to cell, yet sligthly |
1478 } |
1508 } |
1479 } |
1509 } |
1480 |
1510 |
1481 // draw the text |
1511 // draw the text |
1482 if (!voptAdj.text.isEmpty()) { |
1512 if (!voptAdj.text.isEmpty()) { |
1483 if (isSelected) { |
1513 if (isSelected || hasFocus ) |
1484 if (qobject_cast<const QTableView *>(widget)) |
1514 painter->setPen(voptAdj.palette.highlightedText().color()); |
1485 voptAdj.palette.setColor( |
1515 else |
1486 QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0)); |
1516 painter->setPen(voptAdj.palette.text().color()); |
1487 else |
|
1488 voptAdj.palette.setColor( |
|
1489 QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0)); |
|
1490 } |
|
1491 painter->setPen(voptAdj.palette.text().color()); |
|
1492 d->viewItemDrawText(painter, &voptAdj, textRect); |
1517 d->viewItemDrawText(painter, &voptAdj, textRect); |
1493 } |
1518 } |
1494 painter->restore(); |
1519 painter->restore(); |
1495 } |
1520 } |
1496 break; |
1521 break; |
1588 painter->setFont(f); |
1613 painter->setFont(f); |
1589 |
1614 |
1590 const bool selected = optionTab.state & State_Selected; |
1615 const bool selected = optionTab.state & State_Selected; |
1591 if (selected) |
1616 if (selected) |
1592 optionTab.palette.setColor(QPalette::Active, QPalette::WindowText, |
1617 optionTab.palette.setColor(QPalette::Active, QPalette::WindowText, |
1593 QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 3, option)); |
1618 optionTab.palette.highlightedText().color()); |
1594 |
1619 |
1595 const bool verticalTabs = optionTab.shape == QTabBar::RoundedEast |
1620 const bool verticalTabs = optionTab.shape == QTabBar::RoundedEast |
1596 || optionTab.shape == QTabBar::RoundedWest |
1621 || optionTab.shape == QTabBar::RoundedWest |
1597 || optionTab.shape == QTabBar::TriangularEast |
1622 || optionTab.shape == QTabBar::TriangularEast |
1598 || optionTab.shape == QTabBar::TriangularWest; |
1623 || optionTab.shape == QTabBar::TriangularWest; |
1721 uint text_flags = Qt::AlignLeading | Qt::TextShowMnemonic | Qt::TextDontClip |
1746 uint text_flags = Qt::AlignLeading | Qt::TextShowMnemonic | Qt::TextDontClip |
1722 | Qt::TextSingleLine | Qt::AlignVCenter; |
1747 | Qt::TextSingleLine | Qt::AlignVCenter; |
1723 if (!styleHint(SH_UnderlineShortcut, menuItem, widget)) |
1748 if (!styleHint(SH_UnderlineShortcut, menuItem, widget)) |
1724 text_flags |= Qt::TextHideMnemonic; |
1749 text_flags |= Qt::TextHideMnemonic; |
1725 |
1750 |
1726 if ((option->state & State_Selected) && (option->state & State_Enabled)) |
1751 const bool selected = (option->state & State_Selected) && (option->state & State_Enabled); |
1752 if (selected) |
|
1727 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); |
1753 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); |
1728 |
1754 |
1729 QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget); |
1755 QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget); |
1730 QRect textRect = subElementRect(SE_ItemViewItemText, &optionMenuItem, widget); |
1756 QRect textRect = subElementRect(SE_ItemViewItemText, &optionMenuItem, widget); |
1731 |
1757 |
1791 optionMenuItem.palette.setColor(QPalette::Disabled, QPalette::Text, QS60StylePrivate::lighterColor( |
1817 optionMenuItem.palette.setColor(QPalette::Disabled, QPalette::Text, QS60StylePrivate::lighterColor( |
1792 optionMenuItem.palette.color(QPalette::Disabled, QPalette::Text))); |
1818 optionMenuItem.palette.color(QPalette::Disabled, QPalette::Text))); |
1793 painter->save(); |
1819 painter->save(); |
1794 painter->setOpacity(0.5); |
1820 painter->setOpacity(0.5); |
1795 } |
1821 } |
1822 if (selected) |
|
1823 optionMenuItem.palette.setColor( |
|
1824 QPalette::Active, QPalette::Text, optionMenuItem.palette.highlightedText().color()); |
|
1825 |
|
1796 QCommonStyle::drawItemText(painter, textRect, text_flags, |
1826 QCommonStyle::drawItemText(painter, textRect, text_flags, |
1797 optionMenuItem.palette, enabled, |
1827 optionMenuItem.palette, enabled, |
1798 optionMenuItem.text, QPalette::Text); |
1828 optionMenuItem.text, QPalette::Text); |
1799 if (!enabled) |
1829 if (!enabled) |
1800 painter->restore(); |
1830 painter->restore(); |
1812 case CE_HeaderSection: |
1842 case CE_HeaderSection: |
1813 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { |
1843 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { |
1814 painter->save(); |
1844 painter->save(); |
1815 QPen linePen = QPen(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 1, header)); |
1845 QPen linePen = QPen(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 1, header)); |
1816 const int penWidth = (header->orientation == Qt::Horizontal) ? |
1846 const int penWidth = (header->orientation == Qt::Horizontal) ? |
1817 linePen.width() + QS60StylePrivate::pixelMetric(PM_Custom_BoldLineWidth) |
1847 linePen.width() + QS60StylePrivate::pixelMetric(PM_BoldLineWidth) |
1818 : linePen.width() + QS60StylePrivate::pixelMetric(PM_Custom_ThinLineWidth); |
1848 : linePen.width() + QS60StylePrivate::pixelMetric(PM_ThinLineWidth); |
1819 linePen.setWidth(penWidth); |
1849 linePen.setWidth(penWidth); |
1820 painter->setPen(linePen); |
1850 painter->setPen(linePen); |
1821 if (header->orientation == Qt::Horizontal){ |
1851 if (header->orientation == Qt::Horizontal){ |
1822 painter->drawLine(header->rect.bottomLeft(), header->rect.bottomRight()); |
1852 painter->drawLine(header->rect.bottomLeft(), header->rect.bottomRight()); |
1823 } else { |
1853 } else { |
1832 //Draw corner button as normal pushButton. |
1862 //Draw corner button as normal pushButton. |
1833 if (qobject_cast<const QAbstractButton *>(widget)) { |
1863 if (qobject_cast<const QAbstractButton *>(widget)) { |
1834 //Make cornerButton slightly smaller so that it is not on top of table border graphic. |
1864 //Make cornerButton slightly smaller so that it is not on top of table border graphic. |
1835 QStyleOptionHeader subopt = *header; |
1865 QStyleOptionHeader subopt = *header; |
1836 const int borderTweak = |
1866 const int borderTweak = |
1837 QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1; |
1867 QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) >> 1; |
1838 if (subopt.direction == Qt::LeftToRight) |
1868 if (subopt.direction == Qt::LeftToRight) |
1839 subopt.rect.adjust(borderTweak, borderTweak, 0, -borderTweak); |
1869 subopt.rect.adjust(borderTweak, borderTweak, 0, -borderTweak); |
1840 else |
1870 else |
1841 subopt.rect.adjust(0, borderTweak, -borderTweak, -borderTweak); |
1871 subopt.rect.adjust(0, borderTweak, -borderTweak, -borderTweak); |
1842 drawPrimitive(PE_PanelButtonBevel, &subopt, painter, widget); |
1872 drawPrimitive(PE_PanelButtonBevel, &subopt, painter, widget); |
1940 } |
1970 } |
1941 break; |
1971 break; |
1942 case CE_MenuScroller: |
1972 case CE_MenuScroller: |
1943 break; |
1973 break; |
1944 case CE_FocusFrame: { |
1974 case CE_FocusFrame: { |
1945 // The pen width should nearly fill the layoutspacings around the widget |
|
1946 const int penWidth = |
|
1947 qMin(pixelMetric(QS60Style::PM_LayoutVerticalSpacing), pixelMetric(QS60Style::PM_LayoutHorizontalSpacing)) |
|
1948 - 2; // But keep 1 pixel distance to the focus widget and 1 pixel to the adjacent widgets |
|
1949 |
|
1950 #ifdef QT_KEYPAD_NAVIGATION |
1975 #ifdef QT_KEYPAD_NAVIGATION |
1951 bool editFocus = false; |
1976 bool editFocus = false; |
1952 if (const QFocusFrame *focusFrame = qobject_cast<const QFocusFrame*>(widget)) { |
1977 if (const QFocusFrame *focusFrame = qobject_cast<const QFocusFrame*>(widget)) { |
1953 if (focusFrame->widget() && focusFrame->widget()->hasEditFocus()) |
1978 if (focusFrame->widget() && focusFrame->widget()->hasEditFocus()) |
1954 editFocus = true; |
1979 editFocus = true; |
1955 } |
1980 } |
1956 const qreal opacity = editFocus ? 0.65 : 0.45; // Trial and error factors. Feel free to improve. |
1981 const qreal opacity = editFocus ? 1 : 0.75; // Trial and error factors. Feel free to improve. |
1957 #else |
1982 #else |
1958 const qreal opacity = 0.5; |
1983 const qreal opacity = 0.85; |
1959 #endif |
1984 #endif |
1960 // Because of Qts coordinate system, we need to tweak the rect by .5 pixels, otherwise it gets blurred. |
1985 // We need to reduce the focus frame size if LayoutSpacing is smaller than FocusFrameMargin |
1961 const qreal rectAdjustment = (penWidth % 2) ? -.5 : 0; |
1986 // Otherwise, we would overlay adjacent widgets. |
1962 |
1987 const int frameHeightReduction = |
1963 // Make sure that the pen stroke is inside the rect |
1988 qMin(0, pixelMetric(QStyle::PM_LayoutVerticalSpacing) |
1964 const QRectF adjustedRect = |
1989 - pixelMetric(QStyle::PM_FocusFrameVMargin)); |
1965 QRectF(option->rect).adjusted( |
1990 const int frameWidthReduction = |
1966 rectAdjustment + penWidth, |
1991 qMin(0, pixelMetric(QStyle::PM_LayoutHorizontalSpacing) |
1967 rectAdjustment + penWidth, |
1992 - pixelMetric(QStyle::PM_FocusFrameHMargin)); |
1968 -rectAdjustment - penWidth, |
1993 const int rounding = |
1969 -rectAdjustment - penWidth |
1994 qMin(pixelMetric(QStyle::PM_FocusFrameVMargin), |
1970 ); |
1995 pixelMetric(QStyle::PM_LayoutVerticalSpacing)); |
1971 |
1996 const QRect frameRect = |
1972 const qreal roundRectRadius = penWidth * goldenRatio; |
1997 option->rect.adjusted(-frameWidthReduction, -frameHeightReduction, |
1998 frameWidthReduction, frameHeightReduction); |
|
1999 QPainterPath framePath; |
|
2000 framePath.addRoundedRect(frameRect, rounding, rounding); |
|
1973 |
2001 |
1974 painter->save(); |
2002 painter->save(); |
1975 painter->setRenderHint(QPainter::Antialiasing); |
2003 painter->setRenderHint(QPainter::Antialiasing); |
1976 painter->setOpacity(opacity); |
2004 painter->setOpacity(opacity); |
1977 painter->setPen(QPen(option->palette.color(QPalette::Text), penWidth)); |
2005 painter->fillPath(framePath, option->palette.color(QPalette::Text)); |
1978 painter->drawRoundedRect(adjustedRect, roundRectRadius, roundRectRadius); |
|
1979 painter->restore(); |
2006 painter->restore(); |
1980 } |
2007 } |
1981 break; |
2008 break; |
1982 case CE_Splitter: |
2009 case CE_Splitter: |
1983 if (option->state & State_Sunken && option->state & State_Enabled) { |
2010 if (option->state & State_Sunken && option->state & State_Enabled) { |
2045 painter->restore(); |
2072 painter->restore(); |
2046 } |
2073 } |
2047 break; |
2074 break; |
2048 case PE_IndicatorViewItemCheck: |
2075 case PE_IndicatorViewItemCheck: |
2049 #ifndef QT_NO_ITEMVIEWS |
2076 #ifndef QT_NO_ITEMVIEWS |
2050 if (const QListView *listItem = (qobject_cast<const QListView *>(widget))) { |
2077 if (const QAbstractItemView *itemView = (qobject_cast<const QAbstractItemView *>(widget))) { |
2051 if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
2078 if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
2052 const bool checkBoxVisible = vopt->features & QStyleOptionViewItemV2::HasCheckIndicator; |
2079 const bool checkBoxVisible = vopt->features & QStyleOptionViewItemV2::HasCheckIndicator; |
2053 const bool singleSelection = listItem->selectionMode() == |
2080 const bool singleSelection = itemView->selectionMode() == |
2054 QAbstractItemView::SingleSelection || listItem->selectionMode() == QAbstractItemView::NoSelection; |
2081 QAbstractItemView::SingleSelection || itemView->selectionMode() == QAbstractItemView::NoSelection; |
2055 // draw either checkbox at the beginning |
2082 // draw either checkbox at the beginning |
2056 if (checkBoxVisible && singleSelection) { |
2083 if (checkBoxVisible && singleSelection) { |
2057 drawPrimitive(PE_IndicatorCheckBox, option, painter, widget); |
2084 drawPrimitive(PE_IndicatorCheckBox, option, painter, widget); |
2058 // ... or normal "tick" selection at the end. |
2085 // ... or normal "tick" selection at the end. |
2059 } else if (option->state & State_Selected) { |
2086 } else if (option->state & State_Selected) { |
2060 QRect tickRect = option->rect; |
2087 QRect tickRect = option->rect; |
2061 const int frameBorderWidth = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth); |
2088 const int frameBorderWidth = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth); |
2062 // adjust tickmark rect to exclude frame border |
2089 // adjust tickmark rect to exclude frame border |
2063 tickRect.adjust(0, -frameBorderWidth, 0, -frameBorderWidth); |
2090 tickRect.adjust(0, -frameBorderWidth, 0, -frameBorderWidth); |
2064 QS60StyleEnums::SkinParts skinPart = QS60StyleEnums::SP_QgnIndiMarkedAdd; |
2091 QS60StyleEnums::SkinParts skinPart = QS60StyleEnums::SP_QgnIndiMarkedAdd; |
2065 QS60StylePrivate::drawSkinPart(skinPart, painter, tickRect, |
2092 QS60StylePrivate::drawSkinPart(skinPart, painter, tickRect, |
2066 (flags | QS60StylePrivate::SF_ColorSkinned)); |
2093 (flags | QS60StylePrivate::SF_ColorSkinned)); |
2137 if (QS60StylePrivate::canDrawThemeBackground(spinBox->palette.base(), widget)) { |
2164 if (QS60StylePrivate::canDrawThemeBackground(spinBox->palette.base(), widget)) { |
2138 QStyleOptionSpinBox optionSpinBox = *spinBox; |
2165 QStyleOptionSpinBox optionSpinBox = *spinBox; |
2139 const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ? |
2166 const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ? |
2140 QS60StyleEnums::SP_QgnGrafScrollArrowUp : |
2167 QS60StyleEnums::SP_QgnGrafScrollArrowUp : |
2141 QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
2168 QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
2142 const int iconMargin = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1; |
2169 const int iconMargin = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) >> 1; |
2143 optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin ); |
2170 optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin ); |
2144 QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect, flags); |
2171 QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect, flags); |
2145 } else { |
2172 } else { |
2146 commonStyleDraws = true; |
2173 commonStyleDraws = true; |
2147 } |
2174 } |
2151 if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
2178 if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
2152 if (QS60StylePrivate::canDrawThemeBackground( option->palette.base(), widget)) { |
2179 if (QS60StylePrivate::canDrawThemeBackground( option->palette.base(), widget)) { |
2153 // We want to draw down arrow here for comboboxes as well. |
2180 // We want to draw down arrow here for comboboxes as well. |
2154 QStyleOptionFrame optionsComboBox = *cmb; |
2181 QStyleOptionFrame optionsComboBox = *cmb; |
2155 const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
2182 const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
2156 const int iconMargin = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1; |
2183 const int iconMargin = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) >> 1; |
2157 optionsComboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin ); |
2184 optionsComboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin ); |
2158 QS60StylePrivate::drawSkinPart(part, painter, optionsComboBox.rect, flags); |
2185 QS60StylePrivate::drawSkinPart(part, painter, optionsComboBox.rect, flags); |
2159 } else { |
2186 } else { |
2160 commonStyleDraws = true; |
2187 commonStyleDraws = true; |
2161 } |
2188 } |
2189 ) { |
2216 ) { |
2190 //Need extra check since dialogs have their own theme background |
2217 //Need extra check since dialogs have their own theme background |
2191 if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget) && |
2218 if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget) && |
2192 option->palette.window().texture().cacheKey() == |
2219 option->palette.window().texture().cacheKey() == |
2193 QS60StylePrivate::m_themePalette->window().texture().cacheKey()) |
2220 QS60StylePrivate::m_themePalette->window().texture().cacheKey()) |
2194 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_OptionsMenu, painter, option->rect, flags); |
2221 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_PopupBackground, painter, option->rect, flags); |
2195 else |
2222 else |
2196 commonStyleDraws = true; |
2223 commonStyleDraws = true; |
2197 } |
2224 } |
2198 break; |
2225 break; |
2199 case PE_FrameWindow: |
2226 case PE_FrameWindow: |
2285 if (option->state & State_Children) { |
2312 if (option->state & State_Children) { |
2286 QS60StyleEnums::SkinParts skinPart = |
2313 QS60StyleEnums::SkinParts skinPart = |
2287 (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper; |
2314 (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper; |
2288 int minDimension = qMin(option->rect.width(), option->rect.height()); |
2315 int minDimension = qMin(option->rect.width(), option->rect.height()); |
2289 QRect iconRect(option->rect.topLeft(), QSize(minDimension, minDimension)); |
2316 QRect iconRect(option->rect.topLeft(), QSize(minDimension, minDimension)); |
2290 const int magicTweak = 3; |
2317 const int magicTweak = 3; |
2291 int resizeValue = minDimension >> 1; |
2318 int resizeValue = minDimension >> 1; |
2292 if (!QS60StylePrivate::isTouchSupported()) { |
2319 if (!QS60StylePrivate::isTouchSupported()) { |
2293 minDimension += resizeValue; // Adjust the icon bigger because of empty space in svg icon. |
2320 minDimension += resizeValue; // Adjust the icon bigger because of empty space in svg icon. |
2294 iconRect.setSize(QSize(minDimension, minDimension)); |
2321 iconRect.setSize(QSize(minDimension, minDimension)); |
2295 const int verticalMagic = (option->rect.width() <= option->rect.height()) ? magicTweak : 0; |
2322 const int verticalMagic = (option->rect.width() <= option->rect.height()) ? magicTweak : 0; |
2360 { |
2387 { |
2361 int metricValue = QS60StylePrivate::pixelMetric(metric); |
2388 int metricValue = QS60StylePrivate::pixelMetric(metric); |
2362 if (metricValue == KNotFound) |
2389 if (metricValue == KNotFound) |
2363 metricValue = QCommonStyle::pixelMetric(metric, option, widget); |
2390 metricValue = QCommonStyle::pixelMetric(metric, option, widget); |
2364 |
2391 |
2365 if (metric == PM_SubMenuOverlap && widget) { |
|
2366 const QMenu *menu = qobject_cast<const QMenu *>(widget); |
|
2367 if (menu && menu->activeAction() && menu->activeAction()->menu()) { |
|
2368 const int menuWidth = menu->activeAction()->menu()->sizeHint().width(); |
|
2369 metricValue = -menuWidth; |
|
2370 } |
|
2371 } |
|
2372 //if layout direction is mirrored, switch left and right border margins |
2392 //if layout direction is mirrored, switch left and right border margins |
2373 if (option && option->direction == Qt::RightToLeft) { |
2393 if (option && option->direction == Qt::RightToLeft) { |
2374 if (metric == PM_LayoutLeftMargin) |
2394 if (metric == PM_LayoutLeftMargin) |
2375 metricValue = QS60StylePrivate::pixelMetric(PM_LayoutRightMargin); |
2395 metricValue = QS60StylePrivate::pixelMetric(PM_LayoutRightMargin); |
2376 else if (metric == PM_LayoutRightMargin) |
2396 else if (metric == PM_LayoutRightMargin) |
2377 metricValue = QS60StylePrivate::pixelMetric(PM_LayoutLeftMargin); |
2397 metricValue = QS60StylePrivate::pixelMetric(PM_LayoutLeftMargin); |
2378 } |
2398 } |
2399 |
|
2400 if (widget && (metric == PM_LayoutTopMargin)) |
|
2401 if (widget->windowType() == Qt::Dialog) |
|
2402 //double the top layout margin for dialogs, it is very close to real value |
|
2403 //without having to define custom pixel metric |
|
2404 metricValue *= 2; |
|
2379 return metricValue; |
2405 return metricValue; |
2380 } |
2406 } |
2381 |
2407 |
2382 /*! \reimp */ |
2408 /*! \reimp */ |
2383 QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, |
2409 QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, |
2430 sz.setHeight(sz.height() + 2 * pixelMetric(PM_FocusFrameVMargin)); |
2456 sz.setHeight(sz.height() + 2 * pixelMetric(PM_FocusFrameVMargin)); |
2431 break; |
2457 break; |
2432 #ifndef QT_NO_COMBOBOX |
2458 #ifndef QT_NO_COMBOBOX |
2433 case CT_ComboBox: { |
2459 case CT_ComboBox: { |
2434 // Fixing Ui design issues with too wide QComboBoxes and greedy SizeHints |
2460 // Fixing Ui design issues with too wide QComboBoxes and greedy SizeHints |
2435 // Make sure, that the combobox says within the screen. |
2461 // Make sure, that the combobox stays within the screen. |
2436 const QSize desktopContentSize = QApplication::desktop()->availableGeometry().size() |
2462 const QSize desktopContentSize = QApplication::desktop()->availableGeometry().size() |
2437 -QSize(pixelMetric(PM_LayoutLeftMargin) + pixelMetric(PM_LayoutRightMargin), 0); |
2463 - QSize(pixelMetric(PM_LayoutLeftMargin) + pixelMetric(PM_LayoutRightMargin), 0); |
2438 sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget). |
2464 sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget). |
2439 boundedTo(desktopContentSize); |
2465 boundedTo(desktopContentSize); |
2440 } |
2466 } |
2441 break; |
2467 break; |
2442 #endif |
2468 #endif |
2451 int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *widget, |
2477 int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *widget, |
2452 QStyleHintReturn *hret) const |
2478 QStyleHintReturn *hret) const |
2453 { |
2479 { |
2454 int retValue = -1; |
2480 int retValue = -1; |
2455 switch (sh) { |
2481 switch (sh) { |
2482 case SH_RequestSoftwareInputPanel: |
|
2483 if (QS60StylePrivate::isSingleClickUi()) |
|
2484 retValue = RSIP_OnMouseClick; |
|
2485 else |
|
2486 retValue = RSIP_OnMouseClickAndAlreadyFocused; |
|
2487 break; |
|
2488 case SH_ComboBox_Popup: |
|
2489 retValue = true; |
|
2490 break; |
|
2456 case SH_Table_GridLineColor: |
2491 case SH_Table_GridLineColor: |
2457 retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 2, 0).rgba()); |
2492 retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 2, 0).rgba()); |
2458 break; |
2493 break; |
2459 case SH_GroupBox_TextLabelColor: |
2494 case SH_GroupBox_TextLabelColor: |
2460 retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0).rgba()); |
2495 retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0).rgba()); |
2503 case SH_BlinkCursorWhenTextSelected: |
2538 case SH_BlinkCursorWhenTextSelected: |
2504 retValue = true; |
2539 retValue = true; |
2505 break; |
2540 break; |
2506 case SH_UnderlineShortcut: |
2541 case SH_UnderlineShortcut: |
2507 retValue = 0; |
2542 retValue = 0; |
2508 break; |
|
2509 case SH_RequestSoftwareInputPanel: |
|
2510 retValue = RSIP_OnMouseClickAndAlreadyFocused; |
|
2511 break; |
2543 break; |
2512 case SH_FormLayoutWrapPolicy: |
2544 case SH_FormLayoutWrapPolicy: |
2513 retValue = QFormLayout::WrapLongRows; |
2545 retValue = QFormLayout::WrapLongRows; |
2514 break; |
2546 break; |
2515 case SH_ScrollBar_ContextMenu: |
2547 case SH_ScrollBar_ContextMenu: |
2592 case CC_SpinBox: |
2624 case CC_SpinBox: |
2593 if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
2625 if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
2594 const int frameThickness = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; |
2626 const int frameThickness = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; |
2595 const int buttonMargin = spinbox->frame ? 2 : 0; |
2627 const int buttonMargin = spinbox->frame ? 2 : 0; |
2596 const int buttonContentWidth = QS60StylePrivate::pixelMetric(PM_ButtonIconSize) + 2 * buttonMargin; |
2628 const int buttonContentWidth = QS60StylePrivate::pixelMetric(PM_ButtonIconSize) + 2 * buttonMargin; |
2629 // Spinbox buttons should be no larger than one fourth of total width. |
|
2630 // Thus, side-by-side buttons would take half of the total width. |
|
2631 const int maxSize = qMax(spinbox->rect.width() / 4, buttonContentWidth); |
|
2597 QSize buttonSize; |
2632 QSize buttonSize; |
2598 buttonSize.setHeight(qMax(8, spinbox->rect.height() - frameThickness)); |
2633 buttonSize.setHeight(qMin(maxSize, qMax(8, spinbox->rect.height() - frameThickness))); |
2599 //width should at least be equal to height |
2634 //width should at least be equal to height |
2600 buttonSize.setWidth(qMax(buttonSize.height(), buttonContentWidth)); |
2635 buttonSize.setWidth(qMax(buttonSize.height(), buttonContentWidth)); |
2601 buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); |
2636 buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); |
2602 |
2637 |
2603 const int y = frameThickness + spinbox->rect.y(); |
2638 // Normally spinbuttons should be side-by-side, but if spinbox grows very big |
2604 const int x = spinbox->rect.x() + spinbox->rect.width() - frameThickness - 2 * buttonSize.width(); |
2639 // and spinbuttons reach their maximum size, they can be deployed one top of the other. |
2640 const bool sideBySide = (buttonSize.height() * 2 < spinbox->rect.height()) ? false : true; |
|
2641 const int y = frameThickness + spinbox->rect.y() + |
|
2642 (spinbox->rect.height() - (sideBySide ? 1 : 2) * buttonSize.height()) / 2; |
|
2643 const int x = spinbox->rect.x() + |
|
2644 spinbox->rect.width() - frameThickness - (sideBySide ? 2 : 1) * buttonSize.width(); |
|
2605 |
2645 |
2606 switch (scontrol) { |
2646 switch (scontrol) { |
2607 case SC_SpinBoxUp: |
2647 case SC_SpinBoxUp: |
2608 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2648 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2609 return QRect(); |
2649 return QRect(); |
2610 ret = QRect(x, y, buttonSize.width(), buttonSize.height()); |
2650 ret = QRect(x, y, buttonSize.width(), buttonSize.height()); |
2611 break; |
2651 break; |
2612 case SC_SpinBoxDown: |
2652 case SC_SpinBoxDown: |
2613 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2653 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2614 return QRect(); |
2654 return QRect(); |
2615 ret = QRect(x + buttonSize.width(), y, buttonSize.width(), buttonSize.height()); |
2655 ret = QRect(x + (sideBySide ? buttonSize.width() : 0), |
2656 y + (sideBySide ? 0 : buttonSize.height()), |
|
2657 buttonSize.width(), buttonSize.height()); |
|
2616 break; |
2658 break; |
2617 case SC_SpinBoxEditField: |
2659 case SC_SpinBoxEditField: |
2618 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2660 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
2619 ret = QRect( |
2661 ret = QRect( |
2620 frameThickness, |
2662 frameThickness, |
2664 ret = QRect( |
2706 ret = QRect( |
2665 frameThickness, |
2707 frameThickness, |
2666 frameThickness, |
2708 frameThickness, |
2667 withFrameX - frameThickness, |
2709 withFrameX - frameThickness, |
2668 height - 2 * frameThickness); |
2710 height - 2 * frameThickness); |
2711 } |
|
2712 break; |
|
2713 case SC_ComboBoxListBoxPopup: { |
|
2714 const QRect desktopContent = QApplication::desktop()->availableGeometry(); |
|
2715 |
|
2716 // take the size of this and position bottom above available area |
|
2717 QRect popupRect; |
|
2718 const int width = desktopContent.width() - pixelMetric(PM_LayoutRightMargin) - pixelMetric(PM_LayoutLeftMargin); |
|
2719 popupRect.setWidth(width); |
|
2720 popupRect.setHeight(desktopContent.height()); //combobox resets height anyway based on content |
|
2721 popupRect.setBottom(desktopContent.bottom()); |
|
2722 popupRect.translate(pixelMetric(PM_LayoutLeftMargin), 0); |
|
2723 ret = popupRect; |
|
2669 } |
2724 } |
2670 break; |
2725 break; |
2671 default: |
2726 default: |
2672 break; |
2727 break; |
2673 } |
2728 } |
2740 case SE_RadioButtonFocusRect: |
2795 case SE_RadioButtonFocusRect: |
2741 ret = opt->rect; |
2796 ret = opt->rect; |
2742 break; |
2797 break; |
2743 case SE_LineEditContents: { |
2798 case SE_LineEditContents: { |
2744 // in S60 the input text box doesn't start from line Edit's TL, but |
2799 // in S60 the input text box doesn't start from line Edit's TL, but |
2745 // a bit indented. |
2800 // a bit indented (8 pixels). |
2746 QRect lineEditRect = opt->rect; |
2801 const int KLineEditDefaultIndention = 8; |
2747 const int adjustment = opt->rect.height() >> 2; |
2802 ret = visualRect( |
2748 lineEditRect.adjust(adjustment, 0, 0, 0); |
2803 opt->direction, opt->rect, opt->rect.adjusted(KLineEditDefaultIndention, 0, 0, 0)); |
2749 ret = lineEditRect; |
|
2750 } |
2804 } |
2751 break; |
2805 break; |
2752 case SE_TabBarTearIndicator: |
2806 case SE_TabBarTearIndicator: |
2753 ret = QRect(0, 0, 0, 0); |
2807 ret = QRect(0, 0, 0, 0); |
2754 break; |
2808 break; |
2820 pixelMetric(PM_ListViewIconSize, opt, widget) : |
2874 pixelMetric(PM_ListViewIconSize, opt, widget) : |
2821 pixelMetric(PM_SmallIconSize, opt, widget); |
2875 pixelMetric(PM_SmallIconSize, opt, widget); |
2822 ret = menuItem->rect; |
2876 ret = menuItem->rect; |
2823 |
2877 |
2824 if (element == SE_ItemViewItemDecoration) { |
2878 if (element == SE_ItemViewItemDecoration) { |
2825 if (menuItem->direction == Qt::RightToLeft) |
2879 if (menuItem->icon.isNull()) { |
2826 ret.translate(ret.width()-indicatorWidth, 0); |
2880 ret = QRect(); |
2827 ret.setWidth(indicatorWidth); |
2881 } else { |
2882 if (menuItem->direction == Qt::RightToLeft) |
|
2883 ret.translate(ret.width()-indicatorWidth, 0); |
|
2884 ret.setWidth(indicatorWidth); |
|
2885 } |
|
2828 } else { |
2886 } else { |
2829 ret = menuItem->rect; |
2887 ret = menuItem->rect; |
2830 if (!menuItem->icon.isNull()) |
2888 if (!menuItem->icon.isNull()) |
2831 if (menuItem->direction == Qt::LeftToRight) |
2889 if (menuItem->direction == Qt::LeftToRight) |
2832 ret.adjust(indicatorWidth, 0, 0, 0); |
2890 ret.adjust(indicatorWidth, 0, 0, 0); |
2882 case SE_HeaderLabel: |
2940 case SE_HeaderLabel: |
2883 ret = QCommonStyle::subElementRect(element, opt, widget); |
2941 ret = QCommonStyle::subElementRect(element, opt, widget); |
2884 if (qstyleoption_cast<const QStyleOptionHeader *>(opt)) { |
2942 if (qstyleoption_cast<const QStyleOptionHeader *>(opt)) { |
2885 // Subtract area needed for line |
2943 // Subtract area needed for line |
2886 if (opt->state & State_Horizontal) |
2944 if (opt->state & State_Horizontal) |
2887 ret.setHeight(ret.height() - QS60StylePrivate::pixelMetric(PM_Custom_BoldLineWidth)); |
2945 ret.setHeight(ret.height() - QS60StylePrivate::pixelMetric(PM_BoldLineWidth)); |
2888 else |
2946 else |
2889 ret.setWidth(ret.width() - QS60StylePrivate::pixelMetric(PM_Custom_ThinLineWidth)); |
2947 ret.setWidth(ret.width() - QS60StylePrivate::pixelMetric(PM_ThinLineWidth)); |
2890 } |
2948 } |
2891 ret = visualRect(opt->direction, opt->rect, ret); |
2949 ret = visualRect(opt->direction, opt->rect, ret); |
2892 break; |
2950 break; |
2893 case SE_RadioButtonIndicator: { |
2951 case SE_RadioButtonIndicator: { |
2894 const int height = pixelMetric(PM_ExclusiveIndicatorHeight, opt, widget); |
2952 const int height = pixelMetric(PM_ExclusiveIndicatorHeight, opt, widget); |
3195 return QStyle::eventFilter(object, event); |
3253 return QStyle::eventFilter(object, event); |
3196 } |
3254 } |
3197 |
3255 |
3198 /*! |
3256 /*! |
3199 \internal |
3257 \internal |
3200 Handle the timer \a event. |
3258 Handle the timer \a event. |
3201 */ |
3259 */ |
3202 void QS60Style::timerEvent(QTimerEvent *event) |
3260 void QS60Style::timerEvent(QTimerEvent *event) |
3203 { |
3261 { |
3204 #ifdef Q_WS_S60 |
3262 #ifdef Q_WS_S60 |
3205 #ifndef QT_NO_PROGRESSBAR |
3263 #ifndef QT_NO_PROGRESSBAR |