|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtGui module of the Qt Toolkit. |
|
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 "qwindowscestyle.h" |
|
43 |
|
44 #if !defined(QT_NO_STYLE_WINDOWSCE) || defined(QT_PLUGIN) |
|
45 |
|
46 #include "qpainterpath.h" |
|
47 #include "qapplication.h" |
|
48 #include "qdockwidget.h" |
|
49 #include "qtoolbar.h" |
|
50 #include "qpaintengine.h" |
|
51 #include "qpainter.h" |
|
52 #include "qstyleoption.h" |
|
53 #include "qwindowscestyle_p.h" |
|
54 #include "qdebug.h" |
|
55 |
|
56 QT_BEGIN_NAMESPACE |
|
57 |
|
58 static const int windowsItemFrame = 2; // menu item frame width |
|
59 static const int windowsItemHMargin = 3; // menu item hor text margin |
|
60 static const int windowsItemVMargin = 2; // menu item ver text margin |
|
61 static const int windowsArrowHMargin = 6; // arrow horizontal margin |
|
62 static const int windowsRightBorder = 15; // right border on windows |
|
63 static const int windowsCheckMarkWidth = 14; // checkmarks width on windows |
|
64 |
|
65 static const int windowsCEitemViewCheckBoxSize = 14; |
|
66 static const int windowsCEFrameGroupBoxOffset = 9; |
|
67 static const int windowsCEIndicatorSize = 14; |
|
68 static const int windowsCEExclusiveIndicatorSize = 14; |
|
69 static const int windowsCESliderThickness = 24; |
|
70 static const int windowsCEIconSize = 16; |
|
71 |
|
72 static const QColor windowsCECheckBoxGradientColorBegin = QColor(222, 224, 214); |
|
73 static const QColor windowsCECheckBoxGradientColorEnd = QColor(255, 255, 255); |
|
74 |
|
75 enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight }; |
|
76 |
|
77 QWindowsCEStyle::QWindowsCEStyle() : QWindowsStyle() { |
|
78 qApp->setEffectEnabled(Qt::UI_FadeMenu, false); |
|
79 qApp->setEffectEnabled(Qt::UI_AnimateMenu, false); |
|
80 } |
|
81 |
|
82 void QWindowsCEStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, |
|
83 QPainter *painter, const QWidget *widget) const { |
|
84 |
|
85 bool doRestore = false; |
|
86 QRect rect = option->rect; |
|
87 |
|
88 switch (element) { |
|
89 case PE_PanelButtonTool: { |
|
90 if ( |
|
91 #ifndef QT_NO_TOOLBAR |
|
92 (widget && qobject_cast<QToolBar*>(widget->parentWidget())) || |
|
93 #endif |
|
94 #ifndef QT_NO_DOCKWIDGET |
|
95 (widget && widget->inherits("QDockWidgetTitleButton")) || |
|
96 #endif |
|
97 (option->state & (State_Sunken | State_On))) |
|
98 QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect.adjusted(0, 0, 0, 0), |
|
99 option->palette, option->state & (State_Sunken | State_On), |
|
100 &option->palette.button()); |
|
101 if (option->state & (State_On)){ |
|
102 QBrush fill = QBrush(option->palette.midlight().color(), Qt::Dense4Pattern); |
|
103 painter->fillRect(option->rect.adjusted(windowsItemFrame , windowsItemFrame , |
|
104 -windowsItemFrame , -windowsItemFrame ), fill); |
|
105 } |
|
106 break; } |
|
107 case PE_IndicatorButtonDropDown: |
|
108 QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect, option->palette, |
|
109 option->state & (State_Sunken | State_On), |
|
110 &option->palette.brush(QPalette::Button)); |
|
111 break; |
|
112 #ifndef QT_NO_TABBAR |
|
113 case PE_IndicatorTabTear: |
|
114 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) { |
|
115 bool rtl = tab->direction == Qt::RightToLeft; |
|
116 QRect rect = tab->rect; |
|
117 QPainterPath path; |
|
118 rect.setTop(rect.top() + ((tab->state & State_Selected) ? 1 : 3)); |
|
119 rect.setBottom(rect.bottom() - ((tab->state & State_Selected) ? 0 : 2)); |
|
120 path.moveTo(QPoint(rtl ? rect.right() : rect.left(), rect.top())); |
|
121 int count = 3; |
|
122 for(int jags = 1; jags <= count; ++jags, rtl = !rtl) |
|
123 path.lineTo(QPoint(rtl ? rect.left() : rect.right(), rect.top() + jags * rect.height()/count)); |
|
124 |
|
125 painter->setPen(QPen(tab->palette.light(), qreal(.8))); |
|
126 painter->setBrush(tab->palette.background()); |
|
127 painter->setRenderHint(QPainter::Antialiasing); |
|
128 painter->drawPath(path); |
|
129 } |
|
130 break; |
|
131 #endif //QT_NO_TABBAR |
|
132 #ifndef QT_NO_TOOLBAR |
|
133 case PE_IndicatorToolBarSeparator: |
|
134 //nothing to draw on WindowsCE |
|
135 break; |
|
136 case PE_IndicatorToolBarHandle: |
|
137 painter->save(); |
|
138 painter->translate(option->rect.x(), option->rect.y()); |
|
139 if (option->state & State_Horizontal) { |
|
140 int x = option->rect.width() / 2 - 4; |
|
141 if (QApplication::layoutDirection() == Qt::RightToLeft) |
|
142 x -= 2; |
|
143 if (option->rect.height() > 4) { |
|
144 QWindowsCEStylePrivate::drawWinCEButton(painter,x - 1, 0, 7, option->rect.height(), |
|
145 option->palette, false, 0); |
|
146 QWindowsCEStylePrivate::drawWinCEPanel(painter, x, 1, 3, option->rect.height() - 1, |
|
147 option->palette, false, 0); |
|
148 QWindowsCEStylePrivate::drawWinCEPanel(painter, x + 3, 1, 3, option->rect.height() - 1, |
|
149 option->palette, false, 0); |
|
150 painter->setPen(option->palette.button().color()); |
|
151 painter->drawLine(x + 4, 2, x + 4,option->rect.height() - 2); |
|
152 } |
|
153 } else { |
|
154 if (option->rect.width() > 4) { |
|
155 int y = option->rect.height() / 2 - 4; |
|
156 QWindowsCEStylePrivate::drawWinCEPanel(painter, 2, y, option->rect.width() - 2, 3, |
|
157 option->palette, false, 0); |
|
158 QWindowsCEStylePrivate::drawWinCEPanel(painter, 2, y + 3, option->rect.width() - 2, 3, |
|
159 option->palette, false, 0); |
|
160 } |
|
161 } |
|
162 painter->restore(); |
|
163 break; |
|
164 |
|
165 #endif // QT_NO_TOOLBAR |
|
166 case PE_FrameButtonTool: { |
|
167 #ifndef QT_NO_DOCKWIDGET |
|
168 if (widget && widget->inherits("QDockWidgetTitleButton")) { |
|
169 if (const QDockWidget *dw = qobject_cast<const QDockWidget *>(widget->parent())) |
|
170 if (dw->isFloating()){ |
|
171 QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect.adjusted(1, 1, 0, 0), |
|
172 option->palette, option->state & (State_Sunken | State_On), |
|
173 &option->palette.button()); |
|
174 return; |
|
175 } |
|
176 } |
|
177 #endif // QT_NO_DOCKWIDGET |
|
178 QBrush fill; |
|
179 bool stippled; |
|
180 bool panel = (element == PE_PanelButtonTool); |
|
181 if ((!(option->state & State_Sunken )) |
|
182 && (!(option->state & State_Enabled) |
|
183 || ((option->state & State_Enabled ) && !(option->state & State_MouseOver))) |
|
184 && (option->state & State_On)) { |
|
185 fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern); |
|
186 stippled = true; |
|
187 } else { |
|
188 fill = option->palette.brush(QPalette::Button); |
|
189 stippled = false; |
|
190 } |
|
191 if (option->state & (State_Raised | State_Sunken | State_On)) { |
|
192 if (option->state & State_AutoRaise) { |
|
193 if(option->state & (State_Enabled | State_Sunken | State_On)){ |
|
194 if (panel) |
|
195 QWindowsCEStylePrivate::drawWinCEPanel(painter, option->rect, option->palette, |
|
196 option->state & (State_Sunken | State_On), &fill); |
|
197 else |
|
198 qDrawShadeRect(painter, option->rect, option->palette, |
|
199 option->state & (State_Sunken | State_On), 1); |
|
200 } |
|
201 if (stippled) { |
|
202 painter->setPen(option->palette.button().color()); |
|
203 painter->drawRect(option->rect.adjusted(1, 1, -2, -2)); |
|
204 } |
|
205 } else { |
|
206 QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect, option->palette, |
|
207 option->state & (State_Sunken | State_On), panel ? &fill : 0); |
|
208 } |
|
209 } else { |
|
210 painter->fillRect(option->rect, fill); |
|
211 } |
|
212 break; } |
|
213 |
|
214 case PE_PanelButtonBevel: { |
|
215 QBrush fill; |
|
216 bool panel = element != PE_FrameButtonBevel; |
|
217 painter->setBrushOrigin(option->rect.topLeft()); |
|
218 if (!(option->state & State_Sunken) && (option->state & State_On)) |
|
219 fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern); |
|
220 else |
|
221 fill = option->palette.brush(QPalette::Button); |
|
222 |
|
223 if (option->state & (State_Raised | State_On | State_Sunken)) { |
|
224 QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect, option->palette, |
|
225 option->state & (State_Sunken | State_On), |
|
226 panel ? &fill : 0); ; |
|
227 } else { |
|
228 if (panel) |
|
229 painter->fillRect(option->rect, fill); |
|
230 else |
|
231 painter->drawRect(option->rect); |
|
232 } |
|
233 break; } |
|
234 |
|
235 case PE_FrameGroupBox: |
|
236 if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
|
237 QRect fr = frame->rect; |
|
238 painter->setPen(frame->palette.shadow().color()); |
|
239 painter->drawRect(fr.x(), fr.y(), fr.x() + fr.width() - 1, |
|
240 fr.y() + fr.height() - windowsCEFrameGroupBoxOffset); |
|
241 } |
|
242 break; |
|
243 |
|
244 case PE_IndicatorCheckBox: { |
|
245 QBrush fill; |
|
246 if (option->state & State_NoChange) |
|
247 fill = QBrush(option->palette.base().color(), Qt::Dense4Pattern); |
|
248 else if (option->state & State_Sunken) |
|
249 fill = option->palette.button(); |
|
250 else if (option->state & State_Enabled) |
|
251 fill = option->palette.base(); |
|
252 else |
|
253 fill = option->palette.background(); |
|
254 painter->save(); |
|
255 doRestore = true; |
|
256 painter->fillRect(option->rect,fill); |
|
257 painter->setPen(option->palette.dark().color()); |
|
258 painter->drawRect(option->rect); |
|
259 painter->setPen(option->palette.shadow().color()); |
|
260 painter->drawLine(option->rect.x() + 1,option->rect.y() + 1, |
|
261 option->rect.x() + option->rect.width() - 1, option->rect.y() + 1); |
|
262 painter->drawLine(option->rect.x() + 1,option->rect.y() + 1, |
|
263 option->rect.x() + 1, option->rect.y() + option->rect.height() - 1); |
|
264 //fall through... |
|
265 } |
|
266 case PE_IndicatorViewItemCheck: |
|
267 case PE_Q3CheckListIndicator: { |
|
268 if (!doRestore) { |
|
269 painter->save(); |
|
270 doRestore = true; |
|
271 } |
|
272 int arrowSize= 2; |
|
273 if (element == PE_Q3CheckListIndicator || element == PE_IndicatorViewItemCheck) { |
|
274 QLinearGradient linearGradient(QPoint(option->rect.x(),option->rect.y()), QPoint(option->rect.x()+option->rect.width(), |
|
275 option->rect.y()+option->rect.height())); |
|
276 linearGradient.setColorAt(0, windowsCECheckBoxGradientColorBegin); |
|
277 linearGradient.setColorAt(1, windowsCECheckBoxGradientColorEnd); |
|
278 painter->setBrush(linearGradient); |
|
279 painter->setPen(Qt::NoPen); |
|
280 if (option->state & State_NoChange) |
|
281 painter->setBrush(option->palette.brush(QPalette::Button)); |
|
282 painter->setPen(option->palette.link().color()); |
|
283 painter->drawRect(option->rect.x(), option->rect.y(), windowsCEitemViewCheckBoxSize, windowsCEitemViewCheckBoxSize); |
|
284 painter->setPen(option->palette.brightText().color()); |
|
285 arrowSize= 3; |
|
286 } |
|
287 if (!(option->state & State_Off)) { |
|
288 QLineF lines[9]; |
|
289 int i, xx, yy; |
|
290 xx = option->rect.x() + 4; |
|
291 yy = option->rect.y() + 6; |
|
292 for (i = 0; i < 4; ++i) { |
|
293 lines[i] = QLineF(xx, yy, xx, yy + arrowSize); |
|
294 ++xx; |
|
295 ++yy; |
|
296 } |
|
297 yy -= 2; |
|
298 for (i = 4; i < 9; ++i) { |
|
299 lines[i] = QLineF(xx, yy, xx, yy + arrowSize); |
|
300 ++xx; |
|
301 --yy; |
|
302 } |
|
303 painter->drawLines(lines, 9); |
|
304 } |
|
305 if (doRestore) |
|
306 painter->restore(); |
|
307 |
|
308 break; } |
|
309 case PE_IndicatorRadioButton: { |
|
310 QRect ir = option->rect; |
|
311 painter->save(); |
|
312 painter->setPen(Qt::NoPen); |
|
313 painter->setBrush(option->palette.light()); |
|
314 painter->drawEllipse(option->rect); |
|
315 painter->setPen(option->palette.shadow().color()); |
|
316 painter->setBrush(option->palette.shadow().color()); |
|
317 painter->drawArc(option->rect, 0, 360 * 16); |
|
318 painter->drawArc(option->rect.x() + 1, option->rect.y() + 1, option->rect.width() - 2, |
|
319 option->rect.height() - 2, 40 * 16, 180 * 16); |
|
320 painter->setPen(option->palette.light().color()); |
|
321 painter->drawPoint(option->rect.x() + 11, option->rect.y() + 3); |
|
322 painter->drawPoint(option->rect.x() + 3,option->rect.y() + 3); |
|
323 painter->setPen(option->palette.shadow().color()); |
|
324 painter->drawPoint(option->rect.x() +3,option->rect.y() + 12); |
|
325 if (option->state & (State_Sunken | State_On)) { |
|
326 painter->setPen(Qt::NoPen); |
|
327 painter->setBrush(option->palette.text()); |
|
328 painter->drawEllipse(option->rect.x() +3,option->rect.y()+ 2,9,10); |
|
329 } |
|
330 painter->restore(); |
|
331 break; } |
|
332 case PE_PanelMenuBar: |
|
333 painter->save(); |
|
334 painter->setPen(option->palette.shadow().color()); |
|
335 painter->drawRect(option->rect); |
|
336 painter->restore(); |
|
337 break; |
|
338 case PE_PanelButtonCommand: |
|
339 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
|
340 QBrush fill; |
|
341 State flags = option->state; |
|
342 QPalette pal = option->palette; |
|
343 QRect r = option->rect; |
|
344 if (! (flags & State_Sunken) && (flags & State_On)) |
|
345 fill = QBrush(pal.light().color(), Qt::Dense4Pattern); |
|
346 else |
|
347 fill = pal.brush(QPalette::Button); |
|
348 if (btn->features & QStyleOptionButton::DefaultButton && flags & State_Sunken) { |
|
349 painter->setPen(pal.dark().color()); |
|
350 painter->setBrush(fill); |
|
351 painter->drawRect(r.adjusted(0, 0, -1, -1)); |
|
352 } else if (flags & (State_Raised | State_Sunken | State_On | State_Sunken)) { |
|
353 QWindowsCEStylePrivate::drawWinCEButton(painter, r, pal, flags & (State_Sunken | State_On), |
|
354 &fill); |
|
355 } else { |
|
356 painter->fillRect(r, fill); |
|
357 } |
|
358 |
|
359 } |
|
360 break; |
|
361 case PE_FrameDefaultButton: { |
|
362 painter->setPen(option->palette.shadow().color()); |
|
363 QRect rect = option->rect; |
|
364 rect.adjust(0, 0, -1, -1); |
|
365 painter->drawRect(rect); |
|
366 break; } |
|
367 case PE_IndicatorSpinPlus: |
|
368 case PE_IndicatorSpinMinus: { |
|
369 QRect r = option->rect; |
|
370 int fw = pixelMetric(PM_DefaultFrameWidth, option, widget)+2; |
|
371 QRect br = r.adjusted(fw, fw, -fw, -fw); |
|
372 int offset = (option->state & State_Sunken) ? 1 : 0; |
|
373 int step = (br.width() + 4) / 5; |
|
374 painter->fillRect(br.x() + offset, br.y() + offset +br.height() / 2 - step / 2, |
|
375 br.width(), step, |
|
376 option->palette.buttonText()); |
|
377 if (element == PE_IndicatorSpinPlus) |
|
378 painter->fillRect(br.x() + br.width() / 2 - step / 2 + offset, br.y() + offset+4, |
|
379 step, br.height()-7, |
|
380 option->palette.buttonText()); |
|
381 break; } |
|
382 case PE_IndicatorSpinUp: |
|
383 case PE_IndicatorSpinDown: { |
|
384 painter->save(); |
|
385 QPoint points[7]; |
|
386 switch (element) { |
|
387 case PE_IndicatorSpinUp: |
|
388 points[0] = QPoint(-2, -4); |
|
389 points[1] = QPoint(-2, 2); |
|
390 points[2] = QPoint(-1, -3); |
|
391 points[3] = QPoint(-1, 1); |
|
392 points[4] = QPoint(0, -2); |
|
393 points[5] = QPoint(0, 0); |
|
394 points[6] = QPoint(1, -1); |
|
395 break; |
|
396 case PE_IndicatorSpinDown: |
|
397 points[0] = QPoint(0, -4); |
|
398 points[1] = QPoint(0, 2); |
|
399 points[2] = QPoint(-1, -3); |
|
400 points[3] = QPoint(-1, 1); |
|
401 points[4] = QPoint(-2, -2); |
|
402 points[5] = QPoint(-2, 0); |
|
403 points[6] = QPoint(-3, -1); |
|
404 break; |
|
405 default: |
|
406 break; |
|
407 } |
|
408 if (option->state & State_Sunken) |
|
409 painter->translate(pixelMetric(PM_ButtonShiftHorizontal), |
|
410 pixelMetric(PM_ButtonShiftVertical)); |
|
411 if (option->state & State_Enabled) { |
|
412 painter->translate(option->rect.x() + option->rect.width() / 2, |
|
413 option->rect.y() + option->rect.height() / 2); |
|
414 painter->setPen(option->palette.buttonText().color()); |
|
415 painter->drawLine(points[0], points[1]); |
|
416 painter->drawLine(points[2], points[3]); |
|
417 painter->drawLine(points[4], points[5]); |
|
418 painter->drawPoint(points[6]); |
|
419 } else { |
|
420 painter->translate(option->rect.x() + option->rect.width() / 2 + 1, |
|
421 option->rect.y() + option->rect.height() / 2 + 1); |
|
422 painter->setPen(option->palette.light().color()); |
|
423 painter->drawLine(points[0], points[1]); |
|
424 painter->drawLine(points[2], points[3]); |
|
425 painter->drawLine(points[4], points[5]); |
|
426 painter->drawPoint(points[6]); |
|
427 painter->translate(-1, -1); |
|
428 painter->setPen(option->palette.mid().color()); |
|
429 painter->drawLine(points[0], points[1]); |
|
430 painter->drawLine(points[2], points[3]); |
|
431 painter->drawLine(points[4], points[5]); |
|
432 painter->drawPoint(points[6]); |
|
433 } |
|
434 |
|
435 painter->restore(); |
|
436 break; } |
|
437 case PE_IndicatorArrowUp: |
|
438 case PE_IndicatorArrowDown: |
|
439 case PE_IndicatorArrowRight: |
|
440 case PE_IndicatorArrowLeft: { |
|
441 painter->save(); |
|
442 QPoint points[9]; |
|
443 switch (element) { |
|
444 case PE_IndicatorArrowUp: |
|
445 |
|
446 points[0] = QPoint(-4, 2); |
|
447 points[1] = QPoint(4, 2); |
|
448 points[2] = QPoint(-3, 1); |
|
449 points[3] = QPoint(3, 1); |
|
450 points[4] = QPoint(-2, 0); |
|
451 points[5] = QPoint(2, 0); |
|
452 points[6] = QPoint(-1, -1); |
|
453 points[7] = QPoint(1, -1); |
|
454 points[8] = QPoint(0, -2); |
|
455 break; |
|
456 case PE_IndicatorArrowDown: |
|
457 |
|
458 points[0] = QPoint(-4, -2); |
|
459 points[1] = QPoint(4, -2); |
|
460 points[2] = QPoint(-3, -1); |
|
461 points[3] = QPoint(3, -1); |
|
462 points[4] = QPoint(-2, 0); |
|
463 points[5] = QPoint(2, 0); |
|
464 points[6] = QPoint(-1, 1); |
|
465 points[7] = QPoint(1, 1); |
|
466 points[8] = QPoint(0, 2); |
|
467 break; |
|
468 case PE_IndicatorArrowRight: |
|
469 points[0] = QPoint(-3, -4); |
|
470 points[1] = QPoint(-3, 4); |
|
471 points[2] = QPoint(-2, -3); |
|
472 points[3] = QPoint(-2, 3); |
|
473 points[4] = QPoint(-1, -2); |
|
474 points[5] = QPoint(-1, 2); |
|
475 points[6] = QPoint(0, -1); |
|
476 points[7] = QPoint(0, 1); |
|
477 points[8] = QPoint(1, 0); |
|
478 break; |
|
479 case PE_IndicatorArrowLeft: |
|
480 points[0] = QPoint(1, -4); |
|
481 points[1] = QPoint(1, 4); |
|
482 points[2] = QPoint(0, -3); |
|
483 points[3] = QPoint(0, 3); |
|
484 points[4] = QPoint(-1, -2); |
|
485 points[5] = QPoint(-1, 2); |
|
486 points[6] = QPoint(-2, -1); |
|
487 points[7] = QPoint(-2, 1); |
|
488 points[8] = QPoint(-3, 0); |
|
489 break; |
|
490 default: |
|
491 break; |
|
492 } |
|
493 if (option->state & State_Sunken) |
|
494 painter->translate(pixelMetric(PM_ButtonShiftHorizontal), |
|
495 pixelMetric(PM_ButtonShiftVertical)); |
|
496 if (option->state & State_Enabled) { |
|
497 painter->translate(option->rect.x() + option->rect.width() / 2, |
|
498 option->rect.y() + option->rect.height() / 2); |
|
499 painter->setPen(option->palette.buttonText().color()); |
|
500 painter->drawLine(points[0], points[1]); |
|
501 painter->drawLine(points[2], points[3]); |
|
502 painter->drawLine(points[4], points[5]); |
|
503 painter->drawLine(points[6], points[7]); |
|
504 painter->drawPoint(points[8]); |
|
505 } else { |
|
506 painter->translate(option->rect.x() + option->rect.width() / 2 + 1, |
|
507 option->rect.y() + option->rect.height() / 2 + 1); |
|
508 painter->setPen(option->palette.light().color()); |
|
509 painter->drawLine(points[0], points[1]); |
|
510 painter->drawLine(points[2], points[3]); |
|
511 painter->drawLine(points[4], points[5]); |
|
512 painter->drawLine(points[6], points[7]); |
|
513 painter->drawPoint(points[8]); |
|
514 painter->translate(-1, -1); |
|
515 painter->setPen(option->palette.mid().color()); |
|
516 painter->drawLine(points[0], points[1]); |
|
517 painter->drawLine(points[2], points[3]); |
|
518 painter->drawLine(points[4], points[5]); |
|
519 painter->drawLine(points[6], points[7]); |
|
520 painter->drawPoint(points[8]); |
|
521 } |
|
522 painter->restore(); |
|
523 break; } |
|
524 |
|
525 case PE_FrameWindow: { |
|
526 QPalette popupPal = option->palette; |
|
527 popupPal.setColor(QPalette::Light, option->palette.background().color()); |
|
528 popupPal.setColor(QPalette::Midlight, option->palette.light().color()); |
|
529 QWindowsCEStylePrivate::drawWinCEPanel(painter, option->rect, popupPal, option->state & State_Sunken); |
|
530 break; } |
|
531 |
|
532 case PE_Frame: |
|
533 case PE_FrameMenu: |
|
534 if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option)) { |
|
535 QPalette popupPal = frame->palette; |
|
536 QRect r = frame->rect; |
|
537 qDrawPlainRect(painter, r, frame->palette.shadow().color(),1); |
|
538 } |
|
539 break; |
|
540 case PE_FrameStatusBar: |
|
541 QWindowsCEStylePrivate::drawWinCEPanel(painter, option->rect, option->palette, true, 0); |
|
542 break; |
|
543 |
|
544 case PE_FrameTabWidget: { |
|
545 QRect rect = option->rect; |
|
546 QPalette pal = option->palette; |
|
547 QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect, option->palette, false, 0); |
|
548 break; } |
|
549 default: |
|
550 QWindowsStyle::drawPrimitive(element, option, painter, widget); |
|
551 break; |
|
552 } |
|
553 } |
|
554 |
|
555 void QWindowsCEStyle::drawControl(ControlElement element, const QStyleOption *option, |
|
556 QPainter *painter, const QWidget *widget) const { |
|
557 switch (element) { |
|
558 #ifndef QT_NO_MENU |
|
559 case CE_MenuTearoff: { |
|
560 if(option->state & State_Selected) { |
|
561 if(pixelMetric(PM_MenuPanelWidth, option, widget) > 1) |
|
562 qDrawShadePanel(painter, option->rect.x(), option->rect.y(), option->rect.width(), |
|
563 option->rect.height(), option->palette, false, 2, |
|
564 &option->palette.brush(QPalette::Button)); |
|
565 else |
|
566 qDrawShadePanel(painter, option->rect.x() + 1, option->rect.y() + 1, option->rect.width() - 2, |
|
567 option->rect.height() - 2, option->palette, true, 1, &option->palette.brush(QPalette::Button)); |
|
568 } else { |
|
569 painter->fillRect(option->rect, option->palette.brush(QPalette::Button)); |
|
570 } |
|
571 painter->setPen(QPen(option->palette.dark().color(), 1, Qt::DashLine)); |
|
572 painter->drawLine(option->rect.x()+2, option->rect.y()+option->rect.height()/2-1, option->rect.x()+option->rect.width()-4, |
|
573 option->rect.y()+option->rect.height()/2-1); |
|
574 painter->setPen(QPen(option->palette.light().color(), 1, Qt::DashLine)); |
|
575 painter->drawLine(option->rect.x()+2, option->rect.y()+option->rect.height()/2, option->rect.x()+option->rect.width()-4, |
|
576 option->rect.y()+option->rect.height()/2); |
|
577 break; } |
|
578 |
|
579 |
|
580 case CE_MenuBarItem: |
|
581 if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { |
|
582 bool active = mbi->state & State_Selected; |
|
583 bool hasFocus = mbi->state & State_HasFocus; |
|
584 bool down = mbi->state & State_Sunken; |
|
585 QStyleOptionMenuItem newMbi = *mbi; |
|
586 if (active || hasFocus) { |
|
587 QBrush b = mbi->palette.brush(QPalette::Highlight); |
|
588 if (active && down) { |
|
589 painter->fillRect(mbi->rect.adjusted(0, 1, 0, -1), b); |
|
590 } |
|
591 } |
|
592 uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip |
|
593 | Qt::TextSingleLine; |
|
594 if (!styleHint(SH_UnderlineShortcut, mbi, widget)) |
|
595 alignment |= Qt::TextHideMnemonic; |
|
596 |
|
597 painter->save(); |
|
598 QFont f = painter->font(); |
|
599 f.setBold(true); |
|
600 painter->setFont(f); |
|
601 QPixmap pix = mbi->icon.pixmap(pixelMetric(PM_SmallIconSize), |
|
602 (mbi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); |
|
603 if (!pix.isNull()) |
|
604 drawItemPixmap(painter,mbi->rect, alignment, pix); |
|
605 else |
|
606 if (active && down) |
|
607 drawItemText(painter, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled, |
|
608 mbi->text, QPalette::Light); |
|
609 else |
|
610 drawItemText(painter, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled, |
|
611 mbi->text, QPalette::ButtonText); |
|
612 painter->restore(); |
|
613 } |
|
614 break; |
|
615 |
|
616 case CE_MenuBarEmptyArea: |
|
617 painter->save(); |
|
618 painter->setPen(option->palette.shadow().color()); |
|
619 if (widget && !widget->testAttribute(Qt::WA_NoSystemBackground)) { |
|
620 painter->eraseRect(option->rect); |
|
621 QRect r = option->rect; |
|
622 painter->drawLine(r.x() + 1, r.y() + 1, r.x()+ 1, r.y()+ r.height() - 2); |
|
623 painter->drawLine(r.x() - 2 + r.width(), r.y() + 1, r.x() - 2 + r.width(), r.y() + r.height() - 2); |
|
624 painter->drawLine(r.x() + 1, r.y() +1, r.x() - 1 + r.width(), r.y() + 1); |
|
625 painter->drawLine(r.x() + 1, r.y() + r.height()-2 , r.x() - 2 + r.width(), r.y() + r.height() - 2); |
|
626 } |
|
627 painter->restore(); |
|
628 break; |
|
629 |
|
630 case CE_MenuItem: |
|
631 if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { |
|
632 int x, y, w, h; |
|
633 menuitem->rect.getRect(&x, &y, &w, &h); |
|
634 int tab = menuitem->tabWidth; |
|
635 bool dis = !(menuitem->state & State_Enabled); |
|
636 bool checked = menuitem->checkType != QStyleOptionMenuItem::NotCheckable |
|
637 ? menuitem->checked : false; |
|
638 bool act = menuitem->state & State_Selected; |
|
639 |
|
640 // windows always has a check column, regardless whether we have an icon or not |
|
641 int checkcol = qMax(menuitem->maxIconWidth, windowsCheckMarkWidth); |
|
642 QBrush fill = menuitem->palette.brush(act ? QPalette::Highlight : QPalette::Button); |
|
643 painter->fillRect(menuitem->rect.adjusted(1, 1, 0, 0), fill); |
|
644 |
|
645 if (menuitem->menuItemType == QStyleOptionMenuItem::Separator) { |
|
646 int yoff = y-1 + h / 2; |
|
647 painter->setPen(menuitem->palette.shadow().color()); |
|
648 painter->drawLine(x + 4, yoff + 1, x + w - 8, yoff + 1); |
|
649 return; |
|
650 } |
|
651 |
|
652 QRect vCheckRect = visualRect(option->direction, menuitem->rect, QRect(menuitem->rect.x(), |
|
653 menuitem->rect.y(), checkcol, menuitem->rect.height())); |
|
654 if (checked) { |
|
655 if (act && !dis) { |
|
656 qDrawPlainRect(painter, vCheckRect, |
|
657 menuitem->palette.button().color(), 1, |
|
658 &menuitem->palette.brush(QPalette::Button)); |
|
659 } else { |
|
660 QBrush fill(menuitem->palette.button().color(), Qt::Dense4Pattern); |
|
661 qDrawPlainRect(painter, vCheckRect,menuitem->palette.button().color(), 1, &fill); |
|
662 } |
|
663 } else if (!act) { |
|
664 painter->fillRect(vCheckRect, menuitem->palette.brush(QPalette::Button)); |
|
665 } |
|
666 // On Windows Style, if we have a checkable item and an icon we |
|
667 // draw the icon recessed to indicate an item is checked. If we |
|
668 // have no icon, we draw a checkmark instead. |
|
669 if (!menuitem->icon.isNull()) { |
|
670 QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal; |
|
671 if (act && !dis) |
|
672 mode = QIcon::Active; |
|
673 QPixmap pixmap; |
|
674 if (checked) |
|
675 pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize), mode, QIcon::On); |
|
676 else |
|
677 pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize), mode); |
|
678 int pixw = pixmap.width(); |
|
679 int pixh = pixmap.height(); |
|
680 if (act && !dis && !checked) |
|
681 qDrawPlainRect(painter, vCheckRect, menuitem->palette.button().color(), 1, |
|
682 &menuitem->palette.brush(QPalette::Button)); |
|
683 QRect pmr(0, 0, pixw, pixh); |
|
684 pmr.moveCenter(vCheckRect.center()); |
|
685 painter->setPen(menuitem->palette.text().color()); |
|
686 painter->drawPixmap(pmr.topLeft(), pixmap); |
|
687 } else if (checked) { |
|
688 QStyleOptionMenuItem newMi = *menuitem; |
|
689 newMi.state = State_None; |
|
690 if (!dis) |
|
691 newMi.state |= State_Enabled; |
|
692 if (act) |
|
693 newMi.state |= State_On; |
|
694 newMi.rect = visualRect(option->direction, menuitem->rect, QRect(menuitem->rect.x() |
|
695 + windowsItemFrame, menuitem->rect.y() + windowsItemFrame, |
|
696 checkcol - 2 * windowsItemFrame, menuitem->rect.height() - 2*windowsItemFrame)); |
|
697 drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, painter, widget); |
|
698 } |
|
699 painter->setPen(act ? menuitem->palette.highlightedText().color() : menuitem->palette.buttonText().color()); |
|
700 |
|
701 QColor discol; |
|
702 if (dis) { |
|
703 discol = menuitem->palette.text().color(); |
|
704 painter->setPen(discol); |
|
705 } |
|
706 int xm = windowsItemFrame + checkcol + windowsItemHMargin; |
|
707 int xpos = menuitem->rect.x() + xm; |
|
708 QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin); |
|
709 QRect vTextRect = visualRect(option->direction, menuitem->rect, textRect); |
|
710 QString s = menuitem->text; |
|
711 if (!s.isEmpty()) { // draw text |
|
712 painter->save(); |
|
713 int t = s.indexOf(QLatin1Char('\t')); |
|
714 int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; |
|
715 if (!styleHint(SH_UnderlineShortcut, menuitem, widget)) |
|
716 text_flags |= Qt::TextHideMnemonic; |
|
717 text_flags |= Qt::AlignLeft; |
|
718 if (t >= 0) { |
|
719 QRect vShortcutRect = visualRect(option->direction, menuitem->rect, |
|
720 QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom()))); |
|
721 if (dis && !act) |
|
722 painter->setPen(discol); |
|
723 painter->drawText(vShortcutRect, text_flags, s.mid(t + 1)); |
|
724 s = s.left(t); |
|
725 } |
|
726 QFont font = menuitem->font; |
|
727 if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem) |
|
728 font.setBold(true); |
|
729 painter->setFont(font); |
|
730 if (dis && !act) |
|
731 painter->setPen(discol); |
|
732 painter->drawText(vTextRect, text_flags, s.left(t)); |
|
733 painter->restore(); |
|
734 } |
|
735 if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow |
|
736 int dim = (h - 2 * windowsItemFrame) / 2; |
|
737 PrimitiveElement arrow; |
|
738 arrow = (option->direction == Qt::RightToLeft) ? PE_IndicatorSpinDown : PE_IndicatorSpinUp; |
|
739 xpos = x + w - windowsArrowHMargin - windowsItemFrame - dim; |
|
740 QRect vSubMenuRect = visualRect(option->direction, menuitem->rect, QRect(xpos, y + h / 2 - dim / 2, dim, dim)); |
|
741 QStyleOptionMenuItem newMI = *menuitem; |
|
742 newMI.rect = vSubMenuRect; |
|
743 newMI.state = dis ? State_None : State_Enabled; |
|
744 if (act) |
|
745 newMI.palette.setColor(QPalette::ButtonText, |
|
746 newMI.palette.highlightedText().color()); |
|
747 drawPrimitive(arrow, &newMI, painter, widget); |
|
748 } |
|
749 } |
|
750 break; |
|
751 #endif // QT_NO_MENU |
|
752 case CE_MenuVMargin: |
|
753 painter->fillRect(option->rect, Qt::white); |
|
754 break; |
|
755 case CE_MenuEmptyArea: |
|
756 QWindowsStyle::drawControl(element,option, painter, widget); |
|
757 break; |
|
758 |
|
759 #ifndef QT_NO_TABBAR |
|
760 case CE_TabBarTab: |
|
761 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) { |
|
762 drawControl(CE_TabBarTabShape, tab, painter, widget); |
|
763 drawControl(CE_TabBarTabLabel, tab, painter, widget); |
|
764 } |
|
765 break; |
|
766 case CE_TabBarTabShape: |
|
767 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) { |
|
768 bool rtlHorTabs = (tab->direction == Qt::RightToLeft |
|
769 && (tab->shape == QTabBar::RoundedNorth |
|
770 || tab->shape == QTabBar::RoundedSouth)); |
|
771 bool selected = tab->state & State_Selected; |
|
772 bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End) |
|
773 || (rtlHorTabs |
|
774 && tab->position == QStyleOptionTab::Beginning)); |
|
775 bool firstTab = ((!rtlHorTabs |
|
776 && tab->position == QStyleOptionTab::Beginning) |
|
777 || (rtlHorTabs |
|
778 && tab->position == QStyleOptionTab::End)); |
|
779 bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab; |
|
780 bool previousSelected = |
|
781 ((!rtlHorTabs |
|
782 && tab->selectedPosition == QStyleOptionTab::PreviousIsSelected) |
|
783 || (rtlHorTabs |
|
784 && tab->selectedPosition == QStyleOptionTab::NextIsSelected)); |
|
785 bool nextSelected = |
|
786 ((!rtlHorTabs |
|
787 && tab->selectedPosition == QStyleOptionTab::NextIsSelected) |
|
788 || (rtlHorTabs |
|
789 && tab->selectedPosition |
|
790 == QStyleOptionTab::PreviousIsSelected)); |
|
791 int tabBarAlignment = styleHint(SH_TabBar_Alignment, tab, widget); |
|
792 bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft) |
|
793 || (rtlHorTabs |
|
794 && tabBarAlignment == Qt::AlignRight); |
|
795 |
|
796 bool rightAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignRight) |
|
797 || (rtlHorTabs |
|
798 && tabBarAlignment == Qt::AlignLeft); |
|
799 QColor light = tab->palette.light().color(); |
|
800 QColor midlight = tab->palette.midlight().color(); |
|
801 QColor dark = tab->palette.dark().color(); |
|
802 QColor shadow = tab->palette.shadow().color(); |
|
803 QColor background = tab->palette.background().color(); |
|
804 int borderThinkness = pixelMetric(PM_TabBarBaseOverlap, tab, widget); |
|
805 if (selected) |
|
806 borderThinkness /= 2; |
|
807 QRect r2(option->rect); |
|
808 int x1 = r2.left(); |
|
809 int x2 = r2.right(); |
|
810 int y1 = r2.top(); |
|
811 int y2 = r2.bottom(); |
|
812 switch (tab->shape) { |
|
813 default: |
|
814 QCommonStyle::drawControl(element, tab, painter, widget); |
|
815 break; |
|
816 case QTabBar::RoundedNorth: { |
|
817 if (!selected) { |
|
818 y1 += 2; |
|
819 x1 += firstTab ? borderThinkness : 0; |
|
820 x2 -= lastTab ? borderThinkness : 0; |
|
821 } |
|
822 |
|
823 painter->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 2), tab->palette.background()); |
|
824 |
|
825 // Delete border |
|
826 if (selected) { |
|
827 painter->setPen(background); |
|
828 painter->drawLine(x1, y2 - 1, x2, y2 - 1); |
|
829 painter->drawLine(x1, y2 + 1, x2, y2 + 1); |
|
830 painter->drawLine(x1, y2, x2, y2); |
|
831 } |
|
832 // Left |
|
833 if (firstTab || selected || onlyOne || !previousSelected) { |
|
834 painter->setPen(dark); |
|
835 painter->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness)); |
|
836 painter->drawPoint(x1 + 1, y1 + 1); |
|
837 painter->setPen(midlight); |
|
838 painter->drawLine(x1 + 1, y1 + 2, x1 + 1, y2 - |
|
839 ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness)); |
|
840 |
|
841 } |
|
842 // Top |
|
843 { |
|
844 int beg = x1 + (previousSelected ? 0 : 2); |
|
845 int end = x2 - (nextSelected ? 0 : 2); |
|
846 painter->setPen(dark); |
|
847 painter->drawLine(beg, y1, end, y1); |
|
848 |
|
849 painter->setPen(midlight); |
|
850 painter->drawLine(beg, y1 + 1, end, y1 + 1); |
|
851 |
|
852 } |
|
853 // Right |
|
854 if (lastTab || selected || onlyOne || !nextSelected) { |
|
855 painter->setPen(shadow); |
|
856 painter->drawLine(x2, y1 + 2, x2, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness)); |
|
857 painter->drawPoint(x2 - 1, y1 + 1); |
|
858 painter->setPen(dark); |
|
859 painter->drawLine(x2 - 1, y1 + 2, x2 - 1, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness)); |
|
860 } |
|
861 break; } |
|
862 case QTabBar::RoundedSouth: { |
|
863 if (!selected) { |
|
864 y2 -= 2; |
|
865 x1 += firstTab ? borderThinkness : 0; |
|
866 x2 -= lastTab ? borderThinkness : 0; |
|
867 } |
|
868 |
|
869 painter->fillRect(QRect(x1 + 1, y1 + 2, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.background()); |
|
870 |
|
871 // Delete border |
|
872 if (selected) { |
|
873 painter->setPen(background); |
|
874 painter->drawLine(x1, y1 + 1, x2 - 1, y1 + 1); |
|
875 painter->drawLine(x1, y1 - 1, x2 - 1, y1 - 1); |
|
876 painter->drawLine(x1, y1, x2 - 1, y1); |
|
877 } |
|
878 // Left |
|
879 if (firstTab || selected || onlyOne || !previousSelected) { |
|
880 painter->setPen(dark); |
|
881 painter->drawLine(x1, y2 - 2, x1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness)); |
|
882 painter->drawPoint(x1 + 1, y2 - 1); |
|
883 painter->setPen(midlight); |
|
884 painter->drawLine(x1 + 1, y2 - 2, x1 + 1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness)); |
|
885 } |
|
886 // Bottom |
|
887 { |
|
888 int beg = x1 + (previousSelected ? 0 : 2); |
|
889 int end = x2 - (nextSelected ? 0 : 2); |
|
890 painter->setPen(shadow); |
|
891 painter->drawLine(beg, y2, end, y2); |
|
892 painter->setPen(dark); |
|
893 painter->drawLine(beg, y2 - 1, end, y2 - 1); |
|
894 } |
|
895 // Right |
|
896 if (lastTab || selected || onlyOne || !nextSelected) { |
|
897 painter->setPen(shadow); |
|
898 painter->drawLine(x2, y2 - 2, x2, y1 + ((onlyOne || lastTab) && selected && |
|
899 rightAligned ? 0 : borderThinkness)); |
|
900 painter->drawPoint(x2 - 1, y2 - 1); |
|
901 painter->setPen(dark); |
|
902 painter->drawLine(x2 - 1, y2 - 2, x2 - 1, y1 + ((onlyOne || lastTab) && selected && |
|
903 rightAligned ? 0 : borderThinkness)); |
|
904 } |
|
905 break; } |
|
906 case QTabBar::RoundedWest: { |
|
907 if (!selected) { |
|
908 x1 += 2; |
|
909 y1 += firstTab ? borderThinkness : 0; |
|
910 y2 -= lastTab ? borderThinkness : 0; |
|
911 } |
|
912 |
|
913 painter->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 2, (y2 - y1) - 1), tab->palette.background()); |
|
914 |
|
915 // Delete border |
|
916 if (selected) { |
|
917 painter->setPen(background); |
|
918 painter->drawLine(x2 - 1, y1, x2 - 1, y2); |
|
919 painter->drawLine(x2, y1, x2, y2); |
|
920 } |
|
921 // Top |
|
922 if (firstTab || selected || onlyOne || !previousSelected) { |
|
923 painter->setPen(dark); |
|
924 painter->drawLine(x1 + 2, y1, x2 - ((onlyOne || firstTab) && selected && |
|
925 leftAligned ? 0 : borderThinkness), y1); |
|
926 painter->drawPoint(x1 + 1, y1 + 1); |
|
927 painter->setPen(midlight); |
|
928 painter->drawLine(x1 + 2, y1 + 1, x2 - ((onlyOne || firstTab) && selected && |
|
929 leftAligned ? 0 : borderThinkness), y1 + 1); |
|
930 } |
|
931 // Left |
|
932 { |
|
933 int beg = y1 + (previousSelected ? 0 : 2); |
|
934 int end = y2 - (nextSelected ? 0 : 2); |
|
935 painter->setPen(dark); |
|
936 painter->drawLine(x1, beg, x1, end); |
|
937 painter->setPen(midlight); |
|
938 painter->drawLine(x1 + 1, beg, x1 + 1, end); |
|
939 } |
|
940 // Bottom |
|
941 if (lastTab || selected || onlyOne || !nextSelected) { |
|
942 painter->setPen(shadow); |
|
943 painter->drawLine(x1 + 3, y2, x2 - ((onlyOne || lastTab) && selected && |
|
944 rightAligned ? 0 : borderThinkness), y2); |
|
945 painter->drawPoint(x1 + 2, y2 - 1); |
|
946 painter->setPen(dark); |
|
947 painter->drawLine(x1 + 3, y2 - 1, x2 - ((onlyOne || lastTab) && selected && |
|
948 rightAligned ? 0 : borderThinkness), y2 - 1); |
|
949 painter->drawPoint(x1 + 1, y2 - 1); |
|
950 painter->drawPoint(x1 + 2, y2); |
|
951 } |
|
952 break; } |
|
953 case QTabBar::RoundedEast: { |
|
954 if (!selected) { |
|
955 x2 -= 2; |
|
956 y1 += firstTab ? borderThinkness : 0; |
|
957 y2 -= lastTab ? borderThinkness : 0; |
|
958 } |
|
959 |
|
960 painter->fillRect(QRect(x1 + 2, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.background()); |
|
961 |
|
962 // Delete border |
|
963 if (selected) { |
|
964 painter->setPen(background); |
|
965 painter->drawLine(x1 + 1, y1, x1 + 1, y2 - 1); |
|
966 painter->drawLine(x1, y1, x1, y2 - 1); |
|
967 } |
|
968 // Top |
|
969 if (firstTab || selected || onlyOne || !previousSelected) { |
|
970 painter->setPen(dark); |
|
971 painter->drawLine(x2 - 2, y1, x1 + ((onlyOne || firstTab) && selected && |
|
972 leftAligned ? 0 : borderThinkness), y1); |
|
973 painter->drawPoint(x2 - 1, y1 + 1); |
|
974 painter->setPen(midlight); |
|
975 painter->drawLine(x2 - 3, y1 + 1, x1 + ((onlyOne || firstTab) && |
|
976 selected && leftAligned ? 0 : borderThinkness), y1 + 1); |
|
977 painter->drawPoint(x2 - 1, y1); |
|
978 |
|
979 } |
|
980 // Right |
|
981 { |
|
982 int beg = y1 + (previousSelected ? 0 : 2); |
|
983 int end = y2 - (nextSelected ? 0 : 2); |
|
984 painter->setPen(shadow); |
|
985 painter->drawLine(x2, beg, x2, end); |
|
986 painter->setPen(dark); |
|
987 painter->drawLine(x2 - 1, beg, x2 - 1, end); |
|
988 } |
|
989 // Bottom |
|
990 if (lastTab || selected || onlyOne || !nextSelected) { |
|
991 painter->setPen(shadow); |
|
992 painter->drawLine(x2 - 2, y2, x1 + ((onlyOne || lastTab) && |
|
993 selected && rightAligned ? 0 : borderThinkness), y2); |
|
994 painter->drawPoint(x2 - 1, y2 - 1); |
|
995 painter->setPen(dark); |
|
996 painter->drawLine(x2 - 2, y2 - 1, x1 + ((onlyOne || lastTab) && |
|
997 selected && rightAligned ? 0 : borderThinkness), y2 - 1); |
|
998 } |
|
999 break; } |
|
1000 } |
|
1001 } |
|
1002 break; |
|
1003 #endif // QT_NO_TABBAR |
|
1004 |
|
1005 case CE_ToolBar: { |
|
1006 QRect rect = option->rect; |
|
1007 painter->setPen(QPen(option->palette.dark().color())); |
|
1008 painter->drawLine(rect.topRight().x()-1, |
|
1009 rect.topRight().y(), |
|
1010 rect.bottomRight().x()-1, |
|
1011 rect.bottomRight().y()); |
|
1012 painter->drawLine(rect.bottomLeft().x(), |
|
1013 rect.bottomLeft().y(), |
|
1014 rect.bottomRight().x(), |
|
1015 rect.bottomRight().y()); |
|
1016 painter->setPen(QPen(option->palette.light().color())); |
|
1017 painter->drawLine(rect.topRight().x(), |
|
1018 rect.topRight().y(), |
|
1019 rect.bottomRight().x(), |
|
1020 rect.bottomRight().y()); |
|
1021 painter->drawLine(rect.topLeft().x(), |
|
1022 rect.topLeft().y(), |
|
1023 rect.topRight().x(), |
|
1024 rect.topRight().y()); |
|
1025 |
|
1026 break; } |
|
1027 #ifndef QT_NO_SCROLLBAR |
|
1028 case CE_ScrollBarSubLine: |
|
1029 case CE_ScrollBarAddLine: { |
|
1030 if (option->state & State_Sunken) { |
|
1031 QStyleOption buttonOpt = *option; |
|
1032 |
|
1033 drawPrimitive(PE_PanelButtonBevel, &buttonOpt, painter, widget); |
|
1034 } else { |
|
1035 QStyleOption buttonOpt = *option; |
|
1036 if (!(buttonOpt.state & State_Sunken)) |
|
1037 buttonOpt.state |= State_Raised; |
|
1038 drawPrimitive(PE_PanelButtonBevel, &buttonOpt, painter, widget); |
|
1039 } |
|
1040 PrimitiveElement arrow; |
|
1041 if (option->state & State_Horizontal) { |
|
1042 if (element == CE_ScrollBarAddLine) |
|
1043 arrow = option->direction == Qt::LeftToRight ? PE_IndicatorArrowRight : PE_IndicatorArrowLeft; |
|
1044 else |
|
1045 arrow = option->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight; |
|
1046 } else { |
|
1047 if (element == CE_ScrollBarAddLine) |
|
1048 arrow = PE_IndicatorArrowDown; |
|
1049 else |
|
1050 arrow = PE_IndicatorArrowUp; |
|
1051 } |
|
1052 drawPrimitive(arrow, option, painter, widget); |
|
1053 break; } |
|
1054 case CE_ScrollBarAddPage: |
|
1055 case CE_ScrollBarSubPage: { |
|
1056 QBrush br; |
|
1057 QBrush bg = painter->background(); |
|
1058 Qt::BGMode bg_mode = painter->backgroundMode(); |
|
1059 painter->setPen(Qt::NoPen); |
|
1060 painter->setBackgroundMode(Qt::OpaqueMode); |
|
1061 |
|
1062 if (option->state & State_Sunken) { |
|
1063 br = QBrush(option->palette.shadow().color(), Qt::Dense4Pattern); |
|
1064 painter->setBackground(option->palette.dark().color()); |
|
1065 painter->setBrush(br); |
|
1066 } else { |
|
1067 QPixmap pm = option->palette.brush(QPalette::Light).texture(); |
|
1068 if (option->state & State_Enabled) |
|
1069 br = !pm.isNull() ? QBrush(pm) : QBrush(option->palette.button().color(), Qt::Dense4Pattern); |
|
1070 else |
|
1071 br = !pm.isNull() ? QBrush(pm) : QBrush(option->palette.light().color(), Qt::Dense4Pattern); |
|
1072 painter->setBackground(option->palette.base().color()); |
|
1073 painter->setBrush(br); |
|
1074 } |
|
1075 painter->drawRect(option->rect); |
|
1076 painter->setBackground(bg); |
|
1077 painter->setBackgroundMode(bg_mode); |
|
1078 break; } |
|
1079 case CE_ScrollBarSlider: |
|
1080 if (!(option->state & State_Enabled)) { |
|
1081 QStyleOptionButton buttonOpt; |
|
1082 buttonOpt.QStyleOption::operator=(*option); |
|
1083 buttonOpt.state = State_Enabled | State_Raised; |
|
1084 drawPrimitive(PE_PanelButtonBevel, &buttonOpt, painter, widget); |
|
1085 QPixmap pm = option->palette.brush(QPalette::Light).texture(); |
|
1086 QBrush br = !pm.isNull() ? QBrush(pm) : QBrush(option->palette.light().color(), Qt::Dense4Pattern); |
|
1087 painter->setPen(Qt::NoPen); |
|
1088 painter->setBrush(br); |
|
1089 painter->setBackgroundMode(Qt::OpaqueMode); |
|
1090 painter->drawRect(option->rect.adjusted(2, 2, -2, -2)); |
|
1091 } else { |
|
1092 QStyleOptionButton buttonOpt; |
|
1093 buttonOpt.QStyleOption::operator=(*option); |
|
1094 buttonOpt.state = State_Enabled | State_Raised; |
|
1095 drawPrimitive(PE_PanelButtonBevel, &buttonOpt, painter, widget); |
|
1096 } |
|
1097 break; |
|
1098 #endif // QT_NO_SCROLLBAR |
|
1099 case CE_HeaderSection: { |
|
1100 QBrush fill; |
|
1101 if (option->state & State_On) |
|
1102 fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern); |
|
1103 else |
|
1104 fill = option->palette.brush(QPalette::Button); |
|
1105 |
|
1106 if (option->state & (State_Raised | State_Sunken)) { |
|
1107 QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect, option->palette, |
|
1108 option->state & State_Sunken, &fill); |
|
1109 } else { |
|
1110 painter->fillRect(option->rect, fill); |
|
1111 } |
|
1112 break; } |
|
1113 |
|
1114 case CE_DockWidgetTitle: |
|
1115 QWindowsStyle::drawControl(element,option, painter, widget); |
|
1116 break; |
|
1117 |
|
1118 case CE_PushButtonLabel: |
|
1119 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
|
1120 painter->save(); |
|
1121 QFont f = painter->font(); |
|
1122 f.setBold(true); |
|
1123 painter->setFont(f); |
|
1124 QRect ir = btn->rect; |
|
1125 uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic; |
|
1126 if (!styleHint(SH_UnderlineShortcut, btn, widget)) |
|
1127 tf |= Qt::TextHideMnemonic; |
|
1128 |
|
1129 if (btn->state & (State_On | State_Sunken)) |
|
1130 ir.translate(pixelMetric(PM_ButtonShiftHorizontal, option, widget), |
|
1131 pixelMetric(PM_ButtonShiftVertical, option, widget)); |
|
1132 if (!btn->icon.isNull()) { |
|
1133 QIcon::Mode mode = btn->state & State_Enabled ? QIcon::Normal |
|
1134 : QIcon::Disabled; |
|
1135 if (mode == QIcon::Normal && btn->state & State_HasFocus) |
|
1136 mode = QIcon::Active; |
|
1137 QIcon::State state = QIcon::Off; |
|
1138 if (btn->state & State_On) |
|
1139 state = QIcon::On; |
|
1140 QPixmap pixmap = btn->icon.pixmap(btn->iconSize, mode, state); |
|
1141 int pixw = pixmap.width(); |
|
1142 int pixh = pixmap.height(); |
|
1143 //Center the icon if there is no text |
|
1144 |
|
1145 QPoint point; |
|
1146 if (btn->text.isEmpty()) { |
|
1147 point = QPoint(ir.x() + ir.width() / 2 - pixw / 2, |
|
1148 ir.y() + ir.height() / 2 - pixh / 2); |
|
1149 } else { |
|
1150 point = QPoint(ir.x() + 2, ir.y() + ir.height() / 2 - pixh / 2); |
|
1151 } |
|
1152 if (btn->direction == Qt::RightToLeft) |
|
1153 point.rx() += pixw; |
|
1154 |
|
1155 if ((btn->state & (State_On | State_Sunken)) && btn->direction == Qt::RightToLeft) |
|
1156 point.rx() -= pixelMetric(PM_ButtonShiftHorizontal, option, widget) * 2; |
|
1157 |
|
1158 painter->drawPixmap(visualPos(btn->direction, btn->rect, point), pixmap); |
|
1159 |
|
1160 if (btn->direction == Qt::RightToLeft) |
|
1161 ir.translate(-4, 0); |
|
1162 else |
|
1163 ir.translate(pixw + 4, 0); |
|
1164 ir.setWidth(ir.width() - (pixw + 4)); |
|
1165 // left-align text if there is |
|
1166 if (!btn->text.isEmpty()) |
|
1167 tf |= Qt::AlignLeft; |
|
1168 } else { |
|
1169 tf |= Qt::AlignHCenter; |
|
1170 } |
|
1171 drawItemText(painter, ir, tf, btn->palette, (btn->state & State_Enabled), |
|
1172 btn->text, QPalette::ButtonText); |
|
1173 painter->restore(); |
|
1174 } |
|
1175 break; |
|
1176 default: |
|
1177 QWindowsStyle::drawControl(element, option, painter, widget); |
|
1178 break; |
|
1179 } |
|
1180 } |
|
1181 |
|
1182 void QWindowsCEStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, |
|
1183 QPainter *painter, const QWidget *widget) const { |
|
1184 switch (control) { |
|
1185 #ifndef QT_NO_SLIDER |
|
1186 case CC_Slider: |
|
1187 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
1188 int thickness = pixelMetric(PM_SliderControlThickness, slider, widget); |
|
1189 int len = pixelMetric(PM_SliderLength, slider, widget); |
|
1190 int ticks = slider->tickPosition; |
|
1191 QRect groove = subControlRect(CC_Slider, slider, SC_SliderGroove, widget); |
|
1192 QRect handle = subControlRect(CC_Slider, slider, SC_SliderHandle, widget); |
|
1193 |
|
1194 if ((slider->subControls & SC_SliderGroove) && groove.isValid()) { |
|
1195 int mid = thickness / 2; |
|
1196 if (ticks & QSlider::TicksAbove) |
|
1197 mid += len / 8; |
|
1198 if (ticks & QSlider::TicksBelow) |
|
1199 mid -= len / 8; |
|
1200 |
|
1201 painter->setPen(slider->palette.shadow().color()); |
|
1202 if (slider->orientation == Qt::Horizontal) { |
|
1203 QWindowsCEStylePrivate::drawWinCEPanel(painter, groove.x(), groove.y() + mid - 2, |
|
1204 groove.width(), 4, option->palette, true); |
|
1205 painter->drawLine(groove.x() + 1, groove.y() + mid - 1, |
|
1206 groove.x() + groove.width() - 3, groove.y() + mid - 1); |
|
1207 } else { |
|
1208 QWindowsCEStylePrivate::drawWinCEPanel(painter, groove.x() + mid - 2, groove.y(), |
|
1209 4, groove.height(), option->palette, true); |
|
1210 painter->drawLine(groove.x() + mid - 1, groove.y() + 1, |
|
1211 groove.x() + mid - 1, groove.y() + groove.height() - 3); |
|
1212 } |
|
1213 } |
|
1214 if (slider->subControls & SC_SliderTickmarks) { |
|
1215 QStyleOptionSlider tmpSlider = *slider; |
|
1216 tmpSlider.subControls = SC_SliderTickmarks; |
|
1217 QCommonStyle::drawComplexControl(control, &tmpSlider, painter, widget); |
|
1218 } |
|
1219 |
|
1220 if (slider->subControls & SC_SliderHandle) { |
|
1221 // 4444440 |
|
1222 // 4333310 |
|
1223 // 4322210 |
|
1224 // 4322210 |
|
1225 // 4322210 |
|
1226 // 4322210 |
|
1227 // *43210* |
|
1228 // **440** |
|
1229 // ***0*** |
|
1230 const QColor c0 = slider->palette.shadow().color(); |
|
1231 const QColor c1 = slider->palette.dark().color(); |
|
1232 // const QColor c2 = g.button(); |
|
1233 const QColor c3 = slider->palette.midlight().color(); |
|
1234 const QColor c4 = slider->palette.dark().color(); |
|
1235 QBrush handleBrush; |
|
1236 |
|
1237 if (slider->state & State_Enabled) { |
|
1238 handleBrush = slider->palette.color(QPalette::Button); |
|
1239 } else { |
|
1240 handleBrush = QBrush(slider->palette.color(QPalette::Button), |
|
1241 Qt::Dense4Pattern); |
|
1242 } |
|
1243 |
|
1244 int x = handle.x(), y = handle.y(), |
|
1245 wi = handle.width(), he = handle.height(); |
|
1246 |
|
1247 int x1 = x; |
|
1248 int x2 = x + wi - 1; |
|
1249 int y1 = y; |
|
1250 int y2 = y + he - 1; |
|
1251 |
|
1252 Qt::Orientation orient = slider->orientation; |
|
1253 bool tickAbove = slider->tickPosition == QSlider::TicksAbove; |
|
1254 bool tickBelow = slider->tickPosition == QSlider::TicksBelow; |
|
1255 |
|
1256 if (slider->state & State_HasFocus) { |
|
1257 QStyleOptionFocusRect fropt; |
|
1258 fropt.QStyleOption::operator=(*slider); |
|
1259 fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget); |
|
1260 drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); |
|
1261 } |
|
1262 if ((tickAbove && tickBelow) || (!tickAbove && !tickBelow)) { |
|
1263 Qt::BGMode oldMode = painter->backgroundMode(); |
|
1264 painter->setBackgroundMode(Qt::OpaqueMode); |
|
1265 QWindowsCEStylePrivate::drawWinCEButton(painter, QRect(x, y, wi, he), slider->palette, false, |
|
1266 &handleBrush); |
|
1267 painter->setBackgroundMode(oldMode); |
|
1268 QBrush fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern); |
|
1269 if (slider->state & State_Sunken) |
|
1270 painter->fillRect(QRectF(x1 + 2, y1 + 2, x2 - x1 - 3, y2 - y1 - 3),fill); |
|
1271 return; |
|
1272 } |
|
1273 QSliderDirection dir; |
|
1274 if (orient == Qt::Horizontal) |
|
1275 if (tickAbove) |
|
1276 dir = SlUp; |
|
1277 else |
|
1278 dir = SlDown; |
|
1279 else |
|
1280 if (tickAbove) |
|
1281 dir = SlLeft; |
|
1282 else |
|
1283 dir = SlRight; |
|
1284 QPolygon a; |
|
1285 int d = 0; |
|
1286 switch (dir) { |
|
1287 case SlUp: |
|
1288 x2++; |
|
1289 y1 = y1 + wi / 2; |
|
1290 d = (wi + 1) / 2 - 1; |
|
1291 a.setPoints(5, x1, y1, x1, y2, x2, y2, x2, y1, x1 + d, y1 - d); |
|
1292 break; |
|
1293 case SlDown: |
|
1294 x2++; |
|
1295 y2 = y2 - wi / 2; |
|
1296 d = (wi + 1) / 2 - 1; |
|
1297 a.setPoints(5, x1, y1, x1, y2, x1 + d, y2+d, x2, y2, x2, y1); |
|
1298 break; |
|
1299 case SlLeft: |
|
1300 d = (he + 1) / 2 - 1; |
|
1301 x1 = x1 + he / 2; |
|
1302 a.setPoints(5, x1, y1, x1 - d, y1 + d, x1, y2, x2, y2, x2, y1); |
|
1303 y1--; |
|
1304 break; |
|
1305 case SlRight: |
|
1306 d = (he + 1) / 2 - 1; |
|
1307 x2 = x2 - he / 2; |
|
1308 a.setPoints(5, x1, y1, x1, y2, x2, y2, x2 + d, y1 + d, x2, y1); |
|
1309 y1--; |
|
1310 break; |
|
1311 } |
|
1312 QBrush oldBrush = painter->brush(); |
|
1313 painter->setPen(Qt::NoPen); |
|
1314 painter->setBrush(handleBrush); |
|
1315 Qt::BGMode oldMode = painter->backgroundMode(); |
|
1316 painter->setBackgroundMode(Qt::OpaqueMode); |
|
1317 painter->drawRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1); |
|
1318 painter->drawPolygon(a); |
|
1319 QBrush fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern); |
|
1320 if (slider->state & State_Sunken) |
|
1321 painter->fillRect(QRectF(x1, y1, x2 - x1 + 1, y2 - y1 + 1),fill); |
|
1322 painter->setBrush(oldBrush); |
|
1323 painter->setBackgroundMode(oldMode); |
|
1324 |
|
1325 if (dir != SlUp) { |
|
1326 painter->setPen(c4); |
|
1327 painter->drawLine(x1, y1, x2, y1); |
|
1328 painter->setPen(c3); |
|
1329 painter->drawLine(x1, y1 + 1, x2, y1 + 1); |
|
1330 } |
|
1331 if (dir != SlLeft) { |
|
1332 painter->setPen(c3); |
|
1333 painter->drawLine(x1 + 1, y1 + 1, x1 + 1, y2); |
|
1334 painter->setPen(c4); |
|
1335 painter->drawLine(x1, y1, x1, y2); |
|
1336 } |
|
1337 if (dir != SlRight) { |
|
1338 painter->setPen(c0); |
|
1339 painter->drawLine(x2, y1, x2, y2); |
|
1340 painter->setPen(c1); |
|
1341 painter->drawLine(x2 - 1, y1 + 1, x2 - 1, y2 - 1); |
|
1342 } |
|
1343 if (dir != SlDown) { |
|
1344 painter->setPen(c0); |
|
1345 painter->drawLine(x1, y2, x2, y2); |
|
1346 painter->setPen(c1); |
|
1347 painter->drawLine(x1+1, y2 - 1, x2 - 1, y2 - 1); |
|
1348 } |
|
1349 |
|
1350 switch (dir) { |
|
1351 case SlUp: |
|
1352 if (slider->state & State_Sunken) |
|
1353 painter->fillRect(QRectF(x1 + 3, y1 - d + 2, x2 - x1 - 4,y1), fill); |
|
1354 painter->setPen(c4); |
|
1355 painter->drawLine(x1, y1, x1 + d, y1 - d); |
|
1356 painter->setPen(c0); |
|
1357 d = wi - d - 1; |
|
1358 painter->drawLine(x2, y1, x2 - d, y1 - d); |
|
1359 d--; |
|
1360 painter->setPen(c3); |
|
1361 painter->drawLine(x1 + 1, y1, x1 + 1 + d-1, y1 - d + 1); |
|
1362 painter->setPen(c1); |
|
1363 painter->drawLine(x2 - 1, y1, x2-1 - d, y1 - d); |
|
1364 break; |
|
1365 case SlDown: |
|
1366 if (slider->state & State_Sunken) |
|
1367 painter->fillRect(QRectF(x1 + 3, y2 - d, x2 - x1 - 4,y2 - 8), fill); |
|
1368 painter->setPen(c4); |
|
1369 painter->drawLine(x1, y2, x1 + d, y2 + d); |
|
1370 painter->setPen(c0); |
|
1371 d = wi - d - 1; |
|
1372 painter->drawLine(x2, y2, x2 - d, y2 + d); |
|
1373 d--; |
|
1374 painter->setPen(c3); |
|
1375 painter->drawLine(x1 + 1, y2, x1 + 1 + d - 1, y2 + d - 1); |
|
1376 painter->setPen(c1); |
|
1377 painter->drawLine(x2 - 1, y2, x2 - 1 - d, y2 + d); |
|
1378 break; |
|
1379 case SlLeft: |
|
1380 if (slider->state & State_Sunken) |
|
1381 painter->fillRect(QRectF(x1 - d + 2, y1 + 2, x1,y2 - y1 - 3), fill); |
|
1382 painter->setPen(c4); |
|
1383 painter->drawLine(x1, y1, x1 - d, y1 + d); |
|
1384 painter->setPen(c0); |
|
1385 d = he - d - 1; |
|
1386 painter->drawLine(x1, y2, x1 - d, y2 - d); |
|
1387 d--; |
|
1388 painter->setPen(c3); |
|
1389 painter->drawLine(x1, y1 + 1, x1 - d + 1, y1 + 1 + d - 1); |
|
1390 painter->setPen(c1); |
|
1391 painter->drawLine(x1, y2 - 1, x1 - d, y2 - 1 - d); |
|
1392 break; |
|
1393 case SlRight: |
|
1394 if (slider->state & State_Sunken) |
|
1395 painter->fillRect(QRectF(x2 - d - 4, y1 + 2, x2 - 4, y2 - y1 - 3), fill); |
|
1396 painter->setPen(c4); |
|
1397 painter->drawLine(x2, y1, x2 + d, y1 + d); |
|
1398 painter->setPen(c0); |
|
1399 d = he - d - 1; |
|
1400 painter->drawLine(x2, y2, x2 + d, y2 - d); |
|
1401 d--; |
|
1402 painter->setPen(c3); |
|
1403 painter->drawLine(x2, y1 + 1, x2 + d - 1, y1 + 1 + d - 1); |
|
1404 painter->setPen(c1); |
|
1405 painter->drawLine(x2, y2 - 1, x2 + d, y2 - 1 - d); |
|
1406 break; |
|
1407 } |
|
1408 } |
|
1409 } |
|
1410 break; |
|
1411 #endif // QT_NO_SLIDER |
|
1412 case CC_ToolButton: |
|
1413 if (const QStyleOptionToolButton *toolbutton |
|
1414 = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { |
|
1415 QRect button, menuarea; |
|
1416 |
|
1417 #ifndef QT_NO_TOOLBAR |
|
1418 bool flat = !(widget ? qobject_cast<QToolBar*>(widget->parentWidget()) : 0); |
|
1419 #else |
|
1420 bool flat = true; |
|
1421 #endif |
|
1422 |
|
1423 button = subControlRect(control, toolbutton, SC_ToolButton, widget); |
|
1424 menuarea = subControlRect(control, toolbutton, SC_ToolButtonMenu, widget); |
|
1425 |
|
1426 if (flat && (toolbutton->subControls & SC_ToolButtonMenu)) { |
|
1427 menuarea.setLeft(menuarea.left() - 4); |
|
1428 button.setRight(button.right() - 4); |
|
1429 } |
|
1430 |
|
1431 State bflags = toolbutton->state; |
|
1432 |
|
1433 if (bflags & State_AutoRaise) |
|
1434 if (!(bflags & State_MouseOver)) { |
|
1435 bflags &= ~State_Raised; |
|
1436 } |
|
1437 State mflags = bflags; |
|
1438 |
|
1439 if (toolbutton->activeSubControls & SC_ToolButton) |
|
1440 bflags |= State_Sunken; |
|
1441 if (toolbutton->activeSubControls & SC_ToolButtonMenu) |
|
1442 mflags |= State_Sunken; |
|
1443 |
|
1444 QStyleOption tool(0); |
|
1445 tool.palette = toolbutton->palette; |
|
1446 if (toolbutton->subControls & SC_ToolButton) { |
|
1447 tool.rect = button; |
|
1448 tool.state = bflags; |
|
1449 drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); |
|
1450 } |
|
1451 |
|
1452 if (toolbutton->subControls & SC_ToolButtonMenu) { |
|
1453 tool.rect = menuarea; |
|
1454 tool.state = mflags; |
|
1455 tool.state = bflags; |
|
1456 drawPrimitive(PE_IndicatorButtonDropDown, &tool, painter, widget); |
|
1457 |
|
1458 if (!flat) { |
|
1459 |
|
1460 //connect buttons |
|
1461 painter->save(); |
|
1462 painter->setPen(tool.palette.button().color()); |
|
1463 painter->drawLine(tool.rect.x() - 2, tool.rect.y(), tool.rect.x() - 2, tool.rect.y() + tool.rect.height()); |
|
1464 painter->drawLine(tool.rect.x() - 1, tool.rect.y(), tool.rect.x() - 1, tool.rect.y() + tool.rect.height()); |
|
1465 painter->drawLine(tool.rect.x(), tool.rect.y(), tool.rect.x(), tool.rect.y() + tool.rect.height()); |
|
1466 painter->drawLine(tool.rect.x() + 1, tool.rect.y(), tool.rect.x() + 1, tool.rect.y() + tool.rect.height()); |
|
1467 |
|
1468 if (tool.state & State_Sunken) |
|
1469 { |
|
1470 painter->setPen(tool.palette.midlight().color()); |
|
1471 painter->drawLine(tool.rect.x() - 2, tool.rect.y() + tool.rect.height() - 2, |
|
1472 tool.rect.x() + 1, tool.rect.y() + tool.rect.height() -2 ); |
|
1473 painter->setPen(tool.palette.shadow().color()); |
|
1474 painter->drawLine(tool.rect.x() - 2, tool.rect.y() + 1,tool.rect.x() + 1, tool.rect.y() + 1); |
|
1475 painter->drawLine(tool.rect.x() - 2, tool.rect.y(), tool.rect.x() + 1, tool.rect.y()); |
|
1476 painter->setPen(tool.palette.light().color()); |
|
1477 painter->drawLine(tool.rect.x() - 2, tool.rect.y() + tool.rect.height() - 1, |
|
1478 tool.rect.x() + 1, tool.rect.y() + tool.rect.height() - 1); |
|
1479 } |
|
1480 else |
|
1481 { |
|
1482 painter->setPen(tool.palette.dark().color()); |
|
1483 painter->drawLine(tool.rect.x() - 2, tool.rect.y(),tool.rect.x() + 1, tool.rect.y()); |
|
1484 painter->drawLine(tool.rect.x() - 2, tool.rect.y()+tool.rect.height() - 2,tool.rect.x() + 1, |
|
1485 tool.rect.y() + tool.rect.height() - 2); |
|
1486 painter->setPen(tool.palette.midlight().color()); |
|
1487 painter->drawLine(tool.rect.x() - 2, tool.rect.y() + 1,tool.rect.x() + 1, tool.rect.y() + 1); |
|
1488 painter->setPen(tool.palette.shadow().color()); |
|
1489 painter->drawLine(tool.rect.x() - 2, tool.rect.y() + tool.rect.height() - 1, |
|
1490 tool.rect.x() + 1, tool.rect.y() + tool.rect.height() - 1); |
|
1491 } |
|
1492 painter->restore(); |
|
1493 } |
|
1494 |
|
1495 |
|
1496 if (!flat) { |
|
1497 tool.rect.adjust(-3,0,-3,0); |
|
1498 painter->save(); |
|
1499 painter->setPen(tool.palette.button().color()); |
|
1500 if (tool.state & State_Sunken) |
|
1501 painter->drawLine(tool.rect.x() + 2, tool.rect.y() + 10, |
|
1502 tool.rect.x() + tool.rect.width(), tool.rect.y() + 10); |
|
1503 else |
|
1504 painter->drawLine(tool.rect.x() + 1, tool.rect.y() + 9, tool.rect.x() + |
|
1505 tool.rect.width() - 1, tool.rect.y() + 9); |
|
1506 painter->restore(); |
|
1507 } else { |
|
1508 tool.rect.adjust(-1,0,-1,0); |
|
1509 } |
|
1510 |
|
1511 drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget); |
|
1512 } |
|
1513 |
|
1514 if (toolbutton->state & State_HasFocus) { |
|
1515 QStyleOptionFocusRect fr; |
|
1516 fr.QStyleOption::operator=(*toolbutton); |
|
1517 fr.rect.adjust(3, 3, -3, -3); |
|
1518 if (toolbutton->features & QStyleOptionToolButton::Menu) |
|
1519 fr.rect.adjust(0, 0, -pixelMetric(QStyle::PM_MenuButtonIndicator, |
|
1520 toolbutton, widget), 0); |
|
1521 drawPrimitive(PE_FrameFocusRect, &fr, painter, widget); |
|
1522 } |
|
1523 QStyleOptionToolButton label = *toolbutton; |
|
1524 int fw = pixelMetric(PM_DefaultFrameWidth, option, widget); |
|
1525 label.rect = button.adjusted(fw, fw, -fw, -fw); |
|
1526 drawControl(CE_ToolButtonLabel, &label, painter, widget); |
|
1527 } |
|
1528 break; |
|
1529 |
|
1530 #ifndef QT_NO_GROUPBOX |
|
1531 case CC_GroupBox: |
|
1532 if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { |
|
1533 // Draw frame |
|
1534 painter->save(); |
|
1535 QFont f = painter->font(); |
|
1536 f.setBold(true); |
|
1537 painter->setFont(f); |
|
1538 QStyleOptionGroupBox groupBoxFont = *groupBox; |
|
1539 groupBoxFont.fontMetrics = QFontMetrics(f); |
|
1540 QRect textRect = subControlRect(CC_GroupBox, &groupBoxFont, SC_GroupBoxLabel, widget); |
|
1541 QRect checkBoxRect = subControlRect(CC_GroupBox, option, SC_GroupBoxCheckBox, widget); |
|
1542 if (groupBox->subControls & QStyle::SC_GroupBoxFrame) { |
|
1543 QStyleOptionFrameV2 frame; |
|
1544 frame.QStyleOption::operator=(*groupBox); |
|
1545 frame.features = groupBox->features; |
|
1546 frame.lineWidth = groupBox->lineWidth; |
|
1547 frame.midLineWidth = groupBox->midLineWidth; |
|
1548 frame.rect = subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget); |
|
1549 painter->save(); |
|
1550 |
|
1551 QRegion region(groupBox->rect); |
|
1552 if (!groupBox->text.isEmpty()) { |
|
1553 bool ltr = groupBox->direction == Qt::LeftToRight; |
|
1554 QRect finalRect = checkBoxRect.united(textRect); |
|
1555 if (groupBox->subControls & QStyle::SC_GroupBoxCheckBox) |
|
1556 finalRect.adjust(ltr ? -4 : 0, 0, ltr ? 0 : 4, 0); |
|
1557 region -= finalRect; |
|
1558 } |
|
1559 painter->setClipRegion(region); |
|
1560 drawPrimitive(PE_FrameGroupBox, &frame, painter, widget); |
|
1561 painter->restore(); |
|
1562 } |
|
1563 |
|
1564 // Draw title |
|
1565 if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) { |
|
1566 QColor textColor = groupBox->textColor; |
|
1567 if (textColor.isValid()) |
|
1568 painter->setPen(textColor); |
|
1569 int alignment = int(groupBox->textAlignment); |
|
1570 if (!styleHint(QStyle::SH_UnderlineShortcut, option, widget)) |
|
1571 alignment |= Qt::TextHideMnemonic; |
|
1572 |
|
1573 drawItemText(painter, textRect, Qt::TextShowMnemonic | Qt::AlignHCenter | alignment, |
|
1574 groupBox->palette, groupBox->state & State_Enabled, groupBox->text, |
|
1575 textColor.isValid() ? QPalette::NoRole : QPalette::WindowText); |
|
1576 |
|
1577 if (groupBox->state & State_HasFocus) { |
|
1578 QStyleOptionFocusRect fropt; |
|
1579 fropt.QStyleOption::operator=(*groupBox); |
|
1580 fropt.rect = textRect; |
|
1581 drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); |
|
1582 } |
|
1583 } |
|
1584 // Draw checkbox |
|
1585 if (groupBox->subControls & SC_GroupBoxCheckBox) { |
|
1586 QStyleOptionButton box; |
|
1587 box.QStyleOption::operator=(*groupBox); |
|
1588 box.rect = checkBoxRect; |
|
1589 drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget); |
|
1590 } |
|
1591 painter->restore(); |
|
1592 } |
|
1593 break; |
|
1594 #endif //QT_NO_GROUPBOX |
|
1595 #ifndef QT_NO_COMBOBOX |
|
1596 case CC_ComboBox: |
|
1597 if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
|
1598 QBrush editBrush = cmb->palette.brush(QPalette::Base); |
|
1599 if ((cmb->subControls & SC_ComboBoxFrame) && cmb->frame) |
|
1600 QWindowsCEStylePrivate::drawWinCEPanel(painter, option->rect, option->palette, true, &editBrush); |
|
1601 else |
|
1602 painter->fillRect(option->rect, editBrush); |
|
1603 |
|
1604 if (cmb->subControls & SC_ComboBoxArrow) { |
|
1605 State flags = State_None; |
|
1606 |
|
1607 QRect ar = subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget); |
|
1608 if (cmb->activeSubControls == SC_ComboBoxArrow) { |
|
1609 painter->setPen(cmb->palette.dark().color()); |
|
1610 painter->setBrush(cmb->palette.brush(QPalette::Button)); |
|
1611 painter->drawRect(ar.adjusted(0, 0, -1, -1)); |
|
1612 QWindowsCEStylePrivate::drawWinCEButton(painter, ar.adjusted(0, 0, -1, -1), option->palette, true, |
|
1613 &cmb->palette.brush(QPalette::Button)); |
|
1614 } else { |
|
1615 // Make qDrawWinButton use the right colors for drawing the shade of the button |
|
1616 |
|
1617 QWindowsCEStylePrivate::drawWinCEButton(painter, ar, option->palette, false, |
|
1618 &cmb->palette.brush(QPalette::Button)); |
|
1619 } |
|
1620 |
|
1621 ar.adjust(2, 2, -2, -2); |
|
1622 if (option->state & State_Enabled) |
|
1623 flags |= State_Enabled; |
|
1624 |
|
1625 if (cmb->activeSubControls == SC_ComboBoxArrow) |
|
1626 flags |= State_Sunken; |
|
1627 QStyleOption arrowOpt(0); |
|
1628 arrowOpt.rect = ar; |
|
1629 arrowOpt.palette = cmb->palette; |
|
1630 arrowOpt.state = flags; |
|
1631 drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget); |
|
1632 } |
|
1633 if (cmb->subControls & SC_ComboBoxEditField) { |
|
1634 QRect re = subControlRect(CC_ComboBox, cmb, SC_ComboBoxEditField, widget); |
|
1635 if (cmb->state & State_HasFocus && !cmb->editable) |
|
1636 painter->fillRect(re.x(), re.y(), re.width(), re.height(), |
|
1637 cmb->palette.brush(QPalette::Highlight)); |
|
1638 if (cmb->state & State_HasFocus) { |
|
1639 painter->setPen(cmb->palette.highlightedText().color()); |
|
1640 painter->setBackground(cmb->palette.highlight()); |
|
1641 } else { |
|
1642 painter->setPen(cmb->palette.text().color()); |
|
1643 painter->setBackground(cmb->palette.background()); |
|
1644 } |
|
1645 if (cmb->state & State_HasFocus && !cmb->editable) { |
|
1646 QStyleOptionFocusRect focus; |
|
1647 focus.QStyleOption::operator=(*cmb); |
|
1648 focus.rect = subElementRect(SE_ComboBoxFocusRect, cmb, widget); |
|
1649 focus.state |= State_FocusAtBorder; |
|
1650 focus.backgroundColor = cmb->palette.highlight().color(); |
|
1651 drawPrimitive(PE_FrameFocusRect, &focus, painter, widget); |
|
1652 } |
|
1653 } |
|
1654 } |
|
1655 break; |
|
1656 #endif // QT_NO_COMBOBOX |
|
1657 #ifndef QT_NO_SPINBOX |
|
1658 case CC_SpinBox: |
|
1659 if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
|
1660 QStyleOptionSpinBox copy = *sb; |
|
1661 PrimitiveElement pe; |
|
1662 |
|
1663 if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) { |
|
1664 QRect r = subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget); |
|
1665 QWindowsCEStylePrivate::drawWinCEPanel(painter, r, option->palette, true); |
|
1666 } |
|
1667 QPalette shadePal(option->palette); |
|
1668 shadePal.setColor(QPalette::Button, option->palette.light().color()); |
|
1669 shadePal.setColor(QPalette::Light, option->palette.button().color()); |
|
1670 |
|
1671 bool reverse = QApplication::layoutDirection() == Qt::RightToLeft; |
|
1672 |
|
1673 if (sb->subControls & SC_SpinBoxUp) { |
|
1674 copy.subControls = SC_SpinBoxUp; |
|
1675 QPalette pal2 = sb->palette; |
|
1676 if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled)) { |
|
1677 pal2.setCurrentColorGroup(QPalette::Disabled); |
|
1678 copy.state &= ~State_Enabled; |
|
1679 } |
|
1680 copy.palette = pal2; |
|
1681 if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken)) { |
|
1682 copy.state |= State_On; |
|
1683 copy.state |= State_Sunken; |
|
1684 } else { |
|
1685 copy.state |= State_Raised; |
|
1686 copy.state &= ~State_Sunken; |
|
1687 } |
|
1688 if (reverse) |
|
1689 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus |
|
1690 : PE_IndicatorSpinDown); |
|
1691 else |
|
1692 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus |
|
1693 : PE_IndicatorSpinUp); |
|
1694 copy.rect = subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget); |
|
1695 QWindowsCEStylePrivate::drawWinCEButton(painter, copy.rect, option->palette, copy.state & (State_Sunken | State_On), |
|
1696 ©.palette.brush(QPalette::Button)); |
|
1697 copy.rect.adjust(3, 0, -4, 0); |
|
1698 drawPrimitive(pe, ©, painter, widget); |
|
1699 } |
|
1700 if (sb->subControls & SC_SpinBoxDown) { |
|
1701 copy.subControls = SC_SpinBoxDown; |
|
1702 copy.state = sb->state; |
|
1703 QPalette pal2 = sb->palette; |
|
1704 if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled)) { |
|
1705 pal2.setCurrentColorGroup(QPalette::Disabled); |
|
1706 copy.state &= ~State_Enabled; |
|
1707 } |
|
1708 copy.palette = pal2; |
|
1709 |
|
1710 if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken)) { |
|
1711 copy.state |= State_On; |
|
1712 copy.state |= State_Sunken; |
|
1713 } else { |
|
1714 copy.state |= State_Raised; |
|
1715 copy.state &= ~State_Sunken; |
|
1716 } |
|
1717 if (reverse) |
|
1718 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus |
|
1719 : PE_IndicatorSpinUp); |
|
1720 else |
|
1721 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus |
|
1722 : PE_IndicatorSpinDown); |
|
1723 copy.rect = subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget); |
|
1724 QWindowsCEStylePrivate::drawWinCEButton(painter, copy.rect, shadePal, copy.state & (State_Sunken | State_On), |
|
1725 ©.palette.brush(QPalette::Button)); |
|
1726 |
|
1727 copy.rect.adjust(3, 0, -4, 0); |
|
1728 if (pe == PE_IndicatorArrowUp || pe == PE_IndicatorArrowDown) { |
|
1729 copy.rect = copy.rect.adjusted(1, 1, -1, -1); |
|
1730 drawPrimitive(pe, ©, painter, widget); |
|
1731 } |
|
1732 else { |
|
1733 drawPrimitive(pe, ©, painter, widget); |
|
1734 } |
|
1735 if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) { |
|
1736 QRect r = subControlRect(CC_SpinBox, sb, SC_SpinBoxEditField, widget); |
|
1737 painter->save(); |
|
1738 painter->setPen(option->palette.light().color()); |
|
1739 painter->drawLine(r.x() + 1 + r.width(), r.y() - 2, r.x() + 1 + r.width(), r.y() + r.height() + 1); |
|
1740 painter->setPen(option->palette.midlight().color()); |
|
1741 painter->drawLine(r.x() + r.width(), r.y() - 1, r.x() + r.width(), r.y() + r.height()); |
|
1742 painter->restore(); |
|
1743 } |
|
1744 } |
|
1745 } |
|
1746 break; |
|
1747 #endif // QT_NO_SPINBOX |
|
1748 |
|
1749 default: |
|
1750 QWindowsStyle::drawComplexControl(control, option, painter, widget); |
|
1751 break; |
|
1752 } |
|
1753 } |
|
1754 |
|
1755 void QWindowsCEStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal, |
|
1756 bool enabled, const QString& text, QPalette::ColorRole textRole) const { |
|
1757 if (text.isEmpty()) |
|
1758 return; |
|
1759 QPen savedPen; |
|
1760 if (textRole != QPalette::NoRole) { |
|
1761 savedPen = painter->pen(); |
|
1762 painter->setPen(pal.color(textRole)); |
|
1763 } |
|
1764 if (!enabled) { |
|
1765 QPen pen = painter->pen(); |
|
1766 painter->setPen(pal.light().color()); |
|
1767 //painter->drawText(rect.adjusted(1, 1, 1, 1), alignment, text); |
|
1768 painter->setPen(pen); |
|
1769 } |
|
1770 painter->drawText(rect, alignment, text); |
|
1771 if (textRole != QPalette::NoRole) |
|
1772 painter->setPen(savedPen); |
|
1773 } |
|
1774 |
|
1775 |
|
1776 QSize QWindowsCEStyle::sizeFromContents(ContentsType type, const QStyleOption *option, |
|
1777 const QSize &size, const QWidget *widget) const { |
|
1778 QSize newSize = QWindowsStyle::sizeFromContents(type, option, size, widget); |
|
1779 switch (type) { |
|
1780 case CT_PushButton: |
|
1781 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
|
1782 newSize = QWindowsStyle::sizeFromContents(type, option, size, widget); |
|
1783 int w = newSize.width(), |
|
1784 h = newSize.height(); |
|
1785 int defwidth = 0; |
|
1786 if (btn->features & QStyleOptionButton::AutoDefaultButton) |
|
1787 defwidth = 2 * pixelMetric(PM_ButtonDefaultIndicator, btn, widget); |
|
1788 if (w < 75 + defwidth && btn->icon.isNull()) |
|
1789 w = 75 + defwidth; |
|
1790 if (h < 23 + defwidth) |
|
1791 h = 23 + defwidth; |
|
1792 newSize = QSize(w+14, h); |
|
1793 } |
|
1794 break; |
|
1795 |
|
1796 case CT_RadioButton: |
|
1797 case CT_CheckBox: |
|
1798 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { |
|
1799 bool isRadio = (type == CT_RadioButton); |
|
1800 QRect irect = visualRect(btn->direction, btn->rect, |
|
1801 subElementRect(isRadio ? SE_RadioButtonIndicator |
|
1802 : SE_CheckBoxIndicator, btn, widget)); |
|
1803 int h = pixelMetric(isRadio ? PM_ExclusiveIndicatorHeight |
|
1804 : PM_IndicatorHeight, btn, widget); |
|
1805 int margins = (!btn->icon.isNull() && btn->text.isEmpty()) ? 0 : 10; |
|
1806 newSize += QSize(irect.right() + margins, 4); |
|
1807 newSize.setHeight(qMax(newSize.height(), h)); |
|
1808 } |
|
1809 break; |
|
1810 case CT_ComboBox: |
|
1811 if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
|
1812 int fw = cmb->frame ? pixelMetric(PM_ComboBoxFrameWidth, option, widget) * 2 : 0; |
|
1813 newSize = QSize(newSize.width() + fw -1, qMax(24, newSize.height() + fw-1)); |
|
1814 } |
|
1815 break; |
|
1816 #ifndef QT_NO_SPINBOX |
|
1817 case CT_SpinBox: |
|
1818 if (const QStyleOptionSpinBox *spnb = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
|
1819 int fw = spnb->frame ? pixelMetric(PM_SpinBoxFrameWidth, option, widget) * 2 : 0; |
|
1820 newSize = QSize(newSize.width() + fw - 5, newSize.height() + fw - 6); |
|
1821 } |
|
1822 break; |
|
1823 #endif |
|
1824 case CT_LineEdit: |
|
1825 newSize += QSize(0,1); |
|
1826 break; |
|
1827 case CT_MenuBarItem: |
|
1828 newSize += QSize(5, 1); |
|
1829 break; |
|
1830 case CT_MenuItem: |
|
1831 newSize += QSize(0, -2); |
|
1832 break; |
|
1833 case CT_MenuBar: |
|
1834 newSize += QSize(0, -1); |
|
1835 break; |
|
1836 case CT_ToolButton: |
|
1837 if (const QStyleOptionToolButton *b = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { |
|
1838 if (b->toolButtonStyle != Qt::ToolButtonIconOnly) |
|
1839 newSize = QSize(newSize.width() + 1, newSize.height() - 1); |
|
1840 else |
|
1841 newSize = QSize(newSize.width() + 1, newSize.height()); |
|
1842 } |
|
1843 break; |
|
1844 |
|
1845 default: |
|
1846 break; |
|
1847 } |
|
1848 return newSize; |
|
1849 } |
|
1850 |
|
1851 QRect QWindowsCEStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const { |
|
1852 QRect rect = QWindowsStyle::subElementRect(element, option, widget); |
|
1853 switch (element) { |
|
1854 #ifndef QT_NO_COMBOBOX |
|
1855 case SE_ComboBoxFocusRect: |
|
1856 if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
|
1857 int margin = cb->frame ? 3 : 0; |
|
1858 rect.setRect(margin, margin, option->rect.width() - 2*margin - 20, option->rect.height() - 2*margin); |
|
1859 rect = visualRect(option->direction, option->rect, rect); |
|
1860 } |
|
1861 break; |
|
1862 #endif // QT_NO_COMBOBOX |
|
1863 default: |
|
1864 break; |
|
1865 } |
|
1866 return rect; |
|
1867 } |
|
1868 |
|
1869 QRect QWindowsCEStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option, |
|
1870 SubControl subControl, const QWidget *widget) const { |
|
1871 QRect rect = QWindowsStyle::subControlRect(control, option, subControl, widget); |
|
1872 switch (control) { |
|
1873 #ifndef QT_NO_SLIDER |
|
1874 case CC_Slider: |
|
1875 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { |
|
1876 int tickOffset = pixelMetric(PM_SliderTickmarkOffset, slider, widget); |
|
1877 int thickness = pixelMetric(PM_SliderControlThickness, slider, widget); |
|
1878 |
|
1879 switch (subControl) { |
|
1880 case SC_SliderHandle: { |
|
1881 int sliderPos = 0; |
|
1882 int len = pixelMetric(PM_SliderLength, slider, widget); |
|
1883 bool horizontal = slider->orientation == Qt::Horizontal; |
|
1884 sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, |
|
1885 slider->sliderPosition, |
|
1886 (horizontal ? slider->rect.width() |
|
1887 : slider->rect.height()) - len, |
|
1888 slider->upsideDown); |
|
1889 if (horizontal) |
|
1890 rect.setRect(slider->rect.x() + sliderPos, slider->rect.y() + tickOffset, len, thickness); |
|
1891 else |
|
1892 rect.setRect(slider->rect.x() + tickOffset, slider->rect.y() + sliderPos, thickness, len); |
|
1893 break; } |
|
1894 default: |
|
1895 break; |
|
1896 } |
|
1897 rect = visualRect(slider->direction, slider->rect, rect); |
|
1898 } |
|
1899 break; |
|
1900 #endif //QT_NO_SLIDER |
|
1901 #ifndef QT_NO_COMBOBOX |
|
1902 case CC_ComboBox: |
|
1903 if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { |
|
1904 int x = cb->rect.x(), |
|
1905 y = cb->rect.y(), |
|
1906 wi = cb->rect.width(), |
|
1907 he = cb->rect.height(); |
|
1908 int xpos = x; |
|
1909 int margin = cb->frame ? 3 : 0; |
|
1910 int bmarg = cb->frame ? 2 : 0; |
|
1911 xpos += wi - (he - 2*bmarg) - bmarg; |
|
1912 switch (subControl) { |
|
1913 case SC_ComboBoxArrow: |
|
1914 rect.setRect(xpos, y + bmarg, he - 2*bmarg, he - 2*bmarg); |
|
1915 break; |
|
1916 case SC_ComboBoxEditField: |
|
1917 rect.setRect(x + margin, y + margin, wi - 2 * margin - (he - 2*bmarg), he - 2 * margin); |
|
1918 break; |
|
1919 case SC_ComboBoxListBoxPopup: |
|
1920 rect = cb->rect; |
|
1921 break; |
|
1922 case SC_ComboBoxFrame: |
|
1923 rect = cb->rect; |
|
1924 break; |
|
1925 default: |
|
1926 break; |
|
1927 } |
|
1928 rect = visualRect(cb->direction, cb->rect, rect); |
|
1929 } |
|
1930 #endif //QT_NO_COMBOBOX |
|
1931 #ifndef QT_NO_SPINBOX |
|
1932 case CC_SpinBox: |
|
1933 if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { |
|
1934 QSize bs; |
|
1935 int fw = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; |
|
1936 bs.setWidth(qMax(18, (spinbox->rect.height() / 2 - fw + 1))); |
|
1937 // 1.6 -approximate golden mean |
|
1938 bs.setHeight(qMax(18, qMin((bs.height() * 8 / 5), (spinbox->rect.width() / 4)))); |
|
1939 bs = bs.expandedTo(QApplication::globalStrut()); |
|
1940 int y = fw; |
|
1941 int x, lx, rx; |
|
1942 x = spinbox->rect.width() - y - bs.width() * 2; |
|
1943 lx = fw; |
|
1944 rx = x - fw; |
|
1945 switch (subControl) { |
|
1946 case SC_SpinBoxUp: |
|
1947 rect = QRect(x + bs.width(), y, bs.width(), bs.height()); |
|
1948 break; |
|
1949 case SC_SpinBoxDown: |
|
1950 rect = QRect(x, y , bs.width(), bs.height()); |
|
1951 break; |
|
1952 case SC_SpinBoxEditField: |
|
1953 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) { |
|
1954 rect = QRect(lx, fw, spinbox->rect.width() - 2*fw - 2, spinbox->rect.height() - 2*fw); |
|
1955 } else { |
|
1956 rect = QRect(lx, fw, rx-2, spinbox->rect.height() - 2*fw); |
|
1957 } |
|
1958 break; |
|
1959 case SC_SpinBoxFrame: |
|
1960 rect = spinbox->rect; |
|
1961 default: |
|
1962 break; |
|
1963 } |
|
1964 rect = visualRect(spinbox->direction, spinbox->rect, rect); |
|
1965 } |
|
1966 break; |
|
1967 #endif // Qt_NO_SPINBOX |
|
1968 #ifndef QT_NO_GROUPBOX |
|
1969 case CC_GroupBox: { |
|
1970 if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { |
|
1971 switch (subControl) { |
|
1972 case SC_GroupBoxFrame: |
|
1973 // FALL THROUGH |
|
1974 case SC_GroupBoxContents: { |
|
1975 int topMargin = 0; |
|
1976 int topHeight = 0; |
|
1977 int bottomMargin = 0; |
|
1978 int noLabelMargin = 0; |
|
1979 QRect frameRect = groupBox->rect; |
|
1980 int verticalAlignment = styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget); |
|
1981 if (groupBox->text.size()) { |
|
1982 topHeight = groupBox->fontMetrics.height(); |
|
1983 if (verticalAlignment & Qt::AlignVCenter) |
|
1984 topMargin = topHeight / 2; |
|
1985 else if (verticalAlignment & Qt::AlignTop) |
|
1986 topMargin = -topHeight/2; |
|
1987 } |
|
1988 else { |
|
1989 topHeight = groupBox->fontMetrics.height(); |
|
1990 noLabelMargin = topHeight / 2; |
|
1991 if (verticalAlignment & Qt::AlignVCenter) { |
|
1992 topMargin = topHeight / 4 - 4; |
|
1993 bottomMargin = topHeight / 4 - 4; |
|
1994 } |
|
1995 else if (verticalAlignment & Qt::AlignTop) { |
|
1996 topMargin = topHeight/2 - 4; |
|
1997 bottomMargin = topHeight/2 - 4; |
|
1998 } |
|
1999 } |
|
2000 |
|
2001 if (subControl == SC_GroupBoxFrame) { |
|
2002 frameRect.setTop(topMargin); |
|
2003 frameRect.setBottom(frameRect.height() + bottomMargin); |
|
2004 rect = frameRect; |
|
2005 break; |
|
2006 } |
|
2007 |
|
2008 int frameWidth = 0; |
|
2009 if ((groupBox->features & QStyleOptionFrameV2::Flat) == 0) |
|
2010 frameWidth = pixelMetric(PM_DefaultFrameWidth, groupBox, widget); |
|
2011 rect = frameRect.adjusted(frameWidth, frameWidth + topHeight, -frameWidth, -frameWidth - noLabelMargin); |
|
2012 break; |
|
2013 } |
|
2014 case SC_GroupBoxCheckBox: |
|
2015 // FALL THROUGH |
|
2016 case SC_GroupBoxLabel: { |
|
2017 QFontMetrics fontMetrics = groupBox->fontMetrics; |
|
2018 int h = fontMetrics.height(); |
|
2019 int tw = fontMetrics.size(Qt::TextShowMnemonic, groupBox->text + QLatin1Char(' ')).width(); |
|
2020 int marg = (groupBox->features & QStyleOptionFrameV2::Flat) ? 0 : 8; |
|
2021 rect = groupBox->rect.adjusted(marg, 0, -marg, 0); |
|
2022 rect.setHeight(h); |
|
2023 |
|
2024 int indicatorWidth = pixelMetric(PM_IndicatorWidth, option, widget); |
|
2025 int indicatorSpace = pixelMetric(PM_CheckBoxLabelSpacing, option, widget) - 1; |
|
2026 bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox; |
|
2027 int checkBoxSize = hasCheckBox ? (indicatorWidth + indicatorSpace) : 0; |
|
2028 |
|
2029 // Adjusted rect for label + indicatorWidth + indicatorSpace |
|
2030 QRect totalRect = alignedRect(groupBox->direction, groupBox->textAlignment, |
|
2031 QSize(tw + checkBoxSize, h), rect); |
|
2032 |
|
2033 // Adjust totalRect if checkbox is set |
|
2034 if (hasCheckBox) { |
|
2035 bool ltr = groupBox->direction == Qt::LeftToRight; |
|
2036 int left = 0; |
|
2037 // Adjust for check box |
|
2038 if (subControl == SC_GroupBoxCheckBox) { |
|
2039 int indicatorHeight = pixelMetric(PM_IndicatorHeight, option, widget); |
|
2040 left = ltr ? totalRect.left() : (totalRect.right() - indicatorWidth); |
|
2041 int top = totalRect.top() + (fontMetrics.height() - indicatorHeight) / 2; |
|
2042 totalRect.setRect(left, top, indicatorWidth, indicatorHeight); |
|
2043 // Adjust for label |
|
2044 } else { |
|
2045 left = ltr ? (totalRect.left() + checkBoxSize - 2) : totalRect.left(); |
|
2046 totalRect.setRect(left, totalRect.top(), |
|
2047 totalRect.width() - checkBoxSize, totalRect.height()); |
|
2048 } |
|
2049 } |
|
2050 rect = totalRect; |
|
2051 break; |
|
2052 } |
|
2053 default: |
|
2054 break; |
|
2055 } |
|
2056 } |
|
2057 break; |
|
2058 } |
|
2059 #endif // QT_NO_GROUPBOX |
|
2060 default: |
|
2061 break; |
|
2062 } |
|
2063 return rect; |
|
2064 } |
|
2065 |
|
2066 QStyle::SubControl QWindowsCEStyle::hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, |
|
2067 const QPoint &pos, const QWidget *widget) const { |
|
2068 /*switch (control) { |
|
2069 default: |
|
2070 break; |
|
2071 }*/ |
|
2072 return QWindowsStyle::hitTestComplexControl(control, option, pos, widget); |
|
2073 } |
|
2074 |
|
2075 |
|
2076 QPalette QWindowsCEStyle::standardPalette() const { |
|
2077 QPalette palette (Qt::black,QColor(198, 195, 198), QColor(222, 223, 222 ), |
|
2078 QColor(132, 130, 132), QColor(198, 195, 198) , Qt::black, Qt::white, Qt::white, QColor(198, 195, 198)); |
|
2079 palette.setColor(QPalette::Window, QColor(198, 195, 198)); |
|
2080 palette.setColor(QPalette::Base, Qt::white); |
|
2081 palette.setColor(QPalette::Button, QColor(198, 195, 198)); |
|
2082 palette.setColor(QPalette::Highlight, QColor(0, 0, 132)); |
|
2083 palette.setColor(QPalette::Light, Qt::white); |
|
2084 palette.setColor(QPalette::Midlight, QColor(222, 223, 222 )); |
|
2085 palette.setColor(QPalette::Dark, QColor(132, 130, 132)); |
|
2086 palette.setColor(QPalette::Mid, QColor(132, 130, 132)); |
|
2087 palette.setColor(QPalette::Shadow, QColor(0, 0, 0)); |
|
2088 palette.setColor(QPalette::BrightText, QColor(33, 162, 33)); //color for ItemView checked indicator (arrow) |
|
2089 palette.setColor(QPalette::Link, QColor(24,81,132)); // color for the box around the ItemView indicator |
|
2090 |
|
2091 return palette; |
|
2092 } |
|
2093 |
|
2094 void QWindowsCEStyle::polish(QApplication *app) { |
|
2095 QWindowsStyle::polish(app); |
|
2096 } |
|
2097 |
|
2098 void QWindowsCEStyle::polish(QWidget *widget) { |
|
2099 QWindowsStyle::polish(widget); |
|
2100 } |
|
2101 |
|
2102 void QWindowsCEStyle::polish(QPalette &palette) { |
|
2103 QWindowsStyle::polish(palette); |
|
2104 } |
|
2105 |
|
2106 int QWindowsCEStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QWidget *widget) const { |
|
2107 int ret; |
|
2108 |
|
2109 switch (pm) { |
|
2110 case PM_DefaultFrameWidth: |
|
2111 ret = 1; |
|
2112 break; |
|
2113 |
|
2114 case PM_MenuBarHMargin: |
|
2115 ret = 2; |
|
2116 break; |
|
2117 case PM_MenuBarVMargin: |
|
2118 ret = 2; |
|
2119 break; |
|
2120 /*case PM_MenuBarItemSpacing: |
|
2121 ret = 2; |
|
2122 break;*/ |
|
2123 |
|
2124 case PM_MenuButtonIndicator: |
|
2125 ret = 10; |
|
2126 break; |
|
2127 |
|
2128 case PM_SpinBoxFrameWidth: |
|
2129 ret = 2; |
|
2130 break; |
|
2131 case PM_ButtonDefaultIndicator: |
|
2132 case PM_ButtonShiftHorizontal: |
|
2133 case PM_ButtonShiftVertical: |
|
2134 ret = 1; |
|
2135 break; |
|
2136 #ifndef QT_NO_TABBAR |
|
2137 case PM_TabBarTabShiftHorizontal: |
|
2138 ret = 0; |
|
2139 break; |
|
2140 case PM_TabBarTabShiftVertical: |
|
2141 ret = 6; |
|
2142 break; |
|
2143 #endif |
|
2144 case PM_MaximumDragDistance: |
|
2145 ret = 60; |
|
2146 break; |
|
2147 |
|
2148 case PM_IndicatorWidth: |
|
2149 ret = windowsCEIndicatorSize; |
|
2150 break; |
|
2151 |
|
2152 case PM_IndicatorHeight: |
|
2153 ret = windowsCEIndicatorSize; |
|
2154 break; |
|
2155 |
|
2156 case PM_ExclusiveIndicatorWidth: |
|
2157 ret = windowsCEExclusiveIndicatorSize; |
|
2158 break; |
|
2159 |
|
2160 case PM_ExclusiveIndicatorHeight: |
|
2161 ret = windowsCEExclusiveIndicatorSize;; |
|
2162 break; |
|
2163 |
|
2164 #ifndef QT_NO_SLIDER |
|
2165 case PM_SliderLength: |
|
2166 ret = 12; |
|
2167 break; |
|
2168 case PM_SliderThickness: |
|
2169 ret = windowsCESliderThickness; |
|
2170 break; |
|
2171 |
|
2172 case PM_TabBarScrollButtonWidth: |
|
2173 ret = 18; |
|
2174 break; |
|
2175 |
|
2176 // Returns the number of pixels to use for the business part of the |
|
2177 // slider (i.e., the non-tickmark portion). The remaining space is shared |
|
2178 // equally between the tickmark regions. |
|
2179 case PM_SliderControlThickness: |
|
2180 if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { |
|
2181 int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() : sl->rect.width(); |
|
2182 int ticks = sl->tickPosition; |
|
2183 int n = 0; |
|
2184 if (ticks & QSlider::TicksAbove) |
|
2185 ++n; |
|
2186 if (ticks & QSlider::TicksBelow) |
|
2187 ++n; |
|
2188 if (!n) { |
|
2189 ret = space; |
|
2190 break; |
|
2191 } |
|
2192 int thick = 12; |
|
2193 if (ticks != QSlider::TicksBothSides && ticks != QSlider::NoTicks) |
|
2194 thick += pixelMetric(PM_SliderLength, sl, widget) / 4; |
|
2195 |
|
2196 space -= thick; |
|
2197 if (space > 0) |
|
2198 thick += (space * 2) / (n + 2); |
|
2199 ret = thick; |
|
2200 } else { |
|
2201 ret = 0; |
|
2202 } |
|
2203 break; |
|
2204 #endif // QT_NO_SLIDER |
|
2205 |
|
2206 #ifndef QT_NO_MENU |
|
2207 |
|
2208 case PM_SmallIconSize: |
|
2209 ret = windowsCEIconSize; |
|
2210 break; |
|
2211 case PM_ButtonMargin: |
|
2212 ret = 6; |
|
2213 break; |
|
2214 |
|
2215 case PM_LargeIconSize: |
|
2216 ret = 32; |
|
2217 break; |
|
2218 |
|
2219 case PM_IconViewIconSize: |
|
2220 ret = pixelMetric(PM_LargeIconSize, opt, widget); |
|
2221 break; |
|
2222 |
|
2223 case PM_ToolBarIconSize: |
|
2224 ret = windowsCEIconSize; |
|
2225 break; |
|
2226 case PM_DockWidgetTitleMargin: |
|
2227 ret = 2; |
|
2228 break; |
|
2229 #if defined(Q_WS_WIN) |
|
2230 // case PM_DockWidgetFrameWidth: |
|
2231 // ret = GetSystemMetrics(SM_CXFRAME); |
|
2232 // break; |
|
2233 #else |
|
2234 case PM_DockWidgetFrameWidth: |
|
2235 ret = 4; |
|
2236 break; |
|
2237 #endif // Q_WS_WIN |
|
2238 break; |
|
2239 |
|
2240 #endif // QT_NO_MENU |
|
2241 |
|
2242 case PM_TitleBarHeight: |
|
2243 ret = 30; |
|
2244 break; |
|
2245 case PM_ScrollBarExtent: |
|
2246 ret = 19; |
|
2247 break; |
|
2248 case PM_SplitterWidth: |
|
2249 ret = qMax(4, QApplication::globalStrut().width()); |
|
2250 break; |
|
2251 |
|
2252 #if defined(Q_WS_WIN) |
|
2253 case PM_MDIFrameWidth: |
|
2254 ret = 3; |
|
2255 break; |
|
2256 #endif |
|
2257 case PM_ToolBarItemMargin: |
|
2258 ret = 1; |
|
2259 break; |
|
2260 case PM_ToolBarItemSpacing: |
|
2261 ret = 0; |
|
2262 break; |
|
2263 case PM_ToolBarHandleExtent: |
|
2264 ret = 10; |
|
2265 break; |
|
2266 case PM_ButtonIconSize: |
|
2267 ret = 22; |
|
2268 break; |
|
2269 default: |
|
2270 ret = QWindowsStyle::pixelMetric(pm, opt, widget); |
|
2271 break; |
|
2272 } |
|
2273 return ret; |
|
2274 } |
|
2275 |
|
2276 QPixmap QWindowsCEStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, |
|
2277 const QWidget *widget) const { |
|
2278 #ifndef QT_NO_IMAGEFORMAT_XPM |
|
2279 /*switch (standardPixmap) { |
|
2280 |
|
2281 default: |
|
2282 break; |
|
2283 }*/ |
|
2284 #endif //QT_NO_IMAGEFORMAT_XPM |
|
2285 return QWindowsStyle::standardPixmap(standardPixmap, opt, widget); |
|
2286 } |
|
2287 |
|
2288 int QWindowsCEStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *widget, |
|
2289 QStyleHintReturn *returnData) const { |
|
2290 int ret; |
|
2291 switch (hint) { |
|
2292 case SH_TabBar_ElideMode: |
|
2293 ret = Qt::ElideMiddle; |
|
2294 break; |
|
2295 case SH_EtchDisabledText: |
|
2296 ret = false; |
|
2297 case SH_RequestSoftwareInputPanel: |
|
2298 ret = RSIP_OnMouseClick; |
|
2299 break; |
|
2300 default: |
|
2301 ret = QWindowsStyle::styleHint(hint, opt, widget, returnData); |
|
2302 break; |
|
2303 } |
|
2304 return ret; |
|
2305 } |
|
2306 |
|
2307 void QWindowsCEStylePrivate::drawWinShades(QPainter *p, |
|
2308 int x, int y, int w, int h, |
|
2309 const QColor &c1, const QColor &c2, |
|
2310 const QColor &c3, const QColor &c4, |
|
2311 const QBrush *fill) { |
|
2312 if (w < 2 || h < 2) // can't do anything with that |
|
2313 return; |
|
2314 QPen oldPen = p->pen(); |
|
2315 QPoint a[3] = { QPoint(x, y+h-2), QPoint(x, y), QPoint(x+w-2, y) }; |
|
2316 p->setPen(c1); |
|
2317 p->drawPolyline(a, 3); |
|
2318 QPoint b[3] = { QPoint(x, y+h-1), QPoint(x+w-1, y+h-1), QPoint(x+w-1, y) }; |
|
2319 p->setPen(c2); |
|
2320 p->drawPolyline(b, 3); |
|
2321 if (w > 4 && h > 4) { |
|
2322 QPoint c[3] = { QPoint(x+1, y+h-3), QPoint(x+1, y+1), QPoint(x+w-3, y+1) }; |
|
2323 p->setPen(c3); |
|
2324 p->drawPolyline(c, 3); |
|
2325 QPoint d[3] = { QPoint(x+1, y+h-2), QPoint(x+w-2, y+h-2), QPoint(x+w-2, y+1) }; |
|
2326 p->setPen(c4); |
|
2327 p->drawPolyline(d, 3); |
|
2328 if (fill) |
|
2329 p->fillRect(QRect(x+2, y+2, w-4, h-4), *fill); |
|
2330 } |
|
2331 p->setPen(oldPen); |
|
2332 } |
|
2333 |
|
2334 void QWindowsCEStylePrivate::drawWinCEShades(QPainter *p, |
|
2335 int x, int y, int w, int h, |
|
2336 const QColor &c1, const QColor &c2, |
|
2337 const QColor &c3, const QColor &c4, |
|
2338 const QBrush *fill) { |
|
2339 if (w < 2 || h < 2) // can't do anything with that |
|
2340 return; |
|
2341 QPen oldPen = p->pen(); |
|
2342 QPoint b[3] = { QPoint(x, y+h-1), QPoint(x+w-1, y+h-1), QPoint(x+w-1, y) }; |
|
2343 p->setPen(c2); |
|
2344 p->drawPolyline(b, 3); |
|
2345 if (w > 4 && h > 4) { |
|
2346 QPoint c[3] = { QPoint(x+1, y+h-3), QPoint(x+1, y+1), QPoint(x+w-3, y+1) }; |
|
2347 p->setPen(c3); |
|
2348 p->drawPolyline(c, 3); |
|
2349 QPoint d[5] = { QPoint(x, y+h-2), QPoint(x+w-2, y+h-2), QPoint(x+w-2, y), QPoint(x, y), QPoint(x, y+h-2) }; |
|
2350 p->setPen(c4); |
|
2351 p->drawPolyline(d, 5); |
|
2352 if (fill) |
|
2353 p->fillRect(QRect(x+2, y+2, w-4, h-4), *fill); |
|
2354 } |
|
2355 QPoint a[3] = { QPoint(x+1, y+h-3), QPoint(x+1, y+1), QPoint(x+w-3, y+1) }; |
|
2356 p->setPen(c1); |
|
2357 p->drawPolyline(a, 3); |
|
2358 p->setPen(oldPen); |
|
2359 } |
|
2360 |
|
2361 void QWindowsCEStylePrivate::drawWinCEShadesSunken(QPainter *p, |
|
2362 int x, int y, int w, int h, |
|
2363 const QColor &c1, const QColor &c2, |
|
2364 const QColor &c3, const QColor &c4, |
|
2365 const QBrush *fill) { |
|
2366 if (w < 2 || h < 2) // can't do anything with that |
|
2367 return; |
|
2368 QPen oldPen = p->pen(); |
|
2369 |
|
2370 QPoint b[3] = { QPoint(x, y+h-1), QPoint(x+w-1, y+h-1), QPoint(x+w-1, y) }; |
|
2371 p->setPen(c2); |
|
2372 p->drawPolyline(b, 3); |
|
2373 if (w > 4 && h > 4) { |
|
2374 QPoint d[3] = { QPoint(x, y+h-2), QPoint(x+w-2, y+h-2), QPoint(x+w-2, y) }; |
|
2375 p->setPen(c4); |
|
2376 p->drawPolyline(d, 3); |
|
2377 QPoint c[3] = { QPoint(x, y+h-2), QPoint(x, y), QPoint(x+w-2, y) }; |
|
2378 p->setPen(c3); |
|
2379 p->drawPolyline(c, 3); |
|
2380 if (fill) |
|
2381 p->fillRect(QRect(x+2, y+2, w-4, h-4), *fill); |
|
2382 } |
|
2383 QPoint a[3] = { QPoint(x+1, y+h-3), QPoint(x+1, y+1), QPoint(x+w-3, y+1) }; |
|
2384 p->setPen(c1); |
|
2385 p->drawPolyline(a, 3); |
|
2386 p->setPen(oldPen); |
|
2387 } |
|
2388 |
|
2389 |
|
2390 void QWindowsCEStylePrivate::drawWinCEButton(QPainter *p, int x, int y, int w, int h, |
|
2391 const QPalette &pal, bool sunken, |
|
2392 const QBrush *fill) { |
|
2393 if (sunken) |
|
2394 drawWinCEShadesSunken(p, x, y, w, h, |
|
2395 pal.shadow().color(), pal.light().color(), pal.shadow().color(), |
|
2396 pal.midlight().color(), fill); |
|
2397 else |
|
2398 drawWinCEShades(p, x, y, w, h, |
|
2399 pal.midlight().color(), pal.shadow().color(), pal.button().color(), |
|
2400 pal.dark().color(), fill); |
|
2401 } |
|
2402 |
|
2403 void QWindowsCEStylePrivate::drawWinCEPanel(QPainter *p, int x, int y, int w, int h, |
|
2404 const QPalette &pal, bool sunken, |
|
2405 const QBrush *fill) { |
|
2406 if (sunken) |
|
2407 drawWinShades(p, x, y, w, h, |
|
2408 pal.dark().color(), pal.light().color(), pal.shadow().color(), |
|
2409 pal.midlight().color(), fill); |
|
2410 else |
|
2411 drawWinShades(p, x, y, w, h, |
|
2412 pal.light().color(), pal.shadow().color(), pal.button().color(), |
|
2413 pal.midlight().color(), fill); |
|
2414 } |
|
2415 |
|
2416 void QWindowsCEStylePrivate::drawWinCEButton(QPainter *p, const QRect &r, |
|
2417 const QPalette &pal, bool sunken, const QBrush *fill) { |
|
2418 drawWinCEButton(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill); |
|
2419 } |
|
2420 |
|
2421 void QWindowsCEStylePrivate::drawWinCEPanel(QPainter *p, const QRect &r, |
|
2422 const QPalette &pal, bool sunken, const QBrush *fill) { |
|
2423 drawWinCEPanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill); |
|
2424 } |
|
2425 |
|
2426 QT_END_NAMESPACE |
|
2427 |
|
2428 #endif // QT_NO_STYLE_WINDOWSCE |