23 #include <QMouseEvent> 24 #include <QWheelEvent> 32 m_positiveOnly(positiveOnly),
34 m_colorMapper(colorMapper)
36 setAutoFillBackground(
false);
37 setAttribute(Qt::WA_OpaquePaintEvent,
true);
38 setAttribute(Qt::WA_NoSystemBackground,
true);
39 setMouseTracking(
true);
40 setFocusPolicy(Qt::StrongFocus);
44 m_background.setCoordinateMode(QGradient::ObjectBoundingMode);
49 for (; cmit != cmitEnd; ++ cmit) {
67 const QLocale & cLocale = QLocale::c();
76 QWidget::setFont(font);
78 QFontMetrics fm(font);
101 for (; cmit != cmitEnd; ++ cmit) {
164 for(
int i = 0;
i < d;
i++)
171 if (c == QChar(
'+')) {
173 }
else if (c == QChar(
'-')) {
179 if(c == QChar(
'0')) {
182 return QChar::fromLatin1(c.toLatin1() - 1);
187 if(c == QChar(
'9')) {
190 return QChar::fromLatin1(c.toLatin1() + 1);
197 qDebug(
"ValueDialZ::formatText: value: %lld", value);
198 QString str = QString(
"%1%2").arg(
m_positiveOnly ?
"" : value < 0 ?
"-" :
"+").arg(value < 0 ? -value : value,
m_numDigits, 10, QChar(
'0'));
214 QPainter painter(
this);
216 painter.setPen(Qt::black);
219 painter.drawRect(0, 0, width() - 1, height() - 1);
222 painter.setBrush(Qt::NoBrush);
227 painter.drawLine(1 +
i *
m_digitWidth, 1, 1 +
i * m_digitWidth, height() - 1);
229 painter.drawLine(0 +
i * m_digitWidth, 1, 0 +
i * m_digitWidth, height() - 1);
230 painter.drawLine(2 +
i * m_digitWidth, 1, 2 +
i * m_digitWidth, height() - 1);
234 painter.drawLine(1, 1, 1, height() - 1);
235 painter.drawLine(width() - 2, 1, width() - 2, height() - 1);
239 painter.drawLine(0, 0, width() - 2, 0);
240 painter.drawLine(0, height() - 1, 0, 0);
242 painter.drawLine(1, height() - 1, width() - 1, height() - 1);
243 painter.drawLine(width() - 1, height() - 1, width() - 1, 0);
247 painter.setPen(Qt::NoPen);
254 for (
int i = 0;
i <
m_text.length();
i++)
268 painter.setClipping(
false);
272 painter.setPen(Qt::NoPen);
299 painter.drawText(QRect(1 + i * m_digitWidth, h, m_digitWidth,
m_digitHeight), Qt::AlignCenter,
m_text.mid(i, 1));
330 Qt::MouseButton mouseButton =
event->button();
332 if (mouseButton == Qt::RightButton)
348 else if (mouseButton == Qt::LeftButton)
408 if(event->delta() < 0)
410 if (event->modifiers() & Qt::ShiftModifier) {
412 }
else if (event->modifiers() & Qt::ControlModifier) {
420 if (event->modifiers() & Qt::ShiftModifier) {
422 }
else if (event->modifiers() & Qt::ControlModifier) {
448 if((value->key() == Qt::Key_Return) || (value->key() == Qt::Key_Enter) || (value->key() == Qt::Key_Escape))
479 if ((value->key() == Qt::Key_Left) || (value->key() == Qt::Key_Backspace))
498 else if(value->key() == Qt::Key_Right)
517 else if(value->key() == Qt::Key_Up)
531 if (value->modifiers() & Qt::ShiftModifier) {
533 }
else if (value->modifiers() & Qt::ControlModifier) {
547 else if(value->key() == Qt::Key_Down)
561 if (value->modifiers() & Qt::ShiftModifier) {
563 }
else if (value->modifiers() & Qt::ControlModifier) {
578 if(value->text().length() != 1) {
582 QChar c = value->text()[0];
596 else if ((c >= QChar(
'0')) && (c <= QChar(
'9')) && (
m_cursor > 0))
598 int d = c.toLatin1() -
'0';
601 int sign =
m_value < 0 ? -1 : 1;
602 quint64 v = (value / e) % 10;
QLinearGradient m_background
void mousePressEvent(QMouseEvent *)
quint64 findExponent(int digit)
void setValue(qint64 value)
const QColor & getBoundaryColor() const
void setColorMapper(ColorMapper colorMapper)
const QColor & getForegroundColor() const
ValueDialZ(bool positiveOnly=true, QWidget *parent=NULL, ColorMapper colorMapper=ColorMapper(ColorMapper::Normal))
void wheelEvent(QWheelEvent *)
const QColor & getHighlightColor() const
void paintEvent(QPaintEvent *)
Fixed< IntType, IntBits > abs(Fixed< IntType, IntBits > const &x)
const colormap & getDialBackgroundColorMap() const
void keyPressEvent(QKeyEvent *)
const QColor & getBoundaryAlphaColor() const
ColorMapper m_colorMapper
void leaveEvent(QEvent *)
const QColor & getDarkBorderColor() const
QChar digitNeigh(QChar c, bool dir)
QString formatText(qint64 value)
void setValueRange(bool positiveOnly, uint numDigits, qint64 min, qint64 max)
const QColor & getLightBorderColor() const
void changed(qint64 value)
void focusInEvent(QFocusEvent *)
void focusOutEvent(QFocusEvent *)
void mouseMoveEvent(QMouseEvent *)
const QColor & getSecondaryForegroundColor() const
T max(const T &x, const T &y)
T min(const T &x, const T &y)
void setFont(const QFont &font)