author | eric <eric> | 2003-02-21 10:39:29 (UTC) |
---|---|---|
committer | eric <eric> | 2003-02-21 10:39:29 (UTC) |
commit | 2d77abb5ff37abf61e04657431d7e0e1f5138d94 (patch) (unidiff) | |
tree | c78d34380cb9e1722f41c56cda0bbbea394e2a1a | |
parent | d25a16d1fd34374e4d2815dec4d11b25b2049432 (diff) | |
download | opie-2d77abb5ff37abf61e04657431d7e0e1f5138d94.zip opie-2d77abb5ff37abf61e04657431d7e0e1f5138d94.tar.gz opie-2d77abb5ff37abf61e04657431d7e0e1f5138d94.tar.bz2 |
- Improve look 'n feel.
- fix a bug in '=' operation.
-rw-r--r-- | noncore/tools/euroconv/calcdisplay.cpp | 50 | ||||
-rw-r--r-- | noncore/tools/euroconv/calcdisplay.h | 38 | ||||
-rw-r--r-- | noncore/tools/euroconv/calckeypad.cpp | 48 | ||||
-rw-r--r-- | noncore/tools/euroconv/calckeypad.h | 2 | ||||
-rw-r--r-- | noncore/tools/euroconv/currency.h | 4 |
5 files changed, 109 insertions, 33 deletions
diff --git a/noncore/tools/euroconv/calcdisplay.cpp b/noncore/tools/euroconv/calcdisplay.cpp index 06e5158..1659858 100644 --- a/noncore/tools/euroconv/calcdisplay.cpp +++ b/noncore/tools/euroconv/calcdisplay.cpp | |||
@@ -1,188 +1,216 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | * | 2 | * |
3 | * File: calcdisplay.cpp | 3 | * File: calcdisplay.cpp |
4 | * | 4 | * |
5 | * Description: | 5 | * Description: |
6 | * | 6 | * |
7 | * | 7 | * |
8 | * Authors: Eric Santonacci <Eric.Santonacci@talc.fr> | 8 | * Authors: Eric Santonacci <Eric.Santonacci@talc.fr> |
9 | * | 9 | * |
10 | * Requirements: Qt | 10 | * Requirements: Qt |
11 | * | 11 | * |
12 | * $Id$ | 12 | * $Id$ |
13 | * | 13 | * |
14 | ***************************************************************************/ | 14 | ***************************************************************************/ |
15 | 15 | ||
16 | #include <stdio.h> | 16 | #include <stdio.h> |
17 | #include <qvbox.h> | 17 | #include <qvbox.h> |
18 | #include <qpixmap.h> | ||
18 | 19 | ||
19 | #include "currency.h" | 20 | #include "currency.h" |
20 | #include "calcdisplay.h" | 21 | #include "calcdisplay.h" |
21 | 22 | ||
22 | 23 | ||
23 | LCDDisplay::LCDDisplay( QWidget *parent, const char *name ) | 24 | LCDDisplay::LCDDisplay( QWidget *parent, const char *name ) |
24 | : QHBox( parent, name ){ | 25 | : QHBox( parent, name ){ |
25 | 26 | ||
26 | 27 | ||
28 | |||
29 | this->setMargin(5); | ||
30 | this->setSpacing(5); | ||
31 | |||
27 | // Create display | 32 | // Create display |
28 | QVBox *vbxlayout = new QVBox (this); | 33 | QVBox *vbxlayout = new QVBox (this); |
29 | 34 | ||
30 | grpbxTop = new QVGroupBox(vbxlayout, "grpbxTop"); | 35 | /*************** Top LCD ***********************/ |
36 | grpbxTop = new QHGroupBox(vbxlayout, "grpbxTop"); | ||
37 | grpbxStyle = grpbxTop->frameStyle(); | ||
38 | grpbxTop->setMaximumHeight(48); | ||
39 | |||
31 | cbbxTop = new QComboBox(grpbxTop, "cbbxTop"); | 40 | cbbxTop = new QComboBox(grpbxTop, "cbbxTop"); |
41 | cbbxTop->setMaximumWidth(50); | ||
42 | cbbxTop->insertStrList(aCurrency); | ||
43 | |||
32 | lcdTop = new QLCDNumber(10, grpbxTop, "lcdTop"); | 44 | lcdTop = new QLCDNumber(10, grpbxTop, "lcdTop"); |
33 | lcdTop->setMode( QLCDNumber::DEC ); | 45 | lcdTop->setMode( QLCDNumber::DEC ); |
34 | lcdTop->setSmallDecimalPoint(true); | 46 | lcdTop->setSmallDecimalPoint(true); |
35 | lcdTop->setSegmentStyle(QLCDNumber::Flat); | 47 | lcdTop->setSegmentStyle(QLCDNumber::Flat); |
36 | cbbxTop->insertStrList(aCurrency); | ||
37 | 48 | ||
38 | grpbxBottom = new QVGroupBox(vbxlayout, "grpbxBottom"); | 49 | /************** Bottom LCD ************************/ |
50 | grpbxBottom = new QHGroupBox(vbxlayout, "grpbxBottom"); | ||
51 | grpbxBottom->setMaximumHeight(46); | ||
52 | grpbxBottom->setFrameStyle(0); | ||
53 | grpbxBottom->setFrameShadow(QFrame::MShadow); | ||
54 | |||
39 | cbbxBottom = new QComboBox(grpbxBottom, "cbbxBottom"); | 55 | cbbxBottom = new QComboBox(grpbxBottom, "cbbxBottom"); |
56 | cbbxBottom->setMaximumWidth(50); | ||
57 | cbbxBottom->insertStrList(aCurrency); | ||
58 | |||
40 | lcdBottom = new QLCDNumber(10, grpbxBottom, "lcdBottom"); | 59 | lcdBottom = new QLCDNumber(10, grpbxBottom, "lcdBottom"); |
41 | lcdBottom->setMode( QLCDNumber::DEC ); | 60 | lcdBottom->setMode( QLCDNumber::DEC ); |
42 | lcdBottom->setSmallDecimalPoint(true); | 61 | lcdBottom->setSmallDecimalPoint(true); |
43 | lcdBottom->setSegmentStyle(QLCDNumber::Flat); | 62 | lcdBottom->setSegmentStyle(QLCDNumber::Flat); |
44 | cbbxBottom->insertStrList(aCurrency); | ||
45 | 63 | ||
46 | // set combo box signals | 64 | // set combo box signals |
47 | connect(cbbxTop, SIGNAL(activated(int)), this, SLOT(cbbxChange())); | 65 | connect(cbbxTop, SIGNAL(activated(int)), this, SLOT(cbbxChange())); |
48 | connect(cbbxBottom, SIGNAL(activated(int)), this, SLOT(cbbxChange())); | 66 | connect(cbbxBottom, SIGNAL(activated(int)), this, SLOT(cbbxChange())); |
49 | 67 | ||
50 | btnSwap = new QPushButton("S",this, "swap"); | 68 | btnSwap = new QPushButton(this, "swap"); |
51 | btnSwap->setMaximumSize(20,50); | 69 | QPixmap imgSwap((const char**) swap_xpm); |
52 | btnSwap->setMinimumSize(20,50); | 70 | btnSwap->setPixmap(imgSwap); |
71 | btnSwap->setFixedSize(20,40); | ||
53 | // set signal | 72 | // set signal |
54 | connect(btnSwap, SIGNAL(clicked()), this, SLOT(swapLCD())); | 73 | connect(btnSwap, SIGNAL(clicked()), this, SLOT(swapLCD())); |
55 | 74 | ||
56 | // set default LCD to top | 75 | // set default LCD to top |
57 | iCurrentLCD = 0; | 76 | iCurrentLCD = 0; |
58 | 77 | ||
59 | //setValue(123.456); | ||
60 | |||
61 | } | 78 | } |
62 | 79 | ||
63 | /*********************************************************************** | 80 | /*********************************************************************** |
64 | * SLOT: Display value in the correct LCD | 81 | * SLOT: Display value in the correct LCD |
65 | **********************************************************************/ | 82 | **********************************************************************/ |
66 | void LCDDisplay::setValue(double dSrcValue){ | 83 | void LCDDisplay::setValue(double dSrcValue){ |
67 | 84 | ||
68 | double dDstValue=0; | 85 | double dDstValue=0; |
69 | 86 | ||
70 | int iSrcIndex; | 87 | int iSrcIndex; |
71 | int iDstIndex; | 88 | int iDstIndex; |
72 | 89 | ||
73 | 90 | ||
74 | // get item index of the focused | 91 | // get item index of the focused |
75 | if(!iCurrentLCD){ | 92 | if(!iCurrentLCD){ |
76 | iSrcIndex = cbbxTop->currentItem(); | 93 | iSrcIndex = cbbxTop->currentItem(); |
77 | iDstIndex = cbbxBottom->currentItem(); | 94 | iDstIndex = cbbxBottom->currentItem(); |
78 | }else{ | 95 | }else{ |
79 | iSrcIndex = cbbxBottom->currentItem(); | 96 | iSrcIndex = cbbxBottom->currentItem(); |
80 | iDstIndex = cbbxTop->currentItem(); | 97 | iDstIndex = cbbxTop->currentItem(); |
81 | } | 98 | } |
82 | 99 | ||
83 | if(iSrcIndex == iDstIndex) | 100 | if(iSrcIndex == iDstIndex) |
84 | dDstValue = dSrcValue; | 101 | dDstValue = dSrcValue; |
85 | else{ | 102 | else{ |
86 | if(iSrcIndex){ | 103 | if(iSrcIndex){ |
87 | // we are NOT in Euro as iDstIndex <> 0 | 104 | // we are NOT in Euro as iDstIndex <> 0 |
88 | // Convert to Euro | 105 | // Convert to Euro |
89 | dDstValue = x2Euro(iSrcIndex, dSrcValue); | 106 | dDstValue = x2Euro(iSrcIndex, dSrcValue); |
90 | dDstValue = Euro2x(iDstIndex, dDstValue); | 107 | dDstValue = Euro2x(iDstIndex, dDstValue); |
91 | }else | 108 | }else |
92 | // We are in Euro | 109 | // We are in Euro |
93 | dDstValue = Euro2x(iDstIndex, dSrcValue); | 110 | dDstValue = Euro2x(iDstIndex, dSrcValue); |
94 | } | 111 | } |
95 | 112 | ||
96 | 113 | ||
97 | if(!iCurrentLCD){ | 114 | if(!iCurrentLCD){ |
98 | lcdTop->display(dSrcValue); | 115 | lcdTop->display(dSrcValue); |
99 | lcdBottom->display(dDstValue); | 116 | lcdBottom->display(dDstValue); |
100 | }else{ | 117 | }else{ |
101 | lcdBottom->display(dSrcValue); | 118 | lcdBottom->display(dSrcValue); |
102 | lcdTop->display(dDstValue); | 119 | lcdTop->display(dDstValue); |
103 | } | 120 | } |
104 | 121 | ||
105 | } | 122 | } |
106 | 123 | ||
107 | /*********************************************************************** | 124 | /*********************************************************************** |
108 | * SLOT: Swap output keypad between LCD displays | 125 | * SLOT: Swap output keypad between LCD displays |
109 | **********************************************************************/ | 126 | **********************************************************************/ |
110 | void LCDDisplay::swapLCD(void){ | 127 | void LCDDisplay::swapLCD(void){ |
111 | 128 | ||
112 | double dCurrentValue; | 129 | double dCurrentValue; |
113 | 130 | ||
114 | // get current value | 131 | // get current value |
115 | if(!iCurrentLCD){ | 132 | if(!iCurrentLCD){ |
133 | // iCurrentLCD = 0, lcdTop has current focus and is going to loose | ||
134 | // it | ||
116 | dCurrentValue = lcdTop->value(); | 135 | dCurrentValue = lcdTop->value(); |
117 | iCurrentLCD = 1; | 136 | iCurrentLCD = 1; |
137 | grpbxTop->setFrameStyle(0); | ||
138 | grpbxBottom->setFrameStyle(grpbxStyle); | ||
118 | }else{ | 139 | }else{ |
119 | dCurrentValue = lcdBottom->value(); | 140 | dCurrentValue = lcdBottom->value(); |
120 | iCurrentLCD = 0; | 141 | iCurrentLCD = 0; |
142 | grpbxTop->setFrameStyle(grpbxStyle); | ||
143 | grpbxBottom->setFrameStyle(0); | ||
121 | } | 144 | } |
122 | 145 | ||
123 | setValue(dCurrentValue); | 146 | setValue(dCurrentValue); |
124 | } | 147 | } |
125 | 148 | ||
126 | /*********************************************************************** | 149 | /*********************************************************************** |
127 | * SLOT: Currency change | 150 | * SLOT: Currency change |
128 | **********************************************************************/ | 151 | **********************************************************************/ |
129 | void LCDDisplay::cbbxChange(void){ | 152 | void LCDDisplay::cbbxChange(void){ |
130 | 153 | ||
131 | double dCurrentValue; | 154 | double dCurrentValue; |
132 | 155 | ||
133 | printf("combo changes...\n"); | ||
134 | |||
135 | // get current value | 156 | // get current value |
136 | if(!iCurrentLCD){ | 157 | if(!iCurrentLCD){ |
137 | dCurrentValue = lcdTop->value(); | 158 | dCurrentValue = lcdTop->value(); |
138 | }else{ | 159 | }else{ |
139 | dCurrentValue = lcdBottom->value(); | 160 | dCurrentValue = lcdBottom->value(); |
140 | } | 161 | } |
141 | 162 | ||
142 | setValue(dCurrentValue); | 163 | setValue(dCurrentValue); |
143 | } | 164 | } |
144 | 165 | ||
145 | 166 | ||
146 | /*********************************************************************** | 167 | /*********************************************************************** |
147 | * Euro2x converts dValue from Euro to the currency which combo box | 168 | * Euro2x converts dValue from Euro to the currency which combo box |
148 | * index is provided in iIndex. | 169 | * index is provided in iIndex. |
149 | **********************************************************************/ | 170 | **********************************************************************/ |
150 | double LCDDisplay::Euro2x(int iIndex, double dValue){ | 171 | double LCDDisplay::Euro2x(int iIndex, double dValue){ |
151 | 172 | ||
152 | switch (iIndex){ | 173 | switch (iIndex){ |
153 | case 0: // Euro | 174 | case 0: // Euro |
154 | return(dValue); | 175 | return(dValue); |
155 | break; | 176 | break; |
156 | 177 | ||
157 | case 1: // FF: French Francs | 178 | case 1: // FF: French Francs |
158 | return(dValue*FF); | 179 | return(dValue*FF); |
159 | break; | 180 | break; |
160 | 181 | ||
161 | case 2: // DM: Deutch Mark | 182 | case 2: // DM: Deutch Mark |
162 | return(dValue*DM); | 183 | return(dValue*DM); |
163 | break; | 184 | break; |
185 | |||
186 | default: | ||
187 | return 0; | ||
164 | }//switch (iIndex) | 188 | }//switch (iIndex) |
165 | }// fct Eur2x | 189 | }// fct Eur2x |
166 | 190 | ||
167 | 191 | ||
168 | 192 | ||
169 | /*********************************************************************** | 193 | /*********************************************************************** |
170 | * x2Euro converts dValue to Euro from the currency which combo box | 194 | * x2Euro converts dValue to Euro from the currency which combo box |
171 | * index is provided in iIndex. | 195 | * index is provided in iIndex. |
172 | **********************************************************************/ | 196 | **********************************************************************/ |
173 | double LCDDisplay::x2Euro(int iIndex, double dValue){ | 197 | double LCDDisplay::x2Euro(int iIndex, double dValue){ |
174 | 198 | ||
175 | switch (iIndex){ | 199 | switch (iIndex){ |
176 | case 0: // Euro | 200 | case 0: // Euro |
177 | return(dValue); | 201 | return(dValue); |
178 | break; | 202 | break; |
179 | 203 | ||
180 | case 1: // FF: French Francs | 204 | case 1: // FF: French Francs |
181 | return(dValue/FF); | 205 | return(dValue/FF); |
182 | break; | 206 | break; |
183 | 207 | ||
184 | case 2: // DM: Deutch Mark | 208 | case 2: // DM: Deutch Mark |
185 | return(dValue/DM); | 209 | return(dValue/DM); |
186 | break; | 210 | break; |
187 | }//switch (iIndex) | 211 | }//switch (iIndex) |
212 | |||
213 | // we shouldn't come here | ||
214 | return 0; | ||
215 | |||
188 | }// fct x2Euro | 216 | }// fct x2Euro |
diff --git a/noncore/tools/euroconv/calcdisplay.h b/noncore/tools/euroconv/calcdisplay.h index 17ce8f4..d1902cf 100644 --- a/noncore/tools/euroconv/calcdisplay.h +++ b/noncore/tools/euroconv/calcdisplay.h | |||
@@ -1,57 +1,89 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | * | 2 | * |
3 | * File: calcdisplay.h | 3 | * File: calcdisplay.h |
4 | * | 4 | * |
5 | * Description: Header file for the class LCDDisplay | 5 | * Description: Header file for the class LCDDisplay |
6 | * | 6 | * |
7 | * | 7 | * |
8 | * Authors: Eric Santonacci <Eric.Santonacci@talc.fr> | 8 | * Authors: Eric Santonacci <Eric.Santonacci@talc.fr> |
9 | * | 9 | * |
10 | * Requirements: Qt | 10 | * Requirements: Qt |
11 | * | 11 | * |
12 | * $Id$ | 12 | * $Id$ |
13 | * | 13 | * |
14 | * | 14 | * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | #ifndef CALCDISPLAY_H | 16 | #ifndef CALCDISPLAY_H |
17 | #define CALCDISPLAY_H | 17 | #define CALCDISPLAY_H |
18 | 18 | ||
19 | #include <qhbox.h> | 19 | #include <qhbox.h> |
20 | #include <qlcdnumber.h> | 20 | #include <qlcdnumber.h> |
21 | #include <qvgroupbox.h> | 21 | #include <qhgroupbox.h> |
22 | #include <qpushbutton.h> | 22 | #include <qpushbutton.h> |
23 | #include <qcombobox.h> | 23 | #include <qcombobox.h> |
24 | 24 | ||
25 | |||
26 | /* XPM */ | ||
27 | static char *swap_xpm[] = { | ||
28 | /* width height num_colors chars_per_pixel */ | ||
29 | " 13 18 2 1", | ||
30 | /* colors */ | ||
31 | ". c None", | ||
32 | "# c #000000", | ||
33 | /* pixels */ | ||
34 | "..#######....", | ||
35 | "..#####......", | ||
36 | "..######.....", | ||
37 | "..#...###....", | ||
38 | "........##...", | ||
39 | ".........##..", | ||
40 | "..........##.", | ||
41 | "...........##", | ||
42 | "...........##", | ||
43 | "...........##", | ||
44 | "...........##", | ||
45 | "..........##.", | ||
46 | ".........##..", | ||
47 | "........##...", | ||
48 | "..#...###....", | ||
49 | "..######.....", | ||
50 | "..#####......", | ||
51 | "..#######....", | ||
52 | }; | ||
53 | |||
54 | |||
25 | class LCDDisplay : public QHBox{ | 55 | class LCDDisplay : public QHBox{ |
26 | 56 | ||
27 | Q_OBJECT | 57 | Q_OBJECT |
28 | public: | 58 | public: |
29 | LCDDisplay( QWidget *parent=0, const char *name=0 ); | 59 | LCDDisplay( QWidget *parent=0, const char *name=0 ); |
30 | 60 | ||
31 | public slots: | 61 | public slots: |
32 | void setValue(double); | 62 | void setValue(double); |
33 | void swapLCD(void); | 63 | void swapLCD(void); |
34 | void cbbxChange(void); | 64 | void cbbxChange(void); |
35 | 65 | ||
36 | //signals: | 66 | //signals: |
37 | // void valueChanged( int ); | 67 | // void valueChanged( int ); |
38 | private: | 68 | private: |
39 | QVGroupBox *grpbxTop; | 69 | int grpbxStyle; |
70 | |||
71 | QHGroupBox *grpbxTop; | ||
40 | QComboBox *cbbxTop; | 72 | QComboBox *cbbxTop; |
41 | QLCDNumber *lcdTop; | 73 | QLCDNumber *lcdTop; |
42 | 74 | ||
43 | QVGroupBox *grpbxBottom; | 75 | QHGroupBox *grpbxBottom; |
44 | QComboBox *cbbxBottom; | 76 | QComboBox *cbbxBottom; |
45 | QLCDNumber *lcdBottom; | 77 | QLCDNumber *lcdBottom; |
46 | 78 | ||
47 | QPushButton *btnSwap; | 79 | QPushButton *btnSwap; |
48 | 80 | ||
49 | int iCurrentLCD; // 0=top, 1=bottom | 81 | int iCurrentLCD; // 0=top, 1=bottom |
50 | 82 | ||
51 | double Euro2x(int iIndex, double dValue); | 83 | double Euro2x(int iIndex, double dValue); |
52 | double x2Euro(int iIndex, double dValue); | 84 | double x2Euro(int iIndex, double dValue); |
53 | 85 | ||
54 | 86 | ||
55 | }; | 87 | }; |
56 | 88 | ||
57 | #endif // CALCDISPLAY_H | 89 | #endif // CALCDISPLAY_H |
diff --git a/noncore/tools/euroconv/calckeypad.cpp b/noncore/tools/euroconv/calckeypad.cpp index 4156570..f1d61c0 100644 --- a/noncore/tools/euroconv/calckeypad.cpp +++ b/noncore/tools/euroconv/calckeypad.cpp | |||
@@ -1,191 +1,207 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | * | 2 | * |
3 | * File: calckeypad.cpp | 3 | * File: calckeypad.cpp |
4 | * | 4 | * |
5 | * Description: | 5 | * Description: |
6 | * | 6 | * |
7 | * | 7 | * |
8 | * Authors: Eric Santonacci <Eric.Santonacci@talc.fr> | 8 | * Authors: Eric Santonacci <Eric.Santonacci@talc.fr> |
9 | * | 9 | * |
10 | * Requirements: Qt | 10 | * Requirements: Qt |
11 | * | 11 | * |
12 | * $Id$ | 12 | * $Id$ |
13 | * | 13 | * |
14 | ***************************************************************************/ | 14 | ***************************************************************************/ |
15 | 15 | ||
16 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
17 | 17 | ||
18 | #include "calckeypad.h" | 18 | #include "calckeypad.h" |
19 | 19 | ||
20 | 20 | ||
21 | KeyPad::KeyPad(LCDDisplay *lcd, QWidget *parent, const char *name ) | 21 | KeyPad::KeyPad(LCDDisplay *lcd, QWidget *parent, const char *name ) |
22 | : QGrid(5, parent, name){ | 22 | : QGrid(5, parent, name){ |
23 | 23 | ||
24 | int i; | ||
25 | QButton *btnButton; | ||
24 | 26 | ||
25 | // save lcd at init | 27 | // save lcd at init |
26 | display = lcd; | 28 | display = lcd; |
27 | // Init variable | 29 | // Init variable |
28 | dCurrent = 0; | 30 | dCurrent = 0; |
29 | iLenCurrent = 1; | 31 | iLenCurrent = 1; |
30 | bIsDec = false; | 32 | bIsDec = false; |
31 | dDecCurrent = 0; | 33 | dDecCurrent = 0; |
32 | iPreviousOperator = 0; | 34 | iPreviousOperator = 0; |
33 | dPreviousValue = 0; | 35 | dPreviousValue = 0; |
34 | 36 | ||
35 | // First line | 37 | // First line |
36 | btnClear = new QPushButton("CE/C", this, "Clear"); | 38 | btnClear = new QPushButton("CE/C", this, "Clear"); |
37 | btn7 = new QPushButton("7", this, "7"); | 39 | btn7 = new QPushButton("7", this, "7"); |
38 | btn8 = new QPushButton("8", this, "8"); | 40 | btn8 = new QPushButton("8", this, "8"); |
39 | btn9 = new QPushButton("9", this, "9"); | 41 | btn9 = new QPushButton("9", this, "9"); |
40 | btnPlus = new QPushButton("+", this, "+"); | 42 | btnPlus = new QPushButton("+", this, "+"); |
41 | // 2nd line | 43 | // 2nd line |
42 | btnPercent = new QPushButton("%", this, "percent"); | 44 | btnPercent = new QPushButton("%", this, "percent"); |
43 | btn4 = new QPushButton("4", this, "4"); | 45 | btn4 = new QPushButton("4", this, "4"); |
44 | btn5 = new QPushButton("5", this, "5"); | 46 | btn5 = new QPushButton("5", this, "5"); |
45 | btn6 = new QPushButton("6", this, "6"); | 47 | btn6 = new QPushButton("6", this, "6"); |
46 | btnMinus = new QPushButton("-", this, "-"); | 48 | btnMinus = new QPushButton("-", this, "-"); |
47 | // 3rd line | 49 | // 3rd line |
48 | btnF1 = new QPushButton("",this, "F1"); | 50 | btnF1 = new QPushButton("",this, "F1"); |
49 | btn1 = new QPushButton("1", this, "1"); | 51 | btn1 = new QPushButton("1", this, "1"); |
50 | btn2 = new QPushButton("2", this, "2"); | 52 | btn2 = new QPushButton("2", this, "2"); |
51 | btn3 = new QPushButton("3", this, "3"); | 53 | btn3 = new QPushButton("3", this, "3"); |
52 | btnMultiply = new QPushButton("X", this, "X"); | 54 | btnMultiply = new QPushButton("X", this, "X"); |
53 | // 4th line | 55 | // 4th line |
54 | btnAbout = new QPushButton("?", this, "About"); | 56 | btnAbout = new QPushButton("?", this, "About"); |
55 | btn0 = new QPushButton("0", this, "0"); | 57 | btn0 = new QPushButton("0", this, "0"); |
56 | btnDot = new QPushButton(".", this, "dot"); | 58 | btnDot = new QPushButton(".", this, "dot"); |
57 | btnEqual = new QPushButton("=", this, "equal"); | 59 | btnEqual = new QPushButton("=", this, "equal"); |
58 | btnDivide = new QPushButton("/", this, "divide"); | 60 | btnDivide = new QPushButton("/", this, "divide"); |
59 | 61 | ||
60 | // Digit key | 62 | // Digit key |
61 | grpbtnDigits = new QButtonGroup(0, "digits"); | 63 | grpbtnDigits = new QButtonGroup(0, "digits"); |
62 | grpbtnDigits->insert(btn0, 0); | 64 | grpbtnDigits->insert(btn0, 0); |
63 | grpbtnDigits->insert(btn1, 1); | 65 | grpbtnDigits->insert(btn1, 1); |
64 | grpbtnDigits->insert(btn2, 2); | 66 | grpbtnDigits->insert(btn2, 2); |
65 | grpbtnDigits->insert(btn3, 3); | 67 | grpbtnDigits->insert(btn3, 3); |
66 | grpbtnDigits->insert(btn4, 4); | 68 | grpbtnDigits->insert(btn4, 4); |
67 | grpbtnDigits->insert(btn5, 5); | 69 | grpbtnDigits->insert(btn5, 5); |
68 | grpbtnDigits->insert(btn6, 6); | 70 | grpbtnDigits->insert(btn6, 6); |
69 | grpbtnDigits->insert(btn7, 7); | 71 | grpbtnDigits->insert(btn7, 7); |
70 | grpbtnDigits->insert(btn8, 8); | 72 | grpbtnDigits->insert(btn8, 8); |
71 | grpbtnDigits->insert(btn9, 9); | 73 | grpbtnDigits->insert(btn9, 9); |
72 | 74 | ||
75 | // set appearance of buttons | ||
76 | for(i=0; i<10; i++){ | ||
77 | btnButton = grpbtnDigits->find(i); | ||
78 | btnButton->setFixedSize(30,30); | ||
79 | } | ||
80 | |||
73 | // Operator key | 81 | // Operator key |
74 | grpbtnOperators = new QButtonGroup(0, "operator"); | 82 | grpbtnOperators = new QButtonGroup(0, "operator"); |
75 | grpbtnOperators->insert(btnPlus, 1); | 83 | grpbtnOperators->insert(btnPlus, 1); |
76 | grpbtnOperators->insert(btnMinus,2); | 84 | grpbtnOperators->insert(btnMinus,2); |
77 | grpbtnOperators->insert(btnMultiply,3); | 85 | grpbtnOperators->insert(btnMultiply,3); |
78 | grpbtnOperators->insert(btnDivide,4); | 86 | grpbtnOperators->insert(btnDivide,4); |
79 | grpbtnOperators->insert(btnEqual,5); | 87 | grpbtnOperators->insert(btnEqual,5); |
88 | // set appearance of buttons | ||
89 | for(i=1; i<6; i++){ | ||
90 | btnButton = grpbtnOperators->find(i); | ||
91 | btnButton->setFixedSize(30,30); | ||
92 | } | ||
93 | btnClear->setFixedSize(30,30); | ||
94 | btnClear->setPalette(QPalette( QColor(255, 99, 71) ) ); | ||
95 | btnDot->setFixedSize(30,30); | ||
96 | btnPercent->setFixedSize(30,30); | ||
97 | btnF1->setFixedSize(30,30); | ||
98 | btnAbout->setFixedSize(30,30); | ||
80 | 99 | ||
81 | 100 | ||
82 | // SIGNALS AND SLOTS | 101 | // SIGNALS AND SLOTS |
83 | connect(grpbtnDigits, SIGNAL(clicked(int) ), this, SLOT(enterDigits(int))); | 102 | connect(grpbtnDigits, SIGNAL(clicked(int) ), this, SLOT(enterDigits(int))); |
84 | connect(grpbtnOperators, SIGNAL(clicked(int)), this, SLOT(operatorPressed(int))); | 103 | connect(grpbtnOperators, SIGNAL(clicked(int)), this, SLOT(operatorPressed(int))); |
85 | connect(btnClear, SIGNAL(clicked()), this, SLOT(clearLCD())); | 104 | connect(btnClear, SIGNAL(clicked()), this, SLOT(clearLCD())); |
86 | connect(btnAbout, SIGNAL(clicked()), this, SLOT(aboutDialog())); | 105 | connect(btnAbout, SIGNAL(clicked()), this, SLOT(aboutDialog())); |
87 | connect(btnDot, SIGNAL(clicked()), this, SLOT(gotoDec())); | 106 | connect(btnDot, SIGNAL(clicked()), this, SLOT(gotoDec())); |
88 | } | 107 | } |
89 | 108 | ||
90 | 109 | ||
91 | /*********************************************************************** | 110 | /*********************************************************************** |
92 | * SLOT: enterDigits calculates the value to display and display it. | 111 | * SLOT: enterDigits calculates the value to display and display it. |
93 | **********************************************************************/ | 112 | **********************************************************************/ |
94 | void KeyPad::enterDigits(int i){ | 113 | void KeyPad::enterDigits(int i){ |
95 | 114 | ||
96 | if(!dCurrent) | 115 | if(!dCurrent) |
97 | dCurrent = i; | 116 | dCurrent = i; |
98 | else if(!bIsDec){ | 117 | else if(!bIsDec){ |
99 | if(iLenCurrent > 9) | 118 | if(iLenCurrent > 9) |
100 | return; | 119 | return; |
101 | dCurrent *= 10; | 120 | dCurrent *= 10; |
102 | dCurrent += i; | 121 | dCurrent += i; |
103 | iLenCurrent++; | 122 | iLenCurrent++; |
104 | }else{ | 123 | }else{ |
105 | dCurrent += i*dDecCurrent; | 124 | dCurrent += i*dDecCurrent; |
106 | dDecCurrent /= 10; | 125 | dDecCurrent /= 10; |
107 | } | 126 | } |
108 | 127 | ||
109 | display->setValue(dCurrent); | 128 | display->setValue(dCurrent); |
110 | } | 129 | } |
111 | 130 | ||
112 | /*********************************************************************** | 131 | /*********************************************************************** |
113 | * SLOT: Operator has been pressed | 132 | * SLOT: Operator has been pressed |
114 | **********************************************************************/ | 133 | **********************************************************************/ |
115 | void KeyPad::operatorPressed(int i){ | 134 | void KeyPad::operatorPressed(int i){ |
116 | 135 | ||
117 | if(iPreviousOperator){ | 136 | if(iPreviousOperator){ |
118 | switch(iPreviousOperator){ | 137 | switch(iPreviousOperator){ |
119 | case 1: // Plus + | 138 | case 1: // Plus + |
120 | dCurrent += dPreviousValue; | 139 | dCurrent += dPreviousValue; |
121 | break; | 140 | break; |
122 | 141 | ||
123 | case 2: // Minus - | 142 | case 2: // Minus - |
124 | dCurrent = dPreviousValue - dCurrent; | 143 | dCurrent = dPreviousValue - dCurrent; |
125 | break; | 144 | break; |
126 | 145 | ||
127 | case 3: // Multiply * | 146 | case 3: // Multiply * |
128 | dCurrent *= dPreviousValue; | 147 | dCurrent *= dPreviousValue; |
129 | break; | 148 | break; |
130 | 149 | ||
131 | case 4: // Divide / | 150 | case 4: // Divide / |
132 | dCurrent = dPreviousValue / dCurrent; | 151 | dCurrent = dPreviousValue / dCurrent; |
133 | break; | 152 | break; |
134 | 153 | ||
135 | } | 154 | } |
136 | display->setValue(dCurrent); | 155 | display->setValue(dCurrent); |
137 | } | 156 | } |
138 | if(i == 5){ | ||
139 | // key '=' pressed | ||
140 | dPreviousValue = 0; | ||
141 | iPreviousOperator = 0; | ||
142 | // We don't want to add digits | ||
143 | iLenCurrent = 100; | ||
144 | }else{ | ||
145 | dPreviousValue = dCurrent; | ||
146 | iPreviousOperator = i; | ||
147 | // reset LCD for next digit | ||
148 | dCurrent = 0; | ||
149 | iLenCurrent = 1; | ||
150 | bIsDec = false; | ||
151 | dDecCurrent = 0; | ||
152 | } | ||
153 | 157 | ||
158 | dPreviousValue = dCurrent; | ||
159 | iPreviousOperator = i; | ||
160 | |||
161 | // reset LCD for next digit | ||
162 | dCurrent = 0; | ||
163 | iLenCurrent = 1; | ||
164 | bIsDec = false; | ||
165 | dDecCurrent = 0; | ||
154 | } | 166 | } |
155 | /*********************************************************************** | 167 | /*********************************************************************** |
156 | * SLOT: clearLCD CE/C has been pressed | 168 | * SLOT: clearLCD CE/C has been pressed |
157 | **********************************************************************/ | 169 | **********************************************************************/ |
158 | void KeyPad::clearLCD(void){ | 170 | void KeyPad::clearLCD(void){ |
159 | 171 | ||
160 | dCurrent = 0; | 172 | dCurrent = 0; |
161 | iLenCurrent = 1; | 173 | iLenCurrent = 1; |
162 | bIsDec = false; | 174 | bIsDec = false; |
163 | dDecCurrent = 0; | 175 | dDecCurrent = 0; |
164 | iPreviousOperator = 0; | 176 | iPreviousOperator = 0; |
165 | dPreviousValue = 0; | 177 | dPreviousValue = 0; |
166 | display->setValue(0); | 178 | display->setValue(0); |
167 | } | 179 | } |
168 | 180 | ||
169 | /*********************************************************************** | 181 | /*********************************************************************** |
170 | * SLOT: gotoDec Dot has been pressed | 182 | * SLOT: gotoDec Dot has been pressed |
171 | **********************************************************************/ | 183 | **********************************************************************/ |
172 | void KeyPad::gotoDec(void){ | 184 | void KeyPad::gotoDec(void){ |
173 | 185 | ||
174 | bIsDec = true; | 186 | bIsDec = true; |
175 | dDecCurrent = 0.1; | 187 | dDecCurrent = 0.1; |
176 | } | 188 | } |
177 | 189 | ||
178 | 190 | ||
179 | 191 | ||
180 | /*********************************************************************** | 192 | /*********************************************************************** |
181 | * SLOT: Display About Dialog... | 193 | * SLOT: Display About Dialog... |
182 | **********************************************************************/ | 194 | **********************************************************************/ |
183 | void KeyPad::aboutDialog(void){ | 195 | void KeyPad::aboutDialog(void){ |
184 | 196 | ||
185 | QMessageBox::about( this, "About Euroconv", | 197 | QMessageBox::about( this, "About Euroconv", |
186 | "Euroconv is an Euro converter\n\n" | 198 | "Euroconv is an Euro converter\n\n" |
187 | "Copyright 2003 TALC Informatique.\n" | 199 | "Copyright 2003 TALC Informatique.\n" |
188 | "Under GPL license\n\n" | 200 | "Under GPL license\n\n" |
189 | "Written by Eric Santonacci for Opie\n" | 201 | "Written by Eric Santonacci for Opie\n" |
190 | "http://opie.handhelds.org\n" ); | 202 | "http://opie.handhelds.org\n\n" |
203 | "Version 0.2\n\n" | ||
204 | "Any comment or feedback to:\n" | ||
205 | "Eric.Santonacci@talc.fr\n"); | ||
206 | |||
191 | } | 207 | } |
diff --git a/noncore/tools/euroconv/calckeypad.h b/noncore/tools/euroconv/calckeypad.h index 42e7eb3..aac3f41 100644 --- a/noncore/tools/euroconv/calckeypad.h +++ b/noncore/tools/euroconv/calckeypad.h | |||
@@ -42,37 +42,37 @@ private: | |||
42 | bool bIsDec; | 42 | bool bIsDec; |
43 | double dDecCurrent; | 43 | double dDecCurrent; |
44 | int iPreviousOperator; | 44 | int iPreviousOperator; |
45 | double dPreviousValue; | 45 | double dPreviousValue; |
46 | 46 | ||
47 | QPushButton *btn0; | 47 | QPushButton *btn0; |
48 | QPushButton *btn1; | 48 | QPushButton *btn1; |
49 | QPushButton *btn2; | 49 | QPushButton *btn2; |
50 | QPushButton *btn3; | 50 | QPushButton *btn3; |
51 | QPushButton *btn4; | 51 | QPushButton *btn4; |
52 | QPushButton *btn5; | 52 | QPushButton *btn5; |
53 | QPushButton *btn6; | 53 | QPushButton *btn6; |
54 | QPushButton *btn7; | 54 | QPushButton *btn7; |
55 | QPushButton *btn8; | 55 | QPushButton *btn8; |
56 | QPushButton *btn9; | 56 | QPushButton *btn9; |
57 | QButtonGroup *grpbtnDigits; | 57 | QButtonGroup *grpbtnDigits; |
58 | 58 | ||
59 | QPushButton *btnDot; | 59 | QPushButton *btnDot; |
60 | 60 | ||
61 | QPushButton *btnClear; | 61 | QPushButton *btnClear; |
62 | 62 | ||
63 | QPushButton *btnPlus; | 63 | QPushButton *btnPlus; |
64 | QPushButton *btnMinus; | 64 | QPushButton *btnMinus; |
65 | QPushButton *btnMultiply; | 65 | QPushButton *btnMultiply; |
66 | QPushButton *btnDivide; | 66 | QPushButton *btnDivide; |
67 | QPushButton *btnEqual; | 67 | QPushButton *btnEqual; |
68 | QPushButton *btnPercent; | 68 | QPushButton *btnPercent; |
69 | QPushButton *btnF1; | 69 | QPushButton *btnF1; |
70 | QPushButton *btnAbout; | 70 | QPushButton *btnAbout; |
71 | 71 | ||
72 | QButtonGroup *grpbtnOperators; | 72 | QButtonGroup *grpbtnOperators; |
73 | 73 | ||
74 | 74 | void setAppearance(void); | |
75 | 75 | ||
76 | }; | 76 | }; |
77 | 77 | ||
78 | #endif // CALCKEYPAD_H | 78 | #endif // CALCKEYPAD_H |
diff --git a/noncore/tools/euroconv/currency.h b/noncore/tools/euroconv/currency.h index 90f5b57..d9ee75c 100644 --- a/noncore/tools/euroconv/currency.h +++ b/noncore/tools/euroconv/currency.h | |||
@@ -1,20 +1,20 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | * | 2 | * |
3 | * File: currency.h | 3 | * File: currency.h |
4 | * | 4 | * |
5 | * Description: define constant for currency compare Euro | 5 | * Description: define constant for currency compare Euro |
6 | * | 6 | * |
7 | * | 7 | * |
8 | * Authors: Eric Santonacci <Eric.Santonacci@talc.fr> | 8 | * Authors: Eric Santonacci <Eric.Santonacci@talc.fr> |
9 | * | 9 | * |
10 | * | 10 | * |
11 | * $Id$ | 11 | * $Id$ |
12 | * | 12 | * |
13 | ***************************************************************************/ | 13 | ***************************************************************************/ |
14 | 14 | ||
15 | // 1 Euro equal.... | 15 | // 1 Euro equal.... |
16 | #define EURO 1 // Euro | 16 | #define EURO 1 // Euro |
17 | #define FF 6.55957 // French Francs | 17 | #define FF 6.55957 // French Francs |
18 | #define DM 1.96 // Deutch Mark | 18 | #define DM 1.9594 // Deutch Mark |
19 | 19 | ||
20 | static const char* aCurrency[] = { "Euro", "French Frs", "DM", 0 }; | 20 | static const char* aCurrency[] = { "Euro", "FF", "DM", 0 }; |