! \internal Returns the size ("margin" in QCPAxisRect context, so measured perpendicular to the axis backbone direction) needed to fit the axis. */
| 9414 | direction) needed to fit the axis. |
| 9415 | */ |
| 9416 | int QCPAxisPainterPrivate::size() const |
| 9417 | { |
| 9418 | int result = 0; |
| 9419 | |
| 9420 | // get length of tick marks pointing outwards: |
| 9421 | if (!tickPositions.isEmpty()) |
| 9422 | result += qMax(0, qMax(tickLengthOut, subTickLengthOut)); |
| 9423 | |
| 9424 | // calculate size of tick labels: |
| 9425 | if (tickLabelSide == QCPAxis::lsOutside) |
| 9426 | { |
| 9427 | QSize tickLabelsSize(0, 0); |
| 9428 | if (!tickLabels.isEmpty()) |
| 9429 | { |
| 9430 | for (int i=0; i<tickLabels.size(); ++i) |
| 9431 | getMaxTickLabelSize(tickLabelFont, tickLabels.at(i), &tickLabelsSize); |
| 9432 | result += QCPAxis::orientation(type) == Qt::Horizontal ? tickLabelsSize.height() : tickLabelsSize.width(); |
| 9433 | result += tickLabelPadding; |
| 9434 | } |
| 9435 | } |
| 9436 | |
| 9437 | // calculate size of axis label (only height needed, because left/right labels are rotated by 90 degrees): |
| 9438 | if (!label.isEmpty()) |
| 9439 | { |
| 9440 | QFontMetrics fontMetrics(labelFont); |
| 9441 | QRect bounds; |
| 9442 | bounds = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip | Qt::AlignHCenter | Qt::AlignVCenter, label); |
| 9443 | result += bounds.height() + labelPadding; |
| 9444 | } |
| 9445 | |
| 9446 | return result; |
| 9447 | } |
| 9448 | |
| 9449 | /*! \internal |
| 9450 |
no test coverage detected