| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include "qframe.h" | - |
| 43 | #include "qbitmap.h" | - |
| 44 | #include "qdrawutil.h" | - |
| 45 | #include "qevent.h" | - |
| 46 | #include "qpainter.h" | - |
| 47 | #include "qstyle.h" | - |
| 48 | #include "qstyleoption.h" | - |
| 49 | #include "qapplication.h" | - |
| 50 | | - |
| 51 | #include "qframe_p.h" | - |
| 52 | | - |
| 53 | QT_BEGIN_NAMESPACE | - |
| 54 | | - |
| 55 | QFramePrivate::QFramePrivate() | - |
| 56 | : frect(QRect(0, 0, 0, 0)), | - |
| 57 | frameStyle(QFrame::NoFrame | QFrame::Plain), | - |
| 58 | lineWidth(1), | - |
| 59 | midLineWidth(0), | - |
| 60 | frameWidth(0), | - |
| 61 | leftFrameWidth(0), rightFrameWidth(0), | - |
| 62 | topFrameWidth(0), bottomFrameWidth(0) | - |
| 63 | { | - |
| 64 | } executed: }Execution Count:7245 | 7245 |
| 65 | | - |
| 66 | inline void QFramePrivate::init() | - |
| 67 | { | - |
| 68 | setLayoutItemMargins(QStyle::SE_FrameLayoutItem); executed (the execution status of this line is deduced): setLayoutItemMargins(QStyle::SE_FrameLayoutItem); | - |
| 69 | } executed: }Execution Count:7245 | 7245 |
| 70 | | - |
| 71 | /*! | - |
| 72 | \class QFrame | - |
| 73 | \brief The QFrame class is the base class of widgets that can have a frame. | - |
| 74 | | - |
| 75 | \ingroup abstractwidgets | - |
| 76 | \inmodule QtWidgets | - |
| 77 | | - |
| 78 | QMenu uses this to "raise" the menu above the surrounding | - |
| 79 | screen. QProgressBar has a "sunken" look. QLabel has a flat look. | - |
| 80 | The frames of widgets like these can be changed. | - |
| 81 | | - |
| 82 | \snippet code/src_gui_widgets_qframe.cpp 0 | - |
| 83 | | - |
| 84 | The QFrame class can also be used directly for creating simple | - |
| 85 | placeholder frames without any contents. | - |
| 86 | | - |
| 87 | The frame style is specified by a \l{QFrame::Shape}{frame shape} and | - |
| 88 | a \l{QFrame::Shadow}{shadow style} that is used to visually separate | - |
| 89 | the frame from surrounding widgets. These properties can be set | - |
| 90 | together using the setFrameStyle() function and read with frameStyle(). | - |
| 91 | | - |
| 92 | The frame shapes are \l NoFrame, \l Box, \l Panel, \l StyledPanel, | - |
| 93 | HLine and \l VLine; the shadow styles are \l Plain, \l Raised and | - |
| 94 | \l Sunken. | - |
| 95 | | - |
| 96 | A frame widget has three attributes that describe the thickness of the | - |
| 97 | border: \l lineWidth, \l midLineWidth, and \l frameWidth. | - |
| 98 | | - |
| 99 | \list | - |
| 100 | \li The line width is the width of the frame border. It can be modified | - |
| 101 | to customize the frame's appearance. | - |
| 102 | | - |
| 103 | \li The mid-line width specifies the width of an extra line in the | - |
| 104 | middle of the frame, which uses a third color to obtain a special | - |
| 105 | 3D effect. Notice that a mid-line is only drawn for \l Box, \l | - |
| 106 | HLine and \l VLine frames that are raised or sunken. | - |
| 107 | | - |
| 108 | \li The frame width is determined by the frame style, and the frameWidth() | - |
| 109 | function is used to obtain the value defined for the style used. | - |
| 110 | \endlist | - |
| 111 | | - |
| 112 | The margin between the frame and the contents of the frame can be | - |
| 113 | customized with the QWidget::setContentsMargins() function. | - |
| 114 | | - |
| 115 | \target picture | - |
| 116 | This table shows some of the combinations of styles and line widths: | - |
| 117 | | - |
| 118 | \image frames.png Table of frame styles | - |
| 119 | */ | - |
| 120 | | - |
| 121 | | - |
| 122 | /*! | - |
| 123 | \enum QFrame::Shape | - |
| 124 | | - |
| 125 | This enum type defines the shapes of frame available. | - |
| 126 | | - |
| 127 | \value NoFrame QFrame draws nothing | - |
| 128 | \value Box QFrame draws a box around its contents | - |
| 129 | \value Panel QFrame draws a panel to make the contents appear | - |
| 130 | raised or sunken | - |
| 131 | \value StyledPanel draws a rectangular panel with a look that | - |
| 132 | depends on the current GUI style. It can be raised or sunken. | - |
| 133 | \value HLine QFrame draws a horizontal line that frames nothing | - |
| 134 | (useful as separator) | - |
| 135 | \value VLine QFrame draws a vertical line that frames nothing | - |
| 136 | (useful as separator) | - |
| 137 | \value WinPanel draws a rectangular panel that can be raised or | - |
| 138 | sunken like those in Windows 2000. Specifying this shape sets | - |
| 139 | the line width to 2 pixels. WinPanel is provided for compatibility. | - |
| 140 | For GUI style independence we recommend using StyledPanel instead. | - |
| 141 | | - |
| 142 | When it does not call QStyle, Shape interacts with QFrame::Shadow, | - |
| 143 | the lineWidth() and the midLineWidth() to create the total result. | - |
| 144 | See the picture of the frames in the main class documentation. | - |
| 145 | | - |
| 146 | \sa QFrame::Shadow, QFrame::style(), QStyle::drawPrimitive() | - |
| 147 | */ | - |
| 148 | | - |
| 149 | | - |
| 150 | /*! | - |
| 151 | \enum QFrame::Shadow | - |
| 152 | | - |
| 153 | This enum type defines the types of shadow that are used to give | - |
| 154 | a 3D effect to frames. | - |
| 155 | | - |
| 156 | \value Plain the frame and contents appear level with the | - |
| 157 | surroundings; draws using the palette QPalette::WindowText color | - |
| 158 | (without any 3D effect) | - |
| 159 | | - |
| 160 | \value Raised the frame and contents appear raised; draws a 3D | - |
| 161 | raised line using the light and dark colors of the current color | - |
| 162 | group | - |
| 163 | \value Sunken the frame and contents appear sunken; draws a 3D | - |
| 164 | sunken line using the light and dark colors of the current color | - |
| 165 | group | - |
| 166 | | - |
| 167 | Shadow interacts with QFrame::Shape, the lineWidth() and the | - |
| 168 | midLineWidth(). See the picture of the frames in the main class | - |
| 169 | documentation. | - |
| 170 | | - |
| 171 | \sa QFrame::Shape, lineWidth(), midLineWidth() | - |
| 172 | */ | - |
| 173 | | - |
| 174 | /*! | - |
| 175 | \enum QFrame::StyleMask | - |
| 176 | | - |
| 177 | This enum defines two constants that can be used to extract the | - |
| 178 | two components of frameStyle(): | - |
| 179 | | - |
| 180 | \value Shadow_Mask The \l Shadow part of frameStyle() | - |
| 181 | \value Shape_Mask The \l Shape part of frameStyle() | - |
| 182 | | - |
| 183 | Normally, you don't need to use these, since frameShadow() and | - |
| 184 | frameShape() already extract the \l Shadow and the \l Shape parts | - |
| 185 | of frameStyle(). | - |
| 186 | | - |
| 187 | \sa frameStyle(), setFrameStyle() | - |
| 188 | */ | - |
| 189 | | - |
| 190 | /*! | - |
| 191 | Constructs a frame widget with frame style \l NoFrame and a | - |
| 192 | 1-pixel frame width. | - |
| 193 | | - |
| 194 | The \a parent and \a f arguments are passed to the QWidget | - |
| 195 | constructor. | - |
| 196 | */ | - |
| 197 | | - |
| 198 | QFrame::QFrame(QWidget* parent, Qt::WindowFlags f) | - |
| 199 | : QWidget(*new QFramePrivate, parent, f) | - |
| 200 | { | - |
| 201 | Q_D(QFrame); executed (the execution status of this line is deduced): QFramePrivate * const d = d_func(); | - |
| 202 | d->init(); executed (the execution status of this line is deduced): d->init(); | - |
| 203 | } executed: }Execution Count:613 | 613 |
| 204 | | - |
| 205 | /*! \internal */ | - |
| 206 | QFrame::QFrame(QFramePrivate &dd, QWidget* parent, Qt::WindowFlags f) | - |
| 207 | : QWidget(dd, parent, f) | - |
| 208 | { | - |
| 209 | Q_D(QFrame); executed (the execution status of this line is deduced): QFramePrivate * const d = d_func(); | - |
| 210 | d->init(); executed (the execution status of this line is deduced): d->init(); | - |
| 211 | } executed: }Execution Count:6632 | 6632 |
| 212 | | - |
| 213 | | - |
| 214 | /*! | - |
| 215 | Destroys the frame. | - |
| 216 | */ | - |
| 217 | QFrame::~QFrame() | - |
| 218 | { | - |
| 219 | } | - |
| 220 | | - |
| 221 | /*! | - |
| 222 | Returns the frame style. | - |
| 223 | | - |
| 224 | The default value is QFrame::Plain. | - |
| 225 | | - |
| 226 | \sa setFrameStyle(), frameShape(), frameShadow() | - |
| 227 | */ | - |
| 228 | int QFrame::frameStyle() const | - |
| 229 | { | - |
| 230 | Q_D(const QFrame); never executed (the execution status of this line is deduced): const QFramePrivate * const d = d_func(); | - |
| 231 | return d->frameStyle; never executed: return d->frameStyle; | 0 |
| 232 | } | - |
| 233 | | - |
| 234 | /*! | - |
| 235 | \property QFrame::frameShape | - |
| 236 | \brief the frame shape value from the frame style | - |
| 237 | | - |
| 238 | \sa frameStyle(), frameShadow() | - |
| 239 | */ | - |
| 240 | | - |
| 241 | QFrame::Shape QFrame::frameShape() const | - |
| 242 | { | - |
| 243 | Q_D(const QFrame); executed (the execution status of this line is deduced): const QFramePrivate * const d = d_func(); | - |
| 244 | return (Shape) (d->frameStyle & Shape_Mask); executed: return (Shape) (d->frameStyle & Shape_Mask);Execution Count:1317 | 1317 |
| 245 | } | - |
| 246 | | - |
| 247 | void QFrame::setFrameShape(QFrame::Shape s) | - |
| 248 | { | - |
| 249 | Q_D(QFrame); executed (the execution status of this line is deduced): QFramePrivate * const d = d_func(); | - |
| 250 | setFrameStyle((d->frameStyle & Shadow_Mask) | s); executed (the execution status of this line is deduced): setFrameStyle((d->frameStyle & Shadow_Mask) | s); | - |
| 251 | } executed: }Execution Count:191 | 191 |
| 252 | | - |
| 253 | | - |
| 254 | /*! | - |
| 255 | \property QFrame::frameShadow | - |
| 256 | \brief the frame shadow value from the frame style | - |
| 257 | | - |
| 258 | \sa frameStyle(), frameShape() | - |
| 259 | */ | - |
| 260 | QFrame::Shadow QFrame::frameShadow() const | - |
| 261 | { | - |
| 262 | Q_D(const QFrame); never executed (the execution status of this line is deduced): const QFramePrivate * const d = d_func(); | - |
| 263 | return (Shadow) (d->frameStyle & Shadow_Mask); never executed: return (Shadow) (d->frameStyle & Shadow_Mask); | 0 |
| 264 | } | - |
| 265 | | - |
| 266 | void QFrame::setFrameShadow(QFrame::Shadow s) | - |
| 267 | { | - |
| 268 | Q_D(QFrame); executed (the execution status of this line is deduced): QFramePrivate * const d = d_func(); | - |
| 269 | setFrameStyle((d->frameStyle & Shape_Mask) | s); executed (the execution status of this line is deduced): setFrameStyle((d->frameStyle & Shape_Mask) | s); | - |
| 270 | } executed: }Execution Count:191 | 191 |
| 271 | | - |
| 272 | /*! | - |
| 273 | Sets the frame style to \a style. | - |
| 274 | | - |
| 275 | The \a style is the bitwise OR between a frame shape and a frame | - |
| 276 | shadow style. See the picture of the frames in the main class | - |
| 277 | documentation. | - |
| 278 | | - |
| 279 | The frame shapes are given in \l{QFrame::Shape} and the shadow | - |
| 280 | styles in \l{QFrame::Shadow}. | - |
| 281 | | - |
| 282 | If a mid-line width greater than 0 is specified, an additional | - |
| 283 | line is drawn for \l Raised or \l Sunken \l Box, \l HLine, and \l | - |
| 284 | VLine frames. The mid-color of the current color group is used for | - |
| 285 | drawing middle lines. | - |
| 286 | | - |
| 287 | \sa frameStyle() | - |
| 288 | */ | - |
| 289 | | - |
| 290 | void QFrame::setFrameStyle(int style) | - |
| 291 | { | - |
| 292 | Q_D(QFrame); executed (the execution status of this line is deduced): QFramePrivate * const d = d_func(); | - |
| 293 | if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) { evaluated: !testAttribute(Qt::WA_WState_OwnSizePolicy)| yes Evaluation Count:5834 | yes Evaluation Count:2941 |
| 2941-5834 |
| 294 | QSizePolicy sp; executed (the execution status of this line is deduced): QSizePolicy sp; | - |
| 295 | | - |
| 296 | switch (style & Shape_Mask) { | - |
| 297 | case HLine: | - |
| 298 | sp = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed, QSizePolicy::Line); executed (the execution status of this line is deduced): sp = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed, QSizePolicy::Line); | - |
| 299 | break; executed: break;Execution Count:4 | 4 |
| 300 | case VLine: | - |
| 301 | sp = QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum, QSizePolicy::Line); never executed (the execution status of this line is deduced): sp = QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum, QSizePolicy::Line); | - |
| 302 | break; | 0 |
| 303 | default: | - |
| 304 | sp = QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, QSizePolicy::Frame); executed (the execution status of this line is deduced): sp = QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, QSizePolicy::Frame); | - |
| 305 | } executed: }Execution Count:5830 | 5830 |
| 306 | setSizePolicy(sp); executed (the execution status of this line is deduced): setSizePolicy(sp); | - |
| 307 | setAttribute(Qt::WA_WState_OwnSizePolicy, false); executed (the execution status of this line is deduced): setAttribute(Qt::WA_WState_OwnSizePolicy, false); | - |
| 308 | } executed: }Execution Count:5834 | 5834 |
| 309 | d->frameStyle = (short)style; executed (the execution status of this line is deduced): d->frameStyle = (short)style; | - |
| 310 | update(); executed (the execution status of this line is deduced): update(); | - |
| 311 | d->updateFrameWidth(); executed (the execution status of this line is deduced): d->updateFrameWidth(); | - |
| 312 | } executed: }Execution Count:8775 | 8775 |
| 313 | | - |
| 314 | /*! | - |
| 315 | \property QFrame::lineWidth | - |
| 316 | \brief the line width | - |
| 317 | | - |
| 318 | Note that the \e total line width for frames used as separators | - |
| 319 | (\l HLine and \l VLine) is specified by \l frameWidth. | - |
| 320 | | - |
| 321 | The default value is 1. | - |
| 322 | | - |
| 323 | \sa midLineWidth, frameWidth | - |
| 324 | */ | - |
| 325 | | - |
| 326 | void QFrame::setLineWidth(int w) | - |
| 327 | { | - |
| 328 | Q_D(QFrame); executed (the execution status of this line is deduced): QFramePrivate * const d = d_func(); | - |
| 329 | if (short(w) == d->lineWidth) evaluated: short(w) == d->lineWidth| yes Evaluation Count:379 | yes Evaluation Count:430 |
| 379-430 |
| 330 | return; executed: return;Execution Count:379 | 379 |
| 331 | d->lineWidth = short(w); executed (the execution status of this line is deduced): d->lineWidth = short(w); | - |
| 332 | d->updateFrameWidth(); executed (the execution status of this line is deduced): d->updateFrameWidth(); | - |
| 333 | } executed: }Execution Count:430 | 430 |
| 334 | | - |
| 335 | int QFrame::lineWidth() const | - |
| 336 | { | - |
| 337 | Q_D(const QFrame); executed (the execution status of this line is deduced): const QFramePrivate * const d = d_func(); | - |
| 338 | return d->lineWidth; executed: return d->lineWidth;Execution Count:7755 | 7755 |
| 339 | } | - |
| 340 | | - |
| 341 | /*! | - |
| 342 | \property QFrame::midLineWidth | - |
| 343 | \brief the width of the mid-line | - |
| 344 | | - |
| 345 | The default value is 0. | - |
| 346 | | - |
| 347 | \sa lineWidth, frameWidth | - |
| 348 | */ | - |
| 349 | | - |
| 350 | void QFrame::setMidLineWidth(int w) | - |
| 351 | { | - |
| 352 | Q_D(QFrame); executed (the execution status of this line is deduced): QFramePrivate * const d = d_func(); | - |
| 353 | if (short(w) == d->midLineWidth) evaluated: short(w) == d->midLineWidth| yes Evaluation Count:85 | yes Evaluation Count:7 |
| 7-85 |
| 354 | return; executed: return;Execution Count:85 | 85 |
| 355 | d->midLineWidth = short(w); executed (the execution status of this line is deduced): d->midLineWidth = short(w); | - |
| 356 | d->updateFrameWidth(); executed (the execution status of this line is deduced): d->updateFrameWidth(); | - |
| 357 | } executed: }Execution Count:7 | 7 |
| 358 | | - |
| 359 | int QFrame::midLineWidth() const | - |
| 360 | { | - |
| 361 | Q_D(const QFrame); never executed (the execution status of this line is deduced): const QFramePrivate * const d = d_func(); | - |
| 362 | return d->midLineWidth; never executed: return d->midLineWidth; | 0 |
| 363 | } | - |
| 364 | | - |
| 365 | /*! | - |
| 366 | \internal | - |
| 367 | Updates the frame widths from the style. | - |
| 368 | */ | - |
| 369 | void QFramePrivate::updateStyledFrameWidths() | - |
| 370 | { | - |
| 371 | Q_Q(const QFrame); executed (the execution status of this line is deduced): const QFrame * const q = q_func(); | - |
| 372 | QStyleOptionFrameV3 opt; executed (the execution status of this line is deduced): QStyleOptionFrameV3 opt; | - |
| 373 | opt.initFrom(q); executed (the execution status of this line is deduced): opt.initFrom(q); | - |
| 374 | opt.lineWidth = lineWidth; executed (the execution status of this line is deduced): opt.lineWidth = lineWidth; | - |
| 375 | opt.midLineWidth = midLineWidth; executed (the execution status of this line is deduced): opt.midLineWidth = midLineWidth; | - |
| 376 | opt.frameShape = QFrame::Shape(frameStyle & QFrame::Shape_Mask); executed (the execution status of this line is deduced): opt.frameShape = QFrame::Shape(frameStyle & QFrame::Shape_Mask); | - |
| 377 | | - |
| 378 | QRect cr = q->style()->subElementRect(QStyle::SE_ShapedFrameContents, &opt, q); executed (the execution status of this line is deduced): QRect cr = q->style()->subElementRect(QStyle::SE_ShapedFrameContents, &opt, q); | - |
| 379 | leftFrameWidth = cr.left() - opt.rect.left(); executed (the execution status of this line is deduced): leftFrameWidth = cr.left() - opt.rect.left(); | - |
| 380 | topFrameWidth = cr.top() - opt.rect.top(); executed (the execution status of this line is deduced): topFrameWidth = cr.top() - opt.rect.top(); | - |
| 381 | rightFrameWidth = opt.rect.right() - cr.right(), executed (the execution status of this line is deduced): rightFrameWidth = opt.rect.right() - cr.right(), | - |
| 382 | bottomFrameWidth = opt.rect.bottom() - cr.bottom(); executed (the execution status of this line is deduced): bottomFrameWidth = opt.rect.bottom() - cr.bottom(); | - |
| 383 | frameWidth = qMax(qMax(leftFrameWidth, rightFrameWidth), executed (the execution status of this line is deduced): frameWidth = qMax(qMax(leftFrameWidth, rightFrameWidth), | - |
| 384 | qMax(topFrameWidth, bottomFrameWidth)); executed (the execution status of this line is deduced): qMax(topFrameWidth, bottomFrameWidth)); | - |
| 385 | } executed: }Execution Count:18223 | 18223 |
| 386 | | - |
| 387 | /*! | - |
| 388 | \internal | - |
| 389 | Updated the frameWidth parameter. | - |
| 390 | */ | - |
| 391 | | - |
| 392 | void QFramePrivate::updateFrameWidth() | - |
| 393 | { | - |
| 394 | Q_Q(QFrame); executed (the execution status of this line is deduced): QFrame * const q = q_func(); | - |
| 395 | QRect fr = q->frameRect(); executed (the execution status of this line is deduced): QRect fr = q->frameRect(); | - |
| 396 | updateStyledFrameWidths(); executed (the execution status of this line is deduced): updateStyledFrameWidths(); | - |
| 397 | q->setFrameRect(fr); executed (the execution status of this line is deduced): q->setFrameRect(fr); | - |
| 398 | setLayoutItemMargins(QStyle::SE_FrameLayoutItem); executed (the execution status of this line is deduced): setLayoutItemMargins(QStyle::SE_FrameLayoutItem); | - |
| 399 | } executed: }Execution Count:16545 | 16545 |
| 400 | | - |
| 401 | /*! | - |
| 402 | \property QFrame::frameWidth | - |
| 403 | \brief the width of the frame that is drawn. | - |
| 404 | | - |
| 405 | Note that the frame width depends on the \l{QFrame::setFrameStyle()}{frame style}, | - |
| 406 | not only the line width and the mid-line width. For example, the style specified | - |
| 407 | by \l NoFrame always has a frame width of 0, whereas the style \l Panel has a | - |
| 408 | frame width equivalent to the line width. | - |
| 409 | | - |
| 410 | \sa lineWidth(), midLineWidth(), frameStyle() | - |
| 411 | */ | - |
| 412 | int QFrame::frameWidth() const | - |
| 413 | { | - |
| 414 | Q_D(const QFrame); executed (the execution status of this line is deduced): const QFramePrivate * const d = d_func(); | - |
| 415 | return d->frameWidth; executed: return d->frameWidth;Execution Count:8444 | 8444 |
| 416 | } | - |
| 417 | | - |
| 418 | | - |
| 419 | /*! | - |
| 420 | \property QFrame::frameRect | - |
| 421 | \brief the frame's rectangle | - |
| 422 | | - |
| 423 | The frame's rectangle is the rectangle the frame is drawn in. By | - |
| 424 | default, this is the entire widget. Setting the rectangle does | - |
| 425 | does \e not cause a widget update. The frame rectangle is | - |
| 426 | automatically adjusted when the widget changes size. | - |
| 427 | | - |
| 428 | If you set the rectangle to a null rectangle (for example, | - |
| 429 | QRect(0, 0, 0, 0)), then the resulting frame rectangle is | - |
| 430 | equivalent to the \l{QWidget::rect()}{widget rectangle}. | - |
| 431 | */ | - |
| 432 | | - |
| 433 | QRect QFrame::frameRect() const | - |
| 434 | { | - |
| 435 | Q_D(const QFrame); executed (the execution status of this line is deduced): const QFramePrivate * const d = d_func(); | - |
| 436 | QRect fr = contentsRect(); executed (the execution status of this line is deduced): QRect fr = contentsRect(); | - |
| 437 | fr.adjust(-d->leftFrameWidth, -d->topFrameWidth, d->rightFrameWidth, d->bottomFrameWidth); executed (the execution status of this line is deduced): fr.adjust(-d->leftFrameWidth, -d->topFrameWidth, d->rightFrameWidth, d->bottomFrameWidth); | - |
| 438 | return fr; executed: return fr;Execution Count:19243 | 19243 |
| 439 | } | - |
| 440 | | - |
| 441 | void QFrame::setFrameRect(const QRect &r) | - |
| 442 | { | - |
| 443 | Q_D(QFrame); executed (the execution status of this line is deduced): QFramePrivate * const d = d_func(); | - |
| 444 | QRect cr = r.isValid() ? r : rect(); evaluated: r.isValid()| yes Evaluation Count:39743 | yes Evaluation Count:5000 |
| 5000-39743 |
| 445 | cr.adjust(d->leftFrameWidth, d->topFrameWidth, -d->rightFrameWidth, -d->bottomFrameWidth); executed (the execution status of this line is deduced): cr.adjust(d->leftFrameWidth, d->topFrameWidth, -d->rightFrameWidth, -d->bottomFrameWidth); | - |
| 446 | setContentsMargins(cr.left(), cr.top(), rect().right() - cr.right(), rect().bottom() - cr.bottom()); executed (the execution status of this line is deduced): setContentsMargins(cr.left(), cr.top(), rect().right() - cr.right(), rect().bottom() - cr.bottom()); | - |
| 447 | } executed: }Execution Count:44743 | 44743 |
| 448 | | - |
| 449 | /*!\reimp | - |
| 450 | */ | - |
| 451 | QSize QFrame::sizeHint() const | - |
| 452 | { | - |
| 453 | Q_D(const QFrame); executed (the execution status of this line is deduced): const QFramePrivate * const d = d_func(); | - |
| 454 | // Returns a size hint for the frame - for HLine and VLine | - |
| 455 | // shapes, this is stretchable one way and 3 pixels wide the | - |
| 456 | // other. For other shapes, QWidget::sizeHint() is used. | - |
| 457 | switch (d->frameStyle & Shape_Mask) { | - |
| 458 | case HLine: | - |
| 459 | return QSize(-1,3); never executed: return QSize(-1,3); | 0 |
| 460 | case VLine: | - |
| 461 | return QSize(3,-1); never executed: return QSize(3,-1); | 0 |
| 462 | default: | - |
| 463 | return QWidget::sizeHint(); executed: return QWidget::sizeHint();Execution Count:2499 | 2499 |
| 464 | } | - |
| 465 | } | 0 |
| 466 | | - |
| 467 | /*!\reimp | - |
| 468 | */ | - |
| 469 | | - |
| 470 | void QFrame::paintEvent(QPaintEvent *) | - |
| 471 | { | - |
| 472 | QPainter paint(this); executed (the execution status of this line is deduced): QPainter paint(this); | - |
| 473 | drawFrame(&paint); executed (the execution status of this line is deduced): drawFrame(&paint); | - |
| 474 | } executed: }Execution Count:1978 | 1978 |
| 475 | | - |
| 476 | /*! | - |
| 477 | \internal | - |
| 478 | | - |
| 479 | Used by QLabel and QLCDNumber | - |
| 480 | */ | - |
| 481 | void QFrame::drawFrame(QPainter *p) | - |
| 482 | { | - |
| 483 | Q_D(QFrame); executed (the execution status of this line is deduced): QFramePrivate * const d = d_func(); | - |
| 484 | QStyleOptionFrameV3 opt; executed (the execution status of this line is deduced): QStyleOptionFrameV3 opt; | - |
| 485 | opt.init(this); executed (the execution status of this line is deduced): opt.init(this); | - |
| 486 | int frameShape = d->frameStyle & QFrame::Shape_Mask; executed (the execution status of this line is deduced): int frameShape = d->frameStyle & QFrame::Shape_Mask; | - |
| 487 | int frameShadow = d->frameStyle & QFrame::Shadow_Mask; executed (the execution status of this line is deduced): int frameShadow = d->frameStyle & QFrame::Shadow_Mask; | - |
| 488 | opt.frameShape = Shape(int(opt.frameShape) | frameShape); executed (the execution status of this line is deduced): opt.frameShape = Shape(int(opt.frameShape) | frameShape); | - |
| 489 | opt.rect = frameRect(); executed (the execution status of this line is deduced): opt.rect = frameRect(); | - |
| 490 | switch (frameShape) { | - |
| 491 | case QFrame::Box: | - |
| 492 | case QFrame::HLine: | - |
| 493 | case QFrame::VLine: | - |
| 494 | case QFrame::StyledPanel: | - |
| 495 | case QFrame::Panel: | - |
| 496 | opt.lineWidth = d->lineWidth; executed (the execution status of this line is deduced): opt.lineWidth = d->lineWidth; | - |
| 497 | opt.midLineWidth = d->midLineWidth; executed (the execution status of this line is deduced): opt.midLineWidth = d->midLineWidth; | - |
| 498 | break; executed: break;Execution Count:1801 | 1801 |
| 499 | default: | - |
| 500 | // most frame styles do not handle customized line and midline widths | - |
| 501 | // (see updateFrameWidth()). | - |
| 502 | opt.lineWidth = d->frameWidth; executed (the execution status of this line is deduced): opt.lineWidth = d->frameWidth; | - |
| 503 | break; executed: break;Execution Count:897 | 897 |
| 504 | } | - |
| 505 | | - |
| 506 | if (frameShadow == Sunken) evaluated: frameShadow == Sunken| yes Evaluation Count:1208 | yes Evaluation Count:1490 |
| 1208-1490 |
| 507 | opt.state |= QStyle::State_Sunken; executed: opt.state |= QStyle::State_Sunken;Execution Count:1208 | 1208 |
| 508 | else if (frameShadow == Raised) evaluated: frameShadow == Raised| yes Evaluation Count:50 | yes Evaluation Count:1440 |
| 50-1440 |
| 509 | opt.state |= QStyle::State_Raised; executed: opt.state |= QStyle::State_Raised;Execution Count:50 | 50 |
| 510 | | - |
| 511 | style()->drawControl(QStyle::CE_ShapedFrame, &opt, p, this); executed (the execution status of this line is deduced): style()->drawControl(QStyle::CE_ShapedFrame, &opt, p, this); | - |
| 512 | } executed: }Execution Count:2698 | 2698 |
| 513 | | - |
| 514 | | - |
| 515 | /*!\reimp | - |
| 516 | */ | - |
| 517 | void QFrame::changeEvent(QEvent *ev) | - |
| 518 | { | - |
| 519 | Q_D(QFrame); executed (the execution status of this line is deduced): QFramePrivate * const d = d_func(); | - |
| 520 | if (ev->type() == QEvent::StyleChange evaluated: ev->type() == QEvent::StyleChange| yes Evaluation Count:918 | yes Evaluation Count:11239 |
| 918-11239 |
| 521 | #ifdef Q_OS_MAC | - |
| 522 | || ev->type() == QEvent::MacSizeChange | - |
| 523 | #endif | - |
| 524 | ) | - |
| 525 | d->updateFrameWidth(); executed: d->updateFrameWidth();Execution Count:918 | 918 |
| 526 | QWidget::changeEvent(ev); executed (the execution status of this line is deduced): QWidget::changeEvent(ev); | - |
| 527 | } executed: }Execution Count:12157 | 12157 |
| 528 | | - |
| 529 | /*! \reimp */ | - |
| 530 | bool QFrame::event(QEvent *e) | - |
| 531 | { | - |
| 532 | if (e->type() == QEvent::ParentChange) evaluated: e->type() == QEvent::ParentChange| yes Evaluation Count:845 | yes Evaluation Count:129388 |
| 845-129388 |
| 533 | d_func()->updateFrameWidth(); executed: d_func()->updateFrameWidth();Execution Count:845 | 845 |
| 534 | bool result = QWidget::event(e); executed (the execution status of this line is deduced): bool result = QWidget::event(e); | - |
| 535 | //this has to be done after the widget has been polished | - |
| 536 | if (e->type() == QEvent::Polish) evaluated: e->type() == QEvent::Polish| yes Evaluation Count:5570 | yes Evaluation Count:124663 |
| 5570-124663 |
| 537 | d_func()->updateFrameWidth(); executed: d_func()->updateFrameWidth();Execution Count:5570 | 5570 |
| 538 | return result; executed: return result;Execution Count:130233 | 130233 |
| 539 | } | - |
| 540 | | - |
| 541 | QT_END_NAMESPACE | - |
| 542 | | - |
| | |