libyui-qt
2.43.5
|
00001 /* 00002 Copyright (C) 2000-2012 Novell, Inc 00003 This library is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as 00005 published by the Free Software Foundation; either version 2.1 of the 00006 License, or (at your option) version 3.0 of the License. This library 00007 is distributed in the hope that it will be useful, but WITHOUT ANY 00008 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00009 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00010 License for more details. You should have received a copy of the GNU 00011 Lesser General Public License along with this library; if not, write 00012 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00013 Floor, Boston, MA 02110-1301 USA 00014 */ 00015 00016 00017 /*-/ 00018 00019 File: YQMultiProgressMeter.h 00020 00021 Author: Stefan Hundhammer <sh@suse.de> 00022 00023 /-*/ 00024 00025 00026 #ifndef YQMultiProgressMeter_h 00027 #define YQMultiProgressMeter_h 00028 00029 00030 #include <yui/YMultiProgressMeter.h> 00031 #include <qwidget.h> 00032 #include <qpainter.h> 00033 //Added by qt3to4: 00034 #include <qevent.h> 00035 #include <qevent.h> 00036 00037 00038 class QPaintEvent; 00039 class QMouseEvent; 00040 00041 00042 class YQMultiProgressMeter : public QWidget, public YMultiProgressMeter 00043 { 00044 Q_OBJECT 00045 00046 public: 00047 00048 /** 00049 * Constructor. 00050 **/ 00051 YQMultiProgressMeter( YWidget * parent, 00052 YUIDimension dim, 00053 const vector<float> & maxValues ); 00054 /** 00055 * Destructor. 00056 **/ 00057 virtual ~YQMultiProgressMeter(); 00058 00059 /** 00060 * Overall thickness (in pixels) of the MultiProgressMeter. 00061 **/ 00062 int thickness(); 00063 00064 /** 00065 * Overall length (in pixels) of the MultiProgressMeter. 00066 **/ 00067 int length(); 00068 00069 /** 00070 * Returns the margin around the widget contents. 00071 **/ 00072 int margin() const { return _margin; } 00073 00074 /** 00075 * Sets the margin around the widget contents. 00076 * Does not trigger an update. 00077 **/ 00078 void setMargin( int value ) { _margin = value; } 00079 00080 /** 00081 * Returns the spacing between segments in pixels. 00082 **/ 00083 int spacing() const { return _spacing; } 00084 00085 /** 00086 * Sets the spacing between segments in pixels. 00087 * Does not trigger an update. 00088 **/ 00089 void setSpacing( int value ) { _spacing = value; } 00090 00091 /** 00092 * Returns the minimal length of a segment in pixels. 00093 **/ 00094 int segmentMinLength() const { return _segmentMinLength; } 00095 00096 /** 00097 * Set the minimal length of a segment in pixels. 00098 **/ 00099 void setSegmentMinLength( int val ) { _segmentMinLength = val; } 00100 00101 /** 00102 * Returns the thickness (base to point) of the small triangles next to the 00103 * spacing between individual segments. The base length of those small 00104 * triangles is double this value minus one. A value <1 indicates no 00105 * such triangles will be drawn. 00106 **/ 00107 int triThickness() const { return _triThickness; } 00108 00109 /** 00110 * Set the thickness (base to point) of the small triangles next to the 00111 * spacing between individual segments. The base length of those small 00112 * triangles is double this value minus one. 00113 * 00114 * Use -1 to switch off those triangles - in which case triSpacing (see 00115 * below) will be set to 0. 00116 * 00117 * This call does not trigger a screen update. 00118 **/ 00119 void setTriThickness( int value ); 00120 00121 /** 00122 * Returns the spacing between the segment indicators and the small 00123 * triangles next to the spacing between segments. 00124 **/ 00125 int triSpacing() const { return _triSpacing; } 00126 00127 /** 00128 * Sets the spacing between the segment indicators and the small 00129 * triangles next to the spacing between segments. 00130 **/ 00131 void setTriSpacing( int value ) { _triSpacing = value; } 00132 00133 /** 00134 * Set enabled/disabled state. 00135 * 00136 * Reimplemented from YWidget. 00137 **/ 00138 virtual void setEnabled( bool enabled ); 00139 00140 /** 00141 * Preferred width of the widget. 00142 * 00143 * Reimplemented from YWidget. 00144 **/ 00145 virtual int preferredWidth(); 00146 00147 /** 00148 * Preferred height of the widget. 00149 * 00150 * Reimplemented from YWidget. 00151 **/ 00152 virtual int preferredHeight(); 00153 00154 /** 00155 * Set the new size of the widget. 00156 * 00157 * Reimplemented from YWidget. 00158 **/ 00159 virtual void setSize( int newWidth, int newHeight ); 00160 00161 00162 protected: 00163 00164 /** 00165 * Common initialization 00166 **/ 00167 void init(); 00168 00169 /** 00170 * Perform a visual update on the screen. 00171 * Reimplemented from YMultiProgressMeter. 00172 **/ 00173 virtual void doUpdate(); 00174 00175 /** 00176 * Paint the widget's contents. 00177 * Reimplemented from QWidget. 00178 **/ 00179 virtual void paintEvent ( QPaintEvent * ); 00180 00181 /** 00182 * Draw segment number 'segment' with pixel length 'length' from pixel 00183 * coordinate 'offset' on and fill it according to that segment's current 00184 * value. 'painter' is set up previously to take rotating into account 00185 * (horizontal / vertical). 00186 **/ 00187 void drawSegment( int segment, 00188 QPainter & painter, 00189 int offset, 00190 int length, 00191 int thickness ); 00192 00193 /** 00194 * Draw markers between segments (or beside that spacing). 00195 **/ 00196 void drawMarkers( QPainter & painter, int offset, int thickness ); 00197 00198 00199 private: 00200 00201 int _margin; 00202 int _spacing; 00203 int _segmentMinLength; 00204 int _triThickness; 00205 int _triSpacing; 00206 }; 00207 00208 00209 #endif // YQMultiProgressMeter_h