46 #include <private/qdialog_p.h> 63 #include "private/qmacstyle_mac_p.h" 66 #ifndef QT_NO_ACCESSIBILITY 70 #include "private/qmenu_p.h" 71 #include "private/qpushbutton_p.h" 316 if (
const QDialog *dialog = qobject_cast<const QDialog *>(p))
317 return const_cast<QDialog *
>(dialog);
345 if (
d->defaultButton)
347 if (
d->down ||
d->menuOpen)
351 if (!
d->flat && !
d->down)
353 option->
text =
d->text;
354 option->
icon =
d->icon;
364 d->autoDefault = state;
374 return (
d->dialogParent() != 0 );
375 return d->autoDefault;
381 if (
d->defaultButton == enable)
383 d->defaultButton = enable;
384 if (
d->defaultButton) {
385 if (
QDialog *dlg =
d->dialogParent())
386 dlg->d_func()->setMainDefault(
this);
389 #ifndef QT_NO_ACCESSIBILITY 397 return d->defaultButton;
406 if (
d->sizeHint.isValid() &&
d->lastAutoDefault ==
autoDefault())
493 d->defaultButton =
true;
496 dlg->d_func()->setDefault(
this);
510 dlg->d_func()->setDefault(0);
512 d->defaultButton =
false;
517 if (
d->menu &&
d->menu->isVisible())
546 if (menu && !
d->menu) {
555 d->resetLayoutItemMargins();
584 d->_q_popupPressed();
595 QPoint menuPos = adjustedMenuPosition();
614 bool horizontal =
true;
615 #if !defined(QT_NO_TOOLBAR) 627 int x = globalPos.
x();
628 int y = globalPos.
y();
641 x -= menuSize.
width();
653 q->initStyleOption(&opt);
663 d->resetLayoutItemMargins();
680 if (
QDialog *dialog =
d->dialogParent()) {
681 if (
d->defaultButton)
682 dialog->d_func()->setMainDefault(
this);
689 d->resetLayoutItemMargins();
801 #include "moc_qpushbutton.cpp"
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object's accessibility information.
The QKeyEvent class describes a key event.
The QFontMetrics class provides font metrics information.
#define QT_END_NAMESPACE
This macro expands to.
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
void drawControl(QStyle::ControlElement ce, const QStyleOption &opt)
Use the widget's style to draw a control element ce specified by QStyleOption option.
QStyle::State state
the style flags that are used when drawing the control
The QDialog class is the base class of dialog windows.
static QSize globalStrut()
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
static const int PushButtonBottomOffset
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
int width() const
Returns the width of the rectangle.
int height() const
Returns the height of the rectangle.
The QString class provides a Unicode character string.
T * qobject_cast(QObject *object)
static const int PushButtonLeftOffset
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
void setObjectName(const QString &name)
int key() const
Returns the code of the key that was pressed or released.
int width() const
Returns the width.
#define QT_BEGIN_NAMESPACE
This macro expands to.
QSize size(int flags, const QString &str, int tabstops=0, int *tabarray=0) const
Returns the size in pixels of text.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
void initFrom(const QWidget *w)
void setSize(const QSize &s)
Sets the size of the rectangle to the given size.
bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option)
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=0) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
int y() const
Returns the y-coordinate of the rectangle's top edge.
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
int x() const
Returns the x-coordinate of the rectangle's left edge.
QObject * parent() const
Returns a pointer to the parent object.
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle's top-left corner to ({x}, {y}), and its size to the given widt...
The QPoint class defines a point in the plane using integer precision.
int height() const
Returns the height.
The QRect class defines a rectangle in the plane using integer precision.
static const int PushButtonContentPadding
int y() const
Returns the y coordinate of this point.
static const int PushButtonRightOffset
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget...
The QSize class defines the size of a two-dimensional object using integer point precision.
int x() const
Returns the x coordinate of this point.
The QPaintEvent class contains event parameters for paint events.
static void setLayoutItemMargins(int left, int top, int right, int bottom, QRect *rect, Qt::LayoutDirection dir)
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
QRect rect
the area that should be used for various calculations and painting
The QFocusEvent class contains event parameters for widget focus events.
static bool isNull(const QVariant::Private *d)
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.
The QIcon class provides scalable icons in different modes and states.