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