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