]>
Commit | Line | Data |
---|---|---|
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 | %{ | |
19 | #include "wx/display.h" | |
20 | %} | |
21 | ||
22 | ||
23 | //--------------------------------------------------------------------------- | |
24 | %newgroup | |
25 | ||
26 | ||
27 | DocStr(wxVideoMode, | |
d07d2bc9 | 28 | "A simple struct containing video mode parameters for a display", ""); |
96d37ab5 RD |
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, | |
d07d2bc9 RD |
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)", ""); | |
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 | 48 | unspecified", ""); |
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 |
53 | means 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 { | |
64 | bool __eq__(const wxVideoMode* other) { return other ? (*self == *other) : False; } | |
65 | bool __ne__(const wxVideoMode* other) { return other ? (*self != *other) : True; } | |
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; | |
81 | const wxVideoMode wxDefaultVideoMode; | |
82 | %mutable; | |
83 | ||
84 | ||
85 | //--------------------------------------------------------------------------- | |
86 | ||
87 | DocStr(wxDisplay, | |
d07d2bc9 | 88 | "Represents a display/monitor attached to the system", ""); |
96d37ab5 RD |
89 | |
90 | ||
91 | class wxDisplay | |
92 | { | |
93 | public: | |
94 | // | |
95 | DocCtorStr( | |
96 | wxDisplay(size_t index = 0), | |
d07d2bc9 RD |
97 | "Set up a Display instance with the specified display. The displays |
98 | are numbered from 0 to GetCount() - 1, 0 is always the primary display | |
99 | and the only one which is always supported", ""); | |
96d37ab5 RD |
100 | |
101 | virtual ~wxDisplay(); | |
102 | ||
103 | DocDeclStr( | |
104 | static size_t , GetCount(), | |
d07d2bc9 | 105 | "Return the number of available displays.", ""); |
96d37ab5 RD |
106 | |
107 | ||
108 | DocDeclStr( | |
109 | static int , GetFromPoint(const wxPoint& pt), | |
d07d2bc9 RD |
110 | "Find the display where the given point lies, return wx.NOT_FOUND if it |
111 | doesn't belong to any display", ""); | |
96d37ab5 RD |
112 | |
113 | ||
114 | DocStr(GetFromWindow, | |
d07d2bc9 RD |
115 | "Find the display where the given window lies, return wx.NOT_FOUND if |
116 | it is not shown at all.", ""); | |
96d37ab5 RD |
117 | #ifdef __WXMSW__ |
118 | static int GetFromWindow(wxWindow *window); | |
119 | #else | |
120 | %extend { | |
121 | static int GetFromWindow(wxWindow *window) | |
122 | { wxPyRaiseNotImplemented(); return wxNOT_FOUND; } | |
123 | } | |
124 | #endif | |
125 | ||
126 | DocDeclStr( | |
127 | virtual bool , IsOk() const, | |
d07d2bc9 | 128 | "Return true if the object was initialized successfully", ""); |
96d37ab5 RD |
129 | %pythoncode { def __nonzero__(self): return self.IsOk() } |
130 | ||
131 | ||
132 | DocDeclStr( | |
133 | virtual wxRect , GetGeometry() const, | |
d07d2bc9 RD |
134 | "Returns the bounding rectangle of the display whose index was passed |
135 | to the constructor.", ""); | |
96d37ab5 RD |
136 | |
137 | ||
138 | DocDeclStr( | |
139 | virtual wxString , GetName() const, | |
d07d2bc9 | 140 | "Returns the display's name. A name is not available on all platforms.", ""); |
96d37ab5 RD |
141 | |
142 | ||
143 | DocDeclStr( | |
144 | bool , IsPrimary() const, | |
145 | "Returns true if the display is the primary display. The primary | |
d07d2bc9 | 146 | display is the one whose index is 0.", ""); |
96d37ab5 RD |
147 | |
148 | ||
149 | ||
150 | %extend { | |
151 | DocAStr(GetModes, | |
152 | "GetModes(VideoMode mode=DefaultVideoMode) -> [videoMode...]", | |
d07d2bc9 RD |
153 | "Enumerate all video modes supported by this display matching the given |
154 | one (in the sense of VideoMode.Match()). | |
155 | ||
156 | As any mode matches the default value of the argument and there is | |
157 | always at least one video mode supported by display, the returned | |
158 | array is only empty for the default value of the argument if this | |
159 | function is not supported at all on this platform.", ""); | |
96d37ab5 RD |
160 | |
161 | PyObject* GetModes(const wxVideoMode& mode = wxDefaultVideoMode) { | |
162 | PyObject* pyList = NULL; | |
163 | wxArrayVideoModes arr = self->GetModes(mode); | |
da32eb53 | 164 | bool blocked = wxPyBeginBlockThreads(); |
96d37ab5 RD |
165 | pyList = PyList_New(0); |
166 | for (int i=0; i < arr.GetCount(); i++) { | |
167 | wxVideoMode* m = new wxVideoMode(arr.Item(i)); | |
168 | PyObject* pyObj = wxPyConstructObject(m, wxT("wxVideoMode"), true); | |
169 | PyList_Append(pyList, pyObj); | |
ad411ab2 | 170 | Py_DECREF(pyObj); |
96d37ab5 | 171 | } |
da32eb53 | 172 | wxPyEndBlockThreads(blocked); |
96d37ab5 RD |
173 | return pyList; |
174 | } | |
175 | } | |
176 | ||
177 | ||
178 | DocDeclStr( | |
179 | virtual wxVideoMode , GetCurrentMode() const, | |
d07d2bc9 | 180 | "Get the current video mode.", ""); |
96d37ab5 RD |
181 | |
182 | ||
183 | DocDeclStr( | |
184 | virtual bool , ChangeMode(const wxVideoMode& mode = wxDefaultVideoMode), | |
d07d2bc9 | 185 | "Change current mode, return true if succeeded, false otherwise", ""); |
96d37ab5 RD |
186 | |
187 | ||
188 | DocDeclStr( | |
189 | void , ResetMode(), | |
d07d2bc9 | 190 | "Restore the default video mode (just a more readable synonym)", ""); |
96d37ab5 RD |
191 | |
192 | ||
193 | }; | |
194 | ||
195 | //--------------------------------------------------------------------------- |