Changeset 561 for trunk/src/gui/styles/qstyle.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/styles/qstyle.cpp
r2 r561 2 2 ** 3 3 ** 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) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** 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. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 169 169 \section1 Creating a Custom Style 170 170 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. 177 186 178 187 Depending on which parts of the base style you want to change, … … 223 232 224 233 There are several ways of using a custom style in a Qt 225 application. The simplest way is callthe234 application. The simplest way is to pass the custom style to the 226 235 QApplication::setStyle() static function before creating the 227 236 QApplication object: … … 233 242 set using the \c -style command-line option, is respected. 234 243 235 You may want to make your style available for use in other236 applications, some of which may not be yours and are not available for244 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 237 246 you to recompile. The Qt Plugin system makes it possible to create 238 247 styles as plugins. Styles created as plugins are loaded as shared … … 326 335 : QObject(*new QStylePrivate) 327 336 { 328 } 329 337 Q_D(QStyle); 338 d->proxyStyle = this; 339 } 330 340 331 341 /*! … … 337 347 : QObject(dd) 338 348 { 349 Q_D(QStyle); 350 d->proxyStyle = this; 339 351 } 340 352 … … 452 464 if (!text.isEmpty()) { 453 465 result = metrics.boundingRect(x, y, w, h, alignment, text); 454 if (!enabled && styleHint(SH_EtchDisabledText)) {466 if (!enabled && proxy()->styleHint(SH_EtchDisabledText)) { 455 467 result.setWidth(result.width()+1); 456 468 result.setHeight(result.height()+1); … … 514 526 } 515 527 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)); 519 532 return; 520 } else if ( styleHint(SH_EtchDisabledText)) {533 } else if (proxy()->styleHint(SH_EtchDisabledText)) { 521 534 QPen pen = painter->pen(); 522 535 painter->setPen(pal.light().color()); … … 552 565 \enum QStyle::PrimitiveElement 553 566 554 This enum describes th atvarious primitive elements. A567 This enum describes the various primitive elements. A 555 568 primitive element is a common GUI element, such as a checkbox 556 569 indicator or button bevel. … … 1049 1062 \value SE_TabBarTabText Area for the text on a tab in a tab bar. 1050 1063 1064 \value SE_ToolBarHandle Area for the handle of a tool bar. 1065 1051 1066 \sa subElementRect() 1052 1067 */ … … 1094 1109 \value CC_Slider A slider, like QSlider. 1095 1110 \value CC_ToolButton A tool button, like QToolButton. 1096 \value CC_TitleBar A Title bar, like those used in Q Workspace.1111 \value CC_TitleBar A Title bar, like those used in QMdiSubWindow. 1097 1112 \value CC_Q3ListView Used for drawing the Q3ListView class. 1098 1113 \value CC_GroupBox A group box, like QGroupBox. … … 1178 1193 \value SC_All Special value that matches all sub-controls. 1179 1194 \omitvalue SC_Q3ListViewBranch 1195 \omitvalue SC_CustomBase 1180 1196 1181 1197 \sa ComplexControl … … 1331 1347 1332 1348 \value PM_MaximumDragDistance The maximum allowed distance between 1333 the mouse and a s lider when dragging. Exceeding the specified1349 the mouse and a scrollbar when dragging. Exceeding the specified 1334 1350 distance will cause the slider to jump back to the original 1335 1351 position; a value of -1 disables this behavior. … … 1571 1587 1572 1588 /*! 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 /*! 1573 1603 \enum QStyle::StyleHint 1574 1604 … … 1851 1881 \value SH_DockWidget_ButtonsHaveFrame Determines if dockwidget buttons should have frames. Default is true. 1852 1882 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 1853 1888 \omitvalue SH_UnderlineAccelerator 1854 1889 … … 1863 1898 the given \a widget described by the provided style \a option. 1864 1899 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. 1870 1903 */ 1871 1904 … … 1877 1910 1878 1911 \value SP_TitleBarMinButton Minimize button on title bars (e.g., 1879 in Q Workspace).1912 in QMdiSubWindow). 1880 1913 \value SP_TitleBarMenuButton Menu button on a title bar. 1881 1914 \value SP_TitleBarMaxButton Maximize button on title bars. … … 1949 1982 custom values must be greater than this value. 1950 1983 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() 1967 1985 */ 1968 1986 … … 2247 2265 dynamically detect the slot and call it. 2248 2266 2249 \sa standardIconImplementation() , standardPixmap()2267 \sa standardIconImplementation() 2250 2268 */ 2251 2269 QIcon QStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *option, … … 2272 2290 standardIcon() function (introduced in Qt 4.1) is not 2273 2291 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. 2276 2293 2277 2294 The \a standardIcon is a standard pixmap which can follow some … … 2401 2418 } 2402 2419 2403 #if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM)2404 2420 QT_BEGIN_INCLUDE_NAMESPACE 2405 2421 #include <QDebug> … … 2408 2424 QDebug operator<<(QDebug debug, QStyle::State state) 2409 2425 { 2426 #if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) 2410 2427 debug << "QStyle::State("; 2411 2428 … … 2438 2455 qSort(states); 2439 2456 debug << states.join(QLatin1String(" | ")); 2440 debug << ")"; 2457 debug << ')'; 2458 #endif 2441 2459 return debug; 2442 2460 } 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 */ 2472 const 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 */ 2483 void QStyle::setProxy(QStyle *style) 2484 { 2485 Q_D(QStyle); 2486 d->proxyStyle = style; 2487 } 2444 2488 2445 2489 QT_END_NAMESPACE
Note:
See TracChangeset
for help on using the changeset viewer.