qstyle.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/styles/qstyle.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8static const int MaxBits = 8 * sizeof(QSizePolicy::ControlType);-
9-
10static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::ControlType *array)-
11{-
12 if (!controls
!controlsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
13 return
never executed: return 0;
0;
never executed: return 0;
0
14-
15-
16 if ((
(controls & (c...ols - 1)) == 0Description
TRUEnever evaluated
FALSEnever evaluated
controls & (controls - 1)) == 0
(controls & (c...ols - 1)) == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
17 array[0] = QSizePolicy::ControlType(uint(controls));-
18 return
never executed: return 1;
1;
never executed: return 1;
0
19 }-
20-
21 int count = 0;-
22 for (int i = 0; i < MaxBits
i < MaxBitsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
23 if (uint bit = (controls & (0x1 << i))
uint bit = (co... & (0x1 << i))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
24 array[count++] = QSizePolicy::ControlType(bit);
never executed: array[count++] = QSizePolicy::ControlType(bit);
0
25 }
never executed: end of block
0
26 return
never executed: return count;
count;
never executed: return count;
0
27}-
28QStyle::QStyle()-
29 : QObject(*new QStylePrivate)-
30{-
31 QStylePrivate * const d = d_func();-
32 d->proxyStyle = this;-
33}
never executed: end of block
0
34-
35-
36-
37-
38-
39-
40QStyle::QStyle(QStylePrivate &dd)-
41 : QObject(dd)-
42{-
43 QStylePrivate * const d = d_func();-
44 d->proxyStyle = this;-
45}
never executed: end of block
0
46-
47-
48-
49-
50QStyle::~QStyle()-
51{-
52}-
53void QStyle::polish(QWidget * )-
54{-
55}-
56void QStyle::unpolish(QWidget * )-
57{-
58}-
59-
60-
61-
62-
63-
64-
65-
66void QStyle::polish(QApplication * )-
67{-
68}-
69-
70-
71-
72-
73-
74-
75-
76void QStyle::unpolish(QApplication * )-
77{-
78}-
79void QStyle::polish(QPalette & )-
80{-
81}-
82QRect QStyle::itemTextRect(const QFontMetrics &metrics, const QRect &rect, int alignment, bool enabled,-
83 const QString &text) const-
84{-
85 QRect result;-
86 int x, y, w, h;-
87 rect.getRect(&x, &y, &w, &h);-
88 if (!text.isEmpty()
!text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
89 result = metrics.boundingRect(x, y, w, h, alignment, text);-
90 if (!enabled
!enabledDescription
TRUEnever evaluated
FALSEnever evaluated
&& proxy()->styleHint(SH_EtchDisabledText)
proxy()->style...hDisabledText)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
91 result.setWidth(result.width()+1);-
92 result.setHeight(result.height()+1);-
93 }
never executed: end of block
0
94 }
never executed: end of block
else {
0
95 result = QRect(x, y, w, h);-
96 }
never executed: end of block
0
97 return
never executed: return result;
result;
never executed: return result;
0
98}-
99-
100-
101-
102-
103-
104-
105-
106QRect QStyle::itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pixmap) const-
107{-
108 QRect result;-
109 int x, y, w, h;-
110 rect.getRect(&x, &y, &w, &h);-
111-
112 const int pixmapWidth = pixmap.width()/pixmap.devicePixelRatio();-
113 const int pixmapHeight = pixmap.height()/pixmap.devicePixelRatio();-
114-
115 if ((
(alignment & Q...::AlignVCenterDescription
TRUEnever evaluated
FALSEnever evaluated
alignment & Qt::AlignVCenter) == Qt::AlignVCenter
(alignment & Q...::AlignVCenterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
116 y += h/2 - pixmapHeight/2;
never executed: y += h/2 - pixmapHeight/2;
0
117 else if ((
(alignment & Q...t::AlignBottomDescription
TRUEnever evaluated
FALSEnever evaluated
alignment & Qt::AlignBottom) == Qt::AlignBottom
(alignment & Q...t::AlignBottomDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
118 y += h - pixmapHeight;
never executed: y += h - pixmapHeight;
0
119 if ((
(alignment & Q...Qt::AlignRightDescription
TRUEnever evaluated
FALSEnever evaluated
alignment & Qt::AlignRight) == Qt::AlignRight
(alignment & Q...Qt::AlignRightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
120 x += w - pixmapWidth;
never executed: x += w - pixmapWidth;
0
121 else if ((
(alignment & Q...::AlignHCenterDescription
TRUEnever evaluated
FALSEnever evaluated
alignment & Qt::AlignHCenter) == Qt::AlignHCenter
(alignment & Q...::AlignHCenterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
122 x += w/2 - pixmapWidth/2;
never executed: x += w/2 - pixmapWidth/2;
0
123 else if ((
(alignment & Q... Qt::AlignLeftDescription
TRUEnever evaluated
FALSEnever evaluated
alignment & Qt::AlignLeft) != Qt::AlignLeft
(alignment & Q... Qt::AlignLeftDescription
TRUEnever evaluated
FALSEnever evaluated
&& QApplication::isRightToLeft()
QApplication::isRightToLeft()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
124 x += w - pixmapWidth;
never executed: x += w - pixmapWidth;
0
125 result = QRect(x, y, pixmapWidth, pixmapHeight);-
126 return
never executed: return result;
result;
never executed: return result;
0
127}-
128void QStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,-
129 bool enabled, const QString& text, QPalette::ColorRole textRole) const-
130{-
131 if (text.isEmpty()
text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
132 return;
never executed: return;
0
133 QPen savedPen;-
134 if (textRole != QPalette::NoRole
textRole != QPalette::NoRoleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
135 savedPen = painter->pen();-
136 painter->setPen(QPen(pal.brush(textRole), savedPen.widthF()));-
137 }
never executed: end of block
0
138 if (!enabled
!enabledDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
139 if (proxy()->styleHint(SH_DitherDisabledText)
proxy()->style...rDisabledText)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
140 QRect br;-
141 painter->drawText(rect, alignment, text, &br);-
142 painter->fillRect(br, QBrush(painter->background().color(), Qt::Dense5Pattern));-
143 return;
never executed: return;
0
144 } else if (proxy()->styleHint(SH_EtchDisabledText)
proxy()->style...hDisabledText)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
145 QPen pen = painter->pen();-
146 painter->setPen(pal.light().color());-
147 painter->drawText(rect.adjusted(1, 1, 1, 1), alignment, text);-
148 painter->setPen(pen);-
149 }
never executed: end of block
0
150 }
never executed: end of block
0
151 painter->drawText(rect, alignment, text);-
152 if (textRole != QPalette::NoRole
textRole != QPalette::NoRoleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
153 painter->setPen(savedPen);
never executed: painter->setPen(savedPen);
0
154}
never executed: end of block
0
155void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,-
156 const QPixmap &pixmap) const-
157{-
158 qreal scale = pixmap.devicePixelRatio();-
159 QRect aligned = alignedRect(QApplication::layoutDirection(), QFlag(alignment), pixmap.size() / scale, rect);-
160 QRect inter = aligned.intersected(rect);-
161-
162 painter->drawPixmap(inter.x(), inter.y(), pixmap, inter.x() - aligned.x(), inter.y() - aligned.y(), inter.width() * scale, inter.height() *scale);-
163}
never executed: end of block
0
164QRect QStyle::visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)-
165{-
166 if (direction == Qt::LeftToRight
direction == Qt::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
167 return
never executed: return logicalRect;
logicalRect;
never executed: return logicalRect;
0
168 QRect rect = logicalRect;-
169 rect.translate(2 * (boundingRect.right() - logicalRect.right()) +-
170 logicalRect.width() - boundingRect.width(), 0);-
171 return
never executed: return rect;
rect;
never executed: return rect;
0
172}-
173QPoint QStyle::visualPos(Qt::LayoutDirection direction, const QRect &boundingRect, const QPoint &logicalPos)-
174{-
175 if (direction == Qt::LeftToRight
direction == Qt::LeftToRightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
176 return
never executed: return logicalPos;
logicalPos;
never executed: return logicalPos;
0
177 return
never executed: return QPoint(boundingRect.right() - logicalPos.x(), logicalPos.y());
QPoint(boundingRect.right() - logicalPos.x(), logicalPos.y());
never executed: return QPoint(boundingRect.right() - logicalPos.x(), logicalPos.y());
0
178}-
179-
180-
181-
182-
183-
184QRect QStyle::alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment, const QSize &size, const QRect &rectangle)-
185{-
186 alignment = visualAlignment(direction, alignment);-
187 int x = rectangle.x();-
188 int y = rectangle.y();-
189 int w = size.width();-
190 int h = size.height();-
191 if ((
(alignment & Q...::AlignVCenterDescription
TRUEnever evaluated
FALSEnever evaluated
alignment & Qt::AlignVCenter) == Qt::AlignVCenter
(alignment & Q...::AlignVCenterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
192 y += rectangle.size().height()/2 - h/2;
never executed: y += rectangle.size().height()/2 - h/2;
0
193 else if ((
(alignment & Q...t::AlignBottomDescription
TRUEnever evaluated
FALSEnever evaluated
alignment & Qt::AlignBottom) == Qt::AlignBottom
(alignment & Q...t::AlignBottomDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
194 y += rectangle.size().height() - h;
never executed: y += rectangle.size().height() - h;
0
195 if ((
(alignment & Q...Qt::AlignRightDescription
TRUEnever evaluated
FALSEnever evaluated
alignment & Qt::AlignRight) == Qt::AlignRight
(alignment & Q...Qt::AlignRightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
196 x += rectangle.size().width() - w;
never executed: x += rectangle.size().width() - w;
0
197 else if ((
(alignment & Q...::AlignHCenterDescription
TRUEnever evaluated
FALSEnever evaluated
alignment & Qt::AlignHCenter) == Qt::AlignHCenter
(alignment & Q...::AlignHCenterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
198 x += rectangle.size().width()/2 - w/2;
never executed: x += rectangle.size().width()/2 - w/2;
0
199 return
never executed: return QRect(x, y, w, h);
QRect(x, y, w, h);
never executed: return QRect(x, y, w, h);
0
200}-
201Qt::Alignment QStyle::visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)-
202{-
203 return
never executed: return QGuiApplicationPrivate::visualAlignment(direction, alignment);
QGuiApplicationPrivate::visualAlignment(direction, alignment);
never executed: return QGuiApplicationPrivate::visualAlignment(direction, alignment);
0
204}-
205int QStyle::sliderPositionFromValue(int min, int max, int logicalValue, int span, bool upsideDown)-
206{-
207 if (span <= 0
span <= 0Description
TRUEnever evaluated
FALSEnever evaluated
|| logicalValue < min
logicalValue < minDescription
TRUEnever evaluated
FALSEnever evaluated
|| max <= min
max <= minDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
208 return
never executed: return 0;
0;
never executed: return 0;
0
209 if (logicalValue > max
logicalValue > maxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
210 return
never executed: return upsideDown ? span : min;
upsideDown ? span : min;
never executed: return upsideDown ? span : min;
0
211-
212 uint range = max - min;-
213 uint p = upsideDown
upsideDownDescription
TRUEnever evaluated
FALSEnever evaluated
? max - logicalValue : logicalValue - min;
0
214-
215 if (range > (uint)2147483647/4096
range > (uint)2147483647/4096Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
216 double dpos = (double(p))/(double(range)/span);-
217 return
never executed: return int(dpos);
int(dpos);
never executed: return int(dpos);
0
218 } else if (range > (uint)span
range > (uint)spanDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
219 return
never executed: return (2 * p * span + range) / (2*range);
(2 * p * span + range) / (2*range);
never executed: return (2 * p * span + range) / (2*range);
0
220 } else {-
221 uint div = span / range;-
222 uint mod = span % range;-
223 return
never executed: return p * div + (2 * p * mod + range) / (2 * range);
p * div + (2 * p * mod + range) / (2 * range);
never executed: return p * div + (2 * p * mod + range) / (2 * range);
0
224 }-
225-
226-
227-
228}-
229int QStyle::sliderValueFromPosition(int min, int max, int pos, int span, bool upsideDown)-
230{-
231 if (span <= 0
span <= 0Description
TRUEnever evaluated
FALSEnever evaluated
|| pos <= 0
pos <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
232 return
never executed: return upsideDown ? max : min;
upsideDown ? max : min;
never executed: return upsideDown ? max : min;
0
233 if (pos >= span
pos >= spanDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
234 return
never executed: return upsideDown ? min : max;
upsideDown ? min : max;
never executed: return upsideDown ? min : max;
0
235-
236 uint range = max - min;-
237-
238 if ((
(uint)span > rangeDescription
TRUEnever evaluated
FALSEnever evaluated
uint)span > range
(uint)span > rangeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
239 int tmp = (2 * pos * range + span) / (2 * span);-
240 return
never executed: return upsideDown ? max - tmp : tmp + min;
upsideDown ? max - tmp : tmp + min;
never executed: return upsideDown ? max - tmp : tmp + min;
0
241 } else {-
242 uint div = range / span;-
243 uint mod = range % span;-
244 int tmp = pos * div + (2 * pos * mod + span) / (2 * span);-
245 return
never executed: return upsideDown ? max - tmp : tmp + min;
upsideDown ? max - tmp : tmp + min;
never executed: return upsideDown ? max - tmp : tmp + min;
0
246 }-
247-
248-
249-
250}-
251QPalette QStyle::standardPalette() const-
252{-
253 QColor background = QColor(0xd4, 0xd0, 0xc8);-
254-
255 QColor light(background.lighter());-
256 QColor dark(background.darker());-
257 QColor mid(Qt::gray);-
258 QPalette palette(Qt::black, background, light, dark, mid, Qt::black, Qt::white);-
259 palette.setBrush(QPalette::Disabled, QPalette::WindowText, dark);-
260 palette.setBrush(QPalette::Disabled, QPalette::Text, dark);-
261 palette.setBrush(QPalette::Disabled, QPalette::ButtonText, dark);-
262 palette.setBrush(QPalette::Disabled, QPalette::Base, background);-
263 return
never executed: return palette;
palette;
never executed: return palette;
0
264}-
265int QStyle::combinedLayoutSpacing(QSizePolicy::ControlTypes controls1,-
266 QSizePolicy::ControlTypes controls2, Qt::Orientation orientation,-
267 QStyleOption *option, QWidget *widget) const-
268{-
269 QSizePolicy::ControlType array1[MaxBits];-
270 QSizePolicy::ControlType array2[MaxBits];-
271 int count1 = unpackControlTypes(controls1, array1);-
272 int count2 = unpackControlTypes(controls2, array2);-
273 int result = -1;-
274-
275 for (int i = 0; i < count1
i < count1Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
276 for (int j = 0; j < count2
j < count2Description
TRUEnever evaluated
FALSEnever evaluated
; ++j) {
0
277 int spacing = layoutSpacing(array1[i], array2[j], orientation, option, widget);-
278 result = qMax(spacing, result);-
279 }
never executed: end of block
0
280 }
never executed: end of block
0
281 return
never executed: return result;
result;
never executed: return result;
0
282}-
283-
284-
285-
286-
287-
288-
289-
290QDebug operator<<(QDebug debug, QStyle::State state)-
291{-
292-
293 return
never executed: return operator<< <QStyle::StateFlag>(debug, state);
operator<< <QStyle::StateFlag>(debug, state);
never executed: return operator<< <QStyle::StateFlag>(debug, state);
0
294-
295-
296-
297-
298}-
299const QStyle * QStyle::proxy() const-
300{-
301 const QStylePrivate * const d = d_func();-
302 return
never executed: return d->proxyStyle;
d->proxyStyle;
never executed: return d->proxyStyle;
0
303}-
304-
305-
306-
307-
308-
309-
310void QStyle::setProxy(QStyle *style)-
311{-
312 QStylePrivate * const d = d_func();-
313 d->proxyStyle = style;-
314}
never executed: end of block
0
315-
316-
317-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9