[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-edu-devel
Subject: Re: [Kde-edu-devel] New application
From: George Russell <george.russell () clara ! net>
Date: 2001-12-17 17:07:35
[Download RAW message or body]
On Sunday 16 December 2001 17:12, Carsten Niehaus wrote:
> Hello.
>
> Today Kalzium-0.1 has been finished. It is an app which (in the first stage
> of development) shows you the Periodic System of the Elements and further
> information about the elements themselfs. Now, as the framework is
> completed, I want to add a lot of data and enhance the optic of Kalzium.
I the attached code sets the background colours of the element buttons.
If you know how to set foreground colour, you can add it easily.
> The name Kalzium is german for Potassium.
>
> I hope to get some feedback and nice ideas for Kalzium 0.2 and that Kalzium
> might be more usefull in some weeks.
You can use my quiz class, which generates a series of questions in random order
about seven of the properties of the elements in the periodic table. The questions can
be about the first n elements, where n is user selectable, and are of the form, given
all the details of the element except one, what is the missing detail?
I hope I can use your code in Table?
George Russell
["kalzium.h" (text/plain)]
/***************************************************************************
kalzium.h - description
-------------------
begin : Die Dez 4 17:59:34 CET 2001
copyright : (C) 2001 by Carsten Niehaus
email : cniehaus@gmx.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef KALZIUM_H
#define KALZIUM_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <kapp.h>
#include <qwidget.h>
#include <qlabel.h>
#include <qcolor.h> // GR button coluors
#include <kpushbutton.h>
#include <kstatusbar.h>
#include <kmainwindow.h>
#include <ksimpleconfig.h>
#include <kconfig.h>
#include <qaction.h>
#include <kaction.h>
#include <qstring.h>
#include <elementkp.h>
/** Kalzium is the base class of the project */
typedef ElementKP* PElementKP;
class Kalzium : public KMainWindow
{
Q_OBJECT
public:
/** construtor */
Kalzium(const char *name=0);
/** GR return block of element */
int block(int e) const;
/** destructor */
~Kalzium();
private:
PElementKP button[118];
const QColor s;
const QColor t;
const QColor p;
const QColor f;
// GR different colours for different groups
enum {OTHER=0,SBLOCK=1,DBLOCK=2,PBLOCK=3,FBLOCK=4};
public slots:
};
#endif
["kalzium.cpp" (text/plain)]
/***************************************************************************
kalzium.cpp - description
-------------------
begin : Die Dez 4 17:59:34 CET 2001
copyright : (C) 2001 by Carsten Niehaus
email : cniehaus@gmx.de
***************************************************************************/
/***************************************************************************
* \
*
* This program is free software; you can redistribute it and/or modify \
*
* it under the terms of the GNU General Public License as published by \
*
* the Free Software Foundation; either version 2 of the License, or \
*
* (at your option) any later version. \
*
* \
*
***************************************************************************/
#include "kalzium.h"
#include "eleminfo.h"
#include <iostream>
#include <kapp.h>
#include <qlabel.h>
#include <qstring.h>
#include <kmessagebox.h>
#include <kconfig.h>
#include <qdialog.h>
#include <qlayout.h>
#include <qstring.h>
#include <kstddirs.h>
#include <klocale.h>
#include <kglobal.h>
#include <iostream.h>
#include <ksimpleconfig.h>
#include <kmenubar.h>
#include <qpopupmenu.h>
#include <khelpmenu.h>
#include <kstdaction.h>
//horizontal expansion of a button
#define SIZE_X 40
//vertical expansion of a button
#define SIZE_Y 40
#define KALZIUM_VERSION 0.11
Kalzium::Kalzium(const char *name) : KMainWindow( 0 ,name )
{
const QColor s("LightGreen");
const QColor t("CornflowerBlue");
const QColor p("SandyBrown");
const QColor f("LemonChiffon");
setCaption(i18n("Kalzium - v%1").arg(KALZIUM_VERSION));
// GR Beenden == Quit?
KAction *quit = new KAction ("Quit", KStdAccel::quit(), kapp, SLOT \
(closeAllWindows()), this);
KPopupMenu *filemenu = new KPopupMenu;
KPopupMenu *help = helpMenu( );
quit->plug(filemenu);
menuBar()->insertItem(i18n("File"), filemenu);
menuBar()->insertItem( i18n("&Help"), help );
// Loop over all elements
int h=0; int v=0;
QString elementName, rc_path = "/home/grrussel/kalziumrc";
KSimpleConfig config (rc_path);
for (int n=0;n<118;n++)
{
if (config.hasGroup(QString::number(n+1)))
{
config.setGroup(QString::number(n+1));
elementName=config.readEntry("Symbol", "Unknown");
} else elementName="Unknown";
position(n+1,h,v); //get position
button[n] = new ElementKP(elementName,this,elementName.latin1(),n+1,statusBar());
button[n]->setGeometry(h,v+40,SIZE_X,SIZE_Y);
button[n]->setFlat(true);
button[n]->setAutoDefault(false);
switch (block(n+1 )){
case FBLOCK:
button[n] ->setBackgroundColor(f);
break;
case DBLOCK:
button[n] ->setBackgroundColor(t);
break;
case PBLOCK:
button[n] ->setBackgroundColor(p);
break;
case SBLOCK:
button[n] ->setBackgroundColor(s);
break;
default:
break;
}
button[n]->show();
}
}
/** Return an int indicating the block in which the element is
* param int elements atomic number
* return int elements group as set in enumeration
*/
int Kalzium::block(int e) const{
if ( (e >= 58 && e <= 71) || (e >= 90 && e <= 103) )
return FBLOCK;
else if ( (e >= 21 && e <= 30) || ( e >= 39 && e <= 48 ) ||
(e >= 72 && e <= 80) || ( e == 57) || ( e == 89 ) ||
(e >= 104 && e <= 112 ))
return DBLOCK;
else if ( ( e == 2 ) || ( e >= 5 && e <= 10 ) || ( e >= 13 && e <= 18) ||
( e >= 31 && e <= 36 ) || ( e >= 49 && e <= 54 ) || ( e >= 81 && e <= \
86 ) )
return PBLOCK;
else if ( e == 1 || e == 3 || e == 4 || e == 11 || e == 12 || e == 19 || \
e == 20 || e == 37 || e == 38 || e == 55 || e == 56 || e == 87 || e == 88)
return SBLOCK;
else
return OTHER;
}
Kalzium::~Kalzium()
{
for (int n=0; n<118; n++)
delete button[n];
}
_______________________________________________
kde-edu-devel mailing list
kde-edu-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-edu-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic