Back to index

kdeartwork  4.3.2
science.h
Go to the documentation of this file.
00001 // ----------------------------------------------------------------
00002 //
00003 // kscience - screen saver for KDE
00004 //
00005 // copyright (c)  Rene Beutler 1998
00006 //
00007 
00008 #ifndef SCIENCE_H
00009 #define SCIENCE_H
00010 
00011 #include <qrect.h>
00012 #include <qtimer.h>
00013 #include <kdialog.h>
00014 #include <kscreensaver.h>
00015 
00016 class QSlider;
00017 class QCheckBox;
00018 
00019 #define MAX_MODES  6
00020 
00021 typedef signed int T32bit;
00022 
00023 class KScienceSaver;
00024 
00025 class KPreviewWidget : public QWidget
00026 {
00027        Q_OBJECT
00028 public:
00029        KPreviewWidget( QWidget *parent );
00030        void paintEvent( QPaintEvent *event );
00031        void notifySaver( KScienceSaver *s = 0 );
00032 private:
00033        KScienceSaver *saver;
00034 };
00035 
00036 struct KScienceData;
00037 
00038 class KScienceSaver : public KScreenSaver
00039 {
00040        Q_OBJECT
00041 public:
00042        KScienceSaver( WId id, bool setup=false, bool gP=false);
00043        virtual ~KScienceSaver();
00044 
00045        void do_refresh( const QRect & rect );
00046        void setMode        ( int mode );
00047        void setMoveX       ( signed int s );
00048        void setMoveY       ( signed int s );
00049        void setMove        ( bool s );    
00050        void setSize        ( signed int s );
00051        void setIntensity   ( signed int s );
00052        void setSpeed       ( signed int s );
00053        void setInverse     ( bool b );
00054        void setGravity     ( bool b );
00055        void setHideBG      ( bool b );
00056 
00057        void myAssert( bool term, const char *sMsg );
00058 
00059 private:
00060        void readSettings();
00061        void initLens();
00062        void initialize();
00063        void releaseLens();
00064        void (KScienceSaver::*applyLens)(int xs, int ys, int xd, int yd, int w, int h);
00065 
00066 protected slots:
00067        void slotTimeout();
00068 
00069 protected:
00070        void       grabRootWindow();
00071        void       grabPreviewWidget();
00072        void       initWhirlLens();
00073        void       initSphereLens();
00074        void       initExponentialLens();
00075        void       initWaveLens();
00076        void       initCurvatureLens();
00077        void       blackPixel( int x, int y );
00078        void       blackPixelUndo( int x, int y);
00079        void       applyLens8bpp( int xs, int ys, int xd, int yd, int w, int h);
00080        void       applyLens16bpp(int xs, int ys, int xd, int yd, int w, int h);
00081        void       applyLens24bpp(int xs, int ys, int xd, int yd, int w, int h);
00082        void       applyLens32bpp(int xs, int ys, int xd, int yd, int w, int h);
00083        QTimer     timer;
00084        bool       moveOn;
00085        bool       setup;
00086        bool       grabPixmap;
00087        int        mode;
00088        bool       inverse[MAX_MODES];
00089        bool       gravity[MAX_MODES];
00090        bool       hideBG[MAX_MODES];
00091        signed int size[MAX_MODES];
00092        signed int moveX[MAX_MODES];
00093        signed int moveY[MAX_MODES];
00094        signed int speed[MAX_MODES];
00095        signed int intensity[MAX_MODES];
00096        int        xcoord, ycoord;
00097        double     x, y, vx, vy;
00098        signed int bpp, side;
00099        int        border, radius, diam, origin;
00100        int        imgnext;
00101        char       blackRestore[4];
00102     KScienceData *d;
00103 };
00104 
00105 
00106 class KScienceSetup : public KDialog
00107 {
00108        Q_OBJECT
00109 public:
00110        KScienceSetup(QWidget *parent=0);
00111        ~KScienceSetup();
00112 protected:
00113        void updateSettings();
00114        void readSettings();
00115 
00116 private slots:
00117        void slotMode( int );
00118        void slotInverse();
00119        void slotGravity();
00120        void slotHideBG();
00121        void slotMoveX( int );
00122        void slotMoveY( int );
00123        void slotSize( int );
00124        void slotIntensity( int );
00125        void slotSliderPressed();
00126        void slotSliderReleased();
00127        void slotSpeed( int );
00128        void slotOk();
00129        void slotHelp();
00130 
00131 private:
00132        KPreviewWidget *preview;
00133        KScienceSaver *saver;
00134        QSlider *slideSize, *slideSpeed, *slideIntensity;
00135        QSlider *slideMoveX, *slideMoveY;
00136        QCheckBox *checkInverse, *checkGravity, *checkHideBG;   
00137 
00138        int  mode;
00139        bool inverse  [MAX_MODES];
00140        bool gravity  [MAX_MODES];
00141        bool hideBG   [MAX_MODES];
00142        int  moveX    [MAX_MODES];
00143        int  moveY    [MAX_MODES];  
00144        int  size     [MAX_MODES]; 
00145        int  intensity[MAX_MODES];
00146        int  speed    [MAX_MODES];
00147 };
00148 #endif