]> git.tdb.fi Git - libs/gui.git/blob - source/display.h
70efd20627426bed067dbd988b8cac1e1c811c4b
[libs/gui.git] / source / display.h
1 /* $Id$
2
3 This file is part of libmspgbase
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GBASE_DISPLAY_H_
9 #define MSP_GBASE_DISPLAY_H_
10
11 #include <list>
12 #include <map>
13 #include <string>
14 #include "types.h"
15
16 namespace Msp {
17 namespace Graphics {
18
19 class Window;
20
21 struct VideoMode
22 {
23         unsigned width;
24         unsigned height;
25         unsigned rate;
26
27         VideoMode(): width(0), height(0), rate(0) { }
28         VideoMode(unsigned w, unsigned h): width(w), height(h), rate(0) { }
29 };
30
31 class Display
32 {
33 private:
34 #ifndef WIN32
35         ::Display *display;
36 #endif
37         std::list<VideoMode> modes;
38         VideoMode orig_mode;
39         std::map<WindowHandle, Window *> windows;
40
41 public:
42         Display(const std::string &disp_name=std::string());
43         ~Display();
44
45 #ifndef WIN32
46         ::Display *get_display() const { return display; }
47 #endif
48
49         void add_window(Window *);
50         void remove_window(Window *);
51
52         const std::list<VideoMode> &get_modes() const { return modes; }
53         void set_mode(const VideoMode &);
54         void restore_mode() { set_mode(orig_mode); }
55
56         void tick();
57         void check_error();
58 };
59
60 } // namespace Graphics
61 } // namespace Msp
62
63 #endif