source: ntrip/trunk/BNC/qwt/qwt_column_symbol.h@ 4490

Last change on this file since 4490 was 4271, checked in by mervart, 12 years ago
File size: 3.7 KB
RevLine 
[4271]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_COLUMN_SYMBOL_H
11#define QWT_COLUMN_SYMBOL_H
12
13#include "qwt_global.h"
14#include "qwt_interval.h"
15#include <qpen.h>
16#include <qsize.h>
17#include <qrect.h>
18
19class QPainter;
20class QPalette;
21class QRect;
22class QwtText;
23
24/*!
25 \brief Directed rectangle representing bounding rectangle und orientation
26 of a column.
27*/
28class QWT_EXPORT QwtColumnRect
29{
30public:
31 //! Direction of the column
32 enum Direction
33 {
34 //! From left to right
35 LeftToRight,
36
37 //! From right to left
38 RightToLeft,
39
40 //! From bottom to top
41 BottomToTop,
42
43 //! From top to bottom
44 TopToBottom
45 };
46
47 //! Build an rectangle with invalid intervals directed BottomToTop.
48 QwtColumnRect():
49 direction( BottomToTop )
50 {
51 }
52
53 //! \return A normalized QRect built from the intervals
54 QRectF toRect() const
55 {
56 QRectF r( hInterval.minValue(), vInterval.minValue(),
57 hInterval.maxValue() - hInterval.minValue(),
58 vInterval.maxValue() - vInterval.minValue() );
59 r = r.normalized();
60
61 if ( hInterval.borderFlags() & QwtInterval::ExcludeMinimum )
62 r.adjust( 1, 0, 0, 0 );
63 if ( hInterval.borderFlags() & QwtInterval::ExcludeMaximum )
64 r.adjust( 0, 0, -1, 0 );
65 if ( vInterval.borderFlags() & QwtInterval::ExcludeMinimum )
66 r.adjust( 0, 1, 0, 0 );
67 if ( vInterval.borderFlags() & QwtInterval::ExcludeMaximum )
68 r.adjust( 0, 0, 0, -1 );
69
70 return r;
71 }
72
73 //! \return Orientation
74 Qt::Orientation orientation() const
75 {
76 if ( direction == LeftToRight || direction == RightToLeft )
77 return Qt::Horizontal;
78
79 return Qt::Vertical;
80 }
81
82 //! Interval for the horizontal coordinates
83 QwtInterval hInterval;
84
85 //! Interval for the vertical coordinates
86 QwtInterval vInterval;
87
88 //! Direction
89 Direction direction;
90};
91
92//! A drawing primitive for columns
93class QWT_EXPORT QwtColumnSymbol
94{
95public:
96 /*!
97 Style
98 \sa setStyle(), style()
99 */
100 enum Style
101 {
102 //! No Style, the symbol draws nothing
103 NoStyle = -1,
104
105 /*!
106 The column is painted with a frame depending on the frameStyle()
107 and lineWidth() using the palette().
108 */
109 Box,
110
111 /*!
112 Styles >= QwtColumnSymbol::UserStyle are reserved for derived
113 classes of QwtColumnSymbol that overload draw() with
114 additional application specific symbol types.
115 */
116 UserStyle = 1000
117 };
118
119 /*!
120 Frame Style used in Box style().
121 \sa Style, setFrameStyle(), frameStyle(), setStyle(), setPalette()
122 */
123 enum FrameStyle
124 {
125 //! No frame
126 NoFrame,
127
128 //! A plain frame style
129 Plain,
130
131 //! A raised frame style
132 Raised
133 };
134
135public:
136 QwtColumnSymbol( Style = NoStyle );
137 virtual ~QwtColumnSymbol();
138
139 void setFrameStyle( FrameStyle style );
140 FrameStyle frameStyle() const;
141
142 void setLineWidth( int width );
143 int lineWidth() const;
144
145 void setPalette( const QPalette & );
146 const QPalette &palette() const;
147
148 void setStyle( Style );
149 Style style() const;
150
151 virtual void draw( QPainter *, const QwtColumnRect & ) const;
152
153protected:
154 void drawBox( QPainter *, const QwtColumnRect & ) const;
155
156private:
157 class PrivateData;
158 PrivateData* d_data;
159};
160
161#endif
Note: See TracBrowser for help on using the repository browser.