Plasma
scrollwidget.h
Go to the documentation of this file.
00001 /* 00002 * Copyright 2009 Marco Martin <notmart@gmail.com> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU Library General Public License as 00006 * published by the Free Software Foundation; either version 2, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details 00013 * 00014 * You should have received a copy of the GNU Library General Public 00015 * License along with this program; if not, write to the 00016 * Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef PLASMA_SCROLLWIDGET_H 00021 #define PLASMA_SCROLLWIDGET_H 00022 00023 #include <QtCore/QAbstractAnimation> 00024 #include <QtGui/QGraphicsWidget> 00025 00026 #include <plasma/plasma_export.h> 00027 00028 00029 namespace Plasma 00030 { 00031 00032 class ScrollWidgetPrivate; 00033 00043 class PLASMA_EXPORT ScrollWidget : public QGraphicsWidget 00044 { 00045 Q_OBJECT 00046 Q_PROPERTY(QGraphicsWidget *widget READ widget WRITE setWidget) 00047 Q_PROPERTY(Qt::ScrollBarPolicy horizontalScrollBarPolicy READ horizontalScrollBarPolicy WRITE setHorizontalScrollBarPolicy) 00048 Q_PROPERTY(Qt::ScrollBarPolicy verticalScrollBarPolicy READ verticalScrollBarPolicy WRITE setVerticalScrollBarPolicy) 00049 Q_PROPERTY(bool overflowBordersVisible READ overflowBordersVisible WRITE setOverflowBordersVisible) 00050 Q_PROPERTY(QPointF scrollPosition READ scrollPosition WRITE setScrollPosition) 00051 Q_PROPERTY(QSizeF contentsSize READ contentsSize) 00052 Q_PROPERTY(QRectF viewportGeometry READ viewportGeometry) 00053 Q_PROPERTY(QSizeF snapSize READ snapSize WRITE setSnapSize) 00054 Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet) 00055 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) 00056 Q_PROPERTY(bool overShoot READ hasOverShoot WRITE setOverShoot) 00057 00058 public: 00059 00065 explicit ScrollWidget(QGraphicsWidget *parent = 0); 00066 explicit ScrollWidget(QGraphicsItem *parent); 00067 ~ScrollWidget(); 00068 00079 void setWidget(QGraphicsWidget *widget); 00080 00084 QGraphicsWidget *widget() const; 00085 00092 void setAlignment(Qt::Alignment align); 00093 00098 Qt::Alignment alignment() const; 00099 00106 void setOverShoot(bool enable); 00107 00112 bool hasOverShoot() const; 00113 00119 void setHorizontalScrollBarPolicy(const Qt::ScrollBarPolicy policy); 00120 00124 Qt::ScrollBarPolicy horizontalScrollBarPolicy() const; 00125 00131 void setVerticalScrollBarPolicy(const Qt::ScrollBarPolicy policy); 00132 00136 Qt::ScrollBarPolicy verticalScrollBarPolicy() const; 00137 00143 bool overflowBordersVisible() const; 00144 00152 void setOverflowBordersVisible(const bool visible); 00153 00160 Q_INVOKABLE void ensureRectVisible(const QRectF &rect); 00161 00168 Q_INVOKABLE void ensureItemVisible(QGraphicsItem *item); 00169 00184 #ifndef KDE_NO_DEPRECATED 00185 KDE_DEPRECATED Q_INVOKABLE void registerAsDragHandle(QGraphicsWidget *item); 00186 #endif 00187 00196 #ifndef KDE_NO_DEPRECATED 00197 KDE_DEPRECATED Q_INVOKABLE void unregisterAsDragHandle(QGraphicsWidget *item); 00198 #endif 00199 00204 QRectF viewportGeometry() const; 00205 00206 00211 QSizeF contentsSize() const; 00212 00217 void setScrollPosition(const QPointF &position); 00218 00223 QPointF scrollPosition() const; 00224 00232 void setSnapSize(const QSizeF &size); 00233 00238 QSizeF snapSize() const; 00239 00245 void setStyleSheet(const QString &stylesheet); 00246 00250 QString styleSheet() const; 00251 00255 QWidget *nativeWidget() const; 00256 00257 Q_SIGNALS: 00262 void scrollStateChanged(QAbstractAnimation::State newState, 00263 QAbstractAnimation::State oldState); 00264 00270 void viewportGeometryChanged(const QRectF &geomety); 00271 00272 protected: 00273 00274 void resizeEvent(QGraphicsSceneResizeEvent *event); 00275 00276 void mouseMoveEvent(QGraphicsSceneMouseEvent *event); 00277 void mousePressEvent(QGraphicsSceneMouseEvent *event); 00278 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); 00279 void keyPressEvent(QKeyEvent *event); 00280 void wheelEvent(QGraphicsSceneWheelEvent *event); 00281 bool eventFilter(QObject *watched, QEvent *event); 00282 void focusInEvent(QFocusEvent *event); 00283 QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint) const; 00284 bool sceneEventFilter(QGraphicsItem *i, QEvent *e); 00285 00286 private: 00287 ScrollWidgetPrivate * const d; 00288 00289 Q_PRIVATE_SLOT(d, void verticalScroll(int value)) 00290 Q_PRIVATE_SLOT(d, void horizontalScroll(int value)) 00291 Q_PRIVATE_SLOT(d, void makeRectVisible()) 00292 Q_PRIVATE_SLOT(d, void makeItemVisible()) 00293 Q_PRIVATE_SLOT(d, void adjustScrollbars()) 00294 Q_PRIVATE_SLOT(d, void fixupX()) 00295 Q_PRIVATE_SLOT(d, void fixupY()) 00296 Q_PRIVATE_SLOT(d, void setScrollX()) 00297 Q_PRIVATE_SLOT(d, void setScrollY()) 00298 00299 friend class ScrollWidgetPrivate; 00300 }; 00301 00302 } // namespace Plasma 00303 00304 #endif // multiple inclusion guard
KDE 4.6 API Reference