qframe.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qframe.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5QFramePrivate::QFramePrivate()-
6 : frect(0, 0, 0, 0),-
7 frameStyle(QFrame::NoFrame | QFrame::Plain),-
8 lineWidth(1),-
9 midLineWidth(0),-
10 frameWidth(0),-
11 leftFrameWidth(0), rightFrameWidth(0),-
12 topFrameWidth(0), bottomFrameWidth(0)-
13{-
14}
never executed: end of block
0
15-
16QFramePrivate::~QFramePrivate()-
17{-
18}-
19-
20inline void QFramePrivate::init()-
21{-
22 setLayoutItemMargins(QStyle::SE_FrameLayoutItem);-
23}
never executed: end of block
0
24QFrame::QFrame(QWidget* parent, Qt::WindowFlags f)-
25 : QWidget(*new QFramePrivate, parent, f)-
26{-
27 QFramePrivate * const d = d_func();-
28 d->init();-
29}
never executed: end of block
0
30-
31-
32QFrame::QFrame(QFramePrivate &dd, QWidget* parent, Qt::WindowFlags f)-
33 : QWidget(dd, parent, f)-
34{-
35 QFramePrivate * const d = d_func();-
36 d->init();-
37}
never executed: end of block
0
38void QFrame::initStyleOption(QStyleOptionFrame *option) const-
39{-
40 if (!option
!optionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
41 return;
never executed: return;
0
42-
43 const QFramePrivate * const d = d_func();-
44 option->initFrom(this);-
45-
46 int frameShape = d->frameStyle & QFrame::Shape_Mask;-
47 int frameShadow = d->frameStyle & QFrame::Shadow_Mask;-
48 option->frameShape = Shape(int(option->frameShape) | frameShape);-
49 option->rect = frameRect();-
50 switch (frameShape) {-
51 case
never executed: case QFrame::Box:
QFrame::Box:
never executed: case QFrame::Box:
0
52 case
never executed: case QFrame::HLine:
QFrame::HLine:
never executed: case QFrame::HLine:
0
53 case
never executed: case QFrame::VLine:
QFrame::VLine:
never executed: case QFrame::VLine:
0
54 case
never executed: case QFrame::StyledPanel:
QFrame::StyledPanel:
never executed: case QFrame::StyledPanel:
0
55 case
never executed: case QFrame::Panel:
QFrame::Panel:
never executed: case QFrame::Panel:
0
56 option->lineWidth = d->lineWidth;-
57 option->midLineWidth = d->midLineWidth;-
58 break;
never executed: break;
0
59 default
never executed: default:
:
never executed: default:
0
60-
61-
62 option->lineWidth = d->frameWidth;-
63 break;
never executed: break;
0
64 }-
65-
66 if (frameShadow == Sunken
frameShadow == SunkenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
67 option->state |= QStyle::State_Sunken;
never executed: option->state |= QStyle::State_Sunken;
0
68 else if (frameShadow == Raised
frameShadow == RaisedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
69 option->state |= QStyle::State_Raised;
never executed: option->state |= QStyle::State_Raised;
0
70}
never executed: end of block
0
71-
72-
73-
74-
75-
76QFrame::~QFrame()-
77{-
78}-
79int QFrame::frameStyle() const-
80{-
81 const QFramePrivate * const d = d_func();-
82 return
never executed: return d->frameStyle;
d->frameStyle;
never executed: return d->frameStyle;
0
83}-
84QFrame::Shape QFrame::frameShape() const-
85{-
86 const QFramePrivate * const d = d_func();-
87 return
never executed: return (Shape) (d->frameStyle & Shape_Mask);
(Shape) (d->frameStyle & Shape_Mask);
never executed: return (Shape) (d->frameStyle & Shape_Mask);
0
88}-
89-
90void QFrame::setFrameShape(QFrame::Shape s)-
91{-
92 QFramePrivate * const d = d_func();-
93 setFrameStyle((d->frameStyle & Shadow_Mask) | s);-
94}
never executed: end of block
0
95QFrame::Shadow QFrame::frameShadow() const-
96{-
97 const QFramePrivate * const d = d_func();-
98 return
never executed: return (Shadow) (d->frameStyle & Shadow_Mask);
(Shadow) (d->frameStyle & Shadow_Mask);
never executed: return (Shadow) (d->frameStyle & Shadow_Mask);
0
99}-
100-
101void QFrame::setFrameShadow(QFrame::Shadow s)-
102{-
103 QFramePrivate * const d = d_func();-
104 setFrameStyle((d->frameStyle & Shape_Mask) | s);-
105}
never executed: end of block
0
106void QFrame::setFrameStyle(int style)-
107{-
108 QFramePrivate * const d = d_func();-
109 if (!testAttribute(Qt::WA_WState_OwnSizePolicy)
!testAttribute...OwnSizePolicy)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
110 QSizePolicy sp;-
111-
112 switch (style & Shape_Mask) {-
113 case
never executed: case HLine:
HLine:
never executed: case HLine:
0
114 sp = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed, QSizePolicy::Line);-
115 break;
never executed: break;
0
116 case
never executed: case VLine:
VLine:
never executed: case VLine:
0
117 sp = QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum, QSizePolicy::Line);-
118 break;
never executed: break;
0
119 default
never executed: default:
:
never executed: default:
0
120 sp = QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, QSizePolicy::Frame);-
121 }
never executed: end of block
0
122 setSizePolicy(sp);-
123 setAttribute(Qt::WA_WState_OwnSizePolicy, false);-
124 }
never executed: end of block
0
125 d->frameStyle = (short)style;-
126 update();-
127 d->updateFrameWidth();-
128}
never executed: end of block
0
129void QFrame::setLineWidth(int w)-
130{-
131 QFramePrivate * const d = d_func();-
132 if (short(w) == d->lineWidth
short(w) == d->lineWidthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
133 return;
never executed: return;
0
134 d->lineWidth = short(w);-
135 d->updateFrameWidth();-
136}
never executed: end of block
0
137-
138int QFrame::lineWidth() const-
139{-
140 const QFramePrivate * const d = d_func();-
141 return
never executed: return d->lineWidth;
d->lineWidth;
never executed: return d->lineWidth;
0
142}-
143void QFrame::setMidLineWidth(int w)-
144{-
145 QFramePrivate * const d = d_func();-
146 if (short(w) == d->midLineWidth
short(w) == d->midLineWidthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
147 return;
never executed: return;
0
148 d->midLineWidth = short(w);-
149 d->updateFrameWidth();-
150}
never executed: end of block
0
151-
152int QFrame::midLineWidth() const-
153{-
154 const QFramePrivate * const d = d_func();-
155 return
never executed: return d->midLineWidth;
d->midLineWidth;
never executed: return d->midLineWidth;
0
156}-
157-
158-
159-
160-
161-
162void QFramePrivate::updateStyledFrameWidths()-
163{-
164 const QFrame * const q = q_func();-
165 QStyleOptionFrame opt;-
166 q->initStyleOption(&opt);-
167-
168 QRect cr = q->style()->subElementRect(QStyle::SE_ShapedFrameContents, &opt, q);-
169 leftFrameWidth = cr.left() - opt.rect.left();-
170 topFrameWidth = cr.top() - opt.rect.top();-
171 rightFrameWidth = opt.rect.right() - cr.right(),-
172 bottomFrameWidth = opt.rect.bottom() - cr.bottom();-
173 frameWidth = qMax(qMax(leftFrameWidth, rightFrameWidth),-
174 qMax(topFrameWidth, bottomFrameWidth));-
175}
never executed: end of block
0
176-
177-
178-
179-
180-
181-
182void QFramePrivate::updateFrameWidth()-
183{-
184 QFrame * const q = q_func();-
185 QRect fr = q->frameRect();-
186 updateStyledFrameWidths();-
187 q->setFrameRect(fr);-
188 setLayoutItemMargins(QStyle::SE_FrameLayoutItem);-
189}
never executed: end of block
0
190int QFrame::frameWidth() const-
191{-
192 const QFramePrivate * const d = d_func();-
193 return
never executed: return d->frameWidth;
d->frameWidth;
never executed: return d->frameWidth;
0
194}-
195QRect QFrame::frameRect() const-
196{-
197 const QFramePrivate * const d = d_func();-
198 QRect fr = contentsRect();-
199 fr.adjust(-d->leftFrameWidth, -d->topFrameWidth, d->rightFrameWidth, d->bottomFrameWidth);-
200 return
never executed: return fr;
fr;
never executed: return fr;
0
201}-
202-
203void QFrame::setFrameRect(const QRect &r)-
204{-
205 QFramePrivate * const d = d_func();-
206 QRect cr = r.isValid()
r.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
? r : rect();
0
207 cr.adjust(d->leftFrameWidth, d->topFrameWidth, -d->rightFrameWidth, -d->bottomFrameWidth);-
208 setContentsMargins(cr.left(), cr.top(), rect().right() - cr.right(), rect().bottom() - cr.bottom());-
209}
never executed: end of block
0
210-
211-
212-
213QSize QFrame::sizeHint() const-
214{-
215 const QFramePrivate * const d = d_func();-
216-
217-
218-
219 switch (d->frameStyle & Shape_Mask) {-
220 case
never executed: case HLine:
HLine:
never executed: case HLine:
0
221 return
never executed: return QSize(-1,3);
QSize(-1,3);
never executed: return QSize(-1,3);
0
222 case
never executed: case VLine:
VLine:
never executed: case VLine:
0
223 return
never executed: return QSize(3,-1);
QSize(3,-1);
never executed: return QSize(3,-1);
0
224 default
never executed: default:
:
never executed: default:
0
225 return
never executed: return QWidget::sizeHint();
QWidget::sizeHint();
never executed: return QWidget::sizeHint();
0
226 }-
227}-
228-
229-
230-
231-
232void QFrame::paintEvent(QPaintEvent *)-
233{-
234 QPainter paint(this);-
235 drawFrame(&paint);-
236}
never executed: end of block
0
237-
238-
239-
240-
241-
242-
243void QFrame::drawFrame(QPainter *p)-
244{-
245 QStyleOptionFrame opt;-
246 initStyleOption(&opt);-
247 style()->drawControl(QStyle::CE_ShapedFrame, &opt, p, this);-
248}
never executed: end of block
0
249-
250-
251-
252-
253void QFrame::changeEvent(QEvent *ev)-
254{-
255 QFramePrivate * const d = d_func();-
256 if (ev->type() == QEvent::StyleChange
ev->type() == ...t::StyleChangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
257-
258-
259-
260 )-
261 d->updateFrameWidth();
never executed: d->updateFrameWidth();
0
262 QWidget::changeEvent(ev);-
263}
never executed: end of block
0
264-
265-
266bool QFrame::event(QEvent *e)-
267{-
268 if (e->type() == QEvent::ParentChange
e->type() == Q...::ParentChangeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
269 d_func()->updateFrameWidth();
never executed: d_func()->updateFrameWidth();
0
270 bool result = QWidget::event(e);-
271-
272 if (e->type() == QEvent::Polish
e->type() == QEvent::PolishDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
273 d_func()->updateFrameWidth();
never executed: d_func()->updateFrameWidth();
0
274 return
never executed: return result;
result;
never executed: return result;
0
275}-
276-
277-
278-
Switch to Source codePreprocessed file

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