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