1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface for wxVideoMode and wxDisplay
9 // Copyright: (c) 2004 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
19 #include <wx/display.h>
23 //---------------------------------------------------------------------------
28 "A simple struct containing video mode parameters for a display", "");
32 wxVideoMode(int width = 0, int height = 0, int depth = 0, int freq = 0);
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)", "");
42 int , GetWidth() const,
43 "Returns the screen width in pixels (e.g. 640*480), 0 means unspecified", "");
46 int , GetHeight() const,
47 "Returns the screen width in pixels (e.g. 640*480), 0 means
51 int , GetDepth() const,
52 "Returns the screen's bits per pixel (e.g. 32), 1 is monochrome and 0
53 means unspecified/known", "");
58 "returns true if the object has been initialized", "");
62 %pythoncode { def __nonzero__(self): return self.IsOk() }
64 bool __eq__(const wxVideoMode* other) { return other ? (*self == *other) : false; }
65 bool __ne__(const wxVideoMode* other) { return other ? (*self != *other) : true; }
69 // the screen size in pixels (e.g. 640*480), 0 means unspecified
72 // bits per pixel (e.g. 32), 1 is monochrome and 0 means unspecified/known
75 // refresh frequency in Hz, 0 means unspecified/unknown
81 const wxVideoMode wxDefaultVideoMode;
85 //---------------------------------------------------------------------------
89 // dummy version of wxDisplay for when it is not enabled in the wxWidgets build
91 #include <wx/dynarray.h>
92 #include <wx/vidmode.h>
94 WX_DECLARE_OBJARRAY(wxVideoMode, wxArrayVideoModes);
95 #include "wx/arrimpl.cpp"
96 WX_DEFINE_OBJARRAY(wxArrayVideoModes);
97 const wxVideoMode wxDefaultVideoMode;
102 wxDisplay(size_t index = 0) { wxPyRaiseNotImplemented(); }
105 static size_t GetCount()
106 { wxPyRaiseNotImplemented(); return 0; }
108 static int GetFromPoint(const wxPoint& pt)
109 { wxPyRaiseNotImplemented(); return wxNOT_FOUND; }
110 static int GetFromWindow(wxWindow *window)
111 { wxPyRaiseNotImplemented(); return wxNOT_FOUND; }
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; }
118 wxArrayVideoModes GetModes(const wxVideoMode& mode = wxDefaultVideoMode)
119 { wxArrayVideoModes a; return a; }
121 virtual wxVideoMode GetCurrentMode() const
122 { return wxDefaultVideoMode; }
124 virtual bool ChangeMode(const wxVideoMode& mode = wxDefaultVideoMode)
135 "Represents a display/monitor attached to the system", "");
141 wxDisplay(size_t index = 0),
142 "Set up a Display instance with the specified display. The displays
143 are numbered from 0 to GetCount() - 1, 0 is always the primary display
144 and the only one which is always supported", "");
146 virtual ~wxDisplay();
149 static size_t , GetCount(),
150 "Return the number of available displays.", "");
154 static int , GetFromPoint(const wxPoint& pt),
155 "Find the display where the given point lies, return wx.NOT_FOUND if it
156 doesn't belong to any display", "");
159 DocStr(GetFromWindow,
160 "Find the display where the given window lies, return wx.NOT_FOUND if
161 it is not shown at all.", "");
162 static int GetFromWindow(wxWindow *window);
166 virtual bool , IsOk() const,
167 "Return true if the object was initialized successfully", "");
168 %pythoncode { def __nonzero__(self): return self.IsOk() }
172 virtual wxRect , GetGeometry() const,
173 "Returns the bounding rectangle of the display whose index was passed
174 to the constructor.", "");
178 virtual wxString , GetName() const,
179 "Returns the display's name. A name is not available on all platforms.", "");
183 bool , IsPrimary() const,
184 "Returns true if the display is the primary display. The primary
185 display is the one whose index is 0.", "");
191 "GetModes(VideoMode mode=DefaultVideoMode) -> [videoMode...]",
192 "Enumerate all video modes supported by this display matching the given
193 one (in the sense of VideoMode.Match()).
195 As any mode matches the default value of the argument and there is
196 always at least one video mode supported by display, the returned
197 array is only empty for the default value of the argument if this
198 function is not supported at all on this platform.", "");
200 PyObject* GetModes(const wxVideoMode& mode = wxDefaultVideoMode) {
201 PyObject* pyList = NULL;
202 wxArrayVideoModes arr = self->GetModes(mode);
203 wxPyBlock_t blocked = wxPyBeginBlockThreads();
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);
211 wxPyEndBlockThreads(blocked);
218 virtual wxVideoMode , GetCurrentMode() const,
219 "Get the current video mode.", "");
223 virtual bool , ChangeMode(const wxVideoMode& mode = wxDefaultVideoMode),
224 "Changes the video mode of this display to the mode specified in the
227 If wx.DefaultVideoMode is passed in as the mode parameter, the defined
228 behaviour is that wx.Display will reset the video mode to the default
229 mode used by the display. On Windows, the behavior is normal.
230 However, there are differences on other platforms. On Unix variations
231 using X11 extensions it should behave as defined, but some
232 irregularities may occur.
234 On wxMac passing in wx.DefaultVideoMode as the mode parameter does
235 nothing. This happens because Carbon no longer has access to
236 DMUseScreenPrefs, an undocumented function that changed the video mode
237 to the system default by using the system's 'scrn' resource.
239 Returns True if succeeded, False otherwise", "");
244 "Restore the default video mode (just a more readable synonym)", "");
249 //---------------------------------------------------------------------------