1 /*
2  * Copyright 2010-2014 OpenXcom Developers.
3  *
4  * This file is part of OpenXcom.
5  *
6  * OpenXcom is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * OpenXcom is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with OpenXcom.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef OPENXCOM_SCROLLBAR_H
20 #define OPENXCOM_SCROLLBAR_H
21 
22 #include "../Engine/InteractiveSurface.h"
23 
24 namespace OpenXcom
25 {
26 
27 class TextList;
28 
29 /**
30  * Horizontal scrollbar control to select from a range of values.
31  */
32 class ScrollBar : public InteractiveSurface
33 {
34 private:
35 	TextList *_list;
36 	Uint8 _color;
37 	bool _pressed, _contrast;
38 	Surface *_track, *_thumb;
39 	SDL_Rect _thumbRect;
40 	int _offset;
41 	Surface *_bg;
42 	/// Draws the scrollbar track.
43 	void drawTrack();
44 	/// Draws the scrollbar thumb.
45 	void drawThumb();
46 public:
47 	/// Creates a new scrollbar with the specified size and position.
48 	ScrollBar(int width, int height, int x = 0, int y = 0);
49 	/// Cleans up the scrollbar.
50 	~ScrollBar();
51 	/// Sets the X position of the surface.
52 	void setX(int x);
53 	/// Sets the Y position of the surface.
54 	void setY(int y);
55 	/// Sets the height of the surface.
56 	void setHeight(int height);
57 	/// Sets the scrollbar's color.
58 	void setColor(Uint8 color);
59 	/// Gets the scrollbar's color.
60 	Uint8 getColor() const;
61 	/// Sets the scrollbar's high contrast color setting.
62 	void setHighContrast(bool contrast);
63 	/// Sets the scrollbar's list.
64 	void setTextList(TextList *list);
65 	/// Sets the background for the track.
66 	void setBackground(Surface *bg);
67 	/// Sets the scrollbar's palette.
68 	void setPalette(SDL_Color *colors, int firstcolor = 0, int ncolors = 256);
69 	/// Blits the scrollbar onto another surface.
70 	void blit(Surface *surface);
71 	/// Moves the scrollbar.
72 	void handle(Action *action, State *state);
73 	/// Special handling for mouse presses.
74 	void mousePress(Action *action, State *state);
75 	/// Special handling for mouse releases.
76 	void mouseRelease(Action *action, State *state);
77 	/// Draws the scrollbar contents.
78 	void draw();
79 };
80 
81 }
82 
83 #endif
84