2017-01-03 21:19:33 +01:00
|
|
|
#ifndef SCROLLBAR_H
|
|
|
|
#define SCROLLBAR_H
|
|
|
|
|
|
|
|
#include "scrollbarhighlight.h"
|
|
|
|
|
2017-01-18 04:52:47 +01:00
|
|
|
#include <QMutex>
|
|
|
|
#include <QWidget>
|
|
|
|
#include <functional>
|
|
|
|
|
2017-01-03 21:19:33 +01:00
|
|
|
class ScrollBar : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-01-11 18:52:09 +01:00
|
|
|
ScrollBar(QWidget *parent = 0);
|
2017-01-03 21:19:33 +01:00
|
|
|
~ScrollBar();
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
void removeHighlightsWhere(std::function<bool(ScrollBarHighlight &)> func);
|
|
|
|
void addHighlight(ScrollBarHighlight *highlight);
|
2017-01-03 21:19:33 +01:00
|
|
|
|
2017-01-18 04:33:30 +01:00
|
|
|
void
|
|
|
|
setMaximum(qreal value)
|
|
|
|
{
|
2017-01-18 14:48:42 +01:00
|
|
|
this->maximum = value;
|
2017-01-18 04:33:30 +01:00
|
|
|
|
2017-01-18 14:48:42 +01:00
|
|
|
this->updateScroll();
|
2017-01-18 04:33:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
setMinimum(qreal value)
|
|
|
|
{
|
2017-01-18 14:48:42 +01:00
|
|
|
this->minimum = value;
|
2017-01-18 04:33:30 +01:00
|
|
|
|
2017-01-18 14:48:42 +01:00
|
|
|
this->updateScroll();
|
2017-01-18 04:33:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
setLargeChange(qreal value)
|
|
|
|
{
|
2017-01-18 14:48:42 +01:00
|
|
|
this->largeChange = value;
|
2017-01-18 04:33:30 +01:00
|
|
|
|
2017-01-18 14:48:42 +01:00
|
|
|
this->updateScroll();
|
2017-01-18 04:33:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
setSmallChange(qreal value)
|
|
|
|
{
|
2017-01-18 14:48:42 +01:00
|
|
|
this->smallChange = value;
|
2017-01-18 04:33:30 +01:00
|
|
|
|
2017-01-18 14:48:42 +01:00
|
|
|
this->updateScroll();
|
2017-01-18 04:33:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
setValue(qreal value)
|
|
|
|
{
|
2017-01-18 14:48:42 +01:00
|
|
|
this->value = value;
|
2017-01-18 04:33:30 +01:00
|
|
|
|
2017-01-18 14:48:42 +01:00
|
|
|
this->updateScroll();
|
2017-01-18 04:33:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
qreal
|
|
|
|
getMaximum() const
|
|
|
|
{
|
2017-01-18 14:48:42 +01:00
|
|
|
return this->maximum;
|
2017-01-18 04:33:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
qreal
|
|
|
|
getMinimum() const
|
|
|
|
{
|
2017-01-18 14:48:42 +01:00
|
|
|
return this->minimum;
|
2017-01-18 04:33:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
qreal
|
|
|
|
getLargeChange() const
|
|
|
|
{
|
2017-01-18 14:48:42 +01:00
|
|
|
return this->largeChange;
|
2017-01-18 04:33:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
qreal
|
|
|
|
getSmallChange() const
|
|
|
|
{
|
2017-01-18 14:48:42 +01:00
|
|
|
return this->smallChange;
|
2017-01-18 04:33:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
qreal
|
|
|
|
getValue() const
|
|
|
|
{
|
2017-01-18 14:48:42 +01:00
|
|
|
return this->value;
|
2017-01-18 04:33:30 +01:00
|
|
|
}
|
|
|
|
|
2017-01-03 21:19:33 +01:00
|
|
|
private:
|
|
|
|
QMutex mutex;
|
2017-01-18 04:33:30 +01:00
|
|
|
ScrollBarHighlight *highlights;
|
2017-01-03 21:19:33 +01:00
|
|
|
void paintEvent(QPaintEvent *);
|
|
|
|
|
2017-01-18 04:33:30 +01:00
|
|
|
int buttonHeight;
|
|
|
|
int trackHeight;
|
|
|
|
|
2017-01-03 21:19:33 +01:00
|
|
|
QRect thumbRect;
|
2017-01-18 04:33:30 +01:00
|
|
|
|
|
|
|
qreal maximum;
|
|
|
|
qreal minimum;
|
|
|
|
qreal largeChange;
|
|
|
|
qreal smallChange;
|
|
|
|
qreal value;
|
|
|
|
|
|
|
|
void updateScroll();
|
2017-01-03 21:19:33 +01:00
|
|
|
};
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
#endif // SCROLLBAR_H
|