]>
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" |
efc5f224 | 32 | |
7bf85405 RD |
33 | |
34 | //--------------------------------------------------------------------------- | |
35 | ||
36 | class wxEvtHandler { | |
37 | public: | |
cf694132 | 38 | bool ProcessEvent(wxEvent& event); |
7bf85405 RD |
39 | %addmethods { |
40 | void Connect( int id, int lastId, int eventType, PyObject* func) { | |
41 | if (PyCallable_Check(func)) { | |
42 | self->Connect(id, lastId, eventType, | |
853b255a | 43 | (wxObjectEventFunction) &wxPyCallback::EventThunker, |
7bf85405 RD |
44 | new wxPyCallback(func)); |
45 | } | |
46 | } | |
47 | } | |
48 | }; | |
49 | ||
50 | ||
51 | //---------------------------------------------------------------------- | |
52 | ||
efc5f224 | 53 | %apply int * INOUT { int* x, int* y }; |
7bf85405 RD |
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 | ||
b8b8dda7 | 64 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
7bf85405 RD |
65 | |
66 | void CaptureMouse(); | |
8bf5d46e RD |
67 | void Center(int direction = wxBOTH); |
68 | void Centre(int direction = wxBOTH); | |
69 | void CentreOnParent(int direction = wxBOTH ); | |
70 | void CenterOnParent(int direction = wxBOTH ); | |
efc5f224 RD |
71 | |
72 | // (uses apply'ed INOUT typemap, see above) | |
73 | %name(ClientToScreenXY)void ClientToScreen(int* x, int* y); | |
af309447 | 74 | wxPoint ClientToScreen(const wxPoint& pt); |
efc5f224 | 75 | |
7bf85405 RD |
76 | bool Close(int force = FALSE); |
77 | bool Destroy(); | |
78 | void DestroyChildren(); | |
853b255a | 79 | #ifdef __WXMSW__ |
7bf85405 | 80 | void DragAcceptFiles(bool accept); |
853b255a | 81 | #endif |
7bf85405 RD |
82 | void Enable(bool enable); |
83 | //bool FakePopupMenu(wxMenu* menu, int x, int y); | |
af309447 | 84 | %name(FindWindowById) wxWindow* FindWindow(long id); |
714e6a9e | 85 | %name(FindWindowByName) wxWindow* FindWindow(const wxString& name); |
7bf85405 RD |
86 | void Fit(); |
87 | wxColour GetBackgroundColour(); | |
88 | int GetCharHeight(); | |
89 | int GetCharWidth(); | |
b8b8dda7 RD |
90 | %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT); |
91 | wxSize GetClientSize(); | |
7bf85405 | 92 | wxLayoutConstraints * GetConstraints(); |
3ab72185 | 93 | wxEvtHandler* GetEventHandler(); |
105e45b9 | 94 | |
b8b8dda7 | 95 | wxFont& GetFont(); |
7bf85405 RD |
96 | wxColour GetForegroundColour(); |
97 | wxWindow * GetGrandParent(); | |
98 | int GetId(); | |
853b255a | 99 | wxString GetLabel(); |
bb0054cd | 100 | void SetLabel(const wxString& label); |
853b255a | 101 | wxString GetName(); |
7bf85405 | 102 | wxWindow * GetParent(); |
b8b8dda7 RD |
103 | %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT); |
104 | wxPoint GetPosition(); | |
105 | wxRect GetRect(); | |
7bf85405 RD |
106 | int GetScrollThumb(int orientation); |
107 | int GetScrollPos(int orientation); | |
108 | int GetScrollRange(int orientation); | |
b8b8dda7 RD |
109 | %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT); |
110 | wxSize GetSize(); | |
af309447 RD |
111 | void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT); |
112 | %name(GetFullTextExtent)void GetTextExtent(const wxString& string, | |
113 | int *OUTPUT, int *OUTPUT, int *OUTPUT, int* OUTPUT, | |
114 | const wxFont* font = NULL); //, bool use16 = FALSE) | |
853b255a | 115 | wxString GetTitle(); |
8bf5d46e | 116 | wxRegion GetUpdateRegion(); |
7bf85405 | 117 | long GetWindowStyleFlag(); |
bb0054cd | 118 | bool Hide(); |
7bf85405 RD |
119 | void InitDialog(); |
120 | bool IsEnabled(); | |
121 | bool IsRetained(); | |
122 | bool IsShown(); | |
bb0054cd | 123 | bool IsTopLevel(); |
7bf85405 RD |
124 | void Layout(); |
125 | bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL); | |
126 | void Lower(); | |
127 | void MakeModal(bool flag); | |
af309447 RD |
128 | %name(MoveXY)void Move(int x, int y); |
129 | void Move(const wxPoint& point); | |
7bf85405 | 130 | |
3ab72185 RD |
131 | wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE); |
132 | void PushEventHandler(wxEvtHandler* handler); | |
7bf85405 | 133 | |
8bf5d46e RD |
134 | %name(PopupMenuXY)bool PopupMenu(wxMenu *menu, int x, int y); |
135 | bool PopupMenu(wxMenu *menu, const wxPoint& pos); | |
136 | ||
7bf85405 RD |
137 | void Raise(); |
138 | void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL); | |
139 | void ReleaseMouse(); | |
bb0054cd RD |
140 | bool Reparent( wxWindow* newParent ); |
141 | ||
efc5f224 RD |
142 | // (uses apply'ed INOUT typemap, see above) |
143 | %name(ScreenToClientXY)void ScreenToClient(int *x, int *y); | |
af309447 RD |
144 | wxPoint ScreenToClient(const wxPoint& pt); |
145 | ||
7bf85405 | 146 | void ScrollWindow(int dx, int dy, const wxRect* rect = NULL); |
b8b8dda7 | 147 | void SetAcceleratorTable(const wxAcceleratorTable& accel); |
7bf85405 RD |
148 | void SetAutoLayout(bool autoLayout); |
149 | void SetBackgroundColour(const wxColour& colour); | |
150 | void SetConstraints(wxLayoutConstraints *constraints); | |
7bf85405 RD |
151 | void SetFocus(); |
152 | void SetFont(const wxFont& font); | |
153 | void SetForegroundColour(const wxColour& colour); | |
154 | void SetId(int id); | |
155 | void SetName(const wxString& name); | |
7bf85405 RD |
156 | void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh = TRUE); |
157 | void SetScrollPos(int orientation, int pos, bool refresh = TRUE); | |
158 | ||
7bf85405 RD |
159 | %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO); |
160 | %addmethods { | |
161 | void SetSize(const wxSize& size) { | |
162 | self->SetSize(size.x, size.y); | |
163 | } | |
164 | ||
165 | void SetPosition(const wxPoint& pos) { | |
166 | self->SetSize(pos.x, pos.y, -1, -1); | |
167 | } | |
168 | } | |
169 | ||
170 | void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1); | |
af309447 RD |
171 | %name(SetClientSizeWH)void SetClientSize(int width, int height); |
172 | void SetClientSize(const wxSize& size); | |
7bf85405 | 173 | //void SetPalette(wxPalette* palette); |
7bf85405 | 174 | void SetCursor(const wxCursor&cursor); |
3ab72185 | 175 | void SetEventHandler(wxEvtHandler* handler); |
7bf85405 RD |
176 | void SetTitle(const wxString& title); |
177 | bool Show(bool show); | |
178 | bool TransferDataFromWindow(); | |
179 | bool TransferDataToWindow(); | |
180 | bool Validate(); | |
181 | void WarpPointer(int x, int y); | |
182 | ||
b8b8dda7 RD |
183 | %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt); |
184 | %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz); | |
185 | ||
cf694132 RD |
186 | %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt); |
187 | %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz); | |
188 | ||
b8b8dda7 RD |
189 | %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt); |
190 | %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz); | |
191 | ||
af309447 RD |
192 | %name(SetToolTipString)void SetToolTip(const wxString &tip); |
193 | void SetToolTip(wxToolTip *tooltip); | |
194 | wxToolTip* GetToolTip(); | |
7bf85405 RD |
195 | }; |
196 | ||
efc5f224 RD |
197 | //%clear int* x, int* y; |
198 | ||
199 | ||
200 | ||
b8b8dda7 | 201 | %pragma(python) code = " |
bb0054cd RD |
202 | def wxDLG_PNT(win, point_or_x, y=None): |
203 | if y is None: | |
204 | return win.ConvertDialogPointToPixels(point_or_x) | |
205 | else: | |
206 | return win.ConvertDialogPointToPixels(wxPoint(point_or_x, y)) | |
207 | ||
208 | def wxDLG_SZE(win, size_width, height=None): | |
209 | if height is None: | |
210 | return win.ConvertDialogSizeToPixels(size_width) | |
211 | else: | |
212 | return win.ConvertDialogSizeToPixels(wxSize(size_width, height)) | |
b8b8dda7 | 213 | " |
7bf85405 | 214 | |
853b255a | 215 | #ifdef __WXMSW__ |
7bf85405 RD |
216 | %inline %{ |
217 | wxWindow* wxWindow_FindFocus() { | |
218 | return wxWindow::FindFocus(); | |
219 | } | |
220 | %} | |
af309447 RD |
221 | |
222 | ||
223 | %inline %{ | |
224 | wxWindow* wxWindow_FromHWND(unsigned long hWnd) { | |
225 | wxWindow* win = new wxWindow; | |
226 | win->SetHWND(hWnd); | |
227 | win->SubclassWin(hWnd); | |
228 | return win; | |
229 | } | |
230 | %} | |
853b255a | 231 | #endif |
7bf85405 | 232 | |
7bf85405 | 233 | |
efc5f224 | 234 | |
7bf85405 RD |
235 | //--------------------------------------------------------------------------- |
236 | ||
237 | class wxPanel : public wxWindow { | |
238 | public: | |
239 | wxPanel(wxWindow* parent, | |
240 | const wxWindowID id, | |
241 | const wxPoint& pos = wxPyDefaultPosition, | |
242 | const wxSize& size = wxPyDefaultSize, | |
243 | long style = wxTAB_TRAVERSAL, | |
244 | const char* name = "panel"); | |
245 | ||
b8b8dda7 | 246 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
9c039d08 | 247 | |
7bf85405 | 248 | void InitDialog(); |
bb0054cd RD |
249 | wxButton* GetDefaultItem(); |
250 | void SetDefaultItem(wxButton *btn); | |
251 | ||
3ab72185 | 252 | // fix some SWIG trouble... |
bb0054cd RD |
253 | %pragma(python) addtoclass = " |
254 | def GetDefaultItem(self): | |
255 | import controls | |
256 | val = windowsc.wxPanel_GetDefaultItem(self.this) | |
257 | val = controls.wxButtonPtr(val) | |
258 | return val | |
259 | " | |
7bf85405 RD |
260 | }; |
261 | ||
262 | //--------------------------------------------------------------------------- | |
263 | ||
264 | class wxDialog : public wxPanel { | |
265 | public: | |
266 | wxDialog(wxWindow* parent, | |
267 | const wxWindowID id, | |
268 | const wxString& title, | |
269 | const wxPoint& pos = wxPyDefaultPosition, | |
270 | const wxSize& size = wxPyDefaultSize, | |
271 | long style = wxDEFAULT_DIALOG_STYLE, | |
272 | const char* name = "dialogBox"); | |
273 | ||
b8b8dda7 | 274 | %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)" |
9c039d08 | 275 | |
7bf85405 RD |
276 | void Centre(int direction = wxBOTH); |
277 | void EndModal(int retCode); | |
278 | wxString GetTitle(); | |
279 | void Iconize(bool iconize); | |
280 | bool IsIconized(); | |
7bf85405 | 281 | void SetModal(bool flag); |
853b255a | 282 | bool IsModal(); |
7bf85405 RD |
283 | void SetTitle(const wxString& title); |
284 | bool Show(bool show); | |
285 | int ShowModal(); | |
4cd9591a RD |
286 | |
287 | int GetReturnCode(); | |
288 | void SetReturnCode(int retCode); | |
7bf85405 RD |
289 | }; |
290 | ||
291 | //--------------------------------------------------------------------------- | |
292 | ||
bb0054cd | 293 | class wxScrolledWindow : public wxPanel { |
7bf85405 RD |
294 | public: |
295 | wxScrolledWindow(wxWindow* parent, | |
296 | const wxWindowID id = -1, | |
297 | const wxPoint& pos = wxPyDefaultPosition, | |
298 | const wxSize& size = wxPyDefaultSize, | |
299 | long style = wxHSCROLL | wxVSCROLL, | |
300 | char* name = "scrolledWindow"); | |
301 | ||
b8b8dda7 RD |
302 | %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)" |
303 | %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)" | |
9c039d08 | 304 | |
7bf85405 RD |
305 | void EnableScrolling(bool xScrolling, bool yScrolling); |
306 | void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT); | |
307 | void GetVirtualSize(int* OUTPUT, int* OUTPUT); | |
308 | bool IsRetained(); | |
309 | void PrepareDC(wxDC& dc); | |
310 | void Scroll(int x, int y); | |
311 | void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY, | |
312 | int noUnitsX, int noUnitsY, | |
313 | int xPos = 0, int yPos = 0); | |
314 | void ViewStart(int* OUTPUT, int* OUTPUT); | |
315 | }; | |
316 | ||
317 | //---------------------------------------------------------------------- | |
318 | ||
319 | ||
320 | class wxMenu : public wxEvtHandler { | |
321 | public: | |
8bf5d46e | 322 | wxMenu(const wxString& title = wxPyEmptyStr, long style = 0); |
7bf85405 RD |
323 | |
324 | void Append(int id, const wxString& item, | |
325 | const wxString& helpString = wxPyEmptyStr, | |
326 | int checkable = FALSE); | |
327 | %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu, | |
328 | const wxString& helpString = wxPyEmptyStr); | |
b57bdb5a | 329 | #ifndef __WXGTK__ |
af309447 | 330 | %name(AppendItem)void Append(const wxMenuItem* item); |
b57bdb5a | 331 | #endif |
af309447 | 332 | |
7bf85405 RD |
333 | void AppendSeparator(); |
334 | void Break(); | |
335 | void Check(int id, bool flag); | |
7bf85405 RD |
336 | void Enable(int id, bool enable); |
337 | int FindItem(const wxString& itemString); | |
7bf85405 | 338 | wxString GetTitle(); |
7bf85405 | 339 | void SetTitle(const wxString& title); |
714e6a9e RD |
340 | wxMenuItem* FindItemForId(int id); |
341 | wxString GetHelpString(int id); | |
342 | wxString GetLabel(int id); | |
343 | void SetHelpString(int id, const wxString& helpString); | |
853b255a RD |
344 | bool IsChecked(int id); |
345 | bool IsEnabled(int id); | |
346 | void SetLabel(int id, const wxString& label); | |
8bf5d46e | 347 | void UpdateUI(wxEvtHandler* source = NULL); |
efc5f224 RD |
348 | |
349 | %addmethods { | |
350 | void Destroy() { | |
351 | delete self; | |
352 | } | |
353 | } | |
354 | ||
7bf85405 RD |
355 | }; |
356 | ||
357 | ||
7bf85405 RD |
358 | // |
359 | // This one knows how to set a callback and handle INC- and DECREFing it. To | |
360 | // be used for PopupMenus, but you must retain a referece to it while using | |
361 | // it. | |
362 | // | |
8bf5d46e RD |
363 | // class wxPyMenu : public wxMenu { |
364 | // public: | |
365 | // wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL); | |
366 | // ~wxPyMenu(); | |
367 | // }; | |
7bf85405 RD |
368 | |
369 | //---------------------------------------------------------------------- | |
370 | ||
371 | class wxMenuBar : public wxEvtHandler { | |
372 | public: | |
373 | wxMenuBar(); | |
374 | ||
375 | void Append(wxMenu *menu, const wxString& title); | |
376 | void Check(int id, bool flag); | |
377 | bool Checked(int id); | |
378 | void Enable(int id, bool enable); | |
714e6a9e | 379 | bool Enabled(int id); |
7bf85405 | 380 | int FindMenuItem(const wxString& menuString, const wxString& itemString); |
c95e68d8 | 381 | wxMenuItem * FindItemForId(int id); |
aeeb6a44 | 382 | #ifdef __WXMSW__ |
714e6a9e | 383 | void EnableTop(int pos, bool enable); |
7bf85405 RD |
384 | wxString GetHelpString(int id); |
385 | wxString GetLabel(int id); | |
7bf85405 RD |
386 | void SetHelpString(int id, const wxString& helpString); |
387 | void SetLabel(int id, const wxString& label); | |
853b255a | 388 | wxString GetLabelTop(int pos); |
7bf85405 | 389 | void SetLabelTop(int pos, const wxString& label); |
853b255a | 390 | #endif |
714e6a9e RD |
391 | int GetMenuCount(); |
392 | wxMenu* GetMenu(int i); | |
7bf85405 RD |
393 | }; |
394 | ||
395 | ||
396 | //---------------------------------------------------------------------- | |
397 | ||
398 | class wxMenuItem { | |
399 | public: | |
cf694132 RD |
400 | #ifndef __WXGTK__ |
401 | wxMenuItem(wxMenu* parentMenu=NULL, int id=ID_SEPARATOR, | |
402 | const wxString& text = wxPyEmptyStr, | |
403 | const wxString& helpString = wxPyEmptyStr, | |
404 | bool checkable = FALSE, wxMenu* subMenu = NULL); | |
405 | #else | |
406 | wxMenuItem(); | |
407 | #endif | |
408 | ||
7bf85405 RD |
409 | bool IsSeparator(); |
410 | bool IsEnabled(); | |
411 | bool IsChecked(); | |
714e6a9e | 412 | bool IsCheckable(); |
7bf85405 | 413 | int GetId(); |
7bf85405 RD |
414 | wxMenu* GetSubMenu(); |
415 | void SetName(const wxString& strName); | |
cf694132 RD |
416 | wxString GetName(); |
417 | wxString GetHelp(); | |
714e6a9e RD |
418 | void SetHelp(const wxString& strHelp); |
419 | void Enable(bool bDoEnable = TRUE); | |
420 | void Check(bool bDoCheck = TRUE); | |
c95e68d8 | 421 | |
4f22cf8d | 422 | #ifdef __WXMSW__ |
cf694132 RD |
423 | wxColour& GetBackgroundColour(); |
424 | wxBitmap GetBitmap(bool checked = TRUE); | |
425 | wxFont& GetFont(); | |
426 | int GetMarginWidth(); | |
427 | wxColour& GetTextColour(); | |
428 | void SetBackgroundColour(const wxColour& colour); | |
429 | void SetBitmaps(const wxBitmap& checked, const wxBitmap& unchecked = wxNullBitmap); | |
430 | void SetFont(const wxFont& font); | |
431 | void SetMarginWidth(int width); | |
432 | void SetTextColour(const wxColour& colour); | |
4f22cf8d RR |
433 | void DeleteSubMenu(); |
434 | #endif | |
7bf85405 RD |
435 | }; |
436 | ||
437 | //--------------------------------------------------------------------------- | |
7bf85405 RD |
438 | |
439 |