1 // Jason Rohrer
2 // ProgressBar.h
3 
4 /**
5 *
6 *	ProgressBar Gui element
7 *
8 *
9 *	Created 11-6-99
10 *	Mods:
11 *		Jason Rohrer	11-8-99		Changed to use GraphicBuffer object as screen buffer
12 *
13 */
14 
15 
16 
17 #ifndef PROGRESS_BAR_INCLUDED
18 #define PROGRESS_BAR_INCLUDED
19 
20 #include "Color.h"
21 #include "GraphicBuffer.h"
22 
23 class ProgressBar {
24 
25 	public:
26 		// construct a progress bar in a specific location with
27 		//   specific border and maximum colors
28 		ProgressBar( int x, int y, int w, int h, Color bordC, Color hC, Color tipC );
29 		~ProgressBar();
30 
31 		void setProgress( float fractionFull );
32 
33 		// draw progress bar into a graphic buffer
34 		void draw( GraphicBuffer &buff );
35 
36 		// erase progress bar from buffer
37 		void erase( GraphicBuffer &buff, Color &bgColor );
38 
39 	private:
40 
41 		unsigned long *imageMap;
42 
43 		int startX;
44 		int startY;
45 		int high;
46 		int wide;
47 
48 		int barHigh;	// width and heigth of area inside borders
49 		int barWide;
50 
51 		int *mapYOffset;
52 
53 		Color borderC;		// color of border
54 		Color highC;		// color of progress bar max
55 
56 		Color barTipC;
57 
58 		static const int borderWide = 2;
59 
60 		float lastProgress;		// fraction of last progress
61 
62 	};
63 
64 
65 
draw(GraphicBuffer & buff)66 inline void ProgressBar::draw( GraphicBuffer &buff ) {
67 	buff.drawImage(imageMap, mapYOffset, startX, startY, wide, high);
68 	}
69 
erase(GraphicBuffer & buff,Color & bgColor)70 inline void ProgressBar::erase( GraphicBuffer &buff, Color &bgColor ) {
71 	buff.eraseImage(startX, startY, wide, high, bgColor);
72 	}
73 
74 
75 #endif