Qt 4.8
Classes | Public Types | Public Functions | Public Variables | List of all members
QGraphicsWidgetPrivate Class Reference

#include <qgraphicswidget_p.h>

Inheritance diagram for QGraphicsWidgetPrivate:
QGraphicsItemPrivate QGraphicsProxyWidgetPrivate

Classes

struct  WindowData
 

Public Types

enum  { Left, Top, Right, Bottom }
 
- Public Types inherited from QGraphicsItemPrivate
enum  AncestorFlag {
  NoFlag = 0, AncestorHandlesChildEvents = 0x1, AncestorClipsChildren = 0x2, AncestorIgnoresTransformations = 0x4,
  AncestorFiltersChildEvents = 0x8
}
 
enum  Extra {
  ExtraToolTip, ExtraCursor, ExtraCacheData, ExtraMaxDeviceCoordCacheSize,
  ExtraBoundingRegionGranularity
}
 
enum  InvalidateReason { OpacityChanged }
 

Public Functions

void _q_relayout ()
 
void adjustWindowFlags (Qt::WindowFlags *wFlags)
 
int attributeToBitIndex (Qt::WidgetAttribute att) const
 
void ensureMargins () const
 Ensures that margins is allocated. More...
 
void ensureWindowData ()
 Ensures that windowData is allocated. More...
 
void ensureWindowFrameMargins () const
 Ensures that windowFrameMargins is allocated. More...
 
void fixFocusChainBeforeReparenting (QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene=0)
 
bool hasDecoration () const
 
qreal height () const
 
void init (QGraphicsItem *parentItem, Qt::WindowFlags wFlags)
 
void initStyleOptionTitleBar (QStyleOptionTitleBar *option)
 
QFont naturalWidgetFont () const
 
QPalette naturalWidgetPalette () const
 
 QGraphicsWidgetPrivate ()
 
void resetHeight ()
 
void resetWidth ()
 
void resolveFont (uint inheritedMask)
 
void resolveLayoutDirection ()
 
void resolvePalette (uint inheritedMask)
 
void setAttribute (Qt::WidgetAttribute att, bool value)
 
void setFont_helper (const QFont &font)
 
void setGeometryFromSetPos ()
 
void setHeight (qreal)
 
void setLayout_helper (QGraphicsLayout *l)
 
void setLayoutDirection_helper (Qt::LayoutDirection direction)
 
void setPalette_helper (const QPalette &palette)
 
void setWidth (qreal)
 
bool testAttribute (Qt::WidgetAttribute att) const
 
qreal titleBarHeight (const QStyleOptionTitleBar &options) const
 
void updateFont (const QFont &font)
 
void updatePalette (const QPalette &palette)
 
qreal width () const
 
void windowFrameHoverLeaveEvent (QGraphicsSceneHoverEvent *event)
 
void windowFrameHoverMoveEvent (QGraphicsSceneHoverEvent *event)
 
void windowFrameMouseMoveEvent (QGraphicsSceneMouseEvent *event)
 
void windowFrameMousePressEvent (QGraphicsSceneMouseEvent *event)
 
void windowFrameMouseReleaseEvent (QGraphicsSceneMouseEvent *event)
 
virtual ~QGraphicsWidgetPrivate ()
 
- Public Functions inherited from QGraphicsItemPrivate
void addChild (QGraphicsItem *child)
 QGraphicsScenePrivate::registerTopLevelItem(). More...
 
void appendGraphicsTransform (QGraphicsTransform *t)
 
qreal calcEffectiveOpacity () const
 
void childrenBoundingRectHelper (QTransform *x, QRectF *rect, QGraphicsItem *topMostEffectItem)
 Returns the bounding rect of this item's children (excluding itself). More...
 
bool childrenClippedToShape () const
 
bool childrenCombineOpacity () const
 
QDeclarativeListProperty< QGraphicsObjectchildrenList ()
 Returns a list of this item's children. More...
 
void clearFocusHelper (bool giveFocusToParent)
 
void clearSubFocus (QGraphicsItem *rootItem=0, QGraphicsItem *stopItem=0)
 
qreal combineOpacityFromParent (qreal parentOpacity) const
 
void combineTransformFromParent (QTransform *x, const QTransform *viewTransform=0) const
 Combines this item's position and transform onto transform. More...
 
void combineTransformToParent (QTransform *x, const QTransform *viewTransform=0) const
 Combines this item's position and transform onto transform. More...
 
int depth () const
 
bool discardUpdateRequest (bool ignoreVisibleBit=false, bool ignoreDirtyBit=false, bool ignoreOpacity=false) const
 Returns true if we can discard an update request; otherwise false. More...
 
QRectF effectiveBoundingRect (QGraphicsItem *topMostEffectItem=0) const
 Returns the effective bounding rect of the item. More...
 
QRectF effectiveBoundingRect (const QRectF &rect) const
 Returns the effective bounding rect of the given item space rect. More...
 
qreal effectiveOpacity () const
 
void ensureSceneTransform ()
 
void ensureSceneTransformRecursive (QGraphicsItem **topMostDirtyItem)
 
void ensureSequentialSiblingIndex ()
 Ensures that the list of children is sorted by insertion order, and that the siblingIndexes are packed (no gaps), and start at 0. More...
 
void ensureSortedChildren ()
 
QVariant extra (Extra type) const
 
QGraphicsItemCacheextraItemCache () const
 
virtual void focusScopeItemChange (bool isSubFocusItem)
 Subclasses can reimplement this function to be notified when an item becomes a focusScopeItem (or is no longer a focusScopeItem). More...
 
QPointF genericMapFromScene (const QPointF &pos, const QWidget *viewport) const
 Maps the point pos from scene to item coordinates. More...
 
bool hasTranslateOnlySceneTransform ()
 
void initStyleOption (QStyleOptionGraphicsItem *option, const QTransform &worldTransform, const QRegion &exposedRegion, bool allItems=false) const
 
virtual QVariant inputMethodQueryHelper (Qt::InputMethodQuery query) const
 This helper function helped us add input method query support in Qt 4. More...
 
void invalidateChildGraphicsEffectsRecursively (InvalidateReason reason)
 
void invalidateChildrenSceneTransform ()
 
void invalidateDepthRecursively ()
 
void invalidateParentGraphicsEffectsRecursively ()
 
bool isFullyTransparent () const
 
bool isInvisible () const
 
bool isOpacityNull () const
 
virtual bool isProxyWidget () const
 
bool itemIsUntransformable () const
 
void markParentDirty (bool updateBoundingRect=false)
 
QGraphicsItemCachemaybeExtraItemCache () const
 
void prependGraphicsTransform (QGraphicsTransform *t)
 
 QGraphicsItemPrivate ()
 
void remapItemPos (QEvent *event, QGraphicsItem *item)
 Maps any item pos properties of event to item's coordinate system. More...
 
void removeChild (QGraphicsItem *child)
 QGraphicsScenePrivate::unregisterTopLevelItem(). More...
 
void removeExtraItemCache ()
 
void resetFocusProxy ()
 Sets the focusProxy pointer to 0 for all items that have this item as their focusProxy. More...
 
void resolveDepth ()
 Resolves the stacking depth of this object and all its ancestors. More...
 
QRectF sceneEffectiveBoundingRect () const
 Returns the effective bounding rect of this item in scene coordinates, by combining sceneTransform() with boundingRect(), taking into account the effect that the item might have. More...
 
void sendScenePosChange ()
 
void setEnabledHelper (bool newEnabled, bool explicitly, bool update=true)
 Sets this item's visibility to newEnabled. More...
 
void setExtra (Extra type, const QVariant &value)
 
void setFocusHelper (Qt::FocusReason focusReason, bool climb, bool focusFromHide)
 
void setIsMemberOfGroup (bool enabled)
 Propagates item group membership. More...
 
void setParentItemHelper (QGraphicsItem *parent, const QVariant *newParentVariant, const QVariant *thisPointerVariant)
 Make sure not to trigger any pure virtual function calls (e. More...
 
virtual void setPosHelper (const QPointF &pos)
 Sets the position pos. More...
 
void setSubFocus (QGraphicsItem *rootItem=0, QGraphicsItem *stopItem=0)
 
void setTransformHelper (const QTransform &transform)
 Sets the transform transform. More...
 
void setVisibleHelper (bool newVisible, bool explicitly, bool update=true)
 Sets this item's visibility to newVisible. More...
 
virtual void siblingOrderChange ()
 Subclasses can reimplement this function to be notified when its siblingIndex order is changed. More...
 
virtual void subFocusItemChange ()
 Subclasses can reimplement this function to be notified when subFocusItem changes. More...
 
virtual void transformChanged ()
 
QTransform transformToParent () const
 
void unsetExtra (Extra type)
 
void updateAncestorFlag (QGraphicsItem::GraphicsItemFlag childFlag, AncestorFlag flag=NoFlag, bool enabled=false, bool root=true)
 Propagates the ancestor flag flag with value enabled to all this item's children. More...
 
void updateAncestorFlags ()
 
void updateChildWithGraphicsEffectFlagRecursively ()
 
void updatePaintedViewBoundingRects (bool updateChildren)
 
virtual void updateSceneTransformFromParent ()
 
virtual ~QGraphicsItemPrivate ()
 

Public Variables

QList< QAction * > actions
 
quint32 attributes: 10
 
quint32 autoFillBackground: 1
 
QGraphicsWidgetfocusNext
 
Qt::FocusPolicy focusPolicy
 
QGraphicsWidgetfocusPrev
 
QFont font
 
uint inheritedFontResolveMask
 
uint inheritedPaletteResolveMask
 
quint32 inSetGeometry: 1
 
quint32 inSetPos: 1
 
QGraphicsLayoutlayout
 
qrealmargins
 
quint32 padding: 2
 
QPalette palette
 
quint32 polished: 1
 
quint32 refCountInvokeRelayout: 16
 
bool setWindowFrameMargins
 
struct QGraphicsWidgetPrivate::WindowDatawindowData
 
Qt::WindowFlags windowFlags
 
qrealwindowFrameMargins
 
- Public Variables inherited from QGraphicsItemPrivate
quint32 acceptDrops: 1
 
quint32 acceptedMouseButtons: 5
 
quint32 acceptedTouchBeginEvent: 1
 
quint32 acceptsHover: 1
 
quint32 acceptTouchEvents: 1
 
quint32 allChildrenDirty: 1
 
quint32 ancestorFlags: 4
 
quint32 cacheMode: 2
 
QList< QGraphicsItem * > children
 
QRectF childrenBoundingRect
 
quint32 dirty: 1
 
quint32 dirtyChildren: 1
 
quint32 dirtyChildrenBoundingRect: 1
 
quint32 dirtySceneTransform: 1
 
quint32 enabled: 1
 
quint32 explicitActivate: 1
 
quint32 explicitlyDisabled: 1
 
quint32 explicitlyHidden: 1
 
QList< ExtraStructextras
 
quint32 filtersDescendantEvents: 1
 
quint32 flags: 19
 
QGraphicsItemfocusProxy
 
QList< QGraphicsItem ** > focusProxyRefs
 
QGraphicsItemfocusScopeItem
 
quint32 fullUpdatePending: 1
 
quint32 geometryChanged: 1
 
QMap< Qt::GestureType, Qt::GestureFlags > gestureContext
 
int globalStackingOrder
 
QGraphicsEffectgraphicsEffect
 
quint32 handlesChildEvents: 1
 
quint32 hasBoundingRegionGranularity: 1
 
quint32 hasCursor: 1
 
quint32 holesInSiblingIndex: 1
 
quint32 ignoreOpacity: 1
 
quint32 ignoreVisible: 1
 
Qt::InputMethodHints imHints
 
quint32 inDestructor: 1
 
int index
 
quint32 inSetPosHelper: 1
 
quint32 isDeclarativeItem: 1
 
quint32 isMemberOfGroup: 1
 
quint32 isObject: 1
 
quint32 isWidget: 1
 
int itemDepth
 
quint32 itemDiscovered: 1
 
quint32 localCollisionHack: 1
 
quint32 mayHaveChildWithGraphicsEffect: 1
 
quint32 mouseSetsFocus: 1
 
quint32 needSortChildren: 1
 
QRectF needsRepaint
 
quint32 notifyBoundingRectChanged: 1
 
quint32 notifyInvalidated: 1
 
qreal opacity
 
quint32 padding: 21
 
QMap< QWidget *, QRectpaintedViewBoundingRects
 
quint32 paintedViewBoundingRectsNeedRepaint: 1
 
QGraphicsItem::PanelModality panelModality
 
QGraphicsItemparent
 
quint32 pendingPolish: 1
 
QPointF pos
 
QGraphicsItemq_ptr
 
QGraphicsScenescene
 
quint32 scenePosDescendants: 1
 
QTransform sceneTransform
 
quint32 sceneTransformTranslateOnly: 1
 
quint32 selected: 1
 
quint32 sendParentChangeNotification: 1
 
quint32 sequentialOrdering: 1
 
int siblingIndex
 
QGraphicsItemsubFocusItem
 
TransformDatatransformData
 
quint32 updateDueToGraphicsEffect: 1
 
quint32 visible: 1
 
quint32 wantsActive: 1
 
qreal z
 

Additional Inherited Members

- Static Public Functions inherited from QGraphicsItemPrivate
static void children_append (QDeclarativeListProperty< QGraphicsObject > *list, QGraphicsObject *item)
 
static QGraphicsObjectchildren_at (QDeclarativeListProperty< QGraphicsObject > *list, int)
 
static void children_clear (QDeclarativeListProperty< QGraphicsObject > *list)
 
static int children_count (QDeclarativeListProperty< QGraphicsObject > *list)
 
static const QGraphicsItemPrivateget (const QGraphicsItem *item)
 
static QGraphicsItemPrivateget (QGraphicsItem *item)
 
static bool insertionOrder (QGraphicsItem *a, QGraphicsItem *b)
 
static bool isOpacityNull (qreal opacity)
 
static bool movableAncestorIsSelected (const QGraphicsItem *item)
 

Detailed Description

Definition at line 71 of file qgraphicswidget_p.h.

Enumerations

◆ anonymous enum

anonymous enum

Constructors and Destructors

◆ QGraphicsWidgetPrivate()

QGraphicsWidgetPrivate::QGraphicsWidgetPrivate ( )
inline

Definition at line 75 of file qgraphicswidget_p.h.

76  : margins(0),
77  layout(0),
80  inSetGeometry(0),
81  polished(0),
82  inSetPos(0),
86  focusNext(0),
87  focusPrev(0),
88  windowFlags(0),
89  windowData(0),
90  setWindowFrameMargins(false),
92  { }
QGraphicsWidget * focusPrev
Qt::WindowFlags windowFlags
struct QGraphicsWidgetPrivate::WindowData * windowData
Qt::FocusPolicy focusPolicy
QGraphicsWidget * focusNext
QGraphicsLayout * layout

◆ ~QGraphicsWidgetPrivate()

QGraphicsWidgetPrivate::~QGraphicsWidgetPrivate ( )
virtual
Warning
This function is not part of the public interface.

Definition at line 104 of file qgraphicswidget_p.cpp.

Referenced by QGraphicsWidgetPrivate().

105 {
106  // Remove any lazily allocated data
107  delete[] margins;
108  delete[] windowFrameMargins;
109  delete windowData;
110 }
struct QGraphicsWidgetPrivate::WindowData * windowData

Functions

◆ _q_relayout()

void QGraphicsWidgetPrivate::_q_relayout ( )

Definition at line 246 of file qgraphicswidget_p.cpp.

247 {
249  if (refCountInvokeRelayout == 0) {
251  bool wasResized = q->testAttribute(Qt::WA_Resized);
252  q->resize(q->size()); // this will restrict the size
253  q->setAttribute(Qt::WA_Resized, wasResized);
254  }
255 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ adjustWindowFlags()

void QGraphicsWidgetPrivate::adjustWindowFlags ( Qt::WindowFlags *  wFlags)

Definition at line 355 of file qgraphicswidget_p.cpp.

Referenced by init().

356 {
357  bool customize = (*flags & (Qt::CustomizeWindowHint
364 
366  if (customize)
367  ;
368  else if (type == Qt::Dialog || type == Qt::Sheet)
370  else if (type == Qt::Tool)
372  else if (type == Qt::Window || type == Qt::SubWindow)
375 }
int type
Definition: qmetatype.cpp:239
unsigned int uint
Definition: qglobal.h:996

◆ attributeToBitIndex()

int QGraphicsWidgetPrivate::attributeToBitIndex ( Qt::WidgetAttribute  att) const
inline

Definition at line 147 of file qgraphicswidget_p.h.

Referenced by setAttribute(), and testAttribute().

148  {
149  int bit = -1;
150  switch (att) {
151  case Qt::WA_SetLayoutDirection: bit = 0; break;
152  case Qt::WA_RightToLeft: bit = 1; break;
153  case Qt::WA_SetStyle: bit = 2; break;
154  case Qt::WA_Resized: bit = 3; break;
155  case Qt::WA_DeleteOnClose: bit = 4; break;
156  case Qt::WA_NoSystemBackground: bit = 5; break;
157  case Qt::WA_OpaquePaintEvent: bit = 6; break;
158  case Qt::WA_SetPalette: bit = 7; break;
159  case Qt::WA_SetFont: bit = 8; break;
160  case Qt::WA_WindowPropagation: bit = 9; break;
161  default: break;
162  }
163  return bit;
164  }

◆ ensureMargins()

void QGraphicsWidgetPrivate::ensureMargins ( ) const

Ensures that margins is allocated.

Warning
This function is not part of the public interface.

This function must be called before any dereferencing.

Definition at line 121 of file qgraphicswidget_p.cpp.

122 {
123  if (!margins) {
124  margins = new qreal[4];
125  for (int i = 0; i < 4; ++i)
126  margins[i] = 0;
127  }
128 }
double qreal
Definition: qglobal.h:1193

◆ ensureWindowData()

void QGraphicsWidgetPrivate::ensureWindowData ( )

Ensures that windowData is allocated.

Warning
This function is not part of the public interface.

This function must be called before any dereferencing.

Definition at line 157 of file qgraphicswidget_p.cpp.

Referenced by initStyleOptionTitleBar(), QGraphicsWidgetPrivate::WindowData::WindowData(), windowFrameHoverLeaveEvent(), windowFrameHoverMoveEvent(), windowFrameMouseMoveEvent(), windowFrameMousePressEvent(), and windowFrameMouseReleaseEvent().

158 {
159  if (!windowData)
160  windowData = new WindowData;
161 }
struct QGraphicsWidgetPrivate::WindowData * windowData

◆ ensureWindowFrameMargins()

void QGraphicsWidgetPrivate::ensureWindowFrameMargins ( ) const

Ensures that windowFrameMargins is allocated.

Warning
This function is not part of the public interface.

This function must be called before any dereferencing.

Definition at line 139 of file qgraphicswidget_p.cpp.

140 {
141  if (!windowFrameMargins) {
142  windowFrameMargins = new qreal[4];
143  for (int i = 0; i < 4; ++i)
144  windowFrameMargins[i] = 0;
145  }
146 }
double qreal
Definition: qglobal.h:1193

◆ fixFocusChainBeforeReparenting()

void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting ( QGraphicsWidget newParent,
QGraphicsScene oldScene,
QGraphicsScene newScene = 0 
)

is called after a reparent has taken place to fix up the focus chain(s)

Definition at line 785 of file qgraphicswidget_p.cpp.

786 {
788 
790 
791  QGraphicsWidget *n = q; //last one in 'new' list
792  QGraphicsWidget *o = 0; //last one in 'old' list
793 
795 
796  QGraphicsWidget *firstOld = 0;
797  bool wasPreviousNew = true;
798 
799  while (w != q) {
800  bool isCurrentNew = q->isAncestorOf(w);
801  if (isCurrentNew) {
802  if (!wasPreviousNew) {
803  n->d_func()->focusNext = w;
804  w->d_func()->focusPrev = n;
805  }
806  n = w;
807  } else /*if (!isCurrentNew)*/ {
808  if (wasPreviousNew) {
809  if (o) {
810  o->d_func()->focusNext = w;
811  w->d_func()->focusPrev = o;
812  } else {
813  firstOld = w;
814  }
815  }
816  o = w;
817  }
818  w = w->d_func()->focusNext;
819  wasPreviousNew = isCurrentNew;
820  }
821 
822  // repair the 'old' chain
823  if (firstOld) {
824  o->d_func()->focusNext = firstOld;
825  firstOld->d_func()->focusPrev = o;
826  }
827 
828  // update tabFocusFirst for oldScene if the item is going to be removed from oldScene
829  if (newParent)
830  newScene = newParent->scene();
831 
832  if (oldScene && newScene != oldScene)
833  oldScene->d_func()->tabFocusFirst = (firstOld && firstOld->scene() == oldScene) ? firstOld : 0;
834 
835  QGraphicsItem *topLevelItem = newParent ? newParent->topLevelItem() : 0;
836  QGraphicsWidget *topLevel = 0;
837  if (topLevelItem && topLevelItem->isWidget())
838  topLevel = static_cast<QGraphicsWidget *>(topLevelItem);
839 
840  if (topLevel && newParent) {
841  QGraphicsWidget *last = topLevel->d_func()->focusPrev;
842  // link last with new chain
843  last->d_func()->focusNext = q;
844  focusPrev = last;
845 
846  // link last in chain with
847  topLevel->d_func()->focusPrev = n;
848  n->d_func()->focusNext = topLevel;
849  } else {
850  // q is the start of the focus chain
851  n->d_func()->focusNext = q;
852  focusPrev = n;
853  }
854 
855 }
QGraphicsWidget * focusPrev
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
QGraphicsWidget * focusNext
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_Q(Class)
Definition: qglobal.h:2483
QGraphicsItem * topLevelItem() const
Returns this item&#39;s top-level item.
bool isAncestorOf(const QGraphicsItem *child) const
Returns true if this item is an ancestor of child (i.e., if this item is child&#39;s parent, or one of child&#39;s parent&#39;s ancestors).
bool isWidget() const
Returns true if this item is a widget (i.
QGraphicsScene * scene() const
Returns the current scene for the item, or 0 if the item is not stored in a scene.
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ hasDecoration()

bool QGraphicsWidgetPrivate::hasDecoration ( ) const

◆ height()

qreal QGraphicsWidgetPrivate::height ( ) const
virtual
Warning
This function is not part of the public interface. Returns the height of the item Reimplemented by QGraphicsWidget

Reimplemented from QGraphicsItemPrivate.

Definition at line 890 of file qgraphicswidget_p.cpp.

Referenced by _q_boundGeometryToSizeConstraints(), resetWidth(), setWidth(), and titleBarHeight().

891 {
892  Q_Q(const QGraphicsWidget);
893  return q->geometry().height();
894 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ init()

void QGraphicsWidgetPrivate::init ( QGraphicsItem parentItem,
Qt::WindowFlags  wFlags 
)

Definition at line 63 of file qgraphicswidget_p.cpp.

Referenced by QGraphicsWidgetPrivate().

64 {
66 
67  attributes = 0;
68  isWidget = 1; // QGraphicsItem::isWidget() returns true.
69  focusNext = focusPrev = q;
71 
72  adjustWindowFlags(&wFlags);
73  windowFlags = wFlags;
74 
75  if (parentItem)
76  setParentItemHelper(parentItem, 0, 0);
77 
79  q->setGraphicsItem(q);
80 
82  q->unsetWindowFrameMargins();
85  if (windowFlags & Qt::Window)
87 }
void setParentItemHelper(QGraphicsItem *parent, const QVariant *newParentVariant, const QVariant *thisPointerVariant)
Make sure not to trigger any pure virtual function calls (e.
QGraphicsWidget * focusPrev
Qt::WindowFlags windowFlags
Qt::FocusPolicy focusPolicy
void adjustWindowFlags(Qt::WindowFlags *wFlags)
QGraphicsWidget * focusNext
#define Q_Q(Class)
Definition: qglobal.h:2483
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ initStyleOptionTitleBar()

void QGraphicsWidgetPrivate::initStyleOptionTitleBar ( QStyleOptionTitleBar option)

Definition at line 331 of file qgraphicswidget_p.cpp.

Referenced by windowFrameHoverMoveEvent(), and windowFrameMouseReleaseEvent().

332 {
335  q->initStyleOption(option);
336  option->rect.setHeight(titleBarHeight(*option));
337  option->titleBarFlags = windowFlags;
340  bool isActive = q->isActiveWindow();
341  if (isActive) {
342  option->state |= QStyle::State_Active;
345  } else {
346  option->state &= ~QStyle::State_Active;
348  }
349  QFont windowTitleFont = QApplication::font("QWorkspaceTitleBar");
350  QRect textRect = q->style()->subControlRect(QStyle::CC_TitleBar, option, QStyle::SC_TitleBarLabel, 0);
351  option->text = QFontMetrics(windowTitleFont).elidedText(
353 }
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
Qt::WindowFlags windowFlags
struct QGraphicsWidgetPrivate::WindowData * windowData
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
qreal titleBarHeight(const QStyleOptionTitleBar &options) const
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
QString text
the text of the title bar
Definition: qstyleoption.h:822
QStyle::SubControls activeSubControls
This variable holds a bitwise OR of the sub-controls that are active for the complex control...
Definition: qstyleoption.h:694
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.
#define Q_Q(Class)
Definition: qglobal.h:2483
static QFont font()
Returns the default application font.
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void ensureWindowData()
Ensures that windowData is allocated.
Qt::WindowFlags titleBarFlags
the widget flags for the title bar
Definition: qstyleoption.h:825
int titleBarState
the state of the title bar
Definition: qstyleoption.h:824
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ naturalWidgetFont()

QFont QGraphicsWidgetPrivate::naturalWidgetFont ( ) const

Definition at line 318 of file qgraphicswidget_p.cpp.

Referenced by resolveFont().

319 {
320  Q_Q(const QGraphicsWidget);
321  QFont naturalFont; // ### no application font support
322  if (QGraphicsWidget *parent = q->parentWidget()) {
323  naturalFont = parent->font();
324  } else if (scene) {
325  naturalFont = scene->font();
326  }
327  naturalFont.resolve(0);
328  return naturalFont;
329 }
QGraphicsItem * parent
QGraphicsWidget * parentWidget() const
Returns a pointer to the item&#39;s parent widget.
QGraphicsScene * scene
#define Q_Q(Class)
Definition: qglobal.h:2483
QFont resolve(const QFont &) const
Returns a new QFont that has attributes copied from other that have not been previously set on this f...
Definition: qfont.cpp:1983
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
QFont font
the scene&#39;s default font
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ naturalWidgetPalette()

QPalette QGraphicsWidgetPrivate::naturalWidgetPalette ( ) const

Definition at line 257 of file qgraphicswidget_p.cpp.

Referenced by resolvePalette().

258 {
259  Q_Q(const QGraphicsWidget);
261  if (QGraphicsWidget *parent = q->parentWidget()) {
262  palette = parent->palette();
263  } else if (scene) {
264  palette = scene->palette();
265  }
266  palette.resolve(0);
267  return palette;
268 }
QGraphicsItem * parent
QGraphicsWidget * parentWidget() const
Returns a pointer to the item&#39;s parent widget.
QPalette palette
the scene&#39;s default palette
QGraphicsScene * scene
#define Q_Q(Class)
Definition: qglobal.h:2483
QPalette resolve(const QPalette &) const
Returns a new QPalette that has attributes copied from other.
Definition: qpalette.cpp:1101
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ resetHeight()

void QGraphicsWidgetPrivate::resetHeight ( )
virtual
Warning
This function is not part of the public interface. Reset the height of the item Reimplemented by QGraphicsWidget

Reimplemented from QGraphicsItemPrivate.

Definition at line 907 of file qgraphicswidget_p.cpp.

908 {
910  q->setGeometry(QRectF(q->x(), q->y(), width(), 0));
911 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ resetWidth()

void QGraphicsWidgetPrivate::resetWidth ( )
virtual
Warning
This function is not part of the public interface. Reset the width of the item Reimplemented by QGraphicsWidget

Reimplemented from QGraphicsItemPrivate.

Definition at line 884 of file qgraphicswidget_p.cpp.

885 {
887  q->setGeometry(QRectF(q->x(), q->y(), 0, height()));
888 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ resolveFont()

void QGraphicsWidgetPrivate::resolveFont ( uint  inheritedMask)
virtual

Reimplemented from QGraphicsItemPrivate.

Definition at line 277 of file qgraphicswidget_p.cpp.

278 {
280  inheritedFontResolveMask = inheritedMask;
281  if (QGraphicsWidget *p = q->parentWidget())
282  inheritedFontResolveMask |= p->d_func()->inheritedFontResolveMask;
283  QFont naturalFont = naturalWidgetFont();
284  QFont resolvedFont = font.resolve(naturalFont);
285  updateFont(resolvedFont);
286 }
QGraphicsWidget * parentWidget() const
Returns a pointer to the item&#39;s parent widget.
void updateFont(const QFont &font)
#define Q_Q(Class)
Definition: qglobal.h:2483
QFont resolve(const QFont &) const
Returns a new QFont that has attributes copied from other that have not been previously set on this f...
Definition: qfont.cpp:1983
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ resolveLayoutDirection()

void QGraphicsWidgetPrivate::resolveLayoutDirection ( )

Definition at line 228 of file qgraphicswidget_p.cpp.

Referenced by init().

229 {
231  if (q->testAttribute(Qt::WA_SetLayoutDirection)) {
232  return;
233  }
236  } else if (scene) {
237  // ### shouldn't the scene have a layoutdirection really? how does
238  // ### QGraphicsWidget get changes from QApplication::layoutDirection?
240  } else {
242  }
243 }
static Qt::LayoutDirection layoutDirection()
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QGraphicsScene * scene
#define Q_Q(Class)
Definition: qglobal.h:2483
void setLayoutDirection_helper(Qt::LayoutDirection direction)
static QWidget * parentWidget(const QWidget *w)
Qt::LayoutDirection layoutDirection
the layout direction for this widget
Definition: qwidget.h:216
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ resolvePalette()

void QGraphicsWidgetPrivate::resolvePalette ( uint  inheritedMask)
virtual

Reimplemented from QGraphicsItemPrivate.

Definition at line 170 of file qgraphicswidget_p.cpp.

171 {
172  inheritedPaletteResolveMask = inheritedMask;
173  QPalette naturalPalette = naturalWidgetPalette();
174  QPalette resolvedPalette = palette.resolve(naturalPalette);
175  updatePalette(resolvedPalette);
176 }
QPalette naturalWidgetPalette() const
void updatePalette(const QPalette &palette)
QPalette resolve(const QPalette &) const
Returns a new QPalette that has attributes copied from other.
Definition: qpalette.cpp:1101
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ setAttribute()

void QGraphicsWidgetPrivate::setAttribute ( Qt::WidgetAttribute  att,
bool  value 
)
inline

Definition at line 165 of file qgraphicswidget_p.h.

166  {
167  int bit = attributeToBitIndex(att);
168  if (bit == -1) {
169  qWarning("QGraphicsWidget::setAttribute: unsupported attribute %d", int(att));
170  return;
171  }
172  if (value)
173  attributes |= (1 << bit);
174  else
175  attributes &= ~(1 << bit);
176  }
Q_CORE_EXPORT void qWarning(const char *,...)
int attributeToBitIndex(Qt::WidgetAttribute att) const

◆ setFont_helper()

void QGraphicsWidgetPrivate::setFont_helper ( const QFont font)

Definition at line 270 of file qgraphicswidget_p.cpp.

271 {
272  if (this->font == font && this->font.resolve() == font.resolve())
273  return;
274  updateFont(font);
275 }
void updateFont(const QFont &font)
QFont resolve(const QFont &) const
Returns a new QFont that has attributes copied from other that have not been previously set on this f...
Definition: qfont.cpp:1983

◆ setGeometryFromSetPos()

void QGraphicsWidgetPrivate::setGeometryFromSetPos ( )

Definition at line 913 of file qgraphicswidget_p.cpp.

914 {
915  if (inSetGeometry)
916  return;
918  inSetPos = 1;
919  // Ensure setGeometry is called (avoid recursion when setPos is
920  // called from within setGeometry).
921  q->setGeometry(QRectF(pos, q->size()));
922  inSetPos = 0 ;
923 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ setHeight()

void QGraphicsWidgetPrivate::setHeight ( qreal  h)
virtual
Warning
This function is not part of the public interface. Set the height of the item Reimplemented by QGraphicsWidget

Reimplemented from QGraphicsItemPrivate.

Definition at line 896 of file qgraphicswidget_p.cpp.

897 {
898  if (qIsNaN(h))
899  return;
901  if (q->geometry().height() == h)
902  return;
903 
904  q->setGeometry(QRectF(q->x(), q->y(), width(), h));
905 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
Q_CORE_EXPORT bool qIsNaN(double d)
Returns true if the double {d} is not a number (NaN).
Definition: qnumeric.cpp:55
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ setLayout_helper()

void QGraphicsWidgetPrivate::setLayout_helper ( QGraphicsLayout l)

Definition at line 857 of file qgraphicswidget_p.cpp.

858 {
859  delete (this->layout);
860  layout = l;
861  if (!l) {
863  q->updateGeometry();
864  }
865 }
QGraphicsLayout * layout
#define Q_Q(Class)
Definition: qglobal.h:2483
QFactoryLoader * l
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ setLayoutDirection_helper()

void QGraphicsWidgetPrivate::setLayoutDirection_helper ( Qt::LayoutDirection  direction)

Definition at line 206 of file qgraphicswidget_p.cpp.

Referenced by resolveLayoutDirection().

207 {
210  return;
211  q->setAttribute(Qt::WA_RightToLeft, (direction == Qt::RightToLeft));
212 
213  // Propagate this change to all children.
214  for (int i = 0; i < children.size(); ++i) {
215  QGraphicsItem *item = children.at(i);
216  if (item->isWidget()) {
217  QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
218  if (widget->parentWidget() && !widget->testAttribute(Qt::WA_SetLayoutDirection))
219  widget->d_func()->setLayoutDirection_helper(direction);
220  }
221  }
222 
223  // Send the notification event to this widget item.
226 }
QGraphicsWidget * parentWidget() const
Returns a pointer to the item&#39;s parent widget.
QPointer< QWidget > widget
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
#define Q_Q(Class)
Definition: qglobal.h:2483
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
bool testAttribute(Qt::WidgetAttribute attribute) const
Returns true if attribute is enabled for this widget; otherwise, returns false.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
bool isWidget() const
Returns true if this item is a widget (i.
bool testAttribute(Qt::WidgetAttribute att) const
QList< QGraphicsItem * > children
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Qt::LayoutDirection direction
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ setPalette_helper()

void QGraphicsWidgetPrivate::setPalette_helper ( const QPalette palette)

Definition at line 163 of file qgraphicswidget_p.cpp.

164 {
165  if (this->palette == palette && this->palette.resolve() == palette.resolve())
166  return;
167  updatePalette(palette);
168 }
void updatePalette(const QPalette &palette)
QPalette resolve(const QPalette &) const
Returns a new QPalette that has attributes copied from other.
Definition: qpalette.cpp:1101

◆ setWidth()

void QGraphicsWidgetPrivate::setWidth ( qreal  w)
virtual
Warning
This function is not part of the public interface. Set the width of the item Reimplemented by QGraphicsWidget

Reimplemented from QGraphicsItemPrivate.

Definition at line 873 of file qgraphicswidget_p.cpp.

874 {
875  if (qIsNaN(w))
876  return;
878  if (q->geometry().width() == w)
879  return;
880 
881  q->setGeometry(QRectF(q->x(), q->y(), w, height()));
882 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
Q_CORE_EXPORT bool qIsNaN(double d)
Returns true if the double {d} is not a number (NaN).
Definition: qnumeric.cpp:55
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ testAttribute()

bool QGraphicsWidgetPrivate::testAttribute ( Qt::WidgetAttribute  att) const
inline

Definition at line 177 of file qgraphicswidget_p.h.

Referenced by setLayoutDirection_helper().

178  {
179  int bit = attributeToBitIndex(att);
180  if (bit == -1)
181  return false;
182  return (attributes & (1 << bit)) != 0;
183  }
int attributeToBitIndex(Qt::WidgetAttribute att) const

◆ titleBarHeight()

qreal QGraphicsWidgetPrivate::titleBarHeight ( const QStyleOptionTitleBar options) const

Definition at line 89 of file qgraphicswidget_p.cpp.

Referenced by initStyleOptionTitleBar(), QGraphicsWidgetPrivate(), and windowFrameHoverMoveEvent().

90 {
91  Q_Q(const QGraphicsWidget);
92  int height = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options);
93 #if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
94  if (qobject_cast<QMacStyle*>(q->style())) {
95  height -=4;
96  }
97 #endif
98  return (qreal)height;
99 }
double qreal
Definition: qglobal.h:1193
#define Q_Q(Class)
Definition: qglobal.h:2483
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ updateFont()

void QGraphicsWidgetPrivate::updateFont ( const QFont font)

Definition at line 288 of file qgraphicswidget_p.cpp.

Referenced by resolveFont(), and setFont_helper().

289 {
291  // Update the local font setting.
292  this->font = font;
293 
294  // Calculate new mask.
295  if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation))
297  int mask = font.resolve() | inheritedFontResolveMask;
298 
299  // Propagate to children.
300  for (int i = 0; i < children.size(); ++i) {
301  QGraphicsItem *item = children.at(i);
302  if (item->isWidget()) {
303  QGraphicsWidget *w = static_cast<QGraphicsWidget *>(item);
305  w->d_func()->resolveFont(mask);
306  } else {
307  item->d_ptr->resolveFont(mask);
308  }
309  }
310 
311  if (!polished)
312  return;
313  // Notify change.
316 }
EventRef event
bool isWindow() const
Returns true if the item is a QGraphicsWidget window, otherwise returns false.
QScopedPointer< QGraphicsItemPrivate > d_ptr
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
#define Q_Q(Class)
Definition: qglobal.h:2483
QFont resolve(const QFont &) const
Returns a new QFont that has attributes copied from other that have not been previously set on this f...
Definition: qfont.cpp:1983
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
bool testAttribute(Qt::WidgetAttribute attribute) const
Returns true if attribute is enabled for this widget; otherwise, returns false.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
bool isWidget() const
Returns true if this item is a widget (i.
virtual void resolveFont(uint inheritedMask)
QList< QGraphicsItem * > children
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ updatePalette()

void QGraphicsWidgetPrivate::updatePalette ( const QPalette palette)

Definition at line 178 of file qgraphicswidget_p.cpp.

Referenced by resolvePalette(), and setPalette_helper().

179 {
181  // Update local palette setting.
182  this->palette = palette;
183 
184  // Calculate new mask.
185  if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation))
187  int mask = palette.resolve() | inheritedPaletteResolveMask;
188 
189  // Propagate to children.
190  for (int i = 0; i < children.size(); ++i) {
191  QGraphicsItem *item = children.at(i);
192  if (item->isWidget()) {
193  QGraphicsWidget *w = static_cast<QGraphicsWidget *>(item);
195  w->d_func()->resolvePalette(mask);
196  } else {
197  item->d_ptr->resolvePalette(mask);
198  }
199  }
200 
201  // Notify change.
204 }
EventRef event
bool isWindow() const
Returns true if the item is a QGraphicsWidget window, otherwise returns false.
QScopedPointer< QGraphicsItemPrivate > d_ptr
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
#define Q_Q(Class)
Definition: qglobal.h:2483
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
virtual void resolvePalette(uint inheritedMask)
bool testAttribute(Qt::WidgetAttribute attribute) const
Returns true if attribute is enabled for this widget; otherwise, returns false.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
bool isWidget() const
Returns true if this item is a widget (i.
QList< QGraphicsItem * > children
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
QPalette resolve(const QPalette &) const
Returns a new QPalette that has attributes copied from other.
Definition: qpalette.cpp:1101
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ width()

qreal QGraphicsWidgetPrivate::width ( ) const
virtual
Warning
This function is not part of the public interface. Returns the width of the item Reimplemented by QGraphicsWidget

Reimplemented from QGraphicsItemPrivate.

Definition at line 867 of file qgraphicswidget_p.cpp.

Referenced by _q_boundGeometryToSizeConstraints(), minimumHeightForWidth(), resetHeight(), and setHeight().

868 {
869  Q_Q(const QGraphicsWidget);
870  return q->geometry().width();
871 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ windowFrameHoverLeaveEvent()

void QGraphicsWidgetPrivate::windowFrameHoverLeaveEvent ( QGraphicsSceneHoverEvent event)

Definition at line 751 of file qgraphicswidget_p.cpp.

Referenced by windowFrameHoverMoveEvent().

752 {
753  Q_UNUSED(event);
755  if (hasDecoration()) {
756  // ### restore the cursor, don't override it
757 #ifndef QT_NO_CURSOR
758  q->unsetCursor();
759 #endif
760 
762 
763  bool needsUpdate = false;
766  needsUpdate = true;
767 
768  // update the hover state (of buttons etc...)
770  windowData->buttonMouseOver = false;
772  if (needsUpdate)
773  q->update(windowData->buttonRect);
774  }
775 }
struct QGraphicsWidgetPrivate::WindowData * windowData
#define Q_Q(Class)
Definition: qglobal.h:2483
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void ensureWindowData()
Ensures that windowData is allocated.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ windowFrameHoverMoveEvent()

void QGraphicsWidgetPrivate::windowFrameHoverMoveEvent ( QGraphicsSceneHoverEvent event)

Definition at line 667 of file qgraphicswidget_p.cpp.

668 {
670  if (!hasDecoration())
671  return;
672 
674 
675  if (q->rect().contains(event->pos())) {
678  return;
679  }
680 
681  bool wasMouseOver = windowData->buttonMouseOver;
682  QRect oldButtonRect = windowData->buttonRect;
684  windowData->buttonMouseOver = false;
685  QPointF pos = event->pos();
687  // make sure that the coordinates (rect and pos) we send to the style are positive.
688  if (windowFrameMargins) {
689  pos.rx() += windowFrameMargins[Left];
690  pos.ry() += windowFrameMargins[Top];
691  }
693  bar.rect = q->windowFrameRect().toRect();
694  bar.rect.moveTo(0,0);
695  bar.rect.setHeight(int(titleBarHeight(bar)));
696 
697  Qt::CursorShape cursorShape = Qt::ArrowCursor;
698  bool needsSetCursorCall = true;
699  switch (q->windowFrameSectionAt(event->pos())) {
700  case Qt::TopLeftSection:
702  cursorShape = Qt::SizeFDiagCursor;
703  break;
704  case Qt::TopRightSection:
706  cursorShape = Qt::SizeBDiagCursor;
707  break;
708  case Qt::LeftSection:
709  case Qt::RightSection:
710  cursorShape = Qt::SizeHorCursor;
711  break;
712  case Qt::TopSection:
713  case Qt::BottomSection:
714  cursorShape = Qt::SizeVerCursor;
715  break;
716  case Qt::TitleBarArea:
717  windowData->buttonRect = q->style()->subControlRect(
719 #ifdef Q_WS_MAC
720  // On mac we should hover if we are in the 'area' of the buttons
721  windowData->buttonRect |= q->style()->subControlRect(
723  windowData->buttonRect |= q->style()->subControlRect(
725 #endif
727  windowData->buttonMouseOver = true;
728  event->ignore();
729  break;
730  default:
731  needsSetCursorCall = false;
732  event->ignore();
733  }
734 #ifndef QT_NO_CURSOR
735  if (needsSetCursorCall)
736  q->setCursor(cursorShape);
737 #endif
738  // update buttons if we hover over them
739  windowData->hoveredSubControl = q->style()->hitTestComplexControl(QStyle::CC_TitleBar, &bar, pos.toPoint(), 0);
742 
743  if (windowData->buttonMouseOver != wasMouseOver) {
744  if (!oldButtonRect.isNull())
745  q->update(QRectF(oldButtonRect).translated(q->windowFrameRect().topLeft()));
746  if (!windowData->buttonRect.isNull())
747  q->update(QRectF(windowData->buttonRect).translated(q->windowFrameRect().topLeft()));
748  }
749 }
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
struct QGraphicsWidgetPrivate::WindowData * windowData
qreal titleBarHeight(const QStyleOptionTitleBar &options) const
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
void moveTo(int x, int t)
Moves the rectangle, leaving the top-left corner at the given position (x, y).
Definition: qrect.h:334
#define Q_Q(Class)
Definition: qglobal.h:2483
void windowFrameHoverLeaveEvent(QGraphicsSceneHoverEvent *event)
qreal & rx()
Returns a reference to the x coordinate of this point.
Definition: qpoint.h:302
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
void initStyleOptionTitleBar(QStyleOptionTitleBar *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...
Definition: qrect.cpp:1101
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition: qpoint.h:376
CursorShape
Definition: qnamespace.h:1262
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.
Definition: qrect.h:58
qreal & ry()
Returns a reference to the y coordinate of this point.
Definition: qpoint.h:307
void ensureWindowData()
Ensures that windowData is allocated.
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...
Definition: qrect.h:740
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ windowFrameMouseMoveEvent()

void QGraphicsWidgetPrivate::windowFrameMouseMoveEvent ( QGraphicsSceneMouseEvent event)

Definition at line 597 of file qgraphicswidget_p.cpp.

598 {
602  return;
603 
604  QLineF delta(q->mapFromScene(event->buttonDownScenePos(Qt::LeftButton)), event->pos());
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())));
608 
609  QRectF newGeometry;
610  switch (windowData->grabbedSection) {
611  case Qt::LeftSection:
612  newGeometry = QRectF(windowData->startGeometry.topLeft()
613  + QPointF(parentXDelta.dx(), parentXDelta.dy()),
614  windowData->startGeometry.size() - QSizeF(delta.dx(), delta.dy()));
615  break;
616  case Qt::TopLeftSection:
617  newGeometry = QRectF(windowData->startGeometry.topLeft()
618  + QPointF(parentDelta.dx(), parentDelta.dy()),
619  windowData->startGeometry.size() - QSizeF(delta.dx(), delta.dy()));
620  break;
621  case Qt::TopSection:
622  newGeometry = QRectF(windowData->startGeometry.topLeft()
623  + QPointF(parentYDelta.dx(), parentYDelta.dy()),
624  windowData->startGeometry.size() - QSizeF(0, delta.dy()));
625  break;
626  case Qt::TopRightSection:
627  newGeometry = QRectF(windowData->startGeometry.topLeft()
628  + QPointF(parentYDelta.dx(), parentYDelta.dy()),
629  windowData->startGeometry.size() - QSizeF(-delta.dx(), delta.dy()));
630  break;
631  case Qt::RightSection:
632  newGeometry = QRectF(windowData->startGeometry.topLeft(),
633  windowData->startGeometry.size() + QSizeF(delta.dx(), 0));
634  break;
636  newGeometry = QRectF(windowData->startGeometry.topLeft(),
637  windowData->startGeometry.size() + QSizeF(delta.dx(), delta.dy()));
638  break;
639  case Qt::BottomSection:
640  newGeometry = QRectF(windowData->startGeometry.topLeft(),
641  windowData->startGeometry.size() + QSizeF(0, delta.dy()));
642  break;
644  newGeometry = QRectF(windowData->startGeometry.topLeft()
645  + QPointF(parentXDelta.dx(), parentXDelta.dy()),
646  windowData->startGeometry.size() - QSizeF(delta.dx(), -delta.dy()));
647  break;
648  case Qt::TitleBarArea:
649  newGeometry = QRectF(windowData->startGeometry.topLeft()
650  + QPointF(parentDelta.dx(), parentDelta.dy()),
652  break;
653  case Qt::NoSection:
654  break;
655  }
656 
660  q->effectiveSizeHint(Qt::MinimumSize),
661  q->effectiveSizeHint(Qt::MaximumSize),
662  q);
663  q->setGeometry(newGeometry);
664  }
665 }
static void _q_boundGeometryToSizeConstraints(const QRectF &startGeometry, QRectF *rect, Qt::WindowFrameSection section, const QSizeF &min, const QSizeF &max, const QGraphicsWidget *widget)
Qt::WindowFrameSection grabbedSection
struct QGraphicsWidgetPrivate::WindowData * windowData
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QPointF topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:539
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
#define Q_Q(Class)
Definition: qglobal.h:2483
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:212
QPointF buttonDownScenePos(Qt::MouseButton button) const
Returns the mouse cursor position in scene coordinates where the specified button was clicked...
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QSizeF size() const
Returns the size of the rectangle.
Definition: qrect.h:713
QPointF pos() const
Returns the mouse cursor position in item coordinates.
void ensureWindowData()
Ensures that windowData is allocated.
Qt::MouseButtons buttons() const
Returns the combination of mouse buttons that were pressed at the time the event was sent...
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ windowFrameMousePressEvent()

void QGraphicsWidgetPrivate::windowFrameMousePressEvent ( QGraphicsSceneMouseEvent event)

Definition at line 408 of file qgraphicswidget_p.cpp.

409 {
411  if (event->button() != Qt::LeftButton)
412  return;
413 
415  windowData->startGeometry = q->geometry();
416  windowData->grabbedSection = q->windowFrameSectionAt(event->pos());
420  windowData->buttonSunken = true;
421  q->update();
422  }
423  event->setAccepted(windowData->grabbedSection != Qt::NoSection);
424 }
Qt::WindowFrameSection grabbedSection
struct QGraphicsWidgetPrivate::WindowData * windowData
Qt::MouseButton button() const
Returns the mouse button (if any) that caused the event.
#define Q_Q(Class)
Definition: qglobal.h:2483
QPointF pos() const
Returns the mouse cursor position in item coordinates.
void ensureWindowData()
Ensures that windowData is allocated.
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ windowFrameMouseReleaseEvent()

void QGraphicsWidgetPrivate::windowFrameMouseReleaseEvent ( QGraphicsSceneMouseEvent event)

Definition at line 377 of file qgraphicswidget_p.cpp.

378 {
383  windowData->buttonSunken = false;
386  // make sure that the coordinates (rect and pos) we send to the style are positive.
387  bar.rect = q->windowFrameRect().toRect();
388  bar.rect.moveTo(0,0);
389  bar.rect.setHeight(q->style()->pixelMetric(QStyle::PM_TitleBarHeight, &bar));
390  QPointF pos = event->pos();
391  if (windowFrameMargins) {
392  pos.rx() += windowFrameMargins[Left];
393  pos.ry() += windowFrameMargins[Top];
394  }
396  if (q->style()->subControlRect(QStyle::CC_TitleBar, &bar,
398  event->widget()).contains(pos.toPoint())) {
399  q->close();
400  }
401  }
402  if (!(static_cast<QGraphicsSceneMouseEvent *>(event)->buttons()))
404  event->accept();
405  }
406 }
void setHeight(int h)
Sets the height of the rectangle to the given height.
Definition: qrect.h:445
Qt::WindowFrameSection grabbedSection
struct QGraphicsWidgetPrivate::WindowData * windowData
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QStyleOptionTitleBar class is used to describe the parameters for drawing a title bar...
Definition: qstyleoption.h:816
static Qt::MouseButtons buttons
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).
Definition: qrect.h:334
#define Q_Q(Class)
Definition: qglobal.h:2483
qreal & rx()
Returns a reference to the x coordinate of this point.
Definition: qpoint.h:302
void initStyleOptionTitleBar(QStyleOptionTitleBar *option)
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition: qpoint.h:376
qreal & ry()
Returns a reference to the y coordinate of this point.
Definition: qpoint.h:307
void ensureWindowData()
Ensures that windowData is allocated.
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
QStyle::SubControls subControls
This variable holds a bitwise OR of the sub-controls to be drawn for the complex control.
Definition: qstyleoption.h:693
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

Properties

◆ actions

QList<QAction *> QGraphicsWidgetPrivate::actions

Definition at line 222 of file qgraphicswidget_p.h.

◆ attributes

quint32 QGraphicsWidgetPrivate::attributes

Definition at line 185 of file qgraphicswidget_p.h.

Referenced by init(), setAttribute(), and testAttribute().

◆ autoFillBackground

quint32 QGraphicsWidgetPrivate::autoFillBackground

Definition at line 189 of file qgraphicswidget_p.h.

◆ focusNext

QGraphicsWidget* QGraphicsWidgetPrivate::focusNext

Definition at line 195 of file qgraphicswidget_p.h.

Referenced by fixFocusChainBeforeReparenting(), and init().

◆ focusPolicy

Qt::FocusPolicy QGraphicsWidgetPrivate::focusPolicy

Definition at line 194 of file qgraphicswidget_p.h.

Referenced by init().

◆ focusPrev

QGraphicsWidget* QGraphicsWidgetPrivate::focusPrev

Definition at line 196 of file qgraphicswidget_p.h.

Referenced by fixFocusChainBeforeReparenting(), and init().

◆ font

QFont QGraphicsWidgetPrivate::font

Definition at line 119 of file qgraphicswidget_p.h.

Referenced by resolveFont(), and updateFont().

◆ inheritedFontResolveMask

uint QGraphicsWidgetPrivate::inheritedFontResolveMask

Definition at line 120 of file qgraphicswidget_p.h.

Referenced by resolveFont(), and updateFont().

◆ inheritedPaletteResolveMask

uint QGraphicsWidgetPrivate::inheritedPaletteResolveMask

Definition at line 114 of file qgraphicswidget_p.h.

Referenced by resolvePalette(), and updatePalette().

◆ inSetGeometry

quint32 QGraphicsWidgetPrivate::inSetGeometry

Definition at line 186 of file qgraphicswidget_p.h.

Referenced by QGraphicsWidget::setGeometry(), and setGeometryFromSetPos().

◆ inSetPos

quint32 QGraphicsWidgetPrivate::inSetPos

Definition at line 188 of file qgraphicswidget_p.h.

Referenced by QGraphicsWidget::setGeometry(), and setGeometryFromSetPos().

◆ layout

QGraphicsLayout* QGraphicsWidgetPrivate::layout

Definition at line 107 of file qgraphicswidget_p.h.

Referenced by QGraphicsWidget::setGeometry(), and setLayout_helper().

◆ margins

qreal* QGraphicsWidgetPrivate::margins
mutable

Definition at line 100 of file qgraphicswidget_p.h.

Referenced by ensureMargins(), and ~QGraphicsWidgetPrivate().

◆ padding

quint32 QGraphicsWidgetPrivate::padding

Definition at line 191 of file qgraphicswidget_p.h.

◆ palette

QPalette QGraphicsWidgetPrivate::palette

Definition at line 113 of file qgraphicswidget_p.h.

Referenced by naturalWidgetPalette(), resolvePalette(), and updatePalette().

◆ polished

quint32 QGraphicsWidgetPrivate::polished

Definition at line 187 of file qgraphicswidget_p.h.

Referenced by updateFont().

◆ refCountInvokeRelayout

quint32 QGraphicsWidgetPrivate::refCountInvokeRelayout

Definition at line 190 of file qgraphicswidget_p.h.

Referenced by _q_relayout().

◆ setWindowFrameMargins

bool QGraphicsWidgetPrivate::setWindowFrameMargins

Definition at line 217 of file qgraphicswidget_p.h.

◆ windowData

struct QGraphicsWidgetPrivate::WindowData * QGraphicsWidgetPrivate::windowData

◆ windowFlags

Qt::WindowFlags QGraphicsWidgetPrivate::windowFlags

Definition at line 199 of file qgraphicswidget_p.h.

Referenced by hasDecoration(), init(), and initStyleOptionTitleBar().

◆ windowFrameMargins

qreal* QGraphicsWidgetPrivate::windowFrameMargins
mutable

The documentation for this class was generated from the following files: