Back to index

kdeartwork  4.3.2
blob.h
Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 //
00003 // kblob - Basic screen saver for KDE
00004 //
00005 // Copyright (c)  Tiaan Wessels, 1997
00006 //
00007 
00008 #ifndef BLOB_H
00009 #define BLOB_H
00010 
00011 #include <qtimer.h>
00012 
00013 #include <kdialog.h>
00014 #include <kscreensaver.h>
00015 
00016 class QListWidgetItem;
00017 
00018 #define RAMP         64
00019 #define SPEED        10
00020 
00021 enum blob_alg {
00022        ALG_LINEAR,
00023        ALG_HSINE,
00024        ALG_CIRB,
00025        ALG_POLARC,
00026        ALG_LAST,
00027        ALG_RANDOM = ALG_LAST };
00028 
00029 class KBlobSaver : public KScreenSaver
00030 {
00031     Q_OBJECT
00032 
00033 public:
00034     KBlobSaver( WId id );
00035     virtual ~KBlobSaver();
00036 
00037     void setDimension(int d)
00038        { dim = d; }
00039     void setShowlen(time_t s)
00040        { showlen = s; }
00041     void setColorInc(int c)
00042        { colorInc = c; }
00043 
00044 public slots:
00045     void setAlgorithm(int pos);
00046 
00047 public:
00048     typedef void (KBlobSaver::*AlgFunc)();
00049     struct KBSAlg
00050     {
00051        QString Name;
00052        AlgFunc Init;
00053        AlgFunc NextFrame;
00054     };
00055 private:
00056 
00057     QTimer    timer;
00058     uint      colors[RAMP];
00059     uint      lookup[256];
00060     int              colorInc;
00061     int              tx, ty;
00062     int              dim;
00063     int              xhalf, yhalf;
00064     int              alg, newalg, newalgp;
00065     time_t    showlen, start;
00066     KBSAlg    Algs[ALG_LAST];
00067     int              ln_xinc, ln_yinc;
00068     float     hs_radians, hs_rinc, hs_flip, hs_per;
00069     float     cb_radians, cb_rinc, cb_sradians, cb_radius, cb_devradinc;
00070     float     cb_deviate;
00071     float     pc_angle, pc_radius, pc_inc, pc_crot, pc_div;
00072 
00073     void lnSetup();
00074     void hsSetup();
00075     void cbSetup();
00076     void pcSetup();
00077 
00078     void lnNextFrame();
00079     void hsNextFrame();
00080     void cbNextFrame();
00081     void pcNextFrame();
00082 
00083     void box(int, int);
00084     void readSettings();
00085 
00086 protected:
00087     void paintEvent(QPaintEvent *event);
00088 };
00089 
00090 class QListWidget;
00091 class KIntNumInput;
00092 
00093 class KBlobSetup : public KDialog
00094 {
00095     Q_OBJECT
00096 
00097     int showtime;
00098     int alg;
00099     QListWidget  *algs;
00100     KIntNumInput *stime;
00101 
00102 public:
00103     KBlobSetup( QWidget *parent = NULL );
00104 
00105 protected:
00106     void readSettings();
00107 
00108 private slots:
00109     void slotOk();
00110     void slotHelp();
00111     void setAlgorithm(QListWidgetItem* item);
00112 private:
00113     KBlobSaver *saver;
00114 };
00115 
00116 #endif
00117