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