44 #ifndef QT_NO_SCROLLAREA 59 #include <private/qapplication_p.h> 62 #include <private/qt_mac_p.h> 63 #include <private/qt_cocoa_helpers_mac_p.h> 163 viewport(0), cornerWidget(0),
left(0), top(0),
right(0), bottom(0),
164 xoffset(0), yoffset(0), viewportFilter(0)
166 , singleFingerPanEnabled(false)
174 orientation(orientation)
199 layout->insertWidget(insertIndex, widget);
214 for (
int i = 0; i < scrollBarIndex; ++i)
218 for (
int i = scrollBarIndex + 1; i < layoutItemCount; ++i)
236 for (
int i = 0; i < layoutItemCount; ++i) {
252 QScrollBar *oldBar = horizontal ? hbar : vbar;
275 q, horizontal ?
SLOT(_q_hslide(
int)) :
SLOT(_q_vslide(
int)));
284 viewport->setObjectName(
QLatin1String(
"qt_scrollarea_viewport"));
286 viewport->setAutoFillBackground(
true);
302 viewport->installEventFilter(viewportFilter.data());
303 viewport->setFocusProxy(q);
309 #ifndef QT_NO_GESTURES 318 singleFingerPanEnabled = on;
321 dd->winSetupGestures();
366 const int hsbExt = hbar->sizeHint().height();
367 const int vsbExt = vbar->sizeHint().width();
368 const QPoint extPoint(vsbExt, hsbExt);
369 const QSize extSize(vsbExt, hsbExt);
371 const QRect widgetRect = q->rect();
375 const bool hasCornerWidget = (cornerWidget != 0);
381 bool hasMacReverseSizeGrip =
false;
382 bool hasMacSizeGrip =
false;
383 bool nativeGripPresent =
false;
387 if (nativeGripPresent) {
391 const QPoint scrollAreaBottomRight = q->mapTo(window, widgetRect.
bottomRight() -
QPoint(frameWidth, frameWidth));
394 const QPoint offset = windowBottomRight - scrollAreaBottomRight;
395 const QPoint visualOffset = visualWindowBottomRight - scrollAreaBottomRight;
397 hasMacReverseSizeGrip = (hasMacSizeGrip ==
false && (offset.
manhattanLength() < hsbExt));
401 QPoint cornerOffset(needv ? vsbExt : 0, needh ? hsbExt : 0);
409 controlsRect = widgetRect;
411 const QPoint cornerExtra(needv ? extra : 0, needh ? extra : 0);
412 QRect frameRect = widgetRect;
413 frameRect.
adjust(0, 0, -cornerOffset.
x() - cornerExtra.
x(), -cornerOffset.
y() - cornerExtra.
y());
421 controlsRect = q->contentsRect();
427 if (hasCornerWidget && (needv || needh))
428 cornerOffset = extPoint;
433 cornerOffset = extPoint;
443 if ((needv && needh && hasCornerWidget ==
false)
452 cornerPaintingRect =
QRect();
456 if (hasMacReverseSizeGrip)
459 reverseCornerPaintingRect =
QRect();
465 if (hasMacReverseSizeGrip)
466 horizontalScrollBarRect.
adjust(vsbExt, 0, 0, 0);
473 const QRect verticalScrollBarRect (
QPoint(cornerPoint.x(), controlsRect.
top()),
QPoint(controlsRect.
right(), cornerPoint.y() - 1));
486 if (q->isRightToLeft())
509 d->viewportFilter.reset();
526 d->viewportFilter.reset();
539 d->viewportFilter.reset();
559 if (widget !=
d->viewport) {
564 d->viewport->setParent(
this);
565 d->viewport->setFocusProxy(
this);
566 d->viewport->installEventFilter(
d->viewportFilter.data());
568 #ifndef QT_NO_GESTURES 603 int hsbExt =
d->hbar->sizeHint().height();
604 int vsbExt =
d->vbar->sizeHint().width();
606 int f = 2 *
d->frameWidth;
630 return d->vbarpolicy;
637 d->vbarpolicy = policy;
640 if (oldPolicy !=
d->vbarpolicy)
675 qWarning(
"QAbstractScrollArea::setVerticalScrollBar: Cannot set a null scroll bar");
697 return d->hbarpolicy;
704 d->hbarpolicy = policy;
707 if (oldPolicy !=
d->hbarpolicy)
742 qWarning(
"QAbstractScrollArea::setHorizontalScrollBar: Cannot set a null scroll bar");
762 return d->cornerWidget;
797 QWidget* oldWidget =
d->cornerWidget;
798 if (oldWidget != widget) {
973 if (
d->cornerPaintingRect.isValid()) {
974 option.
rect =
d->cornerPaintingRect;
979 if (
d->reverseCornerPaintingRect.isValid()) {
980 option.
rect =
d->reverseCornerPaintingRect;
988 #ifndef QT_NO_CONTEXTMENU 994 #endif // QT_NO_CONTEXTMENU 1000 #ifndef QT_NO_DRAGANDDROP 1011 #ifndef QT_NO_GESTURES 1023 int newX = hBar->
value() - delta.
x();
1024 int newY = vBar->
value() - delta.
y();
1032 #endif // QT_NO_GESTURES 1037 d->layoutChildren();
1067 switch (e->
type()) {
1078 #ifndef QT_NO_WHEELEVENT 1081 #ifndef QT_NO_DRAGANDDROP 1089 #ifndef QT_NO_GESTURES 1186 #ifndef QT_NO_WHEELEVENT 1190 if (static_cast<QWheelEvent*>(e)->orientation() ==
Qt::Horizontal)
1197 #ifndef QT_NO_CONTEXTMENU 1209 #endif // QT_NO_CONTEXTMENU 1220 #ifndef QT_NO_SHORTCUT 1227 #ifdef QT_KEYPAD_NAVIGATION 1228 if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {
1241 #ifdef QT_KEYPAD_NAVIGATION 1242 if (QApplication::keypadNavigationEnabled() && hasEditFocus()
1243 && (!
d->hbar->isVisible() ||
d->hbar->value() ==
d->hbar->minimum())) {
1249 d->hbar->triggerAction(
1254 #ifdef QT_KEYPAD_NAVIGATION 1255 if (QApplication::keypadNavigationEnabled() && hasEditFocus()
1256 && (!
d->hbar->isVisible() ||
d->hbar->value() ==
d->hbar->maximum())) {
1262 d->hbar->triggerAction(
1275 #ifndef QT_NO_DRAGANDDROP 1353 int dx = xoffset -
x;
1355 q->scrollContentsBy(dx, 0);
1361 int dy = yoffset -
y;
1363 q->scrollContentsBy(0, dy);
1374 dd->winSetupGestures();
1382 if (vbar->isVisible())
1383 offset.
setY(vbar->value());
1384 if (hbar->isVisible()) {
1385 if (q->isRightToLeft())
1386 offset.
setX(hbar->maximum() - hbar->value());
1388 offset.
setX(hbar->value());
1400 int hsbExt =
d->hbar->sizeHint().height();
1401 int vsbExt =
d->vbar->sizeHint().width();
1402 int extra = 2 *
d->frameWidth;
1410 d->scrollBarContainers[
Qt::Vertical]->sizeHint().height() + hsbExt + extra);
1418 return QSize(256, 192);
1422 int f = 2 *
d->frameWidth;
1423 return QSize((6 * h) + f, (4 * h) + f);
1442 #include "moc_qabstractscrollarea.cpp" 1443 #include "moc_qabstractscrollarea_p.cpp" 1445 #endif // QT_NO_SCROLLAREA The QPainter class performs low-level painting on widgets and other paint devices.
void paintEvent(QPaintEvent *)
This event handler can be reimplemented in a subclass to receive paint events passed in event...
The QPanGesture class describes a panning gesture made by the user.
The QKeyEvent class describes a key event.
virtual QLayoutItem * itemAt(int index) const =0
Must be implemented in subclasses to return the layout item at index.
The QBoxLayout class lines up child widgets horizontally or vertically.
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
static QPoint visualPos(Qt::LayoutDirection direction, const QRect &boundingRect, const QPoint &logicalPos)
Returns the given logicalPosition converted to screen coordinates based on the specified direction...
int sliderPosition() const
The QWheelEvent class contains parameters that describe a wheel event.
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
#define Q_WS_WIN
Defined on Windows.
The QPointF class defines a point in the plane using floating point precision.
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
int left() const
Returns the x-coordinate of the rectangle's left edge.
void init(const QWidget *w)
Use initFrom(widget) instead.
#define Q_ARG(type, data)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
void setInvertedAppearance(bool)
The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress...
QPointF delta
the offset from the previous input position to the current input
static QObjectPrivate * get(QObject *o)
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
void setRange(int min, int max)
Sets the slider's minimum to min and its maximum to max.
qreal x() const
Returns the x-coordinate of this point.
int top() const
Returns the top margin.
int key() const
Returns the code of the key that was pressed or released.
bool isSliderDown() const
void setInvertedControls(bool)
void append(const T &t)
Inserts value at the end of the list.
QTextStream & right(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignRight) on stream and returns stream...
#define QT_BEGIN_NAMESPACE
This macro expands to.
qreal & rx()
Returns a reference to the x coordinate of this point.
The QGestureEvent class provides the description of triggered gestures.
QPoint bottomRight() const
Returns the position of the rectangle's bottom-right corner.
The QStyleOption class stores the parameters used by QStyle functions.
void insertWidget(int index, QWidget *widget, int stretch=0, Qt::Alignment alignment=0)
Inserts widget at position index, with stretch factor stretch and alignment alignment.
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...
void initFrom(const QWidget *w)
int manhattanLength() const
Returns the sum of the absolute values of x() and y(), traditionally known as the "Manhattan length" ...
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
The QResizeEvent class contains event parameters for resize events.
const char * styleHint(const QFontDef &request)
Q_CORE_EXPORT void qWarning(const char *,...)
Qt::Orientation orientation() const
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leav...
bool invertedControls() const
bool invertedAppearance() const
The QMouseEvent class contains parameters that describe a mouse event.
void setHorizontalPolicy(Policy d)
void setY(int y)
Sets the y coordinate of this point to the given y coordinate.
int top() const
Returns the y-coordinate of the rectangle's top edge.
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction...
The QDropEvent class provides an event which is sent when a drag and drop action is completed...
int right() const
Returns the x-coordinate of the rectangle's right edge.
virtual int count() const =0
Must be implemented in subclasses to return the number of items in the layout.
void addWidget(QWidget *w)
Adds widget w to this layout in a manner specific to the layout.
QObject * parent() const
Returns a pointer to the parent object.
The QDragEnterEvent class provides an event which is sent to a widget when a drag and drop action ent...
The QPoint class defines a point in the plane using integer precision.
bool event(QEvent *e)
Reimplemented Function
void setSliderPosition(int)
int & rheight()
Returns a reference to the height.
Qt::LayoutDirection direction
the text layout direction that should be used when drawing text in the control
The QRect class defines a rectangle in the plane using integer precision.
bool isNull() const
Returns true if both the x and y coordinates are set to +0.
static Qt::Orientation scrollBarOrientation(const QAInterface &scrollBar)
int y() const
Returns the y coordinate of this point.
qreal y() const
Returns the y-coordinate of this point.
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
int left() const
Returns the left margin.
void setVerticalPolicy(Policy d)
QGesture * gesture(Qt::GestureType type) const
Returns a gesture object by type.
void setOrientation(Qt::Orientation)
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
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.
void setTracking(bool enable)
The QMargins class defines the four margins of a rectangle.
The QPaintEvent class contains event parameters for paint events.
bool qt_mac_checkForNativeSizeGrip(const QWidget *widget)
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
The QFrame class is the base class of widgets that can have a frame.
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
void setX(int x)
Sets the x coordinate of this point to the given x coordinate.
static bool isRightToLeft()
Returns true if the application's layout direction is Qt::RightToLeft; otherwise returns false...
int bottom() const
Returns the bottom margin.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
int right() const
Returns the right margin.
QRect rect
the area that should be used for various calculations and painting
int & rwidth()
Returns a reference to the width.
void removeWidget(QWidget *w)
Removes the widget widget from the layout.
The QList class is a template class that provides lists.
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.
QTextStream & left(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignLeft) on stream and returns stream...