-rw-r--r-- | core/settings/light-and-power/calibration.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/core/settings/light-and-power/calibration.cpp b/core/settings/light-and-power/calibration.cpp index aed2bc8..c5377d0 100644 --- a/core/settings/light-and-power/calibration.cpp +++ b/core/settings/light-and-power/calibration.cpp | |||
@@ -1,346 +1,346 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org> | 3 | =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org> |
4 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 4 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | #include "calibration.h" | 28 | #include "calibration.h" |
29 | 29 | ||
30 | #include <qpainter.h> | 30 | #include <qpainter.h> |
31 | #include <qpalette.h> | 31 | #include <qpalette.h> |
32 | #include <qpixmap.h> | 32 | #include <qpixmap.h> |
33 | 33 | ||
34 | #define BRD 3 | 34 | #define BRD 3 |
35 | 35 | ||
36 | Calibration::Calibration ( QWidget *parent, const char *name, WFlags fl ) | 36 | Calibration::Calibration ( QWidget *parent, const char *name, WFlags fl ) |
37 | : QWidget ( parent, name, fl | WRepaintNoErase ) | 37 | : QWidget ( parent, name, fl | WRepaintNoErase ) |
38 | { | 38 | { |
39 | setBackgroundMode ( NoBackground ); | 39 | setBackgroundMode ( NoBackground ); |
40 | 40 | ||
41 | m_scale = QSize ( 256, 256 ); | 41 | m_scale = QSize ( 256, 256 ); |
42 | m_steps = 5; | 42 | m_steps = 5; |
43 | m_dragged = -1; | 43 | m_dragged = -1; |
44 | m_interval = 5; | 44 | m_interval = 5; |
45 | 45 | ||
46 | m_p [0] = QPoint ( 0, 0 ); | 46 | m_p [0] = QPoint ( 0, 0 ); |
47 | m_p [1] = QPoint ( 255, 255 ); | 47 | m_p [1] = QPoint ( 255, 255 ); |
48 | } | 48 | } |
49 | 49 | ||
50 | Calibration::~Calibration ( ) | 50 | Calibration::~Calibration ( ) |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | void Calibration::setScale ( const QSize &s ) | 54 | void Calibration::setScale ( const QSize &s ) |
55 | { | 55 | { |
56 | if ( s. width ( ) < 1 || s. height ( ) < 1 ) | 56 | if ( s. width ( ) < 1 || s. height ( ) < 1 ) |
57 | return; | 57 | return; |
58 | 58 | ||
59 | m_scale = s; | 59 | m_scale = s; |
60 | checkPoints ( ); | 60 | checkPoints ( ); |
61 | 61 | ||
62 | update ( ); | 62 | update ( ); |
63 | } | 63 | } |
64 | 64 | ||
65 | QSize Calibration::scale ( ) const | 65 | QSize Calibration::scale ( ) const |
66 | { | 66 | { |
67 | return m_scale; | 67 | return m_scale; |
68 | } | 68 | } |
69 | 69 | ||
70 | void Calibration::setLineSteps ( int steps ) | 70 | void Calibration::setLineSteps ( int steps ) |
71 | { | 71 | { |
72 | if ( m_steps < 2 ) | 72 | if ( m_steps < 2 ) |
73 | return; | 73 | return; |
74 | 74 | ||
75 | m_steps = steps; | 75 | m_steps = steps; |
76 | update ( ); | 76 | update ( ); |
77 | } | 77 | } |
78 | 78 | ||
79 | int Calibration::lineSteps ( ) const | 79 | int Calibration::lineSteps ( ) const |
80 | { | 80 | { |
81 | return m_steps; | 81 | return m_steps; |
82 | } | 82 | } |
83 | 83 | ||
84 | void Calibration::setInterval ( int iv ) | 84 | void Calibration::setInterval ( int iv ) |
85 | { | 85 | { |
86 | if ( iv < 1 ) | 86 | if ( iv < 1 ) |
87 | return; | 87 | return; |
88 | 88 | ||
89 | m_interval = iv; | 89 | m_interval = iv; |
90 | //update ( ); | 90 | //update ( ); |
91 | } | 91 | } |
92 | 92 | ||
93 | int Calibration::interval ( ) const | 93 | int Calibration::interval ( ) const |
94 | { | 94 | { |
95 | return m_interval; | 95 | return m_interval; |
96 | } | 96 | } |
97 | 97 | ||
98 | void Calibration::setStartPoint ( const QPoint &p ) | 98 | void Calibration::setStartPoint ( const QPoint &p ) |
99 | { | 99 | { |
100 | m_p [0] = QPoint ( p. x ( ), m_scale. height ( ) - p. y ( ) - 1 ); | 100 | m_p [0] = QPoint ( p. x ( ), m_scale. height ( ) - p. y ( ) - 1 ); |
101 | checkPoints ( ); | 101 | checkPoints ( ); |
102 | update ( ); | 102 | update ( ); |
103 | } | 103 | } |
104 | 104 | ||
105 | QPoint Calibration::startPoint ( ) const | 105 | QPoint Calibration::startPoint ( ) const |
106 | { | 106 | { |
107 | return QPoint ( m_p [0]. x ( ), m_scale. height ( ) - m_p [0]. y ( ) - 1 ); | 107 | return QPoint ( m_p [0]. x ( ), m_scale. height ( ) - m_p [0]. y ( ) - 1 ); |
108 | } | 108 | } |
109 | 109 | ||
110 | void Calibration::setEndPoint ( const QPoint &p ) | 110 | void Calibration::setEndPoint ( const QPoint &p ) |
111 | { | 111 | { |
112 | m_p [1] = QPoint ( p. x ( ), m_scale. height ( ) - p. y ( ) - 1 ); | 112 | m_p [1] = QPoint ( p. x ( ), m_scale. height ( ) - p. y ( ) - 1 ); |
113 | checkPoints ( ); | 113 | checkPoints ( ); |
114 | update ( ); | 114 | update ( ); |
115 | } | 115 | } |
116 | 116 | ||
117 | QPoint Calibration::endPoint ( ) const | 117 | QPoint Calibration::endPoint ( ) const |
118 | { | 118 | { |
119 | return QPoint ( m_p [1]. x ( ), m_scale. height ( ) - m_p [1]. y ( ) - 1 ); | 119 | return QPoint ( m_p [1]. x ( ), m_scale. height ( ) - m_p [1]. y ( ) - 1 ); |
120 | } | 120 | } |
121 | 121 | ||
122 | void Calibration::checkPoints ( ) | 122 | void Calibration::checkPoints ( ) |
123 | { | 123 | { |
124 | int dx = m_scale. width ( ); | 124 | int dx = m_scale. width ( ); |
125 | int dy = m_scale. height ( ); | 125 | int dy = m_scale. height ( ); |
126 | 126 | ||
127 | if ( m_p [1]. x ( ) < 0 ) | 127 | if ( m_p [1]. x ( ) < 0 ) |
128 | m_p [1]. setX ( 0 ); | 128 | m_p [1]. setX ( 0 ); |
129 | if ( m_p [1]. x ( ) >= dx ) | 129 | if ( m_p [1]. x ( ) >= dx ) |
130 | m_p [1]. setX ( dx - 1 ); | 130 | m_p [1]. setX ( dx - 1 ); |
131 | if ( m_p [0]. x ( ) < 0 ) | 131 | if ( m_p [0]. x ( ) < 0 ) |
132 | m_p [0]. setX ( 0 ); | 132 | m_p [0]. setX ( 0 ); |
133 | if ( m_p [0]. x ( ) > m_p [1]. x ( )) | 133 | if ( m_p [0]. x ( ) > m_p [1]. x ( )) |
134 | m_p [0]. setX ( m_p [1]. x ( )); | 134 | m_p [0]. setX ( m_p [1]. x ( )); |
135 | 135 | ||
136 | if ( m_p [1]. y ( ) < 0 ) | 136 | if ( m_p [1]. y ( ) < 0 ) |
137 | m_p [1]. setY ( 0 ); | 137 | m_p [1]. setY ( 0 ); |
138 | if ( m_p [1]. y ( ) >= dy ) | 138 | if ( m_p [1]. y ( ) >= dy ) |
139 | m_p [1]. setY ( dy - 1 ); | 139 | m_p [1]. setY ( dy - 1 ); |
140 | if ( m_p [0]. y ( ) < 0 ) | 140 | if ( m_p [0]. y ( ) < 0 ) |
141 | m_p [0]. setY ( 0 ); | 141 | m_p [0]. setY ( 0 ); |
142 | if ( m_p [0]. y ( ) > m_p [1]. y ( )) | 142 | if ( m_p [0]. y ( ) >= dy ) |
143 | m_p [0]. setY ( m_p [1]. y ( )); | 143 | m_p [0]. setY ( dy - 1 ); |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | #define SCALEX(x) (BRD+(x)*(width()- 2*BRD)/m_scale.width()) | 147 | #define SCALEX(x) (BRD+(x)*(width()- 2*BRD)/m_scale.width()) |
148 | #define SCALEY(y) (BRD+(y)*(height()-2*BRD)/m_scale.height()) | 148 | #define SCALEY(y) (BRD+(y)*(height()-2*BRD)/m_scale.height()) |
149 | 149 | ||
150 | 150 | ||
151 | static QRect around ( int x, int y ) | 151 | static QRect around ( int x, int y ) |
152 | { | 152 | { |
153 | return QRect ( x - BRD, y - BRD, 2 * BRD + 1, 2 * BRD + 1 ); | 153 | return QRect ( x - BRD, y - BRD, 2 * BRD + 1, 2 * BRD + 1 ); |
154 | } | 154 | } |
155 | 155 | ||
156 | void Calibration::mousePressEvent ( QMouseEvent *e ) | 156 | void Calibration::mousePressEvent ( QMouseEvent *e ) |
157 | { | 157 | { |
158 | if ( e-> button ( ) != LeftButton ) | 158 | if ( e-> button ( ) != LeftButton ) |
159 | return QWidget::mousePressEvent ( e ); | 159 | return QWidget::mousePressEvent ( e ); |
160 | 160 | ||
161 | int olddragged = m_dragged; | 161 | int olddragged = m_dragged; |
162 | int x [2], y [2]; | 162 | int x [2], y [2]; |
163 | 163 | ||
164 | m_dragged = -1; | 164 | m_dragged = -1; |
165 | for ( int i = 0; i < 2; i++ ) { | 165 | for ( int i = 0; i < 2; i++ ) { |
166 | x [i] = SCALEX( m_p [i]. x ( )); | 166 | x [i] = SCALEX( m_p [i]. x ( )); |
167 | y [i] = SCALEY( m_p [i]. y ( )); | 167 | y [i] = SCALEY( m_p [i]. y ( )); |
168 | 168 | ||
169 | if (( QABS( e-> x ( ) - x [i] ) <= 2 * BRD ) && | 169 | if (( QABS( e-> x ( ) - x [i] ) <= 2 * BRD ) && |
170 | ( QABS( e-> y ( ) - y [i] ) <= 2 * BRD )) { | 170 | ( QABS( e-> y ( ) - y [i] ) <= 2 * BRD )) { |
171 | m_dragged = i; | 171 | m_dragged = i; |
172 | break; | 172 | break; |
173 | } | 173 | } |
174 | } | 174 | } |
175 | 175 | ||
176 | if ( m_dragged != olddragged ) { | 176 | if ( m_dragged != olddragged ) { |
177 | QRect r; | 177 | QRect r; |
178 | 178 | ||
179 | if ( olddragged >= 0 ) | 179 | if ( olddragged >= 0 ) |
180 | r |= around ( x [olddragged], y [olddragged] ); | 180 | r |= around ( x [olddragged], y [olddragged] ); |
181 | if ( m_dragged >= 0 ) | 181 | if ( m_dragged >= 0 ) |
182 | r |= around ( x [m_dragged], y [m_dragged] ); | 182 | r |= around ( x [m_dragged], y [m_dragged] ); |
183 | repaint ( r, false ); | 183 | repaint ( r, false ); |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | void Calibration::mouseMoveEvent ( QMouseEvent *e ) | 187 | void Calibration::mouseMoveEvent ( QMouseEvent *e ) |
188 | { | 188 | { |
189 | if ( m_dragged < 0 ) | 189 | if ( m_dragged < 0 ) |
190 | return; | 190 | return; |
191 | 191 | ||
192 | QPoint n [2]; | 192 | QPoint n [2]; |
193 | 193 | ||
194 | n [m_dragged]. setX (( e-> x ( ) - BRD ) * m_scale. width ( ) / ( width ( ) - 2 * BRD )); | 194 | n [m_dragged]. setX (( e-> x ( ) - BRD ) * m_scale. width ( ) / ( width ( ) - 2 * BRD )); |
195 | n [m_dragged]. setY (( e-> y ( ) - BRD ) * m_scale. height ( ) / ( height ( ) - 2 * BRD )); | 195 | n [m_dragged]. setY (( e-> y ( ) - BRD ) * m_scale. height ( ) / ( height ( ) - 2 * BRD )); |
196 | n [1 - m_dragged] = m_p [1 - m_dragged]; | 196 | n [1 - m_dragged] = m_p [1 - m_dragged]; |
197 | 197 | ||
198 | if ( n [m_dragged]. x ( ) < 0 ) | 198 | if ( n [m_dragged]. x ( ) < 0 ) |
199 | n [m_dragged]. setX ( 0 ); | 199 | n [m_dragged]. setX ( 0 ); |
200 | if ( n [m_dragged]. x ( ) >= m_scale. width ( )) | 200 | if ( n [m_dragged]. x ( ) >= m_scale. width ( )) |
201 | n [m_dragged]. setX ( m_scale. width ( ) - 1 ); | 201 | n [m_dragged]. setX ( m_scale. width ( ) - 1 ); |
202 | if ( n [0]. x ( ) > n [1]. x ( )) | 202 | if ( n [0]. x ( ) > n [1]. x ( )) |
203 | n [m_dragged]. setX ( n [1 - m_dragged]. x ( )); | 203 | n [m_dragged]. setX ( n [1 - m_dragged]. x ( )); |
204 | if ( n [m_dragged]. y ( ) < 0 ) | 204 | if ( n [m_dragged]. y ( ) < 0 ) |
205 | n [m_dragged]. setY ( 0 ); | 205 | n [m_dragged]. setY ( 0 ); |
206 | if ( n [m_dragged]. y ( ) >= m_scale. height ( )) | 206 | if ( n [m_dragged]. y ( ) >= m_scale. height ( )) |
207 | n [m_dragged]. setY ( m_scale. height ( ) - 1 ); | 207 | n [m_dragged]. setY ( m_scale. height ( ) - 1 ); |
208 | if ( n [0]. y ( ) > n [1]. y ( )) | 208 | //if ( n [0]. y ( ) > n [1]. y ( )) |
209 | n [m_dragged]. setY ( n [1 - m_dragged]. y ( )); | 209 | // n [m_dragged]. setY ( n [1 - m_dragged]. y ( )); |
210 | 210 | ||
211 | QRect r; | 211 | QRect r; |
212 | int ox [2], oy [2], nx [2], ny [2]; | 212 | int ox [2], oy [2], nx [2], ny [2]; |
213 | 213 | ||
214 | for ( int i = 0; i < 2; i++ ) { | 214 | for ( int i = 0; i < 2; i++ ) { |
215 | nx [i] = SCALEX( n [i]. x ( )); | 215 | nx [i] = SCALEX( n [i]. x ( )); |
216 | ny [i] = SCALEY( n [i]. y ( )); | 216 | ny [i] = SCALEY( n [i]. y ( )); |
217 | ox [i] = SCALEX( m_p [i]. x ( )); | 217 | ox [i] = SCALEX( m_p [i]. x ( )); |
218 | oy [i] = SCALEY( m_p [i]. y ( )); | 218 | oy [i] = SCALEY( m_p [i]. y ( )); |
219 | 219 | ||
220 | if ( n [i] != m_p [i] ){ | 220 | if ( n [i] != m_p [i] ){ |
221 | r |= around ( nx [i], ny [i] ); | 221 | r |= around ( nx [i], ny [i] ); |
222 | r |= around ( ox [i], oy [i] ); | 222 | r |= around ( ox [i], oy [i] ); |
223 | m_p [i] = n [i]; | 223 | m_p [i] = n [i]; |
224 | 224 | ||
225 | if ( i == 0 ) { | 225 | if ( i == 0 ) { |
226 | r |= QRect ( 0, ny [0], nx [0] - 0 + 1, 1 ); | 226 | r |= QRect ( 0, ny [0], nx [0] - 0 + 1, 1 ); |
227 | r |= QRect ( 0, oy [0], ox [0] - 0 + 1, 1 ); | 227 | r |= QRect ( 0, oy [0], ox [0] - 0 + 1, 1 ); |
228 | 228 | ||
229 | emit startPointChanged ( startPoint ( )); | 229 | emit startPointChanged ( startPoint ( )); |
230 | } | 230 | } |
231 | else if ( i == 1 ) { | 231 | else if ( i == 1 ) { |
232 | r |= QRect ( nx [1], ny [1], width ( ) - nx [1], 1 ); | 232 | r |= QRect ( nx [1], ny [1], width ( ) - nx [1], 1 ); |
233 | r |= QRect ( ox [1], oy [1], width ( ) - ox [1], 1 ); | 233 | r |= QRect ( ox [1], oy [1], width ( ) - ox [1], 1 ); |
234 | 234 | ||
235 | emit endPointChanged ( endPoint ( )); | 235 | emit endPointChanged ( endPoint ( )); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | } | 238 | } |
239 | if ( r. isValid ( )) { | 239 | if ( r. isValid ( )) { |
240 | r |= QRect ( nx [0], ny [0], nx [1] - nx [0] + 1, ny [1] - ny [0] + 1 ); | 240 | r |= QRect ( nx [0], ny [0], nx [1] - nx [0] + 1, ny [1] - ny [0] + 1 ). normalize ( ); |
241 | r |= QRect ( ox [0], oy [0], ox [1] - ox [0] + 1, oy [1] - oy [0] + 1 ); | 241 | r |= QRect ( ox [0], oy [0], ox [1] - ox [0] + 1, oy [1] - oy [0] + 1 ). normalize ( ); |
242 | 242 | ||
243 | repaint ( r, false ); | 243 | repaint ( r, false ); |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | void Calibration::mouseReleaseEvent ( QMouseEvent *e ) | 247 | void Calibration::mouseReleaseEvent ( QMouseEvent *e ) |
248 | { | 248 | { |
249 | if ( e-> button ( ) != LeftButton ) | 249 | if ( e-> button ( ) != LeftButton ) |
250 | return QWidget::mouseReleaseEvent ( e ); | 250 | return QWidget::mouseReleaseEvent ( e ); |
251 | 251 | ||
252 | if ( m_dragged < 0 ) | 252 | if ( m_dragged < 0 ) |
253 | return; | 253 | return; |
254 | 254 | ||
255 | int x = SCALEX( m_p [m_dragged]. x ( )); | 255 | int x = SCALEX( m_p [m_dragged]. x ( )); |
256 | int y = SCALEY( m_p [m_dragged]. y ( )); | 256 | int y = SCALEY( m_p [m_dragged]. y ( )); |
257 | m_dragged = -1; | 257 | m_dragged = -1; |
258 | 258 | ||
259 | repaint ( around ( x, y ), false ); | 259 | repaint ( around ( x, y ), false ); |
260 | } | 260 | } |
261 | 261 | ||
262 | void Calibration::paintEvent ( QPaintEvent *pe ) | 262 | void Calibration::paintEvent ( QPaintEvent *pe ) |
263 | { | 263 | { |
264 | QPixmap pix ( size ( )); | 264 | QPixmap pix ( size ( )); |
265 | QPainter p ( &pix, this ); | 265 | QPainter p ( &pix, this ); |
266 | QRect cr = pe-> rect ( ); | 266 | QRect cr = pe-> rect ( ); |
267 | 267 | ||
268 | int x0 = SCALEX( m_p [0]. x ( )); | 268 | int x0 = SCALEX( m_p [0]. x ( )); |
269 | int y0 = SCALEY( m_p [0]. y ( )); | 269 | int y0 = SCALEY( m_p [0]. y ( )); |
270 | int x1 = SCALEX( m_p [1]. x ( )); | 270 | int x1 = SCALEX( m_p [1]. x ( )); |
271 | int y1 = SCALEY( m_p [1]. y ( )); | 271 | int y1 = SCALEY( m_p [1]. y ( )); |
272 | 272 | ||
273 | int dx = x1 - x0; | 273 | int dx = x1 - x0; |
274 | int dy = y1 - y0; | 274 | int dy = y1 - y0; |
275 | 275 | ||
276 | // restrict steps to real x and y resolution | 276 | // restrict steps to real x and y resolution |
277 | int st = QMIN( QMIN( m_steps, ( dx + 1 )), ( dy + 1 )); | 277 | int st = QMIN( QMIN( m_steps, ( dx + 1 )), ( QABS( dy ) + 1 )); |
278 | 278 | ||
279 | QString stepstr = tr( "%1 Steps" ). arg ( st ); | 279 | QString stepstr = tr( "%1 Steps" ). arg ( st ); |
280 | QRect tr = p. boundingRect ( BRD, BRD, width ( ) - 2*BRD, height() - 2*BRD, AlignTop | AlignRight, stepstr ); | 280 | QRect tr = p. boundingRect ( BRD, BRD, width ( ) - 2*BRD, height() - 2*BRD, AlignTop | AlignRight, stepstr ); |
281 | tr. setLeft ( tr. left ( ) - 20 ); | 281 | tr. setLeft ( tr. left ( ) - 20 ); |
282 | if ( p. hasClipping ( )) | 282 | if ( p. hasClipping ( )) |
283 | p. setClipRegion ( p. clipRegion ( ) | QRegion ( tr )); | 283 | p. setClipRegion ( p. clipRegion ( ) | QRegion ( tr )); |
284 | 284 | ||
285 | QColorGroup g = colorGroup ( ); | 285 | QColorGroup g = colorGroup ( ); |
286 | 286 | ||
287 | p. fillRect ( cr, g. base ( )); | 287 | p. fillRect ( cr, g. base ( )); |
288 | p. fillRect ( tr, g. base ( )); | 288 | p. fillRect ( tr, g. base ( )); |
289 | 289 | ||
290 | int ex = x0, ey = y0; | 290 | int ex = x0, ey = y0; |
291 | 291 | ||
292 | p. setPen ( g. mid ( )); | 292 | p. setPen ( g. mid ( )); |
293 | 293 | ||
294 | int gx0 = SCALEX( 0 ); | 294 | int gx0 = SCALEX( 0 ); |
295 | int gy0 = SCALEY( 0 ); | 295 | int gy0 = SCALEY( 0 ); |
296 | int gx1 = SCALEX( m_scale. width ( ) - 1 ); | 296 | int gx1 = SCALEX( m_scale. width ( ) - 1 ); |
297 | int gy1 = SCALEY( m_scale. height ( ) - 1 ); | 297 | int gy1 = SCALEY( m_scale. height ( ) - 1 ); |
298 | 298 | ||
299 | int xdiv = QMIN( 4, m_scale. width ( )); | 299 | int xdiv = QMIN( 4, m_scale. width ( )); |
300 | int ydiv = QMIN( 4, m_scale. height ( )); | 300 | int ydiv = QMIN( 4, m_scale. height ( )); |
301 | 301 | ||
302 | xdiv = ( gx1 - gx0 + 1 ) / xdiv; | 302 | xdiv = ( gx1 - gx0 + 1 ) / xdiv; |
303 | ydiv = ( gy1 - gy0 + 1 ) / ydiv; | 303 | ydiv = ( gy1 - gy0 + 1 ) / ydiv; |
304 | 304 | ||
305 | for ( int i = gx0 + xdiv; i <= ( gx1 - xdiv ); i += xdiv ) | 305 | for ( int i = gx0 + xdiv; i <= ( gx1 - xdiv ); i += xdiv ) |
306 | p. drawLine ( i, gy0, i, gy1 ); | 306 | p. drawLine ( i, gy0, i, gy1 ); |
307 | 307 | ||
308 | for ( int i = gy0 + ydiv; i <= ( gy1 - ydiv ); i += ydiv ) | 308 | for ( int i = gy0 + ydiv; i <= ( gy1 - ydiv ); i += ydiv ) |
309 | p. drawLine ( gx0, i, gx1, i ); | 309 | p. drawLine ( gx0, i, gx1, i ); |
310 | 310 | ||
311 | p. setPen ( g. highlight ( )); | 311 | p. setPen ( g. highlight ( )); |
312 | 312 | ||
313 | p. drawLine ( BRD, ey, ex, ey ); | 313 | p. drawLine ( BRD, ey, ex, ey ); |
314 | 314 | ||
315 | for ( int i = 1; i < st; i++ ) { | 315 | for ( int i = 1; i < st; i++ ) { |
316 | int fx = x0 + dx * i / st; | 316 | int fx = x0 + dx * i / st; |
317 | int fy = y0 + dy * i / ( st - 1 ); | 317 | int fy = y0 + dy * i / ( st - 1 ); |
318 | 318 | ||
319 | p. drawLine ( ex, ey, fx, ey ); | 319 | p. drawLine ( ex, ey, fx, ey ); |
320 | p. drawLine ( fx, ey, fx, fy ); | 320 | p. drawLine ( fx, ey, fx, fy ); |
321 | 321 | ||
322 | ex = fx; | 322 | ex = fx; |
323 | ey = fy; | 323 | ey = fy; |
324 | } | 324 | } |
325 | if ( st == 1 ) { | 325 | if ( st == 1 ) { |
326 | p. drawLine ( ex, ey, ex, y1 ); | 326 | p. drawLine ( ex, ey, ex, y1 ); |
327 | ey = y1; | 327 | ey = y1; |
328 | } | 328 | } |
329 | 329 | ||
330 | p. drawLine ( ex, ey, width ( ) - 1 - BRD, ey ); | 330 | p. drawLine ( ex, ey, width ( ) - 1 - BRD, ey ); |
331 | 331 | ||
332 | 332 | ||
333 | p. fillRect ( around ( x0, y0 ), m_dragged == 0 ? g. highlightedText ( ) : g. text ( )); | 333 | p. fillRect ( around ( x0, y0 ), m_dragged == 0 ? g. highlightedText ( ) : g. text ( )); |
334 | p. drawRect ( around ( x0, y0 )); | 334 | p. drawRect ( around ( x0, y0 )); |
335 | p. fillRect ( around ( x1, y1 ), m_dragged == 1 ? g. highlightedText ( ) : g. text ( )); | 335 | p. fillRect ( around ( x1, y1 ), m_dragged == 1 ? g. highlightedText ( ) : g. text ( )); |
336 | p. drawRect ( around ( x1, y1 )); | 336 | p. drawRect ( around ( x1, y1 )); |
337 | 337 | ||
338 | p. setPen ( g. text ( )); | 338 | p. setPen ( g. text ( )); |
339 | p. drawText ( tr, AlignTop | AlignRight, stepstr ); | 339 | p. drawText ( tr, AlignTop | AlignRight, stepstr ); |
340 | 340 | ||
341 | p. end ( ); | 341 | p. end ( ); |
342 | bitBlt ( this, cr. topLeft ( ), &pix, cr ); | 342 | bitBlt ( this, cr. topLeft ( ), &pix, cr ); |
343 | if ( !cr. contains ( tr )) | 343 | if ( !cr. contains ( tr )) |
344 | bitBlt ( this, tr. topLeft ( ), &pix, tr ); | 344 | bitBlt ( this, tr. topLeft ( ), &pix, tr ); |
345 | } | 345 | } |
346 | 346 | ||