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