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