]>
Commit | Line | Data |
---|---|---|
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 | ||
14 | %module windows | |
15 | ||
16 | %{ | |
17 | #include "helpers.h" | |
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 | ||
31 | %pragma(python) code = "import wx" | |
32 | //%pragma(python) code = "import controls" | |
33 | //%pragma(python) code = "wxButtonPtr = controls.wxWindowPtr" | |
34 | ||
35 | //--------------------------------------------------------------------------- | |
36 | ||
37 | class wxEvtHandler { | |
38 | public: | |
39 | bool ProcessEvent(wxEvent& event); | |
40 | %addmethods { | |
41 | void Connect( int id, int lastId, int eventType, PyObject* func) { | |
42 | if (PyCallable_Check(func)) { | |
43 | self->Connect(id, lastId, eventType, | |
44 | (wxObjectEventFunction) &wxPyCallback::EventThunker, | |
45 | new wxPyCallback(func)); | |
46 | } | |
47 | } | |
48 | } | |
49 | }; | |
50 | ||
51 | ||
52 | //---------------------------------------------------------------------- | |
53 | ||
54 | ||
55 | class wxWindow : public wxEvtHandler { | |
56 | public: | |
57 | ||
58 | wxWindow(wxWindow* parent, const wxWindowID id, | |
59 | const wxPoint& pos = wxPyDefaultPosition, | |
60 | const wxSize& size = wxPyDefaultSize, | |
61 | long style = 0, | |
62 | char* name = "panel"); | |
63 | ||
64 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" | |
65 | ||
66 | void CaptureMouse(); | |
67 | void Center(int direction = wxHORIZONTAL); | |
68 | void Centre(int direction = wxHORIZONTAL); | |
69 | void CentreOnParent(int direction = wxHORIZONTAL ); | |
70 | void CenterOnParent(int direction = wxHORIZONTAL ); | |
71 | %name(ClientToScreenXY)void ClientToScreen(int *BOTH, int *BOTH); | |
72 | wxPoint ClientToScreen(const wxPoint& pt); | |
73 | bool Close(int force = FALSE); | |
74 | bool Destroy(); | |
75 | void DestroyChildren(); | |
76 | #ifdef __WXMSW__ | |
77 | void DragAcceptFiles(bool accept); | |
78 | #endif | |
79 | void Enable(bool enable); | |
80 | //bool FakePopupMenu(wxMenu* menu, int x, int y); | |
81 | %name(FindWindowById) wxWindow* FindWindow(long id); | |
82 | %name(FindWindowByName) wxWindow* FindWindow(const wxString& name); | |
83 | void Fit(); | |
84 | wxColour GetBackgroundColour(); | |
85 | int GetCharHeight(); | |
86 | int GetCharWidth(); | |
87 | %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT); | |
88 | wxSize GetClientSize(); | |
89 | wxLayoutConstraints * GetConstraints(); | |
90 | //wxEvtHandler* GetEventHandler(); | |
91 | ||
92 | wxFont& GetFont(); | |
93 | wxColour GetForegroundColour(); | |
94 | wxWindow * GetGrandParent(); | |
95 | int GetId(); | |
96 | wxString GetLabel(); | |
97 | void SetLabel(const wxString& label); | |
98 | wxString GetName(); | |
99 | wxWindow * GetParent(); | |
100 | %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT); | |
101 | wxPoint GetPosition(); | |
102 | wxRect GetRect(); | |
103 | int GetScrollThumb(int orientation); | |
104 | int GetScrollPos(int orientation); | |
105 | int GetScrollRange(int orientation); | |
106 | %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT); | |
107 | wxSize GetSize(); | |
108 | void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT); | |
109 | %name(GetFullTextExtent)void GetTextExtent(const wxString& string, | |
110 | int *OUTPUT, int *OUTPUT, int *OUTPUT, int* OUTPUT, | |
111 | const wxFont* font = NULL); //, bool use16 = FALSE) | |
112 | wxString GetTitle(); | |
113 | long GetWindowStyleFlag(); | |
114 | bool Hide(); | |
115 | void InitDialog(); | |
116 | bool IsEnabled(); | |
117 | bool IsRetained(); | |
118 | bool IsShown(); | |
119 | bool IsTopLevel(); | |
120 | void Layout(); | |
121 | bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL); | |
122 | void Lower(); | |
123 | void MakeModal(bool flag); | |
124 | %name(MoveXY)void Move(int x, int y); | |
125 | void Move(const wxPoint& point); | |
126 | ||
127 | //wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE); | |
128 | bool PopupMenu(wxMenu *menu, int x, int y); | |
129 | //void PushEventHandler(wxEvtHandler* handler); | |
130 | ||
131 | void Raise(); | |
132 | void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL); | |
133 | void ReleaseMouse(); | |
134 | bool Reparent( wxWindow* newParent ); | |
135 | ||
136 | %name(ScreenToClientXY)void ScreenToClient(int *BOTH, int *BOTH); | |
137 | wxPoint ScreenToClient(const wxPoint& pt); | |
138 | ||
139 | void ScrollWindow(int dx, int dy, const wxRect* rect = NULL); | |
140 | void SetAcceleratorTable(const wxAcceleratorTable& accel); | |
141 | void SetAutoLayout(bool autoLayout); | |
142 | void SetBackgroundColour(const wxColour& colour); | |
143 | void SetConstraints(wxLayoutConstraints *constraints); | |
144 | // void SetDoubleClick(bool allowDoubleClick); | |
145 | void SetFocus(); | |
146 | void SetFont(const wxFont& font); | |
147 | void SetForegroundColour(const wxColour& colour); | |
148 | void SetId(int id); | |
149 | void SetName(const wxString& name); | |
150 | void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh = TRUE); | |
151 | void SetScrollPos(int orientation, int pos, bool refresh = TRUE); | |
152 | ||
153 | %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO); | |
154 | %addmethods { | |
155 | void SetSize(const wxSize& size) { | |
156 | self->SetSize(size.x, size.y); | |
157 | } | |
158 | ||
159 | void SetPosition(const wxPoint& pos) { | |
160 | self->SetSize(pos.x, pos.y, -1, -1); | |
161 | } | |
162 | } | |
163 | ||
164 | void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1); | |
165 | %name(SetClientSizeWH)void SetClientSize(int width, int height); | |
166 | void SetClientSize(const wxSize& size); | |
167 | //void SetPalette(wxPalette* palette); | |
168 | void SetCursor(const wxCursor&cursor); | |
169 | //void SetEventHandler(wxEvtHandler* handler); | |
170 | void SetTitle(const wxString& title); | |
171 | bool Show(bool show); | |
172 | bool TransferDataFromWindow(); | |
173 | bool TransferDataToWindow(); | |
174 | bool Validate(); | |
175 | void WarpPointer(int x, int y); | |
176 | ||
177 | %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt); | |
178 | %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz); | |
179 | ||
180 | %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt); | |
181 | %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz); | |
182 | ||
183 | %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt); | |
184 | %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz); | |
185 | ||
186 | %name(SetToolTipString)void SetToolTip(const wxString &tip); | |
187 | void SetToolTip(wxToolTip *tooltip); | |
188 | wxToolTip* GetToolTip(); | |
189 | }; | |
190 | ||
191 | %pragma(python) code = " | |
192 | def wxDLG_PNT(win, point_or_x, y=None): | |
193 | if y is None: | |
194 | return win.ConvertDialogPointToPixels(point_or_x) | |
195 | else: | |
196 | return win.ConvertDialogPointToPixels(wxPoint(point_or_x, y)) | |
197 | ||
198 | def wxDLG_SZE(win, size_width, height=None): | |
199 | if height is None: | |
200 | return win.ConvertDialogSizeToPixels(size_width) | |
201 | else: | |
202 | return win.ConvertDialogSizeToPixels(wxSize(size_width, height)) | |
203 | " | |
204 | ||
205 | #ifdef __WXMSW__ | |
206 | %inline %{ | |
207 | wxWindow* wxWindow_FindFocus() { | |
208 | return wxWindow::FindFocus(); | |
209 | } | |
210 | %} | |
211 | ||
212 | ||
213 | %inline %{ | |
214 | wxWindow* wxWindow_FromHWND(unsigned long hWnd) { | |
215 | wxWindow* win = new wxWindow; | |
216 | win->SetHWND(hWnd); | |
217 | win->SubclassWin(hWnd); | |
218 | return win; | |
219 | } | |
220 | %} | |
221 | #endif | |
222 | ||
223 | ||
224 | //--------------------------------------------------------------------------- | |
225 | ||
226 | class wxPanel : public wxWindow { | |
227 | public: | |
228 | wxPanel(wxWindow* parent, | |
229 | const wxWindowID id, | |
230 | const wxPoint& pos = wxPyDefaultPosition, | |
231 | const wxSize& size = wxPyDefaultSize, | |
232 | long style = wxTAB_TRAVERSAL, | |
233 | const char* name = "panel"); | |
234 | ||
235 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" | |
236 | ||
237 | void InitDialog(); | |
238 | wxButton* GetDefaultItem(); | |
239 | void SetDefaultItem(wxButton *btn); | |
240 | ||
241 | // fix a SWIG turd... | |
242 | %pragma(python) addtoclass = " | |
243 | def GetDefaultItem(self): | |
244 | import controls | |
245 | val = windowsc.wxPanel_GetDefaultItem(self.this) | |
246 | val = controls.wxButtonPtr(val) | |
247 | return val | |
248 | " | |
249 | }; | |
250 | ||
251 | //--------------------------------------------------------------------------- | |
252 | ||
253 | class wxDialog : public wxPanel { | |
254 | public: | |
255 | wxDialog(wxWindow* parent, | |
256 | const wxWindowID id, | |
257 | const wxString& title, | |
258 | const wxPoint& pos = wxPyDefaultPosition, | |
259 | const wxSize& size = wxPyDefaultSize, | |
260 | long style = wxDEFAULT_DIALOG_STYLE, | |
261 | const char* name = "dialogBox"); | |
262 | ||
263 | %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)" | |
264 | ||
265 | void Centre(int direction = wxBOTH); | |
266 | void EndModal(int retCode); | |
267 | wxString GetTitle(); | |
268 | void Iconize(bool iconize); | |
269 | bool IsIconized(); | |
270 | void SetModal(bool flag); | |
271 | bool IsModal(); | |
272 | void SetTitle(const wxString& title); | |
273 | bool Show(bool show); | |
274 | int ShowModal(); | |
275 | ||
276 | int GetReturnCode(); | |
277 | void SetReturnCode(int retCode); | |
278 | }; | |
279 | ||
280 | //--------------------------------------------------------------------------- | |
281 | ||
282 | class wxScrolledWindow : public wxPanel { | |
283 | public: | |
284 | wxScrolledWindow(wxWindow* parent, | |
285 | const wxWindowID id = -1, | |
286 | const wxPoint& pos = wxPyDefaultPosition, | |
287 | const wxSize& size = wxPyDefaultSize, | |
288 | long style = wxHSCROLL | wxVSCROLL, | |
289 | char* name = "scrolledWindow"); | |
290 | ||
291 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" | |
292 | %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)" | |
293 | ||
294 | void EnableScrolling(bool xScrolling, bool yScrolling); | |
295 | void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT); | |
296 | void GetVirtualSize(int* OUTPUT, int* OUTPUT); | |
297 | bool IsRetained(); | |
298 | void PrepareDC(wxDC& dc); | |
299 | void Scroll(int x, int y); | |
300 | void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY, | |
301 | int noUnitsX, int noUnitsY, | |
302 | int xPos = 0, int yPos = 0); | |
303 | void ViewStart(int* OUTPUT, int* OUTPUT); | |
304 | }; | |
305 | ||
306 | //---------------------------------------------------------------------- | |
307 | ||
308 | ||
309 | class wxMenu : public wxEvtHandler { | |
310 | public: | |
311 | wxMenu(const wxString& title = wxPyEmptyStr); | |
312 | ||
313 | void Append(int id, const wxString& item, | |
314 | const wxString& helpString = wxPyEmptyStr, | |
315 | int checkable = FALSE); | |
316 | %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu, | |
317 | const wxString& helpString = wxPyEmptyStr); | |
318 | #ifndef __WXGTK__ | |
319 | %name(AppendItem)void Append(const wxMenuItem* item); | |
320 | #endif | |
321 | ||
322 | void AppendSeparator(); | |
323 | void Break(); | |
324 | void Check(int id, bool flag); | |
325 | void Enable(int id, bool enable); | |
326 | int FindItem(const wxString& itemString); | |
327 | wxString GetTitle(); | |
328 | void SetTitle(const wxString& title); | |
329 | wxMenuItem* FindItemForId(int id); | |
330 | wxString GetHelpString(int id); | |
331 | wxString GetLabel(int id); | |
332 | void SetHelpString(int id, const wxString& helpString); | |
333 | bool IsChecked(int id); | |
334 | bool IsEnabled(int id); | |
335 | void SetLabel(int id, const wxString& label); | |
336 | }; | |
337 | ||
338 | ||
339 | // | |
340 | // This one knows how to set a callback and handle INC- and DECREFing it. To | |
341 | // be used for PopupMenus, but you must retain a referece to it while using | |
342 | // it. | |
343 | // | |
344 | class wxPyMenu : public wxMenu { | |
345 | public: | |
346 | wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL); | |
347 | ~wxPyMenu(); | |
348 | }; | |
349 | ||
350 | //---------------------------------------------------------------------- | |
351 | ||
352 | class wxMenuBar : public wxEvtHandler { | |
353 | public: | |
354 | wxMenuBar(); | |
355 | ||
356 | void Append(wxMenu *menu, const wxString& title); | |
357 | void Check(int id, bool flag); | |
358 | bool Checked(int id); | |
359 | void Enable(int id, bool enable); | |
360 | bool Enabled(int id); | |
361 | int FindMenuItem(const wxString& menuString, const wxString& itemString); | |
362 | wxMenuItem * FindItemForId(int id); | |
363 | #ifdef __WXMSW__ | |
364 | void EnableTop(int pos, bool enable); | |
365 | wxString GetHelpString(int id); | |
366 | wxString GetLabel(int id); | |
367 | void SetHelpString(int id, const wxString& helpString); | |
368 | void SetLabel(int id, const wxString& label); | |
369 | wxString GetLabelTop(int pos); | |
370 | void SetLabelTop(int pos, const wxString& label); | |
371 | #endif | |
372 | int GetMenuCount(); | |
373 | wxMenu* GetMenu(int i); | |
374 | }; | |
375 | ||
376 | ||
377 | //---------------------------------------------------------------------- | |
378 | ||
379 | class wxMenuItem { | |
380 | public: | |
381 | #ifndef __WXGTK__ | |
382 | wxMenuItem(wxMenu* parentMenu=NULL, int id=ID_SEPARATOR, | |
383 | const wxString& text = wxPyEmptyStr, | |
384 | const wxString& helpString = wxPyEmptyStr, | |
385 | bool checkable = FALSE, wxMenu* subMenu = NULL); | |
386 | #else | |
387 | wxMenuItem(); | |
388 | #endif | |
389 | ||
390 | bool IsSeparator(); | |
391 | bool IsEnabled(); | |
392 | bool IsChecked(); | |
393 | bool IsCheckable(); | |
394 | int GetId(); | |
395 | wxMenu* GetSubMenu(); | |
396 | void SetName(const wxString& strName); | |
397 | wxString GetName(); | |
398 | wxString GetHelp(); | |
399 | void SetHelp(const wxString& strHelp); | |
400 | void Enable(bool bDoEnable = TRUE); | |
401 | void Check(bool bDoCheck = TRUE); | |
402 | ||
403 | #ifdef __WXMSW__ | |
404 | wxColour& GetBackgroundColour(); | |
405 | wxBitmap GetBitmap(bool checked = TRUE); | |
406 | wxFont& GetFont(); | |
407 | int GetMarginWidth(); | |
408 | wxColour& GetTextColour(); | |
409 | void SetBackgroundColour(const wxColour& colour); | |
410 | void SetBitmaps(const wxBitmap& checked, const wxBitmap& unchecked = wxNullBitmap); | |
411 | void SetFont(const wxFont& font); | |
412 | void SetMarginWidth(int width); | |
413 | void SetTextColour(const wxColour& colour); | |
414 | void DeleteSubMenu(); | |
415 | #endif | |
416 | }; | |
417 | ||
418 | //--------------------------------------------------------------------------- | |
419 | ///////////////////////////////////////////////////////////////////////////// | |
420 | // | |
421 | // $Log$ | |
422 | // Revision 1.17 1999/06/22 07:03:03 RD | |
423 | // wxPython 2.1b1 for wxMSW (wxGTK coming soon) | |
424 | // Lots of changes, see the README.txt for details... | |
425 | // | |
426 | // Revision 1.16 1999/05/15 00:56:04 RD | |
427 | // | |
428 | // fixes for GetReturnCode/SetReturnCode | |
429 | // | |
430 | // Revision 1.15 1999/04/30 03:29:19 RD | |
431 | // | |
432 | // wxPython 2.0b9, first phase (win32) | |
433 | // Added gobs of stuff, see wxPython/README.txt for details | |
434 | // | |
435 | // Revision 1.14.4.3 1999/03/27 23:29:15 RD | |
436 | // | |
437 | // wxPython 2.0b8 | |
438 | // Python thread support | |
439 | // various minor additions | |
440 | // various minor fixes | |
441 | // | |
442 | // Revision 1.14.4.2 1999/03/16 06:26:29 RD | |
443 | // | |
444 | // wxPython 2.0b7 | |
445 | // | |
446 | // Revision 1.14.4.1 1999/03/16 06:04:04 RD | |
447 | // | |
448 | // wxPython 2.0b7 | |
449 | // | |
450 | // Revision 1.14 1999/02/23 23:48:33 RD | |
451 | // | |
452 | // reenabled some methods for wxPython on wxGTK | |
453 | // | |
454 | // Revision 1.13 1999/02/20 10:02:38 RD | |
455 | // | |
456 | // Changes needed to enable wxGTK compatibility. | |
457 | // | |
458 | // Revision 1.12 1999/02/20 09:03:03 RD | |
459 | // Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a | |
460 | // window handle. If you can get the window handle into the python code, | |
461 | // it should just work... More news on this later. | |
462 | // | |
463 | // Added wxImageList, wxToolTip. | |
464 | // | |
465 | // Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the | |
466 | // wxRegConfig class. | |
467 | // | |
468 | // As usual, some bug fixes, tweaks, etc. | |
469 | // | |
470 | // Revision 1.11 1998/12/18 15:49:10 RR | |
471 | // | |
472 | // wxClipboard now serves the primary selection as well | |
473 | // wxPython fixes | |
474 | // warning mesages | |
475 | // | |
476 | // Revision 1.10 1998/12/17 17:52:20 RD | |
477 | // | |
478 | // wxPython 0.5.2 | |
479 | // Minor fixes and SWIG code generation for RR's changes. MSW and GTK | |
480 | // versions are much closer now! | |
481 | // | |
482 | // Revision 1.9 1998/12/17 14:07:46 RR | |
483 | // | |
484 | // Removed minor differences between wxMSW and wxGTK | |
485 | // | |
486 | // Revision 1.8 1998/12/16 22:10:56 RD | |
487 | // | |
488 | // Tweaks needed to be able to build wxPython with wxGTK. | |
489 | // | |
490 | // Revision 1.7 1998/12/15 20:41:25 RD | |
491 | // Changed the import semantics from "from wxPython import *" to "from | |
492 | // wxPython.wx import *" This is for people who are worried about | |
493 | // namespace pollution, they can use "from wxPython import wx" and then | |
494 | // prefix all the wxPython identifiers with "wx." | |
495 | // | |
496 | // Added wxTaskbarIcon for wxMSW. | |
497 | // | |
498 | // Made the events work for wxGrid. | |
499 | // | |
500 | // Added wxConfig. | |
501 | // | |
502 | // Added wxMiniFrame for wxGTK, (untested.) | |
503 | // | |
504 | // Changed many of the args and return values that were pointers to gdi | |
505 | // objects to references to reflect changes in the wxWindows API. | |
506 | // | |
507 | // Other assorted fixes and additions. | |
508 | // | |
509 | // Revision 1.6 1998/10/02 06:40:43 RD | |
510 | // | |
511 | // Version 0.4 of wxPython for MSW. | |
512 | // | |
513 | // Revision 1.5 1998/08/17 18:29:40 RD | |
514 | // Removed an extra method definition | |
515 | // | |
516 | // Revision 1.4 1998/08/16 04:31:11 RD | |
517 | // More wxGTK work. | |
518 | // | |
519 | // Revision 1.3 1998/08/15 07:36:47 RD | |
520 | // - Moved the header in the .i files out of the code that gets put into | |
521 | // the .cpp files. It caused CVS conflicts because of the RCS ID being | |
522 | // different each time. | |
523 | // | |
524 | // - A few minor fixes. | |
525 | // | |
526 | // Revision 1.2 1998/08/14 23:36:46 RD | |
527 | // Beginings of wxGTK compatibility | |
528 | // | |
529 | // Revision 1.1 1998/08/09 08:25:52 RD | |
530 | // Initial version | |
531 | // | |
532 | // | |
533 | ||
534 |