diff options
Diffstat (limited to 'src/gui')
35 files changed, 452 insertions, 207 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index ae0abf9..22c3f92 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4889,6 +4889,24 @@ void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, b if (updateAll) return; + if (removingItemFromScene && !ignoreOpacity && !item->d_ptr->ignoreOpacity) { + // If any of the item's ancestors ignore opacity, it means that the opacity + // was set to 0 (and the update request has not yet been processed). That + // also means that we have to ignore the opacity for the item itself; otherwise + // things like: parent->setOpacity(0); scene->removeItem(child) won't work. + // Note that we only do this when removing items from the scene. In all other + // cases the ignoreOpacity bit propagates properly in processDirtyItems, but + // since the item is removed immediately it won't be processed there. + QGraphicsItem *p = item->d_ptr->parent; + while (p) { + if (p->d_ptr->ignoreOpacity) { + item->d_ptr->ignoreOpacity = true; + break; + } + p = p->d_ptr->parent; + } + } + if (item->d_ptr->discardUpdateRequest(/*ignoreVisibleBit=*/force, /*ignoreDirtyBit=*/removingItemFromScene || invalidateChildren, /*ignoreOpacity=*/ignoreOpacity)) { diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 9dfcd2c..a83b528 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -53,7 +53,7 @@ static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime < QGraphicsView visualizes the contents of a QGraphicsScene in a scrollable viewport. To create a scene with geometrical items, see QGraphicsScene's - documentation. QGraphicsView is part of \l{The Graphics View Framework}. + documentation. QGraphicsView is part of the \l{Graphics View Framework}. To visualize a scene, you start by constructing a QGraphicsView object, passing the address of the scene you want to visualize to QGraphicsView's diff --git a/src/gui/gui.pro b/src/gui/gui.pro index a6370b2..7f1cb78 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -3,6 +3,7 @@ QPRO_PWD = $$PWD QT = core DEFINES += QT_BUILD_GUI_LIB QT_NO_USING_NAMESPACE win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x65000000 +irix-cc*:QMAKE_CXXFLAGS += -no_prelink -ptused !win32:!embedded:!mac:!symbian:CONFIG += x11 diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 85be5b1..98f235e 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -4812,7 +4812,7 @@ bool QImageData::doImageIO(const QImage *image, QImageWriter *writer, int qualit or as a BMP image if the stream's version is 1. Note that writing the stream to a file will not produce a valid image file. - \sa QImage::save(), {Format of the QDataStream Operators} + \sa QImage::save(), {Serializing Qt Data Types} */ QDataStream &operator<<(QDataStream &s, const QImage &image) @@ -4838,7 +4838,7 @@ QDataStream &operator<<(QDataStream &s, const QImage &image) Reads an image from the given \a stream and stores it in the given \a image. - \sa QImage::load(), {Format of the QDataStream Operators} + \sa QImage::load(), {Serializing Qt Data Types} */ QDataStream &operator>>(QDataStream &s, QImage &image) diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 474cd2e..48c5d3f 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -1281,7 +1281,7 @@ bool QPixmap::convertFromImage(const QImage &image, ColorMode mode) image. Note that writing the stream to a file will not produce a valid image file. - \sa QPixmap::save(), {Format of the QDataStream Operators} + \sa QPixmap::save(), {Serializing Qt Data Types} */ QDataStream &operator<<(QDataStream &stream, const QPixmap &pixmap) @@ -1294,7 +1294,7 @@ QDataStream &operator<<(QDataStream &stream, const QPixmap &pixmap) Reads an image from the given \a stream into the given \a pixmap. - \sa QPixmap::load(), {Format of the QDataStream Operators} + \sa QPixmap::load(), {Serializing Qt Data Types} */ QDataStream &operator>>(QDataStream &stream, QPixmap &pixmap) diff --git a/src/gui/itemviews/qlistwidget.cpp b/src/gui/itemviews/qlistwidget.cpp index 125f0c4..da1d5db 100644 --- a/src/gui/itemviews/qlistwidget.cpp +++ b/src/gui/itemviews/qlistwidget.cpp @@ -791,7 +791,7 @@ QListWidgetItem &QListWidgetItem::operator=(const QListWidgetItem &other) This operator uses QListWidgetItem::write(). - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator<<(QDataStream &out, const QListWidgetItem &item) { @@ -806,7 +806,7 @@ QDataStream &operator<<(QDataStream &out, const QListWidgetItem &item) This operator uses QListWidgetItem::read(). - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item) { diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp index b12cd45..f9b6b94 100644 --- a/src/gui/itemviews/qsortfilterproxymodel.cpp +++ b/src/gui/itemviews/qsortfilterproxymodel.cpp @@ -2392,7 +2392,7 @@ bool QSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex QVariant r = (right.model() ? right.model()->data(right, d->sort_role) : QVariant()); switch (l.userType()) { case QVariant::Invalid: - return (r.type() == QVariant::Invalid); + return (r.type() != QVariant::Invalid); case QVariant::Int: return l.toInt() < r.toInt(); case QVariant::UInt: diff --git a/src/gui/itemviews/qstandarditemmodel.cpp b/src/gui/itemviews/qstandarditemmodel.cpp index 9d52c78..767b5a9 100644 --- a/src/gui/itemviews/qstandarditemmodel.cpp +++ b/src/gui/itemviews/qstandarditemmodel.cpp @@ -1921,7 +1921,7 @@ void QStandardItem::write(QDataStream &out) const This operator uses QStandardItem::read(). - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator>>(QDataStream &in, QStandardItem &item) { @@ -1937,7 +1937,7 @@ QDataStream &operator>>(QDataStream &in, QStandardItem &item) This operator uses QStandardItem::write(). - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator<<(QDataStream &out, const QStandardItem &item) { diff --git a/src/gui/itemviews/qtablewidget.cpp b/src/gui/itemviews/qtablewidget.cpp index f653a41..5bb242e 100644 --- a/src/gui/itemviews/qtablewidget.cpp +++ b/src/gui/itemviews/qtablewidget.cpp @@ -1428,7 +1428,7 @@ void QTableWidgetItem::write(QDataStream &out) const This operator uses QTableWidgetItem::read(). - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator>>(QDataStream &in, QTableWidgetItem &item) { @@ -1443,7 +1443,7 @@ QDataStream &operator>>(QDataStream &in, QTableWidgetItem &item) This operator uses QTableWidgetItem::write(). - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator<<(QDataStream &out, const QTableWidgetItem &item) { diff --git a/src/gui/itemviews/qtreewidget.cpp b/src/gui/itemviews/qtreewidget.cpp index 4c80325..0e06f34 100644 --- a/src/gui/itemviews/qtreewidget.cpp +++ b/src/gui/itemviews/qtreewidget.cpp @@ -2199,7 +2199,7 @@ void QTreeWidgetItem::executePendingSort() const This operator uses QTreeWidgetItem::write(). - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator<<(QDataStream &out, const QTreeWidgetItem &item) { @@ -2214,7 +2214,7 @@ QDataStream &operator<<(QDataStream &out, const QTreeWidgetItem &item) This operator uses QTreeWidgetItem::read(). - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator>>(QDataStream &in, QTreeWidgetItem &item) { diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 7b62de1..0d11b27 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -666,7 +666,8 @@ void QApplicationPrivate::process_cmdline() \o -geometry \e geometry, sets the client geometry of the first window that is shown. \o -fn or \c -font \e font, defines the application font. The font - should be specified using an X logical font description. + should be specified using an X logical font description. Note that + this option is ignored when Qt is built with fontconfig support enabled. \o -bg or \c -background \e color, sets the default background color and an application palette (light and dark shades are calculated). \o -fg or \c -foreground \e color, sets the default foreground color. @@ -2218,15 +2219,17 @@ void QApplication::closeAllWindows() { bool did_close = true; QWidget *w; - while((w = activeModalWidget()) && did_close) { - if(!w->isVisible()) + while ((w = activeModalWidget()) && did_close) { + if (!w->isVisible() || w->data->is_closing) break; did_close = w->close(); } QWidgetList list = QApplication::topLevelWidgets(); for (int i = 0; did_close && i < list.size(); ++i) { w = list.at(i); - if (w->isVisible() && w->windowType() != Qt::Desktop) { + if (w->isVisible() + && w->windowType() != Qt::Desktop + && !w->data->is_closing) { did_close = w->close(); list = QApplication::topLevelWidgets(); i = -1; @@ -5268,18 +5271,20 @@ bool QApplication::keypadNavigationEnabled() This function replaces the QInputContext instance used by the application with \a inputContext. + Qt takes ownership of the given \a inputContext. + \sa inputContext() */ void QApplication::setInputContext(QInputContext *inputContext) { - Q_D(QApplication); - Q_UNUSED(d);// only static members being used. + if (inputContext == QApplicationPrivate::inputContext) + return; if (!inputContext) { qWarning("QApplication::setInputContext: called with 0 input context"); return; } - delete d->inputContext; - d->inputContext = inputContext; + delete QApplicationPrivate::inputContext; + QApplicationPrivate::inputContext = inputContext; } /*! diff --git a/src/gui/kernel/qdnd_x11.cpp b/src/gui/kernel/qdnd_x11.cpp index 2b12317..92dd0a1 100644 --- a/src/gui/kernel/qdnd_x11.cpp +++ b/src/gui/kernel/qdnd_x11.cpp @@ -64,6 +64,7 @@ #include "qtextcodec.h" #include "qdnd_p.h" +#include "qapplication_p.h" #include "qt_x11_p.h" #include "qx11info_x11.h" @@ -1111,7 +1112,20 @@ void qt_xdnd_send_leave() waiting_for_status = false; } - +// TODO: remove and use QApplication::currentKeyboardModifiers() in Qt 4.8. +static Qt::KeyboardModifiers currentKeyboardModifiers() +{ + Window root; + Window child; + int root_x, root_y, win_x, win_y; + uint keybstate; + for (int i = 0; i < ScreenCount(X11->display); ++i) { + if (XQueryPointer(X11->display, QX11Info::appRootWindow(i), &root, &child, + &root_x, &root_y, &win_x, &win_y, &keybstate)) + return X11->translateModifiers(keybstate & 0x00ff); + } + return 0; +} void QX11Data::xdndHandleDrop(QWidget *, const XEvent * xe, bool passive) { @@ -1159,6 +1173,11 @@ void QX11Data::xdndHandleDrop(QWidget *, const XEvent * xe, bool passive) if (!dropData) dropData = (manager->object) ? manager->dragPrivate()->data : manager->dropData; + // Drop coming from another app? Update keyboard modifiers. + if (!qt_xdnd_dragging) { + QApplicationPrivate::modifier_buttons = currentKeyboardModifiers(); + } + QDropEvent de(qt_xdnd_current_position, possible_actions, dropData, QApplication::mouseButtons(), QApplication::keyboardModifiers()); QApplication::sendEvent(qt_xdnd_current_widget, &de); diff --git a/src/gui/kernel/qt_cocoa_helpers_mac_p.h b/src/gui/kernel/qt_cocoa_helpers_mac_p.h index 5db121a..44fb4f0 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac_p.h +++ b/src/gui/kernel/qt_cocoa_helpers_mac_p.h @@ -73,6 +73,9 @@ ** ****************************************************************************/ +#ifndef QT_COCOA_HELPERS_MAC_P_H +#define QT_COCOA_HELPERS_MAC_P_H + // // W A R N I N G // ------------- @@ -216,3 +219,5 @@ bool qt_cocoaPostMessage(id target, SEL selector); void qt_mac_post_retranslateAppMenu(); QT_END_NAMESPACE + +#endif // QT_COCOA_HELPERS_MAC_P_H diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 1f2cd8c..569af42 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -312,6 +312,8 @@ QInputContext *QWidget::inputContext() This function sets the input context \a context on this widget. + Qt takes ownership of the given input \a context. + \sa inputContext() */ void QWidget::setInputContext(QInputContext *context) @@ -320,6 +322,8 @@ void QWidget::setInputContext(QInputContext *context) if (!testAttribute(Qt::WA_InputMethodEnabled)) return; #ifndef QT_NO_IM + if (context == d->ic) + return; if (d->ic) delete d->ic; d->ic = context; @@ -670,8 +674,8 @@ void QWidget::setAutoFillBackground(bool enabled) (to move the keyboard focus), and passes on most of the other events to one of the more specialized handlers above. - Events and the mechanism used to deliver them are covered in the - \l{Events and Event Filters} document. + Events and the mechanism used to deliver them are covered in + \l{The Event System}. \section1 Groups of Functions and Properties diff --git a/src/gui/math3d/qgenericmatrix.cpp b/src/gui/math3d/qgenericmatrix.cpp index 96405a8b..be30cb6 100644 --- a/src/gui/math3d/qgenericmatrix.cpp +++ b/src/gui/math3d/qgenericmatrix.cpp @@ -252,7 +252,7 @@ QT_BEGIN_NAMESPACE Writes the given \a matrix to the given \a stream and returns a reference to the stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ /*! @@ -262,7 +262,7 @@ QT_BEGIN_NAMESPACE Reads a NxM matrix from the given \a stream into the given \a matrix and returns a reference to the stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ #endif diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index 62d740c..16c7f97 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -1878,7 +1878,7 @@ QDebug operator<<(QDebug dbg, const QMatrix4x4 &m) Writes the given \a matrix to the given \a stream and returns a reference to the stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator<<(QDataStream &stream, const QMatrix4x4 &matrix) @@ -1896,7 +1896,7 @@ QDataStream &operator<<(QDataStream &stream, const QMatrix4x4 &matrix) Reads a 4x4 matrix from the given \a stream into the given \a matrix and returns a reference to the stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator>>(QDataStream &stream, QMatrix4x4 &matrix) diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp index ad71836..2fd66eb 100644 --- a/src/gui/math3d/qquaternion.cpp +++ b/src/gui/math3d/qquaternion.cpp @@ -595,7 +595,7 @@ QDebug operator<<(QDebug dbg, const QQuaternion &q) Writes the given \a quaternion to the given \a stream and returns a reference to the stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator<<(QDataStream &stream, const QQuaternion &quaternion) @@ -612,7 +612,7 @@ QDataStream &operator<<(QDataStream &stream, const QQuaternion &quaternion) Reads a quaternion from the given \a stream into the given \a quaternion and returns a reference to the stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator>>(QDataStream &stream, QQuaternion &quaternion) diff --git a/src/gui/math3d/qvector2d.cpp b/src/gui/math3d/qvector2d.cpp index b67e8a1..6a5cfc8 100644 --- a/src/gui/math3d/qvector2d.cpp +++ b/src/gui/math3d/qvector2d.cpp @@ -434,7 +434,7 @@ QDebug operator<<(QDebug dbg, const QVector2D &vector) Writes the given \a vector to the given \a stream and returns a reference to the stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator<<(QDataStream &stream, const QVector2D &vector) @@ -450,7 +450,7 @@ QDataStream &operator<<(QDataStream &stream, const QVector2D &vector) Reads a 2D vector from the given \a stream into the given \a vector and returns a reference to the stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator>>(QDataStream &stream, QVector2D &vector) diff --git a/src/gui/math3d/qvector3d.cpp b/src/gui/math3d/qvector3d.cpp index 6a592b2..dfcce0e 100644 --- a/src/gui/math3d/qvector3d.cpp +++ b/src/gui/math3d/qvector3d.cpp @@ -585,7 +585,7 @@ QDebug operator<<(QDebug dbg, const QVector3D &vector) Writes the given \a vector to the given \a stream and returns a reference to the stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator<<(QDataStream &stream, const QVector3D &vector) @@ -602,7 +602,7 @@ QDataStream &operator<<(QDataStream &stream, const QVector3D &vector) Reads a 3D vector from the given \a stream into the given \a vector and returns a reference to the stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator>>(QDataStream &stream, QVector3D &vector) diff --git a/src/gui/math3d/qvector4d.cpp b/src/gui/math3d/qvector4d.cpp index f2f3cc6..abff1ba 100644 --- a/src/gui/math3d/qvector4d.cpp +++ b/src/gui/math3d/qvector4d.cpp @@ -538,7 +538,7 @@ QDebug operator<<(QDebug dbg, const QVector4D &vector) Writes the given \a vector to the given \a stream and returns a reference to the stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator<<(QDataStream &stream, const QVector4D &vector) @@ -555,7 +555,7 @@ QDataStream &operator<<(QDataStream &stream, const QVector4D &vector) Reads a 4D vector from the given \a stream into the given \a vector and returns a reference to the stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator>>(QDataStream &stream, QVector4D &vector) diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index 96d547b..b468b11 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -329,8 +329,8 @@ struct QBrushDataPointerDeleter \endtable - For more information about painting in general, see \l{The Paint - System} documentation. + For more information about painting in general, see the \l{Paint + System}. \sa Qt::BrushStyle, QPainter, QColor */ @@ -1013,7 +1013,7 @@ QDebug operator<<(QDebug dbg, const QBrush &b) Writes the given \a brush to the given \a stream and returns a reference to the \a stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator<<(QDataStream &s, const QBrush &b) @@ -1081,7 +1081,7 @@ QDataStream &operator<<(QDataStream &s, const QBrush &b) Reads the given \a brush from the given \a stream and returns a reference to the \a stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator>>(QDataStream &s, QBrush &b) diff --git a/src/gui/painting/qpaintdevice.qdoc b/src/gui/painting/qpaintdevice.qdoc index 8c73cc0..340db39 100644 --- a/src/gui/painting/qpaintdevice.qdoc +++ b/src/gui/painting/qpaintdevice.qdoc @@ -87,8 +87,7 @@ function returns the number of different colors available for the paint device. - \sa QPaintEngine, QPainter, {The Coordinate System}, {The Paint - System} + \sa QPaintEngine, QPainter, {Coordinate System}, {Paint System} */ /*! diff --git a/src/gui/painting/qpaintengine.cpp b/src/gui/painting/qpaintengine.cpp index 6aabde8..a2d0337 100644 --- a/src/gui/painting/qpaintengine.cpp +++ b/src/gui/painting/qpaintengine.cpp @@ -172,7 +172,7 @@ QFont QTextItem::font() const possible to adapt to multiple technologies on each platform and take advantage of each to the fullest. - \sa QPainter, QPaintDevice::paintEngine(), {The Paint System} + \sa QPainter, QPaintDevice::paintEngine(), {Paint System} */ /*! diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp index e290cbe..2e43984 100644 --- a/src/gui/painting/qpen.cpp +++ b/src/gui/painting/qpen.cpp @@ -92,7 +92,7 @@ typedef QPenPrivate QPenData; convenience functions to extract and set the color of the pen's brush, respectively. Pens may also be compared and streamed. - For more information about painting in general, see \l{The Paint + For more information about painting in general, see the \l{Paint System} documentation. \tableofcontents @@ -872,7 +872,7 @@ bool QPen::isDetached() Writes the given \a pen to the given \a stream and returns a reference to the \a stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator<<(QDataStream &s, const QPen &p) @@ -918,7 +918,7 @@ QDataStream &operator<<(QDataStream &s, const QPen &p) Reads a pen from the given \a stream into the given \a pen and returns a reference to the \a stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator>>(QDataStream &s, QPen &p) diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index aaa241f..423cce9 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -148,8 +148,8 @@ QT_BEGIN_NAMESPACE coordinate system. The standard coordinate system of a QPaintDevice has its origin located at the top-left position. The \e x values increase to the right; \e y values increase - downward. For a complete description, see the \l {The Coordinate - System}{coordinate system} documentation. + downward. For a complete description, see the \l {Coordinate + System} {coordinate system} documentation. QPainter has functions to translate, scale, shear and rotate the coordinate system without using a QTransform. For example: @@ -223,7 +223,7 @@ QT_BEGIN_NAMESPACE \snippet doc/src/snippets/transform/main.cpp 2 \endtable - \sa QPainter, {The Coordinate System}, {demos/affine}{Affine + \sa QPainter, {Coordinate System}, {demos/affine}{Affine Transformations Demo}, {Transformations Example} */ @@ -1028,7 +1028,7 @@ void QTransform::reset() Writes the given \a matrix to the given \a stream and returns a reference to the stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream & operator<<(QDataStream &s, const QTransform &m) { @@ -1052,7 +1052,7 @@ QDataStream & operator<<(QDataStream &s, const QTransform &m) Reads the given \a matrix from the given \a stream and returns a reference to the stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream & operator>>(QDataStream &s, QTransform &t) { diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index 6c8d561..9d6dc9a 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -325,6 +325,7 @@ void QGtkStyle::polish(QApplication *app) qt_filedialog_save_filename_hook = &QGtkStylePrivate::saveFilename; qt_filedialog_open_filenames_hook = &QGtkStylePrivate::openFilenames; qt_filedialog_existing_directory_hook = &QGtkStylePrivate::openDirectory; + qApp->installEventFilter(&d->filter); } } } @@ -345,6 +346,7 @@ void QGtkStyle::unpolish(QApplication *app) qt_filedialog_save_filename_hook = 0; qt_filedialog_open_filenames_hook = 0; qt_filedialog_existing_directory_hook = 0; + qApp->removeEventFilter(&d->filter); } } diff --git a/src/gui/styles/qgtkstyle_p.cpp b/src/gui/styles/qgtkstyle_p.cpp index 3c6a1ef..4ed0fab 100644 --- a/src/gui/styles/qgtkstyle_p.cpp +++ b/src/gui/styles/qgtkstyle_p.cpp @@ -285,8 +285,6 @@ void QGtkStylePrivate::init() { resolveGtk(); initGtkWidgets(); - if (isThemeAvailable()) - qApp->installEventFilter(&filter); } GtkWidget* QGtkStylePrivate::gtkWidget(const QHashableLatin1Literal &path) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 2e2f374..f029602 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -100,23 +100,22 @@ #include <QtGui/qgraphicsproxywidget.h> #include <QtGui/qgraphicsview.h> #include <private/qt_cocoa_helpers_mac_p.h> +#include "qmacstyle_mac_p.h" #include <private/qstylehelper_p.h> QT_BEGIN_NAMESPACE -extern QRegion qt_mac_convert_mac_region(RgnHandle); //qregion_mac.cpp - // The following constants are used for adjusting the size // of push buttons so that they are drawn inside their bounds. -static const int PushButtonLeftOffset = 6; -static const int PushButtonTopOffset = 4; -static const int PushButtonRightOffset = 12; -static const int PushButtonBottomOffset = 12; -static const int MiniButtonH = 26; -static const int SmallButtonH = 30; -static const int BevelButtonW = 50; -static const int BevelButtonH = 22; -static const int PushButtonContentPadding = 6; +const int QMacStylePrivate::PushButtonLeftOffset = 6; +const int QMacStylePrivate::PushButtonTopOffset = 4; +const int QMacStylePrivate::PushButtonRightOffset = 12; +const int QMacStylePrivate::PushButtonBottomOffset = 12; +const int QMacStylePrivate::MiniButtonH = 26; +const int QMacStylePrivate::SmallButtonH = 30; +const int QMacStylePrivate::BevelButtonW = 50; +const int QMacStylePrivate::BevelButtonH = 22; +const int QMacStylePrivate::PushButtonContentPadding = 6; // These colors specify the titlebar gradient colors on // Leopard. Ideally we should get them from the system. @@ -132,25 +131,16 @@ static const QColor titlebarSeparatorLineInactive(131, 131, 131); static const QColor mainWindowGradientBegin(240, 240, 240); static const QColor mainWindowGradientEnd(200, 200, 200); -#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5) -enum { - kThemePushButtonTextured = 31, - kThemePushButtonTexturedSmall = 32, - kThemePushButtonTexturedMini = 33 -}; - -/* Search fields */ -enum { - kHIThemeFrameTextFieldRound = 1000, - kHIThemeFrameTextFieldRoundSmall = 1001, - kHIThemeFrameTextFieldRoundMini = 1002 -}; -#endif +static const int DisclosureOffset = 4; // Resolve these at run-time, since the functions was moved in Leopard. typedef HIRect * (*PtrHIShapeGetBounds)(HIShapeRef, HIRect *); static PtrHIShapeGetBounds ptrHIShapeGetBounds = 0; +static int closeButtonSize = 12; + +extern QRegion qt_mac_convert_mac_region(RgnHandle); //qregion_mac.cpp + static bool isVerticalTabs(const QTabBar::Shape shape) { return (shape == QTabBar::RoundedEast || shape == QTabBar::TriangularEast @@ -158,8 +148,6 @@ static bool isVerticalTabs(const QTabBar::Shape shape) { || shape == QTabBar::TriangularWest); } -static int closeButtonSize = 12; - void drawTabCloseButton(QPainter *p, bool hover, bool active, bool selected) { // draw background circle @@ -378,32 +366,6 @@ void drawTabBase(QPainter *p, const QStyleOptionTabBarBaseV2 *tbb, const QWidget p->drawLine(tabRect.x(), height - 1, width, height - 1); } -/* - AHIG: - Apple Human Interface Guidelines - http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/ - - Builder: - Apple Interface Builder v. 3.1.1 -*/ - -// this works as long as we have at most 16 different control types -#define CT1(c) CT2(c, c) -#define CT2(c1, c2) ((uint(c1) << 16) | uint(c2)) - -enum QAquaWidgetSize { QAquaSizeLarge = 0, QAquaSizeSmall = 1, QAquaSizeMini = 2, - QAquaSizeUnknown = -1 }; - -#define SIZE(large, small, mini) \ - (controlSize == QAquaSizeLarge ? (large) : controlSize == QAquaSizeSmall ? (small) : (mini)) - -// same as return SIZE(...) but optimized -#define return_SIZE(large, small, mini) \ - do { \ - static const int sizes[] = { (large), (small), (mini) }; \ - return sizes[controlSize]; \ - } while (0) - static int getControlSize(const QStyleOption *option, const QWidget *widget) { if (option) { @@ -481,80 +443,9 @@ static inline ThemeTabDirection getTabDirection(QTabBar::Shape shape) return ttd; } -class QMacStylePrivate : public QObject -{ - Q_OBJECT - -public: - QMacStylePrivate(QMacStyle *style); - - // Stuff from QAquaAnimate: - bool addWidget(QWidget *); - void removeWidget(QWidget *); - - enum Animates { AquaPushButton, AquaProgressBar, AquaListViewItemOpen }; - bool animatable(Animates, const QWidget *) const; - void stopAnimate(Animates, QWidget *); - void startAnimate(Animates, QWidget *); - static ThemeDrawState getDrawState(QStyle::State flags); - QAquaWidgetSize aquaSizeConstrain(const QStyleOption *option, const QWidget *widg, - QStyle::ContentsType ct = QStyle::CT_CustomBase, - QSize szHint=QSize(-1, -1), QSize *insz = 0) const; - void getSliderInfo(QStyle::ComplexControl cc, const QStyleOptionSlider *slider, - HIThemeTrackDrawInfo *tdi, const QWidget *needToRemoveMe); - bool doAnimate(Animates); - inline int animateSpeed(Animates) const { return 33; } - - // Utility functions - void drawColorlessButton(const HIRect &macRect, HIThemeButtonDrawInfo *bdi, - QPainter *p, const QStyleOption *opt) const; - - QSize pushButtonSizeFromContents(const QStyleOptionButton *btn) const; - - HIRect pushButtonContentBounds(const QStyleOptionButton *btn, - const HIThemeButtonDrawInfo *bdi) const; - - void initComboboxBdi(const QStyleOptionComboBox *combo, HIThemeButtonDrawInfo *bdi, - const QWidget *widget, const ThemeDrawState &tds); - - static HIRect comboboxInnerBounds(const HIRect &outerBounds, int buttonKind); - - static QRect comboboxEditBounds(const QRect &outerBounds, const HIThemeButtonDrawInfo &bdi); - - static void drawCombobox(const HIRect &outerBounds, const HIThemeButtonDrawInfo &bdi, QPainter *p); - static void drawTableHeader(const HIRect &outerBounds, bool drawTopBorder, bool drawLeftBorder, - const HIThemeButtonDrawInfo &bdi, QPainter *p); - bool contentFitsInPushButton(const QStyleOptionButton *btn, HIThemeButtonDrawInfo *bdi, - ThemeButtonKind buttonKindToCheck) const; - void initHIThemePushButton(const QStyleOptionButton *btn, const QWidget *widget, - const ThemeDrawState tds, - HIThemeButtonDrawInfo *bdi) const; - QPixmap generateBackgroundPattern() const; -protected: - bool eventFilter(QObject *, QEvent *); - void timerEvent(QTimerEvent *); - -private slots: - void startAnimationTimer(); - -public: - QPointer<QPushButton> defaultButton; //default push buttons - int timerID; - QList<QPointer<QWidget> > progressBars; //existing progress bars that need animation - - struct ButtonState { - int frame; - enum { ButtonDark, ButtonLight } dir; - } buttonState; - UInt8 progressFrame; - QPointer<QFocusFrame> focusWidget; - CFAbsoluteTime defaultButtonStart; - QMacStyle *q; - bool mouseDown; -}; - QT_BEGIN_INCLUDE_NAMESPACE -#include "qmacstyle_mac.moc" +#include "moc_qmacstyle_mac.cpp" +#include "moc_qmacstyle_mac_p.cpp" QT_END_INCLUDE_NAMESPACE /***************************************************************************** @@ -1055,10 +946,10 @@ HIRect QMacStylePrivate::pushButtonContentBounds(const QStyleOptionButton *btn, // Adjust the bounds to correct for // carbon not calculating the content bounds fully correct if (bdi->kind == kThemePushButton || bdi->kind == kThemePushButtonSmall){ - outerBounds.origin.y += PushButtonTopOffset; - outerBounds.size.height -= PushButtonBottomOffset; + outerBounds.origin.y += QMacStylePrivate::PushButtonTopOffset; + outerBounds.size.height -= QMacStylePrivate::PushButtonBottomOffset; } else if (bdi->kind == kThemePushButtonMini) { - outerBounds.origin.y += PushButtonTopOffset; + outerBounds.origin.y += QMacStylePrivate::PushButtonTopOffset; } HIRect contentBounds; @@ -1074,7 +965,7 @@ QSize QMacStylePrivate::pushButtonSizeFromContents(const QStyleOptionButton *btn { QSize csz(0, 0); QSize iconSize = btn->icon.isNull() ? QSize(0, 0) - : (btn->iconSize + QSize(PushButtonContentPadding, 0)); + : (btn->iconSize + QSize(QMacStylePrivate::PushButtonContentPadding, 0)); QRect textRect = btn->text.isEmpty() ? QRect(0, 0, 1, 1) : btn->fontMetrics.boundingRect(QRect(), Qt::AlignCenter, btn->text); csz.setWidth(iconSize.width() + textRect.width() @@ -1149,12 +1040,12 @@ void QMacStylePrivate::initHIThemePushButton(const QStyleOptionButton *btn, // Choose the button kind that closest match the button rect, but at the // same time displays the button contents without clipping. bdi->kind = kThemeBevelButton; - if (btn->rect.width() >= BevelButtonW && btn->rect.height() >= BevelButtonH){ + if (btn->rect.width() >= QMacStylePrivate::BevelButtonW && btn->rect.height() >= QMacStylePrivate::BevelButtonH){ if (widget && widget->testAttribute(Qt::WA_MacVariableSize)) { - if (btn->rect.height() <= MiniButtonH){ + if (btn->rect.height() <= QMacStylePrivate::MiniButtonH){ if (contentFitsInPushButton(btn, bdi, kThemePushButtonMini)) bdi->kind = kThemePushButtonMini; - } else if (btn->rect.height() <= SmallButtonH){ + } else if (btn->rect.height() <= QMacStylePrivate::SmallButtonH){ if (contentFitsInPushButton(btn, bdi, kThemePushButtonSmall)) bdi->kind = kThemePushButtonSmall; } else if (contentFitsInPushButton(btn, bdi, kThemePushButton)) { @@ -3100,7 +2991,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai else bi.value = opt->direction == Qt::LeftToRight ? kThemeDisclosureRight : kThemeDisclosureLeft; bi.adornment = kThemeAdornmentNone; - HIRect hirect = qt_hirectForQRect(opt->rect); + HIRect hirect = qt_hirectForQRect(opt->rect.adjusted(DisclosureOffset,0,-DisclosureOffset,0)); HIThemeDrawButton(&hirect, &bi, cg, kHIThemeOrientationNormal, 0); break; } @@ -3494,21 +3385,21 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter // the focus 'shadow' will be inside. HIRect newRect = qt_hirectForQRect(btn->rect); if (bdi.kind == kThemePushButton || bdi.kind == kThemePushButtonSmall) { - newRect.origin.x += PushButtonLeftOffset; - newRect.origin.y += PushButtonTopOffset; - newRect.size.width -= PushButtonRightOffset; - newRect.size.height -= PushButtonBottomOffset; + newRect.origin.x += QMacStylePrivate::PushButtonLeftOffset; + newRect.origin.y += QMacStylePrivate::PushButtonTopOffset; + newRect.size.width -= QMacStylePrivate::PushButtonRightOffset; + newRect.size.height -= QMacStylePrivate::PushButtonBottomOffset; } else if (bdi.kind == kThemePushButtonMini) { - newRect.origin.x += PushButtonLeftOffset - 2; - newRect.origin.y += PushButtonTopOffset; - newRect.size.width -= PushButtonRightOffset - 4; + newRect.origin.x += QMacStylePrivate::PushButtonLeftOffset - 2; + newRect.origin.y += QMacStylePrivate::PushButtonTopOffset; + newRect.size.width -= QMacStylePrivate::PushButtonRightOffset - 4; } HIThemeDrawButton(&newRect, &bdi, cg, kHIThemeOrientationNormal, 0); if (btn->features & QStyleOptionButton::HasMenu) { int mbi = proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator, btn, w); QRect ir = btn->rect; - HIRect arrowRect = CGRectMake(ir.right() - mbi - PushButtonRightOffset, + HIRect arrowRect = CGRectMake(ir.right() - mbi - QMacStylePrivate::PushButtonRightOffset, ir.height() / 2 - 4, mbi, ir.height() / 2); bool drawColorless = btn->palette.currentColorGroup() == QPalette::Active; if (drawColorless && tds == kThemeStateInactive) @@ -3602,14 +3493,14 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter if (btn->state & State_On) state = QIcon::On; QPixmap pixmap = btn->icon.pixmap(btn->iconSize, mode, state); - contentW += pixmap.width() + PushButtonContentPadding; + contentW += pixmap.width() + QMacStylePrivate::PushButtonContentPadding; int iconLeftOffset = freeContentRect.x() + (freeContentRect.width() - contentW) / 2; int iconTopOffset = freeContentRect.y() + (freeContentRect.height() - pixmap.height()) / 2; QRect iconDestRect(iconLeftOffset, iconTopOffset, pixmap.width(), pixmap.height()); QRect visualIconDestRect = visualRect(btn->direction, freeContentRect, iconDestRect); proxy()->drawItemPixmap(p, visualIconDestRect, Qt::AlignLeft | Qt::AlignVCenter, pixmap); int newOffset = iconDestRect.x() + iconDestRect.width() - + PushButtonContentPadding - textRect.x(); + + QMacStylePrivate::PushButtonContentPadding - textRect.x(); textRect.adjust(newOffset, 0, newOffset, 0); } // Draw the text: @@ -4352,6 +4243,15 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, int controlSize = getControlSize(opt, widget); switch (sr) { + case SE_ItemViewItemText: + if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) { + int fw = proxy()->pixelMetric(PM_FocusFrameHMargin, opt, widget); + // We add the focusframeargin between icon and text in commonstyle + rect = QCommonStyle::subElementRect(sr, opt, widget); + if (vopt->features & QStyleOptionViewItemV2::HasDecoration) + rect.adjust(-fw, 0, 0, 0); + } + break; case SE_ToolBoxTabContents: rect = QCommonStyle::subElementRect(sr, opt, widget); break; @@ -4369,9 +4269,9 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, case SE_HeaderLabel: if (qstyleoption_cast<const QStyleOptionHeader *>(opt)) { rect = QWindowsStyle::subElementRect(sr, opt, widget); - if (widget && widget->height() <= qt_mac_aqua_get_metric(kThemeMetricListHeaderHeight)){ - // We need to allow the text a bit more space when the header is as - // small as kThemeMetricListHeaderHeight, otherwise it gets clipped: + if (widget && widget->height() <= 22){ + // We need to allow the text a bit more space when the header is + // small, otherwise it gets clipped: rect.setY(0); rect.setHeight(widget->height()); } @@ -4398,8 +4298,9 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, HIRect outRect; HIThemeGetButtonShape(&inRect, &bdi, &shape); ptrHIShapeGetBounds(shape, &outRect); - rect = QRect(int(outRect.origin.x), int(outRect.origin.y), - int(contentRect.origin.x - outRect.origin.x), int(outRect.size.height)); + rect = QRect(int(outRect.origin.x + DisclosureOffset), int(outRect.origin.y), + int(contentRect.origin.x - outRect.origin.x + DisclosureOffset), + int(outRect.size.height)); break; } case SE_TabWidgetLeftCorner: @@ -5695,8 +5596,8 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, // By default, we fit the contents inside a normal rounded push button. // Do this by add enough space around the contents so that rounded // borders (including highlighting when active) will show. - sz.rwidth() += PushButtonLeftOffset + PushButtonRightOffset + 12; - sz.rheight() += PushButtonTopOffset + PushButtonBottomOffset; + sz.rwidth() += QMacStylePrivate::PushButtonLeftOffset + QMacStylePrivate::PushButtonRightOffset + 12; + sz.rheight() += QMacStylePrivate::PushButtonTopOffset + QMacStylePrivate::PushButtonBottomOffset; break; case QStyle::CT_MenuItem: if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { @@ -5788,6 +5689,13 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz = sz.expandedTo(QSize(sz.width(), minimumSize)); } break; + case CT_ItemViewItem: + if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) { + sz = QCommonStyle::sizeFromContents(ct, vopt, csz, widget); + sz.setHeight(sz.height() + 2); + } + break; + default: sz = QWindowsStyle::sizeFromContents(ct, opt, csz, widget); } diff --git a/src/gui/styles/qmacstyle_mac_p.h b/src/gui/styles/qmacstyle_mac_p.h new file mode 100644 index 0000000..5a0ba4c --- /dev/null +++ b/src/gui/styles/qmacstyle_mac_p.h @@ -0,0 +1,239 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#ifndef QMACSTYLE_MAC_P_H +#define QMACSTYLE_MAC_P_H + +#include <qmacstyle_mac.h> +#include <private/qapplication_p.h> +#include <private/qcombobox_p.h> +#include <private/qmacstylepixmaps_mac_p.h> +#include <private/qpaintengine_mac_p.h> +#include <private/qpainter_p.h> +#include <private/qprintengine_mac_p.h> +#include <private/qstylehelper_p.h> +#include <qapplication.h> +#include <qbitmap.h> +#include <qcheckbox.h> +#include <qcombobox.h> +#include <qdialogbuttonbox.h> +#include <qdockwidget.h> +#include <qevent.h> +#include <qfocusframe.h> +#include <qformlayout.h> +#include <qgroupbox.h> +#include <qhash.h> +#include <qheaderview.h> +#include <qlayout.h> +#include <qlineedit.h> +#include <qlistview.h> +#include <qmainwindow.h> +#include <qmap.h> +#include <qmenubar.h> +#include <qpaintdevice.h> +#include <qpainter.h> +#include <qpixmapcache.h> +#include <qpointer.h> +#include <qprogressbar.h> +#include <qpushbutton.h> +#include <qradiobutton.h> +#include <qrubberband.h> +#include <qsizegrip.h> +#include <qspinbox.h> +#include <qsplitter.h> +#include <qstyleoption.h> +#include <qtextedit.h> +#include <qtextstream.h> +#include <qtoolbar.h> +#include <qtoolbutton.h> +#include <qtreeview.h> +#include <qtableview.h> +#include <qwizard.h> +#include <qdebug.h> +#include <qlibrary.h> +#include <qdatetimeedit.h> +#include <qmath.h> +#include <QtGui/qgraphicsproxywidget.h> +#include <QtGui/qgraphicsview.h> +#include <private/qt_cocoa_helpers_mac_p.h> + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5) +enum { + kThemePushButtonTextured = 31, + kThemePushButtonTexturedSmall = 32, + kThemePushButtonTexturedMini = 33 +}; + +/* Search fields */ +enum { + kHIThemeFrameTextFieldRound = 1000, + kHIThemeFrameTextFieldRoundSmall = 1001, + kHIThemeFrameTextFieldRoundMini = 1002 +}; +#endif + +/* + AHIG: + Apple Human Interface Guidelines + http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/ + + Builder: + Apple Interface Builder v. 3.1.1 +*/ + +// this works as long as we have at most 16 different control types +#define CT1(c) CT2(c, c) +#define CT2(c1, c2) ((uint(c1) << 16) | uint(c2)) + +enum QAquaWidgetSize { QAquaSizeLarge = 0, QAquaSizeSmall = 1, QAquaSizeMini = 2, + QAquaSizeUnknown = -1 }; + +#define SIZE(large, small, mini) \ + (controlSize == QAquaSizeLarge ? (large) : controlSize == QAquaSizeSmall ? (small) : (mini)) + +// same as return SIZE(...) but optimized +#define return_SIZE(large, small, mini) \ + do { \ + static const int sizes[] = { (large), (small), (mini) }; \ + return sizes[controlSize]; \ + } while (0) + +class QMacStylePrivate : public QObject +{ + Q_OBJECT + +public: + QMacStylePrivate(QMacStyle *style); + + // Ideally these wouldn't exist, but since they already exist we need some accessors. + static const int PushButtonLeftOffset; + static const int PushButtonTopOffset; + static const int PushButtonRightOffset; + static const int PushButtonBottomOffset; + static const int MiniButtonH; + static const int SmallButtonH; + static const int BevelButtonW; + static const int BevelButtonH; + static const int PushButtonContentPadding; + + + // Stuff from QAquaAnimate: + bool addWidget(QWidget *); + void removeWidget(QWidget *); + + enum Animates { AquaPushButton, AquaProgressBar, AquaListViewItemOpen }; + bool animatable(Animates, const QWidget *) const; + void stopAnimate(Animates, QWidget *); + void startAnimate(Animates, QWidget *); + static ThemeDrawState getDrawState(QStyle::State flags); + QAquaWidgetSize aquaSizeConstrain(const QStyleOption *option, const QWidget *widg, + QStyle::ContentsType ct = QStyle::CT_CustomBase, + QSize szHint=QSize(-1, -1), QSize *insz = 0) const; + void getSliderInfo(QStyle::ComplexControl cc, const QStyleOptionSlider *slider, + HIThemeTrackDrawInfo *tdi, const QWidget *needToRemoveMe); + bool doAnimate(Animates); + inline int animateSpeed(Animates) const { return 33; } + + // Utility functions + void drawColorlessButton(const HIRect &macRect, HIThemeButtonDrawInfo *bdi, + QPainter *p, const QStyleOption *opt) const; + + QSize pushButtonSizeFromContents(const QStyleOptionButton *btn) const; + + HIRect pushButtonContentBounds(const QStyleOptionButton *btn, + const HIThemeButtonDrawInfo *bdi) const; + + void initComboboxBdi(const QStyleOptionComboBox *combo, HIThemeButtonDrawInfo *bdi, + const QWidget *widget, const ThemeDrawState &tds); + + static HIRect comboboxInnerBounds(const HIRect &outerBounds, int buttonKind); + + static QRect comboboxEditBounds(const QRect &outerBounds, const HIThemeButtonDrawInfo &bdi); + + static void drawCombobox(const HIRect &outerBounds, const HIThemeButtonDrawInfo &bdi, QPainter *p); + static void drawTableHeader(const HIRect &outerBounds, bool drawTopBorder, bool drawLeftBorder, + const HIThemeButtonDrawInfo &bdi, QPainter *p); + bool contentFitsInPushButton(const QStyleOptionButton *btn, HIThemeButtonDrawInfo *bdi, + ThemeButtonKind buttonKindToCheck) const; + void initHIThemePushButton(const QStyleOptionButton *btn, const QWidget *widget, + const ThemeDrawState tds, + HIThemeButtonDrawInfo *bdi) const; + QPixmap generateBackgroundPattern() const; +protected: + bool eventFilter(QObject *, QEvent *); + void timerEvent(QTimerEvent *); + +private slots: + void startAnimationTimer(); + +public: + QPointer<QPushButton> defaultButton; //default push buttons + int timerID; + QList<QPointer<QWidget> > progressBars; //existing progress bars that need animation + + struct ButtonState { + int frame; + enum { ButtonDark, ButtonLight } dir; + } buttonState; + UInt8 progressFrame; + QPointer<QFocusFrame> focusWidget; + CFAbsoluteTime defaultButtonStart; + QMacStyle *q; + bool mouseDown; +}; + +QT_END_NAMESPACE + +#endif // QMACSTYLE_MAC_P_H diff --git a/src/gui/styles/qmacstylepixmaps_mac_p.h b/src/gui/styles/qmacstylepixmaps_mac_p.h index 6a5e0e6..58038c3 100644 --- a/src/gui/styles/qmacstylepixmaps_mac_p.h +++ b/src/gui/styles/qmacstylepixmaps_mac_p.h @@ -39,6 +39,9 @@ ** ****************************************************************************/ +#ifndef QMACSTYLEPIXMAPS_MAC_P_H +#define QMACSTYLEPIXMAPS_MAC_P_H + // // W A R N I N G // ------------- @@ -65,3 +68,5 @@ static const char * const qt_mac_toolbar_ext[]={ "aab###bb###baa", "ab###bb###baaa", ".###..###.aaaa"}; + +#endif // QMACSTYLEPIXMAPS_MAC_P_H diff --git a/src/gui/styles/qstyle.cpp b/src/gui/styles/qstyle.cpp index 429dafe..4cfa93f 100644 --- a/src/gui/styles/qstyle.cpp +++ b/src/gui/styles/qstyle.cpp @@ -325,7 +325,7 @@ static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::C control over size of header items and row and column sizes. \sa QStyleOption, QStylePainter, {Styles Example}, - {Implementing Styles and Style Aware Widgets}, QStyledItemDelegate + {Styles & Style Aware Widgets}, QStyledItemDelegate */ /*! diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri index f920032..0a96272 100644 --- a/src/gui/styles/styles.pri +++ b/src/gui/styles/styles.pri @@ -46,7 +46,8 @@ x11{ contains( styles, mac ) { HEADERS += \ styles/qmacstyle_mac.h \ - styles/qmacstylepixmaps_mac_p.h + styles/qmacstylepixmaps_mac_p.h \ + styles/qmacstyle_mac_p.h OBJECTIVE_SOURCES += styles/qmacstyle_mac.mm !contains( styles, windows ) { diff --git a/src/gui/widgets/qpushbutton.cpp b/src/gui/widgets/qpushbutton.cpp index 1a9adcc..8a18ed0 100644 --- a/src/gui/widgets/qpushbutton.cpp +++ b/src/gui/widgets/qpushbutton.cpp @@ -58,6 +58,10 @@ #include "qdebug.h" #include "qlayoutitem.h" #include "qdialogbuttonbox.h" +#ifdef Q_WS_MAC +#include "qmacstyle_mac.h" +#include "private/qmacstyle_mac_p.h" +#endif // Q_WS_MAC #ifndef QT_NO_ACCESSIBILITY #include "qaccessible.h" @@ -679,6 +683,37 @@ bool QPushButton::event(QEvent *e) return QAbstractButton::event(e); } +#ifdef Q_WS_MAC +/*! \reimp */ +bool QPushButton::hitButton(const QPoint &pos) const +{ + // This is only required if we are using the native style, so check that first. + QMacStyle *macStyle = qobject_cast<QMacStyle *>(style()); + // If this is a flat button we just bail out. + if(isFlat() || (0 == macStyle)) + return QAbstractButton::hitButton(pos); + // Now that we know we are using the native style, let's proceed. + Q_D(const QPushButton); + QPushButtonPrivate *nonConst = const_cast<QPushButtonPrivate *>(d); + // In OSX buttons are round, which causes the hit method to be special. + // We cannot simply relay on detecting if something is inside the rect or not, + // we need to check if it is inside the "rounded area" or not. A point might + // be inside the rect but not inside the rounded area. + // Notice this method is only reimplemented for OSX. + return nonConst->hitButton(pos); +} + +bool QPushButtonPrivate::hitButton(const QPoint &pos) +{ + Q_Q(QPushButton); + QRect roundedRect(q->rect().left() + QMacStylePrivate::PushButtonLeftOffset, + q->rect().top() + QMacStylePrivate::PushButtonContentPadding, + q->rect().width() - QMacStylePrivate::PushButtonRightOffset, + q->rect().height() - QMacStylePrivate::PushButtonBottomOffset); + return roundedRect.contains(pos); +} +#endif // Q_WS_MAC + #ifdef QT3_SUPPORT /*! Use one of the constructors that doesn't take the \a name diff --git a/src/gui/widgets/qpushbutton.h b/src/gui/widgets/qpushbutton.h index 2a4823d..cf28753 100644 --- a/src/gui/widgets/qpushbutton.h +++ b/src/gui/widgets/qpushbutton.h @@ -91,6 +91,9 @@ public Q_SLOTS: protected: bool event(QEvent *e); +#ifdef Q_WS_MAC + bool hitButton(const QPoint &pos) const; +#endif // Q_WS_MAC void paintEvent(QPaintEvent *); void keyPressEvent(QKeyEvent *); void focusInEvent(QFocusEvent *); diff --git a/src/gui/widgets/qpushbutton_p.h b/src/gui/widgets/qpushbutton_p.h index f2ee09d..6feb726 100644 --- a/src/gui/widgets/qpushbutton_p.h +++ b/src/gui/widgets/qpushbutton_p.h @@ -69,6 +69,9 @@ public: inline void init() { resetLayoutItemMargins(); } static QPushButtonPrivate* get(QPushButton *b) { return b->d_func(); } +#ifdef Q_WS_MAC + bool hitButton(const QPoint &pos); +#endif #ifndef QT_NO_MENU QPoint adjustedMenuPosition(); #endif |