]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQMultiProgressMeter.h
moving classes where they are used
[duncan/yast2-qt4.git] / src / YQMultiProgressMeter.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQMultiProgressMeter.h
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19
20 #ifndef YQMultiProgressMeter_h
21 #define YQMultiProgressMeter_h
22
23
24 #include "YMultiProgressMeter.h"
25 #include <qwidget.h>
26 #include <qpainter.h>
27 //Added by qt3to4:
28 #include <qevent.h>
29 #include <qevent.h>
30
31
32 class QPaintEvent;
33 class QMouseEvent;
34
35
36 class YQMultiProgressMeter : public QWidget, public YMultiProgressMeter
37 {
38     Q_OBJECT
39
40 public:
41
42     /**
43      * Constructor.
44      **/
45     YQMultiProgressMeter( YWidget *             parent,
46                           YUIDimension          dim,
47                           const vector<float> & maxValues );
48     /**
49      * Destructor.
50      **/
51     virtual ~YQMultiProgressMeter();
52
53     /**
54      * Overall thickness (in pixels) of the MultiProgressMeter.
55      **/
56     int thickness();
57
58     /**
59      * Overall length (in pixels) of the MultiProgressMeter.
60      **/
61     int length();
62
63     /**
64      * Returns the margin around the widget contents.
65      **/
66     int margin() const { return _margin; }
67
68     /**
69      * Sets the margin around the widget contents.
70      * Does not trigger an update.
71      **/
72     void setMargin( int value ) { _margin = value; }
73
74     /**
75      * Returns the spacing between segments in pixels.
76      **/
77     int spacing() const { return _spacing; }
78
79     /**
80      * Sets the spacing between segments in pixels.
81      * Does not trigger an update.
82      **/
83     void setSpacing( int value ) { _spacing = value; }
84
85     /**
86      * Returns the minimal length of a segment in pixels.
87      **/
88     int segmentMinLength() const { return _segmentMinLength; }
89
90     /**
91      * Set the minimal length of a segment in pixels.
92      **/
93     void setSegmentMinLength( int val ) { _segmentMinLength = val; }
94
95     /**
96      * Returns the thickness (base to point) of the small triangles next to the
97      * spacing between individual segments. The base length of those small
98      * triangles is double this value minus one. A value <1 indicates no
99      * such triangles will be drawn.
100      **/
101     int triThickness() const { return _triThickness; }
102
103     /**
104      * Set the thickness (base to point) of the small triangles next to the
105      * spacing between individual segments. The base length of those small
106      * triangles is double this value minus one.
107      *
108      * Use -1 to switch off those triangles - in which case triSpacing (see
109      * below) will be set to 0.
110      *
111      * This call does not trigger a screen update.
112      **/
113     void setTriThickness( int value );
114
115     /**
116      * Returns the spacing between the segment indicators and the small
117      * triangles next to the spacing between segments.
118      **/
119     int triSpacing() const { return _triSpacing; }
120
121     /**
122      * Sets the spacing between the segment indicators and the small
123      * triangles next to the spacing between segments.
124      **/
125     void setTriSpacing( int value ) { _triSpacing = value; }
126
127     /**
128      * Returns "true" if the segments of this widget are triangular shaped.
129      **/
130     bool triangularShaped() const { return _triangularShaped; }
131
132     /**
133      * Set triangular shape (true) or normal rectangular shape.
134      * This call does not trigger a screen update.
135      **/
136     void setTriangularShaped( bool triangular = true );
137
138     /**
139      * Set enabled/disabled state.
140      *
141      * Reimplemented from YWidget.
142      **/
143     virtual void setEnabled( bool enabled );
144     
145     /**
146      * Preferred width of the widget.
147      *
148      * Reimplemented from YWidget.
149      **/
150     virtual int preferredWidth();
151
152     /**
153      * Preferred height of the widget.
154      *
155      * Reimplemented from YWidget.
156      **/
157     virtual int preferredHeight();
158
159     /**
160      * Set the new size of the widget.
161      *
162      * Reimplemented from YWidget.
163      **/
164     virtual void setSize( int newWidth, int newHeight );
165
166
167 protected:
168
169     /**
170      * Common initialization
171      **/
172     void init();
173
174     /**
175      * Perform a visual update on the screen.
176      * Reimplemented from YMultiProgressMeter.
177      **/
178     virtual void doUpdate();
179
180     /**
181      * Paint the widget's contents.
182      * Reimplemented from QWidget.
183      **/
184     virtual void paintEvent ( QPaintEvent * );
185
186     /**
187      * Mouse double click -
188      *
189      * reimplemented from QWidget.
190      **/
191     virtual void mouseDoubleClickEvent ( QMouseEvent * e );
192
193     /**
194      * Draw segment number 'segment' with pixel length 'length' from pixel
195      * coordinate 'offset' on and fill it according to that segment's current
196      * value. 'painter' is set up previously to take rotating into account
197      * (horizontal / vertical).
198      **/
199     void drawSegment( int segment,
200                       QPainter & painter,
201                       int offset,
202                       int length,
203                       int thickness,
204                       int indent );
205
206     /**
207      * Draw markers between segments (or beside that spacing).
208      **/
209     void drawMarkers( QPainter & painter, int offset, int thickness );
210
211
212 private:
213
214     bool        _triangularShaped;
215     int         _margin;
216     int         _spacing;
217     int         _segmentMinLength;
218     int         _triThickness;
219     int         _triSpacing;
220 };
221
222
223 #endif // YQMultiProgressMeter_h