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