2017-01-03 21:19:33 +01:00
|
|
|
#ifndef SCROLLBAR_H
|
|
|
|
#define SCROLLBAR_H
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include "QMutex"
|
2017-01-11 18:52:09 +01:00
|
|
|
#include "QWidget"
|
2017-01-03 21:19:33 +01:00
|
|
|
#include "scrollbarhighlight.h"
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
maximum = value;
|
|
|
|
|
|
|
|
updateScroll();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
setMinimum(qreal value)
|
|
|
|
{
|
|
|
|
minimum = value;
|
|
|
|
|
|
|
|
updateScroll();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
setLargeChange(qreal value)
|
|
|
|
{
|
|
|
|
largeChange = value;
|
|
|
|
|
|
|
|
updateScroll();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
setSmallChange(qreal value)
|
|
|
|
{
|
|
|
|
smallChange = value;
|
|
|
|
|
|
|
|
updateScroll();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
setValue(qreal value)
|
|
|
|
{
|
|
|
|
value = value;
|
|
|
|
|
|
|
|
updateScroll();
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal
|
|
|
|
getMaximum() const
|
|
|
|
{
|
|
|
|
return maximum;
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal
|
|
|
|
getMinimum() const
|
|
|
|
{
|
|
|
|
return minimum;
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal
|
|
|
|
getLargeChange() const
|
|
|
|
{
|
|
|
|
return largeChange;
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal
|
|
|
|
getSmallChange() const
|
|
|
|
{
|
|
|
|
return smallChange;
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal
|
|
|
|
getValue() const
|
|
|
|
{
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
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
|