changeset 3 | 41300fa6a67c |
parent 0 | 1918ee327afb |
child 4 | 3b1da2848fc7 |
2:56cd8111b7f7 | 3:41300fa6a67c |
---|---|
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2009 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 of the Qt Toolkit. |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
8 ** |
8 ** |
9 ** $QT_BEGIN_LICENSE:LGPL$ |
9 ** $QT_BEGIN_LICENSE:LGPL$ |
10 ** No Commercial Usage |
10 ** No Commercial Usage |
11 ** This file contains pre-release code and may not be distributed. |
11 ** This file contains pre-release code and may not be distributed. |
12 ** You may use this file in accordance with the terms and conditions |
12 ** You may use this file in accordance with the terms and conditions |
64 #include "qtablewidget.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 "qtreeview.h" |
|
70 #include "qfocusframe.h" |
69 #include "qfocusframe.h" |
70 #include "qformlayout.h" |
|
71 |
71 |
72 #include "private/qtoolbarextension_p.h" |
72 #include "private/qtoolbarextension_p.h" |
73 #include "private/qcombobox_p.h" |
73 #include "private/qcombobox_p.h" |
74 #include "private/qwidget_p.h" |
74 #include "private/qwidget_p.h" |
75 #include "private/qapplication_p.h" |
75 #include "private/qapplication_p.h" |
82 extern Q_GUI_EXPORT int qt_defaultDpiY(); |
82 extern Q_GUI_EXPORT int qt_defaultDpiY(); |
83 |
83 |
84 const QS60StylePrivate::SkinElementFlags QS60StylePrivate::KDefaultSkinElementFlags = |
84 const QS60StylePrivate::SkinElementFlags QS60StylePrivate::KDefaultSkinElementFlags = |
85 SkinElementFlags(SF_PointNorth | SF_StateEnabled); |
85 SkinElementFlags(SF_PointNorth | SF_StateEnabled); |
86 |
86 |
87 static const QByteArray propertyKeyLayouts = "layouts"; |
|
88 static const QByteArray propertyKeyCurrentlayout = "currentlayout"; |
|
89 |
|
90 static const qreal goldenRatio = 1.618; |
87 static const qreal goldenRatio = 1.618; |
91 |
88 |
92 const layoutHeader QS60StylePrivate::m_layoutHeaders[] = { |
89 const layoutHeader QS60StylePrivate::m_layoutHeaders[] = { |
93 // *** generated layout data *** |
90 // *** generated layout data *** |
94 {240,320,1,14,true,"QVGA Landscape Mirrored"}, |
91 {240,320,1,15,"QVGA Landscape"}, |
95 {240,320,1,14,false,"QVGA Landscape"}, |
92 {320,240,1,15,"QVGA Portrait"}, |
96 {320,240,1,14,true,"QVGA Portrait Mirrored"}, |
93 {360,640,1,15,"NHD Landscape"}, |
97 {320,240,1,14,false,"QVGA Portrait"}, |
94 {640,360,1,15,"NHD Portrait"}, |
98 {360,640,1,14,true,"NHD Landscape Mirrored"}, |
95 {352,800,1,12,"E90 Landscape"} |
99 {360,640,1,14,false,"NHD Landscape"}, |
|
100 {640,360,1,14,true,"NHD Portrait Mirrored"}, |
|
101 {640,360,1,14,false,"NHD Portrait"}, |
|
102 {352,800,1,12,true,"E90 Landscape Mirrored"}, |
|
103 {352,800,1,12,false,"E90 Landscape"} |
|
104 // *** End of generated data *** |
96 // *** End of generated data *** |
105 }; |
97 }; |
106 const int QS60StylePrivate::m_numberOfLayouts = |
98 const int QS60StylePrivate::m_numberOfLayouts = |
107 (int)sizeof(QS60StylePrivate::m_layoutHeaders)/sizeof(QS60StylePrivate::m_layoutHeaders[0]); |
99 (int)sizeof(QS60StylePrivate::m_layoutHeaders)/sizeof(QS60StylePrivate::m_layoutHeaders[0]); |
108 |
100 |
109 const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = { |
101 const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = { |
110 // *** generated pixel metrics *** |
102 // *** generated pixel metrics *** |
111 {5,0,-909,0,0,1,0,0,-1,8,15,22,15,15,7,198,-909,-909,-909,19,15,2,0,0,21,-909,21,-909,4,4,1,-909,-909,0,2,0,0,13,23,17,17,21,21,2,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,51,27,51,4,4,5,10,15,-909,5,58,12,5,0,7,4,4,9,4,4,-909,1,-909,-909,-909,-909,4,4,3,1}, |
103 {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,3,3,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}, |
112 {5,0,-909,0,0,1,0,0,-1,8,15,22,15,15,7,198,-909,-909,-909,19,15,2,0,0,21,-909,21,-909,4,4,1,-909,-909,0,2,0,0,13,23,17,17,21,21,2,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,51,27,51,4,4,5,10,15,-909,5,58,12,5,0,4,4,7,9,4,4,-909,1,-909,-909,-909,-909,4,4,3,1}, |
104 {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,4,4,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}, |
113 {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,-909,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,4,4,5,10,15,-909,5,58,13,5,0,7,4,4,9,4,4,-909,1,-909,-909,-909,-909,4,4,3,1}, |
105 {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,5,5,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}, |
114 {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,-909,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,4,4,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,1,-909,-909,-909,-909,4,4,3,1}, |
106 {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,5,5,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}, |
115 {7,0,-909,0,0,2,0,0,-1,20,53,28,19,19,9,258,-909,-909,-909,29,19,26,0,0,32,-909,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,5,5,6,8,19,-909,7,74,19,7,0,8,5,5,12,5,5,-909,2,-909,-909,-909,-909,7,7,3,1}, |
107 {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} |
116 {7,0,-909,0,0,2,0,0,-1,20,53,28,19,19,9,258,-909,-909,-909,29,19,26,0,0,32,-909,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,5,5,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,2,-909,-909,-909,-909,7,7,3,1}, |
|
117 {7,0,-909,0,0,2,0,0,-1,20,52,28,19,19,9,258,-909,-909,-909,29,19,6,0,0,32,-909,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,98,35,98,5,5,6,8,19,-909,7,74,22,7,0,8,5,5,12,5,5,-909,2,-909,-909,-909,-909,7,7,3,1}, |
|
118 {7,0,-909,0,0,2,0,0,-1,20,52,28,19,19,9,258,-909,-909,-909,29,19,6,0,0,32,-909,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,98,35,98,5,5,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,2,-909,-909,-909,-909,7,7,3,1}, |
|
119 {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,-909,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,5,-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,8,6,5,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1}, |
|
120 {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,-909,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} |
|
121 // *** End of generated data *** |
108 // *** End of generated data *** |
122 }; |
109 }; |
123 |
110 |
124 const short *QS60StylePrivate::m_pmPointer = QS60StylePrivate::data[0]; |
111 const short *QS60StylePrivate::m_pmPointer = QS60StylePrivate::data[0]; |
125 |
112 |
142 {SE_ToolBar, QS60StyleEnums::SP_QsnFrPopupSubCenter}, |
129 {SE_ToolBar, QS60StyleEnums::SP_QsnFrPopupSubCenter}, |
143 {SE_ToolBarButton, QS60StyleEnums::SP_QsnFrSctrlButtonCenter}, |
130 {SE_ToolBarButton, QS60StyleEnums::SP_QsnFrSctrlButtonCenter}, |
144 {SE_ToolBarButtonPressed, QS60StyleEnums::SP_QsnFrSctrlButtonCenterPressed}, |
131 {SE_ToolBarButtonPressed, QS60StyleEnums::SP_QsnFrSctrlButtonCenterPressed}, |
145 {SE_PanelBackground, QS60StyleEnums::SP_QsnFrSetOptCenter}, |
132 {SE_PanelBackground, QS60StyleEnums::SP_QsnFrSetOptCenter}, |
146 {SE_ButtonInactive, QS60StyleEnums::SP_QsnFrButtonCenterInactive}, |
133 {SE_ButtonInactive, QS60StyleEnums::SP_QsnFrButtonCenterInactive}, |
147 {SE_Editor, QS60StyleEnums::SP_QsnFrNotepadCenter}, |
134 {SE_Editor, QS60StyleEnums::SP_QsnFrInputCenter}, |
148 }; |
135 }; |
149 |
136 |
150 static const int frameElementsCount = |
137 static const int frameElementsCount = |
151 int(sizeof(QS60StylePrivate::m_frameElementsData)/sizeof(QS60StylePrivate::m_frameElementsData[0])); |
138 int(sizeof(QS60StylePrivate::m_frameElementsData)/sizeof(QS60StylePrivate::m_frameElementsData[0])); |
152 |
139 |
201 case SE_ScrollBarHandleVertical: |
188 case SE_ScrollBarHandleVertical: |
202 drawRow(QS60StyleEnums::SP_QsnCpScrollHandleTop, QS60StyleEnums::SP_QsnCpScrollHandleMiddle, |
189 drawRow(QS60StyleEnums::SP_QsnCpScrollHandleTop, QS60StyleEnums::SP_QsnCpScrollHandleMiddle, |
203 QS60StyleEnums::SP_QsnCpScrollHandleBottom, Qt::Vertical, painter, rect, flags | SF_PointNorth); |
190 QS60StyleEnums::SP_QsnCpScrollHandleBottom, Qt::Vertical, painter, rect, flags | SF_PointNorth); |
204 break; |
191 break; |
205 case SE_SliderHandleHorizontal: |
192 case SE_SliderHandleHorizontal: |
206 drawPart(QS60StyleEnums::SP_QgnIndiSliderEdit, painter, rect, flags | SF_PointNorth); |
193 drawPart(QS60StyleEnums::SP_QgnGrafNsliderMarker, painter, rect, flags | SF_PointNorth); |
207 break; |
194 break; |
208 case SE_SliderHandleVertical: |
195 case SE_SliderHandleVertical: |
209 drawPart(QS60StyleEnums::SP_QgnIndiSliderEdit, painter, rect, flags | SF_PointEast); |
196 drawPart(QS60StyleEnums::SP_QgnGrafNsliderMarker, painter, rect, flags | SF_PointEast); |
197 break; |
|
198 case SE_SliderHandleSelectedHorizontal: |
|
199 drawPart(QS60StyleEnums::SP_QgnGrafNsliderMarkerSelected, painter, rect, flags | SF_PointNorth); |
|
200 break; |
|
201 case SE_SliderHandleSelectedVertical: |
|
202 drawPart(QS60StyleEnums::SP_QgnGrafNsliderMarkerSelected, painter, rect, flags | SF_PointEast); |
|
203 break; |
|
204 case SE_SliderGrooveVertical: |
|
205 drawRow(QS60StyleEnums::SP_QgnGrafNsliderEndLeft, QS60StyleEnums::SP_QgnGrafNsliderMiddle, |
|
206 QS60StyleEnums::SP_QgnGrafNsliderEndRight, Qt::Vertical, painter, rect, flags | SF_PointEast); |
|
207 break; |
|
208 case SE_SliderGrooveHorizontal: |
|
209 drawRow(QS60StyleEnums::SP_QgnGrafNsliderEndLeft, QS60StyleEnums::SP_QgnGrafNsliderMiddle, |
|
210 QS60StyleEnums::SP_QgnGrafNsliderEndRight, Qt::Horizontal, painter, rect, flags | SF_PointNorth); |
|
210 break; |
211 break; |
211 case SE_TabBarTabEastActive: |
212 case SE_TabBarTabEastActive: |
212 drawRow(QS60StyleEnums::SP_QgnGrafTabActiveL, QS60StyleEnums::SP_QgnGrafTabActiveM, |
213 drawRow(QS60StyleEnums::SP_QgnGrafTabActiveL, QS60StyleEnums::SP_QgnGrafTabActiveM, |
213 QS60StyleEnums::SP_QgnGrafTabActiveR, Qt::Vertical, painter, rect, flags | SF_PointEast); |
214 QS60StyleEnums::SP_QgnGrafTabActiveR, Qt::Vertical, painter, rect, flags | SF_PointEast); |
214 break; |
215 break; |
280 break; |
281 break; |
281 case SE_ButtonInactive: |
282 case SE_ButtonInactive: |
282 drawFrame(SF_ButtonInactive, painter, rect, flags | SF_PointNorth); |
283 drawFrame(SF_ButtonInactive, painter, rect, flags | SF_PointNorth); |
283 break; |
284 break; |
284 case SE_Editor: |
285 case SE_Editor: |
285 drawFrame(SF_Editor, painter, rect, flags | SF_PointNorth); |
286 drawFrame(SF_FrameLineEdit, painter, rect, flags | SF_PointNorth); |
286 break; |
287 break; |
287 default: |
288 default: |
288 break; |
289 break; |
289 } |
290 } |
290 } |
291 } |
298 short QS60StylePrivate::pixelMetric(int metric) |
299 short QS60StylePrivate::pixelMetric(int metric) |
299 { |
300 { |
300 Q_ASSERT(metric < MAX_PIXELMETRICS); |
301 Q_ASSERT(metric < MAX_PIXELMETRICS); |
301 const short returnValue = m_pmPointer[metric]; |
302 const short returnValue = m_pmPointer[metric]; |
302 return returnValue; |
303 return returnValue; |
303 } |
|
304 |
|
305 void QS60StylePrivate::setStyleProperty(const char *name, const QVariant &value) |
|
306 { |
|
307 if (name == propertyKeyCurrentlayout) { |
|
308 static const QStringList layouts = styleProperty(propertyKeyLayouts).toStringList(); |
|
309 const QString layout = value.toString(); |
|
310 Q_ASSERT(layouts.contains(layout)); |
|
311 const int layoutIndex = layouts.indexOf(layout); |
|
312 setCurrentLayout(layoutIndex); |
|
313 QApplication::setLayoutDirection(m_layoutHeaders[layoutIndex].mirroring ? Qt::RightToLeft : Qt::LeftToRight); |
|
314 clearCaches(); |
|
315 refreshUI(); |
|
316 } |
|
317 } |
|
318 |
|
319 QVariant QS60StylePrivate::styleProperty(const char *name) const |
|
320 { |
|
321 if (name == propertyKeyLayouts) { |
|
322 static QStringList layouts; |
|
323 if (layouts.isEmpty()) |
|
324 for (int i = 0; i < m_numberOfLayouts; i++) |
|
325 layouts.append(QLatin1String(m_layoutHeaders[i].layoutName)); |
|
326 return layouts; |
|
327 } |
|
328 return QVariant(); |
|
329 } |
304 } |
330 |
305 |
331 QColor QS60StylePrivate::stateColor(const QColor &color, const QStyleOption *option) |
306 QColor QS60StylePrivate::stateColor(const QColor &color, const QStyleOption *option) |
332 { |
307 { |
333 QColor retColor (color); |
308 QColor retColor (color); |
432 Q_ASSERT(frameImage.bytesPerLine() > 0); |
407 Q_ASSERT(frameImage.bytesPerLine() > 0); |
433 if (frameImage.isNull()) |
408 if (frameImage.isNull()) |
434 return Qt::black; |
409 return Qt::black; |
435 |
410 |
436 const QRgb *pixelRgb = (const QRgb*)frameImage.bits(); |
411 const QRgb *pixelRgb = (const QRgb*)frameImage.bits(); |
437 const int pixels = frameImage.numBytes()/sizeof(QRgb); |
412 const int pixels = frameImage.byteCount()/sizeof(QRgb); |
438 |
413 |
439 int estimatedRed = 0; |
414 int estimatedRed = 0; |
440 int estimatedGreen = 0; |
415 int estimatedGreen = 0; |
441 int estimatedBlue = 0; |
416 int estimatedBlue = 0; |
442 |
417 |
478 void QS60StylePrivate::setThemePalette(QApplication *app) const |
453 void QS60StylePrivate::setThemePalette(QApplication *app) const |
479 { |
454 { |
480 Q_UNUSED(app) |
455 Q_UNUSED(app) |
481 QPalette widgetPalette = QPalette(Qt::white); |
456 QPalette widgetPalette = QPalette(Qt::white); |
482 setThemePalette(&widgetPalette); |
457 setThemePalette(&widgetPalette); |
483 QApplication::setPalette(widgetPalette); //calling QApplication::setPalette clears palette hash |
|
484 setThemePaletteHash(&widgetPalette); |
|
485 storeThemePalette(&widgetPalette); |
|
486 } |
|
487 |
|
488 void QS60StylePrivate::setThemePalette(QStyleOption *option) const |
|
489 { |
|
490 setThemePalette(&option->palette); |
|
491 } |
458 } |
492 |
459 |
493 QPalette* QS60StylePrivate::themePalette() |
460 QPalette* QS60StylePrivate::themePalette() |
494 { |
461 { |
495 return m_themePalette; |
462 return m_themePalette; |
498 void QS60StylePrivate::setBackgroundTexture(QApplication *app) const |
465 void QS60StylePrivate::setBackgroundTexture(QApplication *app) const |
499 { |
466 { |
500 Q_UNUSED(app) |
467 Q_UNUSED(app) |
501 QPalette applicationPalette = QApplication::palette(); |
468 QPalette applicationPalette = QApplication::palette(); |
502 applicationPalette.setBrush(QPalette::Window, backgroundTexture()); |
469 applicationPalette.setBrush(QPalette::Window, backgroundTexture()); |
503 QApplication::setPalette(applicationPalette); |
470 setThemePalette(&applicationPalette); |
504 } |
471 } |
505 |
472 |
506 void QS60StylePrivate::deleteBackground() |
473 void QS60StylePrivate::deleteBackground() |
507 { |
474 { |
508 if (m_background) { |
475 if (m_background) { |
524 // Freezes on 3.1. Anyways, caching is only really needed on touch UI |
491 // Freezes on 3.1. Anyways, caching is only really needed on touch UI |
525 !(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2); |
492 !(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2); |
526 #else |
493 #else |
527 true; |
494 true; |
528 #endif |
495 #endif |
529 const QPixmap skinPartPixMap((doCache ? cachedPart : part)(skinPart, rect.size(), flags)); |
496 |
497 const QPixmap skinPartPixMap((doCache ? cachedPart : part)(skinPart, rect.size(), painter, flags)); |
|
530 if (!skinPartPixMap.isNull()) |
498 if (!skinPartPixMap.isNull()) |
531 painter->drawPixmap(rect.topLeft(), skinPartPixMap); |
499 painter->drawPixmap(rect.topLeft(), skinPartPixMap); |
532 } |
500 } |
533 |
501 |
534 void QS60StylePrivate::drawFrame(SkinFrameElements frameElement, QPainter *painter, const QRect &rect, SkinElementFlags flags) |
502 void QS60StylePrivate::drawFrame(SkinFrameElements frameElement, QPainter *painter, const QRect &rect, SkinElementFlags flags) |
591 drawPart(end, painter, endRect, flags); |
559 drawPart(end, painter, endRect, flags); |
592 #endif |
560 #endif |
593 } |
561 } |
594 |
562 |
595 QPixmap QS60StylePrivate::cachedPart(QS60StyleEnums::SkinParts part, |
563 QPixmap QS60StylePrivate::cachedPart(QS60StyleEnums::SkinParts part, |
596 const QSize &size, SkinElementFlags flags) |
564 const QSize &size, QPainter *painter, SkinElementFlags flags) |
597 { |
565 { |
598 QPixmap result; |
566 QPixmap result; |
599 const QString cacheKey = |
567 const QString cacheKey = |
600 QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinPartFlags=%4") |
568 QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinPartFlags=%4") |
601 .arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags); |
569 .arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags); |
602 if (!QPixmapCache::find(cacheKey, result)) { |
570 if (!QPixmapCache::find(cacheKey, result)) { |
603 result = QS60StylePrivate::part(part, size, flags); |
571 result = QS60StylePrivate::part(part, size, painter, flags); |
604 QPixmapCache::insert(cacheKey, result); |
572 QPixmapCache::insert(cacheKey, result); |
605 } |
573 } |
606 return result; |
574 return result; |
607 } |
575 } |
608 |
576 |
661 |
629 |
662 void QS60StylePrivate::setThemePalette(QWidget *widget) const |
630 void QS60StylePrivate::setThemePalette(QWidget *widget) const |
663 { |
631 { |
664 if(!widget) |
632 if(!widget) |
665 return; |
633 return; |
666 QPalette widgetPalette = QApplication::palette(widget); |
|
667 |
634 |
668 //header view and its viewport need to be set 100% transparent button color, since drawing code will |
635 //header view and its viewport need to be set 100% transparent button color, since drawing code will |
669 //draw transparent theme graphics to table column and row headers. |
636 //draw transparent theme graphics to table column and row headers. |
670 if (qobject_cast<QHeaderView *>(widget)){ |
637 if (qobject_cast<QHeaderView *>(widget)){ |
638 QPalette widgetPalette = QApplication::palette(widget); |
|
671 widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, |
639 widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, |
672 s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0)); |
640 s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0)); |
673 QHeaderView* header = qobject_cast<QHeaderView *>(widget); |
641 QHeaderView* header = qobject_cast<QHeaderView *>(widget); |
674 widgetPalette.setColor(QPalette::Button, Qt::transparent ); |
642 widgetPalette.setColor(QPalette::Button, Qt::transparent ); |
675 if ( header->viewport() ) |
643 if (header->viewport()) |
676 header->viewport()->setPalette(widgetPalette); |
644 header->viewport()->setPalette(widgetPalette); |
677 QApplication::setPalette(widgetPalette, "QHeaderView"); |
645 QApplication::setPalette(widgetPalette, "QHeaderView"); |
678 } |
646 } |
679 } |
647 } |
680 |
648 |
685 |
653 |
686 // basic colors |
654 // basic colors |
687 palette->setColor(QPalette::WindowText, |
655 palette->setColor(QPalette::WindowText, |
688 s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); |
656 s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); |
689 palette->setColor(QPalette::ButtonText, |
657 palette->setColor(QPalette::ButtonText, |
690 s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); |
658 s60Color(QS60StyleEnums::CL_QsnTextColors, 20, 0)); |
691 palette->setColor(QPalette::Text, |
659 palette->setColor(QPalette::Text, |
692 s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); |
660 s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); |
693 palette->setColor(QPalette::ToolTipText, |
661 palette->setColor(QPalette::ToolTipText, |
694 s60Color(QS60StyleEnums::CL_QsnTextColors, 55, 0)); |
662 s60Color(QS60StyleEnums::CL_QsnTextColors, 55, 0)); |
695 palette->setColor(QPalette::BrightText, palette->color(QPalette::WindowText).lighter()); |
663 palette->setColor(QPalette::BrightText, palette->color(QPalette::WindowText).lighter()); |
696 palette->setColor(QPalette::HighlightedText, |
664 palette->setColor(QPalette::HighlightedText, |
697 s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0)); |
665 s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); |
698 palette->setColor(QPalette::Link, |
666 palette->setColor(QPalette::Link, |
699 s60Color(QS60StyleEnums::CL_QsnHighlightColors, 3, 0)); |
667 s60Color(QS60StyleEnums::CL_QsnHighlightColors, 3, 0)); |
700 palette->setColor(QPalette::LinkVisited, palette->color(QPalette::Link).darker()); |
668 palette->setColor(QPalette::LinkVisited, palette->color(QPalette::Link).darker()); |
701 palette->setColor(QPalette::Highlight, |
669 palette->setColor(QPalette::Highlight, |
702 s60Color(QS60StyleEnums::CL_QsnHighlightColors, 2, 0)); |
670 s60Color(QS60StyleEnums::CL_QsnHighlightColors, 2, 0)); |
713 palette->setColor(QPalette::Light, palette->color(QPalette::Button).lighter()); |
681 palette->setColor(QPalette::Light, palette->color(QPalette::Button).lighter()); |
714 palette->setColor(QPalette::Dark, palette->color(QPalette::Button).darker()); |
682 palette->setColor(QPalette::Dark, palette->color(QPalette::Button).darker()); |
715 palette->setColor(QPalette::Midlight, palette->color(QPalette::Button).lighter(125)); |
683 palette->setColor(QPalette::Midlight, palette->color(QPalette::Button).lighter(125)); |
716 palette->setColor(QPalette::Mid, palette->color(QPalette::Button).darker(150)); |
684 palette->setColor(QPalette::Mid, palette->color(QPalette::Button).darker(150)); |
717 palette->setColor(QPalette::Shadow, Qt::black); |
685 palette->setColor(QPalette::Shadow, Qt::black); |
686 |
|
687 QApplication::setPalette(*palette); //calling QApplication::setPalette clears palette hash |
|
688 setThemePaletteHash(palette); |
|
689 storeThemePalette(palette); |
|
718 } |
690 } |
719 |
691 |
720 void QS60StylePrivate::deleteThemePalette() |
692 void QS60StylePrivate::deleteThemePalette() |
721 { |
693 { |
722 if (m_themePalette) { |
694 if (m_themePalette) { |
741 //store the original palette |
713 //store the original palette |
742 QPalette widgetPalette = *palette; |
714 QPalette widgetPalette = *palette; |
743 const QColor mainAreaTextColor = |
715 const QColor mainAreaTextColor = |
744 s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0); |
716 s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0); |
745 |
717 |
746 widgetPalette.setColor(QPalette::All, QPalette::WindowText, |
718 widgetPalette.setColor(QPalette::WindowText, |
747 s60Color(QS60StyleEnums::CL_QsnLineColors, 8, 0)); |
719 s60Color(QS60StyleEnums::CL_QsnLineColors, 8, 0)); |
748 QApplication::setPalette(widgetPalette, "QSlider"); |
720 QApplication::setPalette(widgetPalette, "QSlider"); |
749 // return to original palette after each widget |
721 // return to original palette after each widget |
750 widgetPalette = *palette; |
722 widgetPalette = *palette; |
751 |
723 |
765 widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, |
737 widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, |
766 s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0)); |
738 s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0)); |
767 QApplication::setPalette(widgetPalette, "QHeaderView"); |
739 QApplication::setPalette(widgetPalette, "QHeaderView"); |
768 widgetPalette = *palette; |
740 widgetPalette = *palette; |
769 |
741 |
770 widgetPalette.setColor(QPalette::All, QPalette::ButtonText, |
742 widgetPalette.setColor(QPalette::ButtonText, |
771 s60Color(QS60StyleEnums::CL_QsnTextColors, 8, 0)); |
743 s60Color(QS60StyleEnums::CL_QsnTextColors, 8, 0)); |
772 QApplication::setPalette(widgetPalette, "QMenuBar"); |
744 QApplication::setPalette(widgetPalette, "QMenuBar"); |
773 widgetPalette = *palette; |
745 widgetPalette = *palette; |
774 |
746 |
775 widgetPalette.setColor(QPalette::Active, QPalette::WindowText, |
747 widgetPalette.setColor(QPalette::WindowText, |
776 s60Color(QS60StyleEnums::CL_QsnTextColors, 4, 0)); |
748 s60Color(QS60StyleEnums::CL_QsnTextColors, 4, 0)); |
777 QApplication::setPalette(widgetPalette, "QTabBar"); |
749 QApplication::setPalette(widgetPalette, "QTabBar"); |
778 widgetPalette = *palette; |
750 widgetPalette = *palette; |
779 |
751 |
780 widgetPalette.setColor(QPalette::All, QPalette::Text, |
752 widgetPalette.setColor(QPalette::Text, |
781 s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0)); |
753 s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0)); |
782 QApplication::setPalette(widgetPalette, "QTableView"); |
754 QApplication::setPalette(widgetPalette, "QTableView"); |
783 widgetPalette = *palette; |
755 widgetPalette = *palette; |
784 |
756 |
785 widgetPalette.setColor(QPalette::All, QPalette::HighlightedText, |
757 widgetPalette.setColor(QPalette::Text, |
758 s60Color(QS60StyleEnums::CL_QsnTextColors, 27, 0)); |
|
759 widgetPalette.setColor(QPalette::HighlightedText, |
|
786 s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); |
760 s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); |
787 QApplication::setPalette(widgetPalette, "QLineEdit"); |
761 QApplication::setPalette(widgetPalette, "QLineEdit"); |
788 widgetPalette = *palette; |
762 widgetPalette = *palette; |
789 |
763 |
790 widgetPalette.setColor(QPalette::All, QPalette::Text, |
764 widgetPalette.setColor(QPalette::Text, |
791 s60Color(QS60StyleEnums::CL_QsnTextColors, 34, 0)); |
765 s60Color(QS60StyleEnums::CL_QsnTextColors, 27, 0)); |
792 widgetPalette.setColor(QPalette::All, QPalette::HighlightedText, |
766 widgetPalette.setColor(QPalette::HighlightedText, |
793 s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); |
767 s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); |
794 QApplication::setPalette(widgetPalette, "QTextEdit"); |
768 QApplication::setPalette(widgetPalette, "QTextEdit"); |
795 widgetPalette = *palette; |
769 widgetPalette = *palette; |
796 |
770 |
797 widgetPalette.setColor(QPalette::All, QPalette::HighlightedText, |
771 widgetPalette.setColor(QPalette::HighlightedText, |
798 s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); |
772 s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); |
799 QApplication::setPalette(widgetPalette, "QComboBox"); |
773 QApplication::setPalette(widgetPalette, "QComboBox"); |
800 widgetPalette = *palette; |
774 widgetPalette = *palette; |
801 |
775 |
802 widgetPalette.setColor(QPalette::WindowText, mainAreaTextColor); |
776 widgetPalette.setColor(QPalette::WindowText, mainAreaTextColor); |
807 widgetPalette = *palette; |
781 widgetPalette = *palette; |
808 |
782 |
809 widgetPalette.setBrush(QPalette::Window, QBrush()); |
783 widgetPalette.setBrush(QPalette::Window, QBrush()); |
810 QApplication::setPalette(widgetPalette, "QScrollArea"); |
784 QApplication::setPalette(widgetPalette, "QScrollArea"); |
811 widgetPalette = *palette; |
785 widgetPalette = *palette; |
786 |
|
787 //Webpages should not use S60 theme colors as they are designed to work |
|
788 //with themeBackground and do not generally mesh well with web page backgrounds. |
|
789 QPalette webPalette = *palette; |
|
790 webPalette.setColor(QPalette::WindowText, Qt::black); |
|
791 webPalette.setColor(QPalette::Text, Qt::black); |
|
792 QApplication::setPalette(webPalette, "QWebView"); |
|
793 QApplication::setPalette(webPalette, "QGraphicsWebView"); |
|
812 } |
794 } |
813 |
795 |
814 QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags) |
796 QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags) |
815 { |
797 { |
816 QSize result(20, 20); |
798 QSize result(20, 20); |
823 case QS60StyleEnums::SP_QgnGrafTabPassiveM: |
805 case QS60StyleEnums::SP_QgnGrafTabPassiveM: |
824 case QS60StyleEnums::SP_QgnGrafTabActiveR: |
806 case QS60StyleEnums::SP_QgnGrafTabActiveR: |
825 case QS60StyleEnums::SP_QgnGrafTabPassiveR: |
807 case QS60StyleEnums::SP_QgnGrafTabPassiveR: |
826 case QS60StyleEnums::SP_QgnGrafTabPassiveL: |
808 case QS60StyleEnums::SP_QgnGrafTabPassiveL: |
827 case QS60StyleEnums::SP_QgnGrafTabActiveL: |
809 case QS60StyleEnums::SP_QgnGrafTabActiveL: |
828 break; |
810 //Returned QSize for tabs must not be square, but narrow rectangle with width:height |
829 case QS60StyleEnums::SP_QgnIndiSliderEdit: |
811 //ratio of 1:2 for horizontal tab bars (and 2:1 for vertical ones). |
812 result.setWidth(result.height()>>1); |
|
813 break; |
|
814 |
|
815 case QS60StyleEnums::SP_QgnGrafNsliderEndLeft: |
|
816 case QS60StyleEnums::SP_QgnGrafNsliderEndRight: |
|
817 case QS60StyleEnums::SP_QgnGrafNsliderMiddle: |
|
818 result.setWidth(result.height()>>1); |
|
819 break; |
|
820 |
|
821 case QS60StyleEnums::SP_QgnGrafNsliderMarker: |
|
822 case QS60StyleEnums::SP_QgnGrafNsliderMarkerSelected: |
|
830 result.scale(pixelMetric(QStyle::PM_SliderLength), |
823 result.scale(pixelMetric(QStyle::PM_SliderLength), |
831 pixelMetric(QStyle::PM_SliderControlThickness), Qt::IgnoreAspectRatio); |
824 pixelMetric(QStyle::PM_SliderControlThickness), Qt::IgnoreAspectRatio); |
825 break; |
|
826 |
|
827 case QS60StyleEnums::SP_QgnGrafBarFrameSideL: |
|
828 case QS60StyleEnums::SP_QgnGrafBarFrameSideR: |
|
829 result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth)); |
|
832 break; |
830 break; |
833 |
831 |
834 case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed: |
832 case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed: |
835 case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed: |
833 case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed: |
836 case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed: |
834 case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed: |
875 result.setHeight(temp); |
873 result.setHeight(temp); |
876 } |
874 } |
877 return result; |
875 return result; |
878 } |
876 } |
879 |
877 |
878 bool QS60StylePrivate::canDrawThemeBackground(const QBrush &backgroundBrush) |
|
879 { |
|
880 //If brush is not changed from style's default values, draw theme graphics. |
|
881 return (backgroundBrush.color() == Qt::transparent || |
|
882 backgroundBrush.style() == Qt::NoBrush) ? true : false; |
|
883 } |
|
884 |
|
880 /*! |
885 /*! |
881 \class QS60Style |
886 \class QS60Style |
882 \brief The QS60Style class provides a look and feel suitable for applications on S60. |
887 \brief The QS60Style class provides a look and feel suitable for applications on S60. |
883 \since 4.6 |
888 \since 4.6 |
884 \ingroup appearance |
889 \ingroup appearance |
933 #endif // QT_NO_SCROLLBAR |
938 #endif // QT_NO_SCROLLBAR |
934 #ifndef QT_NO_SLIDER |
939 #ifndef QT_NO_SLIDER |
935 case CC_Slider: |
940 case CC_Slider: |
936 if (const QStyleOptionSlider *optionSlider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
941 if (const QStyleOptionSlider *optionSlider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
937 |
942 |
938 // The groove is just a centered line. Maybe a qgn_graf_line_* at some point |
|
939 const QRect sliderGroove = subControlRect(control, optionSlider, SC_SliderGroove, widget); |
943 const QRect sliderGroove = subControlRect(control, optionSlider, SC_SliderGroove, widget); |
940 const QPoint sliderGrooveCenter = sliderGroove.center(); |
|
941 const bool horizontal = optionSlider->orientation == Qt::Horizontal; |
944 const bool horizontal = optionSlider->orientation == Qt::Horizontal; |
942 painter->save(); |
945 |
943 if (widget) |
946 //Highlight |
944 painter->setPen(widget->palette().windowText().color()); |
947 /* if (optionSlider->state & QStyle::State_HasFocus) |
945 if (horizontal) |
948 drawPrimitive(PE_FrameFocusRect, optionSlider, painter, widget);*/ |
946 painter->drawLine(0, sliderGrooveCenter.y(), sliderGroove.right(), sliderGrooveCenter.y()); |
949 |
947 else |
950 //Groove graphics |
948 painter->drawLine(sliderGrooveCenter.x(), 0, sliderGrooveCenter.x(), sliderGroove.bottom()); |
951 if (QS60StylePrivate::hasSliderGrooveGraphic()) { |
949 painter->restore(); |
952 const QS60StylePrivate::SkinElements grooveElement = horizontal ? |
950 |
953 QS60StylePrivate::SE_SliderGrooveHorizontal : |
954 QS60StylePrivate::SE_SliderGrooveVertical; |
|
955 QS60StylePrivate::drawSkinElement(grooveElement, painter, sliderGroove, flags); |
|
956 } else { |
|
957 const QRect sliderGroove = subControlRect(control, optionSlider, SC_SliderGroove, widget); |
|
958 const QPoint sliderGrooveCenter = sliderGroove.center(); |
|
959 const bool horizontal = optionSlider->orientation == Qt::Horizontal; |
|
960 painter->save(); |
|
961 if (widget) |
|
962 painter->setPen(widget->palette().windowText().color()); |
|
963 if (horizontal) |
|
964 painter->drawLine(0, sliderGrooveCenter.y(), sliderGroove.right(), sliderGrooveCenter.y()); |
|
965 else |
|
966 painter->drawLine(sliderGrooveCenter.x(), 0, sliderGrooveCenter.x(), sliderGroove.bottom()); |
|
967 painter->restore(); |
|
968 } |
|
969 |
|
970 //Handle graphics |
|
951 const QRect sliderHandle = subControlRect(control, optionSlider, SC_SliderHandle, widget); |
971 const QRect sliderHandle = subControlRect(control, optionSlider, SC_SliderHandle, widget); |
952 const QS60StylePrivate::SkinElements handleElement = |
972 QS60StylePrivate::SkinElements handleElement; |
953 horizontal ? QS60StylePrivate::SE_SliderHandleHorizontal : QS60StylePrivate::SE_SliderHandleVertical; |
973 if (optionSlider->state & QStyle::State_Sunken) |
974 handleElement = |
|
975 horizontal ? QS60StylePrivate::SE_SliderHandleSelectedHorizontal : QS60StylePrivate::SE_SliderHandleSelectedVertical; |
|
976 else |
|
977 handleElement = |
|
978 horizontal ? QS60StylePrivate::SE_SliderHandleHorizontal : QS60StylePrivate::SE_SliderHandleVertical; |
|
954 QS60StylePrivate::drawSkinElement(handleElement, painter, sliderHandle, flags); |
979 QS60StylePrivate::drawSkinElement(handleElement, painter, sliderHandle, flags); |
955 } |
980 } |
956 break; |
981 break; |
957 #endif // QT_NO_SLIDER |
982 #endif // QT_NO_SLIDER |
958 #ifndef QT_NO_COMBOBOX |
983 #ifndef QT_NO_COMBOBOX |
992 #ifndef QT_NO_TOOLBUTTON |
1017 #ifndef QT_NO_TOOLBUTTON |
993 case CC_ToolButton: |
1018 case CC_ToolButton: |
994 if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { |
1019 if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { |
995 const State bflags = toolBtn->state; |
1020 const State bflags = toolBtn->state; |
996 const QRect button(subControlRect(control, toolBtn, SC_ToolButton, widget)); |
1021 const QRect button(subControlRect(control, toolBtn, SC_ToolButton, widget)); |
1022 QRect menuRect = QRect(); |
|
1023 if (toolBtn->subControls & SC_ToolButtonMenu) |
|
1024 menuRect = subControlRect(control, toolBtn, SC_ToolButtonMenu, widget); |
|
1025 |
|
997 QStyleOptionToolButton toolButton = *toolBtn; |
1026 QStyleOptionToolButton toolButton = *toolBtn; |
998 |
1027 |
999 if (sub&SC_ToolButton) { |
1028 if (sub&SC_ToolButton) { |
1000 QStyleOption tool(0); |
1029 QStyleOption tool(0); |
1001 tool.palette = toolBtn->palette; |
1030 tool.palette = toolBtn->palette; |
1004 QToolBar *toolBar = 0; |
1033 QToolBar *toolBar = 0; |
1005 if (widget) |
1034 if (widget) |
1006 toolBar = qobject_cast<QToolBar *>(widget->parentWidget()); |
1035 toolBar = qobject_cast<QToolBar *>(widget->parentWidget()); |
1007 |
1036 |
1008 if (bflags & (State_Sunken | State_On | State_Raised)) { |
1037 if (bflags & (State_Sunken | State_On | State_Raised)) { |
1009 tool.rect = button; |
1038 tool.rect = button.unite(menuRect); |
1010 tool.state = bflags; |
1039 tool.state = bflags; |
1011 |
1040 |
1012 // todo: I'd like to move extension button next to where last button is |
1041 // todo: I'd like to move extension button next to where last button is |
1013 // however, the painter seems to want to clip the button rect even if I turn of the clipping. |
1042 // however, the painter seems to want to clip the button rect even if I turn of the clipping. |
1014 if (toolBar && (qobject_cast<const QToolBarExtension *>(widget))){ |
1043 if (toolBar && (qobject_cast<const QToolBarExtension *>(widget))){ |
1059 painter->restore(); |
1088 painter->restore(); |
1060 */ |
1089 */ |
1061 } else { |
1090 } else { |
1062 drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); |
1091 drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); |
1063 } |
1092 } |
1093 |
|
1094 if (toolButton.subControls & SC_ToolButtonMenu) { |
|
1095 tool.rect = menuRect; |
|
1096 tool.state = bflags; |
|
1097 drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget); |
|
1098 } |
|
1064 } |
1099 } |
1065 } |
1100 } |
1066 |
1101 |
1067 if (toolBtn->features & QStyleOptionToolButton::Arrow) { |
1102 if (toolBtn->features & QStyleOptionToolButton::Arrow) { |
1068 QStyle::PrimitiveElement pe; |
1103 QStyle::PrimitiveElement pe; |
1312 QStyleOptionViewItemV4 voptAdj = *vopt; |
1347 QStyleOptionViewItemV4 voptAdj = *vopt; |
1313 painter->save(); |
1348 painter->save(); |
1314 |
1349 |
1315 painter->setClipRect(voptAdj.rect); |
1350 painter->setClipRect(voptAdj.rect); |
1316 const bool isSelected = (vopt->state & QStyle::State_Selected); |
1351 const bool isSelected = (vopt->state & QStyle::State_Selected); |
1317 |
1352 const bool hasFocus = (vopt->state & QStyle::State_HasFocus); |
1318 bool isVisible = false; |
1353 |
1354 bool isScrollBarVisible = false; |
|
1319 int scrollBarWidth = 0; |
1355 int scrollBarWidth = 0; |
1320 QList<QScrollBar *> scrollBars = qFindChildren<QScrollBar *>(widget); |
1356 QList<QScrollBar *> scrollBars = qFindChildren<QScrollBar *>(widget); |
1321 for (int i = 0; i < scrollBars.size(); ++i) { |
1357 for (int i = 0; i < scrollBars.size(); ++i) { |
1322 QScrollBar *scrollBar = scrollBars.at(i); |
1358 QScrollBar *scrollBar = scrollBars.at(i); |
1323 if (scrollBar && scrollBar->orientation() == Qt::Vertical) { |
1359 if (scrollBar && scrollBar->orientation() == Qt::Vertical) { |
1324 isVisible = scrollBar->isVisible(); |
1360 isScrollBarVisible = scrollBar->isVisible(); |
1325 scrollBarWidth = scrollBar->size().width(); |
1361 scrollBarWidth = scrollBar->size().width(); |
1326 break; |
1362 break; |
1327 } |
1363 } |
1328 } |
1364 } |
1329 |
1365 |
1330 int rightValue = widget ? widget->contentsRect().right() : 0; |
1366 int rightValue = widget ? widget->contentsRect().right() : 0; |
1331 |
1367 |
1332 if (isVisible) |
1368 if (isScrollBarVisible) |
1333 rightValue -= scrollBarWidth; |
1369 rightValue -= scrollBarWidth; |
1334 |
1370 |
1335 if (voptAdj.rect.right() > rightValue) |
1371 if (voptAdj.rect.right() > rightValue) |
1336 voptAdj.rect.setRight(rightValue); |
1372 voptAdj.rect.setRight(rightValue); |
1337 |
1373 |
1338 const QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &voptAdj, widget); |
1374 const QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &voptAdj, widget); |
1339 QRect textRect = subElementRect(SE_ItemViewItemText, &voptAdj, widget); |
1375 QRect textRect = subElementRect(SE_ItemViewItemText, &voptAdj, widget); |
1376 const QAbstractItemView *itemView = qobject_cast<const QAbstractItemView *>(widget); |
|
1340 |
1377 |
1341 // draw themed background for table unless background brush has been defined. |
1378 // draw themed background for table unless background brush has been defined. |
1342 if (vopt->backgroundBrush == Qt::NoBrush) { |
1379 if (vopt->backgroundBrush == Qt::NoBrush) { |
1343 const QStyleOptionViewItemV4 *tableOption = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option); |
1380 if (itemView) { |
1344 const QTableView *table = qobject_cast<const QTableView *>(widget); |
1381 const QModelIndex index = vopt->index; |
1345 if (table && tableOption) { |
|
1346 const QModelIndex index = tableOption->index; |
|
1347 //todo: Draw cell background only once - for the first cell. |
1382 //todo: Draw cell background only once - for the first cell. |
1348 QStyleOptionViewItemV4 voptAdj2 = voptAdj; |
1383 QStyleOptionViewItemV4 voptAdj2 = voptAdj; |
1349 const QModelIndex indexFirst = table->model()->index(0,0); |
1384 const QModelIndex indexFirst = itemView->model()->index(0,0); |
1350 const QModelIndex indexLast = table->model()->index( |
1385 const QModelIndex indexLast = itemView->model()->index( |
1351 table->model()->rowCount()-1,table->model()->columnCount()-1); |
1386 itemView->model()->rowCount()-1,itemView->model()->columnCount()-1); |
1352 if (table->viewport()) |
1387 if (itemView->viewport()) |
1353 voptAdj2.rect = QRect( table->visualRect(indexFirst).topLeft(), |
1388 voptAdj2.rect = QRect( itemView->visualRect(indexFirst).topLeft(), |
1354 table->visualRect(indexLast).bottomRight()).intersect(table->viewport()->rect()); |
1389 itemView->visualRect(indexLast).bottomRight()).intersect(itemView->viewport()->rect()); |
1355 drawPrimitive(PE_PanelItemViewItem, &voptAdj2, painter, widget); |
1390 drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget); |
1356 } |
1391 } |
1357 } else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, option, painter, widget);} |
1392 } else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget);} |
1358 |
1393 |
1359 // draw the focus rect |
1394 // draw the focus rect |
1360 if (isSelected) { |
1395 if (isSelected | hasFocus) { |
1361 QRect highlightRect = option->rect.adjusted(1,1,-1,-1); |
1396 QRect highlightRect = option->rect.adjusted(1,1,-1,-1); |
1362 const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(widget); |
1397 QAbstractItemView::SelectionBehavior selectionBehavior = |
1363 if (view && view->selectionBehavior() != QAbstractItemView::SelectItems) { |
1398 itemView ? itemView->selectionBehavior() : QAbstractItemView::SelectItems; |
1399 if (selectionBehavior != QAbstractItemView::SelectItems) { |
|
1364 // set highlight rect so that it is continuous from cell to cell, yet sligthly |
1400 // set highlight rect so that it is continuous from cell to cell, yet sligthly |
1365 // smaller than cell rect |
1401 // smaller than cell rect |
1366 int xBeginning = 0, yBeginning = 0, xEnd = 0, yEnd = 0; |
1402 int xBeginning = 0, yBeginning = 0, xEnd = 0, yEnd = 0; |
1367 if (view->selectionBehavior() == QAbstractItemView::SelectRows) { |
1403 if (selectionBehavior == QAbstractItemView::SelectRows) { |
1368 yBeginning = 1; yEnd = -1; |
1404 yBeginning = 1; yEnd = -1; |
1369 if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning) |
1405 if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning) |
1370 xBeginning = 1; |
1406 xBeginning = 1; |
1371 else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End) |
1407 else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End) |
1372 xEnd = -1; |
1408 xEnd = -1; |
1373 } else if (view->selectionBehavior() == QAbstractItemView::SelectColumns) { |
1409 } else if (selectionBehavior == QAbstractItemView::SelectColumns) { |
1374 xBeginning = 1; xEnd = -1; |
1410 xBeginning = 1; xEnd = -1; |
1375 if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning) |
1411 if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning) |
1376 yBeginning = 1; |
1412 yBeginning = 1; |
1377 else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End) |
1413 else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End) |
1378 yEnd = -1; |
1414 yEnd = -1; |
1379 } |
1415 } |
1380 highlightRect = option->rect.adjusted(xBeginning, yBeginning, xEnd, xBeginning); |
1416 highlightRect = option->rect.adjusted(xBeginning, yBeginning, xEnd, yEnd); |
1381 } |
1417 } |
1382 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, highlightRect, flags); |
1418 if (vopt->showDecorationSelected && |
1419 (vopt->palette.highlight().color() == QS60StylePrivate::themePalette()->highlight().color())) |
|
1420 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, highlightRect, flags); |
|
1421 else |
|
1422 painter->fillRect(highlightRect, vopt->palette.highlight()); |
|
1383 } |
1423 } |
1384 |
1424 |
1385 // draw the icon |
1425 // draw the icon |
1386 const QIcon::Mode mode = (voptAdj.state & QStyle::State_Enabled) ? QIcon::Normal : QIcon::Disabled; |
1426 const QIcon::Mode mode = (voptAdj.state & QStyle::State_Enabled) ? QIcon::Normal : QIcon::Disabled; |
1387 const QIcon::State state = voptAdj.state & QStyle::State_Open ? QIcon::On : QIcon::Off; |
1427 const QIcon::State state = voptAdj.state & QStyle::State_Open ? QIcon::On : QIcon::Off; |
1388 voptAdj.icon.paint(painter, iconRect, voptAdj.decorationAlignment, mode, state); |
1428 voptAdj.icon.paint(painter, iconRect, voptAdj.decorationAlignment, mode, state); |
1389 |
1429 |
1390 // Draw selection check mark. Show check mark only in multi selection modes. |
1430 // Draw selection check mark. Show check mark only in multi selection modes. |
1391 if (const QListView *listView = (qobject_cast<const QListView *>(widget))) { |
1431 if (itemView) { |
1392 const bool singleSelection = |
1432 const bool singleSelection = |
1393 listView && |
1433 (itemView->selectionMode() == QAbstractItemView::SingleSelection || |
1394 (listView->selectionMode() == QAbstractItemView::SingleSelection || |
1434 itemView->selectionMode() == QAbstractItemView::NoSelection); |
1395 listView->selectionMode() == QAbstractItemView::NoSelection); |
|
1396 const QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, &voptAdj, widget); |
1435 const QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, &voptAdj, widget); |
1436 |
|
1437 QStyleOptionViewItemV4 checkMarkOption(voptAdj); |
|
1438 // Draw selection mark. |
|
1397 if (voptAdj.state & QStyle::State_Selected && !singleSelection) { |
1439 if (voptAdj.state & QStyle::State_Selected && !singleSelection) { |
1398 QStyleOptionViewItemV4 option(voptAdj); |
1440 checkMarkOption.rect = selectionRect; |
1399 option.rect = selectionRect; |
1441 drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget); |
1400 // Draw selection mark. |
|
1401 drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &option, painter, widget); |
|
1402 if ( textRect.right() > selectionRect.left() ) |
1442 if ( textRect.right() > selectionRect.left() ) |
1403 textRect.setRight(selectionRect.left()); |
1443 textRect.setRight(selectionRect.left()); |
1404 } else if (singleSelection && |
1444 } else if (singleSelection && |
1405 voptAdj.features & QStyleOptionViewItemV2::HasCheckIndicator) { |
1445 voptAdj.features & QStyleOptionViewItemV2::HasCheckIndicator && |
1406 // draw the check mark |
1446 selectionRect.isValid()) { |
1407 if (selectionRect.isValid()) { |
1447 checkMarkOption.rect = selectionRect; |
1408 QStyleOptionViewItemV4 option(*vopt); |
1448 checkMarkOption.state = checkMarkOption.state & ~QStyle::State_HasFocus; |
1409 option.rect = selectionRect; |
1449 |
1410 option.state = option.state & ~QStyle::State_HasFocus; |
1450 switch (vopt->checkState) { |
1411 |
1451 case Qt::Unchecked: |
1412 switch (vopt->checkState) { |
1452 checkMarkOption.state |= QStyle::State_Off; |
1413 case Qt::Unchecked: |
1453 break; |
1414 option.state |= QStyle::State_Off; |
1454 case Qt::PartiallyChecked: |
1415 break; |
1455 checkMarkOption.state |= QStyle::State_NoChange; |
1416 case Qt::PartiallyChecked: |
1456 break; |
1417 option.state |= QStyle::State_NoChange; |
1457 case Qt::Checked: |
1418 break; |
1458 checkMarkOption.state |= QStyle::State_On; |
1419 case Qt::Checked: |
1459 break; |
1420 option.state |= QStyle::State_On; |
|
1421 break; |
|
1422 } |
|
1423 drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &option, painter, widget); |
|
1424 } |
1460 } |
1461 drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget); |
|
1425 } |
1462 } |
1426 } |
1463 } |
1427 |
1464 |
1428 // draw the text |
1465 // draw the text |
1429 if (!voptAdj.text.isEmpty()) { |
1466 if (!voptAdj.text.isEmpty()) { |
1430 const QStyleOptionViewItemV4 *tableOption = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option); |
|
1431 if (isSelected) { |
1467 if (isSelected) { |
1432 if (qobject_cast<const QTableView *>(widget) && tableOption) |
1468 if (qobject_cast<const QTableView *>(widget)) |
1433 voptAdj.palette.setColor( |
1469 voptAdj.palette.setColor( |
1434 QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0)); |
1470 QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0)); |
1435 else |
1471 else |
1436 voptAdj.palette.setColor( |
1472 voptAdj.palette.setColor( |
1437 QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0)); |
1473 QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0)); |
1666 uint text_flags = Qt::AlignLeading | Qt::TextShowMnemonic | Qt::TextDontClip |
1702 uint text_flags = Qt::AlignLeading | Qt::TextShowMnemonic | Qt::TextDontClip |
1667 | Qt::TextSingleLine | Qt::AlignVCenter; |
1703 | Qt::TextSingleLine | Qt::AlignVCenter; |
1668 if (!styleHint(SH_UnderlineShortcut, menuItem, widget)) |
1704 if (!styleHint(SH_UnderlineShortcut, menuItem, widget)) |
1669 text_flags |= Qt::TextHideMnemonic; |
1705 text_flags |= Qt::TextHideMnemonic; |
1670 |
1706 |
1671 QRect iconRect = |
|
1672 subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget); |
|
1673 QRect textRect = subElementRect(SE_ItemViewItemText, &optionMenuItem, widget); |
|
1674 |
|
1675 if ((option->state & State_Selected) && (option->state & State_Enabled)) |
1707 if ((option->state & State_Selected) && (option->state & State_Enabled)) |
1676 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); |
1708 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); |
1709 |
|
1710 QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget); |
|
1711 QRect textRect = subElementRect(SE_ItemViewItemText, &optionMenuItem, widget); |
|
1677 |
1712 |
1678 //todo: move the vertical spacing stuff into subElementRect |
1713 //todo: move the vertical spacing stuff into subElementRect |
1679 const int vSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutVerticalSpacing); |
1714 const int vSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutVerticalSpacing); |
1680 if (checkable){ |
1715 if (checkable){ |
1716 const int hSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing); |
|
1681 QStyleOptionMenuItem optionCheckBox; |
1717 QStyleOptionMenuItem optionCheckBox; |
1682 optionCheckBox.QStyleOption::operator=(*menuItem); |
1718 optionCheckBox.QStyleOptionMenuItem::operator=(*menuItem); |
1683 optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth)); |
1719 optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth)); |
1684 optionCheckBox.rect.setHeight(pixelMetric(PM_IndicatorHeight)); |
1720 optionCheckBox.rect.setHeight(pixelMetric(PM_IndicatorHeight)); |
1685 const int moveByX = optionCheckBox.rect.width()+vSpacing; |
1721 const int moveByX = optionCheckBox.rect.width()+vSpacing; |
1686 if (optionMenuItem.direction == Qt::LeftToRight) { |
1722 if (optionMenuItem.direction == Qt::LeftToRight) { |
1687 textRect.translate(moveByX,0); |
1723 textRect.translate(moveByX,0); |
1688 iconRect.translate(moveByX, 0); |
1724 iconRect.translate(moveByX, 0); |
1689 iconRect.setWidth(iconRect.width()+vSpacing); |
1725 iconRect.setWidth(iconRect.width()+vSpacing); |
1690 textRect.setWidth(textRect.width()-moveByX-vSpacing); |
1726 textRect.setWidth(textRect.width()-moveByX-vSpacing); |
1727 optionCheckBox.rect.translate(vSpacing/2, hSpacing/2); |
|
1691 } else { |
1728 } else { |
1692 textRect.setWidth(textRect.width()-moveByX); |
1729 textRect.setWidth(textRect.width()-moveByX); |
1693 iconRect.setWidth(iconRect.width()+vSpacing); |
1730 iconRect.setWidth(iconRect.width()+vSpacing); |
1694 iconRect.translate(-optionCheckBox.rect.width()-vSpacing, 0); |
1731 iconRect.translate(-optionCheckBox.rect.width()-vSpacing, 0); |
1695 optionCheckBox.rect.translate(textRect.width()+iconRect.width(),0); |
1732 optionCheckBox.rect.translate(textRect.width()+iconRect.width(),0); |
1720 arrowOptions.rect.setWidth(indicatorWidth); |
1757 arrowOptions.rect.setWidth(indicatorWidth); |
1721 //by default sub menu indicator in S60 points to east,so here icon |
1758 //by default sub menu indicator in S60 points to east,so here icon |
1722 // direction is set to north (and south when in RightToLeft) |
1759 // direction is set to north (and south when in RightToLeft) |
1723 const QS60StylePrivate::SkinElementFlag arrowDirection = (arrowOptions.direction == Qt::LeftToRight) ? |
1760 const QS60StylePrivate::SkinElementFlag arrowDirection = (arrowOptions.direction == Qt::LeftToRight) ? |
1724 QS60StylePrivate::SF_PointNorth : QS60StylePrivate::SF_PointSouth; |
1761 QS60StylePrivate::SF_PointNorth : QS60StylePrivate::SF_PointSouth; |
1762 painter->save(); |
|
1763 painter->setPen(option->palette.windowText().color()); |
|
1725 QS60StylePrivate::drawSkinPart(QS60StyleEnums::SP_QgnIndiSubMenu, painter, arrowOptions.rect, |
1764 QS60StylePrivate::drawSkinPart(QS60StyleEnums::SP_QgnIndiSubMenu, painter, arrowOptions.rect, |
1726 (flags | QS60StylePrivate::SF_ColorSkinned | arrowDirection)); |
1765 (flags | QS60StylePrivate::SF_ColorSkinned | arrowDirection)); |
1766 painter->restore(); |
|
1727 } |
1767 } |
1728 |
1768 |
1729 //draw text |
1769 //draw text |
1730 if (!enabled){ |
1770 if (!enabled){ |
1731 //In s60, if something becomes disabled, it is removed from menu, so no native look-alike available. |
1771 //In s60, if something becomes disabled, it is removed from menu, so no native look-alike available. |
1749 case CE_MenuBarEmptyArea: |
1789 case CE_MenuBarEmptyArea: |
1750 break; |
1790 break; |
1751 #endif //QT_NO_MENUBAR |
1791 #endif //QT_NO_MENUBAR |
1752 |
1792 |
1753 case CE_HeaderSection: |
1793 case CE_HeaderSection: |
1754 if ( const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { |
1794 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { |
1755 painter->save(); |
1795 painter->save(); |
1756 QPen linePen = QPen(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 1, header)); |
1796 QPen linePen = QPen(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 1, header)); |
1757 const int penWidth = (header->orientation == Qt::Horizontal) ? |
1797 const int penWidth = (header->orientation == Qt::Horizontal) ? |
1758 linePen.width()+QS60StylePrivate::pixelMetric(PM_Custom_BoldLineWidth) |
1798 linePen.width()+QS60StylePrivate::pixelMetric(PM_Custom_BoldLineWidth) |
1759 : linePen.width()+QS60StylePrivate::pixelMetric(PM_Custom_ThinLineWidth); |
1799 : linePen.width()+QS60StylePrivate::pixelMetric(PM_Custom_ThinLineWidth); |
1767 } else { |
1807 } else { |
1768 painter->drawLine(header->rect.topLeft(), header->rect.bottomLeft()); |
1808 painter->drawLine(header->rect.topLeft(), header->rect.bottomLeft()); |
1769 } |
1809 } |
1770 } |
1810 } |
1771 painter->restore(); |
1811 painter->restore(); |
1812 |
|
1813 //Draw corner button as normal pushButton. |
|
1814 if (qobject_cast<const QAbstractButton *>(widget)) { |
|
1815 //Make cornerButton slightly smaller so that it is not on top of table border graphic. |
|
1816 QStyleOptionHeader subopt = *header; |
|
1817 const int borderTweak = |
|
1818 QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth)>>1; |
|
1819 if (subopt.direction == Qt::LeftToRight) |
|
1820 subopt.rect.adjust(borderTweak, borderTweak, 0, -borderTweak); |
|
1821 else |
|
1822 subopt.rect.adjust(0, borderTweak, -borderTweak, -borderTweak); |
|
1823 drawPrimitive(PE_PanelButtonBevel, &subopt, painter, widget); |
|
1824 } else if ((header->palette.brush(QPalette::Button) != Qt::transparent)) { |
|
1825 //Draw non-themed background. Background for theme is drawn in CE_ShapedFrame |
|
1826 //to get continuous theme graphic across all the header cells. |
|
1827 qDrawShadePanel(painter, header->rect, header->palette, |
|
1828 header->state & (State_Sunken | State_On), penWidth, |
|
1829 &header->palette.brush(QPalette::Button)); |
|
1830 } |
|
1772 } |
1831 } |
1773 break; |
1832 break; |
1774 case CE_HeaderEmptyArea: // no need to draw this |
1833 case CE_HeaderEmptyArea: // no need to draw this |
1775 break; |
1834 break; |
1776 case CE_Header: |
1835 case CE_Header: |
1828 } |
1887 } |
1829 } |
1888 } |
1830 break; |
1889 break; |
1831 #endif //QT_NO_TOOLBAR |
1890 #endif //QT_NO_TOOLBAR |
1832 case CE_ShapedFrame: |
1891 case CE_ShapedFrame: |
1833 if (qobject_cast<const QTextEdit *>(widget)) { |
1892 if (const QTextEdit *textEdit = qobject_cast<const QTextEdit *>(widget)) { |
1834 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_Editor, painter, option->rect, flags); |
1893 const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option); |
1894 if (QS60StylePrivate::canDrawThemeBackground(frame->palette.base())) |
|
1895 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_Editor, painter, option->rect, flags); |
|
1896 else |
|
1897 QCommonStyle::drawControl(element, option, painter, widget); |
|
1835 } else if (qobject_cast<const QTableView *>(widget)) { |
1898 } else if (qobject_cast<const QTableView *>(widget)) { |
1836 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableItem, painter, option->rect, flags); |
1899 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableItem, painter, option->rect, flags); |
1837 } else if (const QHeaderView *header = qobject_cast<const QHeaderView *>(widget)) { |
1900 } else if (const QHeaderView *header = qobject_cast<const QHeaderView *>(widget)) { |
1838 if (header->orientation() == Qt::Horizontal) { |
1901 //QS60style draws header background here instead of in each headersection, to get |
1839 QRect headerRect = option->rect; |
1902 //continuous graphic from section to section. |
1903 QS60StylePrivate::SkinElementFlags adjustableFlags = flags; |
|
1904 QRect headerRect = option->rect; |
|
1905 if (header->orientation() != Qt::Horizontal) { |
|
1906 //todo: update to horizontal table graphic |
|
1907 adjustableFlags = (adjustableFlags | QS60StylePrivate::SF_PointWest); |
|
1908 } else { |
|
1840 const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
1909 const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
1841 headerRect.adjust(0,frameWidth,-2*frameWidth,0); |
1910 if (option->direction == Qt::LeftToRight) |
1842 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableHeaderItem, painter, headerRect, flags); |
1911 headerRect.adjust(-2*frameWidth, 0, 0, 0); |
1843 } else { |
1912 else |
1844 //todo: update to horizontal table graphic |
1913 headerRect.adjust(0, 0, 2*frameWidth, 0); |
1845 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableHeaderItem, painter, option->rect, flags | QS60StylePrivate::SF_PointWest); |
1914 } |
1846 } |
1915 if (option->palette.brush(QPalette::Button).color() == Qt::transparent) |
1916 QS60StylePrivate::drawSkinElement( |
|
1917 QS60StylePrivate::SE_TableHeaderItem, painter, headerRect, adjustableFlags); |
|
1918 |
|
1847 } else if (qobject_cast<const QFrame *>(widget)) { |
1919 } else if (qobject_cast<const QFrame *>(widget)) { |
1848 QCommonStyle::drawControl(element, option, painter, widget); |
1920 QCommonStyle::drawControl(element, option, painter, widget); |
1849 } |
1921 } |
1850 break; |
1922 break; |
1851 case CE_MenuScroller: |
1923 case CE_MenuScroller: |
1887 painter->setPen(QPen(option->palette.color(QPalette::Text), penWidth)); |
1959 painter->setPen(QPen(option->palette.color(QPalette::Text), penWidth)); |
1888 painter->drawRoundedRect(adjustedRect, roundRectRadius, roundRectRadius); |
1960 painter->drawRoundedRect(adjustedRect, roundRectRadius, roundRectRadius); |
1889 painter->restore(); |
1961 painter->restore(); |
1890 } |
1962 } |
1891 break; |
1963 break; |
1964 case CE_Splitter: |
|
1965 if (option->state & State_Sunken && option->state & State_Enabled) { |
|
1966 painter->save(); |
|
1967 painter->setOpacity(0.5); |
|
1968 painter->setBrush(QS60StylePrivate::themePalette()->light()); |
|
1969 painter->setRenderHint(QPainter::Antialiasing); |
|
1970 const qreal roundRectRadius = 4 * goldenRatio; |
|
1971 painter->drawRoundedRect(option->rect, roundRectRadius, roundRectRadius); |
|
1972 painter->restore(); |
|
1973 } |
|
1974 break; |
|
1892 default: |
1975 default: |
1893 QCommonStyle::drawControl(element, option, painter, widget); |
1976 QCommonStyle::drawControl(element, option, painter, widget); |
1894 } |
1977 } |
1895 } |
1978 } |
1896 |
1979 |
1897 /*! |
1980 /*! |
1898 \reimp |
1981 \reimp |
1899 */ |
1982 */ |
1900 void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const |
1983 void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const |
1901 { |
1984 { |
1985 Q_D(const QS60Style); |
|
1902 const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled; |
1986 const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled; |
1987 bool commonStyleDraws = false; |
|
1988 |
|
1903 switch (element) { |
1989 switch (element) { |
1904 #ifndef QT_NO_LINEEDIT |
1990 #ifndef QT_NO_LINEEDIT |
1905 case PE_PanelLineEdit: |
1991 case PE_PanelLineEdit: |
1906 if (const QStyleOptionFrame *lineEdit = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
1992 if (const QStyleOptionFrame *lineEdit = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
1907 #ifndef QT_NO_COMBOBOX |
1993 #ifndef QT_NO_COMBOBOX |
1908 if (widget && qobject_cast<const QComboBox *>(widget->parentWidget())) |
1994 if (widget && qobject_cast<const QComboBox *>(widget->parentWidget())) |
1909 break; |
1995 break; |
1910 #endif |
1996 #endif |
1911 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_FrameLineEdit, |
1997 if (QS60StylePrivate::canDrawThemeBackground(option->palette.base())) |
1912 painter, option->rect, flags); |
1998 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_FrameLineEdit, painter, option->rect, flags); |
1999 else |
|
2000 commonStyleDraws = true; |
|
1913 } |
2001 } |
1914 break; |
2002 break; |
1915 #endif // QT_NO_LINEEDIT |
2003 #endif // QT_NO_LINEEDIT |
1916 case PE_IndicatorCheckBox: |
2004 case PE_IndicatorCheckBox: |
1917 { |
2005 { |
1918 const QRect indicatorRect = option->rect; |
|
1919 // Draw checkbox indicator as color skinned graphics. |
2006 // Draw checkbox indicator as color skinned graphics. |
1920 const QS60StyleEnums::SkinParts skinPart = (option->state & QStyle::State_On) ? |
2007 const QS60StyleEnums::SkinParts skinPart = (option->state & QStyle::State_On) ? |
1921 QS60StyleEnums::SP_QgnIndiCheckboxOn : QS60StyleEnums::SP_QgnIndiCheckboxOff; |
2008 QS60StyleEnums::SP_QgnIndiCheckboxOn : QS60StyleEnums::SP_QgnIndiCheckboxOff; |
1922 QS60StylePrivate::drawSkinPart(skinPart, painter, indicatorRect, |
2009 painter->save(); |
1923 (flags | QS60StylePrivate::SF_ColorSkinned)); |
2010 |
2011 QColor themeColor = QS60StylePrivate::themePalette()->windowText().color(); |
|
2012 QColor windowTextColor = option->palette.windowText().color(); |
|
2013 |
|
2014 if (themeColor != windowTextColor) |
|
2015 painter->setPen(windowTextColor); |
|
2016 |
|
2017 QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags | QS60StylePrivate::SF_ColorSkinned ); |
|
2018 painter->restore(); |
|
1924 } |
2019 } |
1925 break; |
2020 break; |
1926 case PE_IndicatorViewItemCheck: |
2021 case PE_IndicatorViewItemCheck: |
1927 #ifndef QT_NO_ITEMVIEWS |
2022 #ifndef QT_NO_ITEMVIEWS |
1928 if (const QListView *listItem = (qobject_cast<const QListView *>(widget))) { |
2023 if (const QListView *listItem = (qobject_cast<const QListView *>(widget))) { |
1956 const qreal scaler = 1 + (reduceWidth/rectWidth); |
2051 const qreal scaler = 1 + (reduceWidth/rectWidth); |
1957 buttonRect.setWidth((int)((buttonRect.width()-reduceWidth) * scaler)); |
2052 buttonRect.setWidth((int)((buttonRect.width()-reduceWidth) * scaler)); |
1958 buttonRect.setHeight((int)(buttonRect.height() * scaler)); |
2053 buttonRect.setHeight((int)(buttonRect.height() * scaler)); |
1959 // move the rect up for half of the new height-gain |
2054 // move the rect up for half of the new height-gain |
1960 const int newY = (buttonRect.bottomRight().y() - option->rect.bottomRight().y()) >> 1 ; |
2055 const int newY = (buttonRect.bottomRight().y() - option->rect.bottomRight().y()) >> 1 ; |
1961 buttonRect.adjust(0,-newY,0,-newY); |
2056 buttonRect.adjust(0, -newY, -1, -newY); |
2057 |
|
2058 painter->save(); |
|
2059 QColor themeColor = d->s60Color(QS60StyleEnums::CL_QsnTextColors, 6, option); |
|
2060 QColor buttonTextColor = option->palette.buttonText().color(); |
|
2061 if (themeColor != buttonTextColor) |
|
2062 painter->setPen(buttonTextColor); |
|
2063 else |
|
2064 painter->setPen(themeColor); |
|
1962 |
2065 |
1963 // Draw radiobutton indicator as color skinned graphics. |
2066 // Draw radiobutton indicator as color skinned graphics. |
1964 QS60StyleEnums::SkinParts skinPart = (option->state & QStyle::State_On) ? |
2067 QS60StyleEnums::SkinParts skinPart = (option->state & QStyle::State_On) ? |
1965 QS60StyleEnums::SP_QgnIndiRadiobuttOn : QS60StyleEnums::SP_QgnIndiRadiobuttOff; |
2068 QS60StyleEnums::SP_QgnIndiRadiobuttOn : QS60StyleEnums::SP_QgnIndiRadiobuttOff; |
1966 QS60StylePrivate::drawSkinPart(skinPart, painter, buttonRect, |
2069 QS60StylePrivate::drawSkinPart(skinPart, painter, buttonRect, |
1967 (flags | QS60StylePrivate::SF_ColorSkinned)); |
2070 (flags | QS60StylePrivate::SF_ColorSkinned)); |
2071 painter->restore(); |
|
1968 } |
2072 } |
1969 break; |
2073 break; |
1970 case PE_PanelButtonCommand: |
2074 case PE_PanelButtonCommand: |
1971 case PE_PanelButtonTool: |
2075 case PE_PanelButtonTool: |
1972 case PE_PanelButtonBevel: |
2076 case PE_PanelButtonBevel: |
1973 case PE_FrameButtonBevel: { |
2077 case PE_FrameButtonBevel: { |
1974 const bool isPressed = option->state & QStyle::State_Sunken; |
2078 if (QS60StylePrivate::canDrawThemeBackground(option->palette.base())) { |
1975 const QS60StylePrivate::SkinElements skinElement = |
2079 const bool isPressed = option->state & QStyle::State_Sunken; |
1976 isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal; |
2080 const QS60StylePrivate::SkinElements skinElement = |
1977 QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); |
2081 isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal; |
2082 QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); |
|
2083 } else { |
|
2084 commonStyleDraws = true; |
|
2085 } |
|
1978 } |
2086 } |
1979 break; |
2087 break; |
1980 #ifndef QT_NO_TOOLBUTTON |
2088 #ifndef QT_NO_TOOLBUTTON |
1981 case PE_IndicatorArrowDown: |
2089 case PE_IndicatorArrowDown: |
1982 case PE_IndicatorArrowLeft: |
2090 case PE_IndicatorArrowLeft: |
1999 #ifndef QT_NO_SPINBOX |
2107 #ifndef QT_NO_SPINBOX |
2000 case PE_IndicatorSpinDown: |
2108 case PE_IndicatorSpinDown: |
2001 case PE_IndicatorSpinUp: |
2109 case PE_IndicatorSpinUp: |
2002 if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
2110 if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
2003 QStyleOptionSpinBox optionSpinBox = *spinBox; |
2111 QStyleOptionSpinBox optionSpinBox = *spinBox; |
2004 const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ? |
2112 if (QS60StylePrivate::canDrawThemeBackground(optionSpinBox.palette.base())) { |
2005 QS60StyleEnums::SP_QgnGrafScrollArrowUp : |
2113 const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ? |
2006 QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
2114 QS60StyleEnums::SP_QgnGrafScrollArrowUp : |
2007 const int adjustment = qMin(optionSpinBox.rect.width(), optionSpinBox.rect.height())/6; |
2115 QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
2008 optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment ); |
2116 const int adjustment = qMin(optionSpinBox.rect.width(), optionSpinBox.rect.height())/6; |
2009 QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect,flags); |
2117 optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment ); |
2118 QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect,flags); |
|
2119 } else { |
|
2120 commonStyleDraws = true; |
|
2121 } |
|
2010 } |
2122 } |
2011 #ifndef QT_NO_COMBOBOX |
2123 #ifndef QT_NO_COMBOBOX |
2012 else if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
2124 else if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
2013 // We want to draw down arrow here for comboboxes as well. |
2125 if (QS60StylePrivate::canDrawThemeBackground( option->palette.base())) { |
2014 const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
2126 // We want to draw down arrow here for comboboxes as well. |
2015 QStyleOptionFrame comboBox = *cmb; |
2127 const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
2016 const int adjustment = qMin(comboBox.rect.width(), comboBox.rect.height())/6; |
2128 QStyleOptionFrame comboBox = *cmb; |
2017 comboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment ); |
2129 const int adjustment = qMin(comboBox.rect.width(), comboBox.rect.height())/6; |
2018 QS60StylePrivate::drawSkinPart(part, painter, comboBox.rect,flags); |
2130 comboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment ); |
2131 QS60StylePrivate::drawSkinPart(part, painter, comboBox.rect,flags); |
|
2132 } else { |
|
2133 commonStyleDraws = true; |
|
2134 } |
|
2019 } |
2135 } |
2020 #endif //QT_NO_COMBOBOX |
2136 #endif //QT_NO_COMBOBOX |
2021 break; |
2137 break; |
2022 case PE_IndicatorSpinMinus: |
2138 case PE_IndicatorSpinMinus: |
2023 case PE_IndicatorSpinPlus: |
2139 case PE_IndicatorSpinPlus: |
2043 #endif //QT_NO_COMBOBOX |
2159 #endif //QT_NO_COMBOBOX |
2044 #ifndef QT_NO_MENU |
2160 #ifndef QT_NO_MENU |
2045 || qobject_cast<const QMenu *> (widget) |
2161 || qobject_cast<const QMenu *> (widget) |
2046 #endif //QT_NO_MENU |
2162 #endif //QT_NO_MENU |
2047 ) { |
2163 ) { |
2048 QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_OptionsMenu; |
2164 if (QS60StylePrivate::canDrawThemeBackground(option->palette.base())) |
2049 QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); |
2165 QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_OptionsMenu, painter, option->rect, flags); |
2166 else |
|
2167 commonStyleDraws = true; |
|
2050 } |
2168 } |
2051 break; |
2169 break; |
2052 case PE_FrameWindow: |
2170 case PE_FrameWindow: |
2053 case PE_FrameTabWidget: |
2171 case PE_FrameTabWidget: |
2054 if (const QStyleOptionTabWidgetFrame *tabFrame = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) { |
2172 if (const QStyleOptionTabWidgetFrame *tabFrame = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) { |
2131 } else if (upLine && downLine) { |
2249 } else if (upLine && downLine) { |
2132 skinPart = QS60StyleEnums::SP_QgnIndiHlLineStraight; |
2250 skinPart = QS60StyleEnums::SP_QgnIndiHlLineStraight; |
2133 drawSkinPart = true; |
2251 drawSkinPart = true; |
2134 } |
2252 } |
2135 |
2253 |
2136 if ( drawSkinPart ) |
2254 if (drawSkinPart) |
2137 QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags); |
2255 QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags); |
2138 |
2256 |
2139 if (option->state & State_Children) { |
2257 if (option->state & State_Children) { |
2140 QS60StyleEnums::SkinParts skinPart = |
2258 QS60StyleEnums::SkinParts skinPart = |
2141 (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper; |
2259 (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper; |
2151 QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, flags); |
2269 QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, flags); |
2152 } |
2270 } |
2153 } |
2271 } |
2154 break; |
2272 break; |
2155 |
2273 |
2274 case PE_PanelScrollAreaCorner: |
|
2275 break; |
|
2276 |
|
2156 // todo: items are below with #ifdefs "just in case". in final version, remove all non-required cases |
2277 // todo: items are below with #ifdefs "just in case". in final version, remove all non-required cases |
2157 case PE_FrameLineEdit: |
2278 case PE_FrameLineEdit: |
2158 case PE_IndicatorButtonDropDown: |
|
2159 case PE_IndicatorDockWidgetResizeHandle: |
2279 case PE_IndicatorDockWidgetResizeHandle: |
2160 case PE_PanelTipLabel: |
2280 case PE_PanelTipLabel: |
2161 case PE_PanelScrollAreaCorner: |
|
2162 |
2281 |
2163 #ifndef QT_NO_TABBAR |
2282 #ifndef QT_NO_TABBAR |
2164 case PE_IndicatorTabTear: // No tab tear in S60 |
2283 case PE_IndicatorTabTear: // No tab tear in S60 |
2165 #endif // QT_NO_TABBAR |
2284 #endif // QT_NO_TABBAR |
2166 case PE_FrameDefaultButton: |
2285 case PE_FrameDefaultButton: |
2177 case PE_IndicatorColumnViewArrow: |
2296 case PE_IndicatorColumnViewArrow: |
2178 case PE_IndicatorItemViewItemDrop: |
2297 case PE_IndicatorItemViewItemDrop: |
2179 #endif //QT_NO_COLUMNVIEW |
2298 #endif //QT_NO_COLUMNVIEW |
2180 case PE_FrameTabBarBase: // since tabs are in S60 always in navipane, let's use common style for tab base in Qt. |
2299 case PE_FrameTabBarBase: // since tabs are in S60 always in navipane, let's use common style for tab base in Qt. |
2181 default: |
2300 default: |
2301 commonStyleDraws = true; |
|
2302 } |
|
2303 if (commonStyleDraws) { |
|
2182 QCommonStyle::drawPrimitive(element, option, painter, widget); |
2304 QCommonStyle::drawPrimitive(element, option, painter, widget); |
2183 } |
2305 } |
2184 } |
2306 } |
2185 |
2307 |
2186 /*! \reimp */ |
2308 /*! \reimp */ |
2188 { |
2310 { |
2189 int metricValue = QS60StylePrivate::pixelMetric(metric); |
2311 int metricValue = QS60StylePrivate::pixelMetric(metric); |
2190 if (metricValue == KNotFound) |
2312 if (metricValue == KNotFound) |
2191 metricValue = QCommonStyle::pixelMetric(metric, option, widget); |
2313 metricValue = QCommonStyle::pixelMetric(metric, option, widget); |
2192 |
2314 |
2193 if (metric == PM_SubMenuOverlap && widget){ |
2315 if (metric == PM_SubMenuOverlap && widget) { |
2194 const QMenu *menu = qobject_cast<const QMenu *>(widget); |
2316 const QMenu *menu = qobject_cast<const QMenu *>(widget); |
2195 if (menu && menu->activeAction() && menu->activeAction()->menu()) { |
2317 if (menu && menu->activeAction() && menu->activeAction()->menu()) { |
2196 const int menuWidth = menu->activeAction()->menu()->sizeHint().width(); |
2318 const int menuWidth = menu->activeAction()->menu()->sizeHint().width(); |
2197 metricValue = -menuWidth; |
2319 metricValue = -menuWidth; |
2198 } |
2320 } |
2199 } |
2321 } |
2322 //if layout direction is mirrored, switch left and right border margins |
|
2323 if (option && option->direction == Qt::RightToLeft) { |
|
2324 if (metric == PM_LayoutLeftMargin) |
|
2325 metricValue = QS60StylePrivate::pixelMetric(PM_LayoutRightMargin); |
|
2326 else if (metric == PM_LayoutRightMargin) |
|
2327 metricValue = QS60StylePrivate::pixelMetric(PM_LayoutLeftMargin); |
|
2328 } |
|
2200 return metricValue; |
2329 return metricValue; |
2201 } |
2330 } |
2202 |
2331 |
2203 /*! \reimp */ |
2332 /*! \reimp */ |
2204 QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, |
2333 QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, |
2205 const QSize &csz, const QWidget *widget) const |
2334 const QSize &csz, const QWidget *widget) const |
2206 { |
2335 { |
2207 QSize sz(csz); |
2336 QSize sz(csz); |
2208 switch (ct) { |
2337 switch (ct) { |
2338 case CT_ToolButton: |
|
2339 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
|
2340 //FIXME properly - style should calculate the location of border frame-part |
|
2341 sz += QSize(2*pixelMetric(PM_ButtonMargin), 2*pixelMetric(PM_ButtonMargin)); |
|
2342 if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) |
|
2343 if (toolBtn->subControls & SC_ToolButtonMenu) |
|
2344 sz += QSize(pixelMetric(PM_MenuButtonIndicator),0); |
|
2345 break; |
|
2209 case CT_PushButton: |
2346 case CT_PushButton: |
2210 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2347 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2348 //FIXME properly - style should calculate the location of border frame-part |
|
2349 sz += QSize(2*pixelMetric(PM_ButtonMargin), 2*pixelMetric(PM_ButtonMargin)); |
|
2211 if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget))) |
2350 if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget))) |
2212 if (buttonWidget->isCheckable()) |
2351 if (buttonWidget->isCheckable()) |
2213 sz += QSize(pixelMetric(PM_IndicatorWidth) + pixelMetric(PM_CheckBoxLabelSpacing), 0); |
2352 sz += QSize(pixelMetric(PM_IndicatorWidth) + pixelMetric(PM_CheckBoxLabelSpacing), 0); |
2214 break; |
2353 break; |
2215 case CT_LineEdit: |
2354 case CT_LineEdit: |
2216 if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) |
2355 if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) |
2217 sz += QSize(2*f->lineWidth, 4*f->lineWidth); |
2356 sz += QSize(2*f->lineWidth, 4*f->lineWidth); |
2218 break; |
2357 break; |
2219 case CT_TabBarTab: |
2358 case CT_TabBarTab: |
2220 QSize naviPaneSize = QS60StylePrivate::naviPaneSize(); |
2359 { |
2360 const QSize naviPaneSize = QS60StylePrivate::naviPaneSize(); |
|
2361 sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget); |
|
2362 if (naviPaneSize.height() > sz.height()) |
|
2363 sz.setHeight(naviPaneSize.height()); |
|
2364 } |
|
2365 break; |
|
2366 case CT_ItemViewItem: |
|
2221 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2367 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2222 if (naviPaneSize.height() > sz.height()) |
2368 if (QS60StylePrivate::isTouchSupported()) |
2223 sz.setHeight(naviPaneSize.height()); |
2369 //Make itemview easier to use in touch devices |
2370 //QCommonStyle does not adjust height with horizontal margin, it only adjusts width |
|
2371 sz.setHeight(sz.height() + 2*pixelMetric(QStyle::PM_FocusFrameVMargin)); |
|
2224 break; |
2372 break; |
2225 default: |
2373 default: |
2226 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2374 sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
2227 break; |
2375 break; |
2228 } |
2376 } |
2234 QStyleHintReturn *hret) const |
2382 QStyleHintReturn *hret) const |
2235 { |
2383 { |
2236 int retValue = -1; |
2384 int retValue = -1; |
2237 switch (sh) { |
2385 switch (sh) { |
2238 case SH_Table_GridLineColor: |
2386 case SH_Table_GridLineColor: |
2239 retValue = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors,2,0).rgb(); |
2387 retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors,2,0).rgba()); |
2240 break; |
2388 break; |
2241 case SH_GroupBox_TextLabelColor: |
2389 case SH_GroupBox_TextLabelColor: |
2242 retValue = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors,6,0).rgb(); |
2390 retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors,6,0).rgba()); |
2243 break; |
2391 break; |
2244 case SH_ScrollBar_ScrollWhenPointerLeavesControl: |
2392 case SH_ScrollBar_ScrollWhenPointerLeavesControl: |
2245 retValue = true; |
2393 retValue = true; |
2246 break; |
2394 break; |
2247 case SH_Slider_SnapToValue: |
2395 case SH_Slider_SnapToValue: |
2289 retValue = 0; |
2437 retValue = 0; |
2290 break; |
2438 break; |
2291 case SH_RequestSoftwareInputPanel: |
2439 case SH_RequestSoftwareInputPanel: |
2292 retValue = RSIP_OnMouseClickAndAlreadyFocused; |
2440 retValue = RSIP_OnMouseClickAndAlreadyFocused; |
2293 break; |
2441 break; |
2442 case SH_FormLayoutWrapPolicy: |
|
2443 retValue = QFormLayout::WrapLongRows; |
|
2444 break; |
|
2294 default: |
2445 default: |
2295 break; |
2446 retValue = QCommonStyle::styleHint(sh, opt, widget, hret); |
2296 } |
2447 break; |
2297 if (retValue == -1) |
2448 } |
2298 retValue = QCommonStyle::styleHint(sh, opt, widget, hret); |
|
2299 return retValue; |
2449 return retValue; |
2300 } |
2450 } |
2301 |
2451 |
2302 /*! \reimp */ |
2452 /*! \reimp */ |
2303 QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComplex *option, SubControl scontrol, const QWidget *widget) const |
2453 QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComplex *option, SubControl scontrol, const QWidget *widget) const |
2473 default: |
2623 default: |
2474 break; |
2624 break; |
2475 } |
2625 } |
2476 } |
2626 } |
2477 break; |
2627 break; |
2628 case CC_ToolButton: |
|
2629 if (const QStyleOptionToolButton *toolButton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { |
|
2630 const int indicatorRect = pixelMetric(PM_MenuButtonIndicator) + 2*pixelMetric(PM_ButtonMargin); |
|
2631 const int border = pixelMetric(PM_ButtonMargin) + pixelMetric(PM_DefaultFrameWidth); |
|
2632 ret = toolButton->rect; |
|
2633 const bool popup = (toolButton->features & |
|
2634 (QStyleOptionToolButton::MenuButtonPopup | QStyleOptionToolButton::PopupDelay)) |
|
2635 == QStyleOptionToolButton::MenuButtonPopup; |
|
2636 switch (scontrol) { |
|
2637 case SC_ToolButton: |
|
2638 if (popup) |
|
2639 ret.adjust(0, 0, -indicatorRect, 0); |
|
2640 break; |
|
2641 case SC_ToolButtonMenu: |
|
2642 if (popup) |
|
2643 ret.adjust(ret.width() - indicatorRect, border, -pixelMetric(PM_ButtonMargin), -border); |
|
2644 break; |
|
2645 default: |
|
2646 break; |
|
2647 } |
|
2648 ret = visualRect(toolButton->direction, toolButton->rect, ret); |
|
2649 } |
|
2650 break; |
|
2478 default: |
2651 default: |
2479 ret = QCommonStyle::subControlRect(control, option, scontrol, widget); |
2652 ret = QCommonStyle::subControlRect(control, option, scontrol, widget); |
2480 } |
2653 } |
2481 return ret; |
2654 return ret; |
2482 } |
2655 } |
2487 QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, const QWidget *widget) const |
2660 QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, const QWidget *widget) const |
2488 { |
2661 { |
2489 QRect ret; |
2662 QRect ret; |
2490 switch (element) { |
2663 switch (element) { |
2491 case SE_LineEditContents: { |
2664 case SE_LineEditContents: { |
2492 // in S60 the input text box doesn't start from line Edit's TL, but |
2665 // in S60 the input text box doesn't start from line Edit's TL, but |
2493 // a bit indented. |
2666 // a bit indented. |
2494 QRect lineEditRect = opt->rect; |
2667 QRect lineEditRect = opt->rect; |
2495 const int adjustment = opt->rect.height()>>2; |
2668 const int adjustment = opt->rect.height()>>2; |
2496 lineEditRect.adjust(adjustment,0,0,0); |
2669 lineEditRect.adjust(adjustment,0,0,0); |
2497 ret = lineEditRect; |
2670 ret = lineEditRect; |
2498 } |
2671 } |
2737 QApplication::setPalette(newPalette); |
2910 QApplication::setPalette(newPalette); |
2738 QApplicationPrivate::setSystemPalette(d->m_originalPalette); |
2911 QApplicationPrivate::setSystemPalette(d->m_originalPalette); |
2739 } |
2912 } |
2740 |
2913 |
2741 /*! |
2914 /*! |
2742 Sets the style property \a name to the \a value. |
|
2743 */ |
|
2744 void QS60Style::setStyleProperty(const char *name, const QVariant &value) |
|
2745 { |
|
2746 Q_D(QS60Style); |
|
2747 d->setStyleProperty_specific(name, value); |
|
2748 } |
|
2749 |
|
2750 /*! |
|
2751 Returns the value of style property \a name. |
|
2752 */ |
|
2753 QVariant QS60Style::styleProperty(const char *name) const |
|
2754 { |
|
2755 Q_D(const QS60Style); |
|
2756 return d->styleProperty_specific(name); |
|
2757 } |
|
2758 |
|
2759 /*! |
|
2760 \reimp |
2915 \reimp |
2761 */ |
2916 */ |
2762 bool QS60Style::event(QEvent *e) |
2917 bool QS60Style::event(QEvent *e) |
2763 { |
2918 { |
2764 #ifdef QT_KEYPAD_NAVIGATION |
2919 #ifdef QT_KEYPAD_NAVIGATION |
2876 |
3031 |
2877 default: |
3032 default: |
2878 return QCommonStyle::standardIconImplementation(standardIcon, option, widget); |
3033 return QCommonStyle::standardIconImplementation(standardIcon, option, widget); |
2879 } |
3034 } |
2880 const QS60StylePrivate::SkinElementFlags flags = adjustedFlags; |
3035 const QS60StylePrivate::SkinElementFlags flags = adjustedFlags; |
2881 const QPixmap cachedPixMap(QS60StylePrivate::cachedPart(part, iconSize.size(), flags)); |
3036 const QPixmap cachedPixMap(QS60StylePrivate::cachedPart(part, iconSize.size(), 0, flags)); |
2882 return cachedPixMap.isNull() ? |
3037 return cachedPixMap.isNull() ? |
2883 QCommonStyle::standardIconImplementation(standardIcon, option, widget) : QIcon(cachedPixMap); |
3038 QCommonStyle::standardIconImplementation(standardIcon, option, widget) : QIcon(cachedPixMap); |
2884 } |
3039 } |
2885 |
3040 |
2886 extern QPoint qt_s60_fill_background_offset(const QWidget *targetWidget); |
3041 extern QPoint qt_s60_fill_background_offset(const QWidget *targetWidget); |