1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the widgets module of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
29
#include "qlcdnumber.h"
30
#ifndef QT_NO_LCDNUMBER
31
#include "qbitarray.h"
33
#include "private/qframe_p.h"
35
class QLCDNumberPrivate : public QFramePrivate
37
Q_DECLARE_PUBLIC(QLCDNumber)
40
void internalSetString(const QString& s);
41
void drawString(const QString& s, QPainter &, QBitArray * = 0, bool = true);
42
//void drawString(const QString &, QPainter &, QBitArray * = 0) const;
43
void drawDigit(const QPoint &, QPainter &, int, char, char = ' ');
44
void drawSegment(const QPoint &, char, QPainter &, int, bool = false);
57
\class QLCDNumber qlcdnumber.h
59
\brief The QLCDNumber widget displays a number with LCD-like digits.
64
It can display a number in just about any size. It can display
65
decimal, hexadecimal, octal or binary numbers. It is easy to
66
connect to data sources using the display() slot, which is
67
overloaded to take any of five argument types.
69
There are also slots to change the base with setMode() and the
70
decimal point with setSmallDecimalPoint().
72
QLCDNumber emits the overflow() signal when it is asked to display
73
something beyond its range. The range is set by setNumDigits(),
74
but setSmallDecimalPoint() also influences it. If the display is
75
set to hexadecimal, octal or binary, the integer equivalent of the
78
These digits and other symbols can be shown: 0/O, 1, 2, 3, 4, 5/S,
79
6, 7, 8, 9/g, minus, decimal point, A, B, C, D, E, F, h, H, L, o,
80
P, r, u, U, Y, colon, degree sign (which is specified as single
81
quote in the string) and space. QLCDNumber substitutes spaces for
84
It is not possible to retrieve the contents of a QLCDNumber
85
object, although you can retrieve the numeric value with value().
86
If you really need the text, we recommend that you connect the
87
signals that feed the display() slot to another slot as well and
88
store the value there.
90
Incidentally, QLCDNumber is the very oldest part of Qt, tracing
91
its roots back to a BASIC program on the \link
92
http://www.nvg.ntnu.no/sinclair/computers/zxspectrum/zxspectrum.htm
93
Sinclair Spectrum\endlink.
95
\inlineimage qlcdnum-m.png Screenshot in Motif style
96
\inlineimage qlcdnum-w.png Screenshot in Windows style
102
\enum QLCDNumber::Mode
104
This type determines how numbers are shown.
106
\value Hex Hexadecimal
115
If the display is set to hexadecimal, octal or binary, the integer
116
equivalent of the value is displayed.
120
\enum QLCDNumber::SegmentStyle
122
This type determines the visual appearance of the QLCDNumber
125
\value Outline gives raised segments filled with the background brush.
126
\value Filled gives raised segments filled with the foreground brush.
127
\value Flat gives flat segments filled with the foreground brush.
133
\fn void QLCDNumber::overflow()
135
This signal is emitted whenever the QLCDNumber is asked to display
136
a too-large number or a too-long string.
138
It is never emitted by setNumDigits().
142
static QString int2string(int num, int base, int ndigits, bool *oflow)
153
case QLCDNumber::Hex:
154
s.sprintf("%*x", ndigits, num);
156
case QLCDNumber::Dec:
157
s.sprintf("%*i", ndigits, num);
159
case QLCDNumber::Oct:
160
s.sprintf("%*o", ndigits, num);
162
case QLCDNumber::Bin:
170
*--p = (char)((n&1)+'0');
177
s += QString::fromLatin1(p);
182
for (int i=0; i<(int)s.length(); i++) {
194
*oflow = (int)s.length() > ndigits;
199
static QString double2string(double num, int base, int ndigits, bool *oflow)
202
if (base != QLCDNumber::Dec) {
203
bool of = num >= 2147483648.0 || num < -2147483648.0;
204
if (of) { // oops, integer overflow
209
s = int2string((int)num, base, ndigits, 0);
210
} else { // decimal base
213
s.sprintf("%*.*g", ndigits, nd, num);
214
int i = s.indexOf('e');
215
if (i > 0 && s[i+1]=='+') {
219
} while (nd-- && (int)s.length() > ndigits);
222
*oflow = (int)s.length() > ndigits;
227
static const char *getSegments(char ch) // gets list of segments for ch
229
static const char segments[30][8] =
230
{ { 0, 1, 2, 4, 5, 6,99, 0}, // 0 0 / O
231
{ 2, 5,99, 0, 0, 0, 0, 0}, // 1 1
232
{ 0, 2, 3, 4, 6,99, 0, 0}, // 2 2
233
{ 0, 2, 3, 5, 6,99, 0, 0}, // 3 3
234
{ 1, 2, 3, 5,99, 0, 0, 0}, // 4 4
235
{ 0, 1, 3, 5, 6,99, 0, 0}, // 5 5 / S
236
{ 0, 1, 3, 4, 5, 6,99, 0}, // 6 6
237
{ 0, 2, 5,99, 0, 0, 0, 0}, // 7 7
238
{ 0, 1, 2, 3, 4, 5, 6,99}, // 8 8
239
{ 0, 1, 2, 3, 5, 6,99, 0}, // 9 9 / g
240
{ 3,99, 0, 0, 0, 0, 0, 0}, // 10 -
241
{ 7,99, 0, 0, 0, 0, 0, 0}, // 11 .
242
{ 0, 1, 2, 3, 4, 5,99, 0}, // 12 A
243
{ 1, 3, 4, 5, 6,99, 0, 0}, // 13 B
244
{ 0, 1, 4, 6,99, 0, 0, 0}, // 14 C
245
{ 2, 3, 4, 5, 6,99, 0, 0}, // 15 D
246
{ 0, 1, 3, 4, 6,99, 0, 0}, // 16 E
247
{ 0, 1, 3, 4,99, 0, 0, 0}, // 17 F
248
{ 1, 3, 4, 5,99, 0, 0, 0}, // 18 h
249
{ 1, 2, 3, 4, 5,99, 0, 0}, // 19 H
250
{ 1, 4, 6,99, 0, 0, 0, 0}, // 20 L
251
{ 3, 4, 5, 6,99, 0, 0, 0}, // 21 o
252
{ 0, 1, 2, 3, 4,99, 0, 0}, // 22 P
253
{ 3, 4,99, 0, 0, 0, 0, 0}, // 23 r
254
{ 4, 5, 6,99, 0, 0, 0, 0}, // 24 u
255
{ 1, 2, 4, 5, 6,99, 0, 0}, // 25 U
256
{ 1, 2, 3, 5, 6,99, 0, 0}, // 26 Y
257
{ 8, 9,99, 0, 0, 0, 0, 0}, // 27 :
258
{ 0, 1, 2, 3,99, 0, 0, 0}, // 28 '
259
{99, 0, 0, 0, 0, 0, 0, 0} }; // 29 empty
261
if (ch >= '0' && ch <= '9')
262
return segments[ch - '0'];
263
if (ch >= 'A' && ch <= 'F')
264
return segments[ch - 'A' + 12];
265
if (ch >= 'a' && ch <= 'f')
266
return segments[ch - 'a' + 12];
316
Constructs an LCD number, sets the number of digits to 5, the base
317
to decimal, the decimal point mode to 'small' and the frame style
318
to a raised box. The segmentStyle() is set to \c Outline.
320
The \a parent and \a name arguments are passed to the QFrame
323
\sa setNumDigits(), setSmallDecimalPoint()
326
QLCDNumber::QLCDNumber(QWidget *parent, const char *name)
327
: QFrame(*new QLCDNumberPrivate, parent)
337
Constructs an LCD number, sets the number of digits to \a
338
numDigits, the base to decimal, the decimal point mode to 'small'
339
and the frame style to a raised box. The segmentStyle() is set to
342
The \a parent and \a name arguments are passed to the QFrame
345
\sa setNumDigits(), setSmallDecimalPoint()
348
QLCDNumber::QLCDNumber(uint numDigits, QWidget *parent, const char *name)
349
: QFrame(*new QLCDNumberPrivate, parent)
353
d->ndigits = numDigits;
359
Constructs an LCD number, sets the number of digits to 5, the base
360
to decimal, the decimal point mode to 'small' and the frame style
361
to a raised box. The segmentStyle() is set to \c Outline.
363
The \a parent argument is passed to the QFrame constructor.
365
\sa setNumDigits(), setSmallDecimalPoint()
368
QLCDNumber::QLCDNumber(QWidget *parent)
369
: QFrame(*new QLCDNumberPrivate, parent)
378
Constructs an LCD number, sets the number of digits to \a
379
numDigits, the base to decimal, the decimal point mode to 'small'
380
and the frame style to a raised box. The segmentStyle() is set to
383
The \a parent argument is passed to the QFrame constructor.
385
\sa setNumDigits(), setSmallDecimalPoint()
388
QLCDNumber::QLCDNumber(uint numDigits, QWidget *parent)
389
: QFrame(*new QLCDNumberPrivate, parent)
392
d->ndigits = numDigits;
396
void QLCDNumberPrivate::init()
400
q->setFrameStyle(QFrame::Box | QFrame::Raised);
402
base = QLCDNumber::Dec;
404
q->setNumDigits(ndigits);
405
q->setSegmentStyle(QLCDNumber::Outline);
406
q->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
410
Destroys the LCD number.
413
QLCDNumber::~QLCDNumber()
419
\property QLCDNumber::numDigits
420
\brief the current number of digits displayed
422
Corresponds to the current number of digits. If \l
423
QLCDNumber::smallDecimalPoint is false, the decimal point occupies
426
\sa smallDecimalPoint
429
void QLCDNumber::setNumDigits(int numDigits)
432
if (numDigits > 99) {
433
qWarning("QLCDNumber::setNumDigits: (%s) Max 99 digits allowed",
434
objectName().toLocal8Bit().constData());
438
qWarning("QLCDNumber::setNumDigits: (%s) Min 0 digits allowed",
439
objectName().toLocal8Bit().constData());
442
if (d->digitStr.isNull()) { // from constructor
443
d->ndigits = numDigits;
444
d->digitStr.fill(' ', d->ndigits);
445
d->points.fill(0, d->ndigits);
446
d->digitStr[d->ndigits - 1] = '0'; // "0" is the default number
448
bool doDisplay = d->ndigits == 0;
449
if (numDigits == d->ndigits) // no change
453
if (numDigits > d->ndigits) { // expand
454
dif = numDigits - d->ndigits;
457
d->digitStr.insert(0, buf);
458
d->points.resize(numDigits);
459
for (i=numDigits-1; i>=dif; i--)
460
d->points.setBit(i, d->points.testBit(i-dif));
461
for (i=0; i<dif; i++)
462
d->points.clearBit(i);
464
dif = d->ndigits - numDigits;
465
d->digitStr = d->digitStr.right(numDigits);
466
QBitArray tmpPoints = d->points;
467
d->points.resize(numDigits);
468
for (i=0; i<(int)numDigits; i++)
469
d->points.setBit(i, tmpPoints.testBit(i+dif));
471
d->ndigits = numDigits;
478
int QLCDNumber::numDigits() const
480
Q_D(const QLCDNumber);
487
Returns true if \a num is too big to be displayed in its entirety;
488
otherwise returns false.
490
\sa display(), numDigits(), smallDecimalPoint()
493
bool QLCDNumber::checkOverflow(int num) const
495
Q_D(const QLCDNumber);
497
int2string(num, d->base, d->ndigits, &of);
503
Returns true if \a num is too big to be displayed in its entirety;
504
otherwise returns false.
506
\sa display(), numDigits(), smallDecimalPoint()
509
bool QLCDNumber::checkOverflow(double num) const
511
Q_D(const QLCDNumber);
513
double2string(num, d->base, d->ndigits, &of);
519
\property QLCDNumber::mode
520
\brief the current display mode (number base)
522
Corresponds to the current display mode, which is one of \c Bin,
523
\c Oct, \c Dec (the default) and \c Hex. \c Dec mode can display
524
floating point values, the other modes display the integer
527
\sa smallDecimalPoint(), setHexMode(), setDecMode(), setOctMode(), setBinMode()
530
QLCDNumber::Mode QLCDNumber::mode() const
532
Q_D(const QLCDNumber);
533
return (QLCDNumber::Mode) d->base;
536
void QLCDNumber::setMode(Mode m)
545
\property QLCDNumber::value
546
\brief the displayed value
548
This property corresponds to the current value displayed by the
551
If the displayed value is not a number, the property has a value
555
double QLCDNumber::value() const
557
Q_D(const QLCDNumber);
564
Displays the number \a num.
566
void QLCDNumber::display(double num)
571
QString s = double2string(d->val, d->base, d->ndigits, &of);
575
d->internalSetString(s);
579
\property QLCDNumber::intValue
580
\brief the displayed value rounded to the nearest integer
582
This property corresponds to the nearest integer to the current
583
value displayed by the LCDNumber. This is the value used for
584
hexadecimal, octal and binary modes.
586
If the displayed value is not a number, the property has a value
589
int QLCDNumber::intValue() const
591
Q_D(const QLCDNumber);
592
return qRound(d->val);
599
Displays the number \a num.
601
void QLCDNumber::display(int num)
604
d->val = (double)num;
606
QString s = int2string(num, d->base, d->ndigits, &of);
610
d->internalSetString(s);
615
Displays the number represented by the string \a s.
617
This version of the function disregards mode() and
620
These digits and other symbols can be shown: 0/O, 1, 2, 3, 4, 5/S,
621
6, 7, 8, 9/g, minus, decimal point, A, B, C, D, E, F, h, H, L, o,
622
P, r, u, U, Y, colon, degree sign (which is specified as single
623
quote in the string) and space. QLCDNumber substitutes spaces for
627
void QLCDNumber::display(const QString &s)
632
double v = s.toDouble(&ok);
635
d->internalSetString(s);
639
Calls setMode(Hex). Provided for convenience (e.g. for
640
connecting buttons to it).
642
\sa setMode(), setDecMode(), setOctMode(), setBinMode(), mode()
645
void QLCDNumber::setHexMode()
652
Calls setMode(Dec). Provided for convenience (e.g. for
653
connecting buttons to it).
655
\sa setMode(), setHexMode(), setOctMode(), setBinMode(), mode()
658
void QLCDNumber::setDecMode()
665
Calls setMode(Oct). Provided for convenience (e.g. for
666
connecting buttons to it).
668
\sa setMode(), setHexMode(), setDecMode(), setBinMode(), mode()
671
void QLCDNumber::setOctMode()
678
Calls setMode(Bin). Provided for convenience (e.g. for
679
connecting buttons to it).
681
\sa setMode(), setHexMode(), setDecMode(), setOctMode(), mode()
684
void QLCDNumber::setBinMode()
691
\property QLCDNumber::smallDecimalPoint
692
\brief the style of the decimal point
694
If true the decimal point is drawn between two digit positions.
695
Otherwise it occupies a digit position of its own, i.e. is drawn
696
in a digit position. The default is false.
698
The inter-digit space is made slightly wider when the decimal
699
point is drawn between the digits.
704
void QLCDNumber::setSmallDecimalPoint(bool b)
711
bool QLCDNumber::smallDecimalPoint() const
713
Q_D(const QLCDNumber);
714
return d->smallPoint;
723
void QLCDNumber::paintEvent(QPaintEvent *)
729
d->drawString(d->digitStr, p, &d->points, false);
731
d->drawString(d->digitStr, p, 0, false);
735
void QLCDNumberPrivate::internalSetString(const QString& s)
740
int len = s.length();
741
QBitArray newPoints(ndigits);
747
buffer = s.right(ndigits).rightJustified(ndigits, ' ');
750
bool lastWasPoint = true;
751
newPoints.clearBit(0);
752
for (i=0; i<len; i++) {
754
if (lastWasPoint) { // point already set for digit?
755
if (index == ndigits - 1) // no more digits
758
buffer[index] = ' '; // 2 points in a row, add space
760
newPoints.setBit(index); // set decimal point
763
if (index == ndigits - 1)
766
buffer[index] = s[i];
767
newPoints.clearBit(index); // decimal point default off
768
lastWasPoint = false;
771
if (index < ((int) ndigits) - 1) {
772
for(i=index; i>=0; i--) {
773
buffer[ndigits - 1 - index + i] = buffer[i];
774
newPoints.setBit(ndigits - 1 - index + i,
775
newPoints.testBit(i));
777
for(i=0; i<ndigits-index-1; i++) {
779
newPoints.clearBit(i);
784
if (buffer == digitStr)
797
void QLCDNumberPrivate::drawString(const QString &s, QPainter &p,
798
QBitArray *newPoints, bool newString)
803
int digitSpace = smallPoint ? 2 : 1;
804
int xSegLen = q->width()*5/(ndigits*(5 + digitSpace) + digitSpace);
805
int ySegLen = q->height()*5/12;
806
int segLen = ySegLen > xSegLen ? xSegLen : ySegLen;
807
int xAdvance = segLen*(5 + digitSpace)/5;
808
int xOffset = (q->width() - ndigits*xAdvance + segLen/5)/2;
809
int yOffset = (q->height() - segLen*2)/2;
811
for (int i=0; i<ndigits; i++) {
812
pos = QPoint(xOffset + xAdvance*i, yOffset);
814
drawDigit(pos, p, segLen, s[i].toLatin1(), digitStr[i].toLatin1());
816
drawDigit(pos, p, segLen, s[i].toLatin1());
818
char newPoint = newPoints->testBit(i) ? '.' : ' ';
820
char oldPoint = points.testBit(i) ? '.' : ' ';
821
drawDigit(pos, p, segLen, newPoint, oldPoint);
823
drawDigit(pos, p, segLen, newPoint);
829
digitStr.truncate(ndigits);
840
void QLCDNumberPrivate::drawDigit(const QPoint &pos, QPainter &p, int segLen,
841
char newCh, char oldCh)
843
// Draws and/or erases segments to change display of a single digit
844
// from oldCh to newCh
846
char updates[18][2]; // can hold 2 times number of segments, only
847
// first 9 used if segment table is correct
853
const char erase = 0;
855
const char leaveAlone = 2;
857
segs = getSegments(oldCh);
858
for (nErases=0; segs[nErases] != 99; nErases++) {
859
updates[nErases][0] = erase; // get segments to erase to
860
updates[nErases][1] = segs[nErases]; // remove old char
863
segs = getSegments(newCh);
864
for(i = 0 ; segs[i] != 99 ; i++) {
865
for (j=0; j<nErases; j++)
866
if (segs[i] == updates[j][1]) { // same segment ?
867
updates[j][0] = leaveAlone; // yes, already on screen
870
if (j == nErases) { // if not already on screen
871
updates[nUpdates][0] = draw;
872
updates[nUpdates][1] = segs[i];
876
for (i=0; i<nUpdates; i++) {
877
if (updates[i][0] == draw)
878
drawSegment(pos, updates[i][1], p, segLen);
879
if (updates[i][0] == erase)
880
drawSegment(pos, updates[i][1], p, segLen, true);
885
static void addPoint(QPolygon &a, const QPoint &p)
896
void QLCDNumberPrivate::drawSegment(const QPoint &pos, char segmentNo, QPainter &p,
897
int segLen, bool erase)
902
int width = segLen/5;
904
const QPalette &pal = q->palette();
905
QColor lightColor,darkColor,fgColor;
907
lightColor = pal.color(q->backgroundRole());
908
darkColor = lightColor;
909
fgColor = lightColor;
911
lightColor = pal.light().color();
912
darkColor = pal.dark().color();
913
fgColor = pal.color(q->foregroundRole());
917
#define LINETO(X,Y) addPoint(a, QPoint(pt.x() + (X),pt.y() + (Y)))
923
//The following is an exact copy of the switch below.
924
//don't make any changes here
929
LINETO(segLen - 1,0);
931
LINETO(segLen - width - 1,width);
941
LINETO(width,segLen - width/2 - 2);
942
LINETO(0,segLen - 2);
947
pt += QPoint(segLen - 1 , 1);
950
LINETO(0,segLen - 2);
951
LINETO(-width,segLen - width/2 - 2);
953
LINETO(-width,width);
957
pt += QPoint(0 , segLen);
960
LINETO(width,-width/2);
961
LINETO(segLen - width - 1,-width/2);
962
LINETO(segLen - 1,0);
964
if (width & 1) { // adjust for integer division error
965
LINETO(segLen - width - 3,width/2 + 1);
966
LINETO(width + 2,width/2 + 1);
968
LINETO(segLen - width - 1,width/2);
969
LINETO(width,width/2);
974
pt += QPoint(0 , segLen + 1);
977
LINETO(width,width/2);
979
LINETO(width,segLen - width - 2);
980
LINETO(0,segLen - 2);
985
pt += QPoint(segLen - 1 , segLen + 1);
988
LINETO(0,segLen - 2);
989
LINETO(-width,segLen - width - 2);
991
LINETO(-width,width/2);
995
pt += QPoint(0 , segLen*2);
998
LINETO(width,-width);
999
LINETO(segLen - width - 1,-width);
1000
LINETO(segLen - 1,0);
1005
if (smallPoint) // if smallpoint place'.' between other digits
1006
pt += QPoint(segLen + width/2 , segLen*2);
1008
pt += QPoint(segLen/2 , segLen*2);
1012
LINETO(width,-width);
1018
pt += QPoint(segLen/2 - width/2 + 1 , segLen/2 + width);
1022
LINETO(width,-width);
1028
pt += QPoint(segLen/2 - width/2 + 1 , 3*segLen/2 + width);
1032
LINETO(width,-width);
1038
qWarning("QLCDNumber::drawSegment: (%s) Internal error."
1039
" Illegal segment id: %d\n",
1040
q->objectName().toLocal8Bit().constData(), segmentNo);
1044
p.setBrush(fgColor);
1046
p.setBrush(Qt::NoBrush);
1054
#define LINETO(X,Y) p.drawLine(ppt.x(), ppt.y(), pt.x()+(X), pt.y()+(Y)); \
1055
ppt = QPoint(pt.x()+(X), pt.y()+(Y))
1056
#define LIGHT p.setPen(lightColor)
1057
#define DARK p.setPen(darkColor)
1059
switch (segmentNo) {
1063
LINETO(segLen - 1,0);
1065
LINETO(segLen - width - 1,width);
1066
LINETO(width,width);
1073
LINETO(width,width);
1075
LINETO(width,segLen - width/2 - 2);
1076
LINETO(0,segLen - 2);
1081
pt += QPoint(segLen - 1 , 1);
1084
LINETO(0,segLen - 2);
1085
LINETO(-width,segLen - width/2 - 2);
1087
LINETO(-width,width);
1091
pt += QPoint(0 , segLen);
1094
LINETO(width,-width/2);
1095
LINETO(segLen - width - 1,-width/2);
1096
LINETO(segLen - 1,0);
1098
if (width & 1) { // adjust for integer division error
1099
LINETO(segLen - width - 3,width/2 + 1);
1100
LINETO(width + 2,width/2 + 1);
1102
LINETO(segLen - width - 1,width/2);
1103
LINETO(width,width/2);
1108
pt += QPoint(0 , segLen + 1);
1111
LINETO(width,width/2);
1113
LINETO(width,segLen - width - 2);
1114
LINETO(0,segLen - 2);
1119
pt += QPoint(segLen - 1 , segLen + 1);
1122
LINETO(0,segLen - 2);
1123
LINETO(-width,segLen - width - 2);
1125
LINETO(-width,width/2);
1129
pt += QPoint(0 , segLen*2);
1132
LINETO(width,-width);
1133
LINETO(segLen - width - 1,-width);
1134
LINETO(segLen - 1,0);
1139
if (smallPoint) // if smallpoint place'.' between other digits
1140
pt += QPoint(segLen + width/2 , segLen*2);
1142
pt += QPoint(segLen/2 , segLen*2);
1146
LINETO(width,-width);
1152
pt += QPoint(segLen/2 - width/2 + 1 , segLen/2 + width);
1156
LINETO(width,-width);
1162
pt += QPoint(segLen/2 - width/2 + 1 , 3*segLen/2 + width);
1166
LINETO(width,-width);
1172
qWarning("QLCDNumber::drawSegment: (%s) Internal error."
1173
" Illegal segment id: %d\n",
1174
q->objectName().toLocal8Bit().constData(), segmentNo);
1185
\property QLCDNumber::segmentStyle
1186
\brief the style of the LCDNumber
1189
\header \i Style \i Result
1191
\i Produces raised segments filled with the background color
1192
(this is the default).
1194
\i Produces raised segments filled with the foreground color.
1196
\i Produces flat segments filled with the foreground color.
1199
\c Outline and \c Filled will additionally use
1200
QPalette::light() and QPalette::dark() for shadow effects.
1202
void QLCDNumber::setSegmentStyle(SegmentStyle s)
1205
d->fill = (s == Flat || s == Filled);
1206
d->shadow = (s == Outline || s == Filled);
1210
QLCDNumber::SegmentStyle QLCDNumber::segmentStyle() const
1212
Q_D(const QLCDNumber);
1213
Q_ASSERT(d->fill || d->shadow);
1214
if (!d->fill && d->shadow)
1216
if (d->fill && d->shadow)
1224
QSize QLCDNumber::sizeHint() const
1226
return QSize(10 + 9 * (numDigits() + (smallDecimalPoint() ? 0 : 1)), 23);
1230
#endif // QT_NO_LCDNUMBER