source: ntrip/branches/BNC_2.12/qwt/qwt_scale_widget.h@ 10588

Last change on this file since 10588 was 4271, checked in by mervart, 12 years ago
File size: 3.4 KB
Line 
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_WIDGET_H
11#define QWT_SCALE_WIDGET_H
12
13#include "qwt_global.h"
14#include "qwt_text.h"
15#include "qwt_scale_draw.h"
16#include <qwidget.h>
17#include <qfont.h>
18#include <qcolor.h>
19#include <qstring.h>
20
21class QPainter;
22class QwtScaleTransformation;
23class QwtScaleDiv;
24class QwtColorMap;
25
26/*!
27 \brief A Widget which contains a scale
28
29 This Widget can be used to decorate composite widgets with
30 a scale.
31*/
32
33class QWT_EXPORT QwtScaleWidget : public QWidget
34{
35 Q_OBJECT
36
37public:
38 //! Layout flags of the title
39 enum LayoutFlag
40 {
41 /*!
42 The title of vertical scales is painted from top to bottom.
43 Otherwise it is painted from bottom to top.
44 */
45 TitleInverted = 1
46 };
47
48 //! Layout flags of the title
49 typedef QFlags<LayoutFlag> LayoutFlags;
50
51 explicit QwtScaleWidget( QWidget *parent = NULL );
52 explicit QwtScaleWidget( QwtScaleDraw::Alignment, QWidget *parent = NULL );
53 virtual ~QwtScaleWidget();
54
55Q_SIGNALS:
56 //! Signal emitted, whenever the scale divison changes
57 void scaleDivChanged();
58
59public:
60 void setTitle( const QString &title );
61 void setTitle( const QwtText &title );
62 QwtText title() const;
63
64 void setLayoutFlag( LayoutFlag, bool on );
65 bool testLayoutFlag( LayoutFlag ) const;
66
67 void setBorderDist( int start, int end );
68 int startBorderDist() const;
69 int endBorderDist() const;
70
71 void getBorderDistHint( int &start, int &end ) const;
72
73 void getMinBorderDist( int &start, int &end ) const;
74 void setMinBorderDist( int start, int end );
75
76 void setMargin( int );
77 int margin() const;
78
79 void setSpacing( int td );
80 int spacing() const;
81
82 void setScaleDiv( QwtScaleTransformation *, const QwtScaleDiv &sd );
83
84 void setScaleDraw( QwtScaleDraw * );
85 const QwtScaleDraw *scaleDraw() const;
86 QwtScaleDraw *scaleDraw();
87
88 void setLabelAlignment( Qt::Alignment );
89 void setLabelRotation( double rotation );
90
91 void setColorBarEnabled( bool );
92 bool isColorBarEnabled() const;
93
94 void setColorBarWidth( int );
95 int colorBarWidth() const;
96
97 void setColorMap( const QwtInterval &, QwtColorMap * );
98
99 QwtInterval colorBarInterval() const;
100 const QwtColorMap *colorMap() const;
101
102 virtual QSize sizeHint() const;
103 virtual QSize minimumSizeHint() const;
104
105 int titleHeightForWidth( int width ) const;
106 int dimForLength( int length, const QFont &scaleFont ) const;
107
108 void drawColorBar( QPainter *painter, const QRectF & ) const;
109 void drawTitle( QPainter *painter, QwtScaleDraw::Alignment,
110 const QRectF &rect ) const;
111
112 void setAlignment( QwtScaleDraw::Alignment );
113 QwtScaleDraw::Alignment alignment() const;
114
115 QRectF colorBarRect( const QRectF& ) const;
116
117protected:
118 virtual void paintEvent( QPaintEvent * );
119 virtual void resizeEvent( QResizeEvent * );
120
121 void draw( QPainter *p ) const;
122
123 void scaleChange();
124 void layoutScale( bool update = true );
125
126private:
127 void initScale( QwtScaleDraw::Alignment );
128
129 class PrivateData;
130 PrivateData *d_data;
131};
132
133Q_DECLARE_OPERATORS_FOR_FLAGS( QwtScaleWidget::LayoutFlags )
134
135#endif
Note: See TracBrowser for help on using the repository browser.