|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtGui module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QLCDNUMBER_H |
|
43 #define QLCDNUMBER_H |
|
44 |
|
45 #include <QtGui/qframe.h> |
|
46 #include <QtCore/qbitarray.h> |
|
47 |
|
48 QT_BEGIN_HEADER |
|
49 |
|
50 QT_BEGIN_NAMESPACE |
|
51 |
|
52 QT_MODULE(Gui) |
|
53 |
|
54 #ifndef QT_NO_LCDNUMBER |
|
55 |
|
56 class QLCDNumberPrivate; |
|
57 class Q_GUI_EXPORT QLCDNumber : public QFrame // LCD number widget |
|
58 { |
|
59 Q_OBJECT |
|
60 Q_ENUMS(Mode SegmentStyle) |
|
61 Q_PROPERTY(bool smallDecimalPoint READ smallDecimalPoint WRITE setSmallDecimalPoint) |
|
62 Q_PROPERTY(int numDigits READ numDigits WRITE setNumDigits) |
|
63 Q_PROPERTY(Mode mode READ mode WRITE setMode) |
|
64 Q_PROPERTY(SegmentStyle segmentStyle READ segmentStyle WRITE setSegmentStyle) |
|
65 Q_PROPERTY(double value READ value WRITE display) |
|
66 Q_PROPERTY(int intValue READ intValue WRITE display) |
|
67 |
|
68 public: |
|
69 explicit QLCDNumber(QWidget* parent = 0); |
|
70 explicit QLCDNumber(uint numDigits, QWidget* parent = 0); |
|
71 ~QLCDNumber(); |
|
72 |
|
73 enum Mode { |
|
74 Hex, Dec, Oct, Bin |
|
75 #if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN) |
|
76 , HEX = Hex, DEC = Dec, OCT = Oct, BIN = Bin |
|
77 #endif |
|
78 }; |
|
79 enum SegmentStyle { |
|
80 Outline, Filled, Flat |
|
81 }; |
|
82 |
|
83 bool smallDecimalPoint() const; |
|
84 |
|
85 int numDigits() const; |
|
86 void setNumDigits(int nDigits); |
|
87 |
|
88 bool checkOverflow(double num) const; |
|
89 bool checkOverflow(int num) const; |
|
90 |
|
91 Mode mode() const; |
|
92 void setMode(Mode); |
|
93 |
|
94 SegmentStyle segmentStyle() const; |
|
95 void setSegmentStyle(SegmentStyle); |
|
96 |
|
97 double value() const; |
|
98 int intValue() const; |
|
99 |
|
100 QSize sizeHint() const; |
|
101 |
|
102 public Q_SLOTS: |
|
103 void display(const QString &str); |
|
104 void display(int num); |
|
105 void display(double num); |
|
106 void setHexMode(); |
|
107 void setDecMode(); |
|
108 void setOctMode(); |
|
109 void setBinMode(); |
|
110 void setSmallDecimalPoint(bool); |
|
111 |
|
112 Q_SIGNALS: |
|
113 void overflow(); |
|
114 |
|
115 protected: |
|
116 bool event(QEvent *e); |
|
117 void paintEvent(QPaintEvent *); |
|
118 |
|
119 public: |
|
120 #ifdef QT3_SUPPORT |
|
121 QT3_SUPPORT_CONSTRUCTOR QLCDNumber(QWidget* parent, const char* name); |
|
122 QT3_SUPPORT_CONSTRUCTOR QLCDNumber(uint numDigits, QWidget* parent, const char* name); |
|
123 |
|
124 QT3_SUPPORT void setMargin(int margin) { setContentsMargins(margin, margin, margin, margin); } |
|
125 QT3_SUPPORT int margin() const |
|
126 { int margin; int dummy; getContentsMargins(&margin, &dummy, &dummy, &dummy); return margin; } |
|
127 #endif |
|
128 |
|
129 private: |
|
130 Q_DISABLE_COPY(QLCDNumber) |
|
131 Q_DECLARE_PRIVATE(QLCDNumber) |
|
132 }; |
|
133 |
|
134 #endif // QT_NO_LCDNUMBER |
|
135 |
|
136 QT_END_NAMESPACE |
|
137 |
|
138 QT_END_HEADER |
|
139 |
|
140 #endif // QLCDNUMBER_H |