~ubuntu-branches/ubuntu/oneiric/qwt/oneiric-proposed

« back to all changes in this revision

Viewing changes to qwt-5.1.2/src/qwt_abstract_scale_draw.h

  • Committer: Bazaar Package Importer
  • Author(s): Fathi Boudra
  • Date: 2009-04-12 23:25:58 UTC
  • mfrom: (1.1.4 upstream) (2.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090412232558-3bl06x785yr8xm8u
Tags: 5.1.2-1
* New upstream release.
* Bump compat/debhelper to 7.
* Bump Standards-Version to 3.8.1. No changes needed.
* Invert Maintainers and Uploaders field.
* Fix lintian warnings:
  - dh_clean _k deprecated.
  - missing dependency on libc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
28
/*!
 
29
  \brief A abstract base class for drawing scales
 
30
 
 
31
  QwtAbstractScaleDraw can be used to draw linear or logarithmic scales.
 
32
 
 
33
  After a scale division has been specified as a QwtScaleDiv object
 
34
  using QwtAbstractScaleDraw::setScaleDiv(const QwtScaleDiv &s),
 
35
  the scale can be drawn with the QwtAbstractScaleDraw::draw() member.
 
36
*/
 
37
class QWT_EXPORT QwtAbstractScaleDraw
 
38
{
 
39
public:
 
40
 
 
41
     /*!
 
42
        Components of a scale
 
43
 
 
44
        - Backbone
 
45
        - Ticks
 
46
        - Labels
 
47
 
 
48
        \sa QwtAbstractScaleDraw::enableComponent, 
 
49
            QwtAbstractScaleDraw::hasComponent
 
50
    */
 
51
 
 
52
    enum ScaleComponent
 
53
    { 
 
54
        Backbone = 1,
 
55
        Ticks = 2,
 
56
        Labels = 4
 
57
    };
 
58
 
 
59
    QwtAbstractScaleDraw();
 
60
    QwtAbstractScaleDraw( const QwtAbstractScaleDraw & );
 
61
    virtual ~QwtAbstractScaleDraw();
 
62
 
 
63
    QwtAbstractScaleDraw &operator=(const QwtAbstractScaleDraw &);
 
64
    
 
65
    void setScaleDiv(const QwtScaleDiv &s);
 
66
    const QwtScaleDiv& scaleDiv() const;
 
67
 
 
68
    void setTransformation(QwtScaleTransformation *);
 
69
    const QwtScaleMap &map() const;
 
70
 
 
71
    void enableComponent(ScaleComponent, bool enable = true);
 
72
    bool hasComponent(ScaleComponent) const;
 
73
 
 
74
    void setTickLength(QwtScaleDiv::TickType, int length);
 
75
    int tickLength(QwtScaleDiv::TickType) const;
 
76
    int majTickLength() const;
 
77
 
 
78
    void setSpacing(int margin);
 
79
    int spacing() const;
 
80
        
 
81
#if QT_VERSION < 0x040000
 
82
    virtual void draw(QPainter *, const QColorGroup &) const;
 
83
#else
 
84
    virtual void draw(QPainter *, const QPalette &) const;
 
85
#endif
 
86
 
 
87
    virtual QwtText label(double) const;
 
88
 
 
89
    /*!  
 
90
      Calculate the extent 
 
91
 
 
92
      The extent is the distcance from the baseline to the outermost
 
93
      pixel of the scale draw in opposite to its orientation.
 
94
      It is at least minimumExtent() pixels.
 
95
 
 
96
      \sa setMinimumExtent(), minimumExtent()
 
97
    */
 
98
    virtual int extent(const QPen &, const QFont &) const = 0;
 
99
 
 
100
    void setMinimumExtent(int);
 
101
    int minimumExtent() const;
 
102
 
 
103
    QwtScaleMap &scaleMap();
 
104
 
 
105
protected:
 
106
    /*!
 
107
       Draw a tick
 
108
  
 
109
       \param painter Painter
 
110
       \param value Value of the tick
 
111
       \param len Lenght of the tick
 
112
 
 
113
       \sa drawBackbone(), drawLabel()
 
114
    */  
 
115
    virtual void drawTick(QPainter *painter, double value, int len) const = 0;
 
116
 
 
117
    /*!
 
118
      Draws the baseline of the scale
 
119
      \param painter Painter
 
120
 
 
121
      \sa drawTick(), drawLabel()
 
122
    */
 
123
    virtual void drawBackbone(QPainter *painter) const = 0;
 
124
 
 
125
    /*!  
 
126
        Draws the label for a major scale tick
 
127
    
 
128
        \param painter Painter
 
129
        \param value Value
 
130
 
 
131
        \sa drawTick, drawBackbone
 
132
    */ 
 
133
    virtual void drawLabel(QPainter *painter, double value) const = 0;
 
134
 
 
135
    void invalidateCache();
 
136
    const QwtText &tickLabel(const QFont &, double value) const;
 
137
 
 
138
private:
 
139
    int operator==(const QwtAbstractScaleDraw &) const;
 
140
    int operator!=(const QwtAbstractScaleDraw &) const;
 
141
 
 
142
    class PrivateData;
 
143
    PrivateData *d_data;
 
144
};
 
145
 
 
146
#endif