⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qframe.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.**** This file is part of the QtGui module of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file.  Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://trolltech.com/products/qt/licenses/licensing/opensource/**** If you are unsure which license is appropriate for your use, please** review the following information:** http://trolltech.com/products/qt/licenses/licensing/licensingoverview** or contact the sales department at sales@trolltech.com.**** In addition, as a special exception, Trolltech gives you certain** additional rights. These rights are described in the Trolltech GPL** Exception version 1.0, which can be found at** http://www.trolltech.com/products/qt/gplexception/ and in the file** GPL_EXCEPTION.txt in this package.**** In addition, as a special exception, Trolltech, as the sole copyright** holder for Qt Designer, grants users of the Qt/Eclipse Integration** plug-in the right for the Qt/Eclipse Integration to link to** functionality provided by Qt Designer and its related libraries.**** Trolltech reserves all rights not expressly granted herein.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#include "qframe.h"#include "qbitmap.h"#include "qdrawutil.h"#include "qevent.h"#include "qpainter.h"#include "qstyle.h"#include "qstyleoption.h"#include "qapplication.h"#include "qframe_p.h"QFramePrivate::QFramePrivate()    : frect(QRect(0, 0, 0, 0)),      frameStyle(QFrame::NoFrame | QFrame::Plain),      lineWidth(1),      midLineWidth(0),      frameWidth(0),      leftFrameWidth(0), rightFrameWidth(0),       topFrameWidth(0), bottomFrameWidth(0),      oldFrameStyle(QFrame::NoFrame | QFrame::Plain){}inline void QFramePrivate::init(){    setLayoutItemMargins(QStyle::SE_FrameLayoutItem);}/*!    \class QFrame    \brief The QFrame class is the base class of widgets that can have a frame.    \ingroup abstractwidgets    \mainclass    QMenu uses this to "raise" the menu above the surrounding    screen. QProgressBar has a "sunken" look. QLabel has a flat look.    The frames of widgets like these can be changed.    \code    QLabel label(...);    label.setFrameStyle(QFrame::Panel | QFrame::Raised);    label.setLineWidth(2);    QProgressBar pbar(...);    label.setFrameStyle(QFrame::NoFrame);    \endcode    The QFrame class can also be used directly for creating simple    placeholder frames without any contents.    The frame style is specified by a \l{QFrame::Shape}{frame shape} and    a \l{QFrame::Shadow}{shadow style} that is used to visually separate    the frame from surrounding widgets. These properties can be set    together using the setFrameStyle() function and read with frameStyle().    The frame shapes are \l NoFrame, \l Box, \l Panel, \l StyledPanel,    HLine and \l VLine; the shadow styles are \l Plain, \l Raised and    \l Sunken.    A frame widget has three attributes that describe the thickness of the    border: \l lineWidth, \l midLineWidth, and \l frameWidth.    \list    \o The line width is the width of the frame border. It can be modified       to customize the frame's appearance.    \o The mid-line width specifies the width of an extra line in the       middle of the frame, which uses a third color to obtain a special       3D effect. Notice that a mid-line is only drawn for \l Box, \l       HLine and \l VLine frames that are raised or sunken.    \o The frame width is determined by the frame style, and the frameWidth()       function is used to obtain the value defined for the style used.    \endlist    The margin between the frame and the contents of the frame can be    customized with the QWidget::setContentsMargins() function.    \target picture    This table shows some of the combinations of styles and line widths:    \image frames.png Table of frame styles*//*!    \enum QFrame::Shape    This enum type defines the shapes of frame available.    \value NoFrame  QFrame draws nothing    \value Box  QFrame draws a box around its contents    \value Panel  QFrame draws a panel to make the contents appear    raised or sunken    \value StyledPanel  draws a rectangular panel with a look that    depends on the current GUI style. It can be raised or sunken.    \value HLine  QFrame draws a horizontal line that frames nothing    (useful as separator)    \value VLine  QFrame draws a vertical line that frames nothing    (useful as separator)    \value WinPanel draws a rectangular panel that can be raised or    sunken like those in Windows 95. Specifying this shape sets    the line width to 2 pixels. WinPanel is provided for compatibility.    For GUI style independence we recommend using StyledPanel instead.    \omitvalue GroupBoxPanel    \omitvalue ToolBarPanel    \omitvalue MenuBarPanel    \omitvalue PopupPanel    \omitvalue LineEditPanel    \omitvalue TabWidgetPanel    When it does not call QStyle, Shape interacts with QFrame::Shadow,    the lineWidth() and the midLineWidth() to create the total result.    See the picture of the frames in the main class documentation.    \sa QFrame::Shadow QFrame::style() QStyle::drawPrimitive()*//*!    \enum QFrame::Shadow    This enum type defines the types of shadow that are used to give    a 3D effect to frames.    \value Plain  the frame and contents appear level with the    surroundings; draws using the palette foreground color (without    any 3D effect)    \value Raised the frame and contents appear raised; draws a 3D    raised line using the light and dark colors of the current color    group    \value Sunken the frame and contents appear sunken; draws a 3D    sunken line using the light and dark colors of the current color    group    Shadow interacts with QFrame::Shape, the lineWidth() and the    midLineWidth(). See the picture of the frames in the main class    documentation.    \sa QFrame::Shape lineWidth() midLineWidth()*//*!    \enum QFrame::StyleMask    This enum defines two constants that can be used to extract the    two components of frameStyle():    \value Shadow_Mask The \l Shadow part of frameStyle()    \value Shape_Mask  The \l Shape part of frameStyle()    \omitvalue MShadow    \omitvalue MShape    Normally, you don't need to use these, since frameShadow() and    frameShape() already extract the \l Shadow and the \l Shape parts    of frameStyle().    \sa frameStyle(), setFrameStyle()*//*!    Constructs a frame widget with frame style \l NoFrame and a    1-pixel frame width.    The \a parent and \a f arguments are passed to the QWidget    constructor.*/QFrame::QFrame(QWidget* parent, Qt::WindowFlags f)    : QWidget(*new QFramePrivate, parent, f){    Q_D(QFrame);    d->init();}/*! \internal */QFrame::QFrame(QFramePrivate &dd, QWidget* parent, Qt::WindowFlags f)    : QWidget(dd, parent, f){    Q_D(QFrame);    d->init();}#ifdef QT3_SUPPORT/*!    Use one of the constructors that doesn't take the \a name    argument and then use setObjectName() instead.*/QFrame::QFrame(QWidget *parent, const char *name, Qt::WindowFlags f)    : QWidget(*new QFramePrivate, parent, f){    Q_D(QFrame);    setObjectName(QString::fromAscii(name));    d->init();}#endif/*!  Destroys the frame. */QFrame::~QFrame(){}/*!    Returns the frame style.    The default value is QFrame::NoFrame.    \sa setFrameStyle(), frameShape(), frameShadow()*/int QFrame::frameStyle() const{    Q_D(const QFrame);    return d->frameStyle;}/*!    \property QFrame::frameShape    \brief the frame shape value from the frame style    \sa frameStyle(), frameShadow()*/QFrame::Shape QFrame::frameShape() const{    Q_D(const QFrame);    return (Shape) (d->frameStyle & Shape_Mask);}void QFrame::setFrameShape(QFrame::Shape s){    Q_D(QFrame);    setFrameStyle((d->frameStyle & Shadow_Mask) | s);}/*!    \property QFrame::frameShadow    \brief the frame shadow value from the frame style    \sa frameStyle(), frameShape()*/QFrame::Shadow QFrame::frameShadow() const{    Q_D(const QFrame);    return (Shadow) (d->frameStyle & Shadow_Mask);}void QFrame::setFrameShadow(QFrame::Shadow s){    Q_D(QFrame);    setFrameStyle((d->frameStyle & Shape_Mask) | s);}/*!    Sets the frame style to \a style.    The \a style is the bitwise OR between a frame shape and a frame    shadow style. See the picture of the frames in the main class    documentation.    The frame shapes are given in \l{QFrame::Shape} and the shadow    styles in \l{QFrame::Shadow}.    If a mid-line width greater than 0 is specified, an additional    line is drawn for \l Raised or \l Sunken \l Box, \l HLine, and \l    VLine frames. The mid-color of the current color group is used for    drawing middle lines.    \sa frameStyle()*/void QFrame::setFrameStyle(int style){    Q_D(QFrame);    if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) {        QSizePolicy sp;        switch (style & Shape_Mask) {        case HLine:            sp = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed, QSizePolicy::Line);            break;        case VLine:            sp = QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum, QSizePolicy::Line);            break;        default:            sp = QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, QSizePolicy::Frame);        }        setSizePolicy(sp);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -