Diffstat (limited to 'noncore/tools/euroconv/calcdisplay.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/tools/euroconv/calcdisplay.cpp | 50 |
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 | |||
@@ -12,55 +12,72 @@ | |||
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){ |
@@ -110,31 +127,35 @@ if(!iCurrentLCD){ | |||
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 | } |
@@ -158,12 +179,15 @@ switch (iIndex){ | |||
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 | /*********************************************************************** |
@@ -182,7 +206,11 @@ switch (iIndex){ | |||
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 |