]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_display.i
Patches from KevinO that work around issues where the widget isn't
[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
38 all 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
44 unspecified");
45
46 DocDeclStr(
47 int , GetHeight() const,
48 "Returns the screen width in pixels (e.g. 640*480), 0 means
49 unspecified");
50
51 DocDeclStr(
52 int , GetDepth() const,
53 "Returns the screen's bits per pixel (e.g. 32), 1 is monochrome
54 and 0 means unspecified/known");
55
56
57 DocDeclStr(
58 bool , IsOk() const,
59 "returns true if the object has been initialized");
60
61
62
63 %pythoncode { def __nonzero__(self): return self.IsOk() }
64 %extend {
65 bool __eq__(const wxVideoMode* other) { return other ? (*self == *other) : False; }
66 bool __ne__(const wxVideoMode* other) { return other ? (*self != *other) : True; }
67 }
68
69
70 // the screen size in pixels (e.g. 640*480), 0 means unspecified
71 int w, h;
72
73 // bits per pixel (e.g. 32), 1 is monochrome and 0 means unspecified/known
74 int bpp;
75
76 // refresh frequency in Hz, 0 means unspecified/unknown
77 int refresh;
78 };
79
80
81 %immutable;
82 const wxVideoMode wxDefaultVideoMode;
83 %mutable;
84
85
86 //---------------------------------------------------------------------------
87
88 DocStr(wxDisplay,
89 "Represents a display/monitor attached to the system");
90
91
92 class wxDisplay
93 {
94 public:
95 //
96 DocCtorStr(
97 wxDisplay(size_t index = 0),
98 "Set up a Display instance with the specified display. The
99 displays are numbered from 0 to GetCount() - 1, 0 is always the
100 primary display and the only one which is always supported");
101
102 virtual ~wxDisplay();
103
104 DocDeclStr(
105 static size_t , GetCount(),
106 "Return the number of available displays.");
107
108
109 DocDeclStr(
110 static int , GetFromPoint(const wxPoint& pt),
111 "Find the display where the given point lies, return wx.NOT_FOUND
112 if it doesn't belong to any display");
113
114
115 DocStr(GetFromWindow,
116 "Find the display where the given window lies, return wx.NOT_FOUND
117 if it is not shown at all.");
118 #ifdef __WXMSW__
119 static int GetFromWindow(wxWindow *window);
120 #else
121 %extend {
122 static int GetFromWindow(wxWindow *window)
123 { wxPyRaiseNotImplemented(); return wxNOT_FOUND; }
124 }
125 #endif
126
127 DocDeclStr(
128 virtual bool , IsOk() const,
129 "Return true if the object was initialized successfully");
130 %pythoncode { def __nonzero__(self): return self.IsOk() }
131
132
133 DocDeclStr(
134 virtual wxRect , GetGeometry() const,
135 "Returns the bounding rectangle of the display whose index was
136 passed to the constructor.");
137
138
139 DocDeclStr(
140 virtual wxString , GetName() const,
141 "Returns the display's name. A name is not available on all platforms.");
142
143
144 DocDeclStr(
145 bool , IsPrimary() const,
146 "Returns true if the display is the primary display. The primary
147 display is the one whose index is 0.");
148
149
150
151 %extend {
152 DocAStr(GetModes,
153 "GetModes(VideoMode mode=DefaultVideoMode) -> [videoMode...]",
154 "Enumerate all video modes supported by this display matching the
155 given one (in the sense of VideoMode.Match()).
156
157 As any mode matches the default value of the argument and there
158 is always at least one video mode supported by display, the
159 returned array is only empty for the default value of the
160 argument if this function is not supported at all on this
161 platform.");
162
163 PyObject* GetModes(const wxVideoMode& mode = wxDefaultVideoMode) {
164 PyObject* pyList = NULL;
165 wxArrayVideoModes arr = self->GetModes(mode);
166 bool blocked = wxPyBeginBlockThreads();
167 pyList = PyList_New(0);
168 for (int i=0; i < arr.GetCount(); i++) {
169 wxVideoMode* m = new wxVideoMode(arr.Item(i));
170 PyObject* pyObj = wxPyConstructObject(m, wxT("wxVideoMode"), true);
171 PyList_Append(pyList, pyObj);
172 }
173 wxPyEndBlockThreads(blocked);
174 return pyList;
175 }
176 }
177
178
179 DocDeclStr(
180 virtual wxVideoMode , GetCurrentMode() const,
181 "Get the current video mode.");
182
183
184 DocDeclStr(
185 virtual bool , ChangeMode(const wxVideoMode& mode = wxDefaultVideoMode),
186 "Change current mode, return true if succeeded, false otherwise");
187
188
189 DocDeclStr(
190 void , ResetMode(),
191 "Restore the default video mode (just a more readable synonym)");
192
193
194 };
195
196 //---------------------------------------------------------------------------