Qwt User's Guide: qwt_abstract_scale_draw.h Source File

Qwt User's Guide 5.2.3

- Main Page
- Related Pages
- Classes

qwt_abstract_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_ABSTRACT_SCALE_DRAW_H
11 #define QWT_ABSTRACT_SCALE_DRAW_H
12
13 #include "qwt_global.h"
14 #include "qwt_scale_div.h"
15 #include "qwt_text.h"
16
17
18 #if QT_VERSION < 0x040000
19 class QColorGroup;
20 #else
21 class QPalette;
22 #endif
23 class QPainter;
24 class QFont;
25 class QwtScaleTransformation;
26 class QwtScaleMap;
27
37 class QWT_EXPORT QwtAbstractScaleDraw
38 {
39 public:
40
51 enum ScaleComponent
52 {
53 Backbone = 1,
54 Ticks = 2,
55 Labels = 4
56 };
57
58 QwtAbstractScaleDraw();
59 QwtAbstractScaleDraw( const QwtAbstractScaleDraw & );
60 virtual ~QwtAbstractScaleDraw();
61
62 QwtAbstractScaleDraw &operator=(const QwtAbstractScaleDraw &);
63
64 void setScaleDiv(const QwtScaleDiv &s);
65 const QwtScaleDiv& scaleDiv() const;
66
67 void setTransformation(QwtScaleTransformation *);
68 const QwtScaleMap &map() const;
69
70 void enableComponent(ScaleComponent, bool enable = true);
71 bool hasComponent(ScaleComponent) const;
72
73 void setTickLength(QwtScaleDiv::TickType, int length);
74 int tickLength(QwtScaleDiv::TickType) const;
75 int majTickLength() const;
76
77 void setSpacing(int margin);
78 int spacing() const;
79
80 #if QT_VERSION < 0x040000
81 virtual void draw(QPainter *, const QColorGroup &) const;
82 #else
83 virtual void draw(QPainter *, const QPalette &) const;
84 #endif
85
86 virtual QwtText label(double) const;
87
97 virtual int extent(const QPen &, const QFont &) const = 0;
98
99 void setMinimumExtent(int);
100 int minimumExtent() const;
101
102 QwtScaleMap &scaleMap();
103
104 protected:
114 virtual void drawTick(QPainter *painter, double value, int len) const = 0;
115
122 virtual void drawBackbone(QPainter *painter) const = 0;
123
132 virtual void drawLabel(QPainter *painter, double value) const = 0;
133
134 void invalidateCache();
135 const QwtText &tickLabel(const QFont &, double value) const;
136
137 private:
138 int operator==(const QwtAbstractScaleDraw &) const;
139 int operator!=(const QwtAbstractScaleDraw &) const;
140
141 class PrivateData;
142 PrivateData *d_data;
143 };
144
145 #endif