author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Wed, 21 Apr 2010 20:15:53 +0300 | |
branch | RCL_3 |
changeset 14 | c0432d11811c |
parent 8 | 3f74d0d4af4c |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
0 | 8 |
** |
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
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 |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include "qs60style_p.h" |
|
43 |
||
44 |
#include "qapplication.h" |
|
45 |
#include "qpainter.h" |
|
46 |
#include "qstyleoption.h" |
|
47 |
#include "qevent.h" |
|
48 |
#include "qpixmapcache.h" |
|
49 |
||
50 |
#include "qcalendarwidget.h" |
|
51 |
#include "qdial.h" |
|
52 |
#include "qdialog.h" |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
53 |
#include "qmessagebox.h" |
0 | 54 |
#include "qgroupbox.h" |
55 |
#include "qheaderview.h" |
|
56 |
#include "qlist.h" |
|
57 |
#include "qlistwidget.h" |
|
58 |
#include "qlistview.h" |
|
59 |
#include "qmenu.h" |
|
60 |
#include "qmenubar.h" |
|
61 |
#include "qpushbutton.h" |
|
62 |
#include "qscrollarea.h" |
|
63 |
#include "qscrollbar.h" |
|
64 |
#include "qtabbar.h" |
|
65 |
#include "qtableview.h" |
|
66 |
#include "qtextedit.h" |
|
67 |
#include "qtoolbar.h" |
|
68 |
#include "qtoolbutton.h" |
|
69 |
#include "qfocusframe.h" |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
70 |
#include "qformlayout.h" |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
71 |
#include "qradiobutton.h" |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
72 |
#include "qcheckbox.h" |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
73 |
#include "qdesktopwidget.h" |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
74 |
#include "qprogressbar.h" |
0 | 75 |
|
76 |
#include "private/qtoolbarextension_p.h" |
|
77 |
#include "private/qcombobox_p.h" |
|
78 |
#include "private/qwidget_p.h" |
|
79 |
#include "private/qapplication_p.h" |
|
80 |
||
81 |
#if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN) |
|
82 |
||
83 |
QT_BEGIN_NAMESPACE |
|
84 |
||
85 |
// from text/qfont.cpp |
|
86 |
extern Q_GUI_EXPORT int qt_defaultDpiY(); |
|
87 |
||
88 |
const QS60StylePrivate::SkinElementFlags QS60StylePrivate::KDefaultSkinElementFlags = |
|
89 |
SkinElementFlags(SF_PointNorth | SF_StateEnabled); |
|
90 |
||
91 |
static const qreal goldenRatio = 1.618; |
|
92 |
||
93 |
const layoutHeader QS60StylePrivate::m_layoutHeaders[] = { |
|
94 |
// *** generated layout data *** |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
95 |
{240,320,1,17,"QVGA Landscape"}, |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
96 |
{320,240,1,17,"QVGA Portrait"}, |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
97 |
{360,640,1,17,"NHD Landscape"}, |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
98 |
{640,360,1,17,"NHD Portrait"}, |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
99 |
{352,800,1,12,"E90 Landscape"} |
0 | 100 |
// *** End of generated data *** |
101 |
}; |
|
102 |
const int QS60StylePrivate::m_numberOfLayouts = |
|
103 |
(int)sizeof(QS60StylePrivate::m_layoutHeaders)/sizeof(QS60StylePrivate::m_layoutHeaders[0]); |
|
104 |
||
105 |
const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = { |
|
106 |
// *** generated pixel metrics *** |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
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}, |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
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}, |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
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}, |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
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}, |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
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} |
0 | 112 |
// *** End of generated data *** |
113 |
}; |
|
114 |
||
115 |
const short *QS60StylePrivate::m_pmPointer = QS60StylePrivate::data[0]; |
|
116 |
||
117 |
// theme background texture |
|
118 |
QPixmap *QS60StylePrivate::m_background = 0; |
|
119 |
||
120 |
// theme palette |
|
121 |
QPalette *QS60StylePrivate::m_themePalette = 0; |
|
122 |
||
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
123 |
qint64 QS60StylePrivate::m_webPaletteKey = 0; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
124 |
|
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
125 |
QPointer<QWidget> QS60StylePrivate::m_pressedWidget = 0; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
126 |
|
0 | 127 |
const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameElementsData[] = { |
128 |
{SE_ButtonNormal, QS60StyleEnums::SP_QsnFrButtonTbCenter}, |
|
129 |
{SE_ButtonPressed, QS60StyleEnums::SP_QsnFrButtonTbCenterPressed}, |
|
130 |
{SE_FrameLineEdit, QS60StyleEnums::SP_QsnFrInputCenter}, |
|
131 |
{SE_ListHighlight, QS60StyleEnums::SP_QsnFrListCenter}, |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
132 |
{SE_PopupBackground, QS60StyleEnums::SP_QsnFrPopupCenter}, |
0 | 133 |
{SE_SettingsList, QS60StyleEnums::SP_QsnFrSetOptCenter}, |
134 |
{SE_TableItem, QS60StyleEnums::SP_QsnFrCaleCenter}, |
|
135 |
{SE_TableHeaderItem, QS60StyleEnums::SP_QsnFrCaleHeadingCenter}, |
|
136 |
{SE_ToolTip, QS60StyleEnums::SP_QsnFrPopupPreviewCenter}, |
|
137 |
{SE_ToolBar, QS60StyleEnums::SP_QsnFrPopupSubCenter}, |
|
138 |
{SE_ToolBarButton, QS60StyleEnums::SP_QsnFrSctrlButtonCenter}, |
|
139 |
{SE_ToolBarButtonPressed, QS60StyleEnums::SP_QsnFrSctrlButtonCenterPressed}, |
|
140 |
{SE_PanelBackground, QS60StyleEnums::SP_QsnFrSetOptCenter}, |
|
141 |
{SE_ButtonInactive, QS60StyleEnums::SP_QsnFrButtonCenterInactive}, |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
142 |
{SE_Editor, QS60StyleEnums::SP_QsnFrInputCenter}, |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
143 |
{SE_TableItemPressed, QS60StyleEnums::SP_QsnFrGridCenterPressed}, |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
144 |
{SE_ListItemPressed, QS60StyleEnums::SP_QsnFrListPressed}, |
0 | 145 |
}; |
146 |
||
147 |
static const int frameElementsCount = |
|
148 |
int(sizeof(QS60StylePrivate::m_frameElementsData)/sizeof(QS60StylePrivate::m_frameElementsData[0])); |
|
149 |
||
150 |
const int KNotFound = -909; |
|
151 |
const double KTabFontMul = 0.72; |
|
152 |
||
153 |
QS60StylePrivate::~QS60StylePrivate() |
|
154 |
{ |
|
155 |
clearCaches(); //deletes also background image |
|
156 |
deleteThemePalette(); |
|
157 |
} |
|
158 |
||
159 |
void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter, |
|
160 |
const QRect &rect, SkinElementFlags flags) |
|
161 |
{ |
|
162 |
switch (element) { |
|
163 |
case SE_ButtonNormal: |
|
164 |
drawFrame(SF_ButtonNormal, painter, rect, flags | SF_PointNorth); |
|
165 |
break; |
|
166 |
case SE_ButtonPressed: |
|
167 |
drawFrame(SF_ButtonPressed, painter, rect, flags | SF_PointNorth); |
|
168 |
break; |
|
169 |
case SE_FrameLineEdit: |
|
170 |
drawFrame(SF_FrameLineEdit, painter, rect, flags | SF_PointNorth); |
|
171 |
break; |
|
172 |
case SE_ProgressBarGrooveHorizontal: |
|
173 |
drawRow(QS60StyleEnums::SP_QgnGrafBarFrameSideL, QS60StyleEnums::SP_QgnGrafBarFrameCenter, |
|
174 |
QS60StyleEnums::SP_QgnGrafBarFrameSideR, Qt::Horizontal, painter, rect, flags | SF_PointNorth); |
|
175 |
break; |
|
176 |
case SE_ProgressBarGrooveVertical: |
|
177 |
drawRow(QS60StyleEnums::SP_QgnGrafBarFrameSideL, QS60StyleEnums::SP_QgnGrafBarFrameCenter, |
|
178 |
QS60StyleEnums::SP_QgnGrafBarFrameSideR, Qt::Vertical, painter, rect, flags | SF_PointEast); |
|
179 |
break; |
|
180 |
case SE_ProgressBarIndicatorHorizontal: |
|
181 |
drawPart(QS60StyleEnums::SP_QgnGrafBarProgress, painter, rect, flags | SF_PointNorth); |
|
182 |
break; |
|
183 |
case SE_ProgressBarIndicatorVertical: |
|
184 |
drawPart(QS60StyleEnums::SP_QgnGrafBarProgress, painter, rect, flags | SF_PointWest); |
|
185 |
break; |
|
186 |
case SE_ScrollBarGrooveHorizontal: |
|
187 |
drawRow(QS60StyleEnums::SP_QsnCpScrollBgBottom, QS60StyleEnums::SP_QsnCpScrollBgMiddle, |
|
188 |
QS60StyleEnums::SP_QsnCpScrollBgTop, Qt::Horizontal, painter, rect, flags | SF_PointEast); |
|
189 |
break; |
|
190 |
case SE_ScrollBarGrooveVertical: |
|
191 |
drawRow(QS60StyleEnums::SP_QsnCpScrollBgTop, QS60StyleEnums::SP_QsnCpScrollBgMiddle, |
|
192 |
QS60StyleEnums::SP_QsnCpScrollBgBottom, Qt::Vertical, painter, rect, flags | SF_PointNorth); |
|
193 |
break; |
|
194 |
case SE_ScrollBarHandleHorizontal: |
|
195 |
drawRow(QS60StyleEnums::SP_QsnCpScrollHandleBottom, QS60StyleEnums::SP_QsnCpScrollHandleMiddle, |
|
196 |
QS60StyleEnums::SP_QsnCpScrollHandleTop, Qt::Horizontal, painter, rect, flags | SF_PointEast); |
|
197 |
break; |
|
198 |
case SE_ScrollBarHandleVertical: |
|
199 |
drawRow(QS60StyleEnums::SP_QsnCpScrollHandleTop, QS60StyleEnums::SP_QsnCpScrollHandleMiddle, |
|
200 |
QS60StyleEnums::SP_QsnCpScrollHandleBottom, Qt::Vertical, painter, rect, flags | SF_PointNorth); |
|
201 |
break; |
|
202 |
case SE_SliderHandleHorizontal: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
203 |
drawPart(QS60StyleEnums::SP_QgnGrafNsliderMarker, painter, rect, flags | SF_PointNorth); |
0 | 204 |
break; |
205 |
case SE_SliderHandleVertical: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
206 |
drawPart(QS60StyleEnums::SP_QgnGrafNsliderMarker, painter, rect, flags | SF_PointEast); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
207 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
208 |
case SE_SliderHandleSelectedHorizontal: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
209 |
drawPart(QS60StyleEnums::SP_QgnGrafNsliderMarkerSelected, painter, rect, flags | SF_PointNorth); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
210 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
211 |
case SE_SliderHandleSelectedVertical: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
212 |
drawPart(QS60StyleEnums::SP_QgnGrafNsliderMarkerSelected, painter, rect, flags | SF_PointEast); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
213 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
214 |
case SE_SliderGrooveVertical: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
215 |
drawRow(QS60StyleEnums::SP_QgnGrafNsliderEndLeft, QS60StyleEnums::SP_QgnGrafNsliderMiddle, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
216 |
QS60StyleEnums::SP_QgnGrafNsliderEndRight, Qt::Vertical, painter, rect, flags | SF_PointEast); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
217 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
218 |
case SE_SliderGrooveHorizontal: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
219 |
drawRow(QS60StyleEnums::SP_QgnGrafNsliderEndLeft, QS60StyleEnums::SP_QgnGrafNsliderMiddle, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
220 |
QS60StyleEnums::SP_QgnGrafNsliderEndRight, Qt::Horizontal, painter, rect, flags | SF_PointNorth); |
0 | 221 |
break; |
222 |
case SE_TabBarTabEastActive: |
|
223 |
drawRow(QS60StyleEnums::SP_QgnGrafTabActiveL, QS60StyleEnums::SP_QgnGrafTabActiveM, |
|
224 |
QS60StyleEnums::SP_QgnGrafTabActiveR, Qt::Vertical, painter, rect, flags | SF_PointEast); |
|
225 |
break; |
|
226 |
case SE_TabBarTabEastInactive: |
|
227 |
drawRow(QS60StyleEnums::SP_QgnGrafTabPassiveL, QS60StyleEnums::SP_QgnGrafTabPassiveM, |
|
228 |
QS60StyleEnums::SP_QgnGrafTabPassiveR, Qt::Vertical, painter, rect, flags | SF_PointEast); |
|
229 |
break; |
|
230 |
case SE_TabBarTabNorthActive: |
|
231 |
drawRow(QS60StyleEnums::SP_QgnGrafTabActiveL, QS60StyleEnums::SP_QgnGrafTabActiveM, |
|
232 |
QS60StyleEnums::SP_QgnGrafTabActiveR, Qt::Horizontal, painter, rect, flags | SF_PointNorth); |
|
233 |
break; |
|
234 |
case SE_TabBarTabNorthInactive: |
|
235 |
drawRow(QS60StyleEnums::SP_QgnGrafTabPassiveL, QS60StyleEnums::SP_QgnGrafTabPassiveM, |
|
236 |
QS60StyleEnums::SP_QgnGrafTabPassiveR, Qt::Horizontal, painter, rect, flags | SF_PointNorth); |
|
237 |
break; |
|
238 |
case SE_TabBarTabSouthActive: |
|
239 |
drawRow(QS60StyleEnums::SP_QgnGrafTabActiveR, QS60StyleEnums::SP_QgnGrafTabActiveM, |
|
240 |
QS60StyleEnums::SP_QgnGrafTabActiveL, Qt::Horizontal, painter, rect, flags | SF_PointSouth); |
|
241 |
break; |
|
242 |
case SE_TabBarTabSouthInactive: |
|
243 |
drawRow(QS60StyleEnums::SP_QgnGrafTabPassiveR, QS60StyleEnums::SP_QgnGrafTabPassiveM, |
|
244 |
QS60StyleEnums::SP_QgnGrafTabPassiveL, Qt::Horizontal, painter, rect, flags | SF_PointSouth); |
|
245 |
break; |
|
246 |
case SE_TabBarTabWestActive: |
|
247 |
drawRow(QS60StyleEnums::SP_QgnGrafTabActiveR, QS60StyleEnums::SP_QgnGrafTabActiveM, |
|
248 |
QS60StyleEnums::SP_QgnGrafTabActiveL, Qt::Vertical, painter, rect, flags | SF_PointWest); |
|
249 |
break; |
|
250 |
case SE_TabBarTabWestInactive: |
|
251 |
drawRow(QS60StyleEnums::SP_QgnGrafTabPassiveR, QS60StyleEnums::SP_QgnGrafTabPassiveM, |
|
252 |
QS60StyleEnums::SP_QgnGrafTabPassiveL, Qt::Vertical, painter, rect, flags | SF_PointWest); |
|
253 |
break; |
|
254 |
case SE_ListHighlight: |
|
255 |
drawFrame(SF_ListHighlight, painter, rect, flags | SF_PointNorth); |
|
256 |
break; |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
257 |
case SE_PopupBackground: |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
258 |
drawFrame(SF_PopupBackground, painter, rect, flags | SF_PointNorth); |
0 | 259 |
break; |
260 |
case SE_SettingsList: |
|
261 |
drawFrame(SF_SettingsList, painter, rect, flags | SF_PointNorth); |
|
262 |
break; |
|
263 |
case SE_TableItem: |
|
264 |
drawFrame(SF_TableItem, painter, rect, flags | SF_PointNorth); |
|
265 |
break; |
|
266 |
case SE_TableHeaderItem: |
|
267 |
drawFrame(SF_TableHeaderItem, painter, rect, flags | SF_PointNorth); |
|
268 |
break; |
|
269 |
case SE_ToolTip: |
|
270 |
drawFrame(SF_ToolTip, painter, rect, flags | SF_PointNorth); |
|
271 |
break; |
|
272 |
case SE_ToolBar: |
|
273 |
drawFrame(SF_ToolBar, painter, rect, flags | SF_PointNorth); |
|
274 |
break; |
|
275 |
case SE_ToolBarButton: |
|
276 |
drawFrame(SF_ToolBarButton, painter, rect, flags | SF_PointNorth); |
|
277 |
break; |
|
278 |
case SE_ToolBarButtonPressed: |
|
279 |
drawFrame(SF_ToolBarButtonPressed, painter, rect, flags | SF_PointNorth); |
|
280 |
break; |
|
281 |
case SE_PanelBackground: |
|
282 |
drawFrame(SF_PanelBackground, painter, rect, flags | SF_PointNorth); |
|
283 |
break; |
|
284 |
case SE_ScrollBarHandlePressedHorizontal: |
|
285 |
drawRow(QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed, QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed, |
|
286 |
QS60StyleEnums::SP_QsnCpScrollHandleTopPressed, Qt::Horizontal, painter, rect, flags | SF_PointEast); |
|
287 |
break; |
|
288 |
case SE_ScrollBarHandlePressedVertical: |
|
289 |
drawRow(QS60StyleEnums::SP_QsnCpScrollHandleTopPressed, QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed, |
|
290 |
QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed, Qt::Vertical, painter, rect, flags | SF_PointNorth); |
|
291 |
break; |
|
292 |
case SE_ButtonInactive: |
|
293 |
drawFrame(SF_ButtonInactive, painter, rect, flags | SF_PointNorth); |
|
294 |
break; |
|
295 |
case SE_Editor: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
296 |
drawFrame(SF_FrameLineEdit, painter, rect, flags | SF_PointNorth); |
0 | 297 |
break; |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
298 |
case SE_DropArea: |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
299 |
drawPart(QS60StyleEnums::SP_QgnGrafOrgBgGrid, painter, rect, flags | SF_PointNorth); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
300 |
break; |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
301 |
case SE_TableItemPressed: |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
302 |
drawFrame(SF_TableItemPressed, painter, rect, flags | SF_PointNorth); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
303 |
break; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
304 |
case SE_ListItemPressed: |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
305 |
drawFrame(SF_ListItemPressed, painter, rect, flags | SF_PointNorth); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
306 |
break; |
0 | 307 |
default: |
308 |
break; |
|
309 |
} |
|
310 |
} |
|
311 |
||
312 |
void QS60StylePrivate::drawSkinPart(QS60StyleEnums::SkinParts part, |
|
313 |
QPainter *painter, const QRect &rect, SkinElementFlags flags) |
|
314 |
{ |
|
315 |
drawPart(part, painter, rect, flags); |
|
316 |
} |
|
317 |
||
318 |
short QS60StylePrivate::pixelMetric(int metric) |
|
319 |
{ |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
320 |
//If it is a custom value, need to strip away the base to map to internal |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
321 |
//pixel metric value table |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
322 |
if (metric & QStyle::PM_CustomBase) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
323 |
metric -= QStyle::PM_CustomBase; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
324 |
metric += MAX_NON_CUSTOM_PIXELMETRICS - 1; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
325 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
326 |
|
0 | 327 |
Q_ASSERT(metric < MAX_PIXELMETRICS); |
328 |
const short returnValue = m_pmPointer[metric]; |
|
329 |
return returnValue; |
|
330 |
} |
|
331 |
||
332 |
QColor QS60StylePrivate::stateColor(const QColor &color, const QStyleOption *option) |
|
333 |
{ |
|
334 |
QColor retColor (color); |
|
335 |
if (option && !(option->state & QStyle::State_Enabled)) { |
|
336 |
QColor hsvColor = retColor.toHsv(); |
|
337 |
int colorSat = hsvColor.saturation(); |
|
338 |
int colorVal = hsvColor.value(); |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
339 |
colorSat = (colorSat != 0) ? (colorSat >> 1) : 128; |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
340 |
colorVal = (colorVal != 0) ? (colorVal >> 1) : 128; |
0 | 341 |
hsvColor.setHsv(hsvColor.hue(), colorSat, colorVal); |
342 |
retColor = hsvColor.toRgb(); |
|
343 |
} |
|
344 |
return retColor; |
|
345 |
} |
|
346 |
||
347 |
QColor QS60StylePrivate::lighterColor(const QColor &baseColor) |
|
348 |
{ |
|
349 |
QColor result(baseColor); |
|
350 |
bool modifyColor = false; |
|
351 |
if (result.saturation() == 0) { |
|
352 |
result.setHsv(result.hue(), 128, result.value()); |
|
353 |
modifyColor = true; |
|
354 |
} |
|
355 |
if (result.value() == 0) { |
|
356 |
result.setHsv(result.hue(), result.saturation(), 128); |
|
357 |
modifyColor = true; |
|
358 |
} |
|
359 |
if (modifyColor) |
|
360 |
result = result.lighter(175); |
|
361 |
else |
|
362 |
result = result.lighter(225); |
|
363 |
return result; |
|
364 |
} |
|
365 |
||
366 |
bool QS60StylePrivate::drawsOwnThemeBackground(const QWidget *widget) |
|
367 |
{ |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
368 |
return (widget ? (widget->windowType() == Qt::Dialog) : false); |
0 | 369 |
} |
370 |
||
371 |
QFont QS60StylePrivate::s60Font( |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
372 |
QS60StyleEnums::FontCategories fontCategory, |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
373 |
int pointSize, bool resolveFontSize) const |
0 | 374 |
{ |
375 |
QFont result; |
|
376 |
int actualPointSize = pointSize; |
|
377 |
if (actualPointSize <= 0) { |
|
378 |
const QFont appFont = QApplication::font(); |
|
379 |
actualPointSize = appFont.pointSize(); |
|
380 |
if (actualPointSize <= 0) |
|
381 |
actualPointSize = appFont.pixelSize() * 72 / qt_defaultDpiY(); |
|
382 |
} |
|
383 |
Q_ASSERT(actualPointSize > 0); |
|
384 |
const QPair<QS60StyleEnums::FontCategories, int> key(fontCategory, actualPointSize); |
|
385 |
if (!m_mappedFontsCache.contains(key)) { |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
386 |
result = s60Font_specific(fontCategory, actualPointSize, resolveFontSize); |
0 | 387 |
m_mappedFontsCache.insert(key, result); |
388 |
} else { |
|
389 |
result = m_mappedFontsCache.value(key); |
|
390 |
if (result.pointSize() != actualPointSize) |
|
391 |
result.setPointSize(actualPointSize); |
|
392 |
} |
|
393 |
return result; |
|
394 |
} |
|
395 |
||
396 |
void QS60StylePrivate::clearCaches(CacheClearReason reason) |
|
397 |
{ |
|
398 |
switch(reason){ |
|
399 |
case CC_LayoutChange: |
|
400 |
// when layout changes, the colors remain in cache, but graphics and fonts can change |
|
401 |
m_mappedFontsCache.clear(); |
|
402 |
QPixmapCache::clear(); |
|
403 |
break; |
|
404 |
case CC_ThemeChange: |
|
405 |
m_colorCache.clear(); |
|
406 |
QPixmapCache::clear(); |
|
407 |
deleteBackground(); |
|
408 |
break; |
|
409 |
case CC_UndefinedChange: |
|
410 |
default: |
|
411 |
m_colorCache.clear(); |
|
412 |
m_mappedFontsCache.clear(); |
|
413 |
QPixmapCache::clear(); |
|
414 |
deleteBackground(); |
|
415 |
break; |
|
416 |
} |
|
417 |
} |
|
418 |
||
419 |
// Since S60Style has 'button' and 'tooltip' as a graphic, we don't have any native color which to use |
|
420 |
// for QPalette::Button and QPalette::ToolTipBase. Therefore S60Style needs to guesstimate |
|
421 |
// palette colors by calculating average rgb values for button pixels. |
|
422 |
// Returns Qt::black if there is an issue with the graphics (image is NULL, or no bits() found). |
|
423 |
QColor QS60StylePrivate::colorFromFrameGraphics(SkinFrameElements frame) const |
|
424 |
{ |
|
425 |
const bool cachedColorExists = m_colorCache.contains(frame); |
|
426 |
if (!cachedColorExists) { |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
427 |
const int frameCornerWidth = pixelMetric(PM_FrameCornerWidth); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
428 |
const int frameCornerHeight = pixelMetric(PM_FrameCornerHeight); |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
429 |
Q_ASSERT(2 * frameCornerWidth < 32); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
430 |
Q_ASSERT(2 * frameCornerHeight < 32); |
0 | 431 |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
432 |
const QImage frameImage = QS60StylePrivate::frame(frame, QSize(32, 32)).toImage(); |
0 | 433 |
Q_ASSERT(frameImage.bytesPerLine() > 0); |
434 |
if (frameImage.isNull()) |
|
435 |
return Qt::black; |
|
436 |
||
437 |
const QRgb *pixelRgb = (const QRgb*)frameImage.bits(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
438 |
const int pixels = frameImage.byteCount()/sizeof(QRgb); |
0 | 439 |
|
440 |
int estimatedRed = 0; |
|
441 |
int estimatedGreen = 0; |
|
442 |
int estimatedBlue = 0; |
|
443 |
||
444 |
int skips = 0; |
|
445 |
int estimations = 0; |
|
446 |
||
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
447 |
const int topBorderLastPixel = frameCornerHeight*frameImage.width() - 1; |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
448 |
const int bottomBorderFirstPixel = frameImage.width() * frameImage.height() - frameCornerHeight*frameImage.width() - 1; |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
449 |
const int rightBorderFirstPixel = frameImage.width() - frameCornerWidth; |
0 | 450 |
const int leftBorderLastPixel = frameCornerWidth; |
451 |
||
452 |
while ((skips + estimations) < pixels) { |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
453 |
if ((skips + estimations) > topBorderLastPixel && |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
454 |
(skips + estimations) < bottomBorderFirstPixel) { |
0 | 455 |
for (int rowIndex = 0; rowIndex < frameImage.width(); rowIndex++) { |
456 |
if (rowIndex > leftBorderLastPixel && |
|
457 |
rowIndex < rightBorderFirstPixel) { |
|
458 |
estimatedRed += qRed(*pixelRgb); |
|
459 |
estimatedGreen += qGreen(*pixelRgb); |
|
460 |
estimatedBlue += qBlue(*pixelRgb); |
|
461 |
} |
|
462 |
pixelRgb++; |
|
463 |
estimations++; |
|
464 |
} |
|
465 |
} else { |
|
466 |
pixelRgb++; |
|
467 |
skips++; |
|
468 |
} |
|
469 |
} |
|
470 |
QColor frameColor(estimatedRed/estimations, estimatedGreen/estimations, estimatedBlue/estimations); |
|
471 |
m_colorCache.insert(frame, frameColor); |
|
472 |
return !estimations ? Qt::black : frameColor; |
|
473 |
} else { |
|
474 |
return m_colorCache.value(frame); |
|
475 |
} |
|
476 |
||
477 |
} |
|
478 |
||
479 |
void QS60StylePrivate::setThemePalette(QApplication *app) const |
|
480 |
{ |
|
481 |
Q_UNUSED(app) |
|
482 |
QPalette widgetPalette = QPalette(Qt::white); |
|
483 |
setThemePalette(&widgetPalette); |
|
484 |
} |
|
485 |
||
486 |
QPalette* QS60StylePrivate::themePalette() |
|
487 |
{ |
|
488 |
return m_themePalette; |
|
489 |
} |
|
490 |
||
491 |
void QS60StylePrivate::setBackgroundTexture(QApplication *app) const |
|
492 |
{ |
|
493 |
Q_UNUSED(app) |
|
494 |
QPalette applicationPalette = QApplication::palette(); |
|
495 |
applicationPalette.setBrush(QPalette::Window, backgroundTexture()); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
496 |
setThemePalette(&applicationPalette); |
0 | 497 |
} |
498 |
||
499 |
void QS60StylePrivate::deleteBackground() |
|
500 |
{ |
|
501 |
if (m_background) { |
|
502 |
delete m_background; |
|
503 |
m_background = 0; |
|
504 |
} |
|
505 |
} |
|
506 |
||
507 |
void QS60StylePrivate::setCurrentLayout(int index) |
|
508 |
{ |
|
509 |
m_pmPointer = data[index]; |
|
510 |
} |
|
511 |
||
512 |
void QS60StylePrivate::drawPart(QS60StyleEnums::SkinParts skinPart, |
|
513 |
QPainter *painter, const QRect &rect, SkinElementFlags flags) |
|
514 |
{ |
|
515 |
static const bool doCache = |
|
516 |
#if defined(Q_WS_S60) |
|
517 |
// Freezes on 3.1. Anyways, caching is only really needed on touch UI |
|
518 |
!(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2); |
|
519 |
#else |
|
520 |
true; |
|
521 |
#endif |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
522 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
523 |
const QPixmap skinPartPixMap((doCache ? cachedPart : part)(skinPart, rect.size(), painter, flags)); |
0 | 524 |
if (!skinPartPixMap.isNull()) |
525 |
painter->drawPixmap(rect.topLeft(), skinPartPixMap); |
|
526 |
} |
|
527 |
||
528 |
void QS60StylePrivate::drawFrame(SkinFrameElements frameElement, QPainter *painter, const QRect &rect, SkinElementFlags flags) |
|
529 |
{ |
|
530 |
static const bool doCache = |
|
531 |
#if defined(Q_WS_S60) |
|
532 |
// Freezes on 3.1. Anyways, caching is only really needed on touch UI |
|
533 |
!(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2); |
|
534 |
#else |
|
535 |
true; |
|
536 |
#endif |
|
537 |
const QPixmap frameElementPixMap((doCache ? cachedFrame : frame)(frameElement, rect.size(), flags)); |
|
538 |
if (!frameElementPixMap.isNull()) |
|
539 |
painter->drawPixmap(rect.topLeft(), frameElementPixMap); |
|
540 |
} |
|
541 |
||
542 |
void QS60StylePrivate::drawRow(QS60StyleEnums::SkinParts start, |
|
543 |
QS60StyleEnums::SkinParts middle, QS60StyleEnums::SkinParts end, |
|
544 |
Qt::Orientation orientation, QPainter *painter, const QRect &rect, |
|
545 |
SkinElementFlags flags) |
|
546 |
{ |
|
547 |
QSize startEndSize(partSize(start, flags)); |
|
548 |
startEndSize.scale(rect.size(), Qt::KeepAspectRatio); |
|
549 |
||
550 |
QRect startRect = QRect(rect.topLeft(), startEndSize); |
|
551 |
QRect middleRect = rect; |
|
552 |
QRect endRect; |
|
553 |
||
554 |
if (orientation == Qt::Horizontal) { |
|
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
555 |
startRect.setHeight(rect.height()); |
0 | 556 |
startRect.setWidth(qMin((rect.width() >> 1) - 1, startRect.width())); |
557 |
endRect = startRect.translated(rect.width() - startRect.width(), 0); |
|
558 |
middleRect.adjust(startRect.width(), 0, -startRect.width(), 0); |
|
559 |
if (startRect.bottomRight().x() > endRect.topLeft().x()) { |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
560 |
const int overlap = (startRect.bottomRight().x() - endRect.topLeft().x()) >> 1; |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
561 |
startRect.setWidth(startRect.width() - overlap); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
562 |
endRect.adjust(overlap, 0, 0, 0); |
0 | 563 |
} |
564 |
} else { |
|
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
565 |
startRect.setWidth(rect.width()); |
0 | 566 |
startRect.setHeight(qMin((rect.height() >> 1) - 1, startRect.height())); |
567 |
endRect = startRect.translated(0, rect.height() - startRect.height()); |
|
568 |
middleRect.adjust(0, startRect.height(), 0, -startRect.height()); |
|
569 |
if (startRect.topRight().y() > endRect.bottomLeft().y()) { |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
570 |
const int overlap = (startRect.topRight().y() - endRect.bottomLeft().y()) >> 1; |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
571 |
startRect.setHeight(startRect.height() - overlap); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
572 |
endRect.adjust(0, overlap, 0, 0); |
0 | 573 |
} |
574 |
} |
|
575 |
||
576 |
#if 0 |
|
577 |
painter->save(); |
|
578 |
painter->setOpacity(.3); |
|
579 |
painter->fillRect(startRect, Qt::red); |
|
580 |
painter->fillRect(middleRect, Qt::green); |
|
581 |
painter->fillRect(endRect, Qt::blue); |
|
582 |
painter->restore(); |
|
583 |
#else |
|
584 |
drawPart(start, painter, startRect, flags); |
|
585 |
if (middleRect.isValid()) |
|
586 |
drawPart(middle, painter, middleRect, flags); |
|
587 |
drawPart(end, painter, endRect, flags); |
|
588 |
#endif |
|
589 |
} |
|
590 |
||
591 |
QPixmap QS60StylePrivate::cachedPart(QS60StyleEnums::SkinParts part, |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
592 |
const QSize &size, QPainter *painter, SkinElementFlags flags) |
0 | 593 |
{ |
594 |
QPixmap result; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
595 |
const int animationFrame = (flags & SF_Animation) ? currentAnimationFrame(part) : 0; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
596 |
|
0 | 597 |
const QString cacheKey = |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
598 |
QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinPartFlags=%4 AnimationFrame=%5") |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
599 |
.arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags).arg(animationFrame); |
0 | 600 |
if (!QPixmapCache::find(cacheKey, result)) { |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
601 |
result = QS60StylePrivate::part(part, size, painter, flags); |
0 | 602 |
QPixmapCache::insert(cacheKey, result); |
603 |
} |
|
604 |
return result; |
|
605 |
} |
|
606 |
||
607 |
QPixmap QS60StylePrivate::cachedFrame(SkinFrameElements frame, const QSize &size, SkinElementFlags flags) |
|
608 |
{ |
|
609 |
QPixmap result; |
|
610 |
const QString cacheKey = |
|
611 |
QString::fromLatin1("S60Style: SkinFrameElements=%1 QSize=%2|%3 SkinElementFlags=%4") |
|
612 |
.arg((int)frame).arg(size.width()).arg(size.height()).arg((int)flags); |
|
613 |
if (!QPixmapCache::find(cacheKey, result)) { |
|
614 |
result = QS60StylePrivate::frame(frame, size, flags); |
|
615 |
QPixmapCache::insert(cacheKey, result); |
|
616 |
} |
|
617 |
return result; |
|
618 |
} |
|
619 |
||
620 |
void QS60StylePrivate::refreshUI() |
|
621 |
{ |
|
622 |
QList<QWidget *> widgets = QApplication::allWidgets(); |
|
623 |
||
624 |
for (int i = 0; i < widgets.size(); ++i) { |
|
625 |
QWidget *widget = widgets.at(i); |
|
626 |
if (widget == 0) |
|
627 |
continue; |
|
628 |
||
629 |
if (widget->style()) { |
|
630 |
widget->style()->polish(widget); |
|
631 |
QEvent event(QEvent::StyleChange); |
|
632 |
qApp->sendEvent(widget, &event); |
|
633 |
} |
|
634 |
widget->update(); |
|
635 |
widget->updateGeometry(); |
|
636 |
} |
|
637 |
} |
|
638 |
||
639 |
void QS60StylePrivate::setFont(QWidget *widget) const |
|
640 |
{ |
|
641 |
QS60StyleEnums::FontCategories fontCategory = QS60StyleEnums::FC_Undefined; |
|
642 |
if (!widget) |
|
643 |
return; |
|
644 |
if (qobject_cast<QPushButton *>(widget)){ |
|
645 |
fontCategory = QS60StyleEnums::FC_Primary; |
|
646 |
} else if (qobject_cast<QToolButton *>(widget)){ |
|
647 |
fontCategory = QS60StyleEnums::FC_Primary; |
|
648 |
} else if (qobject_cast<QHeaderView *>(widget)){ |
|
649 |
fontCategory = QS60StyleEnums::FC_Secondary; |
|
650 |
} else if (qobject_cast<QGroupBox *>(widget)){ |
|
651 |
fontCategory = QS60StyleEnums::FC_Title; |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
652 |
} else if (qobject_cast<QMessageBox *>(widget)){ |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
653 |
fontCategory = QS60StyleEnums::FC_Primary; |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
654 |
} else if (qobject_cast<QMenu *>(widget)){ |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
655 |
fontCategory = QS60StyleEnums::FC_Primary; |
0 | 656 |
} |
657 |
if (fontCategory != QS60StyleEnums::FC_Undefined) { |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
658 |
const bool resolveFontSize = widget->testAttribute(Qt::WA_SetFont) |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
659 |
&& (widget->font().resolve() & QFont::SizeResolved); |
0 | 660 |
const QFont suggestedFont = |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
661 |
s60Font(fontCategory, widget->font().pointSizeF(), resolveFontSize); |
0 | 662 |
widget->setFont(suggestedFont); |
663 |
} |
|
664 |
} |
|
665 |
||
666 |
void QS60StylePrivate::setThemePalette(QWidget *widget) const |
|
667 |
{ |
|
668 |
if(!widget) |
|
669 |
return; |
|
670 |
||
671 |
//header view and its viewport need to be set 100% transparent button color, since drawing code will |
|
672 |
//draw transparent theme graphics to table column and row headers. |
|
673 |
if (qobject_cast<QHeaderView *>(widget)){ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
674 |
QPalette widgetPalette = QApplication::palette(widget); |
0 | 675 |
widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, |
676 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0)); |
|
677 |
QHeaderView* header = qobject_cast<QHeaderView *>(widget); |
|
678 |
widgetPalette.setColor(QPalette::Button, Qt::transparent ); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
679 |
if (header->viewport()) |
0 | 680 |
header->viewport()->setPalette(widgetPalette); |
681 |
QApplication::setPalette(widgetPalette, "QHeaderView"); |
|
682 |
} |
|
683 |
} |
|
684 |
||
685 |
void QS60StylePrivate::setThemePalette(QPalette *palette) const |
|
686 |
{ |
|
687 |
if (!palette) |
|
688 |
return; |
|
689 |
||
690 |
// basic colors |
|
691 |
palette->setColor(QPalette::WindowText, |
|
692 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); |
|
693 |
palette->setColor(QPalette::ButtonText, |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
694 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 20, 0)); |
0 | 695 |
palette->setColor(QPalette::Text, |
696 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); |
|
697 |
palette->setColor(QPalette::ToolTipText, |
|
698 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 55, 0)); |
|
699 |
palette->setColor(QPalette::BrightText, palette->color(QPalette::WindowText).lighter()); |
|
700 |
palette->setColor(QPalette::HighlightedText, |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
701 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); |
0 | 702 |
palette->setColor(QPalette::Link, |
703 |
s60Color(QS60StyleEnums::CL_QsnHighlightColors, 3, 0)); |
|
704 |
palette->setColor(QPalette::LinkVisited, palette->color(QPalette::Link).darker()); |
|
705 |
palette->setColor(QPalette::Highlight, |
|
706 |
s60Color(QS60StyleEnums::CL_QsnHighlightColors, 2, 0)); |
|
707 |
// set background image as a texture brush |
|
708 |
palette->setBrush(QPalette::Window, backgroundTexture()); |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
709 |
// set as transparent so that styled full screen theme background is visible |
0 | 710 |
palette->setBrush(QPalette::Base, Qt::transparent); |
711 |
// set button and tooltipbase based on pixel colors |
|
712 |
const QColor buttonColor = colorFromFrameGraphics(SF_ButtonNormal); |
|
713 |
palette->setColor(QPalette::Button, buttonColor); |
|
714 |
const QColor toolTipColor = colorFromFrameGraphics(SF_ToolTip); |
|
715 |
palette->setColor(QPalette::ToolTipBase, toolTipColor); |
|
716 |
palette->setColor(QPalette::Light, palette->color(QPalette::Button).lighter()); |
|
717 |
palette->setColor(QPalette::Dark, palette->color(QPalette::Button).darker()); |
|
718 |
palette->setColor(QPalette::Midlight, palette->color(QPalette::Button).lighter(125)); |
|
719 |
palette->setColor(QPalette::Mid, palette->color(QPalette::Button).darker(150)); |
|
720 |
palette->setColor(QPalette::Shadow, Qt::black); |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
721 |
QColor alternateBase = palette->light().color(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
722 |
alternateBase.setAlphaF(0.8); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
723 |
palette->setColor(QPalette::AlternateBase, alternateBase); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
724 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
725 |
QApplication::setPalette(*palette); //calling QApplication::setPalette clears palette hash |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
726 |
setThemePaletteHash(palette); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
727 |
storeThemePalette(palette); |
0 | 728 |
} |
729 |
||
730 |
void QS60StylePrivate::deleteThemePalette() |
|
731 |
{ |
|
732 |
if (m_themePalette) { |
|
733 |
delete m_themePalette; |
|
734 |
m_themePalette = 0; |
|
735 |
} |
|
736 |
} |
|
737 |
||
738 |
void QS60StylePrivate::storeThemePalette(QPalette *palette) |
|
739 |
{ |
|
740 |
deleteThemePalette(); |
|
741 |
//store specified palette for latter use. |
|
742 |
m_themePalette = new QPalette(*palette); |
|
743 |
} |
|
744 |
||
745 |
// set widget specific palettes |
|
746 |
void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const |
|
747 |
{ |
|
748 |
if (!palette) |
|
749 |
return; |
|
750 |
||
751 |
//store the original palette |
|
752 |
QPalette widgetPalette = *palette; |
|
753 |
const QColor mainAreaTextColor = |
|
754 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0); |
|
755 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
756 |
widgetPalette.setColor(QPalette::WindowText, |
0 | 757 |
s60Color(QS60StyleEnums::CL_QsnLineColors, 8, 0)); |
758 |
QApplication::setPalette(widgetPalette, "QSlider"); |
|
759 |
// return to original palette after each widget |
|
760 |
widgetPalette = *palette; |
|
761 |
||
762 |
widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, mainAreaTextColor); |
|
763 |
widgetPalette.setColor(QPalette::Inactive, QPalette::ButtonText, mainAreaTextColor); |
|
764 |
const QStyleOption opt; |
|
765 |
widgetPalette.setColor(QPalette::Disabled, QPalette::ButtonText, |
|
766 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 6, &opt)); |
|
767 |
QApplication::setPalette(widgetPalette, "QPushButton"); |
|
768 |
widgetPalette = *palette; |
|
769 |
||
770 |
widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, mainAreaTextColor); |
|
771 |
widgetPalette.setColor(QPalette::Inactive, QPalette::ButtonText, mainAreaTextColor); |
|
772 |
QApplication::setPalette(widgetPalette, "QToolButton"); |
|
773 |
widgetPalette = *palette; |
|
774 |
||
775 |
widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, |
|
776 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0)); |
|
777 |
QApplication::setPalette(widgetPalette, "QHeaderView"); |
|
778 |
widgetPalette = *palette; |
|
779 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
780 |
widgetPalette.setColor(QPalette::ButtonText, |
0 | 781 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 8, 0)); |
782 |
QApplication::setPalette(widgetPalette, "QMenuBar"); |
|
783 |
widgetPalette = *palette; |
|
784 |
||
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
785 |
widgetPalette.setColor(QPalette::Text, |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
786 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0)); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
787 |
widgetPalette.setColor(QPalette::HighlightedText, |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
788 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0)); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
789 |
QApplication::setPalette(widgetPalette, "QMenu"); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
790 |
widgetPalette = *palette; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
791 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
792 |
widgetPalette.setColor(QPalette::WindowText, |
0 | 793 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 4, 0)); |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
794 |
widgetPalette.setColor(QPalette::HighlightedText, |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
795 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 3, 0)); |
0 | 796 |
QApplication::setPalette(widgetPalette, "QTabBar"); |
797 |
widgetPalette = *palette; |
|
798 |
||
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
799 |
widgetPalette.setColor(QPalette::HighlightedText, |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
800 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0)); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
801 |
QApplication::setPalette(widgetPalette, "QListView"); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
802 |
widgetPalette = *palette; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
803 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
804 |
widgetPalette.setColor(QPalette::Text, |
0 | 805 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0)); |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
806 |
widgetPalette.setColor(QPalette::HighlightedText, |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
807 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0)); |
0 | 808 |
QApplication::setPalette(widgetPalette, "QTableView"); |
809 |
widgetPalette = *palette; |
|
810 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
811 |
widgetPalette.setColor(QPalette::Text, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
812 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 27, 0)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
813 |
widgetPalette.setColor(QPalette::HighlightedText, |
0 | 814 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); |
815 |
QApplication::setPalette(widgetPalette, "QLineEdit"); |
|
816 |
widgetPalette = *palette; |
|
817 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
818 |
widgetPalette.setColor(QPalette::Text, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
819 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 27, 0)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
820 |
widgetPalette.setColor(QPalette::HighlightedText, |
0 | 821 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); |
822 |
QApplication::setPalette(widgetPalette, "QTextEdit"); |
|
823 |
widgetPalette = *palette; |
|
824 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
825 |
widgetPalette.setColor(QPalette::HighlightedText, |
0 | 826 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); |
827 |
QApplication::setPalette(widgetPalette, "QComboBox"); |
|
828 |
widgetPalette = *palette; |
|
829 |
||
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
830 |
widgetPalette.setColor(QPalette::WindowText, s60Color(QS60StyleEnums::CL_QsnTextColors, 7, 0)); |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
831 |
widgetPalette.setColor(QPalette::HighlightedText, |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
832 |
s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0)); |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
833 |
QApplication::setPalette(widgetPalette, "QRadioButton"); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
834 |
QApplication::setPalette(widgetPalette, "QCheckBox"); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
835 |
widgetPalette = *palette; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
836 |
|
0 | 837 |
widgetPalette.setColor(QPalette::WindowText, mainAreaTextColor); |
838 |
widgetPalette.setColor(QPalette::Button, QApplication::palette().color(QPalette::Button)); |
|
839 |
widgetPalette.setColor(QPalette::Dark, mainAreaTextColor.darker()); |
|
840 |
widgetPalette.setColor(QPalette::Light, mainAreaTextColor.lighter()); |
|
841 |
QApplication::setPalette(widgetPalette, "QDial"); |
|
842 |
widgetPalette = *palette; |
|
843 |
||
844 |
widgetPalette.setBrush(QPalette::Window, QBrush()); |
|
845 |
QApplication::setPalette(widgetPalette, "QScrollArea"); |
|
846 |
widgetPalette = *palette; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
847 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
848 |
//Webpages should not use S60 theme colors as they are designed to work |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
849 |
//with themeBackground and do not generally mesh well with web page backgrounds. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
850 |
QPalette webPalette = *palette; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
851 |
webPalette.setColor(QPalette::WindowText, Qt::black); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
852 |
webPalette.setColor(QPalette::Text, Qt::black); |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
853 |
webPalette.setBrush(QPalette::Base, Qt::white); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
854 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
855 |
QApplication::setPalette(webPalette, "QWebView"); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
856 |
QApplication::setPalette(webPalette, "QGraphicsWebView"); |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
857 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
858 |
m_webPaletteKey = webPalette.cacheKey(); |
0 | 859 |
} |
860 |
||
861 |
QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags) |
|
862 |
{ |
|
863 |
QSize result(20, 20); |
|
864 |
switch (part) |
|
865 |
{ |
|
866 |
case QS60StyleEnums::SP_QgnGrafBarProgress: |
|
867 |
result.setWidth(pixelMetric(QStyle::PM_ProgressBarChunkWidth)); |
|
868 |
break; |
|
869 |
case QS60StyleEnums::SP_QgnGrafTabActiveM: |
|
870 |
case QS60StyleEnums::SP_QgnGrafTabPassiveM: |
|
871 |
case QS60StyleEnums::SP_QgnGrafTabActiveR: |
|
872 |
case QS60StyleEnums::SP_QgnGrafTabPassiveR: |
|
873 |
case QS60StyleEnums::SP_QgnGrafTabPassiveL: |
|
874 |
case QS60StyleEnums::SP_QgnGrafTabActiveL: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
875 |
//Returned QSize for tabs must not be square, but narrow rectangle with width:height |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
876 |
//ratio of 1:2 for horizontal tab bars (and 2:1 for vertical ones). |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
877 |
result.setWidth(result.height() >> 1); |
0 | 878 |
break; |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
879 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
880 |
case QS60StyleEnums::SP_QgnGrafNsliderEndLeft: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
881 |
case QS60StyleEnums::SP_QgnGrafNsliderEndRight: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
882 |
case QS60StyleEnums::SP_QgnGrafNsliderMiddle: |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
883 |
result.setWidth(result.height() >> 1); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
884 |
break; |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
885 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
886 |
case QS60StyleEnums::SP_QgnGrafNsliderMarker: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
887 |
case QS60StyleEnums::SP_QgnGrafNsliderMarkerSelected: |
0 | 888 |
result.scale(pixelMetric(QStyle::PM_SliderLength), |
889 |
pixelMetric(QStyle::PM_SliderControlThickness), Qt::IgnoreAspectRatio); |
|
890 |
break; |
|
891 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
892 |
case QS60StyleEnums::SP_QgnGrafBarFrameSideL: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
893 |
case QS60StyleEnums::SP_QgnGrafBarFrameSideR: |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
894 |
result.setWidth(pixelMetric(PM_FrameCornerWidth)); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
895 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
896 |
|
0 | 897 |
case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed: |
898 |
case QS60StyleEnums::SP_QsnCpScrollBgBottom: |
|
899 |
case QS60StyleEnums::SP_QsnCpScrollBgTop: |
|
900 |
case QS60StyleEnums::SP_QsnCpScrollHandleBottom: |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
901 |
case QS60StyleEnums::SP_QsnCpScrollHandleTop: |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
902 |
case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed: |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
903 |
result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent)); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
904 |
result.setWidth(pixelMetric(QStyle::PM_ScrollBarExtent)); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
905 |
break; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
906 |
case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed: |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
907 |
case QS60StyleEnums::SP_QsnCpScrollBgMiddle: |
0 | 908 |
case QS60StyleEnums::SP_QsnCpScrollHandleMiddle: |
909 |
result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent)); |
|
910 |
result.setWidth(pixelMetric(QStyle::PM_ScrollBarSliderMin)); |
|
911 |
break; |
|
912 |
default: |
|
913 |
// Generic frame part size gathering. |
|
914 |
for (int i = 0; i < frameElementsCount; ++i) |
|
915 |
{ |
|
916 |
switch (m_frameElementsData[i].center - part) { |
|
917 |
case 8: /* CornerTl */ |
|
918 |
case 7: /* CornerTr */ |
|
919 |
case 6: /* CornerBl */ |
|
920 |
case 5: /* CornerBr */ |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
921 |
result.setWidth(pixelMetric(PM_FrameCornerWidth)); |
0 | 922 |
// Falltrough intended... |
923 |
case 4: /* SideT */ |
|
924 |
case 3: /* SideB */ |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
925 |
result.setHeight(pixelMetric(PM_FrameCornerHeight)); |
0 | 926 |
break; |
927 |
case 2: /* SideL */ |
|
928 |
case 1: /* SideR */ |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
929 |
result.setWidth(pixelMetric(PM_FrameCornerWidth)); |
0 | 930 |
break; |
931 |
case 0: /* center */ |
|
932 |
default: |
|
933 |
break; |
|
934 |
} |
|
935 |
} |
|
936 |
break; |
|
937 |
} |
|
938 |
if (flags & (SF_PointEast | SF_PointWest)) { |
|
939 |
const int temp = result.width(); |
|
940 |
result.setWidth(result.height()); |
|
941 |
result.setHeight(temp); |
|
942 |
} |
|
943 |
return result; |
|
944 |
} |
|
945 |
||
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
946 |
bool QS60StylePrivate::canDrawThemeBackground(const QBrush &backgroundBrush, const QWidget *widget) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
947 |
{ |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
948 |
// Always return true for web pages. |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
949 |
if (widget && m_webPaletteKey == QApplication::palette(widget).cacheKey()) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
950 |
return true; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
951 |
//If brush is not changed from style's default values, draw theme graphics. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
952 |
return (backgroundBrush.color() == Qt::transparent || |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
953 |
backgroundBrush.style() == Qt::NoBrush) ? true : false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
954 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
955 |
|
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
956 |
bool QS60StylePrivate::isWidgetPressed(const QWidget *widget) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
957 |
{ |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
958 |
return (widget && widget == m_pressedWidget); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
959 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
960 |
|
0 | 961 |
/*! |
962 |
\class QS60Style |
|
963 |
\brief The QS60Style class provides a look and feel suitable for applications on S60. |
|
964 |
\since 4.6 |
|
965 |
\ingroup appearance |
|
966 |
||
967 |
\sa QMacStyle, QWindowsStyle, QWindowsXPStyle, QWindowsVistaStyle, QPlastiqueStyle, QCleanlooksStyle, QMotifStyle |
|
968 |
*/ |
|
969 |
||
970 |
||
971 |
/*! |
|
972 |
Destroys the style. |
|
973 |
*/ |
|
974 |
QS60Style::~QS60Style() |
|
975 |
{ |
|
976 |
} |
|
977 |
||
978 |
/*! |
|
979 |
\reimp |
|
980 |
*/ |
|
981 |
void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const |
|
982 |
{ |
|
983 |
const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled; |
|
984 |
SubControls sub = option->subControls; |
|
985 |
||
986 |
switch (control) { |
|
987 |
#ifndef QT_NO_SCROLLBAR |
|
988 |
case CC_ScrollBar: |
|
989 |
if (const QStyleOptionSlider *optionSlider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
990 |
const bool horizontal = optionSlider->orientation == Qt::Horizontal; |
|
991 |
||
992 |
const QRect scrollBarSlider = subControlRect(control, optionSlider, SC_ScrollBarSlider, widget); |
|
993 |
const QRect grooveRect = subControlRect(control, optionSlider, SC_ScrollBarGroove, widget); |
|
994 |
||
995 |
const QS60StylePrivate::SkinElements grooveElement = |
|
996 |
horizontal ? QS60StylePrivate::SE_ScrollBarGrooveHorizontal : QS60StylePrivate::SE_ScrollBarGrooveVertical; |
|
997 |
QS60StylePrivate::drawSkinElement(grooveElement, painter, grooveRect, flags); |
|
998 |
||
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
999 |
const SubControls subControls = optionSlider->subControls; |
0 | 1000 |
|
1001 |
// select correct slider (horizontal/vertical/pressed) |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1002 |
const bool sliderPressed = ((optionSlider->state & State_Sunken) && (subControls & SC_ScrollBarSlider)); |
0 | 1003 |
const QS60StylePrivate::SkinElements handleElement = |
1004 |
horizontal ? |
|
1005 |
( sliderPressed ? |
|
1006 |
QS60StylePrivate::SE_ScrollBarHandlePressedHorizontal : |
|
1007 |
QS60StylePrivate::SE_ScrollBarHandleHorizontal ) : |
|
1008 |
( sliderPressed ? |
|
1009 |
QS60StylePrivate::SE_ScrollBarHandlePressedVertical : |
|
1010 |
QS60StylePrivate::SE_ScrollBarHandleVertical); |
|
1011 |
QS60StylePrivate::drawSkinElement(handleElement, painter, scrollBarSlider, flags); |
|
1012 |
} |
|
1013 |
break; |
|
1014 |
#endif // QT_NO_SCROLLBAR |
|
1015 |
#ifndef QT_NO_SLIDER |
|
1016 |
case CC_Slider: |
|
1017 |
if (const QStyleOptionSlider *optionSlider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
1018 |
||
1019 |
const QRect sliderGroove = subControlRect(control, optionSlider, SC_SliderGroove, widget); |
|
1020 |
const bool horizontal = optionSlider->orientation == Qt::Horizontal; |
|
1021 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1022 |
//Highlight |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1023 |
/* if (optionSlider->state & State_HasFocus) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1024 |
drawPrimitive(PE_FrameFocusRect, optionSlider, painter, widget);*/ |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1025 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1026 |
//Groove graphics |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1027 |
if (QS60StylePrivate::hasSliderGrooveGraphic()) { |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1028 |
const QS60StylePrivate::SkinElements grooveElement = horizontal ? |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1029 |
QS60StylePrivate::SE_SliderGrooveHorizontal : |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1030 |
QS60StylePrivate::SE_SliderGrooveVertical; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1031 |
QS60StylePrivate::drawSkinElement(grooveElement, painter, sliderGroove, flags); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1032 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1033 |
const QPoint sliderGrooveCenter = sliderGroove.center(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1034 |
const bool horizontal = optionSlider->orientation == Qt::Horizontal; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1035 |
painter->save(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1036 |
if (widget) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1037 |
painter->setPen(widget->palette().windowText().color()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1038 |
if (horizontal) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1039 |
painter->drawLine(0, sliderGrooveCenter.y(), sliderGroove.right(), sliderGrooveCenter.y()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1040 |
else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1041 |
painter->drawLine(sliderGrooveCenter.x(), 0, sliderGrooveCenter.x(), sliderGroove.bottom()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1042 |
painter->restore(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1043 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1044 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1045 |
//Handle graphics |
0 | 1046 |
const QRect sliderHandle = subControlRect(control, optionSlider, SC_SliderHandle, widget); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1047 |
QS60StylePrivate::SkinElements handleElement; |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1048 |
if (optionSlider->state & State_Sunken) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1049 |
handleElement = |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1050 |
horizontal ? QS60StylePrivate::SE_SliderHandleSelectedHorizontal : QS60StylePrivate::SE_SliderHandleSelectedVertical; |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1051 |
else |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1052 |
handleElement = |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1053 |
horizontal ? QS60StylePrivate::SE_SliderHandleHorizontal : QS60StylePrivate::SE_SliderHandleVertical; |
0 | 1054 |
QS60StylePrivate::drawSkinElement(handleElement, painter, sliderHandle, flags); |
1055 |
} |
|
1056 |
break; |
|
1057 |
#endif // QT_NO_SLIDER |
|
1058 |
#ifndef QT_NO_COMBOBOX |
|
1059 |
case CC_ComboBox: |
|
1060 |
if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
|
1061 |
const QRect cmbxEditField = subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget); |
|
1062 |
const QRect cmbxFrame = subControlRect(CC_ComboBox, option, SC_ComboBoxFrame, widget); |
|
1063 |
const bool direction = cmb->direction == Qt::LeftToRight; |
|
1064 |
||
1065 |
// Button frame |
|
1066 |
QStyleOptionFrame buttonOption; |
|
1067 |
buttonOption.QStyleOption::operator=(*cmb); |
|
1068 |
const int maxHeight = cmbxFrame.height(); |
|
1069 |
const int maxWidth = cmbxFrame.width() - cmbxEditField.width(); |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1070 |
const int topLeftPoint = direction ? |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1071 |
(cmbxEditField.right() + 1) : (cmbxEditField.left() + 1 - maxWidth); |
0 | 1072 |
const QRect buttonRect(topLeftPoint, cmbxEditField.top(), maxWidth, maxHeight); |
1073 |
buttonOption.rect = buttonRect; |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1074 |
buttonOption.state = cmb->state; |
0 | 1075 |
drawPrimitive(PE_PanelButtonCommand, &buttonOption, painter, widget); |
1076 |
||
1077 |
// draw label background - label itself is drawn separately |
|
1078 |
const QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_FrameLineEdit; |
|
1079 |
QS60StylePrivate::drawSkinElement(skinElement, painter, cmbxEditField, flags); |
|
1080 |
||
1081 |
// Draw the combobox arrow |
|
1082 |
if (sub & SC_ComboBoxArrow) { |
|
1083 |
// Make rect slightly smaller |
|
1084 |
buttonOption.rect.adjust(1, 1, -1, -1); |
|
1085 |
painter->save(); |
|
1086 |
painter->setPen(option->palette.buttonText().color()); |
|
1087 |
drawPrimitive(PE_IndicatorSpinDown, &buttonOption, painter, widget); |
|
1088 |
painter->restore(); |
|
1089 |
} |
|
1090 |
} |
|
1091 |
break; |
|
1092 |
#endif // QT_NO_COMBOBOX |
|
1093 |
#ifndef QT_NO_TOOLBUTTON |
|
1094 |
case CC_ToolButton: |
|
1095 |
if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1096 |
State bflags = toolBtn->state & ~State_Sunken; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1097 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1098 |
if (bflags & State_AutoRaise) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1099 |
if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1100 |
bflags &= ~State_Raised; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1101 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1102 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1103 |
State mflags = bflags; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1104 |
if (toolBtn->state & State_Sunken) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1105 |
if (toolBtn->activeSubControls & SC_ToolButton) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1106 |
bflags |= State_Sunken; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1107 |
mflags |= State_Sunken; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1108 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1109 |
|
0 | 1110 |
const QRect button(subControlRect(control, toolBtn, SC_ToolButton, widget)); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1111 |
QRect menuRect = QRect(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1112 |
if (toolBtn->subControls & SC_ToolButtonMenu) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1113 |
menuRect = subControlRect(control, toolBtn, SC_ToolButtonMenu, widget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1114 |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1115 |
if (toolBtn->subControls & SC_ToolButton) { |
0 | 1116 |
QStyleOption tool(0); |
1117 |
tool.palette = toolBtn->palette; |
|
1118 |
||
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1119 |
if (bflags & (State_Sunken | State_On | State_Raised | State_Enabled)) { |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1120 |
tool.rect = button.unite(menuRect); |
0 | 1121 |
tool.state = bflags; |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1122 |
const QToolButton *toolButtonWidget = qobject_cast<const QToolButton *>(widget); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1123 |
QS60StylePrivate::SkinElements element; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1124 |
if (toolButtonWidget) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1125 |
element = (toolButtonWidget->isDown()) ? QS60StylePrivate::SE_ToolBarButtonPressed : QS60StylePrivate::SE_ToolBarButton; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1126 |
else |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1127 |
element = (option->state & State_Sunken) ? QS60StylePrivate::SE_ToolBarButtonPressed : QS60StylePrivate::SE_ToolBarButton; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1128 |
QS60StylePrivate::drawSkinElement(element, painter, tool.rect, flags); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1129 |
drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1130 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1131 |
if (toolBtn->subControls & SC_ToolButtonMenu) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1132 |
tool.rect = menuRect; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1133 |
tool.state = mflags; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1134 |
drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget); |
0 | 1135 |
} |
1136 |
} |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1137 |
QStyleOptionToolButton toolButton = *toolBtn; |
0 | 1138 |
if (toolBtn->features & QStyleOptionToolButton::Arrow) { |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1139 |
PrimitiveElement pe; |
0 | 1140 |
switch (toolBtn->arrowType) { |
1141 |
case Qt::LeftArrow: |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1142 |
pe = PE_IndicatorArrowLeft; |
0 | 1143 |
break; |
1144 |
case Qt::RightArrow: |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1145 |
pe = PE_IndicatorArrowRight; |
0 | 1146 |
break; |
1147 |
case Qt::UpArrow: |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1148 |
pe = PE_IndicatorArrowUp; |
0 | 1149 |
break; |
1150 |
case Qt::DownArrow: |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1151 |
pe = PE_IndicatorArrowDown; |
0 | 1152 |
break; |
1153 |
default: |
|
1154 |
break; } |
|
1155 |
toolButton.rect = button; |
|
1156 |
drawPrimitive(pe, &toolButton, painter, widget); |
|
1157 |
} |
|
1158 |
||
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1159 |
if (toolBtn->text.length() > 0 || |
0 | 1160 |
!toolBtn->icon.isNull()) { |
1161 |
const int frameWidth = pixelMetric(PM_DefaultFrameWidth, option, widget); |
|
1162 |
toolButton.rect = button.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth); |
|
1163 |
drawControl(CE_ToolButtonLabel, &toolButton, painter, widget); |
|
1164 |
} |
|
1165 |
} |
|
1166 |
break; |
|
1167 |
#endif //QT_NO_TOOLBUTTON |
|
1168 |
#ifndef QT_NO_SPINBOX |
|
1169 |
case CC_SpinBox: |
|
1170 |
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
|
1171 |
QStyleOptionSpinBox copy = *spinBox; |
|
1172 |
PrimitiveElement pe; |
|
1173 |
||
1174 |
if (spinBox->subControls & SC_SpinBoxUp) { |
|
1175 |
copy.subControls = SC_SpinBoxUp; |
|
1176 |
QPalette spinBoxPal = spinBox->palette; |
|
1177 |
if (!(spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled)) { |
|
1178 |
spinBoxPal.setCurrentColorGroup(QPalette::Disabled); |
|
1179 |
copy.state &= ~State_Enabled; |
|
1180 |
copy.palette = spinBoxPal; |
|
1181 |
} |
|
1182 |
||
1183 |
if (spinBox->activeSubControls == SC_SpinBoxUp && (spinBox->state & State_Sunken)) { |
|
1184 |
copy.state |= State_On; |
|
1185 |
copy.state |= State_Sunken; |
|
1186 |
} else { |
|
1187 |
copy.state |= State_Raised; |
|
1188 |
copy.state &= ~State_Sunken; |
|
1189 |
} |
|
1190 |
pe = (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) ? |
|
1191 |
PE_IndicatorSpinPlus : |
|
1192 |
PE_IndicatorSpinUp; |
|
1193 |
||
1194 |
copy.rect = subControlRect(CC_SpinBox, spinBox, SC_SpinBoxUp, widget); |
|
1195 |
drawPrimitive(PE_PanelButtonBevel, ©, painter, widget); |
|
1196 |
copy.rect.adjust(1, 1, -1, -1); |
|
1197 |
drawPrimitive(pe, ©, painter, widget); |
|
1198 |
} |
|
1199 |
||
1200 |
if (spinBox->subControls & SC_SpinBoxDown) { |
|
1201 |
copy.subControls = SC_SpinBoxDown; |
|
1202 |
copy.state = spinBox->state; |
|
1203 |
QPalette spinBoxPal = spinBox->palette; |
|
1204 |
if (!(spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) { |
|
1205 |
spinBoxPal.setCurrentColorGroup(QPalette::Disabled); |
|
1206 |
copy.state &= ~State_Enabled; |
|
1207 |
copy.palette = spinBoxPal; |
|
1208 |
} |
|
1209 |
||
1210 |
if (spinBox->activeSubControls == SC_SpinBoxDown && (spinBox->state & State_Sunken)) { |
|
1211 |
copy.state |= State_On; |
|
1212 |
copy.state |= State_Sunken; |
|
1213 |
} else { |
|
1214 |
copy.state |= State_Raised; |
|
1215 |
copy.state &= ~State_Sunken; |
|
1216 |
} |
|
1217 |
pe = (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) ? |
|
1218 |
PE_IndicatorSpinMinus : |
|
1219 |
PE_IndicatorSpinDown; |
|
1220 |
||
1221 |
copy.rect = subControlRect(CC_SpinBox, spinBox, SC_SpinBoxDown, widget); |
|
1222 |
drawPrimitive(PE_PanelButtonBevel, ©, painter, widget); |
|
1223 |
copy.rect.adjust(1, 1, -1, -1); |
|
1224 |
drawPrimitive(pe, ©, painter, widget); |
|
1225 |
} |
|
1226 |
} |
|
1227 |
break; |
|
1228 |
#endif //QT_NO_SPINBOX |
|
1229 |
#ifndef QT_NO_GROUPBOX |
|
1230 |
case CC_GroupBox: |
|
1231 |
if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { |
|
1232 |
// Draw frame |
|
1233 |
const QRect textRect = subControlRect(CC_GroupBox, option, SC_GroupBoxLabel, widget); |
|
1234 |
const QRect checkBoxRect = subControlRect(CC_GroupBox, option, SC_GroupBoxCheckBox, widget); |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1235 |
if (groupBox->subControls & SC_GroupBoxFrame) { |
0 | 1236 |
QStyleOptionFrameV2 frame; |
1237 |
frame.QStyleOption::operator=(*groupBox); |
|
1238 |
frame.features = groupBox->features; |
|
1239 |
frame.lineWidth = groupBox->lineWidth; |
|
1240 |
frame.midLineWidth = groupBox->midLineWidth; |
|
1241 |
frame.rect = subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget); |
|
1242 |
drawPrimitive(PE_FrameGroupBox, &frame, painter, widget); |
|
1243 |
} |
|
1244 |
||
1245 |
// Draw title |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1246 |
if ((groupBox->subControls & SC_GroupBoxLabel) && !groupBox->text.isEmpty()) { |
0 | 1247 |
const QColor textColor = groupBox->textColor; |
1248 |
painter->save(); |
|
1249 |
||
1250 |
if (textColor.isValid()) |
|
1251 |
painter->setPen(textColor); |
|
1252 |
int alignment = int(groupBox->textAlignment); |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1253 |
if (!styleHint(SH_UnderlineShortcut, option, widget)) |
0 | 1254 |
alignment |= Qt::TextHideMnemonic; |
1255 |
||
1256 |
drawItemText(painter, textRect, Qt::TextShowMnemonic | Qt::AlignHCenter | Qt::AlignVCenter | alignment, |
|
1257 |
groupBox->palette, groupBox->state & State_Enabled, groupBox->text, |
|
1258 |
textColor.isValid() ? QPalette::NoRole : QPalette::WindowText); |
|
1259 |
painter->restore(); |
|
1260 |
} |
|
1261 |
||
1262 |
// Draw checkbox |
|
1263 |
if (groupBox->subControls & SC_GroupBoxCheckBox) { |
|
1264 |
QStyleOptionButton box; |
|
1265 |
box.QStyleOption::operator=(*groupBox); |
|
1266 |
box.rect = checkBoxRect; |
|
1267 |
drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget); |
|
1268 |
} |
|
1269 |
} |
|
1270 |
break; |
|
1271 |
#endif //QT_NO_GROUPBOX |
|
1272 |
default: |
|
1273 |
QCommonStyle::drawComplexControl(control, option, painter, widget); |
|
1274 |
} |
|
1275 |
} |
|
1276 |
||
1277 |
/*! |
|
1278 |
\reimp |
|
1279 |
*/ |
|
1280 |
void QS60Style::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const |
|
1281 |
{ |
|
1282 |
Q_D(const QS60Style); |
|
1283 |
const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled; |
|
1284 |
switch (element) { |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1285 |
case CE_CheckBox: |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1286 |
case CE_RadioButton: |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1287 |
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1288 |
bool isRadio = (element == CE_RadioButton); |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1289 |
QStyleOptionButton subopt = *btn; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1290 |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1291 |
// Highlight needs to be drawn first, as it goes "underneath" the text and indicator. |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1292 |
if (btn->state & State_HasFocus) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1293 |
QStyleOptionFocusRect fropt; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1294 |
fropt.QStyleOption::operator=(*btn); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1295 |
fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1296 |
: SE_CheckBoxFocusRect, btn, widget); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1297 |
drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1298 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1299 |
subopt.palette.setColor(QPalette::Active, QPalette::WindowText, |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1300 |
subopt.palette.highlightedText().color()); |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1301 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1302 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1303 |
subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1304 |
: SE_CheckBoxIndicator, btn, widget); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1305 |
drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1306 |
&subopt, painter, widget); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1307 |
subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1308 |
: SE_CheckBoxContents, btn, widget); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1309 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1310 |
drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, painter, widget); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1311 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1312 |
break; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1313 |
|
0 | 1314 |
case CE_PushButton: |
1315 |
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
|
1316 |
||
1317 |
drawControl(CE_PushButtonBevel, btn, painter, widget); |
|
1318 |
QStyleOptionButton subopt = *btn; |
|
1319 |
subopt.rect = subElementRect(SE_PushButtonContents, btn, widget); |
|
1320 |
||
1321 |
drawControl(CE_PushButtonLabel, &subopt, painter, widget); |
|
1322 |
} |
|
1323 |
break; |
|
1324 |
case CE_PushButtonBevel: |
|
1325 |
if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1326 |
const bool isDisabled = !(option->state & State_Enabled); |
0 | 1327 |
const bool isFlat = button->features & QStyleOptionButton::Flat; |
1328 |
QS60StyleEnums::SkinParts skinPart; |
|
1329 |
QS60StylePrivate::SkinElements skinElement; |
|
1330 |
if (!isDisabled) { |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1331 |
const bool isPressed = (option->state & State_Sunken) || |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1332 |
(option->state & State_On); |
0 | 1333 |
if (isFlat) { |
1334 |
skinPart = |
|
1335 |
isPressed ? QS60StyleEnums::SP_QsnFrButtonTbCenterPressed : QS60StyleEnums::SP_QsnFrButtonTbCenter; |
|
1336 |
} else { |
|
1337 |
skinElement = |
|
1338 |
isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal; |
|
1339 |
} |
|
1340 |
} else { |
|
1341 |
if (isFlat) |
|
1342 |
skinPart =QS60StyleEnums::SP_QsnFrButtonCenterInactive; |
|
1343 |
else |
|
1344 |
skinElement = QS60StylePrivate::SE_ButtonInactive; |
|
1345 |
} |
|
1346 |
if (isFlat) |
|
1347 |
QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags); |
|
1348 |
else |
|
1349 |
QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); |
|
1350 |
} |
|
1351 |
break; |
|
1352 |
#ifndef QT_NO_TOOLBUTTON |
|
1353 |
case CE_ToolButtonLabel: |
|
1354 |
if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { |
|
1355 |
QStyleOptionToolButton optionToolButton = *toolBtn; |
|
1356 |
||
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1357 |
if (!optionToolButton.icon.isNull() && (optionToolButton.state & State_Sunken) |
0 | 1358 |
&& (optionToolButton.state & State_Enabled)) { |
1359 |
||
1360 |
const QIcon::State state = optionToolButton.state & State_On ? QIcon::On : QIcon::Off; |
|
1361 |
const QPixmap pm(optionToolButton.icon.pixmap(optionToolButton.rect.size().boundedTo(optionToolButton.iconSize), |
|
1362 |
QIcon::Normal, state)); |
|
1363 |
optionToolButton.icon = generatedIconPixmap(QIcon::Selected, pm, &optionToolButton); |
|
1364 |
} |
|
1365 |
||
1366 |
QCommonStyle::drawControl(element, &optionToolButton, painter, widget); |
|
1367 |
} |
|
1368 |
break; |
|
1369 |
#endif //QT_NO_TOOLBUTTON |
|
1370 |
#ifndef QT_NO_COMBOBOX |
|
1371 |
case CE_ComboBoxLabel: |
|
1372 |
if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
|
1373 |
QStyleOption optionComboBox = *comboBox; |
|
1374 |
optionComboBox.palette.setColor(QPalette::Active, QPalette::WindowText, |
|
1375 |
optionComboBox.palette.text().color() ); |
|
1376 |
optionComboBox.palette.setColor(QPalette::Inactive, QPalette::WindowText, |
|
1377 |
optionComboBox.palette.text().color() ); |
|
1378 |
QRect editRect = subControlRect(CC_ComboBox, comboBox, SC_ComboBoxEditField, widget); |
|
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1379 |
const int frameW = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget); |
0 | 1380 |
|
1381 |
if (!comboBox->currentIcon.isNull()) { |
|
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1382 |
const QIcon::Mode mode = comboBox->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1383 |
const QPixmap pixmap = comboBox->currentIcon.pixmap(comboBox->iconSize, mode); |
0 | 1384 |
QRect iconRect(editRect); |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1385 |
iconRect.setWidth(comboBox->iconSize.width() + frameW); |
0 | 1386 |
iconRect = alignedRect(comboBox->direction, |
1387 |
Qt::AlignLeft | Qt::AlignVCenter, |
|
1388 |
iconRect.size(), editRect); |
|
1389 |
if (comboBox->editable) |
|
1390 |
painter->fillRect(iconRect, optionComboBox.palette.brush(QPalette::Base)); |
|
1391 |
drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); |
|
1392 |
||
1393 |
if (comboBox->direction == Qt::RightToLeft) |
|
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1394 |
editRect.setRight(editRect.right() - frameW - comboBox->iconSize.width()); |
0 | 1395 |
else |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1396 |
editRect.setLeft(comboBox->iconSize.width() + frameW); |
0 | 1397 |
} |
1398 |
if (!comboBox->currentText.isEmpty() && !comboBox->editable) { |
|
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1399 |
const Qt::TextElideMode elideMode = (comboBox->direction == Qt::LeftToRight) ? Qt::ElideRight : Qt::ElideLeft; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1400 |
const QString text = comboBox->fontMetrics.elidedText(comboBox->currentText, elideMode, editRect.width()); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1401 |
|
0 | 1402 |
QCommonStyle::drawItemText(painter, |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1403 |
editRect.adjusted(QS60StylePrivate::pixelMetric(PM_FrameCornerWidth), 0, -1, 0), |
0 | 1404 |
visualAlignment(comboBox->direction, Qt::AlignLeft | Qt::AlignVCenter), |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1405 |
comboBox->palette, comboBox->state & State_Enabled, text); |
0 | 1406 |
} |
1407 |
} |
|
1408 |
break; |
|
1409 |
#endif //QT_NO_COMBOBOX |
|
1410 |
#ifndef QT_NO_ITEMVIEWS |
|
1411 |
case CE_ItemViewItem: |
|
1412 |
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
|
1413 |
QStyleOptionViewItemV4 voptAdj = *vopt; |
|
1414 |
painter->save(); |
|
1415 |
||
1416 |
painter->setClipRect(voptAdj.rect); |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1417 |
const bool isSelected = (vopt->state & State_Selected); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1418 |
const bool hasFocus = (vopt->state & State_HasFocus); |
0 | 1419 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1420 |
bool isScrollBarVisible = false; |
0 | 1421 |
int scrollBarWidth = 0; |
1422 |
QList<QScrollBar *> scrollBars = qFindChildren<QScrollBar *>(widget); |
|
1423 |
for (int i = 0; i < scrollBars.size(); ++i) { |
|
1424 |
QScrollBar *scrollBar = scrollBars.at(i); |
|
1425 |
if (scrollBar && scrollBar->orientation() == Qt::Vertical) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1426 |
isScrollBarVisible = scrollBar->isVisible(); |
0 | 1427 |
scrollBarWidth = scrollBar->size().width(); |
1428 |
break; |
|
1429 |
} |
|
1430 |
} |
|
1431 |
||
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1432 |
int rightValue = widget ? widget->contentsRect().right() : voptAdj.rect.right(); |
0 | 1433 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1434 |
if (isScrollBarVisible) |
0 | 1435 |
rightValue -= scrollBarWidth; |
1436 |
||
1437 |
if (voptAdj.rect.right() > rightValue) |
|
1438 |
voptAdj.rect.setRight(rightValue); |
|
1439 |
||
1440 |
const QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &voptAdj, widget); |
|
1441 |
QRect textRect = subElementRect(SE_ItemViewItemText, &voptAdj, widget); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1442 |
const QAbstractItemView *itemView = qobject_cast<const QAbstractItemView *>(widget); |
0 | 1443 |
|
1444 |
// draw themed background for table unless background brush has been defined. |
|
1445 |
if (vopt->backgroundBrush == Qt::NoBrush) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1446 |
if (itemView) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1447 |
drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget); |
0 | 1448 |
} |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1449 |
} else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget);} |
0 | 1450 |
|
1451 |
// draw the icon |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1452 |
const QIcon::Mode mode = (voptAdj.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled; |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1453 |
const QIcon::State state = (voptAdj.state & State_Open) ? QIcon::On : QIcon::Off; |
0 | 1454 |
voptAdj.icon.paint(painter, iconRect, voptAdj.decorationAlignment, mode, state); |
1455 |
||
1456 |
// Draw selection check mark. Show check mark only in multi selection modes. |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1457 |
if (itemView) { |
0 | 1458 |
const bool singleSelection = |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1459 |
(itemView->selectionMode() == QAbstractItemView::SingleSelection || |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1460 |
itemView->selectionMode() == QAbstractItemView::NoSelection)|| |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1461 |
(itemView->selectionModel()->selectedIndexes().count() < 2 ); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1462 |
|
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1463 |
const bool selectItemsOnly = (itemView->selectionBehavior() == QAbstractItemView::SelectItems); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1464 |
|
0 | 1465 |
const QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, &voptAdj, widget); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1466 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1467 |
QStyleOptionViewItemV4 checkMarkOption(voptAdj); |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1468 |
if (selectionRect.isValid()) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1469 |
checkMarkOption.rect = selectionRect; |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1470 |
// Draw selection mark. |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1471 |
if (isSelected && !singleSelection && selectItemsOnly) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1472 |
proxy()->drawPrimitive(PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1473 |
// @todo: this should happen in the rect retrievel i.e. subElementRect() |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1474 |
if (textRect.right() > selectionRect.left()) |
0 | 1475 |
textRect.setRight(selectionRect.left()); |
1476 |
} else if (singleSelection && |
|
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1477 |
voptAdj.features & QStyleOptionViewItemV2::HasCheckIndicator) { |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1478 |
checkMarkOption.state = checkMarkOption.state & ~State_HasFocus; |
0 | 1479 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1480 |
switch (vopt->checkState) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1481 |
case Qt::Unchecked: |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1482 |
checkMarkOption.state |= State_Off; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1483 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1484 |
case Qt::PartiallyChecked: |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1485 |
checkMarkOption.state |= State_NoChange; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1486 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1487 |
case Qt::Checked: |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1488 |
checkMarkOption.state |= State_On; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1489 |
break; |
0 | 1490 |
} |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1491 |
drawPrimitive(PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget); |
0 | 1492 |
} |
1493 |
} |
|
1494 |
||
1495 |
// draw the text |
|
1496 |
if (!voptAdj.text.isEmpty()) { |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1497 |
if (isSelected || hasFocus ) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1498 |
painter->setPen(voptAdj.palette.highlightedText().color()); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1499 |
else |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1500 |
painter->setPen(voptAdj.palette.text().color()); |
0 | 1501 |
d->viewItemDrawText(painter, &voptAdj, textRect); |
1502 |
} |
|
1503 |
painter->restore(); |
|
1504 |
} |
|
1505 |
break; |
|
1506 |
#endif // QT_NO_ITEMVIEWS |
|
1507 |
#ifndef QT_NO_TABBAR |
|
1508 |
case CE_TabBarTabShape: |
|
1509 |
if (const QStyleOptionTabV3 *optionTab = qstyleoption_cast<const QStyleOptionTabV3 *>(option)) { |
|
1510 |
QStyleOptionTabV3 optionTabAdj = *optionTab; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1511 |
const bool isSelected = optionTab->state & State_Selected; |
0 | 1512 |
const bool directionMirrored = (optionTab->direction == Qt::RightToLeft); |
1513 |
QS60StylePrivate::SkinElements skinElement; |
|
1514 |
switch (optionTab->shape) { |
|
1515 |
case QTabBar::TriangularEast: |
|
1516 |
case QTabBar::RoundedEast: |
|
1517 |
skinElement = isSelected ? QS60StylePrivate::SE_TabBarTabEastActive: |
|
1518 |
QS60StylePrivate::SE_TabBarTabEastInactive; |
|
1519 |
break; |
|
1520 |
case QTabBar::TriangularSouth: |
|
1521 |
case QTabBar::RoundedSouth: |
|
1522 |
skinElement = isSelected ? QS60StylePrivate::SE_TabBarTabSouthActive: |
|
1523 |
QS60StylePrivate::SE_TabBarTabSouthInactive; |
|
1524 |
break; |
|
1525 |
case QTabBar::TriangularWest: |
|
1526 |
case QTabBar::RoundedWest: |
|
1527 |
skinElement = isSelected ? QS60StylePrivate::SE_TabBarTabWestActive: |
|
1528 |
QS60StylePrivate::SE_TabBarTabWestInactive; |
|
1529 |
break; |
|
1530 |
case QTabBar::TriangularNorth: |
|
1531 |
case QTabBar::RoundedNorth: |
|
1532 |
default: |
|
1533 |
skinElement = isSelected ? QS60StylePrivate::SE_TabBarTabNorthActive: |
|
1534 |
QS60StylePrivate::SE_TabBarTabNorthInactive; |
|
1535 |
break; |
|
1536 |
} |
|
1537 |
if (skinElement==QS60StylePrivate::SE_TabBarTabEastInactive|| |
|
1538 |
skinElement==QS60StylePrivate::SE_TabBarTabNorthInactive|| |
|
1539 |
skinElement==QS60StylePrivate::SE_TabBarTabSouthInactive|| |
|
1540 |
skinElement==QS60StylePrivate::SE_TabBarTabWestInactive|| |
|
1541 |
skinElement==QS60StylePrivate::SE_TabBarTabEastActive|| |
|
1542 |
skinElement==QS60StylePrivate::SE_TabBarTabNorthActive|| |
|
1543 |
skinElement==QS60StylePrivate::SE_TabBarTabSouthActive|| |
|
1544 |
skinElement==QS60StylePrivate::SE_TabBarTabWestActive) { |
|
1545 |
const int borderThickness = |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1546 |
QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
0 | 1547 |
const int tabOverlap = |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1548 |
QS60StylePrivate::pixelMetric(PM_TabBarTabOverlap) - borderThickness; |
0 | 1549 |
|
1550 |
if (skinElement==QS60StylePrivate::SE_TabBarTabEastInactive|| |
|
1551 |
skinElement==QS60StylePrivate::SE_TabBarTabEastActive|| |
|
1552 |
skinElement==QS60StylePrivate::SE_TabBarTabWestInactive|| |
|
1553 |
skinElement==QS60StylePrivate::SE_TabBarTabWestActive){ |
|
1554 |
optionTabAdj.rect.adjust(0, 0, 0, tabOverlap); |
|
1555 |
} else { |
|
1556 |
if (directionMirrored) |
|
1557 |
optionTabAdj.rect.adjust(-tabOverlap, 0, 0, 0); |
|
1558 |
else |
|
1559 |
optionTabAdj.rect.adjust(0, 0, tabOverlap, 0); |
|
1560 |
} |
|
1561 |
} |
|
1562 |
QS60StylePrivate::drawSkinElement(skinElement, painter, optionTabAdj.rect, flags); |
|
1563 |
} |
|
1564 |
break; |
|
1565 |
case CE_TabBarTabLabel: |
|
1566 |
if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(option)) { |
|
1567 |
QStyleOptionTabV3 optionTab = *tab; |
|
1568 |
QRect tr = optionTab.rect; |
|
1569 |
const bool directionMirrored = (optionTab.direction == Qt::RightToLeft); |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1570 |
const int borderThickness = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
0 | 1571 |
const int tabOverlap = |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1572 |
QS60StylePrivate::pixelMetric(PM_TabBarTabOverlap) - borderThickness; |
0 | 1573 |
const QRect windowRect = painter->window(); |
1574 |
||
1575 |
switch (tab->shape) { |
|
1576 |
case QTabBar::TriangularWest: |
|
1577 |
case QTabBar::RoundedWest: |
|
1578 |
case QTabBar::TriangularEast: |
|
1579 |
case QTabBar::RoundedEast: |
|
1580 |
tr.adjust(0, 0, 0, tabOverlap); |
|
1581 |
break; |
|
1582 |
case QTabBar::TriangularSouth: |
|
1583 |
case QTabBar::RoundedSouth: |
|
1584 |
case QTabBar::TriangularNorth: |
|
1585 |
case QTabBar::RoundedNorth: |
|
1586 |
default: |
|
1587 |
if (directionMirrored) |
|
1588 |
tr.adjust(-tabOverlap, 0, 0, 0); |
|
1589 |
else |
|
1590 |
tr.adjust(0, 0, tabOverlap, 0); |
|
1591 |
break; |
|
1592 |
} |
|
1593 |
painter->save(); |
|
1594 |
QFont f = painter->font(); |
|
1595 |
f.setPointSizeF(f.pointSizeF() * KTabFontMul); |
|
1596 |
painter->setFont(f); |
|
1597 |
||
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1598 |
const bool selected = optionTab.state & State_Selected; |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1599 |
if (selected) |
0 | 1600 |
optionTab.palette.setColor(QPalette::Active, QPalette::WindowText, |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1601 |
optionTab.palette.highlightedText().color()); |
0 | 1602 |
|
1603 |
const bool verticalTabs = optionTab.shape == QTabBar::RoundedEast |
|
1604 |
|| optionTab.shape == QTabBar::RoundedWest |
|
1605 |
|| optionTab.shape == QTabBar::TriangularEast |
|
1606 |
|| optionTab.shape == QTabBar::TriangularWest; |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1607 |
|
0 | 1608 |
if (verticalTabs) { |
1609 |
painter->save(); |
|
1610 |
int newX, newY, newRotation; |
|
1611 |
if (optionTab.shape == QTabBar::RoundedEast || optionTab.shape == QTabBar::TriangularEast) { |
|
1612 |
newX = tr.width(); |
|
1613 |
newY = tr.y(); |
|
1614 |
newRotation = 90; |
|
1615 |
} else { |
|
1616 |
newX = 0; |
|
1617 |
newY = tr.y() + tr.height(); |
|
1618 |
newRotation = -90; |
|
1619 |
} |
|
1620 |
tr.setRect(0, 0, tr.height(), tr.width()); |
|
1621 |
QTransform m; |
|
1622 |
m.translate(newX, newY); |
|
1623 |
m.rotate(newRotation); |
|
1624 |
painter->setTransform(m, true); |
|
1625 |
} |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1626 |
tr.adjust(0, 0, pixelMetric(PM_TabBarTabShiftHorizontal, tab, widget), |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1627 |
pixelMetric(PM_TabBarTabShiftVertical, tab, widget)); |
0 | 1628 |
|
1629 |
if (selected) { |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1630 |
tr.setBottom(tr.bottom() - pixelMetric(PM_TabBarTabShiftVertical, tab, widget)); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1631 |
tr.setRight(tr.right() - pixelMetric(PM_TabBarTabShiftHorizontal, tab, widget)); |
0 | 1632 |
} |
1633 |
||
1634 |
int alignment = Qt::AlignCenter | Qt::TextShowMnemonic; |
|
1635 |
if (!styleHint(SH_UnderlineShortcut, &optionTab, widget)) |
|
1636 |
alignment |= Qt::TextHideMnemonic; |
|
1637 |
if (!optionTab.icon.isNull()) { |
|
1638 |
QSize iconSize = optionTab.iconSize; |
|
1639 |
int iconExtent = pixelMetric(PM_TabBarIconSize); |
|
1640 |
if (iconSize.height() > iconExtent || iconSize.width() > iconExtent) |
|
1641 |
iconSize = QSize(iconExtent, iconExtent); |
|
1642 |
QPixmap tabIcon = optionTab.icon.pixmap(iconSize, |
|
1643 |
(optionTab.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); |
|
1644 |
if (tab->text.isEmpty()) |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1645 |
painter->drawPixmap(tr.center().x() - (tabIcon.height() >> 1), |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1646 |
tr.center().y() - (tabIcon.height() >> 1), |
0 | 1647 |
tabIcon); |
1648 |
else |
|
1649 |
painter->drawPixmap(tr.left() + tabOverlap, |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1650 |
tr.center().y() - (tabIcon.height() >> 1), |
0 | 1651 |
tabIcon); |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1652 |
tr.setLeft(tr.left() + iconSize.width() + 4); //todo: magic four |
0 | 1653 |
} |
1654 |
||
1655 |
QCommonStyle::drawItemText(painter, tr, alignment, optionTab.palette, tab->state & State_Enabled, tab->text, QPalette::WindowText); |
|
1656 |
if (verticalTabs) |
|
1657 |
painter->restore(); |
|
1658 |
||
1659 |
painter->restore(); |
|
1660 |
} |
|
1661 |
break; |
|
1662 |
#endif // QT_NO_TABBAR |
|
1663 |
#ifndef QT_NO_PROGRESSBAR |
|
1664 |
case CE_ProgressBarContents: |
|
1665 |
if (const QStyleOptionProgressBarV2 *optionProgressBar = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { |
|
1666 |
QRect progressRect = optionProgressBar->rect; |
|
1667 |
||
1668 |
if (optionProgressBar->minimum == optionProgressBar->maximum && optionProgressBar->minimum == 0) { |
|
1669 |
// busy indicator |
|
1670 |
const QS60StylePrivate::SkinElementFlag orientationFlag = optionProgressBar->orientation == Qt::Horizontal ? |
|
1671 |
QS60StylePrivate::SF_PointNorth : QS60StylePrivate::SF_PointWest; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1672 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1673 |
QS60StylePrivate::drawSkinPart(QS60StyleEnums::SP_QgnGrafBarWaitAnim, |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1674 |
painter, progressRect, flags | orientationFlag | QS60StylePrivate::SF_Animation ); |
0 | 1675 |
} else { |
1676 |
const qreal progressFactor = (optionProgressBar->minimum == optionProgressBar->maximum) ? 1.0 |
|
1677 |
: (qreal)optionProgressBar->progress / optionProgressBar->maximum; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1678 |
const int frameWidth = pixelMetric(PM_DefaultFrameWidth, option, widget); |
0 | 1679 |
if (optionProgressBar->orientation == Qt::Horizontal) { |
1680 |
progressRect.setWidth(int(progressRect.width() * progressFactor)); |
|
1681 |
if(optionProgressBar->direction == Qt::RightToLeft) |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1682 |
progressRect.translate(optionProgressBar->rect.width() - progressRect.width(), 0); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1683 |
progressRect.adjust(frameWidth, 0, -frameWidth, 0); |
0 | 1684 |
} else { |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1685 |
progressRect.adjust(0, frameWidth, 0, -frameWidth); |
0 | 1686 |
progressRect.setTop(progressRect.bottom() - int(progressRect.height() * progressFactor)); |
1687 |
} |
|
1688 |
||
1689 |
const QS60StylePrivate::SkinElements skinElement = optionProgressBar->orientation == Qt::Horizontal ? |
|
1690 |
QS60StylePrivate::SE_ProgressBarIndicatorHorizontal : QS60StylePrivate::SE_ProgressBarIndicatorVertical; |
|
1691 |
QS60StylePrivate::drawSkinElement(skinElement, painter, progressRect, flags); |
|
1692 |
} |
|
1693 |
} |
|
1694 |
break; |
|
1695 |
case CE_ProgressBarGroove: |
|
1696 |
if (const QStyleOptionProgressBarV2 *optionProgressBar = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { |
|
1697 |
const QS60StylePrivate::SkinElements skinElement = optionProgressBar->orientation == Qt::Horizontal ? |
|
1698 |
QS60StylePrivate::SE_ProgressBarGrooveHorizontal : QS60StylePrivate::SE_ProgressBarGrooveVertical; |
|
1699 |
QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); |
|
1700 |
} |
|
1701 |
break; |
|
1702 |
case CE_ProgressBarLabel: |
|
1703 |
if (const QStyleOptionProgressBarV2 *progressbar = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) { |
|
1704 |
QStyleOptionProgressBarV2 optionProgressBar = *progressbar; |
|
1705 |
QCommonStyle::drawItemText(painter, progressbar->rect, flags | Qt::AlignCenter | Qt::TextSingleLine, optionProgressBar.palette, |
|
1706 |
progressbar->state & State_Enabled, progressbar->text, QPalette::WindowText); |
|
1707 |
} |
|
1708 |
break; |
|
1709 |
#endif // QT_NO_PROGRESSBAR |
|
1710 |
#ifndef QT_NO_MENU |
|
1711 |
case CE_MenuItem: |
|
1712 |
if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { |
|
1713 |
QStyleOptionMenuItem optionMenuItem = *menuItem; |
|
1714 |
||
1715 |
bool drawSubMenuIndicator = false; |
|
1716 |
switch(menuItem->menuItemType) { |
|
1717 |
case QStyleOptionMenuItem::Scroller: |
|
1718 |
case QStyleOptionMenuItem::Separator: |
|
1719 |
return; // no separators or scrollers in S60 menus |
|
1720 |
case QStyleOptionMenuItem::SubMenu: |
|
1721 |
drawSubMenuIndicator = true; |
|
1722 |
break; |
|
1723 |
default: |
|
1724 |
break; |
|
1725 |
} |
|
1726 |
const bool enabled = optionMenuItem.state & State_Enabled; |
|
1727 |
const bool checkable = optionMenuItem.checkType != QStyleOptionMenuItem::NotCheckable; |
|
1728 |
||
1729 |
uint text_flags = Qt::AlignLeading | Qt::TextShowMnemonic | Qt::TextDontClip |
|
1730 |
| Qt::TextSingleLine | Qt::AlignVCenter; |
|
1731 |
if (!styleHint(SH_UnderlineShortcut, menuItem, widget)) |
|
1732 |
text_flags |= Qt::TextHideMnemonic; |
|
1733 |
||
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1734 |
const bool selected = (option->state & State_Selected) && (option->state & State_Enabled); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1735 |
if (selected) |
0 | 1736 |
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); |
1737 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1738 |
QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1739 |
QRect textRect = subElementRect(SE_ItemViewItemText, &optionMenuItem, widget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1740 |
|
0 | 1741 |
//todo: move the vertical spacing stuff into subElementRect |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1742 |
const int vSpacing = QS60StylePrivate::pixelMetric(PM_LayoutVerticalSpacing); |
0 | 1743 |
if (checkable){ |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1744 |
const int hSpacing = QS60StylePrivate::pixelMetric(PM_LayoutHorizontalSpacing); |
0 | 1745 |
QStyleOptionMenuItem optionCheckBox; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1746 |
optionCheckBox.QStyleOptionMenuItem::operator=(*menuItem); |
0 | 1747 |
optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth)); |
1748 |
optionCheckBox.rect.setHeight(pixelMetric(PM_IndicatorHeight)); |
|
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1749 |
optionCheckBox.rect.moveCenter(QPoint( |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1750 |
optionCheckBox.rect.center().x(), |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1751 |
menuItem->rect.center().y())); |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1752 |
const int moveByX = optionCheckBox.rect.width() + vSpacing; |
0 | 1753 |
if (optionMenuItem.direction == Qt::LeftToRight) { |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1754 |
textRect.translate(moveByX, 0); |
0 | 1755 |
iconRect.translate(moveByX, 0); |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1756 |
iconRect.setWidth(iconRect.width() + vSpacing); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1757 |
textRect.setWidth(textRect.width() - moveByX - vSpacing); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1758 |
optionCheckBox.rect.translate(vSpacing >> 1, hSpacing >> 1); |
0 | 1759 |
} else { |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1760 |
textRect.setWidth(textRect.width() - moveByX); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1761 |
iconRect.setWidth(iconRect.width() + vSpacing); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1762 |
iconRect.translate(-optionCheckBox.rect.width() - vSpacing, 0); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1763 |
optionCheckBox.rect.translate(textRect.width() + iconRect.width(), 0); |
0 | 1764 |
} |
1765 |
drawPrimitive(PE_IndicatorMenuCheckMark, &optionCheckBox, painter, widget); |
|
1766 |
} |
|
1767 |
//draw icon and/or checkState |
|
1768 |
QPixmap pix = menuItem->icon.pixmap(pixelMetric(PM_SmallIconSize), |
|
1769 |
enabled ? QIcon::Normal : QIcon::Disabled); |
|
1770 |
const bool itemWithIcon = !pix.isNull(); |
|
1771 |
if (itemWithIcon) { |
|
1772 |
drawItemPixmap(painter, iconRect, text_flags, pix); |
|
1773 |
if (optionMenuItem.direction == Qt::LeftToRight) |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1774 |
textRect.translate(vSpacing, 0); |
0 | 1775 |
else |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1776 |
textRect.translate(-vSpacing, 0); |
0 | 1777 |
textRect.setWidth(textRect.width()-vSpacing); |
1778 |
} |
|
1779 |
||
1780 |
//draw indicators |
|
1781 |
if (drawSubMenuIndicator) { |
|
1782 |
QStyleOptionMenuItem arrowOptions; |
|
1783 |
arrowOptions.QStyleOption::operator=(*menuItem); |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1784 |
const int indicatorWidth = (pixelMetric(PM_ListViewIconSize, option, widget) >> 1) + |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1785 |
pixelMetric(PM_LayoutVerticalSpacing, option, widget); |
0 | 1786 |
if (optionMenuItem.direction == Qt::LeftToRight) |
1787 |
arrowOptions.rect.setLeft(textRect.right()); |
|
1788 |
arrowOptions.rect.setWidth(indicatorWidth); |
|
1789 |
//by default sub menu indicator in S60 points to east,so here icon |
|
1790 |
// direction is set to north (and south when in RightToLeft) |
|
1791 |
const QS60StylePrivate::SkinElementFlag arrowDirection = (arrowOptions.direction == Qt::LeftToRight) ? |
|
1792 |
QS60StylePrivate::SF_PointNorth : QS60StylePrivate::SF_PointSouth; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1793 |
painter->save(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1794 |
painter->setPen(option->palette.windowText().color()); |
0 | 1795 |
QS60StylePrivate::drawSkinPart(QS60StyleEnums::SP_QgnIndiSubMenu, painter, arrowOptions.rect, |
1796 |
(flags | QS60StylePrivate::SF_ColorSkinned | arrowDirection)); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1797 |
painter->restore(); |
0 | 1798 |
} |
1799 |
||
1800 |
//draw text |
|
1801 |
if (!enabled){ |
|
1802 |
//In s60, if something becomes disabled, it is removed from menu, so no native look-alike available. |
|
1803 |
optionMenuItem.palette.setColor(QPalette::Disabled, QPalette::Text, QS60StylePrivate::lighterColor( |
|
1804 |
optionMenuItem.palette.color(QPalette::Disabled, QPalette::Text))); |
|
1805 |
painter->save(); |
|
1806 |
painter->setOpacity(0.5); |
|
1807 |
} |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1808 |
if (selected) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1809 |
optionMenuItem.palette.setColor( |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1810 |
QPalette::Active, QPalette::Text, optionMenuItem.palette.highlightedText().color()); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1811 |
|
0 | 1812 |
QCommonStyle::drawItemText(painter, textRect, text_flags, |
1813 |
optionMenuItem.palette, enabled, |
|
1814 |
optionMenuItem.text, QPalette::Text); |
|
1815 |
if (!enabled) |
|
1816 |
painter->restore(); |
|
1817 |
} |
|
1818 |
break; |
|
1819 |
case CE_MenuEmptyArea: |
|
1820 |
break; |
|
1821 |
#endif //QT_NO_MENU |
|
1822 |
||
1823 |
#ifndef QT_NO_MENUBAR |
|
1824 |
case CE_MenuBarEmptyArea: |
|
1825 |
break; |
|
1826 |
#endif //QT_NO_MENUBAR |
|
1827 |
||
1828 |
case CE_HeaderSection: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1829 |
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { |
0 | 1830 |
painter->save(); |
1831 |
QPen linePen = QPen(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 1, header)); |
|
1832 |
const int penWidth = (header->orientation == Qt::Horizontal) ? |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1833 |
linePen.width() + QS60StylePrivate::pixelMetric(PM_BoldLineWidth) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1834 |
: linePen.width() + QS60StylePrivate::pixelMetric(PM_ThinLineWidth); |
0 | 1835 |
linePen.setWidth(penWidth); |
1836 |
painter->setPen(linePen); |
|
1837 |
if (header->orientation == Qt::Horizontal){ |
|
1838 |
painter->drawLine(header->rect.bottomLeft(), header->rect.bottomRight()); |
|
1839 |
} else { |
|
1840 |
if ( header->direction == Qt::LeftToRight ) { |
|
1841 |
painter->drawLine(header->rect.topRight(), header->rect.bottomRight()); |
|
1842 |
} else { |
|
1843 |
painter->drawLine(header->rect.topLeft(), header->rect.bottomLeft()); |
|
1844 |
} |
|
1845 |
} |
|
1846 |
painter->restore(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1847 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1848 |
//Draw corner button as normal pushButton. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1849 |
if (qobject_cast<const QAbstractButton *>(widget)) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1850 |
//Make cornerButton slightly smaller so that it is not on top of table border graphic. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1851 |
QStyleOptionHeader subopt = *header; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1852 |
const int borderTweak = |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1853 |
QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) >> 1; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1854 |
if (subopt.direction == Qt::LeftToRight) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1855 |
subopt.rect.adjust(borderTweak, borderTweak, 0, -borderTweak); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1856 |
else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1857 |
subopt.rect.adjust(0, borderTweak, -borderTweak, -borderTweak); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1858 |
drawPrimitive(PE_PanelButtonBevel, &subopt, painter, widget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1859 |
} else if ((header->palette.brush(QPalette::Button) != Qt::transparent)) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1860 |
//Draw non-themed background. Background for theme is drawn in CE_ShapedFrame |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1861 |
//to get continuous theme graphic across all the header cells. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1862 |
qDrawShadePanel(painter, header->rect, header->palette, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1863 |
header->state & (State_Sunken | State_On), penWidth, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1864 |
&header->palette.brush(QPalette::Button)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1865 |
} |
0 | 1866 |
} |
1867 |
break; |
|
1868 |
case CE_HeaderEmptyArea: // no need to draw this |
|
1869 |
break; |
|
1870 |
case CE_Header: |
|
1871 |
if ( const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { |
|
1872 |
drawControl(CE_HeaderSection, header, painter, widget); |
|
1873 |
QStyleOptionHeader subopt = *header; |
|
1874 |
subopt.rect = subElementRect(SE_HeaderLabel, header, widget); |
|
1875 |
if (subopt.rect.isValid()) |
|
1876 |
drawControl(CE_HeaderLabel, &subopt, painter, widget); |
|
1877 |
if (header->sortIndicator != QStyleOptionHeader::None) { |
|
1878 |
subopt.rect = subElementRect(SE_HeaderArrow, option, widget); |
|
1879 |
drawPrimitive(PE_IndicatorHeaderArrow, &subopt, painter, widget); |
|
1880 |
} |
|
1881 |
} |
|
1882 |
break; |
|
1883 |
#ifndef QT_NO_TOOLBAR |
|
1884 |
case CE_ToolBar: |
|
1885 |
if (const QStyleOptionToolBar *toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) { |
|
1886 |
const QToolBar *tbWidget = qobject_cast<const QToolBar *>(widget); |
|
1887 |
||
1888 |
//toolbar within a toolbar, skip |
|
1889 |
if (!tbWidget || (widget && qobject_cast<QToolBar *>(widget->parentWidget()))) |
|
1890 |
break; |
|
1891 |
||
1892 |
// Normally in S60 5.0+ there is no background for toolbar, but in some cases with versatile QToolBar, |
|
1893 |
// it looks a bit strange. So, lets fillRect with Button. |
|
1894 |
if (!QS60StylePrivate::isToolBarBackground()) { |
|
1895 |
QList<QAction *> actions = tbWidget->actions(); |
|
1896 |
bool justToolButtonsInToolBar = true; |
|
1897 |
for (int i = 0; i < actions.size(); ++i) { |
|
1898 |
QWidget *childWidget = tbWidget->widgetForAction(actions.at(i)); |
|
1899 |
const QToolButton *button = qobject_cast<const QToolButton *>(childWidget); |
|
1900 |
if (!button){ |
|
1901 |
justToolButtonsInToolBar = false; |
|
1902 |
} |
|
1903 |
} |
|
1904 |
||
1905 |
// Draw frame background |
|
1906 |
// for vertical toolbars with text only and |
|
1907 |
// for toolbars with extension buttons and |
|
1908 |
// for toolbars with widgets in them. |
|
1909 |
if (!justToolButtonsInToolBar || |
|
1910 |
(tbWidget && |
|
1911 |
(tbWidget->orientation() == Qt::Vertical) && |
|
1912 |
(tbWidget->toolButtonStyle() == Qt::ToolButtonTextOnly))) { |
|
1913 |
painter->save(); |
|
1914 |
if (widget) |
|
1915 |
painter->setBrush(widget->palette().button()); |
|
1916 |
painter->setOpacity(0.3); |
|
1917 |
painter->fillRect(toolBar->rect, painter->brush()); |
|
1918 |
painter->restore(); |
|
1919 |
} |
|
1920 |
} else { |
|
1921 |
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ToolBar, painter, toolBar->rect, flags); |
|
1922 |
} |
|
1923 |
} |
|
1924 |
break; |
|
1925 |
#endif //QT_NO_TOOLBAR |
|
1926 |
case CE_ShapedFrame: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1927 |
if (const QTextEdit *textEdit = qobject_cast<const QTextEdit *>(widget)) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1928 |
const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option); |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1929 |
if (QS60StylePrivate::canDrawThemeBackground(frame->palette.base(), widget)) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1930 |
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_Editor, painter, option->rect, flags); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1931 |
else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1932 |
QCommonStyle::drawControl(element, option, painter, widget); |
0 | 1933 |
} else if (qobject_cast<const QTableView *>(widget)) { |
1934 |
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableItem, painter, option->rect, flags); |
|
1935 |
} else if (const QHeaderView *header = qobject_cast<const QHeaderView *>(widget)) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1936 |
//QS60style draws header background here instead of in each headersection, to get |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1937 |
//continuous graphic from section to section. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1938 |
QS60StylePrivate::SkinElementFlags adjustableFlags = flags; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1939 |
QRect headerRect = option->rect; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1940 |
if (header->orientation() != Qt::Horizontal) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1941 |
//todo: update to horizontal table graphic |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1942 |
adjustableFlags = (adjustableFlags | QS60StylePrivate::SF_PointWest); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1943 |
} else { |
0 | 1944 |
const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1945 |
if (option->direction == Qt::LeftToRight) |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1946 |
headerRect.adjust(-2 * frameWidth, 0, 0, 0); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1947 |
else |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1948 |
headerRect.adjust(0, 0, 2 * frameWidth, 0); |
0 | 1949 |
} |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1950 |
if (option->palette.brush(QPalette::Button).color() == Qt::transparent) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1951 |
QS60StylePrivate::drawSkinElement( |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1952 |
QS60StylePrivate::SE_TableHeaderItem, painter, headerRect, adjustableFlags); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1953 |
|
0 | 1954 |
} else if (qobject_cast<const QFrame *>(widget)) { |
1955 |
QCommonStyle::drawControl(element, option, painter, widget); |
|
1956 |
} |
|
1957 |
break; |
|
1958 |
case CE_MenuScroller: |
|
1959 |
break; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
1960 |
case CE_FocusFrame: { |
0 | 1961 |
#ifdef QT_KEYPAD_NAVIGATION |
1962 |
bool editFocus = false; |
|
1963 |
if (const QFocusFrame *focusFrame = qobject_cast<const QFocusFrame*>(widget)) { |
|
1964 |
if (focusFrame->widget() && focusFrame->widget()->hasEditFocus()) |
|
1965 |
editFocus = true; |
|
1966 |
} |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1967 |
const qreal opacity = editFocus ? 1 : 0.75; // Trial and error factors. Feel free to improve. |
0 | 1968 |
#else |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1969 |
const qreal opacity = 0.85; |
0 | 1970 |
#endif |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1971 |
// We need to reduce the focus frame size if LayoutSpacing is smaller than FocusFrameMargin |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1972 |
// Otherwise, we would overlay adjacent widgets. |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1973 |
const int frameHeightReduction = |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1974 |
qMin(0, pixelMetric(PM_LayoutVerticalSpacing) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1975 |
- pixelMetric(PM_FocusFrameVMargin)); |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1976 |
const int frameWidthReduction = |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1977 |
qMin(0, pixelMetric(PM_LayoutHorizontalSpacing) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1978 |
- pixelMetric(PM_FocusFrameHMargin)); |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1979 |
const int rounding = |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1980 |
qMin(pixelMetric(PM_FocusFrameVMargin), |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
1981 |
pixelMetric(PM_LayoutVerticalSpacing)); |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1982 |
const QRect frameRect = |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1983 |
option->rect.adjusted(-frameWidthReduction, -frameHeightReduction, |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1984 |
frameWidthReduction, frameHeightReduction); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1985 |
QPainterPath framePath; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1986 |
framePath.addRoundedRect(frameRect, rounding, rounding); |
0 | 1987 |
|
1988 |
painter->save(); |
|
1989 |
painter->setRenderHint(QPainter::Antialiasing); |
|
1990 |
painter->setOpacity(opacity); |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
1991 |
painter->fillPath(framePath, option->palette.color(QPalette::Text)); |
0 | 1992 |
painter->restore(); |
1993 |
} |
|
1994 |
break; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1995 |
case CE_Splitter: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1996 |
if (option->state & State_Sunken && option->state & State_Enabled) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1997 |
painter->save(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1998 |
painter->setOpacity(0.5); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1999 |
painter->setBrush(QS60StylePrivate::themePalette()->light()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2000 |
painter->setRenderHint(QPainter::Antialiasing); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2001 |
const qreal roundRectRadius = 4 * goldenRatio; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2002 |
painter->drawRoundedRect(option->rect, roundRectRadius, roundRectRadius); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2003 |
painter->restore(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2004 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2005 |
break; |
0 | 2006 |
default: |
2007 |
QCommonStyle::drawControl(element, option, painter, widget); |
|
2008 |
} |
|
2009 |
} |
|
2010 |
||
2011 |
/*! |
|
2012 |
\reimp |
|
2013 |
*/ |
|
2014 |
void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const |
|
2015 |
{ |
|
2016 |
const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2017 |
bool commonStyleDraws = false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2018 |
|
0 | 2019 |
switch (element) { |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2020 |
case PE_FrameFocusRect: { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2021 |
//Draw themed highlight to radiobuttons and checkboxes. |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2022 |
//For other widgets skip, unless palette has been modified. In that case, draw with commonstyle. |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2023 |
if (option->palette.highlight().color() == QS60StylePrivate::themePalette()->highlight().color()) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2024 |
if ((qstyleoption_cast<const QStyleOptionFocusRect *>(option) && |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2025 |
(qobject_cast<const QRadioButton *>(widget) || qobject_cast<const QCheckBox *>(widget)))) |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2026 |
QS60StylePrivate::drawSkinElement( |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2027 |
QS60StylePrivate::isWidgetPressed(widget) ? |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2028 |
QS60StylePrivate::SE_ListItemPressed : |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2029 |
QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2030 |
else |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2031 |
commonStyleDraws = true; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2032 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2033 |
break; |
0 | 2034 |
#ifndef QT_NO_LINEEDIT |
2035 |
case PE_PanelLineEdit: |
|
2036 |
if (const QStyleOptionFrame *lineEdit = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
|
2037 |
#ifndef QT_NO_COMBOBOX |
|
2038 |
if (widget && qobject_cast<const QComboBox *>(widget->parentWidget())) |
|
2039 |
break; |
|
2040 |
#endif |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2041 |
if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget)) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2042 |
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_FrameLineEdit, painter, option->rect, flags); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2043 |
else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2044 |
commonStyleDraws = true; |
0 | 2045 |
} |
2046 |
break; |
|
2047 |
#endif // QT_NO_LINEEDIT |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2048 |
case PE_IndicatorCheckBox: { |
0 | 2049 |
// Draw checkbox indicator as color skinned graphics. |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2050 |
const QS60StyleEnums::SkinParts skinPart = (option->state & State_On) ? |
0 | 2051 |
QS60StyleEnums::SP_QgnIndiCheckboxOn : QS60StyleEnums::SP_QgnIndiCheckboxOff; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2052 |
painter->save(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2053 |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2054 |
const QColor themeColor = QS60StylePrivate::themePalette()->windowText().color(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2055 |
const QColor windowTextColor = option->palette.windowText().color(); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2056 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2057 |
if (themeColor != windowTextColor) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2058 |
painter->setPen(windowTextColor); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2059 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2060 |
QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags | QS60StylePrivate::SF_ColorSkinned ); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2061 |
painter->restore(); |
0 | 2062 |
} |
2063 |
break; |
|
2064 |
case PE_IndicatorViewItemCheck: |
|
2065 |
#ifndef QT_NO_ITEMVIEWS |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2066 |
if (const QAbstractItemView *itemView = (qobject_cast<const QAbstractItemView *>(widget))) { |
0 | 2067 |
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
2068 |
const bool checkBoxVisible = vopt->features & QStyleOptionViewItemV2::HasCheckIndicator; |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2069 |
const bool singleSelection = itemView->selectionMode() == |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2070 |
QAbstractItemView::SingleSelection || itemView->selectionMode() == QAbstractItemView::NoSelection; |
0 | 2071 |
// draw either checkbox at the beginning |
2072 |
if (checkBoxVisible && singleSelection) { |
|
2073 |
drawPrimitive(PE_IndicatorCheckBox, option, painter, widget); |
|
2074 |
// ... or normal "tick" selection at the end. |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2075 |
} else if (option->state & State_Selected) { |
0 | 2076 |
QRect tickRect = option->rect; |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2077 |
const int frameBorderWidth = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth); |
0 | 2078 |
// adjust tickmark rect to exclude frame border |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2079 |
tickRect.adjust(0, -frameBorderWidth, 0, -frameBorderWidth); |
0 | 2080 |
QS60StyleEnums::SkinParts skinPart = QS60StyleEnums::SP_QgnIndiMarkedAdd; |
2081 |
QS60StylePrivate::drawSkinPart(skinPart, painter, tickRect, |
|
2082 |
(flags | QS60StylePrivate::SF_ColorSkinned)); |
|
2083 |
} |
|
2084 |
} |
|
2085 |
} |
|
2086 |
#endif //QT_NO_ITEMVIEWS |
|
2087 |
break; |
|
2088 |
case PE_IndicatorRadioButton: { |
|
2089 |
QRect buttonRect = option->rect; |
|
2090 |
//there is empty (a. 33%) space in svg graphics for radiobutton |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2091 |
const qreal reduceWidth = (qreal)buttonRect.width() / 3.0; |
0 | 2092 |
const qreal rectWidth = (qreal)option->rect.width() != 0 ? option->rect.width() : 1.0; |
2093 |
// Try to occupy the full area |
|
2094 |
const qreal scaler = 1 + (reduceWidth/rectWidth); |
|
2095 |
buttonRect.setWidth((int)((buttonRect.width()-reduceWidth) * scaler)); |
|
2096 |
buttonRect.setHeight((int)(buttonRect.height() * scaler)); |
|
2097 |
// move the rect up for half of the new height-gain |
|
2098 |
const int newY = (buttonRect.bottomRight().y() - option->rect.bottomRight().y()) >> 1 ; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2099 |
buttonRect.adjust(0, -newY, -1, -newY); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2100 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2101 |
painter->save(); |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2102 |
const QColor themeColor = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, option); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2103 |
const QColor buttonTextColor = option->palette.buttonText().color(); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2104 |
if (themeColor != buttonTextColor) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2105 |
painter->setPen(buttonTextColor); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2106 |
else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2107 |
painter->setPen(themeColor); |
0 | 2108 |
|
2109 |
// Draw radiobutton indicator as color skinned graphics. |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2110 |
QS60StyleEnums::SkinParts skinPart = (option->state & State_On) ? |
0 | 2111 |
QS60StyleEnums::SP_QgnIndiRadiobuttOn : QS60StyleEnums::SP_QgnIndiRadiobuttOff; |
2112 |
QS60StylePrivate::drawSkinPart(skinPart, painter, buttonRect, |
|
2113 |
(flags | QS60StylePrivate::SF_ColorSkinned)); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2114 |
painter->restore(); |
0 | 2115 |
} |
2116 |
break; |
|
2117 |
case PE_PanelButtonCommand: |
|
2118 |
case PE_PanelButtonTool: |
|
2119 |
case PE_PanelButtonBevel: |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2120 |
case PE_FrameButtonBevel: |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2121 |
if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget)) { |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2122 |
const bool isPressed = option->state & State_Sunken; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2123 |
const QS60StylePrivate::SkinElements skinElement = |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2124 |
isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2125 |
QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2126 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2127 |
commonStyleDraws = true; |
0 | 2128 |
} |
2129 |
break; |
|
2130 |
#ifndef QT_NO_TOOLBUTTON |
|
2131 |
case PE_IndicatorArrowDown: |
|
2132 |
case PE_IndicatorArrowLeft: |
|
2133 |
case PE_IndicatorArrowRight: |
|
2134 |
case PE_IndicatorArrowUp: { |
|
2135 |
QS60StyleEnums::SkinParts skinPart; |
|
2136 |
if (element==PE_IndicatorArrowDown) |
|
2137 |
skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
|
2138 |
else if (element==PE_IndicatorArrowLeft) |
|
2139 |
skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowLeft; |
|
2140 |
else if (element==PE_IndicatorArrowRight) |
|
2141 |
skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowRight; |
|
2142 |
else if (element==PE_IndicatorArrowUp) |
|
2143 |
skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowUp; |
|
2144 |
||
2145 |
QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags); |
|
2146 |
} |
|
2147 |
break; |
|
2148 |
#endif //QT_NO_TOOLBUTTON |
|
2149 |
#ifndef QT_NO_SPINBOX |
|
2150 |
case PE_IndicatorSpinDown: |
|
2151 |
case PE_IndicatorSpinUp: |
|
2152 |
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2153 |
if (QS60StylePrivate::canDrawThemeBackground(spinBox->palette.base(), widget)) { |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2154 |
QStyleOptionSpinBox optionSpinBox = *spinBox; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2155 |
const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ? |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2156 |
QS60StyleEnums::SP_QgnGrafScrollArrowUp : |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2157 |
QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2158 |
const int iconMargin = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) >> 1; |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2159 |
optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin ); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2160 |
QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect, flags); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2161 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2162 |
commonStyleDraws = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2163 |
} |
0 | 2164 |
} |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2165 |
#endif //QT_NO_SPINBOX |
0 | 2166 |
#ifndef QT_NO_COMBOBOX |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2167 |
if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2168 |
if (QS60StylePrivate::canDrawThemeBackground( option->palette.base(), widget)) { |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2169 |
// We want to draw down arrow here for comboboxes as well. |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2170 |
QStyleOptionFrame optionsComboBox = *cmb; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2171 |
const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown; |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2172 |
const int iconMargin = QS60StylePrivate::pixelMetric(PM_FrameCornerWidth) >> 1; |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2173 |
optionsComboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin ); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2174 |
QS60StylePrivate::drawSkinPart(part, painter, optionsComboBox.rect, flags); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2175 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2176 |
commonStyleDraws = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2177 |
} |
0 | 2178 |
} |
2179 |
#endif //QT_NO_COMBOBOX |
|
2180 |
break; |
|
2181 |
case PE_IndicatorSpinMinus: |
|
2182 |
case PE_IndicatorSpinPlus: |
|
2183 |
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
|
2184 |
QStyleOptionSpinBox optionSpinBox = *spinBox; |
|
2185 |
QCommonStyle::drawPrimitive(element, &optionSpinBox, painter, widget); |
|
2186 |
} |
|
2187 |
#ifndef QT_NO_COMBOBOX |
|
2188 |
else if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
|
2189 |
// We want to draw down arrow here for comboboxes as well. |
|
2190 |
QStyleOptionFrame comboBox = *cmb; |
|
2191 |
const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2192 |
comboBox.rect.adjust(0, frameWidth, 0, -frameWidth); |
0 | 2193 |
QCommonStyle::drawPrimitive(element, &comboBox, painter, widget); |
2194 |
} |
|
2195 |
#endif //QT_NO_COMBOBOX |
|
2196 |
break; |
|
2197 |
case PE_Widget: |
|
2198 |
if (QS60StylePrivate::drawsOwnThemeBackground(widget) |
|
2199 |
#ifndef QT_NO_COMBOBOX |
|
2200 |
|| qobject_cast<const QComboBoxListView *>(widget) |
|
2201 |
#endif //QT_NO_COMBOBOX |
|
2202 |
#ifndef QT_NO_MENU |
|
2203 |
|| qobject_cast<const QMenu *> (widget) |
|
2204 |
#endif //QT_NO_MENU |
|
2205 |
) { |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2206 |
//Need extra check since dialogs have their own theme background |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2207 |
if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget) && |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2208 |
option->palette.window().texture().cacheKey() == |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2209 |
QS60StylePrivate::m_themePalette->window().texture().cacheKey()) |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2210 |
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_PopupBackground, painter, option->rect, flags); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2211 |
else |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2212 |
commonStyleDraws = true; |
0 | 2213 |
} |
2214 |
break; |
|
2215 |
case PE_FrameWindow: |
|
2216 |
case PE_FrameTabWidget: |
|
2217 |
if (const QStyleOptionTabWidgetFrame *tabFrame = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) { |
|
2218 |
QStyleOptionTabWidgetFrame optionTabFrame = *tabFrame; |
|
2219 |
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_PanelBackground, painter, optionTabFrame.rect, flags); |
|
2220 |
} |
|
2221 |
break; |
|
2222 |
case PE_IndicatorHeaderArrow: |
|
2223 |
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { |
|
2224 |
if (header->sortIndicator & QStyleOptionHeader::SortUp) |
|
2225 |
drawPrimitive(PE_IndicatorArrowUp, header, painter, widget); |
|
2226 |
else if (header->sortIndicator & QStyleOptionHeader::SortDown) |
|
2227 |
drawPrimitive(PE_IndicatorArrowDown, header, painter, widget); |
|
2228 |
} // QStyleOptionHeader::None is not drawn => not needed |
|
2229 |
break; |
|
2230 |
#ifndef QT_NO_GROUPBOX |
|
2231 |
case PE_FrameGroupBox: |
|
2232 |
if (const QStyleOptionFrameV2 *frame = qstyleoption_cast<const QStyleOptionFrameV2 *>(option)) |
|
2233 |
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_SettingsList, painter, frame->rect, flags); |
|
2234 |
break; |
|
2235 |
#endif //QT_NO_GROUPBOX |
|
2236 |
||
2237 |
// Qt3 primitives are not supported |
|
2238 |
case PE_Q3CheckListController: |
|
2239 |
case PE_Q3CheckListExclusiveIndicator: |
|
2240 |
case PE_Q3CheckListIndicator: |
|
2241 |
case PE_Q3DockWindowSeparator: |
|
2242 |
case PE_Q3Separator: |
|
2243 |
Q_ASSERT(false); |
|
2244 |
break; |
|
2245 |
case PE_Frame: |
|
2246 |
break; |
|
2247 |
#ifndef QT_NO_ITEMVIEWS |
|
2248 |
case PE_PanelItemViewItem: |
|
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2249 |
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2250 |
const bool isSelected = (vopt->state & State_Selected); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2251 |
const bool hasFocus = (vopt->state & State_HasFocus); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2252 |
const bool isPressed = QS60StylePrivate::isWidgetPressed(widget); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2253 |
|
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2254 |
if (option->palette.highlight().color() == QS60StylePrivate::themePalette()->highlight().color()) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2255 |
QRect highlightRect = vopt->rect.adjusted(1,1,-1,-1); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2256 |
const QAbstractItemView *itemView = qobject_cast<const QAbstractItemView *>(widget); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2257 |
QAbstractItemView::SelectionBehavior selectionBehavior = |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2258 |
itemView ? itemView->selectionBehavior() : QAbstractItemView::SelectItems; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2259 |
// Set the draw area for highlights (focus, select rect or pressed rect) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2260 |
if (hasFocus || isSelected || isPressed) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2261 |
if (selectionBehavior != QAbstractItemView::SelectItems) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2262 |
// set highlight rect so that it is continuous from cell to cell, yet sligthly |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2263 |
// smaller than cell rect |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2264 |
int xBeginning = 0, yBeginning = 0, xEnd = 0, yEnd = 0; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2265 |
if (selectionBehavior == QAbstractItemView::SelectRows) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2266 |
yBeginning = 1; yEnd = -1; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2267 |
if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2268 |
xBeginning = 1; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2269 |
else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2270 |
xEnd = -1; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2271 |
} else if (selectionBehavior == QAbstractItemView::SelectColumns) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2272 |
xBeginning = 1; xEnd = -1; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2273 |
if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2274 |
yBeginning = 1; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2275 |
else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2276 |
yEnd = -1; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2277 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2278 |
highlightRect = option->rect.adjusted(xBeginning, yBeginning, xEnd, yEnd); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2279 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2280 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2281 |
bool tableView = false; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2282 |
if (itemView && qobject_cast<const QTableView *>(widget)) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2283 |
tableView = true; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2284 |
|
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2285 |
QS60StylePrivate::SkinElements element; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2286 |
QRect elementRect = option->rect; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2287 |
|
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2288 |
//draw item is drawn as pressed, if it already has focus. |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2289 |
if (isPressed && (hasFocus || isSelected)) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2290 |
element = tableView ? QS60StylePrivate::SE_TableItemPressed : QS60StylePrivate::SE_ListItemPressed; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2291 |
} else if (hasFocus || (isSelected && selectionBehavior != QAbstractItemView::SelectItems)) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2292 |
element = QS60StylePrivate::SE_ListHighlight; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2293 |
elementRect = highlightRect; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2294 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2295 |
QS60StylePrivate::drawSkinElement(element, painter, elementRect, flags); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2296 |
} else { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2297 |
QCommonStyle::drawPrimitive(element, option, painter, widget); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2298 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2299 |
} |
0 | 2300 |
break; |
2301 |
#endif //QT_NO_ITEMVIEWS |
|
2302 |
||
2303 |
case PE_IndicatorMenuCheckMark: |
|
2304 |
if (const QStyleOptionMenuItem *checkBox = qstyleoption_cast<const QStyleOptionMenuItem *>(option)){ |
|
2305 |
QStyleOptionMenuItem optionCheckBox = *checkBox; |
|
2306 |
if (optionCheckBox.checked) |
|
2307 |
optionCheckBox.state = (optionCheckBox.state | State_On); |
|
2308 |
drawPrimitive(PE_IndicatorCheckBox, &optionCheckBox, painter, widget); |
|
2309 |
} |
|
2310 |
break; |
|
2311 |
#ifndef QT_NO_TOOLBAR |
|
2312 |
case PE_IndicatorToolBarHandle: |
|
2313 |
// no toolbar handles in S60/AVKON UI |
|
2314 |
case PE_IndicatorToolBarSeparator: |
|
2315 |
// no separators in S60/AVKON UI |
|
2316 |
break; |
|
2317 |
#endif //QT_NO_TOOLBAR |
|
2318 |
||
2319 |
case PE_PanelMenuBar: |
|
2320 |
case PE_FrameMenu: |
|
2321 |
break; //disable frame in menu |
|
2322 |
||
2323 |
case PE_IndicatorBranch: |
|
2324 |
#if defined(Q_WS_S60) |
|
2325 |
// 3.1 AVKON UI does not have tree view component, use common style for drawing there |
|
2326 |
if (QSysInfo::s60Version() == QSysInfo::SV_S60_3_1) { |
|
2327 |
#else |
|
2328 |
if (true) { |
|
2329 |
#endif |
|
2330 |
QCommonStyle::drawPrimitive(element, option, painter, widget); |
|
2331 |
} else { |
|
2332 |
const bool rightLine = option->state & State_Item; |
|
2333 |
const bool downLine = option->state & State_Sibling; |
|
2334 |
const bool upLine = option->state & (State_Open | State_Children | State_Item | State_Sibling); |
|
2335 |
||
2336 |
QS60StyleEnums::SkinParts skinPart; |
|
2337 |
bool drawSkinPart = false; |
|
2338 |
if (rightLine && downLine && upLine) { |
|
2339 |
skinPart = QS60StyleEnums::SP_QgnIndiHlLineBranch; |
|
2340 |
drawSkinPart = true; |
|
2341 |
} else if (rightLine && upLine) { |
|
2342 |
skinPart = QS60StyleEnums::SP_QgnIndiHlLineEnd; |
|
2343 |
drawSkinPart = true; |
|
2344 |
} else if (upLine && downLine) { |
|
2345 |
skinPart = QS60StyleEnums::SP_QgnIndiHlLineStraight; |
|
2346 |
drawSkinPart = true; |
|
2347 |
} |
|
2348 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2349 |
if (drawSkinPart) |
0 | 2350 |
QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags); |
2351 |
||
2352 |
if (option->state & State_Children) { |
|
2353 |
QS60StyleEnums::SkinParts skinPart = |
|
2354 |
(option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper; |
|
2355 |
int minDimension = qMin(option->rect.width(), option->rect.height()); |
|
2356 |
QRect iconRect(option->rect.topLeft(), QSize(minDimension, minDimension)); |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2357 |
const int magicTweak = 3; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2358 |
int resizeValue = minDimension >> 1; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2359 |
if (!QS60StylePrivate::isTouchSupported()) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2360 |
minDimension += resizeValue; // Adjust the icon bigger because of empty space in svg icon. |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2361 |
iconRect.setSize(QSize(minDimension, minDimension)); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2362 |
const int verticalMagic = (option->rect.width() <= option->rect.height()) ? magicTweak : 0; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2363 |
resizeValue = verticalMagic - resizeValue; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2364 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2365 |
iconRect.translate(magicTweak, resizeValue); |
0 | 2366 |
QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, flags); |
2367 |
} |
|
2368 |
} |
|
2369 |
break; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2370 |
case PE_PanelItemViewRow: // ### Qt 5: remove |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2371 |
#ifndef QT_NO_ITEMVIEWS |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2372 |
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2373 |
if (vopt->palette.base().texture().cacheKey() != QS60StylePrivate::m_themePalette->base().texture().cacheKey()) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2374 |
//QPalette::Base has been changed, let commonstyle draw the item |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2375 |
commonStyleDraws = true; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2376 |
} else { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2377 |
QPalette::ColorGroup cg = vopt->state & State_Enabled ? QPalette::Normal : QPalette::Disabled; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2378 |
if (cg == QPalette::Normal && !(vopt->state & State_Active)) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2379 |
cg = QPalette::Inactive; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2380 |
if (vopt->features & QStyleOptionViewItemV2::Alternate) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2381 |
painter->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::AlternateBase)); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2382 |
//apart from alternate base, no background for list item is drawn for S60Style |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2383 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2384 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2385 |
#endif |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2386 |
break; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2387 |
case PE_PanelScrollAreaCorner: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2388 |
break; |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2389 |
case PE_IndicatorItemViewItemDrop: |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2390 |
if (QS60StylePrivate::isTouchSupported()) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2391 |
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_DropArea, painter, option->rect, flags); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2392 |
else |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2393 |
commonStyleDraws = true; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2394 |
break; |
0 | 2395 |
// todo: items are below with #ifdefs "just in case". in final version, remove all non-required cases |
2396 |
case PE_FrameLineEdit: |
|
2397 |
case PE_IndicatorDockWidgetResizeHandle: |
|
2398 |
case PE_PanelTipLabel: |
|
2399 |
||
2400 |
#ifndef QT_NO_TABBAR |
|
2401 |
case PE_IndicatorTabTear: // No tab tear in S60 |
|
2402 |
#endif // QT_NO_TABBAR |
|
2403 |
case PE_FrameDefaultButton: |
|
2404 |
#ifndef QT_NO_DOCKWIDGET |
|
2405 |
case PE_FrameDockWidget: |
|
2406 |
#endif //QT_NO_DOCKWIDGET |
|
2407 |
#ifndef QT_NO_PROGRESSBAR |
|
2408 |
case PE_IndicatorProgressChunk: |
|
2409 |
#endif //QT_NO_PROGRESSBAR |
|
2410 |
#ifndef QT_NO_TOOLBAR |
|
2411 |
case PE_PanelToolBar: |
|
2412 |
#endif //QT_NO_TOOLBAR |
|
2413 |
#ifndef QT_NO_COLUMNVIEW |
|
2414 |
case PE_IndicatorColumnViewArrow: |
|
2415 |
#endif //QT_NO_COLUMNVIEW |
|
2416 |
case PE_FrameTabBarBase: // since tabs are in S60 always in navipane, let's use common style for tab base in Qt. |
|
2417 |
default: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2418 |
commonStyleDraws = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2419 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2420 |
if (commonStyleDraws) { |
0 | 2421 |
QCommonStyle::drawPrimitive(element, option, painter, widget); |
2422 |
} |
|
2423 |
} |
|
2424 |
||
2425 |
/*! \reimp */ |
|
2426 |
int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const |
|
2427 |
{ |
|
2428 |
int metricValue = QS60StylePrivate::pixelMetric(metric); |
|
2429 |
if (metricValue == KNotFound) |
|
2430 |
metricValue = QCommonStyle::pixelMetric(metric, option, widget); |
|
2431 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2432 |
//if layout direction is mirrored, switch left and right border margins |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2433 |
if (option && option->direction == Qt::RightToLeft) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2434 |
if (metric == PM_LayoutLeftMargin) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2435 |
metricValue = QS60StylePrivate::pixelMetric(PM_LayoutRightMargin); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2436 |
else if (metric == PM_LayoutRightMargin) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2437 |
metricValue = QS60StylePrivate::pixelMetric(PM_LayoutLeftMargin); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2438 |
} |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2439 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2440 |
if (widget && (metric == PM_LayoutTopMargin)) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2441 |
if (widget->windowType() == Qt::Dialog) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2442 |
//double the top layout margin for dialogs, it is very close to real value |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2443 |
//without having to define custom pixel metric |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2444 |
metricValue *= 2; |
0 | 2445 |
return metricValue; |
2446 |
} |
|
2447 |
||
2448 |
/*! \reimp */ |
|
2449 |
QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, |
|
2450 |
const QSize &csz, const QWidget *widget) const |
|
2451 |
{ |
|
2452 |
QSize sz(csz); |
|
2453 |
switch (ct) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2454 |
case CT_ToolButton: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2455 |
sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2456 |
//FIXME properly - style should calculate the location of border frame-part |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2457 |
sz += QSize(2 * pixelMetric(PM_ButtonMargin), 2 * pixelMetric(PM_ButtonMargin)); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2458 |
if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2459 |
if (toolBtn->subControls & SC_ToolButtonMenu) |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2460 |
sz += QSize(pixelMetric(PM_MenuButtonIndicator), 0); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2461 |
break; |
0 | 2462 |
case CT_PushButton: |
2463 |
sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2464 |
//FIXME properly - style should calculate the location of border frame-part |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2465 |
if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget))) { |
0 | 2466 |
if (buttonWidget->isCheckable()) |
2467 |
sz += QSize(pixelMetric(PM_IndicatorWidth) + pixelMetric(PM_CheckBoxLabelSpacing), 0); |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2468 |
const int iconHeight = (!buttonWidget->icon().isNull()) ? buttonWidget->iconSize().height() : 0; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2469 |
const int textHeight = (buttonWidget->text().length() > 0) ? |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2470 |
buttonWidget->fontMetrics().size(Qt::TextSingleLine, buttonWidget->text()).height() : 0; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2471 |
const int decoratorHeight = (buttonWidget->isCheckable()) ? pixelMetric(PM_IndicatorHeight) : 0; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2472 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2473 |
const int contentHeight = |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2474 |
qMax(qMax(iconHeight, decoratorHeight) + pixelMetric(PM_ButtonMargin), |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2475 |
textHeight + 2*pixelMetric(PM_ButtonMargin)); |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2476 |
sz.setHeight(qMax(sz.height(), contentHeight)); |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2477 |
sz += QSize(2 * pixelMetric(PM_ButtonMargin), 0); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2478 |
} |
0 | 2479 |
break; |
2480 |
case CT_LineEdit: |
|
2481 |
if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2482 |
sz += QSize(2 * f->lineWidth, 4 * f->lineWidth); |
0 | 2483 |
break; |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2484 |
case CT_TabBarTab: { |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2485 |
const QSize naviPaneSize = QS60StylePrivate::naviPaneSize(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2486 |
sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2487 |
if (naviPaneSize.height() > sz.height()) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2488 |
sz.setHeight(naviPaneSize.height()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2489 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2490 |
break; |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2491 |
case CT_MenuItem: |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2492 |
case CT_ItemViewItem: |
0 | 2493 |
sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2494 |
if (QS60StylePrivate::isTouchSupported()) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2495 |
//Make itemview easier to use in touch devices |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2496 |
//QCommonStyle does not adjust height with horizontal margin, it only adjusts width |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2497 |
sz.setHeight(sz.height() + 2 * pixelMetric(PM_FocusFrameVMargin)); |
0 | 2498 |
break; |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2499 |
#ifndef QT_NO_COMBOBOX |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2500 |
case CT_ComboBox: { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2501 |
// Fixing Ui design issues with too wide QComboBoxes and greedy SizeHints |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2502 |
// Make sure, that the combobox stays within the screen. |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2503 |
const QSize desktopContentSize = QApplication::desktop()->availableGeometry().size() |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2504 |
- QSize(pixelMetric(PM_LayoutLeftMargin) + pixelMetric(PM_LayoutRightMargin), 0); |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2505 |
sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget). |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2506 |
boundedTo(desktopContentSize); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2507 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2508 |
break; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2509 |
#endif |
0 | 2510 |
default: |
2511 |
sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); |
|
2512 |
break; |
|
2513 |
} |
|
2514 |
return sz; |
|
2515 |
} |
|
2516 |
||
2517 |
/*! \reimp */ |
|
2518 |
int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *widget, |
|
2519 |
QStyleHintReturn *hret) const |
|
2520 |
{ |
|
2521 |
int retValue = -1; |
|
2522 |
switch (sh) { |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2523 |
case SH_RequestSoftwareInputPanel: |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2524 |
if (QS60StylePrivate::isSingleClickUi()) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2525 |
retValue = RSIP_OnMouseClick; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2526 |
else |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2527 |
retValue = RSIP_OnMouseClickAndAlreadyFocused; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2528 |
break; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2529 |
case SH_ComboBox_Popup: |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2530 |
retValue = true; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2531 |
break; |
0 | 2532 |
case SH_Table_GridLineColor: |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2533 |
retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 2, 0).rgba()); |
0 | 2534 |
break; |
2535 |
case SH_GroupBox_TextLabelColor: |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2536 |
retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0).rgba()); |
0 | 2537 |
break; |
2538 |
case SH_ScrollBar_ScrollWhenPointerLeavesControl: |
|
2539 |
retValue = true; |
|
2540 |
break; |
|
2541 |
case SH_Slider_SnapToValue: |
|
2542 |
retValue = true; |
|
2543 |
break; |
|
2544 |
case SH_Slider_StopMouseOverSlider: |
|
2545 |
retValue = true; |
|
2546 |
break; |
|
2547 |
case SH_LineEdit_PasswordCharacter: |
|
2548 |
retValue = '*'; |
|
2549 |
break; |
|
2550 |
case SH_ComboBox_PopupFrameStyle: |
|
2551 |
retValue = QFrame::NoFrame | QFrame::Plain; |
|
2552 |
break; |
|
2553 |
case SH_Dial_BackgroundRole: |
|
2554 |
retValue = QPalette::Base; |
|
2555 |
break; |
|
2556 |
case SH_ItemView_ActivateItemOnSingleClick: |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2557 |
retValue = QS60StylePrivate::isSingleClickUi(); |
0 | 2558 |
break; |
2559 |
case SH_ProgressDialog_TextLabelAlignment: |
|
2560 |
retValue = (QApplication::layoutDirection() == Qt::LeftToRight) ? |
|
2561 |
Qt::AlignLeft : |
|
2562 |
Qt::AlignRight; |
|
2563 |
break; |
|
2564 |
case SH_Menu_SubMenuPopupDelay: |
|
2565 |
retValue = 300; |
|
2566 |
break; |
|
2567 |
case SH_Menu_Scrollable: |
|
2568 |
retValue = true; |
|
2569 |
break; |
|
2570 |
case SH_Menu_SelectionWrap: |
|
2571 |
retValue = true; |
|
2572 |
break; |
|
2573 |
case SH_ItemView_ShowDecorationSelected: |
|
2574 |
retValue = true; |
|
2575 |
break; |
|
2576 |
case SH_ToolBar_Movable: |
|
2577 |
retValue = false; |
|
2578 |
break; |
|
2579 |
case SH_BlinkCursorWhenTextSelected: |
|
2580 |
retValue = true; |
|
2581 |
break; |
|
2582 |
case SH_UnderlineShortcut: |
|
2583 |
retValue = 0; |
|
2584 |
break; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2585 |
case SH_FormLayoutWrapPolicy: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2586 |
retValue = QFormLayout::WrapLongRows; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2587 |
break; |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2588 |
case SH_ScrollBar_ContextMenu: |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2589 |
retValue = false; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2590 |
break; |
0 | 2591 |
default: |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2592 |
retValue = QCommonStyle::styleHint(sh, opt, widget, hret); |
0 | 2593 |
break; |
2594 |
} |
|
2595 |
return retValue; |
|
2596 |
} |
|
2597 |
||
2598 |
/*! \reimp */ |
|
2599 |
QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComplex *option, SubControl scontrol, const QWidget *widget) const |
|
2600 |
{ |
|
2601 |
QRect ret; |
|
2602 |
switch (control) { |
|
2603 |
#ifndef QT_NO_SCROLLBAR |
|
2604 |
// This implementation of subControlRect(CC_ScrollBar..) basically just removes the SC_ScrollBarSubLine and SC_ScrollBarAddLine |
|
2605 |
case CC_ScrollBar: |
|
2606 |
if (const QStyleOptionSlider *scrollbarOption = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
2607 |
const QRect scrollBarRect = scrollbarOption->rect; |
|
2608 |
const bool isHorizontal = scrollbarOption->orientation == Qt::Horizontal; |
|
2609 |
const int maxlen = isHorizontal ? scrollBarRect.width() : scrollBarRect.height(); |
|
2610 |
int sliderlen; |
|
2611 |
||
2612 |
// calculate slider length |
|
2613 |
if (scrollbarOption->maximum != scrollbarOption->minimum) { |
|
2614 |
const uint range = scrollbarOption->maximum - scrollbarOption->minimum; |
|
2615 |
sliderlen = (qint64(scrollbarOption->pageStep) * maxlen) / (range + scrollbarOption->pageStep); |
|
2616 |
||
2617 |
const int slidermin = pixelMetric(PM_ScrollBarSliderMin, scrollbarOption, widget); |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2618 |
if (sliderlen < slidermin || range > (INT_MAX >> 1)) |
0 | 2619 |
sliderlen = slidermin; |
2620 |
if (sliderlen > maxlen) |
|
2621 |
sliderlen = maxlen; |
|
2622 |
} else { |
|
2623 |
sliderlen = maxlen; |
|
2624 |
} |
|
2625 |
||
2626 |
const int sliderstart = sliderPositionFromValue(scrollbarOption->minimum, |
|
2627 |
scrollbarOption->maximum, |
|
2628 |
scrollbarOption->sliderPosition, |
|
2629 |
maxlen - sliderlen, |
|
2630 |
scrollbarOption->upsideDown); |
|
2631 |
||
2632 |
switch (scontrol) { |
|
2633 |
case SC_ScrollBarSubPage: // between top/left button and slider |
|
2634 |
if (isHorizontal) |
|
2635 |
ret.setRect(0, 0, sliderstart, scrollBarRect.height()); |
|
2636 |
else |
|
2637 |
ret.setRect(0, 0, scrollBarRect.width(), sliderstart); |
|
2638 |
break; |
|
2639 |
case SC_ScrollBarAddPage: { // between bottom/right button and slider |
|
2640 |
const int addPageLength = sliderstart + sliderlen; |
|
2641 |
if (isHorizontal) |
|
2642 |
ret = scrollBarRect.adjusted(addPageLength, 0, 0, 0); |
|
2643 |
else |
|
2644 |
ret = scrollBarRect.adjusted(0, addPageLength, 0, 0); |
|
2645 |
} |
|
2646 |
break; |
|
2647 |
case SC_ScrollBarGroove: |
|
2648 |
ret = scrollBarRect; |
|
2649 |
break; |
|
2650 |
case SC_ScrollBarSlider: |
|
2651 |
if (scrollbarOption->orientation == Qt::Horizontal) |
|
2652 |
ret.setRect(sliderstart, 0, sliderlen, scrollBarRect.height()); |
|
2653 |
else |
|
2654 |
ret.setRect(0, sliderstart, scrollBarRect.width(), sliderlen); |
|
2655 |
break; |
|
2656 |
case SC_ScrollBarSubLine: // top/left button |
|
2657 |
case SC_ScrollBarAddLine: // bottom/right button |
|
2658 |
default: |
|
2659 |
break; |
|
2660 |
} |
|
2661 |
ret = visualRect(scrollbarOption->direction, scrollBarRect, ret); |
|
2662 |
} |
|
2663 |
break; |
|
2664 |
#endif // QT_NO_SCROLLBAR |
|
2665 |
case CC_SpinBox: |
|
2666 |
if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
|
2667 |
const int frameThickness = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; |
|
2668 |
const int buttonMargin = spinbox->frame ? 2 : 0; |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2669 |
const int buttonContentWidth = QS60StylePrivate::pixelMetric(PM_ButtonIconSize) + 2 * buttonMargin; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2670 |
// Spinbox buttons should be no larger than one fourth of total width. |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2671 |
// Thus, side-by-side buttons would take half of the total width. |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2672 |
const int maxSize = qMax(spinbox->rect.width() / 4, buttonContentWidth); |
0 | 2673 |
QSize buttonSize; |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2674 |
buttonSize.setHeight(qMin(maxSize, qMax(8, spinbox->rect.height() - frameThickness))); |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2675 |
//width should at least be equal to height |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2676 |
buttonSize.setWidth(qMax(buttonSize.height(), buttonContentWidth)); |
0 | 2677 |
buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); |
2678 |
||
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2679 |
// Normally spinbuttons should be side-by-side, but if spinbox grows very big |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2680 |
// and spinbuttons reach their maximum size, they can be deployed one top of the other. |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2681 |
const bool sideBySide = (buttonSize.height() * 2 < spinbox->rect.height()) ? false : true; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2682 |
const int y = frameThickness + spinbox->rect.y() + |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2683 |
(spinbox->rect.height() - (sideBySide ? 1 : 2) * buttonSize.height()) / 2; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2684 |
const int x = spinbox->rect.x() + |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2685 |
spinbox->rect.width() - frameThickness - (sideBySide ? 2 : 1) * buttonSize.width(); |
0 | 2686 |
|
2687 |
switch (scontrol) { |
|
2688 |
case SC_SpinBoxUp: |
|
2689 |
if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
|
2690 |
return QRect(); |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2691 |
ret = QRect(x, y, buttonSize.width(), buttonSize.height()); |
0 | 2692 |
break; |
2693 |
case SC_SpinBoxDown: |
|
2694 |
if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
|
2695 |
return QRect(); |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2696 |
ret = QRect(x + (sideBySide ? buttonSize.width() : 0), |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2697 |
y + (sideBySide ? 0 : buttonSize.height()), |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2698 |
buttonSize.width(), buttonSize.height()); |
0 | 2699 |
break; |
2700 |
case SC_SpinBoxEditField: |
|
2701 |
if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
|
2702 |
ret = QRect( |
|
2703 |
frameThickness, |
|
2704 |
frameThickness, |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2705 |
spinbox->rect.width() - 2 * frameThickness, |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2706 |
spinbox->rect.height() - 2 * frameThickness); |
0 | 2707 |
else |
2708 |
ret = QRect( |
|
2709 |
frameThickness, |
|
2710 |
frameThickness, |
|
2711 |
x - frameThickness, |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2712 |
spinbox->rect.height() - 2 * frameThickness); |
0 | 2713 |
break; |
2714 |
case SC_SpinBoxFrame: |
|
2715 |
ret = spinbox->rect; |
|
2716 |
break; |
|
2717 |
default: |
|
2718 |
break; |
|
2719 |
} |
|
2720 |
ret = visualRect(spinbox->direction, spinbox->rect, ret); |
|
2721 |
} |
|
2722 |
break; |
|
2723 |
case CC_ComboBox: |
|
2724 |
if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
|
2725 |
ret = cmb->rect; |
|
2726 |
const int width = cmb->rect.width(); |
|
2727 |
const int height = cmb->rect.height(); |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2728 |
const int buttonIconSize = QS60StylePrivate::pixelMetric(PM_ButtonIconSize); |
0 | 2729 |
const int buttonMargin = cmb->frame ? 2 : 0; |
2730 |
// lets use spinbox frame here as well, as no combobox specific value available. |
|
2731 |
const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0; |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2732 |
const int buttonWidth = qMax(cmb->rect.height(), buttonIconSize); |
0 | 2733 |
|
2734 |
QSize buttonSize; |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2735 |
buttonSize.setWidth(buttonWidth + 2 * buttonMargin); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2736 |
buttonSize.setHeight(qMax(8, (cmb->rect.height() >> 1) - frameThickness)); //buttons should be squares |
0 | 2737 |
buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); |
2738 |
switch (scontrol) { |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2739 |
case SC_ComboBoxArrow: { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2740 |
const int xposMod = cmb->rect.x() + width - buttonMargin - buttonWidth; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2741 |
const int ypos = cmb->rect.y(); |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2742 |
ret.setRect(xposMod, ypos + buttonMargin, buttonWidth, height - 2 * buttonMargin); |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2743 |
} |
0 | 2744 |
break; |
2745 |
case SC_ComboBoxEditField: { |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2746 |
const int withFrameX = cmb->rect.x() + width - frameThickness - buttonSize.width(); |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2747 |
ret = QRect( |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2748 |
frameThickness, |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2749 |
frameThickness, |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2750 |
withFrameX - frameThickness, |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2751 |
height - 2 * frameThickness); |
0 | 2752 |
} |
2753 |
break; |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2754 |
case SC_ComboBoxListBoxPopup: { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2755 |
const QRect desktopContent = QApplication::desktop()->availableGeometry(); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2756 |
|
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2757 |
// take the size of this and position bottom above available area |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2758 |
QRect popupRect; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2759 |
const int width = desktopContent.width() - pixelMetric(PM_LayoutRightMargin) - pixelMetric(PM_LayoutLeftMargin); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2760 |
popupRect.setWidth(width); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2761 |
popupRect.setHeight(desktopContent.height()); //combobox resets height anyway based on content |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2762 |
popupRect.setBottom(desktopContent.bottom()); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2763 |
popupRect.translate(pixelMetric(PM_LayoutLeftMargin), 0); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2764 |
ret = popupRect; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2765 |
} |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2766 |
break; |
0 | 2767 |
default: |
2768 |
break; |
|
2769 |
} |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2770 |
ret = visualRect(cmb->direction, cmb->rect, ret); |
0 | 2771 |
} |
2772 |
break; |
|
2773 |
case CC_GroupBox: |
|
2774 |
if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { |
|
2775 |
ret = QCommonStyle::subControlRect(control, option, scontrol, widget); |
|
2776 |
switch (scontrol) { |
|
2777 |
case SC_GroupBoxCheckBox: //fallthrough |
|
2778 |
case SC_GroupBoxLabel: { |
|
2779 |
//slightly indent text and boxes, so that dialog border does not mess with them. |
|
2780 |
const int horizontalSpacing = |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2781 |
QS60StylePrivate::pixelMetric(PM_LayoutHorizontalSpacing); |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2782 |
ret.adjust(2, horizontalSpacing - 3, 0, 0); |
0 | 2783 |
} |
2784 |
break; |
|
2785 |
case SC_GroupBoxFrame: { |
|
2786 |
const QRect textBox = subControlRect(control, option, SC_GroupBoxLabel, widget); |
|
2787 |
const int tbHeight = textBox.height(); |
|
2788 |
ret.translate(0, -ret.y()); |
|
2789 |
// include title to within the groupBox frame |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2790 |
ret.setHeight(ret.height() + tbHeight); |
0 | 2791 |
if (widget && ret.bottom() > widget->rect().bottom()) |
2792 |
ret.setBottom(widget->rect().bottom()); |
|
2793 |
} |
|
2794 |
break; |
|
2795 |
default: |
|
2796 |
break; |
|
2797 |
} |
|
2798 |
} |
|
2799 |
break; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2800 |
case CC_ToolButton: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2801 |
if (const QStyleOptionToolButton *toolButton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2802 |
const int indicatorRect = pixelMetric(PM_MenuButtonIndicator) + 2 * pixelMetric(PM_ButtonMargin); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2803 |
const int border = pixelMetric(PM_ButtonMargin) + pixelMetric(PM_DefaultFrameWidth); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2804 |
ret = toolButton->rect; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2805 |
const bool popup = (toolButton->features & |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2806 |
(QStyleOptionToolButton::MenuButtonPopup | QStyleOptionToolButton::PopupDelay)) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2807 |
== QStyleOptionToolButton::MenuButtonPopup; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2808 |
switch (scontrol) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2809 |
case SC_ToolButton: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2810 |
if (popup) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2811 |
ret.adjust(0, 0, -indicatorRect, 0); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2812 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2813 |
case SC_ToolButtonMenu: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2814 |
if (popup) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2815 |
ret.adjust(ret.width() - indicatorRect, border, -pixelMetric(PM_ButtonMargin), -border); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2816 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2817 |
default: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2818 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2819 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2820 |
ret = visualRect(toolButton->direction, toolButton->rect, ret); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2821 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2822 |
break; |
0 | 2823 |
default: |
2824 |
ret = QCommonStyle::subControlRect(control, option, scontrol, widget); |
|
2825 |
} |
|
2826 |
return ret; |
|
2827 |
} |
|
2828 |
||
2829 |
/*! |
|
2830 |
\reimp |
|
2831 |
*/ |
|
2832 |
QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, const QWidget *widget) const |
|
2833 |
{ |
|
2834 |
QRect ret; |
|
2835 |
switch (element) { |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2836 |
case SE_RadioButtonFocusRect: |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2837 |
ret = opt->rect; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2838 |
break; |
0 | 2839 |
case SE_LineEditContents: { |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2840 |
// in S60 the input text box doesn't start from line Edit's TL, but |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2841 |
// a bit indented (8 pixels). |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2842 |
const int KLineEditDefaultIndention = 8; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2843 |
ret = visualRect( |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2844 |
opt->direction, opt->rect, opt->rect.adjusted(KLineEditDefaultIndention, 0, 0, 0)); |
0 | 2845 |
} |
2846 |
break; |
|
2847 |
case SE_TabBarTearIndicator: |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2848 |
ret = QRect(0, 0, 0, 0); |
0 | 2849 |
break; |
2850 |
case SE_TabWidgetTabBar: |
|
2851 |
if (const QStyleOptionTabWidgetFrame *optionTab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { |
|
2852 |
ret = QCommonStyle::subElementRect(element, opt, widget); |
|
2853 |
||
2854 |
if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { |
|
2855 |
const int tabOverlapNoBorder = |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2856 |
QS60StylePrivate::pixelMetric(PM_TabBarTabOverlap); |
0 | 2857 |
const int tabOverlap = |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2858 |
tabOverlapNoBorder - QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); |
0 | 2859 |
const QTabWidget *tab = qobject_cast<const QTabWidget *>(widget); |
2860 |
int gain = (tab) ? tabOverlap * tab->count() : 0; |
|
2861 |
switch (twf->shape) { |
|
2862 |
case QTabBar::RoundedNorth: |
|
2863 |
case QTabBar::TriangularNorth: |
|
2864 |
case QTabBar::RoundedSouth: |
|
2865 |
case QTabBar::TriangularSouth: { |
|
2866 |
if (widget) { |
|
2867 |
// make sure that gain does not set the rect outside of widget boundaries |
|
2868 |
if (twf->direction == Qt::RightToLeft) { |
|
2869 |
if ((ret.left() - gain) < widget->rect().left()) |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2870 |
gain = widget->rect().left() - ret.left(); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2871 |
ret.adjust(-gain, 0, 0, 0); |
0 | 2872 |
} else { |
2873 |
if ((ret.right() + gain) > widget->rect().right()) |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2874 |
gain = widget->rect().right() - ret.right(); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2875 |
ret.adjust(0, 0, gain, 0); |
0 | 2876 |
} |
2877 |
} |
|
2878 |
break; |
|
2879 |
} |
|
2880 |
default: { |
|
2881 |
if (widget) { |
|
2882 |
if ((ret.bottom() + gain) > widget->rect().bottom()) |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2883 |
gain = widget->rect().bottom() - ret.bottom(); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2884 |
ret.adjust(0, 0, 0, gain); |
0 | 2885 |
} |
2886 |
break; |
|
2887 |
} |
|
2888 |
} |
|
2889 |
} |
|
2890 |
} |
|
2891 |
break; |
|
2892 |
case SE_ItemViewItemText: |
|
2893 |
case SE_ItemViewItemDecoration: |
|
2894 |
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) { |
|
2895 |
const QListWidget *listItem = qobject_cast<const QListWidget *>(widget); |
|
2896 |
const bool multiSelection = !listItem ? false : |
|
2897 |
listItem->selectionMode() == QAbstractItemView::MultiSelection || |
|
2898 |
listItem->selectionMode() == QAbstractItemView::ExtendedSelection || |
|
2899 |
listItem->selectionMode() == QAbstractItemView::ContiguousSelection; |
|
2900 |
ret = QCommonStyle::subElementRect(element, opt, widget); |
|
2901 |
// If both multiselect & check-state, then remove checkbox and move |
|
2902 |
// text and decoration towards the beginning |
|
2903 |
if (listItem && |
|
2904 |
multiSelection && |
|
2905 |
(vopt->features & QStyleOptionViewItemV2::HasCheckIndicator)) { |
|
2906 |
const int verticalSpacing = |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2907 |
QS60StylePrivate::pixelMetric(PM_LayoutVerticalSpacing); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2908 |
//const int horizontalSpacing = QS60StylePrivate::pixelMetric(PM_LayoutHorizontalSpacing); |
0 | 2909 |
const int checkBoxRectWidth = subElementRect(SE_ItemViewItemCheckIndicator, opt, widget).width(); |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2910 |
ret.adjust(-checkBoxRectWidth - verticalSpacing, 0, -checkBoxRectWidth - verticalSpacing, 0); |
0 | 2911 |
} |
2912 |
} else if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { |
|
2913 |
const bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable; |
|
2914 |
const int indicatorWidth = checkable ? |
|
2915 |
pixelMetric(PM_ListViewIconSize, opt, widget) : |
|
2916 |
pixelMetric(PM_SmallIconSize, opt, widget); |
|
2917 |
ret = menuItem->rect; |
|
2918 |
||
2919 |
if (element == SE_ItemViewItemDecoration) { |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2920 |
if (menuItem->icon.isNull()) { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2921 |
ret = QRect(); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2922 |
} else { |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2923 |
if (menuItem->direction == Qt::RightToLeft) |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
2924 |
ret.translate(ret.width() - indicatorWidth, 0); |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2925 |
ret.setWidth(indicatorWidth); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2926 |
} |
0 | 2927 |
} else { |
2928 |
ret = menuItem->rect; |
|
2929 |
if (!menuItem->icon.isNull()) |
|
2930 |
if (menuItem->direction == Qt::LeftToRight) |
|
2931 |
ret.adjust(indicatorWidth, 0, 0, 0); |
|
2932 |
else |
|
2933 |
ret.adjust(0, 0, -indicatorWidth, 0); |
|
2934 |
||
2935 |
// Make room for submenu indicator |
|
2936 |
if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu){ |
|
2937 |
// submenu indicator is very small, so lets halve the rect |
|
2938 |
if (menuItem->direction == Qt::LeftToRight) |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2939 |
ret.adjust(0, 0, -(indicatorWidth >> 1), 0); |
0 | 2940 |
else |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2941 |
ret.adjust((indicatorWidth >> 1), 0, 0, 0); |
0 | 2942 |
} |
2943 |
} |
|
2944 |
} |
|
2945 |
break; |
|
2946 |
case SE_ItemViewItemCheckIndicator: |
|
2947 |
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) { |
|
2948 |
const QListWidget *listItem = qobject_cast<const QListWidget *>(widget); |
|
2949 |
||
2950 |
const bool singleSelection = listItem && |
|
2951 |
(listItem->selectionMode() == QAbstractItemView::SingleSelection || |
|
2952 |
listItem->selectionMode() == QAbstractItemView::NoSelection); |
|
2953 |
const bool checkBoxOnly = (vopt->features & QStyleOptionViewItemV2::HasCheckIndicator) && |
|
2954 |
listItem && |
|
2955 |
singleSelection; |
|
2956 |
||
2957 |
// Selection check mark rect. |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2958 |
const int indicatorWidth = QS60StylePrivate::pixelMetric(PM_IndicatorWidth); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2959 |
const int indicatorHeight = QS60StylePrivate::pixelMetric(PM_IndicatorHeight); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2960 |
const int spacing = QS60StylePrivate::pixelMetric(PM_CheckBoxLabelSpacing); |
0 | 2961 |
|
2962 |
const int itemHeight = opt->rect.height(); |
|
2963 |
int heightOffset = 0; |
|
2964 |
if (indicatorHeight < itemHeight) |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2965 |
heightOffset = ((itemHeight - indicatorHeight) >> 1); |
0 | 2966 |
if (checkBoxOnly) { |
2967 |
// Move rect and make it slightly smaller, so that |
|
2968 |
// a) highlight border does not cross the rect |
|
2969 |
// b) in s60 list checkbox is smaller than normal checkbox |
|
2970 |
//todo; magic three |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2971 |
ret.setRect(opt->rect.left() + 3, opt->rect.top() + heightOffset, |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
2972 |
indicatorWidth - 3, indicatorHeight - 3); |
0 | 2973 |
} else { |
2974 |
ret.setRect(opt->rect.right() - indicatorWidth - spacing, opt->rect.top() + heightOffset, |
|
2975 |
indicatorWidth, indicatorHeight); |
|
2976 |
} |
|
2977 |
} else { |
|
2978 |
ret = QCommonStyle::subElementRect(element, opt, widget); |
|
2979 |
} |
|
2980 |
break; |
|
2981 |
case SE_HeaderLabel: |
|
2982 |
ret = QCommonStyle::subElementRect(element, opt, widget); |
|
2983 |
if (qstyleoption_cast<const QStyleOptionHeader *>(opt)) { |
|
2984 |
// Subtract area needed for line |
|
2985 |
if (opt->state & State_Horizontal) |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2986 |
ret.setHeight(ret.height() - QS60StylePrivate::pixelMetric(PM_BoldLineWidth)); |
0 | 2987 |
else |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
2988 |
ret.setWidth(ret.width() - QS60StylePrivate::pixelMetric(PM_ThinLineWidth)); |
0 | 2989 |
} |
2990 |
ret = visualRect(opt->direction, opt->rect, ret); |
|
2991 |
break; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2992 |
case SE_RadioButtonIndicator: { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2993 |
const int height = pixelMetric(PM_ExclusiveIndicatorHeight, opt, widget); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2994 |
ret.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - height) >> 1), |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2995 |
pixelMetric(PM_ExclusiveIndicatorWidth, opt, widget), height); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2996 |
ret.translate(2, 0); //move indicator slightly to avoid highlight crossing over it |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2997 |
ret = visualRect(opt->direction, opt->rect, ret); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2998 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
2999 |
break; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3000 |
case SE_CheckBoxIndicator: { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3001 |
const int height = pixelMetric(PM_IndicatorHeight, opt, widget); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3002 |
ret.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - height) >> 1), |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3003 |
pixelMetric(PM_IndicatorWidth, opt, widget), height); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3004 |
ret.translate(2, 0); //move indicator slightly to avoid highlight crossing over it |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3005 |
ret = visualRect(opt->direction, opt->rect, ret); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3006 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3007 |
break; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3008 |
case SE_CheckBoxFocusRect: |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3009 |
ret = opt->rect; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3010 |
break; |
0 | 3011 |
default: |
3012 |
ret = QCommonStyle::subElementRect(element, opt, widget); |
|
3013 |
} |
|
3014 |
return ret; |
|
3015 |
} |
|
3016 |
||
3017 |
/*! |
|
3018 |
\reimp |
|
3019 |
*/ |
|
3020 |
void QS60Style::polish(QWidget *widget) |
|
3021 |
{ |
|
3022 |
Q_D(const QS60Style); |
|
3023 |
QCommonStyle::polish(widget); |
|
3024 |
||
3025 |
if (!widget) |
|
3026 |
return; |
|
3027 |
||
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3028 |
//Currently we only support animations in QProgressBar. |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3029 |
#ifndef QT_NO_PROGRESSBAR |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3030 |
if (qobject_cast<QProgressBar *>(widget)) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3031 |
widget->installEventFilter(this); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3032 |
#endif |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3033 |
|
0 | 3034 |
if (false |
3035 |
#ifndef QT_NO_SCROLLBAR |
|
3036 |
|| qobject_cast<QScrollBar *>(widget) |
|
3037 |
#endif |
|
3038 |
) { |
|
3039 |
widget->setAttribute(Qt::WA_OpaquePaintEvent, false); |
|
3040 |
} |
|
3041 |
||
3042 |
if (QS60StylePrivate::drawsOwnThemeBackground(widget)) { |
|
3043 |
widget->setAttribute(Qt::WA_StyledBackground); |
|
3044 |
} else if (false |
|
3045 |
#ifndef QT_NO_MENU |
|
3046 |
|| qobject_cast<const QMenu *> (widget) |
|
3047 |
#endif // QT_NO_MENU |
|
3048 |
) { |
|
3049 |
widget->setAttribute(Qt::WA_StyledBackground); |
|
3050 |
} else if (false |
|
3051 |
#ifndef QT_NO_COMBOBOX |
|
3052 |
|| qobject_cast<const QComboBoxListView *>(widget) |
|
3053 |
#endif //QT_NO_COMBOBOX |
|
3054 |
) { |
|
3055 |
widget->setAttribute(Qt::WA_StyledBackground); |
|
3056 |
} |
|
3057 |
d->setThemePalette(widget); |
|
3058 |
d->setFont(widget); |
|
3059 |
} |
|
3060 |
||
3061 |
/*! |
|
3062 |
\reimp |
|
3063 |
*/ |
|
3064 |
void QS60Style::unpolish(QWidget *widget) |
|
3065 |
{ |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3066 |
Q_D(QS60Style); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3067 |
|
0 | 3068 |
if (false |
3069 |
#ifndef QT_NO_SCROLLBAR |
|
3070 |
|| qobject_cast<QScrollBar *>(widget) |
|
3071 |
#endif |
|
3072 |
) |
|
3073 |
widget->setAttribute(Qt::WA_OpaquePaintEvent); |
|
3074 |
||
3075 |
if (QS60StylePrivate::drawsOwnThemeBackground(widget)) { |
|
3076 |
widget->setAttribute(Qt::WA_StyledBackground, false); |
|
3077 |
} else if (false |
|
3078 |
#ifndef QT_NO_MENU |
|
3079 |
|| qobject_cast<const QMenu *> (widget) |
|
3080 |
#endif // QT_NO_MENU |
|
3081 |
) { |
|
3082 |
widget->setAttribute(Qt::WA_StyledBackground, false); |
|
3083 |
} else if (false |
|
3084 |
#ifndef QT_NO_COMBOBOX |
|
3085 |
|| qobject_cast<const QComboBoxListView *>(widget) |
|
3086 |
#endif //QT_NO_COMBOBOX |
|
3087 |
) { |
|
3088 |
widget->setAttribute(Qt::WA_StyledBackground, false); |
|
3089 |
} |
|
3090 |
||
3091 |
if (widget) |
|
3092 |
widget->setPalette(QPalette()); |
|
3093 |
||
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3094 |
#if defined(Q_WS_S60) && !defined(QT_NO_PROGRESSBAR) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3095 |
if (QProgressBar *bar = qobject_cast<QProgressBar *>(widget)) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3096 |
widget->removeEventFilter(this); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3097 |
d->m_bars.removeAll(bar); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3098 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3099 |
#else |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3100 |
Q_UNUSED(d) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3101 |
#endif |
0 | 3102 |
QCommonStyle::unpolish(widget); |
3103 |
} |
|
3104 |
||
3105 |
/*! |
|
3106 |
\reimp |
|
3107 |
*/ |
|
3108 |
void QS60Style::polish(QApplication *application) |
|
3109 |
{ |
|
3110 |
Q_D(QS60Style); |
|
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3111 |
QCommonStyle::polish(qApp); |
0 | 3112 |
d->m_originalPalette = application->palette(); |
3113 |
d->setThemePalette(application); |
|
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3114 |
if (QS60StylePrivate::isTouchSupported()) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3115 |
qApp->installEventFilter(this); |
0 | 3116 |
} |
3117 |
||
3118 |
/*! |
|
3119 |
\reimp |
|
3120 |
*/ |
|
3121 |
void QS60Style::unpolish(QApplication *application) |
|
3122 |
{ |
|
3123 |
Q_UNUSED(application) |
|
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3124 |
|
0 | 3125 |
Q_D(QS60Style); |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3126 |
QCommonStyle::unpolish(qApp); |
0 | 3127 |
const QPalette newPalette = QApplication::style()->standardPalette(); |
3128 |
QApplication::setPalette(newPalette); |
|
3129 |
QApplicationPrivate::setSystemPalette(d->m_originalPalette); |
|
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3130 |
if (QS60StylePrivate::isTouchSupported()) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3131 |
qApp->removeEventFilter(this); |
0 | 3132 |
} |
3133 |
||
3134 |
/*! |
|
3135 |
\reimp |
|
3136 |
*/ |
|
3137 |
bool QS60Style::event(QEvent *e) |
|
3138 |
{ |
|
3139 |
#ifdef QT_KEYPAD_NAVIGATION |
|
3140 |
Q_D(QS60Style); |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3141 |
const QEvent::Type eventType = e->type(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3142 |
if ((eventType == QEvent::FocusIn || |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3143 |
eventType == QEvent::FocusOut || |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3144 |
eventType == QEvent::EnterEditFocus || |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3145 |
eventType == QEvent::LeaveEditFocus) && |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3146 |
QS60StylePrivate::isTouchSupported()) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3147 |
return false; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3148 |
#endif |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3149 |
|
0 | 3150 |
switch (e->type()) { |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3151 |
case QEvent::Timer: { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3152 |
QTimerEvent *te = static_cast<QTimerEvent*>(e); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3153 |
timerEvent(te); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3154 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3155 |
break; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3156 |
#ifdef QT_KEYPAD_NAVIGATION |
0 | 3157 |
case QEvent::FocusIn: |
3158 |
if (QWidget *focusWidget = QApplication::focusWidget()) { |
|
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3159 |
|
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3160 |
// Menus and combobox popups do not draw focus frame around them |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3161 |
if (qobject_cast<QComboBoxListView *>(focusWidget) || |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3162 |
qobject_cast<QMenu *>(focusWidget)) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3163 |
break; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3164 |
|
0 | 3165 |
if (!d->m_focusFrame) |
3166 |
d->m_focusFrame = new QFocusFrame(focusWidget); |
|
3167 |
d->m_focusFrame->setWidget(focusWidget); |
|
3168 |
} else if (d->m_focusFrame) { |
|
3169 |
d->m_focusFrame->setWidget(0); |
|
3170 |
} |
|
3171 |
break; |
|
3172 |
case QEvent::FocusOut: |
|
3173 |
if (d->m_focusFrame) |
|
3174 |
d->m_focusFrame->setWidget(0); |
|
3175 |
break; |
|
3176 |
case QEvent::EnterEditFocus: |
|
3177 |
case QEvent::LeaveEditFocus: |
|
3178 |
if (d->m_focusFrame) |
|
3179 |
d->m_focusFrame->update(); |
|
3180 |
break; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3181 |
#endif |
0 | 3182 |
default: |
3183 |
break; |
|
3184 |
} |
|
3185 |
return false; |
|
3186 |
} |
|
3187 |
||
3188 |
/*! |
|
3189 |
\internal |
|
3190 |
*/ |
|
3191 |
QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon, |
|
3192 |
const QStyleOption *option, const QWidget *widget) const |
|
3193 |
{ |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3194 |
const int iconDimension = QS60StylePrivate::pixelMetric(PM_ToolBarIconSize); |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3195 |
const QRect iconSize = (!option) ? QRect(0, 0, iconDimension, iconDimension) : option->rect; |
0 | 3196 |
QS60StyleEnums::SkinParts part; |
3197 |
QS60StylePrivate::SkinElementFlags adjustedFlags; |
|
3198 |
if (option) |
|
3199 |
adjustedFlags = (option->state & State_Enabled || option->state == 0) ? |
|
3200 |
QS60StylePrivate::SF_StateEnabled : |
|
3201 |
QS60StylePrivate::SF_StateDisabled; |
|
3202 |
||
3203 |
switch(standardIcon) { |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3204 |
case SP_MessageBoxWarning: |
0 | 3205 |
part = QS60StyleEnums::SP_QgnNoteWarning; |
3206 |
break; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3207 |
case SP_MessageBoxInformation: |
0 | 3208 |
part = QS60StyleEnums::SP_QgnNoteInfo; |
3209 |
break; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3210 |
case SP_MessageBoxCritical: |
0 | 3211 |
part = QS60StyleEnums::SP_QgnNoteError; |
3212 |
break; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3213 |
case SP_MessageBoxQuestion: |
0 | 3214 |
part = QS60StyleEnums::SP_QgnNoteQuery; |
3215 |
break; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3216 |
case SP_ArrowRight: |
0 | 3217 |
part = QS60StyleEnums::SP_QgnIndiNaviArrowRight; |
3218 |
break; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3219 |
case SP_ArrowLeft: |
0 | 3220 |
part = QS60StyleEnums::SP_QgnIndiNaviArrowLeft; |
3221 |
break; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3222 |
case SP_ArrowUp: |
0 | 3223 |
part = QS60StyleEnums::SP_QgnIndiNaviArrowLeft; |
3224 |
adjustedFlags |= QS60StylePrivate::SF_PointEast; |
|
3225 |
break; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3226 |
case SP_ArrowDown: |
0 | 3227 |
part = QS60StyleEnums::SP_QgnIndiNaviArrowLeft; |
3228 |
adjustedFlags |= QS60StylePrivate::SF_PointWest; |
|
3229 |
break; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3230 |
case SP_ArrowBack: |
0 | 3231 |
if (QApplication::layoutDirection() == Qt::RightToLeft) |
3232 |
return QS60Style::standardIcon(SP_ArrowRight, option, widget); |
|
3233 |
return QS60Style::standardIcon(SP_ArrowLeft, option, widget); |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3234 |
case SP_ArrowForward: |
0 | 3235 |
if (QApplication::layoutDirection() == Qt::RightToLeft) |
3236 |
return QS60Style::standardIcon(SP_ArrowLeft, option, widget); |
|
3237 |
return QS60Style::standardIcon(SP_ArrowRight, option, widget); |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3238 |
case SP_ComputerIcon: |
0 | 3239 |
part = QS60StyleEnums::SP_QgnPropPhoneMemcLarge; |
3240 |
break; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3241 |
case SP_DirClosedIcon: |
0 | 3242 |
part = QS60StyleEnums::SP_QgnPropFolderSmall; |
3243 |
break; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3244 |
case SP_DirOpenIcon: |
0 | 3245 |
part = QS60StyleEnums::SP_QgnPropFolderCurrent; |
3246 |
break; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3247 |
case SP_DirIcon: |
0 | 3248 |
part = QS60StyleEnums::SP_QgnPropFolderSmall; |
3249 |
break; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3250 |
case SP_FileDialogNewFolder: |
0 | 3251 |
part = QS60StyleEnums::SP_QgnPropFolderSmallNew; |
3252 |
break; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3253 |
case SP_FileIcon: |
0 | 3254 |
part = QS60StyleEnums::SP_QgnPropFileSmall; |
3255 |
break; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3256 |
case SP_TrashIcon: |
0 | 3257 |
part = QS60StyleEnums::SP_QgnNoteErased; |
3258 |
break; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3259 |
case SP_ToolBarHorizontalExtensionButton: |
0 | 3260 |
part = QS60StyleEnums::SP_QgnIndiSubMenu; |
3261 |
if (QApplication::layoutDirection() == Qt::RightToLeft) |
|
3262 |
adjustedFlags |= QS60StylePrivate::SF_PointSouth; |
|
3263 |
break; |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3264 |
case SP_ToolBarVerticalExtensionButton: |
0 | 3265 |
adjustedFlags |= QS60StylePrivate::SF_PointEast; |
3266 |
part = QS60StyleEnums::SP_QgnIndiSubMenu; |
|
3267 |
break; |
|
3268 |
||
3269 |
default: |
|
3270 |
return QCommonStyle::standardIconImplementation(standardIcon, option, widget); |
|
3271 |
} |
|
3272 |
const QS60StylePrivate::SkinElementFlags flags = adjustedFlags; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3273 |
const QPixmap cachedPixMap(QS60StylePrivate::cachedPart(part, iconSize.size(), 0, flags)); |
0 | 3274 |
return cachedPixMap.isNull() ? |
3275 |
QCommonStyle::standardIconImplementation(standardIcon, option, widget) : QIcon(cachedPixMap); |
|
3276 |
} |
|
3277 |
||
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3278 |
/*! |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3279 |
\internal |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3280 |
Animate indeterminate progress bars only when visible |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3281 |
*/ |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3282 |
bool QS60Style::eventFilter(QObject *object, QEvent *event) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3283 |
{ |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3284 |
Q_D(QS60Style); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3285 |
switch(event->type()) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3286 |
case QEvent::MouseButtonPress: { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3287 |
QWidget *w = QApplication::widgetAt(QCursor::pos()); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3288 |
if (w) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3289 |
QWidget *focusW = w->focusProxy(); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3290 |
if (qobject_cast<QAbstractItemView *>(focusW) || |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3291 |
qobject_cast<QRadioButton *>(focusW) || |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3292 |
qobject_cast<QCheckBox *>(focusW)) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3293 |
d->m_pressedWidget = focusW; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3294 |
else if (qobject_cast<QAbstractItemView *>(w)|| |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3295 |
qobject_cast<QRadioButton *>(w) || |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3296 |
qobject_cast<QCheckBox *>(w)) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3297 |
d->m_pressedWidget = w; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3298 |
|
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3299 |
if ( d->m_pressedWidget) |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3300 |
d->m_pressedWidget->update(); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3301 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3302 |
break; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3303 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3304 |
case QEvent::MouseButtonRelease: { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3305 |
const QWidget *w = QApplication::widgetAt(QCursor::pos()); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3306 |
if (w && d->m_pressedWidget) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3307 |
d->m_pressedWidget->update(); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3308 |
d->m_pressedWidget = 0; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3309 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3310 |
break; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3311 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3312 |
default: |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3313 |
break; |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3314 |
} |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3315 |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3316 |
#ifdef Q_WS_S60 |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3317 |
#ifndef QT_NO_PROGRESSBAR |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3318 |
switch(event->type()) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3319 |
case QEvent::StyleChange: |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3320 |
case QEvent::Show: |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3321 |
if (QProgressBar *bar = qobject_cast<QProgressBar *>(object)) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3322 |
if (!d->m_bars.contains(bar)) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3323 |
d->m_bars << bar; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3324 |
if (d->m_bars.size() == 1) //only start with first animated progressbar |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3325 |
d->startAnimation(QS60StyleEnums::SP_QgnGrafBarWaitAnim); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3326 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3327 |
break; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3328 |
case QEvent::Destroy: |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3329 |
case QEvent::Hide: |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3330 |
if (QProgressBar *bar = reinterpret_cast<QProgressBar *>(object)) { |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3331 |
d->stopAnimation(QS60StyleEnums::SP_QgnGrafBarWaitAnim); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3332 |
d->m_bars.removeAll(bar); |
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3333 |
} |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3334 |
break; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3335 |
default: |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3336 |
break; |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3337 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3338 |
#endif // QT_NO_PROGRESSBAR |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3339 |
#endif // Q_WS_S60 |
14
c0432d11811c
eb175c3290cd7ea85da4a590db9461504a4904bc
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
8
diff
changeset
|
3340 |
return QCommonStyle::eventFilter(object, event); |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3341 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3342 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3343 |
/*! |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3344 |
\internal |
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
5
diff
changeset
|
3345 |
Handle the timer \a event. |
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3346 |
*/ |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3347 |
void QS60Style::timerEvent(QTimerEvent *event) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3348 |
{ |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3349 |
#ifdef Q_WS_S60 |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3350 |
#ifndef QT_NO_PROGRESSBAR |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3351 |
Q_D(QS60Style); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3352 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3353 |
QS60StyleAnimation *progressBarAnimation = |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3354 |
QS60StylePrivate::animationDefinition(QS60StyleEnums::SP_QgnGrafBarWaitAnim); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3355 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3356 |
if (event->timerId() == progressBarAnimation->timerId()) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3357 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3358 |
Q_ASSERT(progressBarAnimation->interval() > 0); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3359 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3360 |
if (progressBarAnimation->currentFrame() == progressBarAnimation->frameCount() ) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3361 |
if (progressBarAnimation->playMode() == QS60StyleEnums::AM_Looping) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3362 |
progressBarAnimation->setCurrentFrame(0); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3363 |
else |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3364 |
d->stopAnimation(progressBarAnimation->animationId()); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3365 |
|
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3366 |
foreach (QProgressBar *bar, d->m_bars) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3367 |
if ((bar->minimum() == 0 && bar->maximum() == 0)) |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3368 |
bar->update(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3369 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3370 |
progressBarAnimation->setCurrentFrame(progressBarAnimation->currentFrame() + 1); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3371 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3372 |
#endif // QT_NO_PROGRESSBAR |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3373 |
#endif // Q_WS_S60 |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3374 |
event->ignore(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3375 |
} |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3376 |
|
0 | 3377 |
extern QPoint qt_s60_fill_background_offset(const QWidget *targetWidget); |
3378 |
||
3379 |
bool qt_s60_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush) |
|
3380 |
{ |
|
3381 |
const QPixmap backgroundTexture(QS60StylePrivate::backgroundTexture()); |
|
3382 |
if (backgroundTexture.cacheKey() != brush.texture().cacheKey()) |
|
3383 |
return false; |
|
3384 |
||
3385 |
const QPaintDevice *target = painter->device(); |
|
3386 |
if (target->devType() == QInternal::Widget) { |
|
3387 |
const QWidget *widget = static_cast<const QWidget *>(target); |
|
5
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3388 |
if (!widget->testAttribute(Qt::WA_TranslucentBackground)) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3389 |
const QVector<QRect> &rects = rgn.rects(); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3390 |
for (int i = 0; i < rects.size(); ++i) { |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3391 |
const QRect rect(rects.at(i)); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3392 |
painter->drawPixmap(rect.topLeft(), backgroundTexture, |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3393 |
rect.translated(qt_s60_fill_background_offset(widget))); |
d3bac044e0f0
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
4
diff
changeset
|
3394 |
} |
0 | 3395 |
} |
3396 |
} |
|
3397 |
return true; |
|
3398 |
} |
|
3399 |
||
3400 |
QT_END_NAMESPACE |
|
3401 |
||
3402 |
#endif // QT_NO_STYLE_S60 || QT_PLUGIN |