summaryrefslogtreecommitdiffstats
path: root/tdescreensaver/kdesavers/science.h
blob: d35788b8503fc46f651d1af0f9a908e3c91d4557 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// ----------------------------------------------------------------
//
// kscience - screen saver for TDE
//
// copyright (c)  Rene Beutler 1998
//

#ifndef __SCIENCE_H__
#define __SCIENCE_H__

#include <tqrect.h>
#include <tqtimer.h>
#include <kdialogbase.h>
#include <tdescreensaver.h>

class TQSlider;
class TQCheckBox;

#define MAX_MODES  6

typedef signed int T32bit;

class KScienceSaver;

class KPreviewWidget : public TQWidget
{
	Q_OBJECT
  
public:
	KPreviewWidget( TQWidget *parent );
	void paintEvent( TQPaintEvent *event );
	void notifySaver( KScienceSaver *s = 0 );
private:
	KScienceSaver *saver;
};

struct KScienceData;

class KScienceSaver : public KScreenSaver
{
	Q_OBJECT
  
public:
	KScienceSaver( WId id, bool setup=false, bool gP=false);
	virtual ~KScienceSaver();

	void do_refresh( const TQRect & rect );
	void setMode        ( int mode );
	void setMoveX       ( signed int s );
	void setMoveY       ( signed int s );
	void setMove        ( bool s );	
	void setSize        ( signed int s );
	void setIntensity   ( signed int s );
	void setSpeed       ( signed int s );
	void setInverse     ( bool b );
	void setGravity     ( bool b );
	void setHideBG      ( bool b );

	void myAssert( bool term, const char *sMsg );

private:
	void readSettings();
	void initLens();
	void initialize();
	void releaseLens();
	void (KScienceSaver::*applyLens)(int xs, int ys, int xd, int yd, int w, int h);

protected slots:
	void slotTimeout();

protected:
	void       grabRootWindow();
	void       grabPreviewWidget();
	void       initWhirlLens();
	void       initSphereLens();
	void       initExponentialLens();
	void       initWaveLens();
	void       initCurvatureLens();
	void       blackPixel( int x, int y );
	void       blackPixelUndo( int x, int y);
	void       applyLens8bpp( int xs, int ys, int xd, int yd, int w, int h);
	void       applyLens16bpp(int xs, int ys, int xd, int yd, int w, int h);
	void       applyLens24bpp(int xs, int ys, int xd, int yd, int w, int h);
	void       applyLens32bpp(int xs, int ys, int xd, int yd, int w, int h);
	TQTimer     timer;
	bool       moveOn;
	bool       setup;
	bool       grabPixmap;
	int        mode;
	bool       inverse[MAX_MODES];
	bool       gravity[MAX_MODES];
	bool       hideBG[MAX_MODES];
	signed int size[MAX_MODES];
	signed int moveX[MAX_MODES];
	signed int moveY[MAX_MODES];
	signed int speed[MAX_MODES];
	signed int intensity[MAX_MODES];
	int        xcoord, ycoord;
	double     x, y, vx, vy;
	signed int bpp, side;
	int        border, radius, diam, origin;
	int        imgnext;
	char       blackRestore[4];
    KScienceData *d;
};


class KScienceSetup : public KDialogBase
{
	Q_OBJECT
  
public:
	KScienceSetup(TQWidget *parent=0, const char *name=0);
	~KScienceSetup();
protected:
	void updateSettings();
	void readSettings();

private slots:
	void slotMode( int );
	void slotInverse();
	void slotGravity();
	void slotHideBG();
	void slotMoveX( int );
	void slotMoveY( int );
	void slotSize( int );
	void slotIntensity( int );
	void slotSliderPressed();
	void slotSliderReleased();
	void slotSpeed( int );
	void slotOk();
	void slotHelp();

private:
	KPreviewWidget *preview;
	KScienceSaver *saver;
	TQSlider *slideSize, *slideSpeed, *slideIntensity;
	TQSlider *slideMoveX, *slideMoveY;
	TQCheckBox *checkInverse, *checkGravity, *checkHideBG;	

	int  mode;
	bool inverse  [MAX_MODES];
	bool gravity  [MAX_MODES];
	bool hideBG   [MAX_MODES];
	int  moveX    [MAX_MODES];
	int  moveY    [MAX_MODES];	
	int  size     [MAX_MODES]; 
	int  intensity[MAX_MODES];
	int  speed    [MAX_MODES];
};
#endif