Qwt User's Guide 6.0.2

- 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 class QPalette;
18 class QPainter;
19 class QFont;
20 class QwtScaleTransformation;
21 class QwtScaleMap;
22
32 class QWT_EXPORT QwtAbstractScaleDraw
33 {
34 public:
35
40 enum ScaleComponent
41 {
43 Backbone = 0x01,
44
46 Ticks = 0x02,
47
49 Labels = 0x04
50 };
51
53 typedef QFlags<ScaleComponent> ScaleComponents;
54
55 QwtAbstractScaleDraw();
56 virtual ~QwtAbstractScaleDraw();
57
58 void setScaleDiv( const QwtScaleDiv &s );
59 const QwtScaleDiv& scaleDiv() const;
60
61 void setTransformation( QwtScaleTransformation * );
62 const QwtScaleMap &scaleMap() const;
63 QwtScaleMap &scaleMap();
64
65 void enableComponent( ScaleComponent, bool enable = true );
66 bool hasComponent( ScaleComponent ) const;
67
68 void setTickLength( QwtScaleDiv::TickType, double length );
69 double tickLength( QwtScaleDiv::TickType ) const;
70 double maxTickLength() const;
71
72 void setSpacing( double margin );
73 double spacing() const;
74
75 void setPenWidth( int width );
76 int penWidth() const;
77
78 virtual void draw( QPainter *, const QPalette & ) const;
79
80 virtual QwtText label( double ) const;
81
91 virtual double extent( const QFont & ) const = 0;
92
93 void setMinimumExtent( double );
94 double minimumExtent() const;
95
96 protected:
106 virtual void drawTick( QPainter *painter, double value, double len ) const = 0;
107
114 virtual void drawBackbone( QPainter *painter ) const = 0;
115
124 virtual void drawLabel( QPainter *painter, double value ) const = 0;
125
126 void invalidateCache();
127 const QwtText &tickLabel( const QFont &, double value ) const;
128
129 private:
130 QwtAbstractScaleDraw( const QwtAbstractScaleDraw & );
131 QwtAbstractScaleDraw &operator=( const QwtAbstractScaleDraw & );
132
133 class PrivateData;
134 PrivateData *d_data;
135 };
136
137 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtAbstractScaleDraw::ScaleComponents )
138
139 #endif