]> git.tdb.fi Git - libs/gui.git/blob - source/graphics/display.h
Retrieve correct names for monitors on Windows
[libs/gui.git] / source / graphics / display.h
1 #ifndef MSP_GRAPHICS_DISPLAY_H_
2 #define MSP_GRAPHICS_DISPLAY_H_
3
4 #include <stdexcept>
5 #include <string>
6 #include <vector>
7 #include <sigc++/signal.h>
8 #include "errordialog.h"
9 #include "monitor.h"
10 #include "mspgui_api.h"
11 #include "videomode.h"
12
13 namespace Msp {
14 namespace Graphics {
15
16 class Window;
17
18 class MSPGUI_API Display
19 {
20 public:
21         struct Private;
22
23         sigc::signal<void> signal_got_focus;
24         sigc::signal<void> signal_lost_focus;
25
26 private:
27         std::vector<Monitor> monitors;
28         Monitor *primary_monitor = nullptr;
29         std::vector<VideoMode> modes;
30         Private *priv = nullptr;
31         ErrorDialog *err_dialog = nullptr;
32         Window *focus_window = nullptr;
33
34 public:
35         Display(const std::string &disp_name = std::string());
36         ~Display();
37
38         const Private &get_private() const { return *priv; }
39
40         void add_window(Window &);
41         void remove_window(Window &);
42
43         const std::vector<Monitor> &get_monitors() const { return monitors; }
44         const std::vector<VideoMode> &get_modes() const { return modes; }
45         const VideoMode &get_desktop_mode() const;
46         void set_mode(const VideoMode &, bool = false);
47         void restore_mode();
48         const VideoMode *find_mode(const VideoMode &, float = 0.5f) const;
49         const VideoMode *find_mode(unsigned, unsigned) const;
50
51 private:
52         void window_got_focus(Window &);
53         void window_lost_focus();
54 public:
55         Window *get_focus_window() const { return focus_window; }
56
57 public:
58         void tick();
59 private:
60         bool process_events();
61 public:
62         void check_error();
63 };
64
65 } // namespace Graphics
66 } // namespace Msp
67
68 #endif