Back to index

kdeartwork  4.3.2
lines.h
Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 //
00003 // klines 0.1.1 - Basic screen saver for KDE
00004 // by Dirk Staneker 1997
00005 // based on kpolygon 0.3 by Martin R. Jones 1996
00006 //
00007 
00008 #ifndef LINES_H
00009 #define LINES_H
00010 
00011 #include <qtimer.h>
00012 
00013 #include <kdialog.h>
00014 #include <krandomsequence.h>
00015 #include <kscreensaver.h>
00016 
00017 class KColorButton;
00018 
00019 class Lines{
00020        private:
00021        struct Ln{
00022               Ln* next;
00023               int x1, y1, x2, y2;
00024        };
00025        Ln *start, *end, *akt;
00026        int offx1, offy1, offx2, offy2;
00027        uint numLn;
00028        public:
00029        Lines(int);
00030        ~Lines();
00031        inline void reset();
00032        inline void getKoord(int&, int&, int&, int&);
00033        inline void setKoord(const int&, const int&, const int&, const int&);
00034        inline void next(void);
00035        void turn(const int&, const int&);
00036 };
00037 
00038 class kLinesSaver:public KScreenSaver{
00039        Q_OBJECT
00040        public:
00041        kLinesSaver( WId id );
00042        virtual ~kLinesSaver();
00043 
00044        void setLines(int len);
00045        void setSpeed(int spd);
00046        void setColor(const QColor&, const QColor&, const QColor&);
00047 
00048        private:
00049        void readSettings();
00050        void initialiseLines();
00051        void initialiseColor();
00052 
00053        protected slots:
00054        void slotTimeout();
00055        protected:
00056         void paintEvent(QPaintEvent *event);
00057 
00058        protected:
00059        KRandomSequence rnd;
00060        QTimer timer;
00061        unsigned numLines;
00062        int speed;
00063        QColor colors[64];
00064     QColor colstart, colmid, colend;
00065        double colscale;
00066        Lines* lines;
00067 };
00068 
00069 class kLinesSetup : public KDialog{
00070        Q_OBJECT
00071        public:
00072        kLinesSetup(QWidget *parent=NULL);
00073     ~kLinesSetup();
00074 
00075        protected:
00076        void readSettings();
00077 
00078        private slots:
00079        void slotLength(int);
00080        void slotSpeed(int);
00081        void slotColstart(const QColor &);
00082        void slotColmid(const QColor &);
00083        void slotColend(const QColor &);
00084        void slotOk();
00085        void slotHelp();
00086 
00087        private:
00088        KColorButton *colorPush0, *colorPush1, *colorPush2;
00089        QWidget *preview;
00090        kLinesSaver *saver;
00091        int length, speed;
00092        QColor colstart, colmid, colend;
00093 };
00094 
00095 #endif
00096