summaryrefslogtreecommitdiff
authorcniehaus <cniehaus>2002-12-26 16:27:41 (UTC)
committer cniehaus <cniehaus>2002-12-26 16:27:41 (UTC)
commit4ccadc49c02a7412fd82eeb98eba3c7cd7f5c05f (patch) (unidiff)
tree6bcf36b728b6c9db70c00ccf2c16f7b082581124
parent6ba7eeea65ba60d022c0d9d041660ceffb2b76f6 (diff)
downloadopie-4ccadc49c02a7412fd82eeb98eba3c7cd7f5c05f.zip
opie-4ccadc49c02a7412fd82eeb98eba3c7cd7f5c05f.tar.gz
opie-4ccadc49c02a7412fd82eeb98eba3c7cd7f5c05f.tar.bz2
adding a nice feature: now the user sees which element he is looking at
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/oxygen/calcdlg.ui4
-rw-r--r--noncore/apps/oxygen/psewidget.cpp24
-rw-r--r--noncore/apps/oxygen/psewidget.h2
3 files changed, 17 insertions, 13 deletions
diff --git a/noncore/apps/oxygen/calcdlg.ui b/noncore/apps/oxygen/calcdlg.ui
index c817a47..51bf334 100644
--- a/noncore/apps/oxygen/calcdlg.ui
+++ b/noncore/apps/oxygen/calcdlg.ui
@@ -1,117 +1,113 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>CalcDlg</class> 2<class>CalcDlg</class>
3<widget> 3<widget>
4 <class>QWidget</class> 4 <class>QWidget</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>CalcDlg</cstring> 7 <cstring>CalcDlg</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>237</width> 14 <width>237</width>
15 <height>318</height> 15 <height>318</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Form1</string>
21 </property>
22 <widget> 18 <widget>
23 <class>QTabWidget</class> 19 <class>QTabWidget</class>
24 <property stdset="1"> 20 <property stdset="1">
25 <name>name</name> 21 <name>name</name>
26 <cstring>TabWidget3</cstring> 22 <cstring>TabWidget3</cstring>
27 </property> 23 </property>
28 <property stdset="1"> 24 <property stdset="1">
29 <name>geometry</name> 25 <name>geometry</name>
30 <rect> 26 <rect>
31 <x>0</x> 27 <x>0</x>
32 <y>0</y> 28 <y>0</y>
33 <width>240</width> 29 <width>240</width>
34 <height>320</height> 30 <height>320</height>
35 </rect> 31 </rect>
36 </property> 32 </property>
37 <widget> 33 <widget>
38 <class>QWidget</class> 34 <class>QWidget</class>
39 <property stdset="1"> 35 <property stdset="1">
40 <name>name</name> 36 <name>name</name>
41 <cstring>tab</cstring> 37 <cstring>tab</cstring>
42 </property> 38 </property>
43 <attribute> 39 <attribute>
44 <name>title</name> 40 <name>title</name>
45 <string>Molecular Weight</string> 41 <string>Molecular Weight</string>
46 </attribute> 42 </attribute>
47 <widget> 43 <widget>
48 <class>QLayoutWidget</class> 44 <class>QLayoutWidget</class>
49 <property stdset="1"> 45 <property stdset="1">
50 <name>name</name> 46 <name>name</name>
51 <cstring>Layout6</cstring> 47 <cstring>Layout6</cstring>
52 </property> 48 </property>
53 <property stdset="1"> 49 <property stdset="1">
54 <name>geometry</name> 50 <name>geometry</name>
55 <rect> 51 <rect>
56 <x>0</x> 52 <x>0</x>
57 <y>0</y> 53 <y>0</y>
58 <width>230</width> 54 <width>230</width>
59 <height>290</height> 55 <height>290</height>
60 </rect> 56 </rect>
61 </property> 57 </property>
62 <vbox> 58 <vbox>
63 <property stdset="1"> 59 <property stdset="1">
64 <name>margin</name> 60 <name>margin</name>
65 <number>0</number> 61 <number>0</number>
66 </property> 62 </property>
67 <property stdset="1"> 63 <property stdset="1">
68 <name>spacing</name> 64 <name>spacing</name>
69 <number>6</number> 65 <number>6</number>
70 </property> 66 </property>
71 <widget> 67 <widget>
72 <class>QLabel</class> 68 <class>QLabel</class>
73 <property stdset="1"> 69 <property stdset="1">
74 <name>name</name> 70 <name>name</name>
75 <cstring>TextLabel2</cstring> 71 <cstring>TextLabel2</cstring>
76 </property> 72 </property>
77 <property stdset="1"> 73 <property stdset="1">
78 <name>text</name> 74 <name>text</name>
79 <string>Chemical Formula</string> 75 <string>Chemical Formula</string>
80 </property> 76 </property>
81 </widget> 77 </widget>
82 <widget> 78 <widget>
83 <class>QLineEdit</class> 79 <class>QLineEdit</class>
84 <property stdset="1"> 80 <property stdset="1">
85 <name>name</name> 81 <name>name</name>
86 <cstring>formula</cstring> 82 <cstring>formula</cstring>
87 </property> 83 </property>
88 </widget> 84 </widget>
89 <widget> 85 <widget>
90 <class>QLayoutWidget</class> 86 <class>QLayoutWidget</class>
91 <property stdset="1"> 87 <property stdset="1">
92 <name>name</name> 88 <name>name</name>
93 <cstring>Layout3</cstring> 89 <cstring>Layout3</cstring>
94 </property> 90 </property>
95 <hbox> 91 <hbox>
96 <property stdset="1"> 92 <property stdset="1">
97 <name>margin</name> 93 <name>margin</name>
98 <number>0</number> 94 <number>0</number>
99 </property> 95 </property>
100 <property stdset="1"> 96 <property stdset="1">
101 <name>spacing</name> 97 <name>spacing</name>
102 <number>6</number> 98 <number>6</number>
103 </property> 99 </property>
104 <widget> 100 <widget>
105 <class>QPushButton</class> 101 <class>QPushButton</class>
106 <property stdset="1"> 102 <property stdset="1">
107 <name>name</name> 103 <name>name</name>
108 <cstring>calculate</cstring> 104 <cstring>calculate</cstring>
109 </property> 105 </property>
110 <property stdset="1"> 106 <property stdset="1">
111 <name>text</name> 107 <name>text</name>
112 <string>Calculate</string> 108 <string>Calculate</string>
113 </property> 109 </property>
114 </widget> 110 </widget>
115 <widget> 111 <widget>
116 <class>QPushButton</class> 112 <class>QPushButton</class>
117 <property stdset="1"> 113 <property stdset="1">
diff --git a/noncore/apps/oxygen/psewidget.cpp b/noncore/apps/oxygen/psewidget.cpp
index d7126b9..d8e4086 100644
--- a/noncore/apps/oxygen/psewidget.cpp
+++ b/noncore/apps/oxygen/psewidget.cpp
@@ -1,176 +1,182 @@
1/*************************************************************************** 1/***************************************************************************
2 application: : Oxygen 2 application: : Oxygen
3 3
4 begin : September 2002 4 begin : September 2002
5 copyright : ( C ) 2002 by Carsten Niehaus 5 copyright : ( C ) 2002 by Carsten Niehaus
6 email : cniehaus@handhelds.org 6 email : cniehaus@handhelds.org
7 **************************************************************************/ 7 **************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * ( at your option ) any later version. * 14 * ( at your option ) any later version. *
15 * * 15 * *
16 **************************************************************************/ 16 **************************************************************************/
17 17
18#include <qpe/config.h> 18#include <qpe/config.h>
19#include <qlayout.h> 19#include <qlayout.h>
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qlist.h> 21#include <qlist.h>
22#include "dataTable.h" 22#include "dataTable.h"
23#include "psewidget.h" 23#include "psewidget.h"
24#include "oxyframe.h" 24#include "oxyframe.h"
25 25
26 26
27PSEWidget::PSEWidget() : QWidget() 27PSEWidget::PSEWidget() : QWidget()
28{ 28{
29 this->setCaption( tr( "Periodic System" ) ); 29 this->setCaption( tr( "Periodic System" ) );
30
31 lastElement=1;
30 32
31 QVBoxLayout *vlay = new QVBoxLayout( this ); 33 QVBoxLayout *vlay = new QVBoxLayout( this );
32 34
33 QGridLayout *grid = new QGridLayout( 18,10 ); 35 QGridLayout *grid = new QGridLayout( 18,10 );
34 int h=0, v=0; 36 int h=0, v=0;
35 37
36 Config configobj( QPEApplication::qpeDir() +"share/oxygen/oxygendata", Config::File ); 38 Config configobj( QPEApplication::qpeDir() +"share/oxygen/oxygendata", Config::File );
37 for( int n = 0 ; n < 109 ; n++ ) 39 for( int n = 0 ; n < 109 ; n++ )
38 { 40 {
39 configobj.setGroup( QString::number( n+1 )); 41 configobj.setGroup( QString::number( n+1 ));
40 42
41 position( n+1,h,v ); 43 position( n+1,h,v );
42 PSEframe.append( new OxyFrame( this , QString::number(n), configobj.readEntry( "Symbol" ) ) ); 44 PSEframe.append( new OxyFrame( this , QString::number(n), configobj.readEntry( "Symbol" ) ) );
43 grid->addWidget( PSEframe.current() , v/40+1 , h/40 ); 45 grid->addWidget( PSEframe.current() , v/40+1 , h/40 );
44 PSEframe.current()->setMinimumHeight( 11 ); 46 PSEframe.current()->setMinimumHeight( 11 );
45 PSEframe.current()->setPalette( QPalette( PSEColor( configobj.readEntry( "Block" ) ) ) ); 47 PSEframe.current()->setPalette( QPalette( PSEColor( configobj.readEntry( "Block" ) ) ) );
46 connect( PSEframe.current(), SIGNAL( num(QString) ), this, SLOT( slotShowElement(QString) )); 48 connect( PSEframe.current(), SIGNAL( num(QString) ), this, SLOT( slotShowElement(QString) ));
47 connect( PSEframe.current(), SIGNAL( num(QString) ), this, SLOT( inverseColor(QString) )); 49 connect( PSEframe.current(), SIGNAL( num(QString) ), this, SLOT( inverseColor(QString) ));
48 } 50 }
49 51
50 oxyDW = new OxydataWidget(this); 52 oxyDW = new OxydataWidget(this);
51 oxyDW->setElement( 0 ); 53 oxyDW->setElement( 0 );
52 oxyDW->setLayout(); 54 oxyDW->setLayout();
53 55
54 vlay->addLayout( grid ); 56 vlay->addLayout( grid );
55 vlay->addWidget( oxyDW ); 57 vlay->addWidget( oxyDW );
56} 58}
57 59
58QColor PSEWidget::PSEColor( QString block ) 60QColor PSEWidget::PSEColor( QString block )
59{ 61{
60 QColor c; 62 QColor c;
61 if ( block == "s" ) c.setRgb( 213 , 233 , 231 ); 63 if ( block == "s" ) c.setRgb( 213 , 233 , 231 );
62 else if ( block == "d" ) c.setRgb( 200,230,160 ); 64 else if ( block == "d" ) c.setRgb( 200,230,160 );
63 else if ( block == "p" ) c.setRgb( 238,146,138 ); 65 else if ( block == "p" ) c.setRgb( 238,146,138 );
64 else if ( block == "f" ) c.setRgb( 190 , 190 , 190 ); 66 else if ( block == "f" ) c.setRgb( 190 , 190 , 190 );
65 return c; 67 return c;
66}; 68};
67 69
68void PSEWidget::inverseColor( QString number ) 70void PSEWidget::inverseColor( QString number)
69{ 71{
70 Config configobj( QPEApplication::qpeDir() +"share/oxygen/oxygendata", Config::File ); 72 Config configobj( QPEApplication::qpeDir() +"share/oxygen/oxygendata", Config::File );
71 configobj.setGroup( number ); 73 configobj.setGroup( number );
72 QString block = configobj.readEntry( "Block" ); 74 QString block = configobj.readEntry( "Block" );
73 QColor c; 75 QColor c, d;
74 if ( block == "s" ) c.setRgb( 213 , 233 , 231 ); 76 c = PSEColor( block );
75 else if ( block == "d" ) c.setRgb( 200,230,160 ); 77 d = c.dark();
76 else if ( block == "p" ) c.setRgb( 238,146,138 ); 78
77 else if ( block == "f" ) c.setRgb( 190 , 190 , 190 ); 79 PSEframe.at( number.toUInt() )->setPalette( QPalette( d ) );
78 c.dark(); 80
79 81 configobj.setGroup( QString::number( lastElement+1 ) );
80 PSEframe.at( number.toUInt() )->setPalette( QPalette( c ) ); 82 block = configobj.readEntry( "Block" );
83 c = PSEColor( block );
84 PSEframe.at( lastElement )->setPalette( QPalette( c ) );
85
86 lastElement=number.toInt();
81} 87}
82 88
83void PSEWidget::slotShowElement(QString number) 89void PSEWidget::slotShowElement(QString number)
84{ 90{
85 oxyDW->setElement( number.toInt() ); 91 oxyDW->setElement( number.toInt() );
86}; 92};
87 93
88void PSEWidget::position(int n, int& h, int& v) 94void PSEWidget::position(int n, int& h, int& v)
89{ 95{
90 //Hydrogen 96 //Hydrogen
91 if (n == 1) 97 if (n == 1)
92 { 98 {
93 h=0; v=0; 99 h=0; v=0;
94 } 100 }
95 101
96 102
97 //Helium 103 //Helium
98 if (n == 2) 104 if (n == 2)
99 { 105 {
100 h=680; v=0; 106 h=680; v=0;
101 } 107 }
102 108
103 109
104 //Lithium 110 //Lithium
105 if (n == 3) 111 if (n == 3)
106 { 112 {
107 h=0; v=40; 113 h=0; v=40;
108 } 114 }
109 115
110 116
111 //Beryllium 117 //Beryllium
112 if (n == 4) 118 if (n == 4)
113 { 119 {
114 h=40; v=40; 120 h=40; v=40;
115 } 121 }
116 122
117 123
118 //Boron-->Neon or Aluminum --> Argon 124 //Boron-->Neon or Aluminum --> Argon
119 if ((n >= 5 && n <= 10) || (n >= 13 && n <= 18)) 125 if ((n >= 5 && n <= 10) || (n >= 13 && n <= 18))
120 for (int i = 1; i <= (6-(10-n)); i++) 126 for (int i = 1; i <= (6-(10-n)); i++)
121 { 127 {
122 h=((i*40)+440); 128 h=((i*40)+440);
123 v = 40; 129 v = 40;
124 if (n >= 13) 130 if (n >= 13)
125 { 131 {
126 v=80; 132 v=80;
127 h=(h-320); 133 h=(h-320);
128 } 134 }
129 } 135 }
130 136
131 137
132 //Sodium 138 //Sodium
133 if (n == 11) 139 if (n == 11)
134 { 140 {
135 h=0; v=80; 141 h=0; v=80;
136 } 142 }
137 143
138 144
139 //Magnesium 145 //Magnesium
140 if (n == 12) 146 if (n == 12)
141 { 147 {
142 h=40; v=80; 148 h=40; v=80;
143 } 149 }
144 150
145 151
146 //Potassium --> Uuo without La and Ac 152 //Potassium --> Uuo without La and Ac
147 if ((n >= 19 && n <= 56) || (n >= 72 && n <= 88) || n >= 104) 153 if ((n >= 19 && n <= 56) || (n >= 72 && n <= 88) || n >= 104)
148 for (int i = 1; i <= 18; i++) 154 for (int i = 1; i <= 18; i++)
149 { 155 {
150 int f = n; 156 int f = n;
151 if (n > 18) 157 if (n > 18)
152 f = n-18; 158 f = n-18;
153 if (n > 36) 159 if (n > 36)
154 f = n-36; 160 f = n-36;
155 if (n > 54) 161 if (n > 54)
156 f = n-54; 162 f = n-54;
157 if (n > 71) 163 if (n > 71)
158 f = n-68; 164 f = n-68;
159 if (n > 86) 165 if (n > 86)
160 f = n-86; 166 f = n-86;
161 if (n > 103) 167 if (n > 103)
162 f = n-100; 168 f = n-100;
163 169
164 h=((f*40)-40); 170 h=((f*40)-40);
165 171
166 v = 120; 172 v = 120;
167 if (n >= 37) 173 if (n >= 37)
168 v=160; 174 v=160;
169 if (n >= 55) 175 if (n >= 55)
170 v=200; 176 v=200;
171 if (n >= 87) 177 if (n >= 87)
172 v=240; 178 v=240;
173 } 179 }
174 180
175 181
176 //Lanthanum --> Lutetium and Actinum --> Lawrencium 182 //Lanthanum --> Lutetium and Actinum --> Lawrencium
diff --git a/noncore/apps/oxygen/psewidget.h b/noncore/apps/oxygen/psewidget.h
index cfb629d..ddeab9d 100644
--- a/noncore/apps/oxygen/psewidget.h
+++ b/noncore/apps/oxygen/psewidget.h
@@ -1,51 +1,53 @@
1/*************************************************************************** 1/***************************************************************************
2 application: : Oxygen 2 application: : Oxygen
3 3
4 begin : September 2002 4 begin : September 2002
5 copyright : ( C ) 2002 by Carsten Niehaus 5 copyright : ( C ) 2002 by Carsten Niehaus
6 email : cniehaus@handhelds.org 6 email : cniehaus@handhelds.org
7 **************************************************************************/ 7 **************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * ( at your option ) any later version. * 14 * ( at your option ) any later version. *
15 * * 15 * *
16 **************************************************************************/ 16 **************************************************************************/
17#ifndef _PSEWIDGET_H 17#ifndef _PSEWIDGET_H
18#define _PSEWIDGET_H 18#define _PSEWIDGET_H
19 19
20#include <qwidget.h> 20#include <qwidget.h>
21#include <qlist.h> 21#include <qlist.h>
22#include "oxyframe.h" 22#include "oxyframe.h"
23 23
24class QGridLayout; 24class QGridLayout;
25class OxydataWidget; 25class OxydataWidget;
26class PSEframe; 26class PSEframe;
27 27
28class PSEWidget : public QWidget 28class PSEWidget : public QWidget
29{ 29{
30 Q_OBJECT 30 Q_OBJECT
31 31
32 public: 32 public:
33 PSEWidget(); 33 PSEWidget();
34 QGridLayout *bottom_grid; 34 QGridLayout *bottom_grid;
35 OxydataWidget *oxyDW; 35 OxydataWidget *oxyDW;
36 36
37 QList<OxyFrame> PSEframe; 37 QList<OxyFrame> PSEframe;
38 38
39 int lastElement;
40
39 private: 41 private:
40 QGridLayout *maingrid; 42 QGridLayout *maingrid;
41 43
42 void position( int, int&, int& ); 44 void position( int, int&, int& );
43 QColor PSEColor( QString ); 45 QColor PSEColor( QString );
44 46
45 public slots: 47 public slots:
46 void slotShowElement(QString); 48 void slotShowElement(QString);
47 void inverseColor( QString ); 49 void inverseColor( QString );
48 50
49}; 51};
50 52
51#endif 53#endif