]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/src/_display.i
Add wxGraphicsMatrix::Get
[wxWidgets.git] / wxPython / src / _display.i
... / ...
CommitLineData
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#include <wx/vidmode.h>
21%}
22
23
24//---------------------------------------------------------------------------
25%newgroup
26
27
28DocStr(wxVideoMode,
29 "A simple struct containing video mode parameters for a display", "");
30
31struct wxVideoMode
32{
33 wxVideoMode(int width = 0, int height = 0, int depth = 0, int freq = 0);
34 ~wxVideoMode();
35
36 DocDeclStr(
37 bool , Matches(const wxVideoMode& other) const,
38 "Returns True if this mode matches the other one in the sense that all
39non-zero fields of the other mode have the same value in this
40one (except for refresh which is allowed to have a greater value)", "");
41
42 DocDeclStr(
43 int , GetWidth() const,
44 "Returns the screen width in pixels (e.g. 640*480), 0 means unspecified", "");
45
46 DocDeclStr(
47 int , GetHeight() const,
48 "Returns the screen height in pixels (e.g. 640*480), 0 means unspecified", "");
49
50 DocDeclStr(
51 int , GetDepth() const,
52 "Returns the screen's bits per pixel (e.g. 32), 1 is monochrome and 0
53means unspecified/known", "");
54
55
56 DocDeclStr(
57 bool , IsOk() const,
58 "returns true if the object has been initialized", "");
59
60
61 %pythoncode { def __nonzero__(self): return self.IsOk() }
62 %extend {
63 bool __eq__(const wxVideoMode* other) { return other ? (*self == *other) : false; }
64 bool __ne__(const wxVideoMode* other) { return other ? (*self != *other) : true; }
65 }
66
67
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;
76
77 %property(Depth, GetDepth, doc="See `GetDepth`");
78 %property(Height, GetHeight, doc="See `GetHeight`");
79 %property(Width, GetWidth, doc="See `GetWidth`");
80};
81
82
83%{
84#if !wxUSE_DISPLAY
85const wxVideoMode wxDefaultVideoMode;
86#endif
87%}
88
89%immutable;
90const wxVideoMode wxDefaultVideoMode;
91%mutable;
92
93
94//---------------------------------------------------------------------------
95
96
97
98DocStr(wxDisplay,
99 "Represents a display/monitor attached to the system", "");
100class wxDisplay
101{
102public:
103 DocCtorStr(
104 wxDisplay(unsigned index = 0),
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", "");
108
109 ~wxDisplay();
110
111 DocDeclStr(
112 static unsigned , GetCount(),
113 "Return the number of available displays.", "");
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
118doesn't belong to any display", "");
119
120 DocStr(GetFromWindow,
121 "Find the display where the given window lies, return wx.NOT_FOUND if
122it is not shown at all.", "");
123
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 DocDeclStr(
133 wxRect , GetGeometry() const,
134 "Returns the bounding rectangle of the display whose index was passed
135to the constructor.", "");
136
137 DocDeclStr(
138 wxRect , GetClientArea() const,
139 "Returns the bounding rectangle the client area of the display,
140i.e., without taskbars and such.", "");
141
142 DocDeclStr(
143 wxString , GetName() const,
144 "Returns the display's name. A name is not available on all platforms.", "");
145
146 DocDeclStr(
147 bool , IsPrimary() const,
148 "Returns True if the display is the primary display. The primary
149display is the one whose index is 0.", "");
150
151
152 %extend
153 {
154 DocAStr(GetModes,
155 "GetModes(VideoMode mode=DefaultVideoMode) -> [videoMode...]",
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.", "");
163
164 PyObject* GetModes(const wxVideoMode& mode = wxDefaultVideoMode)
165 {
166%#if wxUSE_DISPLAY
167 PyObject* pyList = NULL;
168 wxArrayVideoModes arr = self->GetModes(mode);
169 wxPyBlock_t blocked = wxPyBeginBlockThreads();
170 pyList = PyList_New(0);
171 for (size_t i=0; i < arr.GetCount(); i++)
172 {
173 wxVideoMode* m = new wxVideoMode(arr.Item(i));
174 PyObject* pyObj = wxPyConstructObject(m, wxT("wxVideoMode"), true);
175 PyList_Append(pyList, pyObj);
176 Py_DECREF(pyObj);
177 }
178 wxPyEndBlockThreads(blocked);
179 return pyList;
180%#else
181 wxPyRaiseNotImplemented();
182 return NULL;
183%#endif
184 }
185
186 DocStr(GetCurrentMode,
187 "Get the current video mode.", "");
188 wxVideoMode GetCurrentMode() const
189 {
190%#if wxUSE_DISPLAY
191 return self->GetCurrentMode();
192%#else
193 wxPyRaiseNotImplemented();
194 return wxDefaultVideoMode;
195%#endif
196 }
197
198
199 DocStr(
200 ChangeMode,
201 "Changes the video mode of this display to the mode specified in the
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", "");
217
218 bool ChangeMode(const wxVideoMode& mode = wxDefaultVideoMode)
219 {
220%#if wxUSE_DISPLAY
221 return self->ChangeMode(mode);
222%#else
223 wxPyRaiseNotImplemented();
224 return false;
225%#endif
226 }
227
228
229 DocStr(
230 ResetMode,
231 "Restore the default video mode (just a more readable synonym)", "");
232 void ResetMode()
233 {
234%#if wxUSE_DISPLAY
235 self->ResetMode();
236%#else
237 wxPyRaiseNotImplemented();
238%#endif
239 }
240
241 } // end of %extend
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
249};
250
251//---------------------------------------------------------------------------