]>
Commit | Line | Data |
---|---|---|
7bf85405 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: windows.i | |
3 | // Purpose: SWIG definitions of various window classes | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 6/24/97 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 1998 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | ||
03e9bead RD |
14 | %module windows |
15 | ||
16 | %{ | |
7bf85405 | 17 | #include "helpers.h" |
7bf85405 RD |
18 | #include <wx/menuitem.h> |
19 | %} | |
20 | ||
21 | //---------------------------------------------------------------------- | |
22 | ||
23 | %include typemaps.i | |
24 | %include my_typemaps.i | |
25 | ||
26 | // Import some definitions of other classes, etc. | |
27 | %import _defs.i | |
28 | %import misc.i | |
29 | %import gdi.i | |
30 | ||
b8b8dda7 | 31 | %pragma(python) code = "import wx" |
7bf85405 RD |
32 | |
33 | //--------------------------------------------------------------------------- | |
34 | ||
35 | class wxEvtHandler { | |
36 | public: | |
37 | %addmethods { | |
38 | void Connect( int id, int lastId, int eventType, PyObject* func) { | |
39 | if (PyCallable_Check(func)) { | |
40 | self->Connect(id, lastId, eventType, | |
853b255a | 41 | (wxObjectEventFunction) &wxPyCallback::EventThunker, |
7bf85405 RD |
42 | new wxPyCallback(func)); |
43 | } | |
44 | } | |
45 | } | |
46 | }; | |
47 | ||
48 | ||
49 | //---------------------------------------------------------------------- | |
50 | ||
51 | ||
52 | class wxWindow : public wxEvtHandler { | |
53 | public: | |
54 | ||
55 | wxWindow(wxWindow* parent, const wxWindowID id, | |
56 | const wxPoint& pos = wxPyDefaultPosition, | |
57 | const wxSize& size = wxPyDefaultSize, | |
58 | long style = 0, | |
59 | char* name = "panel"); | |
60 | ||
b8b8dda7 | 61 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
7bf85405 RD |
62 | |
63 | void CaptureMouse(); | |
714e6a9e | 64 | void Center(int direction = wxHORIZONTAL); |
7bf85405 RD |
65 | void Centre(int direction = wxHORIZONTAL); |
66 | void ClientToScreen(int *BOTH, int *BOTH); | |
67 | bool Close(int force = FALSE); | |
68 | bool Destroy(); | |
69 | void DestroyChildren(); | |
853b255a | 70 | #ifdef __WXMSW__ |
7bf85405 | 71 | void DragAcceptFiles(bool accept); |
853b255a | 72 | #endif |
7bf85405 RD |
73 | void Enable(bool enable); |
74 | //bool FakePopupMenu(wxMenu* menu, int x, int y); | |
714e6a9e RD |
75 | %name(FindWindowByID) wxWindow* FindWindow(long id); |
76 | %name(FindWindowByName) wxWindow* FindWindow(const wxString& name); | |
7bf85405 RD |
77 | void Fit(); |
78 | wxColour GetBackgroundColour(); | |
79 | int GetCharHeight(); | |
80 | int GetCharWidth(); | |
b8b8dda7 RD |
81 | %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT); |
82 | wxSize GetClientSize(); | |
7bf85405 | 83 | wxLayoutConstraints * GetConstraints(); |
853b255a | 84 | #ifdef __WXMSW__ |
7bf85405 | 85 | wxButton* GetDefaultItem(); |
853b255a | 86 | #endif |
7bf85405 | 87 | //wxEvtHandler* GetEventHandler(); |
105e45b9 | 88 | |
b8b8dda7 | 89 | wxFont& GetFont(); |
7bf85405 RD |
90 | wxColour GetForegroundColour(); |
91 | wxWindow * GetGrandParent(); | |
92 | int GetId(); | |
853b255a RD |
93 | wxString GetLabel(); |
94 | wxString GetName(); | |
7bf85405 | 95 | wxWindow * GetParent(); |
b8b8dda7 RD |
96 | %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT); |
97 | wxPoint GetPosition(); | |
98 | wxRect GetRect(); | |
7bf85405 RD |
99 | int GetReturnCode(); |
100 | int GetScrollThumb(int orientation); | |
101 | int GetScrollPos(int orientation); | |
102 | int GetScrollRange(int orientation); | |
b8b8dda7 RD |
103 | %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT); |
104 | wxSize GetSize(); | |
7bf85405 | 105 | void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT); // int* descent = NULL, int* externalLeading = NULL, const wxFont* font = NULL, bool use16 = FALSE) |
853b255a | 106 | wxString GetTitle(); |
7bf85405 RD |
107 | long GetWindowStyleFlag(); |
108 | void InitDialog(); | |
109 | bool IsEnabled(); | |
110 | bool IsRetained(); | |
111 | bool IsShown(); | |
112 | void Layout(); | |
113 | bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL); | |
114 | void Lower(); | |
115 | void MakeModal(bool flag); | |
116 | void Move(int x, int y); | |
117 | ||
118 | //wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE); | |
119 | bool PopupMenu(wxMenu *menu, int x, int y); | |
120 | //void PushEventHandler(wxEvtHandler* handler); | |
121 | ||
122 | void Raise(); | |
123 | void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL); | |
124 | void ReleaseMouse(); | |
125 | void ScreenToClient(int *BOTH, int *BOTH); | |
126 | void ScrollWindow(int dx, int dy, const wxRect* rect = NULL); | |
b8b8dda7 | 127 | void SetAcceleratorTable(const wxAcceleratorTable& accel); |
7bf85405 RD |
128 | void SetAutoLayout(bool autoLayout); |
129 | void SetBackgroundColour(const wxColour& colour); | |
130 | void SetConstraints(wxLayoutConstraints *constraints); | |
131 | void SetDoubleClick(bool allowDoubleClick); | |
132 | void SetFocus(); | |
133 | void SetFont(const wxFont& font); | |
134 | void SetForegroundColour(const wxColour& colour); | |
135 | void SetId(int id); | |
136 | void SetName(const wxString& name); | |
137 | void SetReturnCode(int retCode); | |
138 | void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh = TRUE); | |
139 | void SetScrollPos(int orientation, int pos, bool refresh = TRUE); | |
140 | ||
141 | //void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO); | |
142 | //%name(SetSizeOnly) void SetSize(int width, int height); | |
143 | ||
144 | %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO); | |
145 | %addmethods { | |
146 | void SetSize(const wxSize& size) { | |
147 | self->SetSize(size.x, size.y); | |
148 | } | |
149 | ||
150 | void SetPosition(const wxPoint& pos) { | |
151 | self->SetSize(pos.x, pos.y, -1, -1); | |
152 | } | |
153 | } | |
154 | ||
155 | void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1); | |
156 | void SetClientSize(int width, int height); | |
157 | //void SetPalette(wxPalette* palette); | |
7bf85405 RD |
158 | void SetCursor(const wxCursor&cursor); |
159 | //void SetEventHandler(wxEvtHandler* handler); | |
160 | void SetTitle(const wxString& title); | |
161 | bool Show(bool show); | |
162 | bool TransferDataFromWindow(); | |
163 | bool TransferDataToWindow(); | |
164 | bool Validate(); | |
165 | void WarpPointer(int x, int y); | |
166 | ||
b8b8dda7 RD |
167 | %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt); |
168 | %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz); | |
169 | ||
170 | %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt); | |
171 | %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz); | |
172 | ||
7bf85405 RD |
173 | }; |
174 | ||
b8b8dda7 RD |
175 | %pragma(python) code = " |
176 | def wxDLG_PNT(win, point): | |
177 | return win.ConvertDialogPointToPixels(point) | |
178 | ||
179 | def wxDLG_SZE(win, size): | |
180 | return win.ConvertDialogPointToPixels(size) | |
181 | " | |
7bf85405 RD |
182 | |
183 | // Static method(s) | |
853b255a | 184 | #ifdef __WXMSW__ |
7bf85405 RD |
185 | %inline %{ |
186 | wxWindow* wxWindow_FindFocus() { | |
187 | return wxWindow::FindFocus(); | |
188 | } | |
189 | %} | |
853b255a | 190 | #endif |
7bf85405 | 191 | |
7bf85405 RD |
192 | |
193 | //--------------------------------------------------------------------------- | |
194 | ||
195 | class wxPanel : public wxWindow { | |
196 | public: | |
197 | wxPanel(wxWindow* parent, | |
198 | const wxWindowID id, | |
199 | const wxPoint& pos = wxPyDefaultPosition, | |
200 | const wxSize& size = wxPyDefaultSize, | |
201 | long style = wxTAB_TRAVERSAL, | |
202 | const char* name = "panel"); | |
203 | ||
b8b8dda7 | 204 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
9c039d08 | 205 | |
7bf85405 RD |
206 | void InitDialog(); |
207 | }; | |
208 | ||
209 | //--------------------------------------------------------------------------- | |
210 | ||
211 | class wxDialog : public wxPanel { | |
212 | public: | |
213 | wxDialog(wxWindow* parent, | |
214 | const wxWindowID id, | |
215 | const wxString& title, | |
216 | const wxPoint& pos = wxPyDefaultPosition, | |
217 | const wxSize& size = wxPyDefaultSize, | |
218 | long style = wxDEFAULT_DIALOG_STYLE, | |
219 | const char* name = "dialogBox"); | |
220 | ||
b8b8dda7 | 221 | %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)" |
9c039d08 | 222 | |
7bf85405 RD |
223 | void Centre(int direction = wxBOTH); |
224 | void EndModal(int retCode); | |
225 | wxString GetTitle(); | |
226 | void Iconize(bool iconize); | |
227 | bool IsIconized(); | |
7bf85405 | 228 | void SetModal(bool flag); |
853b255a | 229 | bool IsModal(); |
7bf85405 RD |
230 | void SetTitle(const wxString& title); |
231 | bool Show(bool show); | |
232 | int ShowModal(); | |
233 | }; | |
234 | ||
235 | //--------------------------------------------------------------------------- | |
236 | ||
237 | class wxScrolledWindow : public wxWindow { | |
238 | public: | |
239 | wxScrolledWindow(wxWindow* parent, | |
240 | const wxWindowID id = -1, | |
241 | const wxPoint& pos = wxPyDefaultPosition, | |
242 | const wxSize& size = wxPyDefaultSize, | |
243 | long style = wxHSCROLL | wxVSCROLL, | |
244 | char* name = "scrolledWindow"); | |
245 | ||
b8b8dda7 RD |
246 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
247 | %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)" | |
9c039d08 | 248 | |
7bf85405 RD |
249 | void EnableScrolling(bool xScrolling, bool yScrolling); |
250 | void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT); | |
251 | void GetVirtualSize(int* OUTPUT, int* OUTPUT); | |
252 | bool IsRetained(); | |
253 | void PrepareDC(wxDC& dc); | |
254 | void Scroll(int x, int y); | |
255 | void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY, | |
256 | int noUnitsX, int noUnitsY, | |
257 | int xPos = 0, int yPos = 0); | |
258 | void ViewStart(int* OUTPUT, int* OUTPUT); | |
259 | }; | |
260 | ||
261 | //---------------------------------------------------------------------- | |
262 | ||
263 | ||
264 | class wxMenu : public wxEvtHandler { | |
265 | public: | |
266 | wxMenu(const wxString& title = wxPyEmptyStr); | |
267 | ||
268 | void Append(int id, const wxString& item, | |
269 | const wxString& helpString = wxPyEmptyStr, | |
270 | int checkable = FALSE); | |
271 | %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu, | |
272 | const wxString& helpString = wxPyEmptyStr); | |
273 | void AppendSeparator(); | |
274 | void Break(); | |
275 | void Check(int id, bool flag); | |
7bf85405 RD |
276 | void Enable(int id, bool enable); |
277 | int FindItem(const wxString& itemString); | |
7bf85405 | 278 | wxString GetTitle(); |
7bf85405 | 279 | void SetTitle(const wxString& title); |
714e6a9e RD |
280 | wxMenuItem* FindItemForId(int id); |
281 | wxString GetHelpString(int id); | |
282 | wxString GetLabel(int id); | |
283 | void SetHelpString(int id, const wxString& helpString); | |
853b255a RD |
284 | bool IsChecked(int id); |
285 | bool IsEnabled(int id); | |
286 | void SetLabel(int id, const wxString& label); | |
7bf85405 RD |
287 | }; |
288 | ||
289 | ||
7bf85405 RD |
290 | // |
291 | // This one knows how to set a callback and handle INC- and DECREFing it. To | |
292 | // be used for PopupMenus, but you must retain a referece to it while using | |
293 | // it. | |
294 | // | |
295 | class wxPyMenu : public wxMenu { | |
296 | public: | |
297 | wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL); | |
298 | ~wxPyMenu(); | |
299 | }; | |
300 | ||
301 | //---------------------------------------------------------------------- | |
302 | ||
303 | class wxMenuBar : public wxEvtHandler { | |
304 | public: | |
305 | wxMenuBar(); | |
306 | ||
307 | void Append(wxMenu *menu, const wxString& title); | |
308 | void Check(int id, bool flag); | |
309 | bool Checked(int id); | |
310 | void Enable(int id, bool enable); | |
714e6a9e | 311 | bool Enabled(int id); |
7bf85405 | 312 | int FindMenuItem(const wxString& menuString, const wxString& itemString); |
c95e68d8 | 313 | wxMenuItem * FindItemForId(int id); |
aeeb6a44 | 314 | #ifdef __WXMSW__ |
714e6a9e | 315 | void EnableTop(int pos, bool enable); |
7bf85405 RD |
316 | wxString GetHelpString(int id); |
317 | wxString GetLabel(int id); | |
7bf85405 RD |
318 | void SetHelpString(int id, const wxString& helpString); |
319 | void SetLabel(int id, const wxString& label); | |
853b255a | 320 | wxString GetLabelTop(int pos); |
7bf85405 | 321 | void SetLabelTop(int pos, const wxString& label); |
853b255a | 322 | #endif |
714e6a9e RD |
323 | int GetMenuCount(); |
324 | wxMenu* GetMenu(int i); | |
7bf85405 RD |
325 | }; |
326 | ||
327 | ||
328 | //---------------------------------------------------------------------- | |
329 | ||
330 | class wxMenuItem { | |
331 | public: | |
332 | bool IsSeparator(); | |
333 | bool IsEnabled(); | |
334 | bool IsChecked(); | |
714e6a9e | 335 | bool IsCheckable(); |
7bf85405 | 336 | int GetId(); |
7bf85405 RD |
337 | wxMenu* GetSubMenu(); |
338 | void SetName(const wxString& strName); | |
7bf85405 | 339 | const wxString& GetName(); |
714e6a9e RD |
340 | const wxString& GetHelp(); |
341 | void SetHelp(const wxString& strHelp); | |
342 | void Enable(bool bDoEnable = TRUE); | |
343 | void Check(bool bDoCheck = TRUE); | |
c95e68d8 | 344 | |
4f22cf8d RR |
345 | #ifdef __WXMSW__ |
346 | void DeleteSubMenu(); | |
347 | #endif | |
7bf85405 RD |
348 | }; |
349 | ||
350 | //--------------------------------------------------------------------------- | |
351 | ///////////////////////////////////////////////////////////////////////////// | |
352 | // | |
353 | // $Log$ | |
aeeb6a44 RR |
354 | // Revision 1.11 1998/12/18 15:49:10 RR |
355 | // wxClipboard now serves the primary selection as well | |
356 | // wxPython fixes | |
357 | // warning mesages | |
358 | // | |
c95e68d8 | 359 | // Revision 1.10 1998/12/17 17:52:20 RD |
aeeb6a44 | 360 | // |
c95e68d8 RD |
361 | // wxPython 0.5.2 |
362 | // Minor fixes and SWIG code generation for RR's changes. MSW and GTK | |
363 | // versions are much closer now! | |
364 | // | |
4f22cf8d | 365 | // Revision 1.9 1998/12/17 14:07:46 RR |
c95e68d8 | 366 | // |
4f22cf8d RR |
367 | // Removed minor differences between wxMSW and wxGTK |
368 | // | |
105e45b9 | 369 | // Revision 1.8 1998/12/16 22:10:56 RD |
4f22cf8d | 370 | // |
105e45b9 RD |
371 | // Tweaks needed to be able to build wxPython with wxGTK. |
372 | // | |
b8b8dda7 RD |
373 | // Revision 1.7 1998/12/15 20:41:25 RD |
374 | // Changed the import semantics from "from wxPython import *" to "from | |
375 | // wxPython.wx import *" This is for people who are worried about | |
376 | // namespace pollution, they can use "from wxPython import wx" and then | |
377 | // prefix all the wxPython identifiers with "wx." | |
378 | // | |
379 | // Added wxTaskbarIcon for wxMSW. | |
380 | // | |
381 | // Made the events work for wxGrid. | |
382 | // | |
383 | // Added wxConfig. | |
384 | // | |
385 | // Added wxMiniFrame for wxGTK, (untested.) | |
386 | // | |
387 | // Changed many of the args and return values that were pointers to gdi | |
388 | // objects to references to reflect changes in the wxWindows API. | |
389 | // | |
390 | // Other assorted fixes and additions. | |
391 | // | |
9c039d08 | 392 | // Revision 1.6 1998/10/02 06:40:43 RD |
b8b8dda7 | 393 | // |
9c039d08 RD |
394 | // Version 0.4 of wxPython for MSW. |
395 | // | |
652e7bb4 RD |
396 | // Revision 1.5 1998/08/17 18:29:40 RD |
397 | // Removed an extra method definition | |
398 | // | |
714e6a9e RD |
399 | // Revision 1.4 1998/08/16 04:31:11 RD |
400 | // More wxGTK work. | |
401 | // | |
03e9bead RD |
402 | // Revision 1.3 1998/08/15 07:36:47 RD |
403 | // - Moved the header in the .i files out of the code that gets put into | |
404 | // the .cpp files. It caused CVS conflicts because of the RCS ID being | |
405 | // different each time. | |
406 | // | |
407 | // - A few minor fixes. | |
408 | // | |
853b255a RD |
409 | // Revision 1.2 1998/08/14 23:36:46 RD |
410 | // Beginings of wxGTK compatibility | |
411 | // | |
7bf85405 RD |
412 | // Revision 1.1 1998/08/09 08:25:52 RD |
413 | // Initial version | |
414 | // | |
415 | // | |
416 | ||
417 |