Qt 4.8
Public Functions | Public Variables | List of all members
QLCDNumberPrivate Class Reference
Inheritance diagram for QLCDNumberPrivate:
QFramePrivate QWidgetPrivate QObjectPrivate QObjectData

Public Functions

void drawDigit (const QPoint &, QPainter &, int, char, char=' ')
 
void drawSegment (const QPoint &, char, QPainter &, int, bool=false)
 
void drawString (const QString &s, QPainter &, QBitArray *=0, bool=true)
 
void init ()
 
void internalSetString (const QString &s)
 
- Public Functions inherited from QFramePrivate
void init ()
 
 QFramePrivate ()
 
void updateFrameWidth ()
 Updated the frameWidth parameter. More...
 
void updateStyledFrameWidths ()
 Updates the frame widths from the style. More...
 
- Public Functions inherited from QWidgetPrivate
void _q_showIfNotHidden ()
 
virtual void aboutToDestroy ()
 
void activateChildLayoutsRecursively ()
 
QSize adjustedSize () const
 
void adjustQuitOnCloseAttribute ()
 
QInputContextassignedInputContext () const
 
QPainterbeginSharedPainter ()
 
QWidgetchildAt_helper (const QPoint &, bool) const
 
QWidgetchildAtRecursiveHelper (const QPoint &p, bool, bool includeFrame=false) const
 
QRect clipRect () const
 
QRegion clipRegion () const
 
void clipToEffectiveMask (QRegion &region) const
 
bool close_helper (CloseMode mode)
 
void create_sys (WId window, bool initializeWindow, bool destroyOldWindow)
 
QWindowSurfacecreateDefaultWindowSurface ()
 
QWindowSurfacecreateDefaultWindowSurface_sys ()
 
void createExtra ()
 Creates the widget extra data. More...
 
void createRecursively ()
 
void createSysExtra ()
 
void createTLExtra ()
 
void createTLSysExtra ()
 
void createWinId (WId id=0)
 
void deactivateWidgetCleanup ()
 
void deleteExtra ()
 Deletes the widget extra data. More...
 
void deleteSysExtra ()
 
void deleteTLSysExtra ()
 
void drawWidget (QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter=0, QWidgetBackingStore *backingStore=0)
 
QWidgeteffectiveFocusWidget ()
 
QRect effectiveRectFor (const QRect &rect) const
 
bool endSharedPainter ()
 
void enforceNativeChildren ()
 
QWExtraextraData () const
 
QRect frameStrut () const
 
void getLayoutItemMargins (int *left, int *top, int *right, int *bottom) const
 
const QRegiongetOpaqueChildren () const
 
void handleSoftwareInputPanel (Qt::MouseButton button, bool clickCausedFocus)
 
virtual bool hasHeightForWidth () const
 
void hide_helper ()
 
void hide_sys ()
 Platform-specific part of QWidget::hide(). More...
 
void hideChildren (bool spontaneous)
 
void inheritStyle ()
 
void init (QWidget *desktopWidget, Qt::WindowFlags f)
 
QInputContextinputContext () const
 
void invalidateBuffer (const QRegion &)
 Invalidates the rgn (in widget's coordinates) of the backing store, i.e. More...
 
void invalidateBuffer (const QRect &)
 This function is equivalent to calling invalidateBuffer(QRegion(rect), ...), but is more efficient as it eliminates QRegion operations/allocations and can use the rect more precisely for additional cut-offs. More...
 
void invalidateBuffer_resizeHelper (const QPoint &oldPos, const QSize &oldSize)
 Invalidates the buffer when the widget is resized. More...
 
void invalidateGraphicsEffectsRecursively ()
 
bool isAboutToShow () const
 
bool isBackgroundInherited () const
 
bool isOverlapped (const QRect &) const
 
void lower_sys ()
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QWidgetBackingStoremaybeBackingStore () const
 
QTLWExtramaybeTopData () const
 
void moveRect (const QRect &, int dx, int dy)
 
bool nativeChildrenForced () const
 
QFont naturalWidgetFont (uint inheritedMask) const
 
QPalette naturalWidgetPalette (uint inheritedMask) const
 Returns the palette that the widget w inherits from its ancestors and QApplication::palette. More...
 
void paintBackground (QPainter *, const QRegion &, int flags=DrawAsRoot) const
 
bool paintOnScreen () const
 
void paintSiblingsRecursive (QPaintDevice *pdev, const QObjectList &children, int index, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter, QWidgetBackingStore *backingStore)
 
bool pointInsideRectAndMask (const QPoint &) const
 
QRegion prepareToRender (const QRegion &region, QWidget::RenderFlags renderFlags)
 
void propagatePaletteChange ()
 Propagate this widget's palette to all children, except style sheet widgets, and windows that don't enable window propagation (palettes don't normally propagate to windows). More...
 
 QWidgetPrivate (int version=QObjectPrivateVersion)
 
void raise_sys ()
 
QPaintDeviceredirected (QPoint *offset) const
 
void registerDropSite (bool)
 
void render (QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags, bool readyToRender)
 
void render_helper (QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags)
 
void repaint_sys (const QRegion &rgn)
 
void reparentFocusWidgets (QWidget *oldtlw)
 
void resolveFont ()
 Determine which font is implicitly imposed on this widget by its ancestors and QApplication::font, resolve this against its own font (attributes from the implicit font are copied over). More...
 
void resolveLayoutDirection ()
 
void resolveLocale ()
 
void resolvePalette ()
 Determine which palette is inherited from this widget's ancestors and QApplication::palette, resolve this against this widget's palette (attributes from the inherited palette are copied over this widget's palette). More...
 
void restoreRedirected ()
 
void scroll_sys (int dx, int dy)
 
void scroll_sys (int dx, int dy, const QRect &r)
 
void scrollChildren (int dx, int dy)
 
void scrollRect (const QRect &, int dx, int dy)
 
void sendPendingMoveAndResizeEvents (bool recursive=false, bool disableUpdates=false)
 
void sendStartupMessage (const char *message) const
 Platform-specific part of QWidget::show(). More...
 
void setConstraints_sys ()
 
void setCursor_sys (const QCursor &cursor)
 
void setDirtyOpaqueRegion ()
 
void setEnabled_helper (bool)
 
void setFocus_sys ()
 
void setFont_helper (const QFont &font)
 
void setGeometry_sys (int, int, int, int, bool)
 
void setLayoutDirection_helper (Qt::LayoutDirection)
 
void setLayoutItemMargins (int left, int top, int right, int bottom)
 
void setLayoutItemMargins (QStyle::SubElement element, const QStyleOption *opt=0)
 
void setLocale_helper (const QLocale &l, bool forceUpdate=false)
 
void setMask_sys (const QRegion &)
 
bool setMaximumSize_helper (int &maxw, int &maxh)
 
bool setMinimumSize_helper (int &minw, int &minh)
 
void setModal_sys ()
 
void setNetWmWindowTypes ()
 
void setOpaque (bool opaque)
 
void setPalette_helper (const QPalette &)
 
void setParent_sys (QWidget *parent, Qt::WindowFlags)
 
void setRedirected (QPaintDevice *replacement, const QPoint &offset)
 
void setSharedPainter (QPainter *painter)
 
void setStyle_helper (QStyle *newStyle, bool propagate, bool metalHack=false)
 
void setUpdatesEnabled_helper (bool)
 
void setWindowFilePath_helper (const QString &filePath)
 
void setWindowIcon_helper ()
 
void setWindowIcon_sys (bool forceReset=false)
 
void setWindowIconText_helper (const QString &cap)
 
void setWindowIconText_sys (const QString &cap)
 
void setWindowOpacity_sys (qreal opacity)
 
void setWindowRole ()
 
void setWindowTitle_helper (const QString &cap)
 
void setWindowTitle_sys (const QString &cap)
 
void setWinId (WId)
 
QPaintersharedPainter () const
 
void show_helper ()
 
void show_recursive ()
 Makes the widget visible in the isVisible() meaning of the word. More...
 
void show_sys ()
 Platform-specific part of QWidget::show(). More...
 
void showChildren (bool spontaneous)
 
void stackUnder_sys (QWidget *)
 
void subtractOpaqueChildren (QRegion &rgn, const QRect &clipRect) const
 
void subtractOpaqueSiblings (QRegion &source, bool *hasDirtySiblingsAbove=0, bool alsoNonOpaque=false) const
 
void syncBackingStore ()
 
void syncBackingStore (const QRegion &region)
 
QTLWExtratopData () const
 
void unsetCursor_sys ()
 
void updateFont (const QFont &)
 Assign font to this widget, and propagate it to all children, except style sheet widgets (handled differently) and windows that don't enable window propagation. More...
 
void updateFrameStrut ()
 Computes the frame rectangle when needed. More...
 
void updateGeometry_helper (bool forceUpdate)
 
void updateIsOpaque ()
 
void updateIsTranslucent ()
 
void updateSystemBackground ()
 
void updateX11AcceptFocus ()
 
void x11UpdateIsOpaque ()
 
 ~QWidgetPrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Public Variables

uint base: 2
 
QString digitStr
 
uint fill: 1
 
int ndigits
 
QBitArray points
 
uint shadow: 1
 
uint smallPoint: 1
 
double val
 
- Public Variables inherited from QFramePrivate
short bottomFrameWidth
 
int frameStyle
 
short frameWidth
 
QRect frect
 
short leftFrameWidth
 
short lineWidth
 
short midLineWidth
 
short rightFrameWidth
 
short topFrameWidth
 
- Public Variables inherited from QWidgetPrivate
QString accessibleDescription
 
QString accessibleName
 
QList< QAction * > actions
 
QPalette::ColorRole bg_role: 8
 
signed char bottomLayoutItemMargin
 
short bottommargin
 
QWidgetData data
 
QRegion dirty
 
uint dirtyOpaqueChildren: 1
 
QWExtraextra
 
QPaintEngineextraPaintEngine
 
QPalette::ColorRole fg_role: 8
 
QWidgetfocus_child
 
QWidgetfocus_next
 
QWidgetfocus_prev
 
QMap< Qt::GestureType, Qt::GestureFlags > gestureContext
 
QGraphicsEffectgraphicsEffect
 
Qt::HANDLE hd
 
uint high_attributes [4]
 
QPointer< QInputContextic
 
Qt::InputMethodHints imHints
 
uint inDirtyList: 1
 
uint inheritedFontResolveMask
 
uint inheritedPaletteResolveMask
 
uint inheritsInputMethodHints: 1
 
uint inSetParent: 1
 
uint isGLWidget: 1
 
uint isMoved: 1
 
uint isOpaque: 1
 
uint isScrolled: 1
 
QLayoutlayout
 
signed char leftLayoutItemMargin
 
short leftmargin
 
QLocale locale
 
QRegionneedsFlush
 
QRegion opaqueChildren
 
Qt::HANDLE picture
 
const QMetaObjectpolished
 
QPaintDeviceredirectDev
 
QPoint redirectOffset
 
signed char rightLayoutItemMargin
 
short rightmargin
 
QSizePolicy size_policy
 
QString statusTip
 
QString toolTip
 
signed char topLayoutItemMargin
 
short topmargin
 
uint usesDoubleBufferedGLContext: 1
 
QString whatsThis
 
QWidgetItemV2widgetItem
 
QX11Info xinfo
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QWidgetPrivate
enum  CloseMode { CloseNoEvent, CloseWithEvent, CloseWithSpontaneousEvent }
 
enum  Direction { DirectionNorth = 0x01, DirectionEast = 0x10, DirectionSouth = 0x02, DirectionWest = 0x20 }
 
enum  DrawWidgetFlags {
  DrawAsRoot = 0x01, DrawPaintOnScreen = 0x02, DrawRecursive = 0x04, DrawInvisible = 0x08,
  DontSubtractOpaqueChildren = 0x10, DontSetCompositionMode = 0x20, DontDrawOpaqueChildren = 0x40, DontDrawNativeChildren = 0x80
}
 
- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 
- Static Public Functions inherited from QWidgetPrivate
static void adjustFlags (Qt::WindowFlags &flags, QWidget *w=0)
 
static QGraphicsProxyWidgetnearestGraphicsProxyWidget (const QWidget *origin)
 Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this widget and its ancestors. More...
 
static int pointToRect (const QPoint &p, const QRect &r)
 
static QRect screenGeometry (const QWidget *widget)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 
- Static Public Variables inherited from QWidgetPrivate
static QWidgetSetallWidgets = 0
 
static int instanceCounter = 0
 
static QWidgetkeyboardGrabber = 0
 
static QWidgetMappermapper = 0
 
static int maxInstances = 0
 
static QWidgetmouseGrabber = 0
 

Detailed Description

Definition at line 50 of file qlcdnumber.cpp.

Functions

◆ drawDigit()

void QLCDNumberPrivate::drawDigit ( const QPoint pos,
QPainter p,
int  segLen,
char  newCh,
char  oldCh = ' ' 
)
Warning
This function is not part of the public interface.

Definition at line 944 of file qlcdnumber.cpp.

946 {
947 // Draws and/or erases segments to change display of a single digit
948 // from oldCh to newCh
949 
950  char updates[18][2]; // can hold 2 times number of segments, only
951  // first 9 used if segment table is correct
952  int nErases;
953  int nUpdates;
954  const char *segs;
955  int i,j;
956 
957  const char erase = 0;
958  const char draw = 1;
959  const char leaveAlone = 2;
960 
961  segs = getSegments(oldCh);
962  for (nErases=0; segs[nErases] != 99; nErases++) {
963  updates[nErases][0] = erase; // get segments to erase to
964  updates[nErases][1] = segs[nErases]; // remove old char
965  }
966  nUpdates = nErases;
967  segs = getSegments(newCh);
968  for(i = 0 ; segs[i] != 99 ; i++) {
969  for (j=0; j<nErases; j++)
970  if (segs[i] == updates[j][1]) { // same segment ?
971  updates[j][0] = leaveAlone; // yes, already on screen
972  break;
973  }
974  if (j == nErases) { // if not already on screen
975  updates[nUpdates][0] = draw;
976  updates[nUpdates][1] = segs[i];
977  nUpdates++;
978  }
979  }
980  for (i=0; i<nUpdates; i++) {
981  if (updates[i][0] == draw)
982  drawSegment(pos, updates[i][1], p, segLen);
983  if (updates[i][0] == erase)
984  drawSegment(pos, updates[i][1], p, segLen, true);
985  }
986 }
static const char * getSegments(char ch)
Definition: qlcdnumber.cpp:263
void drawSegment(const QPoint &, char, QPainter &, int, bool=false)

◆ drawSegment()

void QLCDNumberPrivate::drawSegment ( const QPoint pos,
char  segmentNo,
QPainter p,
int  segLen,
bool  erase = false 
)
Warning
This function is not part of the public interface.

Definition at line 1000 of file qlcdnumber.cpp.

1002 {
1003  Q_Q(QLCDNumber);
1004  QPoint ppt;
1005  QPoint pt = pos;
1006  int width = segLen/5;
1007 
1008  const QPalette &pal = q->palette();
1009  QColor lightColor,darkColor,fgColor;
1010  if (erase){
1011  lightColor = pal.color(q->backgroundRole());
1012  darkColor = lightColor;
1013  fgColor = lightColor;
1014  } else {
1015  lightColor = pal.light().color();
1016  darkColor = pal.dark().color();
1017  fgColor = pal.color(q->foregroundRole());
1018  }
1019 
1020 
1021 #define LINETO(X,Y) addPoint(a, QPoint(pt.x() + (X),pt.y() + (Y)))
1022 #define LIGHT
1023 #define DARK
1024 
1025  if (fill) {
1026  QPolygon a(0);
1027  //The following is an exact copy of the switch below.
1028  //don't make any changes here
1029  switch (segmentNo) {
1030  case 0 :
1031  ppt = pt;
1032  LIGHT;
1033  LINETO(segLen - 1,0);
1034  DARK;
1035  LINETO(segLen - width - 1,width);
1036  LINETO(width,width);
1037  LINETO(0,0);
1038  break;
1039  case 1 :
1040  pt += QPoint(0 , 1);
1041  ppt = pt;
1042  LIGHT;
1043  LINETO(width,width);
1044  DARK;
1045  LINETO(width,segLen - width/2 - 2);
1046  LINETO(0,segLen - 2);
1047  LIGHT;
1048  LINETO(0,0);
1049  break;
1050  case 2 :
1051  pt += QPoint(segLen - 1 , 1);
1052  ppt = pt;
1053  DARK;
1054  LINETO(0,segLen - 2);
1055  LINETO(-width,segLen - width/2 - 2);
1056  LIGHT;
1057  LINETO(-width,width);
1058  LINETO(0,0);
1059  break;
1060  case 3 :
1061  pt += QPoint(0 , segLen);
1062  ppt = pt;
1063  LIGHT;
1064  LINETO(width,-width/2);
1065  LINETO(segLen - width - 1,-width/2);
1066  LINETO(segLen - 1,0);
1067  DARK;
1068  if (width & 1) { // adjust for integer division error
1069  LINETO(segLen - width - 3,width/2 + 1);
1070  LINETO(width + 2,width/2 + 1);
1071  } else {
1072  LINETO(segLen - width - 1,width/2);
1073  LINETO(width,width/2);
1074  }
1075  LINETO(0,0);
1076  break;
1077  case 4 :
1078  pt += QPoint(0 , segLen + 1);
1079  ppt = pt;
1080  LIGHT;
1081  LINETO(width,width/2);
1082  DARK;
1083  LINETO(width,segLen - width - 2);
1084  LINETO(0,segLen - 2);
1085  LIGHT;
1086  LINETO(0,0);
1087  break;
1088  case 5 :
1089  pt += QPoint(segLen - 1 , segLen + 1);
1090  ppt = pt;
1091  DARK;
1092  LINETO(0,segLen - 2);
1093  LINETO(-width,segLen - width - 2);
1094  LIGHT;
1095  LINETO(-width,width/2);
1096  LINETO(0,0);
1097  break;
1098  case 6 :
1099  pt += QPoint(0 , segLen*2);
1100  ppt = pt;
1101  LIGHT;
1102  LINETO(width,-width);
1103  LINETO(segLen - width - 1,-width);
1104  LINETO(segLen - 1,0);
1105  DARK;
1106  LINETO(0,0);
1107  break;
1108  case 7 :
1109  if (smallPoint) // if smallpoint place'.' between other digits
1110  pt += QPoint(segLen + width/2 , segLen*2);
1111  else
1112  pt += QPoint(segLen/2 , segLen*2);
1113  ppt = pt;
1114  DARK;
1115  LINETO(width,0);
1116  LINETO(width,-width);
1117  LIGHT;
1118  LINETO(0,-width);
1119  LINETO(0,0);
1120  break;
1121  case 8 :
1122  pt += QPoint(segLen/2 - width/2 + 1 , segLen/2 + width);
1123  ppt = pt;
1124  DARK;
1125  LINETO(width,0);
1126  LINETO(width,-width);
1127  LIGHT;
1128  LINETO(0,-width);
1129  LINETO(0,0);
1130  break;
1131  case 9 :
1132  pt += QPoint(segLen/2 - width/2 + 1 , 3*segLen/2 + width);
1133  ppt = pt;
1134  DARK;
1135  LINETO(width,0);
1136  LINETO(width,-width);
1137  LIGHT;
1138  LINETO(0,-width);
1139  LINETO(0,0);
1140  break;
1141  default :
1142  qWarning("QLCDNumber::drawSegment: (%s) Illegal segment id: %d\n",
1143  q->objectName().toLocal8Bit().constData(), segmentNo);
1144  }
1145  // End exact copy
1146  p.setPen(Qt::NoPen);
1147  p.setBrush(fgColor);
1148  p.drawPolygon(a);
1149  p.setBrush(Qt::NoBrush);
1150 
1151  pt = pos;
1152  }
1153 #undef LINETO
1154 #undef LIGHT
1155 #undef DARK
1156 
1157 #define LINETO(X,Y) p.drawLine(ppt.x(), ppt.y(), pt.x()+(X), pt.y()+(Y)); \
1158  ppt = QPoint(pt.x()+(X), pt.y()+(Y))
1159 #define LIGHT p.setPen(lightColor)
1160 #define DARK p.setPen(darkColor)
1161  if (shadow)
1162  switch (segmentNo) {
1163  case 0 :
1164  ppt = pt;
1165  LIGHT;
1166  LINETO(segLen - 1,0);
1167  DARK;
1168  LINETO(segLen - width - 1,width);
1169  LINETO(width,width);
1170  LINETO(0,0);
1171  break;
1172  case 1 :
1173  pt += QPoint(0,1);
1174  ppt = pt;
1175  LIGHT;
1176  LINETO(width,width);
1177  DARK;
1178  LINETO(width,segLen - width/2 - 2);
1179  LINETO(0,segLen - 2);
1180  LIGHT;
1181  LINETO(0,0);
1182  break;
1183  case 2 :
1184  pt += QPoint(segLen - 1 , 1);
1185  ppt = pt;
1186  DARK;
1187  LINETO(0,segLen - 2);
1188  LINETO(-width,segLen - width/2 - 2);
1189  LIGHT;
1190  LINETO(-width,width);
1191  LINETO(0,0);
1192  break;
1193  case 3 :
1194  pt += QPoint(0 , segLen);
1195  ppt = pt;
1196  LIGHT;
1197  LINETO(width,-width/2);
1198  LINETO(segLen - width - 1,-width/2);
1199  LINETO(segLen - 1,0);
1200  DARK;
1201  if (width & 1) { // adjust for integer division error
1202  LINETO(segLen - width - 3,width/2 + 1);
1203  LINETO(width + 2,width/2 + 1);
1204  } else {
1205  LINETO(segLen - width - 1,width/2);
1206  LINETO(width,width/2);
1207  }
1208  LINETO(0,0);
1209  break;
1210  case 4 :
1211  pt += QPoint(0 , segLen + 1);
1212  ppt = pt;
1213  LIGHT;
1214  LINETO(width,width/2);
1215  DARK;
1216  LINETO(width,segLen - width - 2);
1217  LINETO(0,segLen - 2);
1218  LIGHT;
1219  LINETO(0,0);
1220  break;
1221  case 5 :
1222  pt += QPoint(segLen - 1 , segLen + 1);
1223  ppt = pt;
1224  DARK;
1225  LINETO(0,segLen - 2);
1226  LINETO(-width,segLen - width - 2);
1227  LIGHT;
1228  LINETO(-width,width/2);
1229  LINETO(0,0);
1230  break;
1231  case 6 :
1232  pt += QPoint(0 , segLen*2);
1233  ppt = pt;
1234  LIGHT;
1235  LINETO(width,-width);
1236  LINETO(segLen - width - 1,-width);
1237  LINETO(segLen - 1,0);
1238  DARK;
1239  LINETO(0,0);
1240  break;
1241  case 7 :
1242  if (smallPoint) // if smallpoint place'.' between other digits
1243  pt += QPoint(segLen + width/2 , segLen*2);
1244  else
1245  pt += QPoint(segLen/2 , segLen*2);
1246  ppt = pt;
1247  DARK;
1248  LINETO(width,0);
1249  LINETO(width,-width);
1250  LIGHT;
1251  LINETO(0,-width);
1252  LINETO(0,0);
1253  break;
1254  case 8 :
1255  pt += QPoint(segLen/2 - width/2 + 1 , segLen/2 + width);
1256  ppt = pt;
1257  DARK;
1258  LINETO(width,0);
1259  LINETO(width,-width);
1260  LIGHT;
1261  LINETO(0,-width);
1262  LINETO(0,0);
1263  break;
1264  case 9 :
1265  pt += QPoint(segLen/2 - width/2 + 1 , 3*segLen/2 + width);
1266  ppt = pt;
1267  DARK;
1268  LINETO(width,0);
1269  LINETO(width,-width);
1270  LIGHT;
1271  LINETO(0,-width);
1272  LINETO(0,0);
1273  break;
1274  default :
1275  qWarning("QLCDNumber::drawSegment: (%s) Illegal segment id: %d\n",
1276  q->objectName().toLocal8Bit().constData(), segmentNo);
1277  }
1278 
1279 #undef LINETO
1280 #undef LIGHT
1281 #undef DARK
1282 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
#define LINETO(X, Y)
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition: qpalette.h:127
long ASN1_INTEGER_get ASN1_INTEGER * a
The QPolygon class provides a vector of points using integer precision.
Definition: qpolygon.h:60
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
#define Q_Q(Class)
Definition: qglobal.h:2483
const QBrush & light() const
Returns the light brush of the current color group.
Definition: qpalette.h:126
Q_CORE_EXPORT void qWarning(const char *,...)
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws the polygon defined by the first pointCount points in the array points using the current pen an...
Definition: qpainter.cpp:5205
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
The QLCDNumber widget displays a number with LCD-like digits.
Definition: qlcdnumber.h:57
#define LIGHT
#define DARK
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ drawString()

void QLCDNumberPrivate::drawString ( const QString s,
QPainter p,
QBitArray newPoints = 0,
bool  newString = true 
)
Warning
This function is not part of the public interface.

Definition at line 901 of file qlcdnumber.cpp.

903 {
904  Q_Q(QLCDNumber);
905  QPoint pos;
906 
907  int digitSpace = smallPoint ? 2 : 1;
908  int xSegLen = q->width()*5/(ndigits*(5 + digitSpace) + digitSpace);
909  int ySegLen = q->height()*5/12;
910  int segLen = ySegLen > xSegLen ? xSegLen : ySegLen;
911  int xAdvance = segLen*(5 + digitSpace)/5;
912  int xOffset = (q->width() - ndigits*xAdvance + segLen/5)/2;
913  int yOffset = (q->height() - segLen*2)/2;
914 
915  for (int i=0; i<ndigits; i++) {
916  pos = QPoint(xOffset + xAdvance*i, yOffset);
917  if (newString)
918  drawDigit(pos, p, segLen, s[i].toLatin1(), digitStr[i].toLatin1());
919  else
920  drawDigit(pos, p, segLen, s[i].toLatin1());
921  if (newPoints) {
922  char newPoint = newPoints->testBit(i) ? '.' : ' ';
923  if (newString) {
924  char oldPoint = points.testBit(i) ? '.' : ' ';
925  drawDigit(pos, p, segLen, newPoint, oldPoint);
926  } else {
927  drawDigit(pos, p, segLen, newPoint);
928  }
929  }
930  }
931  if (newString) {
932  digitStr = s;
933  digitStr.truncate(ndigits);
934  if (newPoints)
935  points = *newPoints;
936  }
937 }
bool testBit(int i) const
Returns true if the bit at index position i is 1; otherwise returns false.
Definition: qbitarray.h:124
#define Q_Q(Class)
Definition: qglobal.h:2483
void truncate(int pos)
Truncates the string at the given position index.
Definition: qstring.cpp:4603
void drawDigit(const QPoint &, QPainter &, int, char, char=' ')
Definition: qlcdnumber.cpp:944
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QBitArray points
Definition: qlcdnumber.cpp:68
The QLCDNumber widget displays a number with LCD-like digits.
Definition: qlcdnumber.h:57

◆ init()

void QLCDNumberPrivate::init ( )

Definition at line 438 of file qlcdnumber.cpp.

439 {
440  Q_Q(QLCDNumber);
441 
442  q->setFrameStyle(QFrame::Box | QFrame::Raised);
443  val = 0;
445  smallPoint = false;
446  q->setDigitCount(ndigits);
447  q->setSegmentStyle(QLCDNumber::Filled);
449 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QLCDNumber widget displays a number with LCD-like digits.
Definition: qlcdnumber.h:57

◆ internalSetString()

void QLCDNumberPrivate::internalSetString ( const QString s)

Definition at line 839 of file qlcdnumber.cpp.

840 {
841  Q_Q(QLCDNumber);
842  QString buffer;
843  int i;
844  int len = s.length();
845  QBitArray newPoints(ndigits);
846 
847  if (!smallPoint) {
848  if (len == ndigits)
849  buffer = s;
850  else
851  buffer = s.right(ndigits).rightJustified(ndigits, QLatin1Char(' '));
852  } else {
853  int index = -1;
854  bool lastWasPoint = true;
855  newPoints.clearBit(0);
856  for (i=0; i<len; i++) {
857  if (s[i] == QLatin1Char('.')) {
858  if (lastWasPoint) { // point already set for digit?
859  if (index == ndigits - 1) // no more digits
860  break;
861  index++;
862  buffer[index] = QLatin1Char(' '); // 2 points in a row, add space
863  }
864  newPoints.setBit(index); // set decimal point
865  lastWasPoint = true;
866  } else {
867  if (index == ndigits - 1)
868  break;
869  index++;
870  buffer[index] = s[i];
871  newPoints.clearBit(index); // decimal point default off
872  lastWasPoint = false;
873  }
874  }
875  if (index < ((int) ndigits) - 1) {
876  for(i=index; i>=0; i--) {
877  buffer[ndigits - 1 - index + i] = buffer[i];
878  newPoints.setBit(ndigits - 1 - index + i,
879  newPoints.testBit(i));
880  }
881  for(i=0; i<ndigits-index-1; i++) {
882  buffer[i] = QLatin1Char(' ');
883  newPoints.clearBit(i);
884  }
885  }
886  }
887 
888  if (buffer == digitStr)
889  return;
890 
891  digitStr = buffer;
892  if (smallPoint)
893  points = newPoints;
894  q->update();
895 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_Q(Class)
Definition: qglobal.h:2483
QString rightJustified(int width, QChar fill=QLatin1Char(' '), bool trunc=false) const Q_REQUIRED_RESULT
Returns a string of size() width that contains the fill character followed by the string...
Definition: qstring.cpp:5357
QString right(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n rightmost characters of the string.
Definition: qstring.cpp:3682
The QBitArray class provides an array of bits.
Definition: qbitarray.h:54
QBitArray points
Definition: qlcdnumber.cpp:68
The QLCDNumber widget displays a number with LCD-like digits.
Definition: qlcdnumber.h:57
quint16 index
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

Properties

◆ base

uint QLCDNumberPrivate::base

Definition at line 63 of file qlcdnumber.cpp.

◆ digitStr

QString QLCDNumberPrivate::digitStr

Definition at line 67 of file qlcdnumber.cpp.

◆ fill

uint QLCDNumberPrivate::fill

Definition at line 65 of file qlcdnumber.cpp.

◆ ndigits

int QLCDNumberPrivate::ndigits

Definition at line 61 of file qlcdnumber.cpp.

Referenced by double2string(), and int2string().

◆ points

QBitArray QLCDNumberPrivate::points

Definition at line 68 of file qlcdnumber.cpp.

◆ shadow

uint QLCDNumberPrivate::shadow

Definition at line 66 of file qlcdnumber.cpp.

◆ smallPoint

uint QLCDNumberPrivate::smallPoint

Definition at line 64 of file qlcdnumber.cpp.

◆ val

double QLCDNumberPrivate::val

Definition at line 62 of file qlcdnumber.cpp.


The documentation for this class was generated from the following file: