summaryrefslogtreecommitdiff
path: root/noncore/tools/euroconv/calcdisplay.cpp
Unidiff
Diffstat (limited to 'noncore/tools/euroconv/calcdisplay.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/euroconv/calcdisplay.cpp50
1 files changed, 39 insertions, 11 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
@@ -6,67 +6,84 @@
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
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;
69 86
70int iSrcIndex; 87int iSrcIndex;
71int iDstIndex; 88int iDstIndex;
72 89
@@ -104,43 +121,47 @@ if(!iCurrentLCD){
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 **********************************************************************/
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);
143} 164}
144 165
145 166
146/*********************************************************************** 167/***********************************************************************
@@ -152,37 +173,44 @@ double LCDDisplay::Euro2x(int iIndex, double dValue){
152switch (iIndex){ 173switch (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 **********************************************************************/
173double LCDDisplay::x2Euro(int iIndex, double dValue){ 197double LCDDisplay::x2Euro(int iIndex, double dValue){
174 198
175switch (iIndex){ 199switch (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
214return 0;
215
188}// fct x2Euro 216}// fct x2Euro