xref: /haiku/src/add-ons/screen_savers/spider/SpiderSaver.h (revision 820dca4df6c7bf955c46e8f6521b9408f50b2900)
1 /*
2  * Copyright 2007, Haiku Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Stephan Aßmus <superstippi@gmx.de>
7  */
8 #ifndef SPIDER_SAVER_H
9 #define SPIDER_SAVER_H
10 
11 #include <Locker.h>
12 #include <ScreenSaver.h>
13 #include <View.h>
14 
15 class BSlider;
16 class BMenuField;
17 class Polygon;
18 class PolygonQueue;
19 class SpiderView;
20 
21 class SpiderSaver : public BScreenSaver {
22  public:
23 								SpiderSaver(BMessage *message,
24 											image_id image);
25 	virtual						~SpiderSaver();
26 
27 								// BScreenSaver
28 	virtual	void				StartConfig(BView *view);
29 	virtual	status_t			StartSaver(BView *view, bool preview);
30 	virtual	void				StopSaver();
31 	virtual	void				Draw(BView* view, int32 frame);
32 	virtual	status_t			SaveState(BMessage* into) const;
33 
34 								// SpiderSaver
35 			void				SetQueueNumber(uint32 number);
36 			void				SetQueueDepth(uint32 maxDepth);
37 			void				SetPolyPoints(uint32 maxPoints);
38 			void				SetColor(uint32 color);
39 
40  private:
41 			void				_Init(BRect bounds);
42 			void				_Cleanup();
43 			void				_AllocBackBitmap(float width, float height);
44 			void				_FreeBackBitmap();
45 			void				_DrawInto(BView *view);
46 			void				_DrawPolygon(Polygon* polygon, BView *view);
47 
48 	BBitmap*					fBackBitmap;
49 	BView*						fBackView;
50 
51 	PolygonQueue**				fQueues;
52 	uint32						fQueueNumber;
53 	uint32						fMaxPolyPoints;
54 	uint32						fMaxQueueDepth;
55 	uint32						fColor;
56 
57 	bool						fPreview;
58 	BRect						fBounds;
59 
60 	BLocker						fLocker;
61 };
62 
63 class SpiderView : public BView {
64  public:
65 								SpiderView(BRect frame,
66 										   SpiderSaver* saver,
67 										   uint32 queueNumber,
68 										   uint32 maxPolyPoints,
69 										   uint32 maxQueueDepth,
70 										   uint32 color);
71 	virtual						~SpiderView();
72 
73 								// BView
74 	virtual	void				AttachedToWindow();
75 	virtual	void				MessageReceived(BMessage* message);
76 
77  private:
78 			SpiderSaver*		fSaver;
79 
80 			BSlider*			fQueueNumberS;
81 			BSlider*			fPolyNumberS;
82 			BSlider*			fQueueDepthS;
83 			BMenuField*			fColorMF;
84 };
85 
86 #endif	//	SPIDER_SAVER_H
87