]>
Commit | Line | Data |
---|---|---|
96d37ab5 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: _display.i | |
3 | // Purpose: SWIG interface for wxVideoMode and wxDisplay | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 9-Mar-2004 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2004 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | // Not a %module | |
14 | ||
15 | ||
16 | //--------------------------------------------------------------------------- | |
17 | ||
18 | %{ | |
f2e64141 | 19 | #include <wx/display.h> |
96d37ab5 RD |
20 | %} |
21 | ||
22 | ||
23 | //--------------------------------------------------------------------------- | |
24 | %newgroup | |
25 | ||
26 | ||
27 | DocStr(wxVideoMode, | |
d07d2bc9 | 28 | "A simple struct containing video mode parameters for a display", ""); |
96d37ab5 RD |
29 | |
30 | struct wxVideoMode | |
31 | { | |
32 | wxVideoMode(int width = 0, int height = 0, int depth = 0, int freq = 0); | |
33 | ~wxVideoMode(); | |
611ac06b | 34 | |
96d37ab5 RD |
35 | DocDeclStr( |
36 | bool , Matches(const wxVideoMode& other) const, | |
3abaf181 | 37 | "Returns True if this mode matches the other one in the sense that all |
611ac06b | 38 | non-zero fields of the other mode have the same value in this |
d07d2bc9 | 39 | one (except for refresh which is allowed to have a greater value)", ""); |
96d37ab5 RD |
40 | |
41 | DocDeclStr( | |
42 | int , GetWidth() const, | |
d07d2bc9 | 43 | "Returns the screen width in pixels (e.g. 640*480), 0 means unspecified", ""); |
611ac06b | 44 | |
96d37ab5 RD |
45 | DocDeclStr( |
46 | int , GetHeight() const, | |
611ac06b DS |
47 | "Returns the screen height in pixels (e.g. 640*480), 0 means unspecified", ""); |
48 | ||
96d37ab5 RD |
49 | DocDeclStr( |
50 | int , GetDepth() const, | |
d07d2bc9 RD |
51 | "Returns the screen's bits per pixel (e.g. 32), 1 is monochrome and 0 |
52 | means unspecified/known", ""); | |
611ac06b | 53 | |
96d37ab5 RD |
54 | |
55 | DocDeclStr( | |
56 | bool , IsOk() const, | |
d07d2bc9 | 57 | "returns true if the object has been initialized", ""); |
96d37ab5 RD |
58 | |
59 | ||
60 | %pythoncode { def __nonzero__(self): return self.IsOk() } | |
61 | %extend { | |
a72f4631 RD |
62 | bool __eq__(const wxVideoMode* other) { return other ? (*self == *other) : false; } |
63 | bool __ne__(const wxVideoMode* other) { return other ? (*self != *other) : true; } | |
96d37ab5 RD |
64 | } |
65 | ||
611ac06b | 66 | |
96d37ab5 RD |
67 | // the screen size in pixels (e.g. 640*480), 0 means unspecified |
68 | int w, h; | |
69 | ||
70 | // bits per pixel (e.g. 32), 1 is monochrome and 0 means unspecified/known | |
71 | int bpp; | |
72 | ||
73 | // refresh frequency in Hz, 0 means unspecified/unknown | |
74 | int refresh; | |
dba7934c RD |
75 | |
76 | %property(Depth, GetDepth, doc="See `GetDepth`"); | |
77 | %property(Height, GetHeight, doc="See `GetHeight`"); | |
78 | %property(Width, GetWidth, doc="See `GetWidth`"); | |
96d37ab5 RD |
79 | }; |
80 | ||
81 | ||
3abaf181 RD |
82 | %{ |
83 | #if !wxUSE_DISPLAY | |
84 | const wxVideoMode wxDefaultVideoMode; | |
85 | #endif | |
611ac06b | 86 | %} |
3abaf181 | 87 | |
96d37ab5 RD |
88 | %immutable; |
89 | const wxVideoMode wxDefaultVideoMode; | |
90 | %mutable; | |
91 | ||
92 | ||
93 | //--------------------------------------------------------------------------- | |
94 | ||
96d37ab5 | 95 | |
f2e64141 | 96 | |
f2e64141 RD |
97 | DocStr(wxDisplay, |
98 | "Represents a display/monitor attached to the system", ""); | |
96d37ab5 RD |
99 | class wxDisplay |
100 | { | |
101 | public: | |
96d37ab5 RD |
102 | DocCtorStr( |
103 | wxDisplay(size_t index = 0), | |
d07d2bc9 RD |
104 | "Set up a Display instance with the specified display. The displays |
105 | are numbered from 0 to GetCount() - 1, 0 is always the primary display | |
106 | and the only one which is always supported", ""); | |
96d37ab5 | 107 | |
3abaf181 RD |
108 | ~wxDisplay(); |
109 | ||
96d37ab5 RD |
110 | DocDeclStr( |
111 | static size_t , GetCount(), | |
d07d2bc9 | 112 | "Return the number of available displays.", ""); |
96d37ab5 RD |
113 | |
114 | DocDeclStr( | |
115 | static int , GetFromPoint(const wxPoint& pt), | |
d07d2bc9 RD |
116 | "Find the display where the given point lies, return wx.NOT_FOUND if it |
117 | doesn't belong to any display", ""); | |
96d37ab5 RD |
118 | |
119 | DocStr(GetFromWindow, | |
d07d2bc9 RD |
120 | "Find the display where the given window lies, return wx.NOT_FOUND if |
121 | it is not shown at all.", ""); | |
611ac06b | 122 | |
96d37ab5 | 123 | static int GetFromWindow(wxWindow *window); |
eb3d1416 | 124 | |
611ac06b | 125 | |
96d37ab5 | 126 | DocDeclStr( |
3abaf181 | 127 | bool , IsOk() const, |
d07d2bc9 | 128 | "Return true if the object was initialized successfully", ""); |
96d37ab5 | 129 | %pythoncode { def __nonzero__(self): return self.IsOk() } |
96d37ab5 RD |
130 | |
131 | DocDeclStr( | |
3abaf181 | 132 | wxRect , GetGeometry() const, |
d07d2bc9 RD |
133 | "Returns the bounding rectangle of the display whose index was passed |
134 | to the constructor.", ""); | |
90ab4a35 | 135 | |
90ab4a35 RD |
136 | DocDeclStr( |
137 | wxRect , GetClientArea() const, | |
611ac06b DS |
138 | "Returns the bounding rectangle the client area of the display, |
139 | i.e., without taskbars and such.", ""); | |
96d37ab5 RD |
140 | |
141 | DocDeclStr( | |
3abaf181 | 142 | wxString , GetName() const, |
d07d2bc9 | 143 | "Returns the display's name. A name is not available on all platforms.", ""); |
96d37ab5 RD |
144 | |
145 | DocDeclStr( | |
146 | bool , IsPrimary() const, | |
611ac06b | 147 | "Returns True if the display is the primary display. The primary |
d07d2bc9 | 148 | display is the one whose index is 0.", ""); |
96d37ab5 RD |
149 | |
150 | ||
611ac06b DS |
151 | %extend |
152 | { | |
96d37ab5 RD |
153 | DocAStr(GetModes, |
154 | "GetModes(VideoMode mode=DefaultVideoMode) -> [videoMode...]", | |
d07d2bc9 RD |
155 | "Enumerate all video modes supported by this display matching the given |
156 | one (in the sense of VideoMode.Match()). | |
157 | ||
158 | As any mode matches the default value of the argument and there is | |
159 | always at least one video mode supported by display, the returned | |
160 | array is only empty for the default value of the argument if this | |
161 | function is not supported at all on this platform.", ""); | |
611ac06b DS |
162 | |
163 | PyObject* GetModes(const wxVideoMode& mode = wxDefaultVideoMode) | |
164 | { | |
3abaf181 | 165 | %#if wxUSE_DISPLAY |
96d37ab5 RD |
166 | PyObject* pyList = NULL; |
167 | wxArrayVideoModes arr = self->GetModes(mode); | |
6e6b3557 | 168 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); |
96d37ab5 | 169 | pyList = PyList_New(0); |
611ac06b DS |
170 | for (size_t i=0; i < arr.GetCount(); i++) |
171 | { | |
96d37ab5 RD |
172 | wxVideoMode* m = new wxVideoMode(arr.Item(i)); |
173 | PyObject* pyObj = wxPyConstructObject(m, wxT("wxVideoMode"), true); | |
174 | PyList_Append(pyList, pyObj); | |
ad411ab2 | 175 | Py_DECREF(pyObj); |
96d37ab5 | 176 | } |
da32eb53 | 177 | wxPyEndBlockThreads(blocked); |
96d37ab5 | 178 | return pyList; |
3abaf181 RD |
179 | %#else |
180 | wxPyRaiseNotImplemented(); | |
181 | return NULL; | |
182 | %#endif | |
96d37ab5 | 183 | } |
611ac06b | 184 | |
3abaf181 RD |
185 | DocStr(GetCurrentMode, |
186 | "Get the current video mode.", ""); | |
611ac06b DS |
187 | wxVideoMode GetCurrentMode() const |
188 | { | |
3abaf181 RD |
189 | %#if wxUSE_DISPLAY |
190 | return self->GetCurrentMode(); | |
191 | %#else | |
192 | wxPyRaiseNotImplemented(); | |
193 | return wxDefaultVideoMode; | |
194 | %#endif | |
195 | } | |
611ac06b | 196 | |
96d37ab5 | 197 | |
3abaf181 RD |
198 | DocStr( |
199 | ChangeMode, | |
200 | "Changes the video mode of this display to the mode specified in the | |
9f8a9f54 RD |
201 | mode parameter. |
202 | ||
203 | If wx.DefaultVideoMode is passed in as the mode parameter, the defined | |
204 | behaviour is that wx.Display will reset the video mode to the default | |
205 | mode used by the display. On Windows, the behavior is normal. | |
206 | However, there are differences on other platforms. On Unix variations | |
207 | using X11 extensions it should behave as defined, but some | |
208 | irregularities may occur. | |
209 | ||
210 | On wxMac passing in wx.DefaultVideoMode as the mode parameter does | |
211 | nothing. This happens because Carbon no longer has access to | |
212 | DMUseScreenPrefs, an undocumented function that changed the video mode | |
213 | to the system default by using the system's 'scrn' resource. | |
214 | ||
215 | Returns True if succeeded, False otherwise", ""); | |
611ac06b DS |
216 | |
217 | bool ChangeMode(const wxVideoMode& mode = wxDefaultVideoMode) | |
218 | { | |
3abaf181 RD |
219 | %#if wxUSE_DISPLAY |
220 | return self->ChangeMode(mode); | |
221 | %#else | |
222 | wxPyRaiseNotImplemented(); | |
223 | return false; | |
224 | %#endif | |
225 | } | |
96d37ab5 | 226 | |
96d37ab5 | 227 | |
3abaf181 RD |
228 | DocStr( |
229 | ResetMode, | |
230 | "Restore the default video mode (just a more readable synonym)", ""); | |
611ac06b DS |
231 | void ResetMode() |
232 | { | |
3abaf181 RD |
233 | %#if wxUSE_DISPLAY |
234 | self->ResetMode(); | |
235 | %#else | |
236 | wxPyRaiseNotImplemented(); | |
237 | %#endif | |
238 | } | |
611ac06b | 239 | |
3abaf181 | 240 | } // end of %extend |
0eae5d09 RD |
241 | |
242 | %property(ClientArea, GetClientArea, doc="See `GetClientArea`"); | |
243 | %property(CurrentMode, GetCurrentMode, doc="See `GetCurrentMode`"); | |
244 | %property(Geometry, GetGeometry, doc="See `GetGeometry`"); | |
245 | %property(Modes, GetModes, doc="See `GetModes`"); | |
246 | %property(Name, GetName, doc="See `GetName`"); | |
247 | ||
96d37ab5 RD |
248 | }; |
249 | ||
250 | //--------------------------------------------------------------------------- |