| 135 | } |
| 136 | |
| 137 | void GUIHelpers::drawText(QPainter& painter, const QStringList& text, const QPoint& where, const QColor& col_fg, const QColor& col_bg, const QFont& f) |
| 138 | { |
| 139 | painter.save(); |
| 140 | |
| 141 | // font |
| 142 | painter.setFont(f); |
| 143 | |
| 144 | int line_spacing; |
| 145 | QRectF dim = getTextDimension(text, painter.font(), line_spacing); |
| 146 | |
| 147 | // draw background for text |
| 148 | if (col_bg.isValid()) painter.fillRect(where.x(), where.y(), dim.width(), dim.height(), col_bg); |
| 149 | |
| 150 | // draw text |
| 151 | if (col_fg.isValid()) painter.setPen(col_fg); |
| 152 | |
| 153 | for (int i = 0; i < text.size(); ++i) |
| 154 | { |
| 155 | painter.drawText(where.x() + 1, where.y() + (i + 1) * line_spacing, text[i]); |
| 156 | } |
| 157 | painter.restore(); |
| 158 | } |
| 159 | |
| 160 | QRectF GUIHelpers::getTextDimension(const QStringList& text, const QFont& f, int& line_spacing) |
| 161 | { |
no test coverage detected