libyui-qt  2.47.1.1
YQMultiProgressMeter.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YQMultiProgressMeter.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 
26 #ifndef YQMultiProgressMeter_h
27 #define YQMultiProgressMeter_h
28 
29 
30 #include <yui/YMultiProgressMeter.h>
31 #include <qwidget.h>
32 #include <qpainter.h>
33 //Added by qt3to4:
34 #include <qevent.h>
35 #include <qevent.h>
36 
37 
38 class QPaintEvent;
39 class QMouseEvent;
40 
41 
42 class YQMultiProgressMeter : public QWidget, public YMultiProgressMeter
43 {
44  Q_OBJECT
45 
46 public:
47 
48  /**
49  * Constructor.
50  **/
51  YQMultiProgressMeter( YWidget * parent,
52  YUIDimension dim,
53  const vector<float> & maxValues );
54  /**
55  * Destructor.
56  **/
57  virtual ~YQMultiProgressMeter();
58 
59  /**
60  * Overall thickness (in pixels) of the MultiProgressMeter.
61  **/
62  int thickness();
63 
64  /**
65  * Overall length (in pixels) of the MultiProgressMeter.
66  **/
67  int length();
68 
69  /**
70  * Returns the margin around the widget contents.
71  **/
72  int margin() const { return _margin; }
73 
74  /**
75  * Sets the margin around the widget contents.
76  * Does not trigger an update.
77  **/
78  void setMargin( int value ) { _margin = value; }
79 
80  /**
81  * Returns the spacing between segments in pixels.
82  **/
83  int spacing() const { return _spacing; }
84 
85  /**
86  * Sets the spacing between segments in pixels.
87  * Does not trigger an update.
88  **/
89  void setSpacing( int value ) { _spacing = value; }
90 
91  /**
92  * Returns the minimal length of a segment in pixels.
93  **/
94  int segmentMinLength() const { return _segmentMinLength; }
95 
96  /**
97  * Set the minimal length of a segment in pixels.
98  **/
99  void setSegmentMinLength( int val ) { _segmentMinLength = val; }
100 
101  /**
102  * Returns the thickness (base to point) of the small triangles next to the
103  * spacing between individual segments. The base length of those small
104  * triangles is double this value minus one. A value <1 indicates no
105  * such triangles will be drawn.
106  **/
107  int triThickness() const { return _triThickness; }
108 
109  /**
110  * Set the thickness (base to point) of the small triangles next to the
111  * spacing between individual segments. The base length of those small
112  * triangles is double this value minus one.
113  *
114  * Use -1 to switch off those triangles - in which case triSpacing (see
115  * below) will be set to 0.
116  *
117  * This call does not trigger a screen update.
118  **/
119  void setTriThickness( int value );
120 
121  /**
122  * Returns the spacing between the segment indicators and the small
123  * triangles next to the spacing between segments.
124  **/
125  int triSpacing() const { return _triSpacing; }
126 
127  /**
128  * Sets the spacing between the segment indicators and the small
129  * triangles next to the spacing between segments.
130  **/
131  void setTriSpacing( int value ) { _triSpacing = value; }
132 
133  /**
134  * Set enabled/disabled state.
135  *
136  * Reimplemented from YWidget.
137  **/
138  virtual void setEnabled( bool enabled );
139 
140  /**
141  * Preferred width of the widget.
142  *
143  * Reimplemented from YWidget.
144  **/
145  virtual int preferredWidth();
146 
147  /**
148  * Preferred height of the widget.
149  *
150  * Reimplemented from YWidget.
151  **/
152  virtual int preferredHeight();
153 
154  /**
155  * Set the new size of the widget.
156  *
157  * Reimplemented from YWidget.
158  **/
159  virtual void setSize( int newWidth, int newHeight );
160 
161 
162 protected:
163 
164  /**
165  * Common initialization
166  **/
167  void init();
168 
169  /**
170  * Perform a visual update on the screen.
171  * Reimplemented from YMultiProgressMeter.
172  **/
173  virtual void doUpdate();
174 
175  /**
176  * Paint the widget's contents.
177  * Reimplemented from QWidget.
178  **/
179  virtual void paintEvent ( QPaintEvent * );
180 
181  /**
182  * Draw segment number 'segment' with pixel length 'length' from pixel
183  * coordinate 'offset' on and fill it according to that segment's current
184  * value. 'painter' is set up previously to take rotating into account
185  * (horizontal / vertical).
186  **/
187  void drawSegment( int segment,
188  QPainter & painter,
189  int offset,
190  int length,
191  int thickness );
192 
193  /**
194  * Draw markers between segments (or beside that spacing).
195  **/
196  void drawMarkers( QPainter & painter, int offset, int thickness );
197 
198 
199 private:
200 
201  int _margin;
202  int _spacing;
203  int _segmentMinLength;
204  int _triThickness;
205  int _triSpacing;
206 };
207 
208 
209 #endif // YQMultiProgressMeter_h
int margin() const
Returns the margin around the widget contents.
void setSpacing(int value)
Sets the spacing between segments in pixels.
int triSpacing() const
Returns the spacing between the segment indicators and the small triangles next to the spacing betwee...
void setTriThickness(int value)
Set the thickness (base to point) of the small triangles next to the spacing between individual segme...
void setTriSpacing(int value)
Sets the spacing between the segment indicators and the small triangles next to the spacing between s...
void setMargin(int value)
Sets the margin around the widget contents.
int segmentMinLength() const
Returns the minimal length of a segment in pixels.
void init()
Common initialization.
int spacing() const
Returns the spacing between segments in pixels.
virtual int preferredHeight()
Preferred height of the widget.
YQMultiProgressMeter(YWidget *parent, YUIDimension dim, const vector< float > &maxValues)
Constructor.
virtual void setEnabled(bool enabled)
Set enabled/disabled state.
virtual void doUpdate()
Perform a visual update on the screen.
void drawSegment(int segment, QPainter &painter, int offset, int length, int thickness)
Draw segment number &#39;segment&#39; with pixel length &#39;length&#39; from pixel coordinate &#39;offset&#39; on and fill i...
virtual ~YQMultiProgressMeter()
Destructor.
void setSegmentMinLength(int val)
Set the minimal length of a segment in pixels.
int thickness()
Overall thickness (in pixels) of the MultiProgressMeter.
virtual void setSize(int newWidth, int newHeight)
Set the new size of the widget.
virtual int preferredWidth()
Preferred width of the widget.
virtual void paintEvent(QPaintEvent *)
Paint the widget&#39;s contents.
int length()
Overall length (in pixels) of the MultiProgressMeter.
void drawMarkers(QPainter &painter, int offset, int thickness)
Draw markers between segments (or beside that spacing).
int triThickness() const
Returns the thickness (base to point) of the small triangles next to the spacing between individual s...