18 #include <QMouseEvent> 19 #include <QPaintEvent> 20 #include <QWheelEvent> 36 m_thumbColour(palette().highlightedText().color()),
37 m_backgroundAlpha(255),
68 if (unit < 0.01) unit = 0.01;
84 if (e->button() == Qt::MidButton ||
85 ((e->button() == Qt::LeftButton) &&
86 (e->modifiers() & Qt::ControlModifier))) {
88 }
else if (e->button() == Qt::LeftButton) {
99 if (e->button() != Qt::LeftButton) {
111 float dx = float(e->pos().x() -
m_clickPos.x()) /
float(width());
112 float dy = float(e->pos().y() -
m_clickPos.y()) /
float(height());
153 QPainter paint(
this);
154 paint.setRenderHint(QPainter::Antialiasing,
false);
156 QColor bg(palette().background().color());
159 paint.setPen(palette().dark().color());
161 paint.drawRect(0, 0, width()-1, height()-1);
173 paint.drawRect(lrintf(width() *
m_rectX),
275 return QSize(30, 30);
virtual void mousePressEvent(QMouseEvent *e)
virtual void leaveEvent(QEvent *)
void getRectExtents(float &x0, float &y0, float &width, float &height)
Panner(QWidget *parent=0)
virtual QSize sizeHint() const
void scroll(bool up)
Move up (if up is true) or down a bit.
void setScrollUnit(float unit)
Set the amount the scroll() function or mouse wheel movement makes the panner rectangle move by.
virtual void mouseDoubleClickEvent(QMouseEvent *e)
void setRectWidth(float width)
Set the width of the panned rectangle as a fraction (0 -> 1) of that of the whole panner widget.
virtual void enterEvent(QEvent *)
void setRectHeight(float height)
Set the height of the panned rectangle as a fraction (0 -> 1) of that of the whole panner widget.
void setRectCentreY(float y)
Set the location of the centre of the panned rectangle on the y axis, as a proportion (0 -> 1) of the...
virtual void mouseReleaseEvent(QMouseEvent *e)
virtual void wheelEvent(QWheelEvent *e)
void rectExtentsChanged(float, float, float, float)
Emitted when the panned rectangle is dragged or otherwise moved.
void doubleClicked()
Emitted when the panner is double-clicked (for the "customer" code to pop up a value editing dialog,...
virtual void mouseMoveEvent(QMouseEvent *e)
void setRectCentreX(float x)
Set the location of the centre of the panned rectangle on the x axis, as a proportion (0 -> 1) of the...
void setDefaultRectCentre(float, float)
void setRectExtents(float x0, float y0, float width, float height)
Set the extents of the panned rectangle within the overall panner widget.
void rectCentreMoved(float, float)
Emitted when the rectangle is dragged or otherwise moved (as well as extentsChanged).
virtual void paintEvent(QPaintEvent *e)
void setAlpha(int backgroundAlpha, int thumbAlpha)