Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/widgets/qpushbutton.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5959#include "qlayoutitem.h"
    6060#include "qdialogbuttonbox.h"
     61#ifdef Q_WS_MAC
     62#include "qmacstyle_mac.h"
     63#include "private/qmacstyle_mac_p.h"
     64#endif // Q_WS_MAC
    6165
    6266#ifndef QT_NO_ACCESSIBILITY
     
    680684}
    681685
     686#ifdef Q_WS_MAC
     687/*! \reimp */
     688bool QPushButton::hitButton(const QPoint &pos) const
     689{
     690    QStyleOptionButton opt;
     691    initStyleOption(&opt);
     692    if (qt_mac_buttonIsRenderedFlat(this, &opt))
     693        return QAbstractButton::hitButton(pos);
     694
     695    // Now that we know we are using the native style, let's proceed.
     696    Q_D(const QPushButton);
     697    QPushButtonPrivate *nonConst = const_cast<QPushButtonPrivate *>(d);
     698    // In OSX buttons are round, which causes the hit method to be special.
     699    // We cannot simply relay on detecting if something is inside the rect or not,
     700    // we need to check if it is inside the "rounded area" or not. A point might
     701    // be inside the rect but not inside the rounded area.
     702    // Notice this method is only reimplemented for OSX.
     703    return nonConst->hitButton(pos);
     704}
     705
     706bool QPushButtonPrivate::hitButton(const QPoint &pos)
     707{
     708    Q_Q(QPushButton);
     709    QRect roundedRect(q->rect().left() + QMacStylePrivate::PushButtonLeftOffset,
     710                      q->rect().top() + QMacStylePrivate::PushButtonContentPadding,
     711                      q->rect().width() - QMacStylePrivate::PushButtonRightOffset,
     712                      q->rect().height() - QMacStylePrivate::PushButtonBottomOffset);
     713    return roundedRect.contains(pos);
     714}
     715#endif // Q_WS_MAC
     716
    682717#ifdef QT3_SUPPORT
    683718/*!
Note: See TracChangeset for help on using the changeset viewer.