Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

# QwtScale Class Reference

Collaboration diagram for QwtScale:

[legend]
List of all members.

## Detailed Description

A Widget which contains a scale.

This Widget can be used to decorate composite widgets with a scale.

Definition at line 34 of file qwt_scale.h.

## Public Types
enum | Position { Left, Right, Top, Bottom }
## Public Member Functions
| QwtScale (QWidget *parent=0, const char *name=0)
| QwtScale (Position, QWidget *parent=0, const char *name=0)
virtual | ~QwtScale ()
void | setTitle (const QString &title)
const QString | title () const
void | setTitleColor (const QColor &c)
const QColor | titleColor () const
void | setTitleFont (const QFont &f)
const QFont | titleFont () const
void | setTitleAlignment (int flags)
int | titleAlignment () const
void | setBorderDist (int start, int end)
int | startBorderDist () const
int | endBorderDist () const
void | minBorderDist (int &start, int &end) const
void | setBaselineDist (int bd)
int | baseLineDist () const
void | setTitleDist (int td)
int | titleDist () const
void | setScaleDiv (const QwtScaleDiv &sd)
void | setScaleDraw (QwtScaleDraw *)
const QwtScaleDraw * | scaleDraw () const
void | setLabelFormat (char f, int prec, int fieldWidth)
void | labelFormat (char &f, int &prec, int &fieldWidth) const
void | setLabelAlignment (int align)
void | setLabelRotation (double rotation)
virtual QSize | sizeHint () const
virtual QSize | minimumSizeHint () const
virtual QSizePolicy | sizePolicy () const
int | titleHeightForWidth (int width) const
int | dimForLength (int length, const QFontMetrics &scaleFontMetrics) const
void | drawTitle (QPainter *painter, QwtScaleDraw::Orientation o, const QRect &rect) const
void | setPosition (Position o)
Position | position () const
## Protected Member Functions
void | draw (QPainter *p) const
void | paintEvent (QPaintEvent *e)
void | resizeEvent (QResizeEvent *e)
void | scaleChange ()
void | fontChange (const QFont &oldfont)
void | layoutScale (bool update=TRUE)

## Member Enumeration Documentation

enum QwtScale::Position

| Position of the scale See also: QwtScale::QwtScale Definition at line 49 of file qwt_scale.h. Referenced by position().

## Constructor & Destructor Documentation

QwtScale::QwtScale | ( | QWidget * | parent = `0`,
|  | const char * | name = `0`
| ) |

  | Create a scale with the position QwtScale::Left. Parameters:
  | parent |
  | name | passed to QWidget's CTOR
Warning: Workaround of a designer problem Definition at line 27 of file qwt_scale.cpp.

QwtScale::QwtScale | ( | QwtScale::Position | pos,
|  | QWidget * | parent = `0`,
|  | const char * | name = `0`
| ) |

  | Constructor. Parameters:
  | pos | Position. Must be one of `QwtScale::Left, QwtScale::Right, QwtScale::Bottom,` or `QwtScale::Top`
  | parent |
  | name | passed to QWidget's CTOR
Definition at line 41 of file qwt_scale.cpp.

QwtScale::~QwtScale | ( |  | ) | `[virtual]`

| Destructor. Definition at line 48 of file qwt_scale.cpp.

## Member Function Documentation

int QwtScale::baseLineDist | ( |  | ) | const

| Returns: base line distance See also: QwtScale::setBaselineDist Definition at line 396 of file qwt_scale.cpp. Referenced by QwtPlotLayout::minimumSizeHint(), and QwtPlot::print().

int QwtScale::dimForLength | ( | int | length,
|  | const QFontMetrics & | scaleFontMetrics
| ) | const

  | Find the minimum dimension for a given length. dim is the height, length the width seen in direction of the title. Parameters:
  | length | width for horizontal, height for vertical scales
  | scaleFontMetrics | Font metrics of the scale
Returns: height for horizontal, width for vertical scales Definition at line 686 of file qwt_scale.cpp. References QwtScaleDraw::minHeight(), QwtScaleDraw::minWidth(), QwtScaleDraw::orientation(), QwtText::text(), and titleHeightForWidth(). Referenced by minimumSizeHint().

void QwtScale::draw | ( | QPainter * | p | ) | const`[protected]`

| draw the scale Definition at line 426 of file qwt_scale.cpp. References QwtScaleDraw::draw(), drawTitle(), and QwtScaleDraw::orientation(). Referenced by paintEvent().

void QwtScale::drawTitle | ( | QPainter * | painter,
|  | QwtScaleDraw::Orientation | o,
|  | const QRect & | rect
| ) | const

  | Rotate and paint a title according to its position into a given rectangle. Parameters:
  | painter | Painter
  | o | Orientation
  | rect | Bounding rectangle
Definition at line 529 of file qwt_scale.cpp. References QwtText::alignment(), QwtText::draw(), and QwtText::setAlignment(). Referenced by draw(), and QwtPlot::printScale().

int QwtScale::endBorderDist | ( |  | ) | const

| Returns: end border distance See also: QwtScale::setBorderDist Definition at line 387 of file qwt_scale.cpp. Referenced by QwtPlot::canvasMap().

void QwtScale::fontChange | ( | const QFont & | oldFont | ) | `[protected]`

  | Notify a change of the font. This virtual function may be overloaded by derived widgets. The default implementation resizes the scale and repaints the widget. Parameters:
  | oldFont | Previous font
Definition at line 732 of file qwt_scale.cpp. References layoutScale().

void QwtScale::labelFormat | ( | char & | f,
|  | int & | prec,
|  | int & | fieldwidth
| ) | const

  | Format character and precision have the same meaning as for the QString class. Return values:
  | f | format character
  | prec | precision
  | fieldwidth | minimum fieldwidth
Returns: the number format for the major scale labels See also: QwtScale::setLabelFormat, QString::sprintf in the Qt manual Definition at line 324 of file qwt_scale.cpp. References QwtScaleDraw::labelFormat(). Referenced by QwtPlot::axisLabelFormat().

void QwtScale::layoutScale | ( | bool | update = `TRUE` | ) | `[protected]`

| Recalculate the scale's geometry and layout based on. Definition at line 468 of file qwt_scale.cpp. References QwtScaleDraw::maxHeight(), QwtScaleDraw::maxWidth(), minBorderDist(), QwtScaleDraw::orientation(), and QwtScaleDraw::setGeometry(). Referenced by fontChange(), resizeEvent(), scaleChange(), setBaselineDist(), setBorderDist(), setLabelAlignment(), setLabelFormat(), setLabelRotation(), setPosition(), setScaleDiv(), setScaleDraw(), setTitle(), setTitleAlignment(), setTitleDist(), and setTitleFont().

void QwtScale::minBorderDist | ( | int & | start,
|  | int & | end
| ) | const

| Determine the minimum Border distances. This member function returns the minimum distance of the scale's endpoints from the widget borders which is required for the mark labels to fit into the widget. Warning: The minimum border distance depends on the font. See also: QwtScale::setBorderDist() Definition at line 718 of file qwt_scale.cpp. References QwtScaleDraw::minBorderDist(). Referenced by QwtPlotPrintFilter::apply(), layoutScale(), minimumSizeHint(), QwtPlotLayout::minimumSizeHint(), QwtPlotPrintFilter::reset(), and QwtPlot::updateAxes().

QSize QwtScale::minimumSizeHint | ( |  | ) | const`[virtual]`

| Returns: a minimum size hint Definition at line 628 of file qwt_scale.cpp. References dimForLength(), minBorderDist(), QwtScaleDraw::minHeight(), QwtScaleDraw::minWidth(), and QwtScaleDraw::orientation(). Referenced by QwtPlotLayout::minimumSizeHint(), sizeHint(), and QwtPlot::sizeHint().

void QwtScale::paintEvent | ( | QPaintEvent * | e | ) | `[protected]`

| paintEvent Definition at line 413 of file qwt_scale.cpp. References draw(), and QwtPaintBuffer::painter().

QwtScale::Position QwtScale::position | ( |  | ) | const

| Returns: position See also: QwtScale::setPosition Definition at line 144 of file qwt_scale.cpp. References QwtScaleDraw::orientation(), Position, and scaleDraw().

void QwtScale::resizeEvent | ( | QResizeEvent * | e | ) | `[protected]`

| resizeEvent Definition at line 458 of file qwt_scale.cpp. References layoutScale().

void QwtScale::scaleChange | ( |  | ) | `[protected]`

| Notify a change of the scale. This virtual function can be overloaded by derived classes. The default implementation updates the geometry and repaints the widget. Definition at line 591 of file qwt_scale.cpp. References layoutScale().

const QwtScaleDraw * QwtScale::scaleDraw | ( |  | ) | const

| scaleDraw of this scale See also: QwtScaleDraw::setScaleDraw Definition at line 333 of file qwt_scale.cpp. Referenced by QwtPlot::axisScaleDraw(), QwtPlotLayout::minimumSizeHint(), position(), QwtPlot::printScale(), and QwtPlot::sizeHint().

void QwtScale::setBaselineDist | ( | int | bd | ) |

  | Specify the border distance of the scale's base line. Parameters:
  | bd | border distance of the baseline
See also: QwtScale::baseLineDist Definition at line 188 of file qwt_scale.cpp. References layoutScale(). Referenced by QwtPlot::print().

void QwtScale::setBorderDist | ( | int | dist1,
|  | int | dist2
| ) |

  | Specify distances of the scale's endpoints from the widget's borders. The actual borders will never be less than minimum border distance. Parameters:
  | dist1 | Left or top Distance
  | dist2 | Right or bottom distance
See also: QwtScale::borderDist Definition at line 173 of file qwt_scale.cpp. References layoutScale(). Referenced by QwtPlotPrintFilter::apply(), QwtPlotPrintFilter::reset(), and QwtPlot::updateAxes().

void QwtScale::setLabelAlignment | ( | int | align | ) |

| Change the alignment for the labels. See QwtScaleDraw::setLabelAlignment(). See also: QwtScaleDraw::setLabelAlignment(), QwtScale::setLabelRotation() Definition at line 278 of file qwt_scale.cpp. References layoutScale(), and QwtScaleDraw::setLabelAlignment(). Referenced by QwtPlot::setAxisLabelAlignment().

void QwtScale::setLabelFormat | ( | char | f,
|  | int | prec,
|  | int | fieldwidth
| ) |

  | Set the number format for the major scale labels. Format character and precision have the same meaning as for the QString class. Parameters:
  | f | format character
  | prec | precision
  | fieldwidth | minimum fieldwidth
See also: QwtScale::labelFormat, QString::sprintf in the Qt manual Definition at line 265 of file qwt_scale.cpp. References layoutScale(), and QwtScaleDraw::setLabelFormat(). Referenced by QwtPlot::setAxisLabelFormat().

void QwtScale::setLabelRotation | ( | double | rotation | ) |

| Change the rotation for the labels. See QwtScaleDraw::setLabelRotation(). See also: QwtScaleDraw::setLabelRotation(), QwtScale::setLabelAlignment() Definition at line 289 of file qwt_scale.cpp. References layoutScale(), and QwtScaleDraw::setLabelRotation(). Referenced by QwtPlot::setAxisLabelRotation().

void QwtScale::setPosition | ( | Position | pos | ) |

  | Assign a position. Parameters:
  | pos | new position
See also: QwtScale::position Definition at line 113 of file qwt_scale.cpp. References layoutScale(), and QwtScaleDraw::setGeometry().

void QwtScale::setScaleDiv | ( | const QwtScaleDiv & | sd | ) |

  | Assign a scale division. The scale division determines where to set the tick marks. Parameters:
  | sd | Scale Division
See also: For more information about scale divisions, see QwtScaleDiv. Definition at line 746 of file qwt_scale.cpp. References layoutScale(), QwtScaleDraw::scaleDiv(), and QwtScaleDraw::setScale(). Referenced by QwtPlot::updateAxes().

void QwtScale::setScaleDraw | ( | QwtScaleDraw * | sd | ) |

| Set a scale draw sd has to be created with new and will be deleted in QwtScale::~QwtScale or the next call of QwtScale::setScaleDraw. Definition at line 300 of file qwt_scale.cpp. References layoutScale(). Referenced by QwtPlot::setAxisScaleDraw().

void QwtScale::setTitle | ( | const QString & | text | ) |

  | Give title new text contents. Parameters:
  | text | New text
See also: QwtScale::title Definition at line 94 of file qwt_scale.cpp. References QwtText::alignment(), QwtText::color(), QwtText::font(), layoutScale(), QwtText::makeText(), and title(). Referenced by QwtPlot::setAxisTitle().

void QwtScale::setTitleAlignment | ( | int | flags | ) |

  | Change the title alignment. Parameters:
  | flags | see Qt::AlignmentFlags. flags are interpreted in direction of the label, AlignTop, AlignBottom can't be set as the title will always be aligned to the scale.
See also: QwtScale::titleAlignment, Qt::AlignmentFlags Definition at line 247 of file qwt_scale.cpp. References layoutScale(), and QwtText::setAlignment(). Referenced by QwtPlot::setAxisTitleAlignment().

void QwtScale::setTitleColor | ( | const QColor & | c | ) |

  | Change the title color. Parameters:
  | c | new title color
See also: QwtScale::titleColor Definition at line 233 of file qwt_scale.cpp. References QwtText::setColor(). Referenced by QwtPlotPrintFilter::apply(), and QwtPlotPrintFilter::reset().

void QwtScale::setTitleDist | ( | int | td | ) |

  | Specify the distance between scale and title. Parameters:
  | td | Title distance
See also: QwtScale::titleDist Definition at line 203 of file qwt_scale.cpp. References layoutScale().

void QwtScale::setTitleFont | ( | const QFont & | f | ) |

  | Change the title font. Parameters:
  | f | new font
See also: QwtScale::title Definition at line 219 of file qwt_scale.cpp. References QwtText::font(), layoutScale(), and QwtText::setFont(). Referenced by QwtPlotPrintFilter::apply(), QwtPlotPrintFilter::reset(), and QwtPlot::setAxisTitleFont().

QSize QwtScale::sizeHint | ( |  | ) | const`[virtual]`

| Returns: a size hint Definition at line 620 of file qwt_scale.cpp. References minimumSizeHint().

QSizePolicy QwtScale::sizePolicy | ( |  | ) | const`[virtual]`

| Returns: Fixed/MinimumExpanding for vertical, MinimumExpanding/Fixed for horizontal scales. Definition at line 600 of file qwt_scale.cpp. References QwtScaleDraw::orientation().

int QwtScale::startBorderDist | ( |  | ) | const

| Returns: start border distance See also: QwtScale::setBorderDist Definition at line 378 of file qwt_scale.cpp. Referenced by QwtPlot::canvasMap(), and QwtPlot::print().

const QString QwtScale::title | ( |  | ) | const

| Returns: title See also: QwtScale::setTitle Definition at line 369 of file qwt_scale.cpp. References QwtText::text(). Referenced by QwtPlot::axisTitle(), and setTitle().

int QwtScale::titleAlignment | ( |  | ) | const

| Returns: alignment See also: QwtScale::setTitleAlignment, Qt::AlignmentFlags Definition at line 342 of file qwt_scale.cpp. References QwtText::alignment(). Referenced by QwtPlot::axisTitleAlignment().

const QColor QwtScale::titleColor | ( |  | ) | const

| Returns: title color See also: QwtScale::setTitleColor Definition at line 360 of file qwt_scale.cpp. References QwtText::color(). Referenced by QwtPlotPrintFilter::apply().

int QwtScale::titleDist | ( |  | ) | const

| Returns: distance between scale and title See also: QwtScale::setBaselineDist Definition at line 405 of file qwt_scale.cpp.

const QFont QwtScale::titleFont | ( |  | ) | const

| Returns: title font See also: QwtScale::setTitleFont Definition at line 351 of file qwt_scale.cpp. References QwtText::font(). Referenced by QwtPlotPrintFilter::apply(), and QwtPlot::axisTitleFont().

int QwtScale::titleHeightForWidth | ( | int | width | ) | const

  | Find the height of the title for a given width. Parameters:
  | width | Width
Returns: height Height Definition at line 672 of file qwt_scale.cpp. References QwtText::heightForWidth(). Referenced by dimForLength().