]> git.tdb.fi Git - libs/gui.git/blob - source/graphics/display.h
d311ba73c75f36ded3fe02e0401518638e88d2e2
[libs/gui.git] / source / graphics / display.h
1 #ifndef MSP_GRAPHICS_DISPLAY_H_
2 #define MSP_GRAPHICS_DISPLAY_H_
3
4 #include <list>
5 #include <stdexcept>
6 #include <string>
7
8 namespace Msp {
9 namespace Graphics {
10
11 class Window;
12
13 struct VideoMode
14 {
15         unsigned width;
16         unsigned height;
17         unsigned rate;
18
19         VideoMode(): width(0), height(0), rate(0) { }
20         VideoMode(unsigned w, unsigned h): width(w), height(h), rate(0) { }
21 };
22
23
24 class unsupported_video_mode: public std::runtime_error
25 {
26 public:
27         unsupported_video_mode(const VideoMode &);
28         virtual ~unsupported_video_mode() throw () { }
29 };
30
31
32 class Display
33 {
34 public:
35         struct Private;
36
37 private:
38         std::list<VideoMode> modes;
39         VideoMode orig_mode;
40         Private *priv;
41
42 public:
43         Display(const std::string &disp_name = std::string());
44         ~Display();
45
46         const Private &get_private() const { return *priv; }
47
48         void add_window(Window &);
49         void remove_window(Window &);
50
51         const std::list<VideoMode> &get_modes() const { return modes; }
52         const VideoMode &get_desktop_mode() const { return orig_mode; }
53         void set_mode(const VideoMode &);
54         void restore_mode() { set_mode(orig_mode); }
55
56         void tick();
57 private:
58         bool process_events();
59 public:
60         void check_error();
61 };
62
63 } // namespace Graphics
64 } // namespace Msp
65
66 #endif