17#include <klocalizedstring.h>
21#include <QResizeEvent>
24#include <QFontDatabase>
46 case QTextOption::LeftTab:
47 m_type = QTextOption::RightTab;
49 case QTextOption::RightTab:
50 m_type = QTextOption::CenterTab;
52 case QTextOption::CenterTab:
53 m_type = QTextOption::DelimiterTab;
55 case QTextOption::DelimiterTab:
56 m_type = QTextOption::LeftTab;
68 QPainter painter(
this);
71 painter.setPen(QPen(
palette().color(QPalette::Text), 0));
72 painter.setBrush(
palette().color(QPalette::Text));
73 painter.setRenderHint( QPainter::Antialiasing );
75 qreal x = 0.5 * width();
76 painter.translate(0,-height()/2+5);
79 case QTextOption::LeftTab:
80 polygon << QPointF(x+0.5, height() - 8.5)
81 << QPointF(x+6.5, height() - 2.5)
82 << QPointF(x+0.5, height() - 2.5);
83 painter.drawPolygon(polygon);
85 case QTextOption::RightTab:
86 polygon << QPointF(x+0.5, height() - 8.5)
87 << QPointF(x-5.5, height() - 2.5)
88 << QPointF(x+0.5, height() - 2.5);
89 painter.drawPolygon(polygon);
91 case QTextOption::CenterTab:
92 polygon << QPointF(x+0.5, height() - 8.5)
93 << QPointF(x-5.5, height() - 2.5)
94 << QPointF(x+6.5, height() - 2.5);
95 painter.drawPolygon(polygon);
97 case QTextOption::DelimiterTab:
98 polygon << QPointF(x-5.5, height() - 2.5)
99 << QPointF(x+6.5, height() - 2.5);
100 painter.drawPolyline(polygon);
101 polygon << QPointF(x+0.5, height() - 2.5)
102 << QPointF(x+0.5, height() - 8.5);
103 painter.drawPolyline(polygon);
120 lengthInPixel = d->viewConverter->documentToViewX(d->rulerLength);
123 rectangle.setX(qMax(0, d->offset));
125 rectangle.setWidth(qMin(qreal(d->ruler->width() - 1.0 - rectangle.x()),
127 rectangle.setHeight(d->ruler->height() - 1);
128 QRectF activeRangeRectangle;
129 activeRangeRectangle.setX(qMax(rectangle.x() + 1,
130 d->viewConverter->documentToViewX(d->effectiveActiveRangeStart()) + d->offset));
131 activeRangeRectangle.setY(rectangle.y() + 1);
132 activeRangeRectangle.setRight(qMin(rectangle.right() - 1,
133 d->viewConverter->documentToViewX(d->effectiveActiveRangeEnd()) + d->offset));
134 activeRangeRectangle.setHeight(rectangle.height() - 2);
136 painter.setPen(QPen(d->ruler->palette().color(QPalette::Mid), 0));
138 painter.fillRect(rectangle,d->ruler->palette().color(QPalette::AlternateBase));
139 painter.drawRect(rectangle);
141 if(d->effectiveActiveRangeStart() != d->effectiveActiveRangeEnd())
142 painter.fillRect(activeRangeRectangle, d->ruler->palette().brush(QPalette::Base));
144 if(d->showSelectionBorders) {
146 if(d->firstSelectionBorder > 0) {
147 qreal border = d->viewConverter->documentToViewX(d->firstSelectionBorder) + d->offset;
148 painter.drawLine(QPointF(border, rectangle.y() + 1), QPointF(border, rectangle.bottom() - 1));
151 if(d->secondSelectionBorder > 0) {
152 qreal border = d->viewConverter->documentToViewX(d->secondSelectionBorder) + d->offset;
153 painter.drawLine(QPointF(border, rectangle.y() + 1), QPointF(border, rectangle.bottom() - 1));
166 const QColor tabColor = d->ruler->palette().color(QPalette::Text);
167 painter.setPen(QPen(tabColor, 0));
168 painter.setBrush(tabColor);
169 painter.setRenderHint( QPainter::Antialiasing );
171 qreal position = -10000;
175 if (d->rightToLeft) {
176 x = d->viewConverter->documentToViewX(d->effectiveActiveRangeEnd()
177 - (d->relativeTabs ? d->paragraphIndent : 0) - t.
position) + d->offset;
179 x = d->viewConverter->documentToViewX(d->effectiveActiveRangeStart()
180 + (d->relativeTabs ? d->paragraphIndent : 0) + t.
position) + d->offset;
182 position = qMax(position, t.
position);
186 case QTextOption::LeftTab:
187 polygon << QPointF(x+0.5, d->ruler->height() - 6.5)
188 << QPointF(x+6.5, d->ruler->height() - 0.5)
189 << QPointF(x+0.5, d->ruler->height() - 0.5);
190 painter.drawPolygon(polygon);
192 case QTextOption::RightTab:
193 polygon << QPointF(x+0.5, d->ruler->height() - 6.5)
194 << QPointF(x-5.5, d->ruler->height() - 0.5)
195 << QPointF(x+0.5, d->ruler->height() - 0.5);
196 painter.drawPolygon(polygon);
198 case QTextOption::CenterTab:
199 polygon << QPointF(x+0.5, d->ruler->height() - 6.5)
200 << QPointF(x-5.5, d->ruler->height() - 0.5)
201 << QPointF(x+6.5, d->ruler->height() - 0.5);
202 painter.drawPolygon(polygon);
204 case QTextOption::DelimiterTab:
205 polygon << QPointF(x-5.5, d->ruler->height() - 0.5)
206 << QPointF(x+6.5, d->ruler->height() - 0.5);
207 painter.drawPolyline(polygon);
208 polygon << QPointF(x+0.5, d->ruler->height() - 0.5)
209 << QPointF(x+0.5, d->ruler->height() - 6.5);
210 painter.drawPolyline(polygon);
218 if (d->tabDistance > 0.0) {
220 position = qMax(position, d->relativeTabs ? 0 : d->paragraphIndent);
222 position = int(position / d->tabDistance) * d->tabDistance;
224 position = (int(position / d->tabDistance) + 1) * d->tabDistance;
226 while (position < d->effectiveActiveRangeEnd() - d->effectiveActiveRangeStart()
229 if (d->rightToLeft) {
230 x = d->viewConverter->documentToViewX(d->effectiveActiveRangeEnd()
231 - (d->relativeTabs ? d->paragraphIndent : 0) - position) + d->offset;
233 x = d->viewConverter->documentToViewX(d->effectiveActiveRangeStart()
234 + (d->relativeTabs ? d->paragraphIndent : 0) + position) + d->offset;
238 polygon << QPointF(x+0.5, d->ruler->height() - 3.5)
239 << QPointF(x+4.5, d->ruler->height() - 0.5)
240 << QPointF(x+0.5, d->ruler->height() - 0.5);
241 painter.drawPolygon(polygon);
243 position += d->tabDistance;
250 const QFont font = QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont);
251 const QFontMetrics fontMetrics(font);
252 const QPen numberPen(d->ruler->palette().color(QPalette::Text), 0);
253 const QPen markerPen(d->ruler->palette().color(QPalette::Inactive, QPalette::Text), 0);
254 painter.setPen(markerPen);
255 painter.setFont(font);
258 const int rulerLengthPixel = d->viewConverter->documentToViewX(d->rulerLength);
260 const qreal rulerLengthUnit = d->unit.toUserValue(d->rulerLength);
262 const qreal unitLength = d->viewConverter->documentToViewX(d->unit.fromUserValue(1.0));
264 const int textLength = fontMetrics.horizontalAdvance(QString::number(qCeil(rulerLengthUnit))) + 20;
266 const qreal minimalNumberSeparation = qCeil(textLength / unitLength);
268 qreal numberSeparation = minimalNumberSeparation;
269 if (minimalNumberSeparation <= 5) {
270 }
else if (minimalNumberSeparation <= 10) {
271 numberSeparation = 10;
272 }
else if (minimalNumberSeparation <= 20) {
273 numberSeparation = 20;
274 }
else if (minimalNumberSeparation <= 50) {
275 numberSeparation = 50;
276 }
else if (minimalNumberSeparation <= 100) {
277 numberSeparation = 100;
278 }
else if (minimalNumberSeparation <= 200) {
279 numberSeparation = 200;
280 }
else if (minimalNumberSeparation <= 500) {
281 numberSeparation = 500;
283 numberSeparation = qRound(qreal(numberSeparation / 100)) * 100;
286 const int pixelSeparation = qRound(d->viewConverter->documentToViewX(d->unit.fromUserValue(numberSeparation)));
288 const int secondarydisplacement = d->rightToLeft ? -pixelSeparation : pixelSeparation;
292 qreal numberStart, numberEnd;
293 if (d->rightToLeft) {
294 rulerEnd = d->offset;
295 numberStart = d->unit.toUserValue(d->viewConverter->viewToDocumentX(
296 rulerLengthPixel + d->offset - rectangle.right()));
299 int pixelEnd = rulerLengthPixel + d->offset - rectangle.left();
300 if (rulerEnd + textLength < rectangle.left()) {
301 pixelEnd -= textLength;
303 numberEnd = d->unit.toUserValue(d->viewConverter->viewToDocumentX(
305 if (rulerLengthPixel + d->offset > rectangle.right()) {
306 numberStart -= fmod(numberStart, numberSeparation);
309 rulerEnd = d->offset + rulerLengthPixel;
310 numberStart = d->unit.toUserValue(d->viewConverter->viewToDocumentX(
311 rectangle.left() - d->offset));
314 int pixelEnd = rectangle.right() - d->offset;
315 if (rulerEnd - textLength > rectangle.right()) {
316 pixelEnd += textLength;
318 numberEnd = d->unit.toUserValue(d->viewConverter->viewToDocumentX(
321 numberStart -= fmod(numberStart, numberSeparation);
324 for(qreal n = numberStart; n < numberEnd; n += numberSeparation) {
325 int posOnRuler = qRound(d->viewConverter->documentToViewX(d->unit.fromUserValue(n)));
326 int x = posOnRuler + d->offset;
327 if (d->rightToLeft) {
328 x = d->offset + rulerLengthPixel - posOnRuler;
332 painter.drawLine(QPointF(x, rectangle.bottom()-1),
334 QString numberText = QString::number(n);
335 painter.setPen(numberPen);
336 painter.drawText(QPointF(x - fontMetrics.horizontalAdvance(numberText)/2.0,
340 painter.setPen(markerPen);
342 int xQuarterMark1 = qRound(qreal(x) + qreal(secondarydisplacement) / 4.0);
343 if (d->rightToLeft ? xQuarterMark1 < rulerEnd : xQuarterMark1 > rulerEnd)
345 painter.drawLine(QPointF(xQuarterMark1, rectangle.bottom() - 1),
348 int xHalfMark = qRound(qreal(x) + qreal(secondarydisplacement) / 2.0);
349 if (d->rightToLeft ? xHalfMark < rulerEnd : xHalfMark > rulerEnd)
351 painter.drawLine(QPointF(xHalfMark, rectangle.bottom() - 1),
354 int xQuarterMark2 = qRound(qreal(x) + 3.0 * qreal(secondarydisplacement) / 4.0);
355 if (d->rightToLeft ? xQuarterMark2 < rulerEnd : xQuarterMark2 > rulerEnd)
357 painter.drawLine(QPointF(xQuarterMark2, rectangle.bottom() - 1),
362 const int mouseCoord = d->mouseCoordinate + d->offset;
364 const qreal top = rectangle.y() + 1;
365 const qreal bottom = rectangle.bottom() -1;
367 && d->showMousePosition
368 && d->mouseCoordinate > 0
369 && d->mouseCoordinate < rulerLengthPixel)
370 painter.drawLine(QPointF(mouseCoord, top), QPointF(mouseCoord, bottom));
372 const qreal x = d->viewConverter->documentToViewX(hp.
position) + d->offset;
373 painter.drawLine(QPointF(x, top), QPointF(x, bottom));
382 painter.setBrush(d->ruler->palette().brush(QPalette::Base));
383 painter.setRenderHint( QPainter::Antialiasing );
388 x = d->effectiveActiveRangeEnd() - d->firstLineIndent - d->paragraphIndent;
390 x = d->effectiveActiveRangeStart() + d->firstLineIndent + d->paragraphIndent;
392 x = int(d->viewConverter->documentToViewX(x) + d->offset + 0.5);
393 polygon << QPointF(x+6.5, 0.5)
394 << QPointF(x+0.5, 8.5)
395 << QPointF(x-5.5, 0.5)
396 << QPointF(x+5.5, 0.5);
397 painter.drawPolygon(polygon);
401 x = d->effectiveActiveRangeStart() + d->endIndent;
403 x = d->effectiveActiveRangeStart() + d->paragraphIndent;
405 x = int(d->viewConverter->documentToViewX(x) + d->offset + 0.5);
406 const int bottom = d->ruler->height();
408 polygon << QPointF(x+6.5, bottom - 0.5)
409 << QPointF(x+0.5, bottom - 8.5)
410 << QPointF(x-5.5, bottom - 0.5)
411 << QPointF(x+5.5, bottom - 0.5);
412 painter.drawPolygon(polygon);
417 diff = d->viewConverter->documentToViewX(d->effectiveActiveRangeEnd()
418 - d->paragraphIndent) + d->offset - x;
420 diff = d->viewConverter->documentToViewX(d->effectiveActiveRangeEnd() - d->endIndent)
422 polygon.translate(diff, 0);
423 painter.drawPolygon(polygon);
429 const QFontMetrics fm(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
430 const int digitsHeight = fm.ascent() + 1;
433 return QSize(0, minimum);
438 lengthInPixel = d->viewConverter->documentToViewY(d->rulerLength);
441 rectangle.setY(qMax(0, d->offset));
442 rectangle.setWidth(d->ruler->width() - 1.0);
443 rectangle.setHeight(qMin(qreal(d->ruler->height() - 1.0 - rectangle.y()),
446 QRectF activeRangeRectangle;
447 activeRangeRectangle.setX(rectangle.x() + 1);
448 activeRangeRectangle.setY(qMax(rectangle.y() + 1,
449 d->viewConverter->documentToViewY(d->effectiveActiveRangeStart()) + d->offset));
450 activeRangeRectangle.setWidth(rectangle.width() - 2);
451 activeRangeRectangle.setBottom(qMin(rectangle.bottom() - 1,
452 d->viewConverter->documentToViewY(d->effectiveActiveRangeEnd()) + d->offset));
454 painter.setPen(QPen(d->ruler->palette().color(QPalette::Mid), 0));
456 painter.fillRect(rectangle,d->ruler->palette().color(QPalette::AlternateBase));
457 painter.drawRect(rectangle);
459 if(d->effectiveActiveRangeStart() != d->effectiveActiveRangeEnd())
460 painter.fillRect(activeRangeRectangle, d->ruler->palette().brush(QPalette::Base));
462 if(d->showSelectionBorders) {
464 if(d->firstSelectionBorder > 0) {
465 qreal border = d->viewConverter->documentToViewY(d->firstSelectionBorder) + d->offset;
466 painter.drawLine(QPointF(rectangle.x() + 1, border), QPointF(rectangle.right() - 1, border));
469 if(d->secondSelectionBorder > 0) {
470 qreal border = d->viewConverter->documentToViewY(d->secondSelectionBorder) + d->offset;
471 painter.drawLine(QPointF(rectangle.x() + 1, border), QPointF(rectangle.right() - 1, border));
480 const QFont font = QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont);
481 const QFontMetrics fontMetrics(font);
482 const QPen numberPen(d->ruler->palette().color(QPalette::Text), 0);
483 const QPen markerPen(d->ruler->palette().color(QPalette::Inactive, QPalette::Text), 0);
484 painter.setPen(markerPen);
485 painter.setFont(font);
488 const int rulerLengthPixel = d->viewConverter->documentToViewY(d->rulerLength);
490 const qreal rulerLengthUnit = d->unit.toUserValue(d->rulerLength);
492 const qreal unitLength = d->viewConverter->documentToViewY(d->unit.fromUserValue(1.0));
494 const int textLength = fontMetrics.horizontalAdvance(QString::number(qCeil(rulerLengthUnit))) + 20;
497 const qreal minimalNumberSeparation = qCeil(textLength / unitLength);
499 qreal numberSeparation = minimalNumberSeparation;
500 if (minimalNumberSeparation <= 5) {
501 }
else if (minimalNumberSeparation <= 10) {
502 numberSeparation = 10;
503 }
else if (minimalNumberSeparation <= 20) {
504 numberSeparation = 20;
505 }
else if (minimalNumberSeparation <= 50) {
506 numberSeparation = 50;
507 }
else if (minimalNumberSeparation <= 100) {
508 numberSeparation = 100;
509 }
else if (minimalNumberSeparation <= 200) {
510 numberSeparation = 200;
511 }
else if (minimalNumberSeparation <= 500) {
512 numberSeparation = 500;
514 numberSeparation = qRound(qreal(numberSeparation / 100.0)) * 100;
517 const int pixelSeparation = qRound(d->viewConverter->documentToViewY(d->unit.fromUserValue(numberSeparation)));
520 const int rulerEnd = rulerLengthPixel + d->offset;
521 qreal numberStart = d->unit.toUserValue(d->viewConverter->viewToDocumentY(
522 rectangle.top() - d->offset));
525 int pixelEnd = rectangle.bottom() - d->offset;
526 if (rulerEnd - textLength > rectangle.bottom()) {
527 pixelEnd += textLength;
529 qreal numberEnd = d->unit.toUserValue(d->viewConverter->viewToDocumentX(
532 numberStart -= fmod(numberStart, numberSeparation);
534 for(qreal n = numberStart; n < numberEnd; n += numberSeparation) {
535 int posOnRuler = qRound(d->viewConverter->documentToViewY(d->unit.fromUserValue(n)));
536 int y = d->offset + posOnRuler;
539 QString numberText = QString::number(n);
542 painter.drawLine(QPointF(0, 0),
544 painter.setPen(numberPen);
546 painter.drawText(QPointF(-fontMetrics.horizontalAdvance(numberText) / 2.0, 0),
551 painter.setPen(markerPen);
553 int yQuarterMark1 = qRound(qreal(y + pixelSeparation / 4.0));
554 if (yQuarterMark1 > rulerEnd)
556 painter.drawLine(QPointF(rectangle.right() - 1, yQuarterMark1),
559 int yHalfMark = qRound(qreal(y + pixelSeparation / 2.0));
560 if (yHalfMark > rulerEnd)
562 painter.drawLine(QPointF(rectangle.right() - 1, yHalfMark),
565 int yQuarterMark2 = qRound(qreal(y + 3.0 * pixelSeparation / 4.0));
566 if (yQuarterMark2 > rulerEnd)
568 painter.drawLine(QPointF(rectangle.right() - 1, yQuarterMark2),
573 const int mouseCoord = d->mouseCoordinate + d->offset;
575 const qreal left = rectangle.left() + 1;
576 const qreal right = rectangle.right() -1;
578 && d->showMousePosition
579 && d->mouseCoordinate > 0
580 && d->mouseCoordinate < rulerLengthPixel)
581 painter.drawLine(QPointF(left, mouseCoord), QPointF(right, mouseCoord));
583 const qreal y = d->viewConverter->documentToViewY(hp.
position) + d->offset;
584 painter.drawLine(QPointF(left, y), QPointF(right, y));
592 const QFontMetrics fm(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
593 const int digitsHeight = fm.ascent() + 1;
596 return QSize(minimum, 0);
604 if (qMax(start, end) - qMin(start, end) < 1)
608 painter.translate(d->offset, d->ruler->height() / 2);
609 painter.setPen(QPen(d->ruler->palette().color(QPalette::Text), 0));
610 painter.setBrush(d->ruler->palette().color(QPalette::Text));
612 QLineF line(QPointF(d->viewConverter->documentToViewX(start), 0),
613 QPointF(d->viewConverter->documentToViewX(end), 0));
614 QPointF midPoint = line.pointAt(0.5);
617 const QFont font = QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont);
618 const QFontMetrics fontMetrics(font);
619 QString label = d->unit.toUserStringValue(
620 d->viewConverter->viewToDocumentX(line.length())) +
' ' + d->unit.symbol();
621 QPointF labelPosition = QPointF(midPoint.x() - fontMetrics.horizontalAdvance(label)/2,
622 midPoint.y() + fontMetrics.ascent()/2);
623 painter.setFont(font);
624 painter.drawText(labelPosition, label);
627 qreal arrowLength = (line.length() - fontMetrics.horizontalAdvance(label)) / 2 - 2;
628 arrowLength = qMax(qreal(0.0), arrowLength);
629 QLineF startArrow(line.p1(), line.pointAt(arrowLength / line.length()));
630 QLineF endArrow(line.p2(), line.pointAt(1.0 - arrowLength / line.length()));
631 painter.drawLine(startArrow);
632 painter.drawLine(endArrow);
636 arrowHead << line.p1() << QPointF(line.x1()+3, line.y1()-3)
637 << QPointF(line.x1()+3, line.y1()+3);
638 painter.drawPolygon(arrowHead);
640 arrowHead << line.p2() << QPointF(line.x2()-3, line.y2()-3)
641 << QPointF(line.x2()-3, line.y2()+3);
642 painter.drawPolygon(arrowHead);
651 points << d->effectiveActiveRangeStart() + d->paragraphIndent + d->firstLineIndent;
652 points << d->effectiveActiveRangeStart() + d->paragraphIndent;
653 points << d->effectiveActiveRangeEnd() - d->endIndent;
654 points << d->effectiveActiveRangeStart();
655 points << d->effectiveActiveRangeEnd();
656 points << d->rulerLength;
657 std::sort(points.begin(), points.end());
658 QListIterator<qreal> i(points);
660 while (i.hasNext() && i.hasPrevious()) {
674 activeOverrideRangeStart(0),
675 activeOverrideRangeEnd(0),
677 showMousePosition(0),
678 showSelectionBorders(false),
679 firstSelectionBorder(0),
680 secondSelectionBorder(0),
694 normalPaintingStrategy(o == Qt::Horizontal ?
697 paintingStrategy(normalPaintingStrategy),
699 guideCreationStarted(false),
730 return numberStep * qRound(
value / numberStep);
735 const int height =
ruler->height();
738 if (pos.x() >= x - 8 && pos.x() <= x +8 && pos.y() < height / 2) {
745 if (pos.x() >= x - 8 && pos.x() <= x +8 && pos.y() > height / 2) {
752 if (pos.x() >= x - 8 && pos.x() <= x + 8) {
760 if (pos.x() >= x -8 && pos.x() <= x + 8 && pos.y() < height / 2) {
767 if (pos.x() >= x - 8 && pos.x() <= x + 8 && pos.y() > height/2) {
774 if (pos.x() >= x - 8 && pos.x() <= x + 8) {
786 for(
int counter = 0; counter <
hotspots.count(); counter++) {
830 setMouseTracking(
true );
873 QPainter painter(
this);
875 painter.setClipRegion(event->region());
879 painter.fillRect(
rect(), QColor(0, 0, 0, 24));
1049 std::sort(answer.begin(), answer.end(),
compareTabs);
1068 if (ev->button() == Qt::RightButton && !
d->
popupActions.isEmpty())
1070 if (ev->button() != Qt::LeftButton) {
1084 QPoint pos = ev->pos();
1097 if (pos.x() >= x-6 && pos.x() <= x+6) {
1112 if (hotSpotIndex >= 0) {
1130 QTextOption::LeftTab};
1138 if (
d->
orientation == Qt::Horizontal && (ev->modifiers() & Qt::ShiftModifier) &&
1177 QPoint pos = ev->pos();
1196 if( ! (ev->modifiers() & Qt::ShiftModifier)) {
1213 if( ! (ev->modifiers() & Qt::ShiftModifier)) {
1232 if (!(ev->modifiers() & Qt::ShiftModifier)) {
1247 if (ev->pos().y() < height()) {
1260 if (!(ev->modifiers() & Qt::ShiftModifier))
1292 if (hotSpotIndex >= 0) {
1293 setCursor(QCursor(
d->
orientation == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor ));
1305 if (ev->buttons() & Qt::LeftButton) {
1331 for(
uint i = 0; i < hotspotCount; ++i ) {
1350 if (iter->id ==
id) {
1365 tool, SLOT(createGuideLine(Qt::Orientation,qreal)));
qreal length(const QPointF &vec)
float value(const T *src, size_t ch)
static const int OutsideRulerThreshold
static const int measurementTextAboveBelowMargin
static const int halfStepMarkerLength
static const int fullStepMarkerLength
static const int quarterStepMarkerLength
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void drawDistanceLine(const KoRulerPrivate *d, QPainter &painter, const qreal start, const qreal end)
void drawMeasurements(const KoRulerPrivate *ruler, QPainter &painter, const QRectF &rectangle) override
void drawIndents(const KoRulerPrivate *ruler, QPainter &painter) override
void drawTabs(const KoRulerPrivate *ruler, QPainter &painter) override
QSize sizeHint() override
QRectF drawBackground(const KoRulerPrivate *ruler, QPainter &painter) override
void drawMeasurements(const KoRulerPrivate *ruler, QPainter &painter, const QRectF &rectangle) override
int hotSpotIndex(const QPoint &pos)
bool guideCreationStarted
RulerTabChooser * tabChooser
PaintingStrategy * paintingStrategy
QList< HotSpotData > hotspots
QList< QAction * > popupActions
qreal firstSelectionBorder
qreal effectiveActiveRangeEnd() const
qreal secondSelectionBorder
qreal numberStepForUnit() const
qreal activeOverrideRangeStart
KoRulerPrivate(KoRuler *parent, const KoViewConverter *vc, Qt::Orientation orientation)
qreal activeOverrideRangeEnd
qreal doSnapping(const qreal value) const
const KoViewConverter *const viewConverter
qreal effectiveActiveRangeStart() const
QList< KoRuler::Tab > tabs
const Qt::Orientation orientation
Selection selectionAtPosition(const QPoint &pos, int *selectOffset=0)
PaintingStrategy * distancesPaintingStrategy
PaintingStrategy * normalPaintingStrategy
bool showSelectionBorders
bool showMousePosition() const
void updateMouseCoordinate(int coordinate)
void setEndIndent(qreal indent)
void updateSelectionBorders(qreal first, qreal second)
KoUnit unit() const
The ruler's unit.
void guideCreationFinished(Qt::Orientation orientation, const QPoint &globalPos)
void guideLineCreated(Qt::Orientation orientation, qreal viewPosition)
emitted when the mouse is drag+released outside the ruler
void aboutToChange()
emitted when there the user is about to change a tab or hotspot
void setUnit(const KoUnit &unit)
Set the unit of the ruler.
void setParagraphIndent(qreal indent)
void createGuideToolConnection(KoCanvasBase *canvas)
void setRightToLeft(bool isRightToLeft)
void setShowIndents(bool show)
void paintEvent(QPaintEvent *event) override
reimplemented
KoRuler(QWidget *parent, Qt::Orientation orientation, const KoViewConverter *viewConverter)
void indentsChanged(bool final)
void setRulerLength(qreal length)
Sets the length of the ruler to length in points (pt)
qreal endIndent() const
The end indent of all lines.
void mouseReleaseEvent(QMouseEvent *ev) override
reimplemented
void setOverrideActiveRange(qreal start, qreal end)
QSize minimumSizeHint() const override
reimplemented
void guideCreationInProgress(Qt::Orientation orientation, const QPoint &globalPos)
void setHotSpot(qreal position, int id=-1)
void setRelativeTabs(bool relative)
QList< Tab > tabs() const
qreal rulerLength() const
The length of the ruler in points (pt)
void setUnitPixelMultiple2(bool enabled)
void setShowTabs(bool show)
void updateTabs(const QList< Tab > &tabs, qreal tabDistance)
void setOffset(int offset)
void hotSpotChanged(int id, qreal newPosition)
qreal firstLineIndent() const
The start indent of the first line.
void setActiveRange(qreal start, qreal end)
bool removeHotSpot(int id)
void mouseMoveEvent(QMouseEvent *ev) override
reimplemented
QList< QAction * > popupActionList() const
void setShowSelectionBorders(bool show)
void setPopupActionList(const QList< QAction * > &popupActionList)
QSize sizeHint() const override
reimplemented
void mousePressEvent(QMouseEvent *ev) override
reimplemented
void tabChanged(int originalTabIndex, KoRuler::Tab *tab)
void setShowMousePosition(bool show)
void setFirstLineIndent(qreal indent)
Qt::Orientation orientation() const
The orientation of the ruler.
qreal paragraphIndent() const
The start indent of the rest of the lines.
qreal fromUserValue(qreal value) const
KoUnit::Type type() const
@ Point
Postscript point, 1/72th of an Inco.
virtual qreal documentToViewY(qreal documentY) const
virtual qreal viewToDocumentY(qreal viewY) const
virtual qreal documentToViewX(qreal documentX) const
virtual qreal viewToDocumentX(qreal viewX) const
virtual void drawTabs(const KoRulerPrivate *ruler, QPainter &painter)=0
virtual QRectF drawBackground(const KoRulerPrivate *ruler, QPainter &painter)=0
virtual QSize sizeHint()=0
virtual void drawIndents(const KoRulerPrivate *ruler, QPainter &painter)=0
virtual void drawMeasurements(const KoRulerPrivate *ruler, QPainter &painter, const QRectF &rectangle)=0
void setShowTabs(bool showTabs)
QTextOption::TabType type()
void paintEvent(QPaintEvent *) override
QTextOption::TabType m_type
void mousePressEvent(QMouseEvent *) override
void drawMeasurements(const KoRulerPrivate *ruler, QPainter &painter, const QRectF &rectangle) override
QRectF drawBackground(const KoRulerPrivate *ruler, QPainter &painter) override
QSize sizeHint() override
rgba palette[MAX_PALETTE]
For paragraphs each tab definition is represented by this struct.
qreal position
distance in point from the start of the text-shape
QTextOption::TabType type
Determine which type is used.