

Definition at line 30 of file qlcdnumber.cpp.
Public Member Functions | |
| void | init () |
| void | internalSetString (const QString &s) |
| void | drawString (const QString &s, QPainter &, QBitArray *=0, bool=true) |
| void | drawDigit (const QPoint &, QPainter &, int, char, char= ' ') |
| void | drawSegment (const QPoint &, char, QPainter &, int, bool=false) |
Public Attributes | |
| int | ndigits |
| double | val |
| uint | base: 2 |
| uint | smallPoint: 1 |
| uint | fill: 1 |
| uint | shadow: 1 |
| QString | digitStr |
| QBitArray | points |
| void QLCDNumberPrivate::init | ( | ) |
Definition at line 401 of file qlcdnumber.cpp.
References base, QFrame::Box, QLCDNumber::Dec, QSizePolicy::Minimum, ndigits, QLCDNumber::Outline, QFrame::Raised, smallPoint, and val.
00402 { 00403 Q_Q(QLCDNumber); 00404 00405 q->setFrameStyle(QFrame::Box | QFrame::Raised); 00406 val = 0; 00407 base = QLCDNumber::Dec; 00408 smallPoint = false; 00409 q->setNumDigits(ndigits); 00410 q->setSegmentStyle(QLCDNumber::Outline); 00411 q->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); 00412 }
| void QLCDNumberPrivate::internalSetString | ( | const QString & | s | ) |
Definition at line 740 of file qlcdnumber.cpp.
References buffer, QBitArray::clearBit(), digitStr, i, index, len, ndigits, points, s, QBitArray::setBit(), smallPoint, and QBitArray::testBit().
00741 { 00742 Q_Q(QLCDNumber); 00743 QString buffer; 00744 int i; 00745 int len = s.length(); 00746 QBitArray newPoints(ndigits); 00747 00748 if (!smallPoint) { 00749 if (len == ndigits) 00750 buffer = s; 00751 else 00752 buffer = s.right(ndigits).rightJustified(ndigits, QLatin1Char(' ')); 00753 } else { 00754 int index = -1; 00755 bool lastWasPoint = true; 00756 newPoints.clearBit(0); 00757 for (i=0; i<len; i++) { 00758 if (s[i] == QLatin1Char('.')) { 00759 if (lastWasPoint) { // point already set for digit? 00760 if (index == ndigits - 1) // no more digits 00761 break; 00762 index++; 00763 buffer[index] = QLatin1Char(' '); // 2 points in a row, add space 00764 } 00765 newPoints.setBit(index); // set decimal point 00766 lastWasPoint = true; 00767 } else { 00768 if (index == ndigits - 1) 00769 break; 00770 index++; 00771 buffer[index] = s[i]; 00772 newPoints.clearBit(index); // decimal point default off 00773 lastWasPoint = false; 00774 } 00775 } 00776 if (index < ((int) ndigits) - 1) { 00777 for(i=index; i>=0; i--) { 00778 buffer[ndigits - 1 - index + i] = buffer[i]; 00779 newPoints.setBit(ndigits - 1 - index + i, 00780 newPoints.testBit(i)); 00781 } 00782 for(i=0; i<ndigits-index-1; i++) { 00783 buffer[i] = QLatin1Char(' '); 00784 newPoints.clearBit(i); 00785 } 00786 } 00787 } 00788 00789 if (buffer == digitStr) 00790 return; 00791 00792 digitStr = buffer; 00793 if (smallPoint) 00794 points = newPoints; 00795 q->update(); 00796 }
Here is the call graph for this function:

Definition at line 802 of file qlcdnumber.cpp.
References digitStr, drawDigit(), i, ndigits, p, points, s, smallPoint, QBitArray::testBit(), and QString::truncate().
00804 { 00805 Q_Q(QLCDNumber); 00806 QPoint pos; 00807 00808 int digitSpace = smallPoint ? 2 : 1; 00809 int xSegLen = q->width()*5/(ndigits*(5 + digitSpace) + digitSpace); 00810 int ySegLen = q->height()*5/12; 00811 int segLen = ySegLen > xSegLen ? xSegLen : ySegLen; 00812 int xAdvance = segLen*(5 + digitSpace)/5; 00813 int xOffset = (q->width() - ndigits*xAdvance + segLen/5)/2; 00814 int yOffset = (q->height() - segLen*2)/2; 00815 00816 for (int i=0; i<ndigits; i++) { 00817 pos = QPoint(xOffset + xAdvance*i, yOffset); 00818 if (newString) 00819 drawDigit(pos, p, segLen, s[i].toLatin1(), digitStr[i].toLatin1()); 00820 else 00821 drawDigit(pos, p, segLen, s[i].toLatin1()); 00822 if (newPoints) { 00823 char newPoint = newPoints->testBit(i) ? '.' : ' '; 00824 if (newString) { 00825 char oldPoint = points.testBit(i) ? '.' : ' '; 00826 drawDigit(pos, p, segLen, newPoint, oldPoint); 00827 } else { 00828 drawDigit(pos, p, segLen, newPoint); 00829 } 00830 } 00831 } 00832 if (newString) { 00833 digitStr = s; 00834 digitStr.truncate(ndigits); 00835 if (newPoints) 00836 points = *newPoints; 00837 } 00838 }
Here is the call graph for this function:

Definition at line 845 of file qlcdnumber.cpp.
References drawSegment(), getSegments(), i, j, and p.
Referenced by drawString().
00847 { 00848 // Draws and/or erases segments to change display of a single digit 00849 // from oldCh to newCh 00850 00851 char updates[18][2]; // can hold 2 times number of segments, only 00852 // first 9 used if segment table is correct 00853 int nErases; 00854 int nUpdates; 00855 const char *segs; 00856 int i,j; 00857 00858 const char erase = 0; 00859 const char draw = 1; 00860 const char leaveAlone = 2; 00861 00862 segs = getSegments(oldCh); 00863 for (nErases=0; segs[nErases] != 99; nErases++) { 00864 updates[nErases][0] = erase; // get segments to erase to 00865 updates[nErases][1] = segs[nErases]; // remove old char 00866 } 00867 nUpdates = nErases; 00868 segs = getSegments(newCh); 00869 for(i = 0 ; segs[i] != 99 ; i++) { 00870 for (j=0; j<nErases; j++) 00871 if (segs[i] == updates[j][1]) { // same segment ? 00872 updates[j][0] = leaveAlone; // yes, already on screen 00873 break; 00874 } 00875 if (j == nErases) { // if not already on screen 00876 updates[nUpdates][0] = draw; 00877 updates[nUpdates][1] = segs[i]; 00878 nUpdates++; 00879 } 00880 } 00881 for (i=0; i<nUpdates; i++) { 00882 if (updates[i][0] == draw) 00883 drawSegment(pos, updates[i][1], p, segLen); 00884 if (updates[i][0] == erase) 00885 drawSegment(pos, updates[i][1], p, segLen, true); 00886 } 00887 }
Here is the call graph for this function:

Definition at line 901 of file qlcdnumber.cpp.
References a, QBrush::color(), QPalette::color(), DARK, QPalette::dark(), fill, QPalette::light(), LIGHT, LINETO, Qt::NoBrush, p, qWarning(), shadow, smallPoint, and width.
Referenced by drawDigit().
00903 { 00904 Q_Q(QLCDNumber); 00905 QPoint ppt; 00906 QPoint pt = pos; 00907 int width = segLen/5; 00908 00909 const QPalette &pal = q->palette(); 00910 QColor lightColor,darkColor,fgColor; 00911 if (erase){ 00912 lightColor = pal.color(q->backgroundRole()); 00913 darkColor = lightColor; 00914 fgColor = lightColor; 00915 } else { 00916 lightColor = pal.light().color(); 00917 darkColor = pal.dark().color(); 00918 fgColor = pal.color(q->foregroundRole()); 00919 } 00920 00921 00922 #define LINETO(X,Y) addPoint(a, QPoint(pt.x() + (X),pt.y() + (Y))) 00923 #define LIGHT 00924 #define DARK 00925 00926 if (fill) { 00927 QPolygon a(0); 00928 //The following is an exact copy of the switch below. 00929 //don't make any changes here 00930 switch (segmentNo) { 00931 case 0 : 00932 ppt = pt; 00933 LIGHT; 00934 LINETO(segLen - 1,0); 00935 DARK; 00936 LINETO(segLen - width - 1,width); 00937 LINETO(width,width); 00938 LINETO(0,0); 00939 break; 00940 case 1 : 00941 pt += QPoint(0 , 1); 00942 ppt = pt; 00943 LIGHT; 00944 LINETO(width,width); 00945 DARK; 00946 LINETO(width,segLen - width/2 - 2); 00947 LINETO(0,segLen - 2); 00948 LIGHT; 00949 LINETO(0,0); 00950 break; 00951 case 2 : 00952 pt += QPoint(segLen - 1 , 1); 00953 ppt = pt; 00954 DARK; 00955 LINETO(0,segLen - 2); 00956 LINETO(-width,segLen - width/2 - 2); 00957 LIGHT; 00958 LINETO(-width,width); 00959 LINETO(0,0); 00960 break; 00961 case 3 : 00962 pt += QPoint(0 , segLen); 00963 ppt = pt; 00964 LIGHT; 00965 LINETO(width,-width/2); 00966 LINETO(segLen - width - 1,-width/2); 00967 LINETO(segLen - 1,0); 00968 DARK; 00969 if (width & 1) { // adjust for integer division error 00970 LINETO(segLen - width - 3,width/2 + 1); 00971 LINETO(width + 2,width/2 + 1); 00972 } else { 00973 LINETO(segLen - width - 1,width/2); 00974 LINETO(width,width/2); 00975 } 00976 LINETO(0,0); 00977 break; 00978 case 4 : 00979 pt += QPoint(0 , segLen + 1); 00980 ppt = pt; 00981 LIGHT; 00982 LINETO(width,width/2); 00983 DARK; 00984 LINETO(width,segLen - width - 2); 00985 LINETO(0,segLen - 2); 00986 LIGHT; 00987 LINETO(0,0); 00988 break; 00989 case 5 : 00990 pt += QPoint(segLen - 1 , segLen + 1); 00991 ppt = pt; 00992 DARK; 00993 LINETO(0,segLen - 2); 00994 LINETO(-width,segLen - width - 2); 00995 LIGHT; 00996 LINETO(-width,width/2); 00997 LINETO(0,0); 00998 break; 00999 case 6 : 01000 pt += QPoint(0 , segLen*2); 01001 ppt = pt; 01002 LIGHT; 01003 LINETO(width,-width); 01004 LINETO(segLen - width - 1,-width); 01005 LINETO(segLen - 1,0); 01006 DARK; 01007 LINETO(0,0); 01008 break; 01009 case 7 : 01010 if (smallPoint) // if smallpoint place'.' between other digits 01011 pt += QPoint(segLen + width/2 , segLen*2); 01012 else 01013 pt += QPoint(segLen/2 , segLen*2); 01014 ppt = pt; 01015 DARK; 01016 LINETO(width,0); 01017 LINETO(width,-width); 01018 LIGHT; 01019 LINETO(0,-width); 01020 LINETO(0,0); 01021 break; 01022 case 8 : 01023 pt += QPoint(segLen/2 - width/2 + 1 , segLen/2 + width); 01024 ppt = pt; 01025 DARK; 01026 LINETO(width,0); 01027 LINETO(width,-width); 01028 LIGHT; 01029 LINETO(0,-width); 01030 LINETO(0,0); 01031 break; 01032 case 9 : 01033 pt += QPoint(segLen/2 - width/2 + 1 , 3*segLen/2 + width); 01034 ppt = pt; 01035 DARK; 01036 LINETO(width,0); 01037 LINETO(width,-width); 01038 LIGHT; 01039 LINETO(0,-width); 01040 LINETO(0,0); 01041 break; 01042 default : 01043 qWarning("QLCDNumber::drawSegment: (%s) Illegal segment id: %d\n", 01044 q->objectName().toLocal8Bit().constData(), segmentNo); 01045 } 01046 // End exact copy 01047 p.setPen(fgColor); 01048 p.setBrush(fgColor); 01049 p.drawPolygon(a); 01050 p.setBrush(Qt::NoBrush); 01051 01052 pt = pos; 01053 } 01054 #undef LINETO 01055 #undef LIGHT 01056 #undef DARK 01057 01058 #define LINETO(X,Y) p.drawLine(ppt.x(), ppt.y(), pt.x()+(X), pt.y()+(Y)); \ 01059 ppt = QPoint(pt.x()+(X), pt.y()+(Y)) 01060 #define LIGHT p.setPen(lightColor) 01061 #define DARK p.setPen(darkColor) 01062 if (shadow) 01063 switch (segmentNo) { 01064 case 0 : 01065 ppt = pt; 01066 LIGHT; 01067 LINETO(segLen - 1,0); 01068 DARK; 01069 LINETO(segLen - width - 1,width); 01070 LINETO(width,width); 01071 LINETO(0,0); 01072 break; 01073 case 1 : 01074 pt += QPoint(0,1); 01075 ppt = pt; 01076 LIGHT; 01077 LINETO(width,width); 01078 DARK; 01079 LINETO(width,segLen - width/2 - 2); 01080 LINETO(0,segLen - 2); 01081 LIGHT; 01082 LINETO(0,0); 01083 break; 01084 case 2 : 01085 pt += QPoint(segLen - 1 , 1); 01086 ppt = pt; 01087 DARK; 01088 LINETO(0,segLen - 2); 01089 LINETO(-width,segLen - width/2 - 2); 01090 LIGHT; 01091 LINETO(-width,width); 01092 LINETO(0,0); 01093 break; 01094 case 3 : 01095 pt += QPoint(0 , segLen); 01096 ppt = pt; 01097 LIGHT; 01098 LINETO(width,-width/2); 01099 LINETO(segLen - width - 1,-width/2); 01100 LINETO(segLen - 1,0); 01101 DARK; 01102 if (width & 1) { // adjust for integer division error 01103 LINETO(segLen - width - 3,width/2 + 1); 01104 LINETO(width + 2,width/2 + 1); 01105 } else { 01106 LINETO(segLen - width - 1,width/2); 01107 LINETO(width,width/2); 01108 } 01109 LINETO(0,0); 01110 break; 01111 case 4 : 01112 pt += QPoint(0 , segLen + 1); 01113 ppt = pt; 01114 LIGHT; 01115 LINETO(width,width/2); 01116 DARK; 01117 LINETO(width,segLen - width - 2); 01118 LINETO(0,segLen - 2); 01119 LIGHT; 01120 LINETO(0,0); 01121 break; 01122 case 5 : 01123 pt += QPoint(segLen - 1 , segLen + 1); 01124 ppt = pt; 01125 DARK; 01126 LINETO(0,segLen - 2); 01127 LINETO(-width,segLen - width - 2); 01128 LIGHT; 01129 LINETO(-width,width/2); 01130 LINETO(0,0); 01131 break; 01132 case 6 : 01133 pt += QPoint(0 , segLen*2); 01134 ppt = pt; 01135 LIGHT; 01136 LINETO(width,-width); 01137 LINETO(segLen - width - 1,-width); 01138 LINETO(segLen - 1,0); 01139 DARK; 01140 LINETO(0,0); 01141 break; 01142 case 7 : 01143 if (smallPoint) // if smallpoint place'.' between other digits 01144 pt += QPoint(segLen + width/2 , segLen*2); 01145 else 01146 pt += QPoint(segLen/2 , segLen*2); 01147 ppt = pt; 01148 DARK; 01149 LINETO(width,0); 01150 LINETO(width,-width); 01151 LIGHT; 01152 LINETO(0,-width); 01153 LINETO(0,0); 01154 break; 01155 case 8 : 01156 pt += QPoint(segLen/2 - width/2 + 1 , segLen/2 + width); 01157 ppt = pt; 01158 DARK; 01159 LINETO(width,0); 01160 LINETO(width,-width); 01161 LIGHT; 01162 LINETO(0,-width); 01163 LINETO(0,0); 01164 break; 01165 case 9 : 01166 pt += QPoint(segLen/2 - width/2 + 1 , 3*segLen/2 + width); 01167 ppt = pt; 01168 DARK; 01169 LINETO(width,0); 01170 LINETO(width,-width); 01171 LIGHT; 01172 LINETO(0,-width); 01173 LINETO(0,0); 01174 break; 01175 default : 01176 qWarning("QLCDNumber::drawSegment: (%s) Illegal segment id: %d\n", 01177 q->objectName().toLocal8Bit().constData(), segmentNo); 01178 } 01179 01180 #undef LINETO 01181 #undef LIGHT 01182 #undef DARK 01183 }
Here is the call graph for this function:

Definition at line 41 of file qlcdnumber.cpp.
Referenced by drawString(), init(), and internalSetString().
| double QLCDNumberPrivate::val |
Definition at line 44 of file qlcdnumber.cpp.
Referenced by drawSegment(), drawString(), init(), and internalSetString().
1.5.1