44 #ifndef QT_NO_GRAPHICSVIEW 46 #include <QtCore/qdebug.h> 47 #include <QtCore/qnumeric.h> 52 #include <QtGui/qapplication.h> 53 #include <QtGui/qgraphicsscene.h> 54 #include <QtGui/qstyleoption.h> 55 #include <QtGui/QStyleOptionTitleBar> 56 #include <QtGui/QGraphicsSceneMouseEvent> 57 #if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC) 79 q->setGraphicsItem(q);
82 q->unsetWindowFrameMargins();
93 #if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC) 94 if (qobject_cast<QMacStyle*>(q->style())) {
125 for (
int i = 0; i < 4; ++i)
143 for (
int i = 0; i < 4; ++i)
165 if (this->palette == palette && this->palette.
resolve() == palette.
resolve())
195 w->d_func()->resolvePalette(mask);
219 widget->d_func()->setLayoutDirection_helper(direction);
252 q->resize(q->size());
262 palette =
parent->palette();
305 w->d_func()->resolveFont(mask);
323 naturalFont =
parent->font();
335 q->initStyleOption(option);
340 bool isActive = q->isActiveWindow();
387 bar.
rect = q->windowFrameRect().toRect();
402 if (!(static_cast<QGraphicsSceneMouseEvent *>(event)->
buttons()))
437 bool heightForWidth =
true)
441 if (hasHFW == heightForWidth) {
442 minimumHeightForWidth = hasHFW
448 while (maxh - minh > 0.1) {
449 qreal middle = minh + (maxh - minh)/2;
456 if (hfw > constraint) {
458 }
else if (hfw <= constraint) {
462 minimumHeightForWidth = maxh;
483 qreal middlew = maxw;
484 qreal middleh = maxh;
489 if (maxw - minw < 0.1) {
494 middlew = minw + (maxw - minw)/
qreal(2.0);
495 middleh = minh + (maxh - minh)/
qreal(2.0);
499 if (min_hfw > middleh) {
502 }
else if (min_hfw <= middleh) {
506 }
while (maxw != minw);
511 if (min_hfw < maxh) {
512 result =
QSizeF(middlew, min_hfw);
525 const QRectF proposedRect = *rect;
532 const bool widthChanged = proposedRect.
width() != widget->
size().
width();
533 const bool heightChanged = proposedRect.
height() != widget->
size().
height();
535 if (hasHFW || hasWFH) {
536 if (widthChanged || heightChanged) {
545 proposed = proposedRect.
height();
548 minExtent = min.
width();
549 maxExtent = max.
width();
551 proposed = proposedRect.
width();
555 width = effectiveSize.
width();
556 height = effectiveSize.
height();
605 QLineF parentDelta(q->mapToParent(delta.p1()), q->mapToParent(delta.p2()));
606 QLineF parentXDelta(q->mapToParent(
QPointF(delta.p1().x(), 0)), q->mapToParent(
QPointF(delta.p2().x(), 0)));
607 QLineF parentYDelta(q->mapToParent(
QPointF(0, delta.p1().y())), q->mapToParent(
QPointF(0, delta.p2().y())));
613 +
QPointF(parentXDelta.dx(), parentXDelta.dy()),
618 +
QPointF(parentDelta.dx(), parentDelta.dy()),
623 +
QPointF(parentYDelta.dx(), parentYDelta.dy()),
628 +
QPointF(parentYDelta.dx(), parentYDelta.dy()),
645 +
QPointF(parentXDelta.dx(), parentXDelta.dy()),
650 +
QPointF(parentDelta.dx(), parentDelta.dy()),
663 q->setGeometry(newGeometry);
675 if (q->rect().contains(event->
pos())) {
693 bar.
rect = q->windowFrameRect().toRect();
698 bool needsSetCursorCall =
true;
699 switch (q->windowFrameSectionAt(event->
pos())) {
731 needsSetCursorCall =
false;
735 if (needsSetCursorCall)
736 q->setCursor(cursorShape);
744 if (!oldButtonRect.
isNull())
745 q->update(
QRectF(oldButtonRect).translated(q->windowFrameRect().topLeft()));
763 bool needsUpdate =
false;
797 bool wasPreviousNew =
true;
802 if (!wasPreviousNew) {
803 n->d_func()->focusNext = w;
804 w->d_func()->focusPrev = n;
808 if (wasPreviousNew) {
810 o->d_func()->focusNext = w;
811 w->d_func()->focusPrev = o;
818 w = w->d_func()->focusNext;
819 wasPreviousNew = isCurrentNew;
824 o->d_func()->focusNext = firstOld;
825 firstOld->d_func()->focusPrev = o;
830 newScene = newParent->
scene();
832 if (oldScene && newScene != oldScene)
833 oldScene->d_func()->tabFocusFirst = (firstOld && firstOld->
scene() == oldScene) ? firstOld : 0;
837 if (topLevelItem && topLevelItem->
isWidget())
838 topLevel = static_cast<QGraphicsWidget *>(topLevelItem);
840 if (topLevel && newParent) {
843 last->d_func()->focusNext = q;
847 topLevel->d_func()->focusPrev = n;
848 n->d_func()->focusNext = topLevel;
851 n->d_func()->focusNext = q;
870 return q->geometry().width();
878 if (q->geometry().width() == w)
893 return q->geometry().height();
901 if (q->geometry().height() == h)
904 q->setGeometry(
QRectF(q->x(), q->y(),
width(), h));
910 q->setGeometry(
QRectF(q->x(), q->y(),
width(), 0));
927 #include "moc_qgraphicswidget.cpp" 929 #endif //QT_NO_GRAPHICSVIEW
QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const
Returns the effective size hint for this QGraphicsLayoutItem.
static Qt::LayoutDirection layoutDirection()
void setParentItemHelper(QGraphicsItem *parent, const QVariant *newParentVariant, const QVariant *thisPointerVariant)
Make sure not to trigger any pure virtual function calls (e.
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items...
qreal right() const
Returns the x-coordinate of the rectangle's right edge.
static QGraphicsLayoutItemPrivate * get(QGraphicsLayoutItem *q)
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
void setHeight(int h)
Sets the height of the rectangle to the given height.
void setHeight(qreal h)
Sets the height of the rectangle to the given height.
The QFontMetrics class provides font metrics information.
QGraphicsWidget * parentWidget() const
Returns a pointer to the item's parent widget.
#define QT_END_NAMESPACE
This macro expands to.
bool isWindow() const
Returns true if the item is a QGraphicsWidget window, otherwise returns false.
QPointer< QWidget > widget
QScopedPointer< QGraphicsItemPrivate > d_ptr
QStyle::State state
the style flags that are used when drawing the control
qreal width() const
Returns the width.
The QPointF class defines a point in the plane using floating point precision.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
qreal height() const
Returns the height.
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
qreal left() const
Returns the x-coordinate of the rectangle's left edge.
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
static Qt::MouseButtons buttons
bool hasHeightForWidth() const
QPalette palette
the scene's default palette
Qt::MouseButton button() const
Returns the mouse button (if any) that caused the event.
QPointF topLeft() const
Returns the position of the rectangle's top-left corner.
int width() const
Returns the width of the rectangle.
void setTop(qreal pos)
Sets the top edge of the rectangle to the given y coordinate.
QString text
the text of the title bar
QWidget * widget() const
Returns the widget where the event originated, or 0 if the event originates from another application...
void moveTo(int x, int t)
Moves the rectangle, leaving the top-left corner at the given position (x, y).
QStyle::SubControls activeSubControls
This variable holds a bitwise OR of the sub-controls that are active for the complex control...
The QSizeF class defines the size of a two-dimensional object using floating point precision...
QString elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags=0) const
If the string text is wider than width, returns an elided version of the string (i.
static QFont font()
Returns the default application font.
The QLineF class provides a two-dimensional vector using floating point precision.
QPointF buttonDownScenePos(Qt::MouseButton button) const
Returns the mouse cursor position in scene coordinates where the specified button was clicked...
QFont resolve(const QFont &) const
Returns a new QFont that has attributes copied from other that have not been previously set on this f...
#define QT_BEGIN_NAMESPACE
This macro expands to.
qreal & rx()
Returns a reference to the x coordinate of this point.
The QRectF class defines a rectangle in the plane using floating point precision. ...
qreal height() const
Returns the height of the rectangle.
const T & at(int i) const
Returns the item at index position i in the list.
qreal width() const
Returns the width of the rectangle.
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
void setRect(qreal x, qreal y, qreal w, qreal h)
Sets the coordinates of the rectangle's top-left corner to (x, y), and its size to the given width an...
QGraphicsItem * topLevelItem() const
Returns this item's top-level item.
virtual void resolvePalette(uint inheritedMask)
Q_CORE_EXPORT bool qIsNaN(double d)
Returns true if the double {d} is not a number (NaN).
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 QWidget * parentWidget(const QWidget *w)
bool isAncestorOf(const QGraphicsItem *child) const
Returns true if this item is an ancestor of child (i.e., if this item is child's parent, or one of child's parent's ancestors).
bool hasWidthForHeight() const
The QFont class specifies a font used for drawing text.
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
int size() const
Returns the number of items in the list.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
The QGraphicsLayout class provides the base class for all layouts in Graphics View.
QPointF pos() const
Returns the position of the mouse cursor in item coordinates at the moment the hover event was sent...
The QRect class defines a rectangle in the plane using integer precision.
bool isWidget() const
Returns true if this item is a widget (i.
virtual void resolveFont(uint inheritedMask)
QSizeF size() const
Returns the size of the rectangle.
qreal & ry()
Returns a reference to the y coordinate of this point.
QPointF pos() const
Returns the mouse cursor position in item coordinates.
qreal top() const
Returns the y-coordinate of the rectangle's top edge.
void setWidth(qreal w)
Sets the width of the rectangle to the given width.
QGraphicsScene * scene() const
Returns the current scene for the item, or 0 if the item is not stored in a scene.
Qt::WindowFlags titleBarFlags
the widget flags for the title bar
qreal bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
QFont font
the scene's default font
QList< QGraphicsItem * > children
QRectF translated(qreal dx, qreal dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
int titleBarState
the state of the title bar
The QEvent class is the base class of all event classes.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
QRect rect
the area that should be used for various calculations and painting
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Q_DECL_CONSTEXPR int qRound(qreal d)
Qt::MouseButtons buttons() const
Returns the combination of mouse buttons that were pressed at the time the event was sent...
The QGraphicsSceneHoverEvent class provides hover events in the graphics view framework.
QPalette resolve(const QPalette &) const
Returns a new QPalette that has attributes copied from other.
Qt::LayoutDirection direction
The QPalette class contains color groups for each widget state.