-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 | |||
@@ -16,4 +16,5 @@ | |||
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" |
@@ -25,22 +26,39 @@ LCDDisplay::LCDDisplay( QWidget *parent, const char *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 |
@@ -48,7 +66,8 @@ 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())); |
@@ -57,6 +76,4 @@ connect(btnSwap, SIGNAL(clicked()), this, SLOT(swapLCD())); | |||
57 | iCurrentLCD = 0; | 76 | iCurrentLCD = 0; |
58 | 77 | ||
59 | //setValue(123.456); | ||
60 | |||
61 | } | 78 | } |
62 | 79 | ||
@@ -114,9 +131,15 @@ double dCurrentValue; | |||
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 | ||
@@ -131,6 +154,4 @@ void LCDDisplay::cbbxChange(void){ | |||
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){ |
@@ -162,4 +183,7 @@ switch (iIndex){ | |||
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 |
@@ -186,3 +210,7 @@ switch (iIndex){ | |||
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 | |||
@@ -19,8 +19,38 @@ | |||
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 | ||
@@ -37,9 +67,11 @@ public slots: | |||
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; |
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 | |||
@@ -22,4 +22,6 @@ 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 |
@@ -71,4 +73,10 @@ 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"); |
@@ -78,4 +86,15 @@ 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 | ||
@@ -136,20 +155,13 @@ if(iPreviousOperator){ | |||
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 | /*********************************************************************** |
@@ -188,4 +200,8 @@ QMessageBox::about( this, "About Euroconv", | |||
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 | |||
@@ -72,5 +72,5 @@ private: | |||
72 | QButtonGroup *grpbtnOperators; | 72 | QButtonGroup *grpbtnOperators; |
73 | 73 | ||
74 | 74 | void setAppearance(void); | |
75 | 75 | ||
76 | }; | 76 | }; |
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 | |||
@@ -16,5 +16,5 @@ | |||
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 }; |