summaryrefslogtreecommitdiff
authorcniehaus <cniehaus>2002-09-20 12:13:58 (UTC)
committer cniehaus <cniehaus>2002-09-20 12:13:58 (UTC)
commite1c71743917aa6047c5ed7da6ca3a18024ceabde (patch) (unidiff)
tree097c975669e3372973b46431a9cc02cda6210cc7
parentb1f3d33cb0b3f203f153074a8812d5988c3031b2 (diff)
downloadopie-e1c71743917aa6047c5ed7da6ca3a18024ceabde.zip
opie-e1c71743917aa6047c5ed7da6ca3a18024ceabde.tar.gz
opie-e1c71743917aa6047c5ed7da6ca3a18024ceabde.tar.bz2
fixing the colors. THis looks almost cool :)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/oxygen/dataTable.cpp4
-rw-r--r--noncore/apps/oxygen/oxyframe.cpp8
-rw-r--r--noncore/apps/oxygen/psewidget.cpp15
-rw-r--r--noncore/apps/oxygen/psewidget.h1
4 files changed, 22 insertions, 6 deletions
diff --git a/noncore/apps/oxygen/dataTable.cpp b/noncore/apps/oxygen/dataTable.cpp
index 870ac56..70b5a6a 100644
--- a/noncore/apps/oxygen/dataTable.cpp
+++ b/noncore/apps/oxygen/dataTable.cpp
@@ -1,102 +1,102 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * ( at your option ) any later version. * 6 * ( at your option ) any later version. *
7 * * 7 * *
8 **************************************************************************/ 8 **************************************************************************/
9 9
10#include <qpe/config.h> 10#include <qpe/config.h>
11 11
12#include "dataTable.h" 12#include "dataTable.h"
13#include <qwidget.h> 13#include <qwidget.h>
14#include <qhbox.h> 14#include <qhbox.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qfont.h> 16#include <qfont.h>
17#include <qlayout.h> 17#include <qlayout.h>
18 18
19OxydataWidget::OxydataWidget(QWidget *parent) : QWidget(parent) 19OxydataWidget::OxydataWidget(QWidget *parent) : QWidget(parent)
20{ 20{
21 QGridLayout *qgrid = new QGridLayout( this, 2,1 ); 21 QGridLayout *qgrid = new QGridLayout( this, 2,1 );
22 QHBox *hbox = new QHBox( this ); 22 QHBox *hbox = new QHBox( this );
23 left = new QLabel( hbox ); 23 left = new QLabel( hbox );
24 middle = new QLabel( hbox ); 24 middle = new QLabel( hbox );
25 right = new QLabel( hbox ); 25 right = new QLabel( hbox );
26 26
27 DataTable = new OxydataTable( 9,2, this ); 27 DataTable = new OxydataTable( 9,2, this );
28 28
29 QFont bf; 29 QFont bf;
30 bf.setBold( true ); 30 bf.setBold( true );
31 bf.setPointSize( bf.pointSize()+2 ); 31 bf.setPointSize( bf.pointSize()+2 );
32 middle->setFont( bf ); 32 middle->setFont( bf );
33 33
34 setTable(); 34 setTable();
35 35
36 qgrid->addWidget( hbox,0,0 ); 36 qgrid->addWidget( hbox,0,0 );
37 qgrid->addWidget( DataTable,1,0 ); 37 qgrid->addWidget( DataTable,1,0 );
38} 38}
39 39
40void OxydataWidget::setElement( int el ) 40void OxydataWidget::setElement( int el )
41{ 41{
42 Config configobj( "oxygendata" ); 42 Config configobj( "oxygendata" );
43 configobj.setGroup( QString::number( el+1 )); 43 configobj.setGroup( QString::number( el+1 ));
44 44
45 left->setText( configobj.readEntry( "Symbol" ) ); 45 left->setText( configobj.readEntry( "Symbol" ) );
46 middle->setText( configobj.readEntry( "Name" ) ); 46 middle->setText( configobj.readEntry( "Name" ) );
47 right->setText( QString::number( el+1 ) ); 47 right->setText( QString::number( el+1 ) );
48 48
49 DataTable->setText( 0,1,configobj.readEntry( "Weight" ) ); 49 DataTable->setText( 0,1,configobj.readEntry( "Weight" ) );
50 DataTable->setText( 1,1,configobj.readEntry( "Block" ) ); 50 DataTable->setText( 1,1,configobj.readEntry( "Block" ) );
51 DataTable->setText( 2,1,configobj.readEntry( "Group" ) ); 51 DataTable->setText( 2,1,configobj.readEntry( "Group" ) );
52 DataTable->setText( 3,1,configobj.readEntry( "EN" ) ); 52 DataTable->setText( 3,1,configobj.readEntry( "EN" ) );
53 DataTable->setText( 4,1,configobj.readEntry( "AR" ) ) ; 53 DataTable->setText( 4,1,configobj.readEntry( "AR" ) ) ;
54 DataTable->setText( 5,1,configobj.readEntry( "IE" ) ); 54 DataTable->setText( 5,1,configobj.readEntry( "IE" ) );
55 DataTable->setText( 6,1,configobj.readEntry( "Density" ) ); 55 DataTable->setText( 6,1,configobj.readEntry( "Density" ) );
56 DataTable->setText( 7,1,configobj.readEntry( "BP" ) ); 56 DataTable->setText( 7,1,configobj.readEntry( "BP" ) );
57 DataTable->setText( 8,1,configobj.readEntry( "MP" ) ); 57 DataTable->setText( 8,1,configobj.readEntry( "MP" ) );
58} 58}
59 59
60void OxydataWidget::setTable() const 60void OxydataWidget::setTable() const
61{ 61{
62 DataTable->setText( 0,0, tr( "Weight:" ) ); 62 DataTable->setText( 0,0, tr( "Weight:" ) );
63 DataTable->setText( 1,0, tr( "Block" )) ; 63 DataTable->setText( 1,0, tr( "Block" )) ;
64 DataTable->setText( 2,0, tr( "Group" )) ; 64 DataTable->setText( 2,0, tr( "Group" )) ;
65 DataTable->setText( 3,0, tr( "Electronegativity" )) ; 65 DataTable->setText( 3,0, tr( "Electronegativity" )) ;
66 DataTable->setText( 4,0, tr( "Atomic radius" )) ; 66 DataTable->setText( 4,0, tr( "Atomic radius" )) ;
67 DataTable->setText( 5,0, tr( "Ionizationenergie" )) ; 67 DataTable->setText( 5,0, tr( "Ionizationenergie" )) ;
68 DataTable->setText( 6,0, tr( "Density" )) ; 68 DataTable->setText( 6,0, tr( "Density" )) ;
69 DataTable->setText( 7,0, tr( "Boilingpoint" ) ); 69 DataTable->setText( 7,0, tr( "Boilingpoint" ) );
70 DataTable->setText( 8,0, tr( "Meltingpoint" ) ); 70 DataTable->setText( 8,0, tr( "Meltingpoint" ) );
71} 71}
72 72
73OxydataTable::OxydataTable(int numRows, int numCols, QWidget *parent, 73OxydataTable::OxydataTable(int numRows, int numCols, QWidget *parent,
74 const char *name) : QTable(numRows, numRows, parent, name) 74 const char *name) : QTable(numRows, numRows, parent, name)
75{ 75{
76 this->setShowGrid( false ); 76 this->setShowGrid( false );
77 this->setHScrollBarMode(QScrollView::AlwaysOff); 77 this->setHScrollBarMode(QScrollView::AlwaysOff);
78 this->horizontalHeader()->hide(); 78 this->horizontalHeader()->hide();
79 this->verticalHeader()->hide(); 79 this->verticalHeader()->hide();
80 this->setTopMargin( 0 ); 80 this->setTopMargin( 0 );
81 this->setLeftMargin( 0 ); 81 this->setLeftMargin( 0 );
82} 82}
83 83
84void OxydataTable::paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected) 84void OxydataTable::paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected)
85{ 85{
86 if ( cr.width() == 0 || cr.height() == 0 ) 86 if ( cr.width() == 0 || cr.height() == 0 )
87 return; 87 return;
88 selected = FALSE; 88 selected = FALSE;
89 89
90 QTableItem *itm = item( row, col ); 90 QTableItem *itm = item( row, col );
91 QColorGroup colgrp = colorGroup(); 91 QColorGroup colgrp = colorGroup();
92 if ( itm ) 92 if ( itm )
93 { 93 {
94 if ( row%2 ) 94 if ( row%2 )
95 colgrp.setColor( QColorGroup::Base, QColor( cyan ) ); 95 colgrp.setColor( QColorGroup::Base, QColor( 180,200,210 ) );
96 else 96 else
97 colgrp.setColor( QColorGroup::Base, QColor( white ) ); 97 colgrp.setColor( QColorGroup::Base, QColor( 230,235,235 ) );
98 p->save(); 98 p->save();
99 itm->paint( p, colgrp, cr, selected ); 99 itm->paint( p, colgrp, cr, selected );
100 p->restore(); 100 p->restore();
101 } 101 }
102} 102}
diff --git a/noncore/apps/oxygen/oxyframe.cpp b/noncore/apps/oxygen/oxyframe.cpp
index 2d7fc84..a5f262e 100644
--- a/noncore/apps/oxygen/oxyframe.cpp
+++ b/noncore/apps/oxygen/oxyframe.cpp
@@ -1,25 +1,25 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * ( at your option ) any later version. * 6 * ( at your option ) any later version. *
7 * * 7 * *
8 **************************************************************************/ 8 **************************************************************************/
9#include "oxygen.h" 9#include "oxygen.h"
10 10
11#include <qpe/config.h> 11#include <qpe/config.h>
12#include "oxyframe.h" 12#include "oxyframe.h"
13 13
14OxyFrame::OxyFrame(QWidget *parent, const char *name) : QFrame(parent,name) 14OxyFrame::OxyFrame(QWidget *parent, const char *name) : QFrame(parent,name)
15{ 15{
16 N = name; 16 N = name;
17 this->setFrameStyle( QFrame::Panel ); 17 this->setFrameStyle( QFrame::Box );
18 this->setLineWidth( 2 ); 18 this->setLineWidth( 0 );
19 this->setFrameShadow( QFrame::Raised ); 19 this->setMidLineWidth( 1 );
20 this->setBackgroundColor( QColor( green ) ); 20 this->setFrameShadow( QFrame::Sunken );
21} 21}
22 22
23void OxyFrame::mousePressEvent ( QMouseEvent * e ){ 23void OxyFrame::mousePressEvent ( QMouseEvent * e ){
24 emit num( N ); 24 emit num( N );
25}; 25};
diff --git a/noncore/apps/oxygen/psewidget.cpp b/noncore/apps/oxygen/psewidget.cpp
index f7725e3..78e54d5 100644
--- a/noncore/apps/oxygen/psewidget.cpp
+++ b/noncore/apps/oxygen/psewidget.cpp
@@ -1,151 +1,166 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * ( at your option ) any later version. * 6 * ( at your option ) any later version. *
7 * * 7 * *
8 **************************************************************************/ 8 **************************************************************************/
9 9
10#include <qpe/config.h> 10#include <qpe/config.h>
11#include <qlayout.h> 11#include <qlayout.h>
12#include <qlist.h> 12#include <qlist.h>
13#include "dataTable.h" 13#include "dataTable.h"
14#include "psewidget.h" 14#include "psewidget.h"
15#include "oxyframe.h" 15#include "oxyframe.h"
16 16
17 17
18PSEWidget::PSEWidget() : QWidget() 18PSEWidget::PSEWidget() : QWidget()
19{ 19{
20 this->setCaption( tr( "Periodic System" ) ); 20 this->setCaption( tr( "Periodic System" ) );
21 21
22 QVBoxLayout *vlay = new QVBoxLayout( this ); 22 QVBoxLayout *vlay = new QVBoxLayout( this );
23 23
24 QGridLayout *grid = new QGridLayout( 18,10 ); 24 QGridLayout *grid = new QGridLayout( 18,10 );
25 int h=0, v=0; 25 int h=0, v=0;
26
27 Config configobj( "oxygendata" );
26 for( int n = 0 ; n < 118 ; n++ ) 28 for( int n = 0 ; n < 118 ; n++ )
27 { 29 {
30 configobj.setGroup( QString::number( n+1 ));
31
28 position( n+1,h,v ); 32 position( n+1,h,v );
29 QList<OxyFrame> PSEframe; 33 QList<OxyFrame> PSEframe;
30 PSEframe.append( new OxyFrame( this , QString::number(n) ) ); 34 PSEframe.append( new OxyFrame( this , QString::number(n) ) );
31 grid->addWidget( PSEframe.current() , v/40+1 , h/40 ); 35 grid->addWidget( PSEframe.current() , v/40+1 , h/40 );
32 PSEframe.current()->setMinimumHeight( 11 ); 36 PSEframe.current()->setMinimumHeight( 11 );
37 PSEframe.current()->setPalette( QPalette( PSEColor( configobj.readEntry( "Block" ) ) ) );
33 connect( PSEframe.current(), SIGNAL( num(QString) ), this, SLOT( slotShowElement(QString) )); 38 connect( PSEframe.current(), SIGNAL( num(QString) ), this, SLOT( slotShowElement(QString) ));
34 } 39 }
35 40
36 oxyDW = new OxydataWidget(this); 41 oxyDW = new OxydataWidget(this);
37 oxyDW->setElement( 1 ); 42 oxyDW->setElement( 1 );
38 43
39 vlay->addLayout( grid ); 44 vlay->addLayout( grid );
40 vlay->addWidget( oxyDW ); 45 vlay->addWidget( oxyDW );
41} 46}
42 47
48QColor PSEWidget::PSEColor( QString block )
49{
50 QColor c;
51 if ( block == "s" ) c.setRgb( 213 , 233 , 231 );
52 else if ( block == "d" ) c.setRgb( 200,230,160 );
53 else if ( block == "p" ) c.setRgb( 238,146,138 );
54 else if ( block == "f" ) c.setRgb( 190 , 190 , 190 );
55 return c;
56};
57
43void PSEWidget::slotShowElement(QString number) 58void PSEWidget::slotShowElement(QString number)
44{ 59{
45 oxyDW->setElement( number.toInt() ); 60 oxyDW->setElement( number.toInt() );
46}; 61};
47 62
48void PSEWidget::position(int n, int& h, int& v) 63void PSEWidget::position(int n, int& h, int& v)
49{ 64{
50 //Hydrogen 65 //Hydrogen
51 if (n == 1) 66 if (n == 1)
52 { 67 {
53 h=0; v=0; 68 h=0; v=0;
54 } 69 }
55 70
56 71
57 //Helium 72 //Helium
58 if (n == 2) 73 if (n == 2)
59 { 74 {
60 h=680; v=0; 75 h=680; v=0;
61 } 76 }
62 77
63 78
64 //Lithium 79 //Lithium
65 if (n == 3) 80 if (n == 3)
66 { 81 {
67 h=0; v=40; 82 h=0; v=40;
68 } 83 }
69 84
70 85
71 //Beryllium 86 //Beryllium
72 if (n == 4) 87 if (n == 4)
73 { 88 {
74 h=40; v=40; 89 h=40; v=40;
75 } 90 }
76 91
77 92
78 //Boron-->Neon or Aluminum --> Argon 93 //Boron-->Neon or Aluminum --> Argon
79 if ((n >= 5 && n <= 10) || (n >= 13 && n <= 18)) 94 if ((n >= 5 && n <= 10) || (n >= 13 && n <= 18))
80 for (int i = 1; i <= (6-(10-n)); i++) 95 for (int i = 1; i <= (6-(10-n)); i++)
81 { 96 {
82 h=((i*40)+440); 97 h=((i*40)+440);
83 v = 40; 98 v = 40;
84 if (n >= 13) 99 if (n >= 13)
85 { 100 {
86 v=80; 101 v=80;
87 h=(h-320); 102 h=(h-320);
88 } 103 }
89 } 104 }
90 105
91 106
92 //Sodium 107 //Sodium
93 if (n == 11) 108 if (n == 11)
94 { 109 {
95 h=0; v=80; 110 h=0; v=80;
96 } 111 }
97 112
98 113
99 //Magnesium 114 //Magnesium
100 if (n == 12) 115 if (n == 12)
101 { 116 {
102 h=40; v=80; 117 h=40; v=80;
103 } 118 }
104 119
105 120
106 //Potassium --> Uuo without La and Ac 121 //Potassium --> Uuo without La and Ac
107 if ((n >= 19 && n <= 56) || (n >= 72 && n <= 88) || n >= 104) 122 if ((n >= 19 && n <= 56) || (n >= 72 && n <= 88) || n >= 104)
108 for (int i = 1; i <= 18; i++) 123 for (int i = 1; i <= 18; i++)
109 { 124 {
110 int f = n; 125 int f = n;
111 if (n > 18) 126 if (n > 18)
112 f = n-18; 127 f = n-18;
113 if (n > 36) 128 if (n > 36)
114 f = n-36; 129 f = n-36;
115 if (n > 54) 130 if (n > 54)
116 f = n-54; 131 f = n-54;
117 if (n > 71) 132 if (n > 71)
118 f = n-68; 133 f = n-68;
119 if (n > 86) 134 if (n > 86)
120 f = n-86; 135 f = n-86;
121 if (n > 103) 136 if (n > 103)
122 f = n-100; 137 f = n-100;
123 138
124 h=((f*40)-40); 139 h=((f*40)-40);
125 140
126 v = 120; 141 v = 120;
127 if (n >= 37) 142 if (n >= 37)
128 v=160; 143 v=160;
129 if (n >= 55) 144 if (n >= 55)
130 v=200; 145 v=200;
131 if (n >= 87) 146 if (n >= 87)
132 v=240; 147 v=240;
133 } 148 }
134 149
135 150
136 //Lanthanum --> Lutetium and Actinum --> Lawrencium 151 //Lanthanum --> Lutetium and Actinum --> Lawrencium
137 if ((n >= 57 && n <= 71) || (n >= 89 && n <= 103)) 152 if ((n >= 57 && n <= 71) || (n >= 89 && n <= 103))
138 for (int i = 1; i <= 14; i++) 153 for (int i = 1; i <= 14; i++)
139 { 154 {
140 int f = n; 155 int f = n;
141 if (n > 56) 156 if (n > 56)
142 f = n-55; 157 f = n-55;
143 if (n > 88) 158 if (n > 88)
144 f = n-87; 159 f = n-87;
145 h=(f*40); 160 h=(f*40);
146 v = 290; 161 v = 290;
147 if (n >= 89) 162 if (n >= 89)
148 v=330; 163 v=330;
149 } 164 }
150 v += 10; 165 v += 10;
151} 166}
diff --git a/noncore/apps/oxygen/psewidget.h b/noncore/apps/oxygen/psewidget.h
index a7a8603..f69eeb3 100644
--- a/noncore/apps/oxygen/psewidget.h
+++ b/noncore/apps/oxygen/psewidget.h
@@ -1,37 +1,38 @@
1 1
2/*************************************************************************** 2/***************************************************************************
3 * * 3 * *
4 * This program is free software; you can redistribute it and/or modify * 4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by * 5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or * 6 * the Free Software Foundation; either version 2 of the License, or *
7 * ( at your option ) any later version. * 7 * ( at your option ) any later version. *
8 * * 8 * *
9 **************************************************************************/ 9 **************************************************************************/
10#ifndef _PSEWIDGET_H 10#ifndef _PSEWIDGET_H
11#define _PSEWIDGET_H 11#define _PSEWIDGET_H
12 12
13#include <qwidget.h> 13#include <qwidget.h>
14 14
15class QGridLayout; 15class QGridLayout;
16class OxydataWidget; 16class OxydataWidget;
17 17
18class PSEWidget : public QWidget 18class PSEWidget : public QWidget
19{ 19{
20 Q_OBJECT 20 Q_OBJECT
21 21
22 public: 22 public:
23 PSEWidget(); 23 PSEWidget();
24 QGridLayout *bottom_grid; 24 QGridLayout *bottom_grid;
25 OxydataWidget *oxyDW; 25 OxydataWidget *oxyDW;
26 26
27 private: 27 private:
28 QGridLayout *maingrid; 28 QGridLayout *maingrid;
29 29
30 void position( int, int&, int& ); 30 void position( int, int&, int& );
31 QColor PSEColor( QString );
31 32
32 public slots: 33 public slots:
33 void slotShowElement(QString); 34 void slotShowElement(QString);
34 35
35}; 36};
36 37
37#endif 38#endif