]>
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 | |
b1462dfa | 30 | %import clip_dnd.i |
efc5f224 | 31 | |
2f90df85 | 32 | %pragma(python) code = "import wx" |
7bf85405 | 33 | |
b68dc582 RD |
34 | |
35 | %{ | |
36 | static wxString wxPyEmptyStr(""); | |
37 | %} | |
38 | ||
7bf85405 RD |
39 | //--------------------------------------------------------------------------- |
40 | ||
41 | class wxEvtHandler { | |
42 | public: | |
c368d904 RD |
43 | wxEvtHandler(); |
44 | ||
cf694132 | 45 | bool ProcessEvent(wxEvent& event); |
f6bcfd97 | 46 | void AddPendingEvent(wxEvent& event); |
2f90df85 RD |
47 | //bool SearchEventTable(wxEventTable& table, wxEvent& event); |
48 | ||
49 | bool GetEvtHandlerEnabled(); | |
50 | void SetEvtHandlerEnabled(bool enabled); | |
51 | ||
52 | wxEvtHandler* GetNextHandler(); | |
53 | wxEvtHandler* GetPreviousHandler(); | |
54 | void SetNextHandler(wxEvtHandler* handler); | |
55 | void SetPreviousHandler(wxEvtHandler* handler); | |
56 | ||
57 | ||
7bf85405 RD |
58 | %addmethods { |
59 | void Connect( int id, int lastId, int eventType, PyObject* func) { | |
60 | if (PyCallable_Check(func)) { | |
61 | self->Connect(id, lastId, eventType, | |
853b255a | 62 | (wxObjectEventFunction) &wxPyCallback::EventThunker, |
7bf85405 RD |
63 | new wxPyCallback(func)); |
64 | } | |
65 | } | |
6999b0d8 RD |
66 | |
67 | bool Disconnect(int id, int lastId = -1, | |
68 | wxEventType eventType = wxEVT_NULL) { | |
69 | return self->Disconnect(id, lastId, eventType, | |
70 | (wxObjectEventFunction) | |
71 | &wxPyCallback::EventThunker); | |
72 | } | |
73 | ||
926bb76c RD |
74 | // This really belongs in the wxObject base class. It's probably |
75 | // time to actually add it... | |
76 | const char* GetClassName() { | |
77 | return self->GetClassInfo()->GetClassName(); | |
78 | } | |
7bf85405 | 79 | } |
f6bcfd97 | 80 | |
926bb76c RD |
81 | // %pragma(python) addtoclass = " |
82 | // _prop_list_ = {} | |
83 | // " | |
f6bcfd97 BP |
84 | // %pragma(python) addtoclass = " |
85 | // def __getattr__(self, name): | |
86 | // pl = self._prop_list_ | |
87 | // if pl.has_key(name): | |
88 | // getFunc, setFunc = pl[name] | |
89 | // if getFunc: | |
90 | // return getattr(self, getFunc)() | |
91 | // else: | |
92 | // raise TypeError, '%s property is write-only' % name | |
93 | // raise AttributeError, name | |
94 | ||
95 | // def __setattr__(self, name, value): | |
96 | // pl = self._prop_list_ | |
97 | // if pl.has_key(name): | |
98 | // getFunc, setFunc = pl[name] | |
99 | // if setFunc: | |
100 | // return getattr(self, setFunc)(value) | |
101 | // else: | |
102 | // raise TypeError, '%s property is read-only' % name | |
103 | // self.__dict__[name] = value | |
104 | // " | |
7bf85405 RD |
105 | }; |
106 | ||
107 | ||
2f90df85 RD |
108 | //---------------------------------------------------------------------- |
109 | ||
110 | class wxValidator : public wxEvtHandler { | |
111 | public: | |
112 | wxValidator(); | |
113 | //~wxValidator(); | |
114 | ||
115 | wxValidator* Clone(); | |
116 | wxWindow* GetWindow(); | |
117 | void SetWindow(wxWindow* window); | |
f6bcfd97 | 118 | |
c368d904 RD |
119 | // // Properties list |
120 | // %pragma(python) addtoclass = " | |
121 | // _prop_list_ = { | |
122 | // 'window' : ('GetWindow', 'SetWindow'), | |
123 | // } | |
124 | // _prop_list_.update(wxEvtHandler._prop_list_) | |
125 | // " | |
2f90df85 RD |
126 | }; |
127 | ||
128 | %inline %{ | |
129 | bool wxValidator_IsSilent() { | |
130 | return wxValidator::IsSilent(); | |
131 | } | |
132 | ||
133 | void wxValidator_SetBellOnError(int doIt = TRUE) { | |
134 | wxValidator::SetBellOnError(doIt); | |
135 | } | |
136 | %} | |
137 | ||
138 | //---------------------------------------------------------------------- | |
139 | %{ | |
140 | class wxPyValidator : public wxValidator { | |
141 | DECLARE_DYNAMIC_CLASS(wxPyValidator); | |
142 | public: | |
143 | wxPyValidator() { | |
144 | } | |
145 | // wxPyValidator(const wxPyValidator& other); | |
146 | ||
147 | ~wxPyValidator() { | |
148 | } | |
149 | ||
150 | wxObject* wxPyValidator::Clone() const { | |
694759cf RD |
151 | wxPyValidator* ptr = NULL; |
152 | wxPyValidator* self = (wxPyValidator*)this; | |
153 | ||
154 | bool doSave = wxPyRestoreThread(); | |
155 | if (self->m_myInst.findCallback("Clone")) { | |
156 | PyObject* ro; | |
157 | ro = self->m_myInst.callCallbackObj(Py_BuildValue("()")); | |
f6bcfd97 BP |
158 | if (ro) { |
159 | SWIG_GetPtrObj(ro, (void **)&ptr, "_wxPyValidator_p"); | |
160 | Py_DECREF(ro); | |
161 | } | |
694759cf RD |
162 | } |
163 | // This is very dangerous!!! But is the only way I could find | |
164 | // to squash a memory leak. Currently it is okay, but if the | |
165 | // validator architecture in wxWindows ever changes, problems | |
166 | // could arise. | |
167 | delete self; | |
168 | ||
169 | wxPySaveThread(doSave); | |
170 | return ptr; | |
2f90df85 | 171 | } |
2f90df85 RD |
172 | |
173 | DEC_PYCALLBACK_BOOL_WXWIN(Validate); | |
174 | DEC_PYCALLBACK_BOOL_(TransferToWindow); | |
175 | DEC_PYCALLBACK_BOOL_(TransferFromWindow); | |
176 | ||
177 | PYPRIVATE; | |
178 | // PyObject* m_data; | |
179 | }; | |
180 | ||
181 | IMP_PYCALLBACK_BOOL_WXWIN(wxPyValidator, wxValidator, Validate); | |
182 | IMP_PYCALLBACK_BOOL_(wxPyValidator, wxValidator, TransferToWindow); | |
183 | IMP_PYCALLBACK_BOOL_(wxPyValidator, wxValidator, TransferFromWindow); | |
184 | ||
185 | IMPLEMENT_DYNAMIC_CLASS(wxPyValidator, wxValidator); | |
186 | ||
187 | %} | |
188 | ||
189 | class wxPyValidator : public wxValidator { | |
190 | public: | |
191 | wxPyValidator(); | |
192 | // ~wxPyValidator(); | |
193 | ||
9b3d3bc4 | 194 | %addmethods { void Destroy() { delete self; } } |
2f90df85 | 195 | |
f6bcfd97 BP |
196 | void _setSelf(PyObject* self, PyObject* _class, int incref=TRUE); |
197 | %pragma(python) addtomethod = "__init__:self._setSelf(self, wxPyValidator, 0)" | |
2f90df85 RD |
198 | |
199 | }; | |
200 | ||
7bf85405 RD |
201 | //---------------------------------------------------------------------- |
202 | ||
efc5f224 | 203 | %apply int * INOUT { int* x, int* y }; |
7bf85405 RD |
204 | |
205 | class wxWindow : public wxEvtHandler { | |
206 | public: | |
207 | ||
208 | wxWindow(wxWindow* parent, const wxWindowID id, | |
b68dc582 RD |
209 | const wxPoint& pos = wxDefaultPosition, |
210 | const wxSize& size = wxDefaultSize, | |
7bf85405 RD |
211 | long style = 0, |
212 | char* name = "panel"); | |
213 | ||
f6bcfd97 | 214 | %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)" |
7bf85405 RD |
215 | |
216 | void CaptureMouse(); | |
8bf5d46e RD |
217 | void Center(int direction = wxBOTH); |
218 | void Centre(int direction = wxBOTH); | |
219 | void CentreOnParent(int direction = wxBOTH ); | |
220 | void CenterOnParent(int direction = wxBOTH ); | |
3ca6a5f0 BP |
221 | void CentreOnScreen(int direction = wxBOTH ); |
222 | void CenterOnScreen(int direction = wxBOTH ); | |
efc5f224 RD |
223 | |
224 | // (uses apply'ed INOUT typemap, see above) | |
225 | %name(ClientToScreenXY)void ClientToScreen(int* x, int* y); | |
af309447 | 226 | wxPoint ClientToScreen(const wxPoint& pt); |
efc5f224 | 227 | |
7bf85405 RD |
228 | bool Close(int force = FALSE); |
229 | bool Destroy(); | |
230 | void DestroyChildren(); | |
853b255a | 231 | #ifdef __WXMSW__ |
7bf85405 | 232 | void DragAcceptFiles(bool accept); |
853b255a | 233 | #endif |
7bf85405 RD |
234 | void Enable(bool enable); |
235 | //bool FakePopupMenu(wxMenu* menu, int x, int y); | |
af309447 | 236 | %name(FindWindowById) wxWindow* FindWindow(long id); |
714e6a9e | 237 | %name(FindWindowByName) wxWindow* FindWindow(const wxString& name); |
7bf85405 RD |
238 | void Fit(); |
239 | wxColour GetBackgroundColour(); | |
d426c97e RD |
240 | |
241 | //wxList& GetChildren(); | |
242 | %addmethods { | |
243 | PyObject* GetChildren() { | |
244 | wxWindowList& list = self->GetChildren(); | |
245 | return wxPy_ConvertList(&list, "wxWindow"); | |
246 | } | |
247 | } | |
248 | ||
7bf85405 RD |
249 | int GetCharHeight(); |
250 | int GetCharWidth(); | |
b8b8dda7 RD |
251 | %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT); |
252 | wxSize GetClientSize(); | |
7bf85405 | 253 | wxLayoutConstraints * GetConstraints(); |
3ab72185 | 254 | wxEvtHandler* GetEventHandler(); |
105e45b9 | 255 | |
b8b8dda7 | 256 | wxFont& GetFont(); |
7bf85405 RD |
257 | wxColour GetForegroundColour(); |
258 | wxWindow * GetGrandParent(); | |
2abc0a0f RD |
259 | %addmethods { |
260 | long GetHandle() { | |
54b96882 | 261 | return wxPyGetWinHandle(self); //(long)self->GetHandle(); |
2abc0a0f RD |
262 | } |
263 | } | |
7bf85405 | 264 | int GetId(); |
853b255a | 265 | wxString GetLabel(); |
bb0054cd | 266 | void SetLabel(const wxString& label); |
853b255a | 267 | wxString GetName(); |
7bf85405 | 268 | wxWindow * GetParent(); |
b8b8dda7 RD |
269 | %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT); |
270 | wxPoint GetPosition(); | |
271 | wxRect GetRect(); | |
7bf85405 RD |
272 | int GetScrollThumb(int orientation); |
273 | int GetScrollPos(int orientation); | |
274 | int GetScrollRange(int orientation); | |
b8b8dda7 RD |
275 | %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT); |
276 | wxSize GetSize(); | |
af309447 RD |
277 | void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT); |
278 | %name(GetFullTextExtent)void GetTextExtent(const wxString& string, | |
279 | int *OUTPUT, int *OUTPUT, int *OUTPUT, int* OUTPUT, | |
280 | const wxFont* font = NULL); //, bool use16 = FALSE) | |
853b255a | 281 | wxString GetTitle(); |
8bf5d46e | 282 | wxRegion GetUpdateRegion(); |
7bf85405 | 283 | long GetWindowStyleFlag(); |
f6bcfd97 BP |
284 | void SetWindowStyleFlag(long style); |
285 | void SetWindowStyle(long style); | |
bb0054cd | 286 | bool Hide(); |
7bf85405 RD |
287 | void InitDialog(); |
288 | bool IsEnabled(); | |
1b55cabf RD |
289 | bool IsExposed( int x, int y, int w=0, int h=0 ); |
290 | %name(IsExposedPoint) bool IsExposed( const wxPoint& pt ); | |
291 | %name(IsExposedRect) bool IsExposed( const wxRect& rect ); | |
7bf85405 RD |
292 | bool IsRetained(); |
293 | bool IsShown(); | |
bb0054cd | 294 | bool IsTopLevel(); |
7bf85405 RD |
295 | void Layout(); |
296 | bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL); | |
297 | void Lower(); | |
298 | void MakeModal(bool flag); | |
af309447 RD |
299 | %name(MoveXY)void Move(int x, int y); |
300 | void Move(const wxPoint& point); | |
7bf85405 | 301 | |
3ab72185 RD |
302 | wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE); |
303 | void PushEventHandler(wxEvtHandler* handler); | |
7bf85405 | 304 | |
8bf5d46e RD |
305 | %name(PopupMenuXY)bool PopupMenu(wxMenu *menu, int x, int y); |
306 | bool PopupMenu(wxMenu *menu, const wxPoint& pos); | |
307 | ||
7bf85405 RD |
308 | void Raise(); |
309 | void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL); | |
310 | void ReleaseMouse(); | |
b7e72427 | 311 | void RemoveChild(wxWindow* child); |
bb0054cd RD |
312 | bool Reparent( wxWindow* newParent ); |
313 | ||
efc5f224 RD |
314 | // (uses apply'ed INOUT typemap, see above) |
315 | %name(ScreenToClientXY)void ScreenToClient(int *x, int *y); | |
af309447 RD |
316 | wxPoint ScreenToClient(const wxPoint& pt); |
317 | ||
7bf85405 | 318 | void ScrollWindow(int dx, int dy, const wxRect* rect = NULL); |
b8b8dda7 | 319 | void SetAcceleratorTable(const wxAcceleratorTable& accel); |
7bf85405 | 320 | void SetAutoLayout(bool autoLayout); |
1dec68aa | 321 | bool GetAutoLayout(); |
7bf85405 RD |
322 | void SetBackgroundColour(const wxColour& colour); |
323 | void SetConstraints(wxLayoutConstraints *constraints); | |
2f90df85 | 324 | void UnsetConstraints(wxLayoutConstraints *constraints); |
7bf85405 | 325 | void SetFocus(); |
2f90df85 | 326 | bool AcceptsFocus(); |
7bf85405 RD |
327 | void SetFont(const wxFont& font); |
328 | void SetForegroundColour(const wxColour& colour); | |
329 | void SetId(int id); | |
330 | void SetName(const wxString& name); | |
eb715945 | 331 | void SetScrollbar(int orientation, int position, int thumbSize, int range, int refresh = TRUE); |
7bf85405 RD |
332 | void SetScrollPos(int orientation, int pos, bool refresh = TRUE); |
333 | ||
7bf85405 RD |
334 | %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO); |
335 | %addmethods { | |
336 | void SetSize(const wxSize& size) { | |
b7e72427 | 337 | self->SetSize(size); |
7bf85405 RD |
338 | } |
339 | ||
340 | void SetPosition(const wxPoint& pos) { | |
b7e72427 | 341 | self->Move(pos); |
7bf85405 | 342 | } |
33510773 RD |
343 | |
344 | void SetRect(const wxRect& rect, int sizeFlags=wxSIZE_AUTO) { | |
345 | self->SetSize(rect, sizeFlags); | |
346 | } | |
7bf85405 RD |
347 | } |
348 | ||
349 | void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1); | |
af309447 RD |
350 | %name(SetClientSizeWH)void SetClientSize(int width, int height); |
351 | void SetClientSize(const wxSize& size); | |
7bf85405 | 352 | //void SetPalette(wxPalette* palette); |
7bf85405 | 353 | void SetCursor(const wxCursor&cursor); |
3ab72185 | 354 | void SetEventHandler(wxEvtHandler* handler); |
83b18bab | 355 | void SetExtraStyle(long exStyle); |
7bf85405 RD |
356 | void SetTitle(const wxString& title); |
357 | bool Show(bool show); | |
358 | bool TransferDataFromWindow(); | |
359 | bool TransferDataToWindow(); | |
360 | bool Validate(); | |
361 | void WarpPointer(int x, int y); | |
362 | ||
b8b8dda7 RD |
363 | %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt); |
364 | %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz); | |
365 | ||
cf694132 RD |
366 | %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt); |
367 | %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz); | |
368 | ||
b8b8dda7 RD |
369 | %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt); |
370 | %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz); | |
371 | ||
af309447 RD |
372 | %name(SetToolTipString)void SetToolTip(const wxString &tip); |
373 | void SetToolTip(wxToolTip *tooltip); | |
374 | wxToolTip* GetToolTip(); | |
2f90df85 RD |
375 | |
376 | void SetSizer(wxSizer* sizer); | |
f6bcfd97 BP |
377 | wxSizer* GetSizer(); |
378 | ||
2f90df85 RD |
379 | wxValidator* GetValidator(); |
380 | void SetValidator(const wxValidator& validator); | |
381 | ||
b1462dfa RD |
382 | void SetDropTarget(wxDropTarget* target); |
383 | wxDropTarget* GetDropTarget(); | |
384 | %pragma(python) addtomethod = "SetDropTarget:_args[0].thisown = 0" | |
694759cf RD |
385 | |
386 | wxSize GetBestSize(); | |
a1df7a95 RD |
387 | |
388 | void SetCaret(wxCaret *caret); | |
389 | wxCaret *GetCaret(); | |
c368d904 | 390 | %pragma(python) addtoclass = "# replaces broken shadow methods |
a1df7a95 RD |
391 | def GetCaret(self, *_args, **_kwargs): |
392 | from misc2 import wxCaretPtr | |
393 | val = apply(windowsc.wxWindow_GetCaret,(self,) + _args, _kwargs) | |
394 | if val: val = wxCaretPtr(val) | |
395 | return val | |
f6bcfd97 | 396 | |
c368d904 RD |
397 | def GetSizer(self, *_args, **_kwargs): |
398 | from sizers import wxSizerPtr | |
399 | val = apply(windowsc.wxWindow_GetSizer,(self,) + _args, _kwargs) | |
400 | if val: val = wxSizerPtr(val) | |
401 | return val | |
f6bcfd97 | 402 | |
c368d904 RD |
403 | def GetToolTip(self, *_args, **_kwargs): |
404 | from misc2 import wxToolTipPtr | |
405 | val = apply(windowsc.wxWindow_GetToolTip,(self,) + _args, _kwargs) | |
406 | if val: val = wxToolTipPtr(val) | |
407 | return val | |
f6bcfd97 | 408 | " |
c368d904 RD |
409 | |
410 | ||
411 | // // Properties list | |
412 | // %pragma(python) addtoclass = " | |
413 | // _prop_list_ = { | |
414 | // 'size' : ('GetSize', 'SetSize'), | |
415 | // 'enabled' : ('IsEnabled', 'Enable'), | |
416 | // 'background' : ('GetBackgroundColour', 'SetBackgroundColour'), | |
417 | // 'foreground' : ('GetForegroundColour', 'SetForegroundColour'), | |
418 | // 'children' : ('GetChildren', None), | |
419 | // 'charHeight' : ('GetCharHeight', None), | |
420 | // 'charWidth' : ('GetCharWidth', None), | |
421 | // 'clientSize' : ('GetClientSize', 'SetClientSize'), | |
422 | // 'font' : ('GetFont', 'SetFont'), | |
423 | // 'grandParent' : ('GetGrandParent', None), | |
424 | // 'handle' : ('GetHandle', None), | |
425 | // 'label' : ('GetLabel', 'SetLabel'), | |
426 | // 'name' : ('GetName', 'SetName'), | |
427 | // 'parent' : ('GetParent', None), | |
428 | // 'position' : ('GetPosition', 'SetPosition'), | |
429 | // 'title' : ('GetTitle', 'SetTitle'), | |
430 | // 'style' : ('GetWindowStyleFlag', 'SetWindowStyleFlag'), | |
431 | // 'visible' : ('IsShown', 'Show'), | |
432 | // 'toolTip' : ('GetToolTip', 'SetToolTip'), | |
433 | // 'sizer' : ('GetSizer', 'SetSizer'), | |
434 | // 'validator' : ('GetValidator', 'SetValidator'), | |
435 | // 'dropTarget' : ('GetDropTarget', 'SetDropTarget'), | |
436 | // 'caret' : ('GetCaret', 'SetCaret'), | |
437 | // 'autoLayout' : ('GetAutoLayout', 'SetAutoLayout'), | |
438 | // 'constraints' : ('GetConstraints', 'SetConstraints'), | |
439 | ||
440 | // } | |
441 | // _prop_list_.update(wxEvtHandler._prop_list_) | |
442 | // " | |
7bf85405 RD |
443 | }; |
444 | ||
efc5f224 RD |
445 | |
446 | ||
447 | ||
b8b8dda7 | 448 | %pragma(python) code = " |
bb0054cd RD |
449 | def wxDLG_PNT(win, point_or_x, y=None): |
450 | if y is None: | |
451 | return win.ConvertDialogPointToPixels(point_or_x) | |
452 | else: | |
453 | return win.ConvertDialogPointToPixels(wxPoint(point_or_x, y)) | |
454 | ||
455 | def wxDLG_SZE(win, size_width, height=None): | |
456 | if height is None: | |
457 | return win.ConvertDialogSizeToPixels(size_width) | |
458 | else: | |
459 | return win.ConvertDialogSizeToPixels(wxSize(size_width, height)) | |
b8b8dda7 | 460 | " |
7bf85405 | 461 | |
7bf85405 RD |
462 | %inline %{ |
463 | wxWindow* wxWindow_FindFocus() { | |
464 | return wxWindow::FindFocus(); | |
465 | } | |
466 | %} | |
af309447 RD |
467 | |
468 | ||
c368d904 | 469 | #ifdef __WXMSW__ |
af309447 RD |
470 | %inline %{ |
471 | wxWindow* wxWindow_FromHWND(unsigned long hWnd) { | |
472 | wxWindow* win = new wxWindow; | |
473 | win->SetHWND(hWnd); | |
474 | win->SubclassWin(hWnd); | |
475 | return win; | |
476 | } | |
477 | %} | |
853b255a | 478 | #endif |
7bf85405 | 479 | |
a1df7a95 RD |
480 | %inline %{ |
481 | int wxWindow_NewControlId() { | |
482 | return wxWindow::NewControlId(); | |
483 | } | |
484 | int wxWindow_NextControlId(int id) { | |
485 | return wxWindow::NextControlId(id); | |
486 | } | |
487 | int wxWindow_PrevControlId(int id) { | |
488 | return wxWindow::PrevControlId(id); | |
489 | } | |
490 | %} | |
7bf85405 | 491 | |
efc5f224 | 492 | |
7bf85405 RD |
493 | //--------------------------------------------------------------------------- |
494 | ||
495 | class wxPanel : public wxWindow { | |
496 | public: | |
497 | wxPanel(wxWindow* parent, | |
498 | const wxWindowID id, | |
b68dc582 RD |
499 | const wxPoint& pos = wxDefaultPosition, |
500 | const wxSize& size = wxDefaultSize, | |
7bf85405 RD |
501 | long style = wxTAB_TRAVERSAL, |
502 | const char* name = "panel"); | |
503 | ||
f6bcfd97 | 504 | %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)" |
9c039d08 | 505 | |
7bf85405 | 506 | void InitDialog(); |
bb0054cd RD |
507 | wxButton* GetDefaultItem(); |
508 | void SetDefaultItem(wxButton *btn); | |
509 | ||
3ab72185 | 510 | // fix some SWIG trouble... |
bb0054cd RD |
511 | %pragma(python) addtoclass = " |
512 | def GetDefaultItem(self): | |
513 | import controls | |
514 | val = windowsc.wxPanel_GetDefaultItem(self.this) | |
515 | val = controls.wxButtonPtr(val) | |
516 | return val | |
517 | " | |
7bf85405 RD |
518 | }; |
519 | ||
520 | //--------------------------------------------------------------------------- | |
521 | ||
522 | class wxDialog : public wxPanel { | |
523 | public: | |
524 | wxDialog(wxWindow* parent, | |
525 | const wxWindowID id, | |
526 | const wxString& title, | |
b68dc582 RD |
527 | const wxPoint& pos = wxDefaultPosition, |
528 | const wxSize& size = wxDefaultSize, | |
7bf85405 RD |
529 | long style = wxDEFAULT_DIALOG_STYLE, |
530 | const char* name = "dialogBox"); | |
531 | ||
f6bcfd97 | 532 | %pragma(python) addtomethod = "__init__:#wx._StdDialogCallbacks(self)" |
9c039d08 | 533 | |
7bf85405 RD |
534 | void Centre(int direction = wxBOTH); |
535 | void EndModal(int retCode); | |
536 | wxString GetTitle(); | |
537 | void Iconize(bool iconize); | |
538 | bool IsIconized(); | |
7bf85405 | 539 | void SetModal(bool flag); |
853b255a | 540 | bool IsModal(); |
7bf85405 RD |
541 | void SetTitle(const wxString& title); |
542 | bool Show(bool show); | |
543 | int ShowModal(); | |
4cd9591a RD |
544 | |
545 | int GetReturnCode(); | |
546 | void SetReturnCode(int retCode); | |
f3d9dc1d RD |
547 | |
548 | wxSizer* CreateTextSizer( const wxString &message ); | |
549 | wxSizer* CreateButtonSizer( long flags ); | |
550 | ||
551 | %pragma(python) addtoclass = " | |
552 | # replace swig generated shadow methods to resolve import issues | |
553 | def CreateTextSizer(self, *_args, **_kwargs): | |
554 | import sizers | |
555 | val = apply(windowsc.wxDialog_CreateTextSizer,(self,) + _args, _kwargs) | |
556 | if val: val = sizers.wxSizerPtr(val) | |
557 | return val | |
558 | def CreateButtonSizer(self, *_args, **_kwargs): | |
559 | import sizers | |
560 | val = apply(windowsc.wxDialog_CreateButtonSizer,(self,) + _args, _kwargs) | |
561 | if val: val = sizers.wxSizerPtr(val) | |
562 | return val | |
563 | " | |
564 | ||
7bf85405 RD |
565 | }; |
566 | ||
567 | //--------------------------------------------------------------------------- | |
568 | ||
bb0054cd | 569 | class wxScrolledWindow : public wxPanel { |
7bf85405 RD |
570 | public: |
571 | wxScrolledWindow(wxWindow* parent, | |
572 | const wxWindowID id = -1, | |
b68dc582 RD |
573 | const wxPoint& pos = wxDefaultPosition, |
574 | const wxSize& size = wxDefaultSize, | |
7bf85405 RD |
575 | long style = wxHSCROLL | wxVSCROLL, |
576 | char* name = "scrolledWindow"); | |
577 | ||
f6bcfd97 BP |
578 | %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)" |
579 | %pragma(python) addtomethod = "__init__:#wx._StdOnScrollCallbacks(self)" | |
9c039d08 | 580 | |
7bf85405 | 581 | void EnableScrolling(bool xScrolling, bool yScrolling); |
b7e72427 | 582 | int GetScrollPageSize(int orient); |
7bf85405 | 583 | void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT); |
b7e72427 | 584 | wxWindow* GetTargetWindow(); |
7bf85405 RD |
585 | void GetVirtualSize(int* OUTPUT, int* OUTPUT); |
586 | bool IsRetained(); | |
587 | void PrepareDC(wxDC& dc); | |
588 | void Scroll(int x, int y); | |
589 | void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY, | |
590 | int noUnitsX, int noUnitsY, | |
f6bcfd97 | 591 | int xPos = 0, int yPos = 0, int noRefresh=FALSE); |
b7e72427 | 592 | void SetScrollPageSize(int orient, int pageSize); |
eb715945 | 593 | void SetTargetWindow(wxWindow* window); |
4c9993c3 | 594 | void GetViewStart(int* OUTPUT, int* OUTPUT); |
7bf85405 | 595 | void ViewStart(int* OUTPUT, int* OUTPUT); |
9d8bd15f RD |
596 | |
597 | void CalcScrolledPosition( int x, int y, int *OUTPUT, int *OUTPUT); | |
598 | void CalcUnscrolledPosition( int x, int y, int *OUTPUT, int *OUTPUT); | |
599 | ||
d1679124 RD |
600 | void SetScale(double xs, double ys); |
601 | double GetScaleX(); | |
602 | double GetScaleY(); | |
603 | ||
604 | void AdjustScrollbars(); | |
7bf85405 RD |
605 | }; |
606 | ||
607 | //---------------------------------------------------------------------- | |
608 | ||
609 | ||
610 | class wxMenu : public wxEvtHandler { | |
611 | public: | |
8bf5d46e | 612 | wxMenu(const wxString& title = wxPyEmptyStr, long style = 0); |
7bf85405 RD |
613 | |
614 | void Append(int id, const wxString& item, | |
615 | const wxString& helpString = wxPyEmptyStr, | |
926bb76c | 616 | int checkable = FALSE); |
7bf85405 RD |
617 | %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu, |
618 | const wxString& helpString = wxPyEmptyStr); | |
af309447 RD |
619 | %name(AppendItem)void Append(const wxMenuItem* item); |
620 | ||
7bf85405 RD |
621 | void AppendSeparator(); |
622 | void Break(); | |
623 | void Check(int id, bool flag); | |
b1462dfa | 624 | bool IsChecked(int id); |
7bf85405 | 625 | void Enable(int id, bool enable); |
b1462dfa RD |
626 | bool IsEnabled(int id); |
627 | ||
7bf85405 | 628 | int FindItem(const wxString& itemString); |
b1462dfa RD |
629 | %name(FindItemById)wxMenuItem* FindItem(int id/*, wxMenu **menu = NULL*/); |
630 | ||
7bf85405 | 631 | wxString GetTitle(); |
7bf85405 | 632 | void SetTitle(const wxString& title); |
b1462dfa | 633 | |
714e6a9e | 634 | wxString GetLabel(int id); |
853b255a | 635 | void SetLabel(int id, const wxString& label); |
b1462dfa RD |
636 | |
637 | wxString GetHelpString(int id); | |
638 | void SetHelpString(int id, const wxString& helpString); | |
8bf5d46e | 639 | void UpdateUI(wxEvtHandler* source = NULL); |
efc5f224 | 640 | |
b1462dfa RD |
641 | bool Delete(int id); |
642 | %name(DeleteItem)bool Delete(wxMenuItem *item); | |
643 | bool Insert(size_t pos, wxMenuItem *item); | |
644 | wxMenuItem *Remove(int id); | |
645 | %name(RemoveItem) wxMenuItem *Remove(wxMenuItem *item); | |
646 | ||
efc5f224 | 647 | %addmethods { |
eb715945 | 648 | void Destroy() { delete self; } |
efc5f224 | 649 | } |
b1462dfa RD |
650 | %name(DestroyId)bool Destroy(int id); |
651 | %name(DestroyItem)bool Destroy(wxMenuItem *item); | |
efc5f224 | 652 | |
b1462dfa RD |
653 | size_t GetMenuItemCount(); |
654 | //wxMenuItemList& GetMenuItems(); | |
655 | %addmethods { | |
656 | PyObject* GetMenuItems() { | |
657 | wxMenuItemList& list = self->GetMenuItems(); | |
658 | return wxPy_ConvertList(&list, "wxMenuItem"); | |
659 | } | |
660 | } | |
7bf85405 | 661 | |
b1462dfa RD |
662 | void SetEventHandler(wxEvtHandler *handler); |
663 | wxEvtHandler *GetEventHandler(); | |
664 | ||
665 | void SetInvokingWindow(wxWindow *win); | |
666 | wxWindow *GetInvokingWindow(); | |
667 | ||
668 | long GetStyle(); | |
669 | ||
670 | bool IsAttached(); | |
671 | ||
672 | void SetParent(wxMenu *parent); | |
673 | wxMenu *GetParent(); | |
674 | }; | |
7bf85405 | 675 | |
7bf85405 RD |
676 | |
677 | //---------------------------------------------------------------------- | |
678 | ||
b1462dfa | 679 | class wxMenuBar : public wxWindow { |
7bf85405 | 680 | public: |
c368d904 | 681 | wxMenuBar(long style = 0); |
7bf85405 | 682 | |
b1462dfa RD |
683 | bool Append(wxMenu *menu, const wxString& title); |
684 | bool Insert(size_t pos, wxMenu *menu, const wxString& title); | |
685 | size_t GetMenuCount(); | |
686 | wxMenu *GetMenu(size_t pos); | |
687 | wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title); | |
688 | wxMenu *Remove(size_t pos); | |
689 | void EnableTop(size_t pos, bool enable); | |
690 | void SetLabelTop(size_t pos, const wxString& label); | |
691 | wxString GetLabelTop(size_t pos); | |
692 | int FindMenuItem(const wxString& menuString, const wxString& itemString); | |
693 | %name(FindItemById)wxMenuItem* FindItem(int id/*, wxMenu **menu = NULL*/); | |
7bf85405 | 694 | void Enable(int id, bool enable); |
b1462dfa | 695 | void Check(int id, bool check); |
2abc0a0f RD |
696 | bool IsChecked(int id); |
697 | bool IsEnabled(int id); | |
b1462dfa RD |
698 | |
699 | void SetLabel(int id, const wxString &label); | |
7bf85405 | 700 | wxString GetLabel(int id); |
b1462dfa | 701 | |
7bf85405 | 702 | void SetHelpString(int id, const wxString& helpString); |
b1462dfa | 703 | wxString GetHelpString(int id); |
2abc0a0f | 704 | |
7bf85405 RD |
705 | }; |
706 | ||
707 | ||
708 | //---------------------------------------------------------------------- | |
709 | ||
710 | class wxMenuItem { | |
711 | public: | |
4c9993c3 | 712 | wxMenuItem(wxMenu* parentMenu=NULL, int id=wxID_SEPARATOR, |
cf694132 | 713 | const wxString& text = wxPyEmptyStr, |
b1462dfa RD |
714 | const wxString& help = wxPyEmptyStr, |
715 | bool isCheckable = FALSE, wxMenu* subMenu = NULL); | |
cf694132 | 716 | |
b1462dfa RD |
717 | |
718 | wxMenu *GetMenu(); | |
2abc0a0f | 719 | void SetId(int id); |
b1462dfa RD |
720 | int GetId(); |
721 | bool IsSeparator(); | |
2abc0a0f | 722 | void SetText(const wxString& str); |
b1462dfa | 723 | wxString GetLabel(); |
2abc0a0f | 724 | const wxString& GetText(); |
2abc0a0f | 725 | void SetCheckable(bool checkable); |
b1462dfa RD |
726 | bool IsCheckable(); |
727 | bool IsSubMenu(); | |
2abc0a0f | 728 | void SetSubMenu(wxMenu *menu); |
b1462dfa RD |
729 | wxMenu *GetSubMenu(); |
730 | void Enable(bool enable = TRUE); | |
731 | bool IsEnabled(); | |
732 | void Check(bool check = TRUE); | |
733 | bool IsChecked(); | |
734 | void Toggle(); | |
735 | void SetHelp(const wxString& str); | |
736 | const wxString& GetHelp(); | |
737 | wxAcceleratorEntry *GetAccel(); | |
738 | void SetAccel(wxAcceleratorEntry *accel); | |
739 | ||
1b62f00d RD |
740 | static wxString GetLabelFromText(const wxString& text); |
741 | ||
f3d9dc1d | 742 | // wxOwnerDrawn methods |
4662be59 | 743 | #ifdef __WXMSW__ |
f3d9dc1d RD |
744 | void SetFont(const wxFont& font); |
745 | wxFont& GetFont(); | |
746 | void SetTextColour(const wxColour& colText); | |
747 | wxColour& GetTextColour(); | |
748 | void SetBackgroundColour(const wxColour& colBack); | |
749 | wxColour& GetBackgroundColour(); | |
750 | void SetBitmaps(const wxBitmap& bmpChecked, | |
751 | const wxBitmap& bmpUnchecked = wxNullBitmap); | |
752 | void SetBitmap(const wxBitmap& bmpChecked); | |
753 | const wxBitmap& GetBitmap(bool bChecked = TRUE); | |
754 | void SetMarginWidth(int nWidth); | |
755 | int GetMarginWidth(); | |
756 | static int GetDefaultMarginWidth(); | |
757 | //void SetName(const wxString& strName); | |
758 | //const wxString& GetName(); | |
759 | //void SetCheckable(bool checkable); | |
760 | //bool IsCheckable(); | |
761 | bool IsOwnerDrawn(); | |
762 | void ResetOwnerDrawn(); | |
4662be59 | 763 | #endif |
7bf85405 RD |
764 | }; |
765 | ||
766 | //--------------------------------------------------------------------------- | |
7bf85405 RD |
767 | |
768 | ||
694759cf | 769 |