Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qframe.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | - | |||||||
4 | - | |||||||
5 | QFramePrivate::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 | - | |||||||
16 | QFramePrivate::~QFramePrivate() | - | ||||||
17 | { | - | ||||||
18 | } | - | ||||||
19 | - | |||||||
20 | inline void QFramePrivate::init() | - | ||||||
21 | { | - | ||||||
22 | setLayoutItemMargins(QStyle::SE_FrameLayoutItem); | - | ||||||
23 | } never executed: end of block | 0 | ||||||
24 | QFrame::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 | - | |||||||
32 | QFrame::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 | ||||||
38 | void QFrame::initStyleOption(QStyleOptionFrame *option) const | - | ||||||
39 | { | - | ||||||
40 | if (!option
| 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: QFrame::Box:case QFrame::Box: never executed: case QFrame::Box: | 0 | ||||||
52 | case never executed: QFrame::HLine:case QFrame::HLine: never executed: case QFrame::HLine: | 0 | ||||||
53 | case never executed: QFrame::VLine:case QFrame::VLine: never executed: case QFrame::VLine: | 0 | ||||||
54 | case never executed: QFrame::StyledPanel:case QFrame::StyledPanel: never executed: case QFrame::StyledPanel: | 0 | ||||||
55 | case never executed: QFrame::Panel:case 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
| 0 | ||||||
67 | option->state |= QStyle::State_Sunken; never executed: option->state |= QStyle::State_Sunken; | 0 | ||||||
68 | else if (frameShadow == Raised
| 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 | - | |||||||
76 | QFrame::~QFrame() | - | ||||||
77 | { | - | ||||||
78 | } | - | ||||||
79 | int QFrame::frameStyle() const | - | ||||||
80 | { | - | ||||||
81 | const QFramePrivate * const d = d_func(); | - | ||||||
82 | return never executed: d->frameStyle;return d->frameStyle; never executed: return d->frameStyle; | 0 | ||||||
83 | } | - | ||||||
84 | QFrame::Shape QFrame::frameShape() const | - | ||||||
85 | { | - | ||||||
86 | const QFramePrivate * const d = d_func(); | - | ||||||
87 | return never executed: (Shape) (d->frameStyle & Shape_Mask);return (Shape) (d->frameStyle & Shape_Mask); never executed: return (Shape) (d->frameStyle & Shape_Mask); | 0 | ||||||
88 | } | - | ||||||
89 | - | |||||||
90 | void 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 | ||||||
95 | QFrame::Shadow QFrame::frameShadow() const | - | ||||||
96 | { | - | ||||||
97 | const QFramePrivate * const d = d_func(); | - | ||||||
98 | return never executed: (Shadow) (d->frameStyle & Shadow_Mask);return (Shadow) (d->frameStyle & Shadow_Mask); never executed: return (Shadow) (d->frameStyle & Shadow_Mask); | 0 | ||||||
99 | } | - | ||||||
100 | - | |||||||
101 | void 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 | ||||||
106 | void QFrame::setFrameStyle(int style) | - | ||||||
107 | { | - | ||||||
108 | QFramePrivate * const d = d_func(); | - | ||||||
109 | if (!testAttribute(Qt::WA_WState_OwnSizePolicy)
| 0 | ||||||
110 | QSizePolicy sp; | - | ||||||
111 | - | |||||||
112 | switch (style & Shape_Mask) { | - | ||||||
113 | case never executed: HLine:case 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: VLine:case 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 | ||||||
129 | void QFrame::setLineWidth(int w) | - | ||||||
130 | { | - | ||||||
131 | QFramePrivate * const d = d_func(); | - | ||||||
132 | if (short(w) == d->lineWidth
| 0 | ||||||
133 | return; never executed: return; | 0 | ||||||
134 | d->lineWidth = short(w); | - | ||||||
135 | d->updateFrameWidth(); | - | ||||||
136 | } never executed: end of block | 0 | ||||||
137 | - | |||||||
138 | int QFrame::lineWidth() const | - | ||||||
139 | { | - | ||||||
140 | const QFramePrivate * const d = d_func(); | - | ||||||
141 | return never executed: d->lineWidth;return d->lineWidth; never executed: return d->lineWidth; | 0 | ||||||
142 | } | - | ||||||
143 | void QFrame::setMidLineWidth(int w) | - | ||||||
144 | { | - | ||||||
145 | QFramePrivate * const d = d_func(); | - | ||||||
146 | if (short(w) == d->midLineWidth
| 0 | ||||||
147 | return; never executed: return; | 0 | ||||||
148 | d->midLineWidth = short(w); | - | ||||||
149 | d->updateFrameWidth(); | - | ||||||
150 | } never executed: end of block | 0 | ||||||
151 | - | |||||||
152 | int QFrame::midLineWidth() const | - | ||||||
153 | { | - | ||||||
154 | const QFramePrivate * const d = d_func(); | - | ||||||
155 | return never executed: d->midLineWidth;return d->midLineWidth; never executed: return d->midLineWidth; | 0 | ||||||
156 | } | - | ||||||
157 | - | |||||||
158 | - | |||||||
159 | - | |||||||
160 | - | |||||||
161 | - | |||||||
162 | void 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 | - | |||||||
182 | void 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 | ||||||
190 | int QFrame::frameWidth() const | - | ||||||
191 | { | - | ||||||
192 | const QFramePrivate * const d = d_func(); | - | ||||||
193 | return never executed: d->frameWidth;return d->frameWidth; never executed: return d->frameWidth; | 0 | ||||||
194 | } | - | ||||||
195 | QRect 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: fr;return fr; never executed: return fr; | 0 | ||||||
201 | } | - | ||||||
202 | - | |||||||
203 | void QFrame::setFrameRect(const QRect &r) | - | ||||||
204 | { | - | ||||||
205 | QFramePrivate * const d = d_func(); | - | ||||||
206 | QRect cr = r.isValid()
| 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 | - | |||||||
213 | QSize QFrame::sizeHint() const | - | ||||||
214 | { | - | ||||||
215 | const QFramePrivate * const d = d_func(); | - | ||||||
216 | - | |||||||
217 | - | |||||||
218 | - | |||||||
219 | switch (d->frameStyle & Shape_Mask) { | - | ||||||
220 | case never executed: HLine:case HLine: never executed: case HLine: | 0 | ||||||
221 | return never executed: QSize(-1,3);return QSize(-1,3); never executed: return QSize(-1,3); | 0 | ||||||
222 | case never executed: VLine:case VLine: never executed: case VLine: | 0 | ||||||
223 | return never executed: QSize(3,-1);return QSize(3,-1); never executed: return QSize(3,-1); | 0 | ||||||
224 | default never executed: :default: never executed: default: | 0 | ||||||
225 | return never executed: QWidget::sizeHint();return QWidget::sizeHint(); never executed: return QWidget::sizeHint(); | 0 | ||||||
226 | } | - | ||||||
227 | } | - | ||||||
228 | - | |||||||
229 | - | |||||||
230 | - | |||||||
231 | - | |||||||
232 | void QFrame::paintEvent(QPaintEvent *) | - | ||||||
233 | { | - | ||||||
234 | QPainter paint(this); | - | ||||||
235 | drawFrame(&paint); | - | ||||||
236 | } never executed: end of block | 0 | ||||||
237 | - | |||||||
238 | - | |||||||
239 | - | |||||||
240 | - | |||||||
241 | - | |||||||
242 | - | |||||||
243 | void 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 | - | |||||||
253 | void QFrame::changeEvent(QEvent *ev) | - | ||||||
254 | { | - | ||||||
255 | QFramePrivate * const d = d_func(); | - | ||||||
256 | if (ev->type() == QEvent::StyleChange
| 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 | - | |||||||
266 | bool QFrame::event(QEvent *e) | - | ||||||
267 | { | - | ||||||
268 | if (e->type() == QEvent::ParentChange
| 0 | ||||||
269 | d_func()->updateFrameWidth(); never executed: d_func()->updateFrameWidth(); | 0 | ||||||
270 | bool result = QWidget::event(e); | - | ||||||
271 | - | |||||||
272 | if (e->type() == QEvent::Polish
| 0 | ||||||
273 | d_func()->updateFrameWidth(); never executed: d_func()->updateFrameWidth(); | 0 | ||||||
274 | return never executed: result;return result; never executed: return result; | 0 | ||||||
275 | } | - | ||||||
276 | - | |||||||
277 | - | |||||||
278 | - | |||||||
Switch to Source code | Preprocessed file |