qlcdnumber.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qlcdnumber.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qlcdnumber.h"-
41#ifndef QT_NO_LCDNUMBER-
42#include "qbitarray.h"-
43#include "qpainter.h"-
44#include "private/qframe_p.h"-
45-
46QT_BEGIN_NAMESPACE-
47-
48class QLCDNumberPrivate : public QFramePrivate-
49{-
50 Q_DECLARE_PUBLIC(QLCDNumber)-
51public:-
52 void init();-
53 void internalSetString(const QString& s);-
54 void drawString(const QString& s, QPainter &, QBitArray * = 0, bool = true);-
55 //void drawString(const QString &, QPainter &, QBitArray * = 0) const;-
56 void drawDigit(const QPoint &, QPainter &, int, char, char = ' ');-
57 void drawSegment(const QPoint &, char, QPainter &, int, bool = false);-
58-
59 int ndigits;-
60 double val;-
61 uint base : 2;-
62 uint smallPoint : 1;-
63 uint fill : 1;-
64 uint shadow : 1;-
65 QString digitStr;-
66 QBitArray points;-
67};-
68-
69/*!-
70 \class QLCDNumber-
71-
72 \brief The QLCDNumber widget displays a number with LCD-like digits.-
73-
74 \ingroup basicwidgets-
75 \inmodule QtWidgets-
76-
77 It can display a number in just about any size. It can display-
78 decimal, hexadecimal, octal or binary numbers. It is easy to-
79 connect to data sources using the display() slot, which is-
80 overloaded to take any of five argument types.-
81-
82 There are also slots to change the base with setMode() and the-
83 decimal point with setSmallDecimalPoint().-
84-
85 QLCDNumber emits the overflow() signal when it is asked to display-
86 something beyond its range. The range is set by setDigitCount(),-
87 but setSmallDecimalPoint() also influences it. If the display is-
88 set to hexadecimal, octal or binary, the integer equivalent of the-
89 value is displayed.-
90-
91 These digits and other symbols can be shown: 0/O, 1, 2, 3, 4, 5/S,-
92 6, 7, 8, 9/g, minus, decimal point, A, B, C, D, E, F, h, H, L, o,-
93 P, r, u, U, Y, colon, degree sign (which is specified as single-
94 quote in the string) and space. QLCDNumber substitutes spaces for-
95 illegal characters.-
96-
97 It is not possible to retrieve the contents of a QLCDNumber-
98 object, although you can retrieve the numeric value with value().-
99 If you really need the text, we recommend that you connect the-
100 signals that feed the display() slot to another slot as well and-
101 store the value there.-
102-
103 Incidentally, QLCDNumber is the very oldest part of Qt, tracing-
104 its roots back to a BASIC program on the \l{Sinclair Spectrum}{Sinclair Spectrum}.-
105-
106 \table-
107 \row \li-
108 \inlineimage windows-lcdnumber.png Screenshot of a Windows style LCD number widget-
109 \inlineimage windowsvista-lcdnumber.png Screenshot of a Windows Vista style LCD number widget-
110 \inlineimage macintosh-lcdnumber.png Screenshot of a Macintosh style LCD number widget-
111 \inlineimage fusion-lcdnumber.png Screenshot of a Fusion style LCD number widget-
112 \row \li LCD number widgets shown in various widget styles (from left to right):-
113 \l{Windows Style Widget Gallery}{Windows}, \l{Windows Vista Style Widget Gallery}{Windows Vista},-
114 \l{Macintosh Style Widget Gallery}{Macintosh}, \l{Fusion Style Widget Gallery}{Fusion}.-
115 \endtable-
116-
117 \sa QLabel, QFrame, {Digital Clock Example}, {Tetrix Example}-
118*/-
119-
120/*!-
121 \enum QLCDNumber::Mode-
122-
123 This type determines how numbers are shown.-
124-
125 \value Hex Hexadecimal-
126 \value Dec Decimal-
127 \value Oct Octal-
128 \value Bin Binary-
129-
130 If the display is set to hexadecimal, octal or binary, the integer-
131 equivalent of the value is displayed.-
132*/-
133-
134/*!-
135 \enum QLCDNumber::SegmentStyle-
136-
137 This type determines the visual appearance of the QLCDNumber-
138 widget.-
139-
140 \value Outline gives raised segments filled with the background color.-
141 \value Filled gives raised segments filled with the windowText color.-
142 \value Flat gives flat segments filled with the windowText color.-
143*/-
144-
145-
146-
147/*!-
148 \fn void QLCDNumber::overflow()-
149-
150 This signal is emitted whenever the QLCDNumber is asked to display-
151 a too-large number or a too-long string.-
152-
153 It is never emitted by setDigitCount().-
154*/-
155-
156-
157static QString int2string(int num, int base, int ndigits, bool *oflow)-
158{-
159 QString s;-
160 bool negative;-
161 if (num < 0) {
num < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
162 negative = true;-
163 num = -num;-
164 } else {
never executed: end of block
0
165 negative = false;-
166 }
never executed: end of block
0
167 switch(base) {-
168 case QLCDNumber::Hex:
never executed: case QLCDNumber::Hex:
0
169 s = QString::asprintf("%*x", ndigits, num);-
170 break;
never executed: break;
0
171 case QLCDNumber::Dec:
never executed: case QLCDNumber::Dec:
0
172 s = QString::asprintf("%*i", ndigits, num);-
173 break;
never executed: break;
0
174 case QLCDNumber::Oct:
never executed: case QLCDNumber::Oct:
0
175 s = QString::asprintf("%*o", ndigits, num);-
176 break;
never executed: break;
0
177 case QLCDNumber::Bin:
never executed: case QLCDNumber::Bin:
0
178 {-
179 char buf[42];-
180 char *p = &buf[41];-
181 uint n = num;-
182 int len = 0;-
183 *p = '\0';-
184 do {-
185 *--p = (char)((n&1)+'0');-
186 n >>= 1;-
187 len++;-
188 } while (n != 0);
never executed: end of block
n != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
189 len = ndigits - len;-
190 if (len > 0)
len > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
191 s.fill(QLatin1Char(' '), len);
never executed: s.fill(QLatin1Char(' '), len);
0
192 s += QString::fromLatin1(p);-
193 }-
194 break;
never executed: break;
0
195 }-
196 if (negative) {
negativeDescription
TRUEnever evaluated
FALSEnever evaluated
0
197 for (int i=0; i<(int)s.length(); i++) {
i<(int)s.length()Description
TRUEnever evaluated
FALSEnever evaluated
0
198 if (s[i] != QLatin1Char(' ')) {
s[i] != QLatin1Char(' ')Description
TRUEnever evaluated
FALSEnever evaluated
0
199 if (i != 0) {
i != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
200 s[i-1] = QLatin1Char('-');-
201 } else {
never executed: end of block
0
202 s.insert(0, QLatin1Char('-'));-
203 }
never executed: end of block
0
204 break;
never executed: break;
0
205 }-
206 }
never executed: end of block
0
207 }
never executed: end of block
0
208 if (oflow)
oflowDescription
TRUEnever evaluated
FALSEnever evaluated
0
209 *oflow = (int)s.length() > ndigits;
never executed: *oflow = (int)s.length() > ndigits;
0
210 return s;
never executed: return s;
0
211}-
212-
213-
214static QString double2string(double num, int base, int ndigits, bool *oflow)-
215{-
216 QString s;-
217 if (base != QLCDNumber::Dec) {
base != QLCDNumber::DecDescription
TRUEnever evaluated
FALSEnever evaluated
0
218 bool of = num >= 2147483648.0 || num < -2147483648.0;
num >= 2147483648.0Description
TRUEnever evaluated
FALSEnever evaluated
num < -2147483648.0Description
TRUEnever evaluated
FALSEnever evaluated
0
219 if (of) { // oops, integer overflow
ofDescription
TRUEnever evaluated
FALSEnever evaluated
0
220 if (oflow)
oflowDescription
TRUEnever evaluated
FALSEnever evaluated
0
221 *oflow = true;
never executed: *oflow = true;
0
222 return s;
never executed: return s;
0
223 }-
224 s = int2string((int)num, base, ndigits, 0);-
225 } else { // decimal base
never executed: end of block
0
226 int nd = ndigits;-
227 do {-
228 s = QString::asprintf("%*.*g", ndigits, nd, num);-
229 int i = s.indexOf(QLatin1Char('e'));-
230 if (i > 0 && s[i+1]==QLatin1Char('+')) {
i > 0Description
TRUEnever evaluated
FALSEnever evaluated
s[i+1]==QLatin1Char('+')Description
TRUEnever evaluated
FALSEnever evaluated
0
231 s[i] = QLatin1Char(' ');-
232 s[i+1] = QLatin1Char('e');-
233 }
never executed: end of block
0
234 } while (nd-- && (int)s.length() > ndigits);
never executed: end of block
nd--Description
TRUEnever evaluated
FALSEnever evaluated
(int)s.length() > ndigitsDescription
TRUEnever evaluated
FALSEnever evaluated
0
235 }
never executed: end of block
0
236 if (oflow)
oflowDescription
TRUEnever evaluated
FALSEnever evaluated
0
237 *oflow = (int)s.length() > ndigits;
never executed: *oflow = (int)s.length() > ndigits;
0
238 return s;
never executed: return s;
0
239}-
240-
241-
242static const char *getSegments(char ch) // gets list of segments for ch-
243{-
244 static const char segments[30][8] =-
245 { { 0, 1, 2, 4, 5, 6,99, 0}, // 0 0 / O-
246 { 2, 5,99, 0, 0, 0, 0, 0}, // 1 1-
247 { 0, 2, 3, 4, 6,99, 0, 0}, // 2 2-
248 { 0, 2, 3, 5, 6,99, 0, 0}, // 3 3-
249 { 1, 2, 3, 5,99, 0, 0, 0}, // 4 4-
250 { 0, 1, 3, 5, 6,99, 0, 0}, // 5 5 / S-
251 { 0, 1, 3, 4, 5, 6,99, 0}, // 6 6-
252 { 0, 2, 5,99, 0, 0, 0, 0}, // 7 7-
253 { 0, 1, 2, 3, 4, 5, 6,99}, // 8 8-
254 { 0, 1, 2, 3, 5, 6,99, 0}, // 9 9 / g-
255 { 3,99, 0, 0, 0, 0, 0, 0}, // 10 --
256 { 7,99, 0, 0, 0, 0, 0, 0}, // 11 .-
257 { 0, 1, 2, 3, 4, 5,99, 0}, // 12 A-
258 { 1, 3, 4, 5, 6,99, 0, 0}, // 13 B-
259 { 0, 1, 4, 6,99, 0, 0, 0}, // 14 C-
260 { 2, 3, 4, 5, 6,99, 0, 0}, // 15 D-
261 { 0, 1, 3, 4, 6,99, 0, 0}, // 16 E-
262 { 0, 1, 3, 4,99, 0, 0, 0}, // 17 F-
263 { 1, 3, 4, 5,99, 0, 0, 0}, // 18 h-
264 { 1, 2, 3, 4, 5,99, 0, 0}, // 19 H-
265 { 1, 4, 6,99, 0, 0, 0, 0}, // 20 L-
266 { 3, 4, 5, 6,99, 0, 0, 0}, // 21 o-
267 { 0, 1, 2, 3, 4,99, 0, 0}, // 22 P-
268 { 3, 4,99, 0, 0, 0, 0, 0}, // 23 r-
269 { 4, 5, 6,99, 0, 0, 0, 0}, // 24 u-
270 { 1, 2, 4, 5, 6,99, 0, 0}, // 25 U-
271 { 1, 2, 3, 5, 6,99, 0, 0}, // 26 Y-
272 { 8, 9,99, 0, 0, 0, 0, 0}, // 27 :-
273 { 0, 1, 2, 3,99, 0, 0, 0}, // 28 '-
274 {99, 0, 0, 0, 0, 0, 0, 0} }; // 29 empty-
275-
276 if (ch >= '0' && ch <= '9')
ch >= '0'Description
TRUEnever evaluated
FALSEnever evaluated
ch <= '9'Description
TRUEnever evaluated
FALSEnever evaluated
0
277 return segments[ch - '0'];
never executed: return segments[ch - '0'];
0
278 if (ch >= 'A' && ch <= 'F')
ch >= 'A'Description
TRUEnever evaluated
FALSEnever evaluated
ch <= 'F'Description
TRUEnever evaluated
FALSEnever evaluated
0
279 return segments[ch - 'A' + 12];
never executed: return segments[ch - 'A' + 12];
0
280 if (ch >= 'a' && ch <= 'f')
ch >= 'a'Description
TRUEnever evaluated
FALSEnever evaluated
ch <= 'f'Description
TRUEnever evaluated
FALSEnever evaluated
0
281 return segments[ch - 'a' + 12];
never executed: return segments[ch - 'a' + 12];
0
282-
283 int n;-
284 switch (ch) {-
285 case '-':
never executed: case '-':
0
286 n = 10; break;
never executed: break;
0
287 case 'O':
never executed: case 'O':
0
288 n = 0; break;
never executed: break;
0
289 case 'g':
never executed: case 'g':
0
290 n = 9; break;
never executed: break;
0
291 case '.':
never executed: case '.':
0
292 n = 11; break;
never executed: break;
0
293 case 'h':
never executed: case 'h':
0
294 n = 18; break;
never executed: break;
0
295 case 'H':
never executed: case 'H':
0
296 n = 19; break;
never executed: break;
0
297 case 'l':
never executed: case 'l':
0
298 case 'L':
never executed: case 'L':
0
299 n = 20; break;
never executed: break;
0
300 case 'o':
never executed: case 'o':
0
301 n = 21; break;
never executed: break;
0
302 case 'p':
never executed: case 'p':
0
303 case 'P':
never executed: case 'P':
0
304 n = 22; break;
never executed: break;
0
305 case 'r':
never executed: case 'r':
0
306 case 'R':
never executed: case 'R':
0
307 n = 23; break;
never executed: break;
0
308 case 's':
never executed: case 's':
0
309 case 'S':
never executed: case 'S':
0
310 n = 5; break;
never executed: break;
0
311 case 'u':
never executed: case 'u':
0
312 n = 24; break;
never executed: break;
0
313 case 'U':
never executed: case 'U':
0
314 n = 25; break;
never executed: break;
0
315 case 'y':
never executed: case 'y':
0
316 case 'Y':
never executed: case 'Y':
0
317 n = 26; break;
never executed: break;
0
318 case ':':
never executed: case ':':
0
319 n = 27; break;
never executed: break;
0
320 case '\'':
never executed: case '\'':
0
321 n = 28; break;
never executed: break;
0
322 default:
never executed: default:
0
323 n = 29; break;
never executed: break;
0
324 }-
325 return segments[n];
never executed: return segments[n];
0
326}-
327-
328-
329-
330/*!-
331 Constructs an LCD number, sets the number of digits to 5, the base-
332 to decimal, the decimal point mode to 'small' and the frame style-
333 to a raised box. The segmentStyle() is set to \c Outline.-
334-
335 The \a parent argument is passed to the QFrame constructor.-
336-
337 \sa setDigitCount(), setSmallDecimalPoint()-
338*/-
339-
340QLCDNumber::QLCDNumber(QWidget *parent)-
341 : QFrame(*new QLCDNumberPrivate, parent)-
342{-
343 Q_D(QLCDNumber);-
344 d->ndigits = 5;-
345 d->init();-
346}
never executed: end of block
0
347-
348-
349/*!-
350 Constructs an LCD number, sets the number of digits to \a-
351 numDigits, the base to decimal, the decimal point mode to 'small'-
352 and the frame style to a raised box. The segmentStyle() is set to-
353 \c Filled.-
354-
355 The \a parent argument is passed to the QFrame constructor.-
356-
357 \sa setDigitCount(), setSmallDecimalPoint()-
358*/-
359-
360QLCDNumber::QLCDNumber(uint numDigits, QWidget *parent)-
361 : QFrame(*new QLCDNumberPrivate, parent)-
362{-
363 Q_D(QLCDNumber);-
364 d->ndigits = numDigits;-
365 d->init();-
366}
never executed: end of block
0
367-
368void QLCDNumberPrivate::init()-
369{-
370 Q_Q(QLCDNumber);-
371-
372 q->setFrameStyle(QFrame::Box | QFrame::Raised);-
373 val = 0;-
374 base = QLCDNumber::Dec;-
375 smallPoint = false;-
376 q->setDigitCount(ndigits);-
377 q->setSegmentStyle(QLCDNumber::Filled);-
378 q->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));-
379}
never executed: end of block
0
380-
381/*!-
382 Destroys the LCD number.-
383*/-
384-
385QLCDNumber::~QLCDNumber()-
386{-
387}-
388-
389-
390/*!-
391 \since 4.6-
392 \property QLCDNumber::digitCount-
393 \brief the current number of digits displayed-
394-
395 Corresponds to the current number of digits. If \l-
396 QLCDNumber::smallDecimalPoint is false, the decimal point occupies-
397 one digit position.-
398-
399 By default, this property contains a value of 5.-
400-
401 \sa smallDecimalPoint-
402*/-
403-
404/*!-
405 Sets the current number of digits to \a numDigits. Must-
406 be in the range 0..99.-
407 */-
408void QLCDNumber::setDigitCount(int numDigits)-
409{-
410 Q_D(QLCDNumber);-
411 if (Q_UNLIKELY(numDigits > 99)) {
__builtin_expe... > 99), false)Description
TRUEnever evaluated
FALSEnever evaluated
0
412 qWarning("QLCDNumber::setNumDigits: (%s) Max 99 digits allowed",-
413 objectName().toLocal8Bit().constData());-
414 numDigits = 99;-
415 }
never executed: end of block
0
416 if (Q_UNLIKELY(numDigits < 0)) {
__builtin_expe...s < 0), false)Description
TRUEnever evaluated
FALSEnever evaluated
0
417 qWarning("QLCDNumber::setNumDigits: (%s) Min 0 digits allowed",-
418 objectName().toLocal8Bit().constData());-
419 numDigits = 0;-
420 }
never executed: end of block
0
421 if (d->digitStr.isNull()) { // from constructor
d->digitStr.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
422 d->ndigits = numDigits;-
423 d->digitStr.fill(QLatin1Char(' '), d->ndigits);-
424 d->points.fill(0, d->ndigits);-
425 d->digitStr[d->ndigits - 1] = QLatin1Char('0'); // "0" is the default number-
426 } else {
never executed: end of block
0
427 bool doDisplay = d->ndigits == 0;-
428 if (numDigits == d->ndigits) // no change
numDigits == d->ndigitsDescription
TRUEnever evaluated
FALSEnever evaluated
0
429 return;
never executed: return;
0
430 int i;-
431 int dif;-
432 if (numDigits > d->ndigits) { // expand
numDigits > d->ndigitsDescription
TRUEnever evaluated
FALSEnever evaluated
0
433 dif = numDigits - d->ndigits;-
434 QString buf;-
435 buf.fill(QLatin1Char(' '), dif);-
436 d->digitStr.insert(0, buf);-
437 d->points.resize(numDigits);-
438 for (i=numDigits-1; i>=dif; i--)
i>=difDescription
TRUEnever evaluated
FALSEnever evaluated
0
439 d->points.setBit(i, d->points.testBit(i-dif));
never executed: d->points.setBit(i, d->points.testBit(i-dif));
0
440 for (i=0; i<dif; i++)
i<difDescription
TRUEnever evaluated
FALSEnever evaluated
0
441 d->points.clearBit(i);
never executed: d->points.clearBit(i);
0
442 } else { // shrink
never executed: end of block
0
443 dif = d->ndigits - numDigits;-
444 d->digitStr = d->digitStr.right(numDigits);-
445 QBitArray tmpPoints = d->points;-
446 d->points.resize(numDigits);-
447 for (i=0; i<(int)numDigits; i++)
i<(int)numDigitsDescription
TRUEnever evaluated
FALSEnever evaluated
0
448 d->points.setBit(i, tmpPoints.testBit(i+dif));
never executed: d->points.setBit(i, tmpPoints.testBit(i+dif));
0
449 }
never executed: end of block
0
450 d->ndigits = numDigits;-
451 if (doDisplay)
doDisplayDescription
TRUEnever evaluated
FALSEnever evaluated
0
452 display(value());
never executed: display(value());
0
453 update();-
454 }
never executed: end of block
0
455}-
456-
457/*!-
458 Returns the current number of digits.-
459 */-
460int QLCDNumber::digitCount() const-
461{-
462 Q_D(const QLCDNumber);-
463 return d->ndigits;
never executed: return d->ndigits;
0
464}-
465-
466/*!-
467 \overload-
468-
469 Returns \c true if \a num is too big to be displayed in its entirety;-
470 otherwise returns \c false.-
471-
472 \sa display(), digitCount(), smallDecimalPoint()-
473*/-
474-
475bool QLCDNumber::checkOverflow(int num) const-
476{-
477 Q_D(const QLCDNumber);-
478 bool of;-
479 int2string(num, d->base, d->ndigits, &of);-
480 return of;
never executed: return of;
0
481}-
482-
483-
484/*!-
485 Returns \c true if \a num is too big to be displayed in its entirety;-
486 otherwise returns \c false.-
487-
488 \sa display(), digitCount(), smallDecimalPoint()-
489*/-
490-
491bool QLCDNumber::checkOverflow(double num) const-
492{-
493 Q_D(const QLCDNumber);-
494 bool of;-
495 double2string(num, d->base, d->ndigits, &of);-
496 return of;
never executed: return of;
0
497}-
498-
499-
500/*!-
501 \property QLCDNumber::mode-
502 \brief the current display mode (number base)-
503-
504 Corresponds to the current display mode, which is one of \c Bin,-
505 \c Oct, \c Dec (the default) and \c Hex. \c Dec mode can display-
506 floating point values, the other modes display the integer-
507 equivalent.-
508-
509 \sa smallDecimalPoint(), setHexMode(), setDecMode(), setOctMode(), setBinMode()-
510*/-
511-
512QLCDNumber::Mode QLCDNumber::mode() const-
513{-
514 Q_D(const QLCDNumber);-
515 return (QLCDNumber::Mode) d->base;
never executed: return (QLCDNumber::Mode) d->base;
0
516}-
517-
518void QLCDNumber::setMode(Mode m)-
519{-
520 Q_D(QLCDNumber);-
521 d->base = m;-
522 display(d->val);-
523}
never executed: end of block
0
524-
525-
526/*!-
527 \property QLCDNumber::value-
528 \brief the displayed value-
529-
530 This property corresponds to the current value displayed by the-
531 LCDNumber.-
532-
533 If the displayed value is not a number, the property has a value-
534 of 0.-
535-
536 By default, this property contains a value of 0.-
537*/-
538-
539double QLCDNumber::value() const-
540{-
541 Q_D(const QLCDNumber);-
542 return d->val;
never executed: return d->val;
0
543}-
544-
545/*!-
546 \overload-
547-
548 Displays the number \a num.-
549*/-
550void QLCDNumber::display(double num)-
551{-
552 Q_D(QLCDNumber);-
553 d->val = num;-
554 bool of;-
555 QString s = double2string(d->val, d->base, d->ndigits, &of);-
556 if (of)
ofDescription
TRUEnever evaluated
FALSEnever evaluated
0
557 emit overflow();
never executed: overflow();
0
558 else-
559 d->internalSetString(s);
never executed: d->internalSetString(s);
0
560}-
561-
562/*!-
563 \property QLCDNumber::intValue-
564 \brief the displayed value rounded to the nearest integer-
565-
566 This property corresponds to the nearest integer to the current-
567 value displayed by the LCDNumber. This is the value used for-
568 hexadecimal, octal and binary modes.-
569-
570 If the displayed value is not a number, the property has a value-
571 of 0.-
572-
573 By default, this property contains a value of 0.-
574*/-
575int QLCDNumber::intValue() const-
576{-
577 Q_D(const QLCDNumber);-
578 return qRound(d->val);
never executed: return qRound(d->val);
0
579}-
580-
581-
582/*!-
583 \overload-
584-
585 Displays the number \a num.-
586*/-
587void QLCDNumber::display(int num)-
588{-
589 Q_D(QLCDNumber);-
590 d->val = (double)num;-
591 bool of;-
592 QString s = int2string(num, d->base, d->ndigits, &of);-
593 if (of)
ofDescription
TRUEnever evaluated
FALSEnever evaluated
0
594 emit overflow();
never executed: overflow();
0
595 else-
596 d->internalSetString(s);
never executed: d->internalSetString(s);
0
597}-
598-
599-
600/*!-
601 Displays the number represented by the string \a s.-
602-
603 This version of the function disregards mode() and-
604 smallDecimalPoint().-
605-
606 These digits and other symbols can be shown: 0/O, 1, 2, 3, 4, 5/S,-
607 6, 7, 8, 9/g, minus, decimal point, A, B, C, D, E, F, h, H, L, o,-
608 P, r, u, U, Y, colon, degree sign (which is specified as single-
609 quote in the string) and space. QLCDNumber substitutes spaces for-
610 illegal characters.-
611*/-
612-
613void QLCDNumber::display(const QString &s)-
614{-
615 Q_D(QLCDNumber);-
616 d->val = 0;-
617 bool ok = false;-
618 double v = s.toDouble(&ok);-
619 if (ok)
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
620 d->val = v;
never executed: d->val = v;
0
621 d->internalSetString(s);-
622}
never executed: end of block
0
623-
624/*!-
625 Calls setMode(Hex). Provided for convenience (e.g. for-
626 connecting buttons to it).-
627-
628 \sa setMode(), setDecMode(), setOctMode(), setBinMode(), mode()-
629*/-
630-
631void QLCDNumber::setHexMode()-
632{-
633 setMode(Hex);-
634}
never executed: end of block
0
635-
636-
637/*!-
638 Calls setMode(Dec). Provided for convenience (e.g. for-
639 connecting buttons to it).-
640-
641 \sa setMode(), setHexMode(), setOctMode(), setBinMode(), mode()-
642*/-
643-
644void QLCDNumber::setDecMode()-
645{-
646 setMode(Dec);-
647}
never executed: end of block
0
648-
649-
650/*!-
651 Calls setMode(Oct). Provided for convenience (e.g. for-
652 connecting buttons to it).-
653-
654 \sa setMode(), setHexMode(), setDecMode(), setBinMode(), mode()-
655*/-
656-
657void QLCDNumber::setOctMode()-
658{-
659 setMode(Oct);-
660}
never executed: end of block
0
661-
662-
663/*!-
664 Calls setMode(Bin). Provided for convenience (e.g. for-
665 connecting buttons to it).-
666-
667 \sa setMode(), setHexMode(), setDecMode(), setOctMode(), mode()-
668*/-
669-
670void QLCDNumber::setBinMode()-
671{-
672 setMode(Bin);-
673}
never executed: end of block
0
674-
675-
676/*!-
677 \property QLCDNumber::smallDecimalPoint-
678 \brief the style of the decimal point-
679-
680 If true the decimal point is drawn between two digit positions.-
681 Otherwise it occupies a digit position of its own, i.e. is drawn-
682 in a digit position. The default is false.-
683-
684 The inter-digit space is made slightly wider when the decimal-
685 point is drawn between the digits.-
686-
687 \sa mode-
688*/-
689-
690void QLCDNumber::setSmallDecimalPoint(bool b)-
691{-
692 Q_D(QLCDNumber);-
693 d->smallPoint = b;-
694 update();-
695}
never executed: end of block
0
696-
697bool QLCDNumber::smallDecimalPoint() const-
698{-
699 Q_D(const QLCDNumber);-
700 return d->smallPoint;
never executed: return d->smallPoint;
0
701}-
702-
703-
704-
705/*!\reimp-
706*/-
707-
708-
709void QLCDNumber::paintEvent(QPaintEvent *)-
710{-
711 Q_D(QLCDNumber);-
712 QPainter p(this);-
713 drawFrame(&p);-
714 p.setRenderHint(QPainter::Antialiasing);-
715 if (d->shadow)
d->shadowDescription
TRUEnever evaluated
FALSEnever evaluated
0
716 p.translate(0.5, 0.5);
never executed: p.translate(0.5, 0.5);
0
717-
718 if (d->smallPoint)
d->smallPointDescription
TRUEnever evaluated
FALSEnever evaluated
0
719 d->drawString(d->digitStr, p, &d->points, false);
never executed: d->drawString(d->digitStr, p, &d->points, false);
0
720 else-
721 d->drawString(d->digitStr, p, 0, false);
never executed: d->drawString(d->digitStr, p, 0, false);
0
722}-
723-
724-
725void QLCDNumberPrivate::internalSetString(const QString& s)-
726{-
727 Q_Q(QLCDNumber);-
728 QString buffer;-
729 int i;-
730 int len = s.length();-
731 QBitArray newPoints(ndigits);-
732-
733 if (!smallPoint) {
!smallPointDescription
TRUEnever evaluated
FALSEnever evaluated
0
734 if (len == ndigits)
len == ndigitsDescription
TRUEnever evaluated
FALSEnever evaluated
0
735 buffer = s;
never executed: buffer = s;
0
736 else-
737 buffer = s.right(ndigits).rightJustified(ndigits, QLatin1Char(' '));
never executed: buffer = s.right(ndigits).rightJustified(ndigits, QLatin1Char(' '));
0
738 } else {-
739 int index = -1;-
740 bool lastWasPoint = true;-
741 newPoints.clearBit(0);-
742 for (i=0; i<len; i++) {
i<lenDescription
TRUEnever evaluated
FALSEnever evaluated
0
743 if (s[i] == QLatin1Char('.')) {
s[i] == QLatin1Char('.')Description
TRUEnever evaluated
FALSEnever evaluated
0
744 if (lastWasPoint) { // point already set for digit?
lastWasPointDescription
TRUEnever evaluated
FALSEnever evaluated
0
745 if (index == ndigits - 1) // no more digits
index == ndigits - 1Description
TRUEnever evaluated
FALSEnever evaluated
0
746 break;
never executed: break;
0
747 index++;-
748 buffer[index] = QLatin1Char(' '); // 2 points in a row, add space-
749 }
never executed: end of block
0
750 newPoints.setBit(index); // set decimal point-
751 lastWasPoint = true;-
752 } else {
never executed: end of block
0
753 if (index == ndigits - 1)
index == ndigits - 1Description
TRUEnever evaluated
FALSEnever evaluated
0
754 break;
never executed: break;
0
755 index++;-
756 buffer[index] = s[i];-
757 newPoints.clearBit(index); // decimal point default off-
758 lastWasPoint = false;-
759 }
never executed: end of block
0
760 }-
761 if (index < ((int) ndigits) - 1) {
index < ((int) ndigits) - 1Description
TRUEnever evaluated
FALSEnever evaluated
0
762 for(i=index; i>=0; i--) {
i>=0Description
TRUEnever evaluated
FALSEnever evaluated
0
763 buffer[ndigits - 1 - index + i] = buffer[i];-
764 newPoints.setBit(ndigits - 1 - index + i,-
765 newPoints.testBit(i));-
766 }
never executed: end of block
0
767 for(i=0; i<ndigits-index-1; i++) {
i<ndigits-index-1Description
TRUEnever evaluated
FALSEnever evaluated
0
768 buffer[i] = QLatin1Char(' ');-
769 newPoints.clearBit(i);-
770 }
never executed: end of block
0
771 }
never executed: end of block
0
772 }
never executed: end of block
0
773-
774 if (buffer == digitStr)
buffer == digitStrDescription
TRUEnever evaluated
FALSEnever evaluated
0
775 return;
never executed: return;
0
776-
777 digitStr = buffer;-
778 if (smallPoint)
smallPointDescription
TRUEnever evaluated
FALSEnever evaluated
0
779 points = newPoints;
never executed: points = newPoints;
0
780 q->update();-
781}
never executed: end of block
0
782-
783/*!-
784 \internal-
785*/-
786-
787void QLCDNumberPrivate::drawString(const QString &s, QPainter &p,-
788 QBitArray *newPoints, bool newString)-
789{-
790 Q_Q(QLCDNumber);-
791 QPoint pos;-
792-
793 int digitSpace = smallPoint ? 2 : 1;
smallPointDescription
TRUEnever evaluated
FALSEnever evaluated
0
794 int xSegLen = q->width()*5/(ndigits*(5 + digitSpace) + digitSpace);-
795 int ySegLen = q->height()*5/12;-
796 int segLen = ySegLen > xSegLen ? xSegLen : ySegLen;
ySegLen > xSegLenDescription
TRUEnever evaluated
FALSEnever evaluated
0
797 int xAdvance = segLen*(5 + digitSpace)/5;-
798 int xOffset = (q->width() - ndigits*xAdvance + segLen/5)/2;-
799 int yOffset = (q->height() - segLen*2)/2;-
800-
801 for (int i=0; i<ndigits; i++) {
i<ndigitsDescription
TRUEnever evaluated
FALSEnever evaluated
0
802 pos = QPoint(xOffset + xAdvance*i, yOffset);-
803 if (newString)
newStringDescription
TRUEnever evaluated
FALSEnever evaluated
0
804 drawDigit(pos, p, segLen, s[i].toLatin1(), digitStr[i].toLatin1());
never executed: drawDigit(pos, p, segLen, s[i].toLatin1(), digitStr[i].toLatin1());
0
805 else-
806 drawDigit(pos, p, segLen, s[i].toLatin1());
never executed: drawDigit(pos, p, segLen, s[i].toLatin1());
0
807 if (newPoints) {
newPointsDescription
TRUEnever evaluated
FALSEnever evaluated
0
808 char newPoint = newPoints->testBit(i) ? '.' : ' ';
newPoints->testBit(i)Description
TRUEnever evaluated
FALSEnever evaluated
0
809 if (newString) {
newStringDescription
TRUEnever evaluated
FALSEnever evaluated
0
810 char oldPoint = points.testBit(i) ? '.' : ' ';
points.testBit(i)Description
TRUEnever evaluated
FALSEnever evaluated
0
811 drawDigit(pos, p, segLen, newPoint, oldPoint);-
812 } else {
never executed: end of block
0
813 drawDigit(pos, p, segLen, newPoint);-
814 }
never executed: end of block
0
815 }-
816 }
never executed: end of block
0
817 if (newString) {
newStringDescription
TRUEnever evaluated
FALSEnever evaluated
0
818 digitStr = s;-
819 digitStr.truncate(ndigits);-
820 if (newPoints)
newPointsDescription
TRUEnever evaluated
FALSEnever evaluated
0
821 points = *newPoints;
never executed: points = *newPoints;
0
822 }
never executed: end of block
0
823}
never executed: end of block
0
824-
825-
826/*!-
827 \internal-
828*/-
829-
830void QLCDNumberPrivate::drawDigit(const QPoint &pos, QPainter &p, int segLen,-
831 char newCh, char oldCh)-
832{-
833// Draws and/or erases segments to change display of a single digit-
834// from oldCh to newCh-
835-
836 char updates[18][2]; // can hold 2 times number of segments, only-
837 // first 9 used if segment table is correct-
838 int nErases;-
839 int nUpdates;-
840 const char *segs;-
841 int i,j;-
842-
843 const char erase = 0;-
844 const char draw = 1;-
845 const char leaveAlone = 2;-
846-
847 segs = getSegments(oldCh);-
848 for (nErases=0; segs[nErases] != 99; nErases++) {
segs[nErases] != 99Description
TRUEnever evaluated
FALSEnever evaluated
0
849 updates[nErases][0] = erase; // get segments to erase to-
850 updates[nErases][1] = segs[nErases]; // remove old char-
851 }
never executed: end of block
0
852 nUpdates = nErases;-
853 segs = getSegments(newCh);-
854 for(i = 0 ; segs[i] != 99 ; i++) {
segs[i] != 99Description
TRUEnever evaluated
FALSEnever evaluated
0
855 for (j=0; j<nErases; j++)
j<nErasesDescription
TRUEnever evaluated
FALSEnever evaluated
0
856 if (segs[i] == updates[j][1]) { // same segment ?
segs[i] == updates[j][1]Description
TRUEnever evaluated
FALSEnever evaluated
0
857 updates[j][0] = leaveAlone; // yes, already on screen-
858 break;
never executed: break;
0
859 }-
860 if (j == nErases) { // if not already on screen
j == nErasesDescription
TRUEnever evaluated
FALSEnever evaluated
0
861 updates[nUpdates][0] = draw;-
862 updates[nUpdates][1] = segs[i];-
863 nUpdates++;-
864 }
never executed: end of block
0
865 }
never executed: end of block
0
866 for (i=0; i<nUpdates; i++) {
i<nUpdatesDescription
TRUEnever evaluated
FALSEnever evaluated
0
867 if (updates[i][0] == draw)
updates[i][0] == drawDescription
TRUEnever evaluated
FALSEnever evaluated
0
868 drawSegment(pos, updates[i][1], p, segLen);
never executed: drawSegment(pos, updates[i][1], p, segLen);
0
869 if (updates[i][0] == erase)
updates[i][0] == eraseDescription
TRUEnever evaluated
FALSEnever evaluated
0
870 drawSegment(pos, updates[i][1], p, segLen, true);
never executed: drawSegment(pos, updates[i][1], p, segLen, true);
0
871 }
never executed: end of block
0
872}
never executed: end of block
0
873-
874-
875static void addPoint(QPolygon &a, const QPoint &p)-
876{-
877 uint n = a.size();-
878 a.resize(n + 1);-
879 a.setPoint(n, p);-
880}
never executed: end of block
0
881-
882/*!-
883 \internal-
884*/-
885-
886void QLCDNumberPrivate::drawSegment(const QPoint &pos, char segmentNo, QPainter &p,-
887 int segLen, bool erase)-
888{-
889 Q_Q(QLCDNumber);-
890 QPoint ppt;-
891 QPoint pt = pos;-
892 int width = segLen/5;-
893-
894 const QPalette &pal = q->palette();-
895 QColor lightColor,darkColor,fgColor;-
896 if (erase){
eraseDescription
TRUEnever evaluated
FALSEnever evaluated
0
897 lightColor = pal.color(q->backgroundRole());-
898 darkColor = lightColor;-
899 fgColor = lightColor;-
900 } else {
never executed: end of block
0
901 lightColor = pal.light().color();-
902 darkColor = pal.dark().color();-
903 fgColor = pal.color(q->foregroundRole());-
904 }
never executed: end of block
0
905-
906-
907#define LINETO(X,Y) addPoint(a, QPoint(pt.x() + (X),pt.y() + (Y)))-
908#define LIGHT-
909#define DARK-
910-
911 if (fill) {
fillDescription
TRUEnever evaluated
FALSEnever evaluated
0
912 QPolygon a(0);-
913 //The following is an exact copy of the switch below.-
914 //don't make any changes here-
915 switch (segmentNo) {-
916 case 0 :
never executed: case 0 :
0
917 ppt = pt;-
918 LIGHT;-
919 LINETO(segLen - 1,0);-
920 DARK;-
921 LINETO(segLen - width - 1,width);-
922 LINETO(width,width);-
923 LINETO(0,0);-
924 break;
never executed: break;
0
925 case 1 :
never executed: case 1 :
0
926 pt += QPoint(0 , 1);-
927 ppt = pt;-
928 LIGHT;-
929 LINETO(width,width);-
930 DARK;-
931 LINETO(width,segLen - width/2 - 2);-
932 LINETO(0,segLen - 2);-
933 LIGHT;-
934 LINETO(0,0);-
935 break;
never executed: break;
0
936 case 2 :
never executed: case 2 :
0
937 pt += QPoint(segLen - 1 , 1);-
938 ppt = pt;-
939 DARK;-
940 LINETO(0,segLen - 2);-
941 LINETO(-width,segLen - width/2 - 2);-
942 LIGHT;-
943 LINETO(-width,width);-
944 LINETO(0,0);-
945 break;
never executed: break;
0
946 case 3 :
never executed: case 3 :
0
947 pt += QPoint(0 , segLen);-
948 ppt = pt;-
949 LIGHT;-
950 LINETO(width,-width/2);-
951 LINETO(segLen - width - 1,-width/2);-
952 LINETO(segLen - 1,0);-
953 DARK;-
954 if (width & 1) { // adjust for integer division error
width & 1Description
TRUEnever evaluated
FALSEnever evaluated
0
955 LINETO(segLen - width - 3,width/2 + 1);-
956 LINETO(width + 2,width/2 + 1);-
957 } else {
never executed: end of block
0
958 LINETO(segLen - width - 1,width/2);-
959 LINETO(width,width/2);-
960 }
never executed: end of block
0
961 LINETO(0,0);-
962 break;
never executed: break;
0
963 case 4 :
never executed: case 4 :
0
964 pt += QPoint(0 , segLen + 1);-
965 ppt = pt;-
966 LIGHT;-
967 LINETO(width,width/2);-
968 DARK;-
969 LINETO(width,segLen - width - 2);-
970 LINETO(0,segLen - 2);-
971 LIGHT;-
972 LINETO(0,0);-
973 break;
never executed: break;
0
974 case 5 :
never executed: case 5 :
0
975 pt += QPoint(segLen - 1 , segLen + 1);-
976 ppt = pt;-
977 DARK;-
978 LINETO(0,segLen - 2);-
979 LINETO(-width,segLen - width - 2);-
980 LIGHT;-
981 LINETO(-width,width/2);-
982 LINETO(0,0);-
983 break;
never executed: break;
0
984 case 6 :
never executed: case 6 :
0
985 pt += QPoint(0 , segLen*2);-
986 ppt = pt;-
987 LIGHT;-
988 LINETO(width,-width);-
989 LINETO(segLen - width - 1,-width);-
990 LINETO(segLen - 1,0);-
991 DARK;-
992 LINETO(0,0);-
993 break;
never executed: break;
0
994 case 7 :
never executed: case 7 :
0
995 if (smallPoint) // if smallpoint place'.' between other digits
smallPointDescription
TRUEnever evaluated
FALSEnever evaluated
0
996 pt += QPoint(segLen + width/2 , segLen*2);
never executed: pt += QPoint(segLen + width/2 , segLen*2);
0
997 else-
998 pt += QPoint(segLen/2 , segLen*2);
never executed: pt += QPoint(segLen/2 , segLen*2);
0
999 ppt = pt;-
1000 DARK;-
1001 LINETO(width,0);-
1002 LINETO(width,-width);-
1003 LIGHT;-
1004 LINETO(0,-width);-
1005 LINETO(0,0);-
1006 break;
never executed: break;
0
1007 case 8 :
never executed: case 8 :
0
1008 pt += QPoint(segLen/2 - width/2 + 1 , segLen/2 + width);-
1009 ppt = pt;-
1010 DARK;-
1011 LINETO(width,0);-
1012 LINETO(width,-width);-
1013 LIGHT;-
1014 LINETO(0,-width);-
1015 LINETO(0,0);-
1016 break;
never executed: break;
0
1017 case 9 :
never executed: case 9 :
0
1018 pt += QPoint(segLen/2 - width/2 + 1 , 3*segLen/2 + width);-
1019 ppt = pt;-
1020 DARK;-
1021 LINETO(width,0);-
1022 LINETO(width,-width);-
1023 LIGHT;-
1024 LINETO(0,-width);-
1025 LINETO(0,0);-
1026 break;
never executed: break;
0
1027 default :
never executed: default :
0
1028 qWarning("QLCDNumber::drawSegment: (%s) Illegal segment id: %d\n",-
1029 q->objectName().toLocal8Bit().constData(), segmentNo);-
1030 }
never executed: end of block
0
1031 // End exact copy-
1032 p.setPen(Qt::NoPen);-
1033 p.setBrush(fgColor);-
1034 p.drawPolygon(a);-
1035 p.setBrush(Qt::NoBrush);-
1036-
1037 pt = pos;-
1038 }
never executed: end of block
0
1039#undef LINETO-
1040#undef LIGHT-
1041#undef DARK-
1042-
1043#define LINETO(X,Y) p.drawLine(ppt.x(), ppt.y(), pt.x()+(X), pt.y()+(Y)); \-
1044 ppt = QPoint(pt.x()+(X), pt.y()+(Y))-
1045#define LIGHT p.setPen(lightColor)-
1046#define DARK p.setPen(darkColor)-
1047 if (shadow)
shadowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1048 switch (segmentNo) {-
1049 case 0 :
never executed: case 0 :
0
1050 ppt = pt;-
1051 LIGHT;-
1052 LINETO(segLen - 1,0);-
1053 DARK;-
1054 LINETO(segLen - width - 1,width);-
1055 LINETO(width,width);-
1056 LINETO(0,0);-
1057 break;
never executed: break;
0
1058 case 1 :
never executed: case 1 :
0
1059 pt += QPoint(0,1);-
1060 ppt = pt;-
1061 LIGHT;-
1062 LINETO(width,width);-
1063 DARK;-
1064 LINETO(width,segLen - width/2 - 2);-
1065 LINETO(0,segLen - 2);-
1066 LIGHT;-
1067 LINETO(0,0);-
1068 break;
never executed: break;
0
1069 case 2 :
never executed: case 2 :
0
1070 pt += QPoint(segLen - 1 , 1);-
1071 ppt = pt;-
1072 DARK;-
1073 LINETO(0,segLen - 2);-
1074 LINETO(-width,segLen - width/2 - 2);-
1075 LIGHT;-
1076 LINETO(-width,width);-
1077 LINETO(0,0);-
1078 break;
never executed: break;
0
1079 case 3 :
never executed: case 3 :
0
1080 pt += QPoint(0 , segLen);-
1081 ppt = pt;-
1082 LIGHT;-
1083 LINETO(width,-width/2);-
1084 LINETO(segLen - width - 1,-width/2);-
1085 LINETO(segLen - 1,0);-
1086 DARK;-
1087 if (width & 1) { // adjust for integer division error
width & 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1088 LINETO(segLen - width - 3,width/2 + 1);-
1089 LINETO(width + 2,width/2 + 1);-
1090 } else {
never executed: end of block
0
1091 LINETO(segLen - width - 1,width/2);-
1092 LINETO(width,width/2);-
1093 }
never executed: end of block
0
1094 LINETO(0,0);-
1095 break;
never executed: break;
0
1096 case 4 :
never executed: case 4 :
0
1097 pt += QPoint(0 , segLen + 1);-
1098 ppt = pt;-
1099 LIGHT;-
1100 LINETO(width,width/2);-
1101 DARK;-
1102 LINETO(width,segLen - width - 2);-
1103 LINETO(0,segLen - 2);-
1104 LIGHT;-
1105 LINETO(0,0);-
1106 break;
never executed: break;
0
1107 case 5 :
never executed: case 5 :
0
1108 pt += QPoint(segLen - 1 , segLen + 1);-
1109 ppt = pt;-
1110 DARK;-
1111 LINETO(0,segLen - 2);-
1112 LINETO(-width,segLen - width - 2);-
1113 LIGHT;-
1114 LINETO(-width,width/2);-
1115 LINETO(0,0);-
1116 break;
never executed: break;
0
1117 case 6 :
never executed: case 6 :
0
1118 pt += QPoint(0 , segLen*2);-
1119 ppt = pt;-
1120 LIGHT;-
1121 LINETO(width,-width);-
1122 LINETO(segLen - width - 1,-width);-
1123 LINETO(segLen - 1,0);-
1124 DARK;-
1125 LINETO(0,0);-
1126 break;
never executed: break;
0
1127 case 7 :
never executed: case 7 :
0
1128 if (smallPoint) // if smallpoint place'.' between other digits
smallPointDescription
TRUEnever evaluated
FALSEnever evaluated
0
1129 pt += QPoint(segLen + width/2 , segLen*2);
never executed: pt += QPoint(segLen + width/2 , segLen*2);
0
1130 else-
1131 pt += QPoint(segLen/2 , segLen*2);
never executed: pt += QPoint(segLen/2 , segLen*2);
0
1132 ppt = pt;-
1133 DARK;-
1134 LINETO(width,0);-
1135 LINETO(width,-width);-
1136 LIGHT;-
1137 LINETO(0,-width);-
1138 LINETO(0,0);-
1139 break;
never executed: break;
0
1140 case 8 :
never executed: case 8 :
0
1141 pt += QPoint(segLen/2 - width/2 + 1 , segLen/2 + width);-
1142 ppt = pt;-
1143 DARK;-
1144 LINETO(width,0);-
1145 LINETO(width,-width);-
1146 LIGHT;-
1147 LINETO(0,-width);-
1148 LINETO(0,0);-
1149 break;
never executed: break;
0
1150 case 9 :
never executed: case 9 :
0
1151 pt += QPoint(segLen/2 - width/2 + 1 , 3*segLen/2 + width);-
1152 ppt = pt;-
1153 DARK;-
1154 LINETO(width,0);-
1155 LINETO(width,-width);-
1156 LIGHT;-
1157 LINETO(0,-width);-
1158 LINETO(0,0);-
1159 break;
never executed: break;
0
1160 default :
never executed: default :
0
1161 qWarning("QLCDNumber::drawSegment: (%s) Illegal segment id: %d\n",-
1162 q->objectName().toLocal8Bit().constData(), segmentNo);-
1163 }
never executed: end of block
0
1164-
1165#undef LINETO-
1166#undef LIGHT-
1167#undef DARK-
1168}
never executed: end of block
0
1169-
1170-
1171-
1172/*!-
1173 \property QLCDNumber::segmentStyle-
1174 \brief the style of the LCDNumber-
1175-
1176 \table-
1177 \header \li Style \li Result-
1178 \row \li \c Outline-
1179 \li Produces raised segments filled with the background color-
1180 \row \li \c Filled-
1181 (this is the default).-
1182 \li Produces raised segments filled with the foreground color.-
1183 \row \li \c Flat-
1184 \li Produces flat segments filled with the foreground color.-
1185 \endtable-
1186-
1187 \c Outline and \c Filled will additionally use-
1188 QPalette::light() and QPalette::dark() for shadow effects.-
1189*/-
1190void QLCDNumber::setSegmentStyle(SegmentStyle s)-
1191{-
1192 Q_D(QLCDNumber);-
1193 d->fill = (s == Flat || s == Filled);
s == FlatDescription
TRUEnever evaluated
FALSEnever evaluated
s == FilledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1194 d->shadow = (s == Outline || s == Filled);
s == OutlineDescription
TRUEnever evaluated
FALSEnever evaluated
s == FilledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1195 update();-
1196}
never executed: end of block
0
1197-
1198QLCDNumber::SegmentStyle QLCDNumber::segmentStyle() const-
1199{-
1200 Q_D(const QLCDNumber);-
1201 Q_ASSERT(d->fill || d->shadow);-
1202 if (!d->fill && d->shadow)
!d->fillDescription
TRUEnever evaluated
FALSEnever evaluated
d->shadowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1203 return Outline;
never executed: return Outline;
0
1204 if (d->fill && d->shadow)
d->fillDescription
TRUEnever evaluated
FALSEnever evaluated
d->shadowDescription
TRUEnever evaluated
FALSEnever evaluated
0
1205 return Filled;
never executed: return Filled;
0
1206 return Flat;
never executed: return Flat;
0
1207}-
1208-
1209-
1210/*!\reimp-
1211*/-
1212QSize QLCDNumber::sizeHint() const-
1213{-
1214 return QSize(10 + 9 * (digitCount() + (smallDecimalPoint() ? 0 : 1)), 23);
never executed: return QSize(10 + 9 * (digitCount() + (smallDecimalPoint() ? 0 : 1)), 23);
0
1215}-
1216-
1217/*! \reimp */-
1218bool QLCDNumber::event(QEvent *e)-
1219{-
1220 return QFrame::event(e);
never executed: return QFrame::event(e);
0
1221}-
1222-
1223QT_END_NAMESPACE-
1224-
1225#include "moc_qlcdnumber.cpp"-
1226-
1227#endif // QT_NO_LCDNUMBER-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9