1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
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 *****************************************************************************/
10 #ifndef QWT_SCALE_WIDGET_H
11 #define QWT_SCALE_WIDGET_H
13 #include "qwt_global.h"
15 #include "qwt_scale_draw.h"
27 \brief A Widget which contains a scale
29 This Widget can be used to decorate composite widgets with
33 class QWT_EXPORT QwtScaleWidget
: public QWidget
38 //! Layout flags of the title
42 The title of vertical scales is painted from top to bottom.
43 Otherwise it is painted from bottom to top.
48 //! Layout flags of the title
49 typedef QFlags
<LayoutFlag
> LayoutFlags
;
51 explicit QwtScaleWidget( QWidget
*parent
= NULL
);
52 explicit QwtScaleWidget( QwtScaleDraw::Alignment
, QWidget
*parent
= NULL
);
53 virtual ~QwtScaleWidget();
56 //! Signal emitted, whenever the scale division changes
57 void scaleDivChanged();
60 void setTitle( const QString
&title
);
61 void setTitle( const QwtText
&title
);
62 QwtText
title() const;
64 void setLayoutFlag( LayoutFlag
, bool on
);
65 bool testLayoutFlag( LayoutFlag
) const;
67 void setBorderDist( int start
, int end
);
68 int startBorderDist() const;
69 int endBorderDist() const;
71 void getBorderDistHint( int &start
, int &end
) const;
73 void getMinBorderDist( int &start
, int &end
) const;
74 void setMinBorderDist( int start
, int end
);
76 void setMargin( int );
79 void setSpacing( int td
);
82 void setScaleDiv( const QwtScaleDiv
&sd
);
83 void setTransformation( QwtTransform
* );
85 void setScaleDraw( QwtScaleDraw
* );
86 const QwtScaleDraw
*scaleDraw() const;
87 QwtScaleDraw
*scaleDraw();
89 void setLabelAlignment( Qt::Alignment
);
90 void setLabelRotation( double rotation
);
92 void setColorBarEnabled( bool );
93 bool isColorBarEnabled() const;
95 void setColorBarWidth( int );
96 int colorBarWidth() const;
98 void setColorMap( const QwtInterval
&, QwtColorMap
* );
100 QwtInterval
colorBarInterval() const;
101 const QwtColorMap
*colorMap() const;
103 virtual QSize
sizeHint() const;
104 virtual QSize
minimumSizeHint() const;
106 int titleHeightForWidth( int width
) const;
107 int dimForLength( int length
, const QFont
&scaleFont
) const;
109 void drawColorBar( QPainter
*painter
, const QRectF
& ) const;
110 void drawTitle( QPainter
*painter
, QwtScaleDraw::Alignment
,
111 const QRectF
&rect
) const;
113 void setAlignment( QwtScaleDraw::Alignment
);
114 QwtScaleDraw::Alignment
alignment() const;
116 QRectF
colorBarRect( const QRectF
& ) const;
119 virtual void paintEvent( QPaintEvent
* );
120 virtual void resizeEvent( QResizeEvent
* );
122 void draw( QPainter
*p
) const;
125 void layoutScale( bool update
= true );
128 void initScale( QwtScaleDraw::Alignment
);
134 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtScaleWidget::LayoutFlags
)