]>
Commit | Line | Data |
---|---|---|
a536e411 | 1 | ///////////////////////////////////////////////////////////////////////////// |
bfc90810 | 2 | // Name: wx/display.h |
a536e411 JS |
3 | // Purpose: wxDisplay class |
4 | // Author: Royce Mitchell III | |
bfc90810 | 5 | // Modified by: Vadim Zeitlin (resolution changes, display modes, ...) |
a536e411 JS |
6 | // Created: 06/21/02 |
7 | // RCS-ID: $Id$ | |
bfc90810 | 8 | // Copyright: (c) 2002-2003 wxWindows team |
a536e411 JS |
9 | // Licence: wxWindows licence |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_DISPLAY_H_BASE_ | |
13 | #define _WX_DISPLAY_H_BASE_ | |
14 | ||
15 | #if wxUSE_DISPLAY | |
16 | ||
af49c4b8 | 17 | #if defined(__GNUG__) && !defined(__APPLE__) |
bfc90810 | 18 | #pragma interface "displaybase.h" |
a536e411 JS |
19 | #endif |
20 | ||
bfc90810 VZ |
21 | #include "wx/dynarray.h" |
22 | ||
23 | // ---------------------------------------------------------------------------- | |
24 | // wxVideoMode: contains video mode parameters for a display | |
25 | // ---------------------------------------------------------------------------- | |
26 | ||
27 | struct WXDLLEXPORT wxVideoMode | |
28 | { | |
29 | wxVideoMode(int width = 0, int height = 0, int depth = 0, int freq = 0) | |
30 | { | |
31 | w = width; | |
32 | h = height; | |
33 | ||
34 | bpp = depth; | |
35 | ||
36 | refresh = freq; | |
37 | } | |
38 | ||
39 | // default copy ctor and assignment operator are ok | |
40 | ||
41 | bool operator==(const wxVideoMode& m) const | |
42 | { | |
43 | return w == m.w && h == m.h && bpp == m.bpp && refresh == m.refresh; | |
44 | } | |
45 | bool operator!=(const wxVideoMode& mode) const | |
46 | { | |
47 | return !operator==(mode); | |
48 | } | |
49 | ||
50 | // returns true if this mode matches the other one in the sense that all | |
51 | // non zero fields of the other mode have the same value in this one | |
52 | // (except for refresh which is allowed to have a greater value) | |
53 | bool Matches(const wxVideoMode& other) const | |
54 | { | |
55 | return (!other.w || w == other.w) && | |
56 | (!other.h || h == other.h) && | |
57 | (!other.bpp || bpp == other.bpp) && | |
58 | (!other.refresh || refresh >= other.refresh); | |
59 | } | |
60 | ||
61 | // the screen size in pixels (e.g. 640*480), 0 means unspecified | |
62 | int w, h; | |
63 | ||
64 | // bits per pixel (e.g. 32), 1 is monochrome and 0 means unspecified/known | |
65 | int bpp; | |
66 | ||
67 | // refresh frequency in Hz, 0 means unspecified/unknown | |
68 | int refresh; | |
69 | }; | |
70 | ||
71 | WX_DECLARE_EXPORTED_OBJARRAY(wxVideoMode, wxArrayVideoModes); | |
72 | ||
73 | // default, uninitialized, video mode object | |
74 | WXDLLEXPORT_DATA(extern const wxVideoMode) wxDefaultVideoMode; | |
75 | ||
76 | // ---------------------------------------------------------------------------- | |
77 | // wxDisplayBase: represents a display/monitor attached to the system | |
78 | // ---------------------------------------------------------------------------- | |
a536e411 JS |
79 | |
80 | class WXDLLEXPORT wxDisplayBase | |
81 | { | |
82 | public: | |
83 | // initialize the object containing all information about the given | |
84 | // display | |
bfc90810 VZ |
85 | // |
86 | // the displays are numbered from 0 to GetCount() - 1, 0 is always the | |
87 | // primary display and the only one which is always supported | |
88 | wxDisplayBase(size_t index = 0); | |
a536e411 JS |
89 | |
90 | // return the number of available displays, valid parameters to | |
91 | // wxDisplay ctor are from 0 up to this number | |
92 | static size_t GetCount(); | |
93 | ||
bfc90810 | 94 | // find the display where the given point lies, return wxNOT_FOUND if |
a536e411 | 95 | // it doesn't belong to any display |
bfc90810 VZ |
96 | static int GetFromPoint(const wxPoint& pt); |
97 | ||
98 | // find the display where the given window lies, return wxNOT_FOUND if it | |
99 | // is not shown at all | |
100 | static int GetFromWindow(wxWindow *window); | |
a536e411 | 101 | |
a536e411 | 102 | |
06efac1f VZ |
103 | // return true if the object was initialized successfully |
104 | virtual bool IsOk() const { return true; } | |
105 | ||
bfc90810 VZ |
106 | // get the display size |
107 | virtual wxRect GetGeometry() const = 0; | |
a536e411 JS |
108 | |
109 | // name may be empty | |
110 | virtual wxString GetName() const = 0; | |
111 | ||
bfc90810 VZ |
112 | // display 0 is always the primary display |
113 | bool IsPrimary() const { return m_index == 0; } | |
114 | ||
a536e411 | 115 | |
bfc90810 VZ |
116 | // enumerate all video modes supported by this display matching the given |
117 | // one (in the sense of wxVideoMode::Match()) | |
118 | // | |
119 | // as any mode matches the default value of the argument and there is | |
120 | // always at least one video mode supported by display, the returned array | |
121 | // is only empty for the default value of the argument if this function is | |
122 | // not supported at all on this platform | |
123 | virtual wxArrayVideoModes | |
124 | GetModes(const wxVideoMode& mode = wxDefaultVideoMode) const = 0; | |
a536e411 | 125 | |
bfc90810 VZ |
126 | // get current video mode |
127 | virtual wxVideoMode GetCurrentMode() const = 0; | |
128 | ||
129 | // change current mode, return true if succeeded, false otherwise | |
130 | // | |
131 | // for the default value of the argument restores the video mode to default | |
132 | virtual bool ChangeMode(const wxVideoMode& mode = wxDefaultVideoMode) = 0; | |
133 | ||
134 | // restore the default video mode (just a more readable synonym) | |
135 | void ResetMode() { (void)ChangeMode(); } | |
136 | ||
137 | // virtual dtor as for any base class | |
138 | virtual ~wxDisplayBase() { } | |
a536e411 JS |
139 | |
140 | protected: | |
bfc90810 VZ |
141 | // the index of this display (0 is always the primary one) |
142 | size_t m_index; | |
a536e411 JS |
143 | |
144 | DECLARE_NO_COPY_CLASS(wxDisplayBase); | |
145 | }; | |
146 | ||
bfc90810 | 147 | |
a536e411 JS |
148 | #if defined(__WXMSW__) |
149 | #include "wx/msw/display.h" | |
150 | #elif defined(__WXMOTIF__) | |
151 | #include "wx/motif/display.h" | |
152 | #elif defined(__WXGTK__) | |
153 | #include "wx/gtk/display.h" | |
154 | #elif defined(__WXMAC__) | |
155 | #include "wx/mac/display.h" | |
156 | #elif defined(__WXPM__) | |
157 | #include "wx/os2/display.h" | |
158 | #endif | |
159 | ||
160 | #endif // wxUSE_DISPLAY | |
161 | ||
162 | #endif // _WX_DISPLAY_H_BASE_ |