Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/styles/qstyleoption.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4646# include "qmacstyle_mac.h"
    4747#endif
    48 #ifndef QT_NO_DEBUG
    4948#include <qdebug.h>
    50 #endif
     49#include <QtCore/qmath.h>
    5150
    5251QT_BEGIN_NAMESPACE
     
    657656    \enum QStyleOptionFrameV2::FrameFeature
    658657
    659     This enum describles the different types of features a frame can have.
     658    This enum describes the different types of features a frame can have.
    660659
    661660    \value None Indicates a normal frame.
     
    712711*/
    713712QStyleOptionFrameV3::QStyleOptionFrameV3()
    714     : QStyleOptionFrameV2(Version), frameShape(QFrame::NoFrame)
     713    : QStyleOptionFrameV2(Version), frameShape(QFrame::NoFrame), unused(0)
    715714{
    716715}
     
    726725*/
    727726QStyleOptionFrameV3::QStyleOptionFrameV3(int version)
    728     : QStyleOptionFrameV2(version), frameShape(QFrame::NoFrame)
     727    : QStyleOptionFrameV2(version), frameShape(QFrame::NoFrame), unused(0)
    729728{
    730729}
     
    899898    \enum QStyleOptionViewItemV2::ViewItemFeature
    900899
    901     This enum describles the different types of features an item can have.
     900    This enum describes the different types of features an item can have.
    902901
    903902    \value None      Indicates a normal item.
     
    954953*/
    955954QStyleOptionViewItemV3::QStyleOptionViewItemV3()
    956     : QStyleOptionViewItemV2(Version)
     955    : QStyleOptionViewItemV2(Version), widget(0)
    957956{
    958957}
     
    962961*/
    963962QStyleOptionViewItemV3::QStyleOptionViewItemV3(const QStyleOptionViewItem &other)
    964     : QStyleOptionViewItemV2(Version)
     963    : QStyleOptionViewItemV2(Version), widget(0)
    965964{
    966965    (void)QStyleOptionViewItemV3::operator=(other);
     
    991990*/
    992991QStyleOptionViewItemV3::QStyleOptionViewItemV3(int version)
    993     : QStyleOptionViewItemV2(version)
     992    : QStyleOptionViewItemV2(version), widget(0)
    994993{
    995994}
     
    12541253
    12551254    The frame is flat by default.
    1256    
     1255
    12571256    \sa QStyleOptionFrameV2::FrameFeature
    12581257*/
     
    28282827/*!
    28292828    \variable QStyleOptionComplex::subControls
    2830     \brief a bitwise OR of the various sub-controls that need to be
    2831     drawn for the complex control
     2829
     2830    This variable holds a bitwise OR of the \l{QStyle::SubControl}
     2831    {sub-controls} to be drawn for the complex control.
    28322832
    28332833    The default value is QStyle::SC_All.
     
    28382838/*!
    28392839    \variable QStyleOptionComplex::activeSubControls
    2840     \brief a bitwise OR of the various sub-controls that are active
    2841     (pressed) for the complex control
     2840
     2841    This variable holds a bitwise OR of the \l{QStyle::SubControl}
     2842    {sub-controls} that are active for the complex control.
    28422843
    28432844    The default value is QStyle::SC_None.
     
    35423543
    35433544QStyleOptionDockWidget::QStyleOptionDockWidget()
    3544     : QStyleOption(Version, SO_DockWidget), movable(false)
     3545    : QStyleOption(Version, SO_DockWidget), closable(false),
     3546      movable(false), floatable(false)
    35453547{
    35463548}
     
    42574259
    42584260    QStyleOptionTitleBar contains all the information that QStyle
    4259     functions need to draw the title bars of QWorkspace's MDI
    4260     children.
     4261    functions need to draw the title bar of a QMdiSubWindow.
    42614262
    42624263    For performance reasons, the access to the member variables is
     
    42684269    the \l {widgets/styles}{Styles} example.
    42694270
    4270     \sa QStyleOption, QStyleOptionComplex, QWorkspace
     4271    \sa QStyleOption, QStyleOptionComplex, QMdiSubWindow
    42714272*/
    42724273
     
    46564657    The default value is QSize(-1, -1), i.e. an invalid size.
    46574658*/
     4659
     4660
     4661/*!
     4662
     4663    \class QStyleOptionTabWidgetFrameV2
     4664    \brief The QStyleOptionTabWidgetFrameV2 class is used to describe the
     4665    parameters for drawing the frame around a tab widget.
     4666
     4667    QStyleOptionTabWidgetFrameV2 contains all the information that
     4668    QStyle functions need to draw the frame around QTabWidget.
     4669
     4670    For performance reasons, the access to the member variables is
     4671    direct (i.e., using the \c . or \c -> operator). This low-level feel
     4672    makes the structures straightforward to use and emphasizes that
     4673    these are simply parameters used by the style functions.
     4674
     4675    For an example demonstrating how style options can be used, see
     4676    the \l {widgets/styles}{Styles} example.
     4677
     4678    \sa QStyleOption, QTabWidget
     4679*/
     4680
     4681
     4682/*!
     4683    \variable QStyleOptionTabWidgetFrameV2::tabBarRect
     4684    \brief the rectangle containing all the tabs
     4685
     4686    The default value is a null rectangle, i.e. a rectangle with both
     4687    the width and the height set to 0.
     4688*/
     4689
     4690/*!
     4691    \variable QStyleOptionTabWidgetFrameV2::selectedTabRect
     4692    \brief the rectangle containing the selected tab
     4693
     4694    This rectangle is contained within the tabBarRect. The default
     4695    value is a null rectangle, i.e. a rectangle with both the width
     4696    and the height set to 0.
     4697*/
     4698
     4699
     4700/*!
     4701    Constructs a QStyleOptionTabWidgetFrameV2, initializing the members
     4702    variables to their default values.
     4703*/
     4704
     4705QStyleOptionTabWidgetFrameV2::QStyleOptionTabWidgetFrameV2()
     4706    : QStyleOptionTabWidgetFrame(Version)
     4707{
     4708}
     4709
     4710
     4711/*! \internal */
     4712QStyleOptionTabWidgetFrameV2::QStyleOptionTabWidgetFrameV2(int version)
     4713    : QStyleOptionTabWidgetFrame(version)
     4714{
     4715}
     4716
     4717
     4718/*! \fn QStyleOptionTabWidgetFrameV2::QStyleOptionTabWidgetFrameV2(const QStyleOptionTabWidgetFrameV2 &other)
     4719    Constructs a QStyleOptionTabWidgetFrameV2 copy of the \a other style option.
     4720
     4721    If the \a other style option's version is 1, the new style option's \l
     4722    selectedTabRect and tabBarRect will contain null rects
     4723
     4724    \sa version
     4725*/
     4726
     4727/*!
     4728    Constructs a QStyleOptionTabWidgetFrameV2 copy of the \a other style option.
     4729
     4730    If the \a other style option's version is 1, the new style option's \l
     4731    selectedTabRect and tabBarRect will contain null rects
     4732
     4733    \sa version
     4734*/
     4735QStyleOptionTabWidgetFrameV2::QStyleOptionTabWidgetFrameV2(const QStyleOptionTabWidgetFrame &other)
     4736{
     4737    QStyleOptionTabWidgetFrameV2::operator=(other);
     4738
     4739}
     4740
     4741
     4742/*!
     4743    Assigns the \a other style option to this style option. The \a
     4744    other style option can be either of the QStyleOptionFrameV2 or
     4745    QStyleOptionFrame types.
     4746
     4747    If the \a{other} style option's version is 1, this style option's
     4748    QStyleOptionFrameV2::FrameFeature value is set to
     4749    QStyleOptionFrameV2::None. If its version is 2, its
     4750    \l{QStyleOptionFrameV2::}{FrameFeature} value is simply copied to
     4751    this style option.
     4752*/
     4753QStyleOptionTabWidgetFrameV2 &QStyleOptionTabWidgetFrameV2::operator=(const QStyleOptionTabWidgetFrame &other)
     4754{
     4755    QStyleOptionTabWidgetFrame::operator=(other);
     4756    if (const QStyleOptionTabWidgetFrameV2 *f2 = qstyleoption_cast<const QStyleOptionTabWidgetFrameV2 *>(&other)) {
     4757        selectedTabRect = f2->selectedTabRect;
     4758        tabBarRect = f2->tabBarRect;
     4759    }
     4760    return *this;
     4761}
     4762
     4763
     4764/*!
     4765    \enum QStyleOptionTabWidgetFrameV2::StyleOptionVersion
     4766
     4767    This enum is used to hold information about the version of the style option, and
     4768    is defined for each QStyleOption subclass.
     4769
     4770    \value Version 2
     4771
     4772    The version is used by QStyleOption subclasses to implement
     4773    extensions without breaking compatibility. If you use
     4774    qstyleoption_cast(), you normally do not need to check it.
     4775
     4776    \sa StyleOptionType
     4777*/
     4778
     4779
    46584780#endif // QT_NO_TABWIDGET
    46594781
     
    48454967/*! \internal */
    48464968QStyleOptionTabBarBaseV2::QStyleOptionTabBarBaseV2(int version)
    4847     : QStyleOptionTabBarBase(version)
     4969    : QStyleOptionTabBarBase(version), documentMode(false)
    48484970{
    48494971}
     
    49375059    the parameters needed to draw a QGraphicsItem.
    49385060    \since 4.2
    4939     \ingroup multimedia
     5061    \ingroup graphicsview-api
    49405062
    49415063    For performance reasons, the access to the member variables is
     
    49825104
    49835105/*!
    4984     Constructs a QStyleOptionGraphicsItem. The levelOfDetail parameter is
    4985     initialized to 1.
     5106    Constructs a QStyleOptionGraphicsItem.
    49865107*/
    49875108QStyleOptionGraphicsItem::QStyleOptionGraphicsItem()
     
    49965117    : QStyleOption(version, Type), levelOfDetail(1)
    49975118{
     5119}
     5120
     5121/*!
     5122    \since 4.6
     5123
     5124    Returns the level of detail from the \a worldTransform.
     5125
     5126    Its value represents the maximum value of the height and
     5127    width of a unity rectangle, mapped using the \a worldTransform
     5128    of the painter used to draw the item. By default, if no
     5129    transformations are applied, its value is 1. If zoomed out 1:2, the level
     5130    of detail will be 0.5, and if zoomed in 2:1, its value is 2.
     5131*/
     5132qreal QStyleOptionGraphicsItem::levelOfDetailFromTransform(const QTransform &worldTransform)
     5133{
     5134    if (worldTransform.type() <= QTransform::TxTranslate)
     5135        return 1; // Translation only? The LOD is 1.
     5136
     5137    // Two unit vectors.
     5138    QLineF v1(0, 0, 1, 0);
     5139    QLineF v2(0, 0, 0, 1);
     5140    // LOD is the transformed area of a 1x1 rectangle.
     5141    return qSqrt(worldTransform.map(v1).length() * worldTransform.map(v2).length());
    49985142}
    49995143
     
    50115155    item are exposed. If the whole item is exposed, this rectangle will be the
    50125156    same as QGraphicsItem::boundingRect().
     5157
     5158    This member is only initialized for items that have the
     5159    QGraphicsItem::ItemUsesExtendedStyleOption flag set.
    50135160*/
    50145161
     
    50165163     \variable QStyleOptionGraphicsItem::matrix
    50175164     \brief the complete transformation matrix for the item
    5018 
    5019      This matrix is the sum of the item's scene matrix and the matrix of the
    5020      painter used for drawing the item. It is provided for convenience,
     5165     \obsolete
     5166
     5167     The QMatrix provided through this member does include information about
     5168     any perspective transformations applied to the view or item. To get the
     5169     correct transformation matrix, use QPainter::transform() on the painter
     5170     passed into the QGraphicsItem::paint() implementation.
     5171
     5172     This matrix is the combination of the item's scene matrix and the matrix
     5173     of the painter used for drawing the item. It is provided for convenience,
    50215174     allowing anvanced level-of-detail metrics that can be used to speed up
    50225175     item drawing.
    50235176
    5024      To find the dimentions of an item in screen coordinates (i.e., pixels),
     5177     To find the dimensions of an item in screen coordinates (i.e., pixels),
    50255178     you can use the mapping functions of QMatrix, such as QMatrix::map().
    50265179
    5027      \sa QStyleOptionGraphicsItem::levelOfDetail
     5180     This member is only initialized for items that have the
     5181     QGraphicsItem::ItemUsesExtendedStyleOption flag set.
     5182
     5183     \sa QStyleOptionGraphicsItem::levelOfDetailFromTransform()
    50285184*/
    50295185
    50305186/*!
    50315187    \variable QStyleOptionGraphicsItem::levelOfDetail
    5032     \brief a simple metric for determining an item's level of detail
    5033 
    5034     This simple metric provides an easy way to determine the level of detail
    5035     for an item. Its value represents the maximum value of the height and
    5036     width of a unity rectangle, mapped using the complete transformation
    5037     matrix of the painter used to draw the item. By default, if no
    5038     transformations are applied, its value is 1. If zoomed out 1:2, the level
    5039     of detail will be 0.5, and if zoomed in 2:1, its value is 2.
    5040 
    5041     For more advanced level-of-detail metrics, use
    5042     QStyleOptionGraphicsItem::matrix directly.
    5043 
    5044     \sa QStyleOptionGraphicsItem::matrix
     5188    \obsolete
     5189
     5190    Use QStyleOptionGraphicsItem::levelOfDetailFromTransform()
     5191    together with QPainter::worldTransform() instead.
    50455192*/
    50465193
     
    52735420*/
    52745421
     5422QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType)
     5423{
    52755424#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM)
    5276 QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType)
    5277 {
    52785425    switch (optionType) {
    52795426    case QStyleOption::SO_Default:
     
    53365483        debug << "SO_GraphicsItem"; break;
    53375484    }
     5485#endif
    53385486    return debug;
    53395487}
     
    53415489QDebug operator<<(QDebug debug, const QStyleOption &option)
    53425490{
     5491#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM)
    53435492    debug << "QStyleOption(";
    53445493    debug << QStyleOption::OptionType(option.type);
    5345     debug << "," << (option.direction == Qt::RightToLeft ? "RightToLeft" : "LeftToRight");
    5346     debug << "," << option.state;
    5347     debug << "," << option.rect;
    5348     debug << ")";
     5494    debug << ',' << (option.direction == Qt::RightToLeft ? "RightToLeft" : "LeftToRight");
     5495    debug << ',' << option.state;
     5496    debug << ',' << option.rect;
     5497    debug << ')';
     5498#endif
    53495499    return debug;
    53505500}
    5351 #endif
    53525501
    53535502QT_END_NAMESPACE
Note: See TracChangeset for help on using the changeset viewer.