Qwt User's Guide  5.2.3
qwt_scale_draw.h
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2  * Qwt Widget Library
3  * Copyright (C) 1997 Josef Wilgen
4  * Copyright (C) 2002 Uwe Rathmann
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the Qwt License, Version 1.0
8  *****************************************************************************/
9 
10 #ifndef QWT_SCALE_DRAW_H
11 #define QWT_SCALE_DRAW_H
12 
13 #include <qpoint.h>
14 #include "qwt_global.h"
15 #include "qwt_abstract_scale_draw.h"
16 
30 class QWT_EXPORT QwtScaleDraw: public QwtAbstractScaleDraw
31 {
32 public:
37  enum Alignment { BottomScale, TopScale, LeftScale, RightScale };
38 
39  QwtScaleDraw();
40  QwtScaleDraw(const QwtScaleDraw &);
41 
42  virtual ~QwtScaleDraw();
43 
44  QwtScaleDraw &operator=(const QwtScaleDraw &other);
45 
46  void getBorderDistHint(const QFont &, int &start, int &end) const;
47  int minLabelDist(const QFont &) const;
48 
49  int minLength(const QPen &, const QFont &) const;
50  virtual int extent(const QPen &, const QFont &) const;
51 
52  void move(int x, int y);
53  void move(const QPoint &);
54  void setLength(int length);
55 
56  Alignment alignment() const;
57  void setAlignment(Alignment);
58 
59  Qt::Orientation orientation() const;
60 
61  QPoint pos() const;
62  int length() const;
63 
64 #if QT_VERSION < 0x040000
65  void setLabelAlignment(int);
66  int labelAlignment() const;
67 #else
68  void setLabelAlignment(Qt::Alignment);
69  Qt::Alignment labelAlignment() const;
70 #endif
71 
72  void setLabelRotation(double rotation);
73  double labelRotation() const;
74 
75  int maxLabelHeight(const QFont &) const;
76  int maxLabelWidth(const QFont &) const;
77 
78  QPoint labelPosition(double val) const;
79 
80  QRect labelRect(const QFont &, double val) const;
81  QSize labelSize(const QFont &, double val) const;
82 
83  QRect boundingLabelRect(const QFont &, double val) const;
84 
85 protected:
86 
87 #if QT_VERSION < 0x040000
88  QWMatrix labelMatrix(const QPoint &, const QSize &) const;
89 #else
90  QMatrix labelMatrix(const QPoint &, const QSize &) const;
91 #endif
92 
93  virtual void drawTick(QPainter *p, double val, int len) const;
94  virtual void drawBackbone(QPainter *p) const;
95  virtual void drawLabel(QPainter *p, double val) const;
96 
97 private:
98  void updateMap();
99 
100  class PrivateData;
101  PrivateData *d_data;
102 };
103 
108 inline void QwtScaleDraw::move(int x, int y)
109 {
110  move(QPoint(x, y));
111 }
112 
113 #endif