1 /****************************************************************************
2 ** $Id: qt/qlcdnumber.h   3.3.8   edited Jan 11 14:38 $
3 **
4 ** Definition of QLCDNumber class
5 **
6 ** Created : 940518
7 **
8 ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
9 **
10 ** This file is part of the widgets module of the Qt GUI Toolkit.
11 **
12 ** This file may be distributed under the terms of the Q Public License
13 ** as defined by Trolltech ASA of Norway and appearing in the file
14 ** LICENSE.QPL included in the packaging of this file.
15 **
16 ** This file may be distributed and/or modified under the terms of the
17 ** GNU General Public License version 2 as published by the Free Software
18 ** Foundation and appearing in the file LICENSE.GPL included in the
19 ** packaging of this file.
20 **
21 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22 ** licenses may use this file in accordance with the Qt Commercial License
23 ** Agreement provided with the Software.
24 **
25 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27 **
28 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29 **   information about Qt Commercial License Agreements.
30 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
31 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
32 **
33 ** Contact info@trolltech.com if any conditions of this licensing are
34 ** not clear to you.
35 **
36 **********************************************************************/
37 
38 #ifndef QLCDNUMBER_H
39 #define QLCDNUMBER_H
40 
41 #ifndef QT_H
42 #include "qframe.h"
43 #include "qbitarray.h"
44 #endif // QT_H
45 
46 #ifndef QT_NO_LCDNUMBER
47 
48 
49 class QLCDNumberPrivate;
50 
51 class Q_EXPORT QLCDNumber : public QFrame		// LCD number widget
52 {
53     Q_OBJECT
54     Q_ENUMS( Mode SegmentStyle )
55     Q_PROPERTY( bool smallDecimalPoint READ smallDecimalPoint WRITE setSmallDecimalPoint )
56     Q_PROPERTY( int numDigits READ numDigits WRITE setNumDigits )
57     Q_PROPERTY( Mode mode READ mode WRITE setMode )
58     Q_PROPERTY( SegmentStyle segmentStyle READ segmentStyle WRITE setSegmentStyle )
59     Q_PROPERTY( double value READ value WRITE display )
60     Q_PROPERTY( int intValue READ intValue WRITE display )
61 
62 public:
63     QLCDNumber( QWidget* parent=0, const char* name=0 );
64     QLCDNumber( uint numDigits, QWidget* parent=0, const char* name=0 );
65     ~QLCDNumber();
66 
67     enum Mode { Hex, Dec, Oct, Bin, HEX = Hex, DEC = Dec, OCT = Oct,
68 		BIN = Bin };
69     enum SegmentStyle { Outline, Filled, Flat };
70 
71     bool    smallDecimalPoint() const;
72 
73     int	    numDigits() const;
74     virtual void setNumDigits( int nDigits );
75 
76     bool    checkOverflow( double num ) const;
77     bool    checkOverflow( int	  num ) const;
78 
79     Mode mode() const;
80     virtual void setMode( Mode );
81 
82     SegmentStyle segmentStyle() const;
83     virtual void setSegmentStyle( SegmentStyle );
84 
85     double  value() const;
86     int	    intValue() const;
87 
88     QSize sizeHint() const;
89 
90 public slots:
91     void    display( const QString &str );
92     void    display( int num );
93     void    display( double num );
94     virtual void setHexMode();
95     virtual void setDecMode();
96     virtual void setOctMode();
97     virtual void setBinMode();
98     virtual void setSmallDecimalPoint( bool );
99 
100 signals:
101     void    overflow();
102 
103 protected:
104     void    drawContents( QPainter * );
105 
106 private:
107     void    init();
108     void    internalDisplay( const QString &);
109     void    internalSetString( const QString& s );
110     void    drawString( const QString& s, QPainter &, QBitArray * = 0,
111 			bool = TRUE );
112     //void    drawString( const QString &, QPainter &, QBitArray * = 0 ) const;
113     void    drawDigit( const QPoint &, QPainter &, int, char,
114 		       char = ' ' );
115     void    drawSegment( const QPoint &, char, QPainter &, int, bool = FALSE );
116 
117     int	    ndigits;
118     double  val;
119     uint    base	: 2;
120     uint    smallPoint	: 1;
121     uint    fill	: 1;
122     uint    shadow	: 1;
123     QString digitStr;
124     QBitArray points;
125     QLCDNumberPrivate * d;
126 
127 private:	// Disabled copy constructor and operator=
128 #if defined(Q_DISABLE_COPY)
129     QLCDNumber( const QLCDNumber & );
130     QLCDNumber &operator=( const QLCDNumber & );
131 #endif
132 };
133 
smallDecimalPoint()134 inline bool QLCDNumber::smallDecimalPoint() const
135 { return (bool)smallPoint; }
136 
numDigits()137 inline int QLCDNumber::numDigits() const
138 { return ndigits; }
139 
140 
141 #endif // QT_NO_LCDNUMBER
142 
143 #endif // QLCDNUMBER_H
144