summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/euroconv/calcdisplay.cpp50
-rw-r--r--noncore/tools/euroconv/calcdisplay.h38
-rw-r--r--noncore/tools/euroconv/calckeypad.cpp48
-rw-r--r--noncore/tools/euroconv/calckeypad.h2
-rw-r--r--noncore/tools/euroconv/currency.h4
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
@@ -10,59 +10,76 @@
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
23LCDDisplay::LCDDisplay( QWidget *parent, const char *name ) 24LCDDisplay::LCDDisplay( QWidget *parent, const char *name )
24 : QHBox( parent, name ){ 25 : QHBox( parent, name ){
25 26
26 27
28
29this->setMargin(5);
30this->setSpacing(5);
31
27// Create display 32// Create display
28QVBox *vbxlayout = new QVBox (this); 33QVBox *vbxlayout = new QVBox (this);
29 34
30grpbxTop = new QVGroupBox(vbxlayout, "grpbxTop"); 35/*************** Top LCD ***********************/
36grpbxTop = new QHGroupBox(vbxlayout, "grpbxTop");
37grpbxStyle = grpbxTop->frameStyle();
38grpbxTop->setMaximumHeight(48);
39
31cbbxTop = new QComboBox(grpbxTop, "cbbxTop"); 40cbbxTop = new QComboBox(grpbxTop, "cbbxTop");
41cbbxTop->setMaximumWidth(50);
42cbbxTop->insertStrList(aCurrency);
43
32lcdTop = new QLCDNumber(10, grpbxTop, "lcdTop"); 44lcdTop = new QLCDNumber(10, grpbxTop, "lcdTop");
33lcdTop->setMode( QLCDNumber::DEC ); 45lcdTop->setMode( QLCDNumber::DEC );
34lcdTop->setSmallDecimalPoint(true); 46lcdTop->setSmallDecimalPoint(true);
35lcdTop->setSegmentStyle(QLCDNumber::Flat); 47lcdTop->setSegmentStyle(QLCDNumber::Flat);
36cbbxTop->insertStrList(aCurrency);
37 48
38grpbxBottom = new QVGroupBox(vbxlayout, "grpbxBottom"); 49/************** Bottom LCD ************************/
50grpbxBottom = new QHGroupBox(vbxlayout, "grpbxBottom");
51grpbxBottom->setMaximumHeight(46);
52grpbxBottom->setFrameStyle(0);
53grpbxBottom->setFrameShadow(QFrame::MShadow);
54
39cbbxBottom = new QComboBox(grpbxBottom, "cbbxBottom"); 55cbbxBottom = new QComboBox(grpbxBottom, "cbbxBottom");
56cbbxBottom->setMaximumWidth(50);
57cbbxBottom->insertStrList(aCurrency);
58
40lcdBottom = new QLCDNumber(10, grpbxBottom, "lcdBottom"); 59lcdBottom = new QLCDNumber(10, grpbxBottom, "lcdBottom");
41lcdBottom->setMode( QLCDNumber::DEC ); 60lcdBottom->setMode( QLCDNumber::DEC );
42lcdBottom->setSmallDecimalPoint(true); 61lcdBottom->setSmallDecimalPoint(true);
43lcdBottom->setSegmentStyle(QLCDNumber::Flat); 62lcdBottom->setSegmentStyle(QLCDNumber::Flat);
44cbbxBottom->insertStrList(aCurrency);
45 63
46// set combo box signals 64// set combo box signals
47connect(cbbxTop, SIGNAL(activated(int)), this, SLOT(cbbxChange())); 65connect(cbbxTop, SIGNAL(activated(int)), this, SLOT(cbbxChange()));
48connect(cbbxBottom, SIGNAL(activated(int)), this, SLOT(cbbxChange())); 66connect(cbbxBottom, SIGNAL(activated(int)), this, SLOT(cbbxChange()));
49 67
50btnSwap = new QPushButton("S",this, "swap"); 68btnSwap = new QPushButton(this, "swap");
51btnSwap->setMaximumSize(20,50); 69QPixmap imgSwap((const char**) swap_xpm);
52btnSwap->setMinimumSize(20,50); 70btnSwap->setPixmap(imgSwap);
71btnSwap->setFixedSize(20,40);
53// set signal 72// set signal
54connect(btnSwap, SIGNAL(clicked()), this, SLOT(swapLCD())); 73connect(btnSwap, SIGNAL(clicked()), this, SLOT(swapLCD()));
55 74
56// set default LCD to top 75// set default LCD to top
57iCurrentLCD = 0; 76iCurrentLCD = 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 **********************************************************************/
66void LCDDisplay::setValue(double dSrcValue){ 83void LCDDisplay::setValue(double dSrcValue){
67 84
68double dDstValue=0; 85double dDstValue=0;
@@ -108,35 +125,39 @@ if(!iCurrentLCD){
108 * SLOT: Swap output keypad between LCD displays 125 * SLOT: Swap output keypad between LCD displays
109 **********************************************************************/ 126 **********************************************************************/
110void LCDDisplay::swapLCD(void){ 127void LCDDisplay::swapLCD(void){
111 128
112double dCurrentValue; 129double dCurrentValue;
113 130
114// get current value 131// get current value
115if(!iCurrentLCD){ 132if(!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
123setValue(dCurrentValue); 146setValue(dCurrentValue);
124} 147}
125 148
126/*********************************************************************** 149/***********************************************************************
127 * SLOT: Currency change 150 * SLOT: Currency change
128 **********************************************************************/ 151 **********************************************************************/
129void LCDDisplay::cbbxChange(void){ 152void LCDDisplay::cbbxChange(void){
130 153
131double dCurrentValue; 154double dCurrentValue;
132 155
133printf("combo changes...\n");
134
135// get current value 156// get current value
136if(!iCurrentLCD){ 157if(!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
142setValue(dCurrentValue); 163setValue(dCurrentValue);
@@ -156,16 +177,19 @@ switch (iIndex){
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.
@@ -180,9 +204,13 @@ switch (iIndex){
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
214return 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
@@ -13,39 +13,71 @@
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 */
27static 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
25class LCDDisplay : public QHBox{ 55class LCDDisplay : public QHBox{
26 56
27Q_OBJECT 57Q_OBJECT
28public: 58public:
29 LCDDisplay( QWidget *parent=0, const char *name=0 ); 59 LCDDisplay( QWidget *parent=0, const char *name=0 );
30 60
31public slots: 61public 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 );
38private: 68private:
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);
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
@@ -16,16 +16,18 @@
16#include <qmessagebox.h> 16#include <qmessagebox.h>
17 17
18#include "calckeypad.h" 18#include "calckeypad.h"
19 19
20 20
21KeyPad::KeyPad(LCDDisplay *lcd, QWidget *parent, const char *name ) 21KeyPad::KeyPad(LCDDisplay *lcd, QWidget *parent, const char *name )
22 : QGrid(5, parent, name){ 22 : QGrid(5, parent, name){
23 23
24int i;
25QButton *btnButton;
24 26
25// save lcd at init 27// save lcd at init
26display = lcd; 28display = lcd;
27// Init variable 29// Init variable
28dCurrent = 0; 30dCurrent = 0;
29iLenCurrent = 1; 31iLenCurrent = 1;
30bIsDec = false; 32bIsDec = false;
31dDecCurrent = 0; 33dDecCurrent = 0;
@@ -65,23 +67,40 @@ grpbtnDigits->insert(btn2, 2);
65grpbtnDigits->insert(btn3, 3); 67grpbtnDigits->insert(btn3, 3);
66grpbtnDigits->insert(btn4, 4); 68grpbtnDigits->insert(btn4, 4);
67grpbtnDigits->insert(btn5, 5); 69grpbtnDigits->insert(btn5, 5);
68grpbtnDigits->insert(btn6, 6); 70grpbtnDigits->insert(btn6, 6);
69grpbtnDigits->insert(btn7, 7); 71grpbtnDigits->insert(btn7, 7);
70grpbtnDigits->insert(btn8, 8); 72grpbtnDigits->insert(btn8, 8);
71grpbtnDigits->insert(btn9, 9); 73grpbtnDigits->insert(btn9, 9);
72 74
75// set appearance of buttons
76for(i=0; i<10; i++){
77 btnButton = grpbtnDigits->find(i);
78 btnButton->setFixedSize(30,30);
79}
80
73// Operator key 81// Operator key
74grpbtnOperators = new QButtonGroup(0, "operator"); 82grpbtnOperators = new QButtonGroup(0, "operator");
75grpbtnOperators->insert(btnPlus, 1); 83grpbtnOperators->insert(btnPlus, 1);
76grpbtnOperators->insert(btnMinus,2); 84grpbtnOperators->insert(btnMinus,2);
77grpbtnOperators->insert(btnMultiply,3); 85grpbtnOperators->insert(btnMultiply,3);
78grpbtnOperators->insert(btnDivide,4); 86grpbtnOperators->insert(btnDivide,4);
79grpbtnOperators->insert(btnEqual,5); 87grpbtnOperators->insert(btnEqual,5);
88// set appearance of buttons
89for(i=1; i<6; i++){
90 btnButton = grpbtnOperators->find(i);
91 btnButton->setFixedSize(30,30);
92}
93btnClear->setFixedSize(30,30);
94btnClear->setPalette(QPalette( QColor(255, 99, 71) ) );
95btnDot->setFixedSize(30,30);
96btnPercent->setFixedSize(30,30);
97btnF1->setFixedSize(30,30);
98btnAbout->setFixedSize(30,30);
80 99
81 100
82// SIGNALS AND SLOTS 101// SIGNALS AND SLOTS
83connect(grpbtnDigits, SIGNAL(clicked(int) ), this, SLOT(enterDigits(int))); 102connect(grpbtnDigits, SIGNAL(clicked(int) ), this, SLOT(enterDigits(int)));
84connect(grpbtnOperators, SIGNAL(clicked(int)), this, SLOT(operatorPressed(int))); 103connect(grpbtnOperators, SIGNAL(clicked(int)), this, SLOT(operatorPressed(int)));
85connect(btnClear, SIGNAL(clicked()), this, SLOT(clearLCD())); 104connect(btnClear, SIGNAL(clicked()), this, SLOT(clearLCD()));
86connect(btnAbout, SIGNAL(clicked()), this, SLOT(aboutDialog())); 105connect(btnAbout, SIGNAL(clicked()), this, SLOT(aboutDialog()));
87connect(btnDot, SIGNAL(clicked()), this, SLOT(gotoDec())); 106connect(btnDot, SIGNAL(clicked()), this, SLOT(gotoDec()));
@@ -130,32 +149,25 @@ if(iPreviousOperator){
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}
138if(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
158dPreviousValue = dCurrent;
159iPreviousOperator = i;
160
161// reset LCD for next digit
162dCurrent = 0;
163iLenCurrent = 1;
164bIsDec = false;
165dDecCurrent = 0;
154} 166}
155/*********************************************************************** 167/***********************************************************************
156 * SLOT: clearLCD CE/C has been pressed 168 * SLOT: clearLCD CE/C has been pressed
157 **********************************************************************/ 169 **********************************************************************/
158void KeyPad::clearLCD(void){ 170void KeyPad::clearLCD(void){
159 171
160dCurrent = 0; 172dCurrent = 0;
161iLenCurrent = 1; 173iLenCurrent = 1;
@@ -182,10 +194,14 @@ dDecCurrent = 0.1;
182 **********************************************************************/ 194 **********************************************************************/
183void KeyPad::aboutDialog(void){ 195void KeyPad::aboutDialog(void){
184 196
185QMessageBox::about( this, "About Euroconv", 197QMessageBox::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
@@ -66,13 +66,13 @@ private:
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
@@ -10,11 +10,11 @@
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
20static const char* aCurrency[] = { "Euro", "French Frs", "DM", 0 }; 20static const char* aCurrency[] = { "Euro", "FF", "DM", 0 };