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/qstyle.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**
     
    169169    \section1 Creating a Custom Style
    170170
    171     If you want to design a custom look and feel for your application,
    172     the first step is to pick one of the styles provided with Qt to
    173     build your custom style from. The choice will depend on which
    174     existing style resembles your style the most. The most general
    175     class that you can use as base is QCommonStyle (and not QStyle).
    176     This is because Qt requires its styles to be \l{QCommonStyle}s.
     171    You can create a custom look and feel for your application by
     172    creating a custom style. There are two approaches to creating a
     173    custom style. In the static approach, you either choose an
     174    existing QStyle class, subclass it, and reimplement virtual
     175    functions to provide the custom behavior, or you create an entire
     176    QStyle class from scratch. In the dynamic approach, you modify the
     177    behavior of your system style at runtime. The static approach is
     178    described below. The dynamic approach is described in QProxyStyle.
     179
     180    The first step in the static approach is to pick one of the styles
     181    provided by Qt from which you will build your custom style. Your
     182    choice of QStyle class will depend on which style resembles your
     183    desired style the most. The most general class that you can use as
     184    a base is QCommonStyle (not QStyle). This is because Qt requires
     185    its styles to be \l{QCommonStyle}s.
    177186
    178187    Depending on which parts of the base style you want to change,
     
    223232
    224233    There are several ways of using a custom style in a Qt
    225     application. The simplest way is call the
     234    application. The simplest way is to pass the custom style to the
    226235    QApplication::setStyle() static function before creating the
    227236    QApplication object:
     
    233242    set using the \c -style command-line option, is respected.
    234243
    235     You may want to make your style available for use in other
    236     applications, some of which may not be yours and are not available for
     244    You may want to make your custom style available for use in other
     245    applications, which may not be yours and hence not available for
    237246    you to recompile. The Qt Plugin system makes it possible to create
    238247    styles as plugins. Styles created as plugins are loaded as shared
     
    326335    : QObject(*new QStylePrivate)
    327336{
    328 }
    329 
     337    Q_D(QStyle);
     338    d->proxyStyle = this;
     339}
    330340
    331341/*!
     
    337347    : QObject(dd)
    338348{
     349  Q_D(QStyle);
     350  d->proxyStyle = this;
    339351}
    340352
     
    452464    if (!text.isEmpty()) {
    453465        result = metrics.boundingRect(x, y, w, h, alignment, text);
    454         if (!enabled && styleHint(SH_EtchDisabledText)) {
     466        if (!enabled && proxy()->styleHint(SH_EtchDisabledText)) {
    455467            result.setWidth(result.width()+1);
    456468            result.setHeight(result.height()+1);
     
    514526    }
    515527    if (!enabled) {
    516         if (styleHint(SH_DitherDisabledText)) {
    517             painter->drawText(rect, alignment, text);
    518             painter->fillRect(painter->boundingRect(rect, alignment, text), QBrush(painter->background().color(), Qt::Dense5Pattern));
     528        if (proxy()->styleHint(SH_DitherDisabledText)) {
     529            QRect br;
     530            painter->drawText(rect, alignment, text, &br);
     531            painter->fillRect(br, QBrush(painter->background().color(), Qt::Dense5Pattern));
    519532            return;
    520         } else if (styleHint(SH_EtchDisabledText)) {
     533        } else if (proxy()->styleHint(SH_EtchDisabledText)) {
    521534            QPen pen = painter->pen();
    522535            painter->setPen(pal.light().color());
     
    552565    \enum QStyle::PrimitiveElement
    553566
    554     This enum describes that various primitive elements. A
     567    This enum describes the various primitive elements. A
    555568    primitive element is a common GUI element, such as a checkbox
    556569    indicator or button bevel.
     
    10491062    \value SE_TabBarTabText Area for the text on a tab in a tab bar.
    10501063
     1064    \value SE_ToolBarHandle Area for the handle of a tool bar.
     1065
    10511066    \sa subElementRect()
    10521067*/
     
    10941109    \value CC_Slider            A slider, like QSlider.
    10951110    \value CC_ToolButton        A tool button, like QToolButton.
    1096     \value CC_TitleBar          A Title bar, like those used in QWorkspace.
     1111    \value CC_TitleBar          A Title bar, like those used in QMdiSubWindow.
    10971112    \value CC_Q3ListView        Used for drawing the Q3ListView class.
    10981113    \value CC_GroupBox          A group box, like QGroupBox.
     
    11781193    \value SC_All  Special value that matches all sub-controls.
    11791194    \omitvalue SC_Q3ListViewBranch
     1195    \omitvalue SC_CustomBase
    11801196
    11811197    \sa ComplexControl
     
    13311347
    13321348    \value PM_MaximumDragDistance The maximum allowed distance between
    1333     the mouse and a slider when dragging. Exceeding the specified
     1349    the mouse and a scrollbar when dragging. Exceeding the specified
    13341350    distance will cause the slider to jump back to the original
    13351351    position; a value of -1 disables this behavior.
     
    15711587
    15721588/*!
     1589    \enum QStyle::RequestSoftwareInputPanel
     1590
     1591    This enum describes under what circumstances a software input panel will be
     1592    requested by input capable widgets.
     1593
     1594    \value RSIP_OnMouseClickAndAlreadyFocused Requests an input panel if the user
     1595           clicks on the widget, but only if it is already focused.
     1596    \value RSIP_OnMouseClick Requests an input panel if the user clicks on the
     1597           widget.
     1598
     1599    \sa QEvent::RequestSoftwareInputPanel, QInputContext
     1600*/
     1601
     1602/*!
    15731603    \enum QStyle::StyleHint
    15741604
     
    18511881    \value SH_DockWidget_ButtonsHaveFrame Determines if dockwidget buttons should have frames. Default is true.
    18521882
     1883    \value SH_ToolButtonStyle Determines the default system style for tool buttons that uses Qt::ToolButtonFollowStyle.
     1884
     1885    \value SH_RequestSoftwareInputPanel Determines when a software input panel should
     1886           be requested by input widgets. Returns an enum of type QStyle::RequestSoftwareInputPanel.
     1887
    18531888    \omitvalue SH_UnderlineAccelerator
    18541889
     
    18631898    the given \a widget described by the provided style \a option.
    18641899
    1865     Note that currently, the \a returnData and \a widget parameters
    1866     are not used; they are provided for future enhancement. In
    1867     addition, the \a option parameter is used only in case of the
    1868     SH_ComboBox_Popup, SH_ComboBox_LayoutDirection, and
    1869     SH_GroupBox_TextLabelColor style hints.
     1900    \a returnData is used when the querying widget needs more detailed data than
     1901    the integer that styleHint() returns. See the QStyleHintReturn class
     1902    description for details.
    18701903*/
    18711904
     
    18771910
    18781911    \value SP_TitleBarMinButton  Minimize button on title bars (e.g.,
    1879         in QWorkspace).
     1912        in QMdiSubWindow).
    18801913    \value SP_TitleBarMenuButton Menu button on a title bar.
    18811914    \value SP_TitleBarMaxButton  Maximize button on title bars.
     
    19491982    custom values must be greater than this value.
    19501983
    1951     \sa standardPixmap() standardIcon()
    1952 */
    1953 
    1954 /*###
    1955   \enum QStyle::IconMode
    1956 
    1957   This enum represents the effects performed on a pixmap to achieve a
    1958   GUI style's perferred way of representing the image in different
    1959   states.
    1960 
    1961   \value IM_Disabled  A disabled pixmap (drawn on disabled widgets)
    1962   \value IM_Active  An active pixmap (drawn on active tool buttons and menu items)
    1963   \value IM_CustomBase  Base value for custom PixmapTypes; custom
    1964   values must be greater than this value
    1965 
    1966   \sa generatedIconPixmap()
     1984    \sa standardIcon()
    19671985*/
    19681986
     
    22472265    dynamically detect the slot and call it.
    22482266
    2249     \sa standardIconImplementation(), standardPixmap()
     2267    \sa standardIconImplementation()
    22502268*/
    22512269QIcon QStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *option,
     
    22722290    standardIcon() function (introduced in Qt 4.1) is not
    22732291    virtual. Instead, standardIcon() will dynamically detect and call
    2274     \e this slot.  The default implementation simply calls the
    2275     standardPixmap() function with the given parameters.
     2292    \e this slot.
    22762293
    22772294    The \a standardIcon is a standard pixmap which can follow some
     
    24012418}
    24022419
    2403 #if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM)
    24042420QT_BEGIN_INCLUDE_NAMESPACE
    24052421#include <QDebug>
     
    24082424QDebug operator<<(QDebug debug, QStyle::State state)
    24092425{
     2426#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM)
    24102427    debug << "QStyle::State(";
    24112428
     
    24382455    qSort(states);
    24392456    debug << states.join(QLatin1String(" | "));
    2440     debug << ")";
     2457    debug << ')';
     2458#endif
    24412459    return debug;
    24422460}
    2443 #endif
     2461
     2462/*!
     2463    \since 4.6
     2464
     2465    \fn const QStyle *QStyle::proxy() const
     2466
     2467    This function returns the current proxy for this style.
     2468    By default most styles will return themselves. However
     2469    when a proxy style is in use, it will allow the style to
     2470    call back into its proxy.
     2471*/
     2472const QStyle * QStyle::proxy() const
     2473{
     2474    Q_D(const QStyle);
     2475    return d->proxyStyle;
     2476}
     2477
     2478/* \internal
     2479
     2480    This function sets the base style that style calls will be
     2481    redirected to. Note that ownership is not transferred.
     2482*/
     2483void QStyle::setProxy(QStyle *style)
     2484{
     2485    Q_D(QStyle);
     2486    d->proxyStyle = style;
     2487}
    24442488
    24452489QT_END_NAMESPACE
Note: See TracChangeset for help on using the changeset viewer.