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