]>
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 | 65 | void Centre(int direction = wxHORIZONTAL); |
af309447 | 66 | %name(ClientToScreenXY)void ClientToScreen(int *BOTH, int *BOTH); |
b57bdb5a | 67 | #ifndef __WXGTK__ |
af309447 | 68 | wxPoint ClientToScreen(const wxPoint& pt); |
b57bdb5a | 69 | #endif |
7bf85405 RD |
70 | bool Close(int force = FALSE); |
71 | bool Destroy(); | |
72 | void DestroyChildren(); | |
853b255a | 73 | #ifdef __WXMSW__ |
7bf85405 | 74 | void DragAcceptFiles(bool accept); |
853b255a | 75 | #endif |
7bf85405 RD |
76 | void Enable(bool enable); |
77 | //bool FakePopupMenu(wxMenu* menu, int x, int y); | |
af309447 | 78 | %name(FindWindowById) wxWindow* FindWindow(long id); |
714e6a9e | 79 | %name(FindWindowByName) wxWindow* FindWindow(const wxString& name); |
7bf85405 RD |
80 | void Fit(); |
81 | wxColour GetBackgroundColour(); | |
82 | int GetCharHeight(); | |
83 | int GetCharWidth(); | |
b8b8dda7 RD |
84 | %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT); |
85 | wxSize GetClientSize(); | |
7bf85405 | 86 | wxLayoutConstraints * GetConstraints(); |
853b255a | 87 | #ifdef __WXMSW__ |
7bf85405 | 88 | wxButton* GetDefaultItem(); |
853b255a | 89 | #endif |
7bf85405 | 90 | //wxEvtHandler* GetEventHandler(); |
105e45b9 | 91 | |
b8b8dda7 | 92 | wxFont& GetFont(); |
7bf85405 RD |
93 | wxColour GetForegroundColour(); |
94 | wxWindow * GetGrandParent(); | |
95 | int GetId(); | |
853b255a RD |
96 | wxString GetLabel(); |
97 | wxString GetName(); | |
7bf85405 | 98 | wxWindow * GetParent(); |
b8b8dda7 RD |
99 | %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT); |
100 | wxPoint GetPosition(); | |
101 | wxRect GetRect(); | |
7bf85405 RD |
102 | int GetReturnCode(); |
103 | int GetScrollThumb(int orientation); | |
104 | int GetScrollPos(int orientation); | |
105 | int GetScrollRange(int orientation); | |
b8b8dda7 RD |
106 | %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT); |
107 | wxSize GetSize(); | |
af309447 RD |
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) | |
853b255a | 112 | wxString GetTitle(); |
7bf85405 RD |
113 | long GetWindowStyleFlag(); |
114 | void InitDialog(); | |
115 | bool IsEnabled(); | |
116 | bool IsRetained(); | |
117 | bool IsShown(); | |
118 | void Layout(); | |
119 | bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL); | |
120 | void Lower(); | |
121 | void MakeModal(bool flag); | |
af309447 | 122 | %name(MoveXY)void Move(int x, int y); |
b57bdb5a | 123 | #ifndef __WXGTK__ |
af309447 | 124 | void Move(const wxPoint& point); |
b57bdb5a | 125 | #endif |
7bf85405 RD |
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(); | |
af309447 | 134 | %name(ScreenToClientXY)void ScreenToClient(int *BOTH, int *BOTH); |
b57bdb5a | 135 | #ifndef __WXGTK__ |
af309447 | 136 | wxPoint ScreenToClient(const wxPoint& pt); |
b57bdb5a | 137 | #endif |
af309447 | 138 | |
7bf85405 | 139 | void ScrollWindow(int dx, int dy, const wxRect* rect = NULL); |
b8b8dda7 | 140 | void SetAcceleratorTable(const wxAcceleratorTable& accel); |
7bf85405 RD |
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 SetReturnCode(int retCode); | |
151 | void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh = TRUE); | |
152 | void SetScrollPos(int orientation, int pos, bool refresh = TRUE); | |
153 | ||
7bf85405 RD |
154 | %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO); |
155 | %addmethods { | |
156 | void SetSize(const wxSize& size) { | |
157 | self->SetSize(size.x, size.y); | |
158 | } | |
159 | ||
160 | void SetPosition(const wxPoint& pos) { | |
161 | self->SetSize(pos.x, pos.y, -1, -1); | |
162 | } | |
163 | } | |
164 | ||
165 | void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1); | |
af309447 | 166 | %name(SetClientSizeWH)void SetClientSize(int width, int height); |
b57bdb5a | 167 | #ifndef __WXGTK__ |
af309447 | 168 | void SetClientSize(const wxSize& size); |
b57bdb5a | 169 | #endif |
7bf85405 | 170 | //void SetPalette(wxPalette* palette); |
7bf85405 RD |
171 | void SetCursor(const wxCursor&cursor); |
172 | //void SetEventHandler(wxEvtHandler* handler); | |
173 | void SetTitle(const wxString& title); | |
174 | bool Show(bool show); | |
175 | bool TransferDataFromWindow(); | |
176 | bool TransferDataToWindow(); | |
177 | bool Validate(); | |
178 | void WarpPointer(int x, int y); | |
179 | ||
b8b8dda7 RD |
180 | %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt); |
181 | %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz); | |
182 | ||
183 | %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt); | |
184 | %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz); | |
185 | ||
af309447 RD |
186 | %name(SetToolTipString)void SetToolTip(const wxString &tip); |
187 | void SetToolTip(wxToolTip *tooltip); | |
188 | wxToolTip* GetToolTip(); | |
7bf85405 RD |
189 | }; |
190 | ||
b8b8dda7 RD |
191 | %pragma(python) code = " |
192 | def wxDLG_PNT(win, point): | |
193 | return win.ConvertDialogPointToPixels(point) | |
194 | ||
195 | def wxDLG_SZE(win, size): | |
af309447 | 196 | return win.ConvertDialogSizeToPixels(size) |
b8b8dda7 | 197 | " |
7bf85405 | 198 | |
853b255a | 199 | #ifdef __WXMSW__ |
7bf85405 RD |
200 | %inline %{ |
201 | wxWindow* wxWindow_FindFocus() { | |
202 | return wxWindow::FindFocus(); | |
203 | } | |
204 | %} | |
af309447 RD |
205 | |
206 | ||
207 | %inline %{ | |
208 | wxWindow* wxWindow_FromHWND(unsigned long hWnd) { | |
209 | wxWindow* win = new wxWindow; | |
210 | win->SetHWND(hWnd); | |
211 | win->SubclassWin(hWnd); | |
212 | return win; | |
213 | } | |
214 | %} | |
853b255a | 215 | #endif |
7bf85405 | 216 | |
7bf85405 RD |
217 | |
218 | //--------------------------------------------------------------------------- | |
219 | ||
220 | class wxPanel : public wxWindow { | |
221 | public: | |
222 | wxPanel(wxWindow* parent, | |
223 | const wxWindowID id, | |
224 | const wxPoint& pos = wxPyDefaultPosition, | |
225 | const wxSize& size = wxPyDefaultSize, | |
226 | long style = wxTAB_TRAVERSAL, | |
227 | const char* name = "panel"); | |
228 | ||
b8b8dda7 | 229 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
9c039d08 | 230 | |
7bf85405 RD |
231 | void InitDialog(); |
232 | }; | |
233 | ||
234 | //--------------------------------------------------------------------------- | |
235 | ||
236 | class wxDialog : public wxPanel { | |
237 | public: | |
238 | wxDialog(wxWindow* parent, | |
239 | const wxWindowID id, | |
240 | const wxString& title, | |
241 | const wxPoint& pos = wxPyDefaultPosition, | |
242 | const wxSize& size = wxPyDefaultSize, | |
243 | long style = wxDEFAULT_DIALOG_STYLE, | |
244 | const char* name = "dialogBox"); | |
245 | ||
b8b8dda7 | 246 | %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)" |
9c039d08 | 247 | |
7bf85405 RD |
248 | void Centre(int direction = wxBOTH); |
249 | void EndModal(int retCode); | |
250 | wxString GetTitle(); | |
251 | void Iconize(bool iconize); | |
252 | bool IsIconized(); | |
7bf85405 | 253 | void SetModal(bool flag); |
853b255a | 254 | bool IsModal(); |
7bf85405 RD |
255 | void SetTitle(const wxString& title); |
256 | bool Show(bool show); | |
257 | int ShowModal(); | |
258 | }; | |
259 | ||
260 | //--------------------------------------------------------------------------- | |
261 | ||
262 | class wxScrolledWindow : public wxWindow { | |
263 | public: | |
264 | wxScrolledWindow(wxWindow* parent, | |
265 | const wxWindowID id = -1, | |
266 | const wxPoint& pos = wxPyDefaultPosition, | |
267 | const wxSize& size = wxPyDefaultSize, | |
268 | long style = wxHSCROLL | wxVSCROLL, | |
269 | char* name = "scrolledWindow"); | |
270 | ||
b8b8dda7 RD |
271 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
272 | %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)" | |
9c039d08 | 273 | |
7bf85405 RD |
274 | void EnableScrolling(bool xScrolling, bool yScrolling); |
275 | void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT); | |
276 | void GetVirtualSize(int* OUTPUT, int* OUTPUT); | |
277 | bool IsRetained(); | |
278 | void PrepareDC(wxDC& dc); | |
279 | void Scroll(int x, int y); | |
280 | void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY, | |
281 | int noUnitsX, int noUnitsY, | |
282 | int xPos = 0, int yPos = 0); | |
283 | void ViewStart(int* OUTPUT, int* OUTPUT); | |
284 | }; | |
285 | ||
286 | //---------------------------------------------------------------------- | |
287 | ||
288 | ||
289 | class wxMenu : public wxEvtHandler { | |
290 | public: | |
291 | wxMenu(const wxString& title = wxPyEmptyStr); | |
292 | ||
293 | void Append(int id, const wxString& item, | |
294 | const wxString& helpString = wxPyEmptyStr, | |
295 | int checkable = FALSE); | |
296 | %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu, | |
297 | const wxString& helpString = wxPyEmptyStr); | |
b57bdb5a | 298 | #ifndef __WXGTK__ |
af309447 | 299 | %name(AppendItem)void Append(const wxMenuItem* item); |
b57bdb5a | 300 | #endif |
af309447 | 301 | |
7bf85405 RD |
302 | void AppendSeparator(); |
303 | void Break(); | |
304 | void Check(int id, bool flag); | |
7bf85405 RD |
305 | void Enable(int id, bool enable); |
306 | int FindItem(const wxString& itemString); | |
7bf85405 | 307 | wxString GetTitle(); |
7bf85405 | 308 | void SetTitle(const wxString& title); |
714e6a9e RD |
309 | wxMenuItem* FindItemForId(int id); |
310 | wxString GetHelpString(int id); | |
311 | wxString GetLabel(int id); | |
312 | void SetHelpString(int id, const wxString& helpString); | |
853b255a RD |
313 | bool IsChecked(int id); |
314 | bool IsEnabled(int id); | |
315 | void SetLabel(int id, const wxString& label); | |
7bf85405 RD |
316 | }; |
317 | ||
318 | ||
7bf85405 RD |
319 | // |
320 | // This one knows how to set a callback and handle INC- and DECREFing it. To | |
321 | // be used for PopupMenus, but you must retain a referece to it while using | |
322 | // it. | |
323 | // | |
324 | class wxPyMenu : public wxMenu { | |
325 | public: | |
326 | wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL); | |
327 | ~wxPyMenu(); | |
328 | }; | |
329 | ||
330 | //---------------------------------------------------------------------- | |
331 | ||
332 | class wxMenuBar : public wxEvtHandler { | |
333 | public: | |
334 | wxMenuBar(); | |
335 | ||
336 | void Append(wxMenu *menu, const wxString& title); | |
337 | void Check(int id, bool flag); | |
338 | bool Checked(int id); | |
339 | void Enable(int id, bool enable); | |
714e6a9e | 340 | bool Enabled(int id); |
7bf85405 | 341 | int FindMenuItem(const wxString& menuString, const wxString& itemString); |
c95e68d8 | 342 | wxMenuItem * FindItemForId(int id); |
aeeb6a44 | 343 | #ifdef __WXMSW__ |
714e6a9e | 344 | void EnableTop(int pos, bool enable); |
7bf85405 RD |
345 | wxString GetHelpString(int id); |
346 | wxString GetLabel(int id); | |
7bf85405 RD |
347 | void SetHelpString(int id, const wxString& helpString); |
348 | void SetLabel(int id, const wxString& label); | |
853b255a | 349 | wxString GetLabelTop(int pos); |
7bf85405 | 350 | void SetLabelTop(int pos, const wxString& label); |
853b255a | 351 | #endif |
714e6a9e RD |
352 | int GetMenuCount(); |
353 | wxMenu* GetMenu(int i); | |
7bf85405 RD |
354 | }; |
355 | ||
356 | ||
357 | //---------------------------------------------------------------------- | |
358 | ||
359 | class wxMenuItem { | |
360 | public: | |
361 | bool IsSeparator(); | |
362 | bool IsEnabled(); | |
363 | bool IsChecked(); | |
714e6a9e | 364 | bool IsCheckable(); |
7bf85405 | 365 | int GetId(); |
7bf85405 RD |
366 | wxMenu* GetSubMenu(); |
367 | void SetName(const wxString& strName); | |
7bf85405 | 368 | const wxString& GetName(); |
714e6a9e RD |
369 | const wxString& GetHelp(); |
370 | void SetHelp(const wxString& strHelp); | |
371 | void Enable(bool bDoEnable = TRUE); | |
372 | void Check(bool bDoCheck = TRUE); | |
c95e68d8 | 373 | |
4f22cf8d RR |
374 | #ifdef __WXMSW__ |
375 | void DeleteSubMenu(); | |
376 | #endif | |
7bf85405 RD |
377 | }; |
378 | ||
379 | //--------------------------------------------------------------------------- | |
380 | ///////////////////////////////////////////////////////////////////////////// | |
381 | // | |
382 | // $Log$ | |
b57bdb5a RD |
383 | // Revision 1.13 1999/02/20 10:02:38 RD |
384 | // Changes needed to enable wxGTK compatibility. | |
385 | // | |
af309447 RD |
386 | // Revision 1.12 1999/02/20 09:03:03 RD |
387 | // Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a | |
388 | // window handle. If you can get the window handle into the python code, | |
389 | // it should just work... More news on this later. | |
390 | // | |
391 | // Added wxImageList, wxToolTip. | |
392 | // | |
393 | // Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the | |
394 | // wxRegConfig class. | |
395 | // | |
396 | // As usual, some bug fixes, tweaks, etc. | |
397 | // | |
aeeb6a44 | 398 | // Revision 1.11 1998/12/18 15:49:10 RR |
af309447 | 399 | // |
aeeb6a44 RR |
400 | // wxClipboard now serves the primary selection as well |
401 | // wxPython fixes | |
402 | // warning mesages | |
403 | // | |
c95e68d8 | 404 | // Revision 1.10 1998/12/17 17:52:20 RD |
aeeb6a44 | 405 | // |
c95e68d8 RD |
406 | // wxPython 0.5.2 |
407 | // Minor fixes and SWIG code generation for RR's changes. MSW and GTK | |
408 | // versions are much closer now! | |
409 | // | |
4f22cf8d | 410 | // Revision 1.9 1998/12/17 14:07:46 RR |
c95e68d8 | 411 | // |
4f22cf8d RR |
412 | // Removed minor differences between wxMSW and wxGTK |
413 | // | |
105e45b9 | 414 | // Revision 1.8 1998/12/16 22:10:56 RD |
4f22cf8d | 415 | // |
105e45b9 RD |
416 | // Tweaks needed to be able to build wxPython with wxGTK. |
417 | // | |
b8b8dda7 RD |
418 | // Revision 1.7 1998/12/15 20:41:25 RD |
419 | // Changed the import semantics from "from wxPython import *" to "from | |
420 | // wxPython.wx import *" This is for people who are worried about | |
421 | // namespace pollution, they can use "from wxPython import wx" and then | |
422 | // prefix all the wxPython identifiers with "wx." | |
423 | // | |
424 | // Added wxTaskbarIcon for wxMSW. | |
425 | // | |
426 | // Made the events work for wxGrid. | |
427 | // | |
428 | // Added wxConfig. | |
429 | // | |
430 | // Added wxMiniFrame for wxGTK, (untested.) | |
431 | // | |
432 | // Changed many of the args and return values that were pointers to gdi | |
433 | // objects to references to reflect changes in the wxWindows API. | |
434 | // | |
435 | // Other assorted fixes and additions. | |
436 | // | |
9c039d08 | 437 | // Revision 1.6 1998/10/02 06:40:43 RD |
b8b8dda7 | 438 | // |
9c039d08 RD |
439 | // Version 0.4 of wxPython for MSW. |
440 | // | |
652e7bb4 RD |
441 | // Revision 1.5 1998/08/17 18:29:40 RD |
442 | // Removed an extra method definition | |
443 | // | |
714e6a9e RD |
444 | // Revision 1.4 1998/08/16 04:31:11 RD |
445 | // More wxGTK work. | |
446 | // | |
03e9bead RD |
447 | // Revision 1.3 1998/08/15 07:36:47 RD |
448 | // - Moved the header in the .i files out of the code that gets put into | |
449 | // the .cpp files. It caused CVS conflicts because of the RCS ID being | |
450 | // different each time. | |
451 | // | |
452 | // - A few minor fixes. | |
453 | // | |
853b255a RD |
454 | // Revision 1.2 1998/08/14 23:36:46 RD |
455 | // Beginings of wxGTK compatibility | |
456 | // | |
7bf85405 RD |
457 | // Revision 1.1 1998/08/09 08:25:52 RD |
458 | // Initial version | |
459 | // | |
460 | // | |
461 | ||
462 |