]>
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 | #include <wx/tooltip.h> | |
20 | %} | |
21 | ||
22 | //---------------------------------------------------------------------- | |
23 | ||
24 | %include typemaps.i | |
25 | %include my_typemaps.i | |
26 | ||
27 | // Import some definitions of other classes, etc. | |
28 | %import _defs.i | |
29 | %import misc.i | |
30 | %import gdi.i | |
31 | %import clip_dnd.i | |
32 | ||
33 | %pragma(python) code = "import wx" | |
34 | ||
35 | ||
36 | //---------------------------------------------------------------------- | |
37 | ||
38 | %{ | |
39 | // Put some wx default wxChar* values into wxStrings. | |
40 | DECLARE_DEF_STRING(PanelNameStr); | |
41 | static const wxString wxPyEmptyString(wxT("")); | |
42 | %} | |
43 | ||
44 | //--------------------------------------------------------------------------- | |
45 | ||
46 | class wxEvtHandler : public wxObject { | |
47 | public: | |
48 | wxEvtHandler(); | |
49 | ||
50 | bool ProcessEvent(wxEvent& event); | |
51 | void AddPendingEvent(wxEvent& event); | |
52 | //bool SearchEventTable(wxEventTable& table, wxEvent& event); | |
53 | ||
54 | bool GetEvtHandlerEnabled(); | |
55 | void SetEvtHandlerEnabled(bool enabled); | |
56 | ||
57 | wxEvtHandler* GetNextHandler(); | |
58 | wxEvtHandler* GetPreviousHandler(); | |
59 | void SetNextHandler(wxEvtHandler* handler); | |
60 | void SetPreviousHandler(wxEvtHandler* handler); | |
61 | ||
62 | ||
63 | %addmethods { | |
64 | void Connect( int id, int lastId, int eventType, PyObject* func) { | |
65 | if (PyCallable_Check(func)) { | |
66 | self->Connect(id, lastId, eventType, | |
67 | (wxObjectEventFunction) &wxPyCallback::EventThunker, | |
68 | new wxPyCallback(func)); | |
69 | } | |
70 | else if (func == Py_None) { | |
71 | self->Disconnect(id, lastId, eventType, | |
72 | (wxObjectEventFunction) | |
73 | &wxPyCallback::EventThunker); | |
74 | } | |
75 | else { | |
76 | PyErr_SetString(PyExc_TypeError, "Expected callable object or None."); | |
77 | } | |
78 | } | |
79 | ||
80 | bool Disconnect(int id, int lastId = -1, | |
81 | wxEventType eventType = wxEVT_NULL) { | |
82 | return self->Disconnect(id, lastId, eventType, | |
83 | (wxObjectEventFunction) | |
84 | &wxPyCallback::EventThunker); | |
85 | } | |
86 | } | |
87 | ||
88 | %addmethods { | |
89 | void _setOORInfo(PyObject* _self) { | |
90 | self->SetClientObject(new wxPyOORClientData(_self)); | |
91 | } | |
92 | } | |
93 | }; | |
94 | ||
95 | ||
96 | //---------------------------------------------------------------------- | |
97 | ||
98 | class wxValidator : public wxEvtHandler { | |
99 | public: | |
100 | wxValidator(); | |
101 | //~wxValidator(); | |
102 | ||
103 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
104 | ||
105 | wxValidator* Clone(); | |
106 | wxWindow* GetWindow(); | |
107 | void SetWindow(wxWindow* window); | |
108 | ||
109 | static bool IsSilent(); | |
110 | static void SetBellOnError(int doIt = TRUE); | |
111 | ||
112 | }; | |
113 | ||
114 | ||
115 | //---------------------------------------------------------------------- | |
116 | %{ | |
117 | class wxPyValidator : public wxValidator { | |
118 | DECLARE_DYNAMIC_CLASS(wxPyValidator); | |
119 | public: | |
120 | wxPyValidator() { | |
121 | } | |
122 | ||
123 | ~wxPyValidator() { | |
124 | } | |
125 | ||
126 | wxObject* Clone() const { | |
127 | wxPyValidator* ptr = NULL; | |
128 | wxPyValidator* self = (wxPyValidator*)this; | |
129 | ||
130 | wxPyBeginBlockThreads(); | |
131 | if (self->m_myInst.findCallback("Clone")) { | |
132 | PyObject* ro; | |
133 | ro = self->m_myInst.callCallbackObj(Py_BuildValue("()")); | |
134 | if (ro) { | |
135 | SWIG_GetPtrObj(ro, (void **)&ptr, "_wxPyValidator_p"); | |
136 | Py_DECREF(ro); | |
137 | } | |
138 | } | |
139 | wxPyEndBlockThreads(); | |
140 | ||
141 | // This is very dangerous!!! But is the only way I could find | |
142 | // to squash a memory leak. Currently it is okay, but if the | |
143 | // validator architecture in wxWindows ever changes, problems | |
144 | // could arise. | |
145 | delete self; | |
146 | return ptr; | |
147 | } | |
148 | ||
149 | ||
150 | DEC_PYCALLBACK_BOOL_WXWIN(Validate); | |
151 | DEC_PYCALLBACK_BOOL_(TransferToWindow); | |
152 | DEC_PYCALLBACK_BOOL_(TransferFromWindow); | |
153 | ||
154 | PYPRIVATE; | |
155 | }; | |
156 | ||
157 | IMP_PYCALLBACK_BOOL_WXWIN(wxPyValidator, wxValidator, Validate); | |
158 | IMP_PYCALLBACK_BOOL_(wxPyValidator, wxValidator, TransferToWindow); | |
159 | IMP_PYCALLBACK_BOOL_(wxPyValidator, wxValidator, TransferFromWindow); | |
160 | ||
161 | IMPLEMENT_DYNAMIC_CLASS(wxPyValidator, wxValidator); | |
162 | ||
163 | %} | |
164 | ||
165 | class wxPyValidator : public wxValidator { | |
166 | public: | |
167 | wxPyValidator(); | |
168 | ||
169 | void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=TRUE); | |
170 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyValidator, 1)" | |
171 | ||
172 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
173 | }; | |
174 | ||
175 | //---------------------------------------------------------------------- | |
176 | ||
177 | %apply int * INOUT { int* x, int* y }; | |
178 | ||
179 | class wxWindow : public wxEvtHandler { | |
180 | public: | |
181 | wxWindow(wxWindow* parent, const wxWindowID id, | |
182 | const wxPoint& pos = wxDefaultPosition, | |
183 | const wxSize& size = wxDefaultSize, | |
184 | long style = 0, | |
185 | const wxString& name = wxPyPanelNameStr); | |
186 | %name(wxPreWindow)wxWindow(); | |
187 | ||
188 | bool Create(wxWindow* parent, const wxWindowID id, | |
189 | const wxPoint& pos = wxDefaultPosition, | |
190 | const wxSize& size = wxDefaultSize, | |
191 | long style = 0, | |
192 | const wxString& name = wxPyPanelNameStr); | |
193 | ||
194 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
195 | %pragma(python) addtomethod = "wxPreWindow:val._setOORInfo(val)" | |
196 | ||
197 | ||
198 | void Center(int direction = wxBOTH); | |
199 | void Centre(int direction = wxBOTH); | |
200 | void CentreOnParent(int direction = wxBOTH ); | |
201 | void CenterOnParent(int direction = wxBOTH ); | |
202 | void CentreOnScreen(int direction = wxBOTH ); | |
203 | void CenterOnScreen(int direction = wxBOTH ); | |
204 | ||
205 | void ClearBackground(); | |
206 | ||
207 | // (uses apply'ed INOUT typemap, see above) | |
208 | %name(ClientToScreenXY)void ClientToScreen(int* x, int* y); | |
209 | wxPoint ClientToScreen(const wxPoint& pt); | |
210 | ||
211 | bool Close(int force = FALSE); | |
212 | bool Destroy(); | |
213 | void DestroyChildren(); | |
214 | bool IsBeingDeleted(); | |
215 | #ifdef __WXMSW__ | |
216 | void DragAcceptFiles(bool accept); | |
217 | #endif | |
218 | void Enable(bool enable); | |
219 | void Disable(); | |
220 | ||
221 | // Find child window by ID or name | |
222 | %name(FindWindowById) wxWindow* FindWindow(long id); | |
223 | %name(FindWindowByName) wxWindow* FindWindow(const wxString& name); | |
224 | ||
225 | void Fit(); | |
226 | ||
227 | // set virtual size to satisfy children | |
228 | void FitInside(); | |
229 | ||
230 | wxColour GetBackgroundColour(); | |
231 | ||
232 | //wxList& GetChildren(); | |
233 | %addmethods { | |
234 | PyObject* GetChildren() { | |
235 | wxWindowList& list = self->GetChildren(); | |
236 | return wxPy_ConvertList(&list, "wxWindow"); | |
237 | } | |
238 | } | |
239 | ||
240 | int GetCharHeight(); | |
241 | int GetCharWidth(); | |
242 | %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT); | |
243 | wxSize GetClientSize(); | |
244 | ||
245 | // get the origin of the client area of the window relative to the | |
246 | // window top left corner (the client area may be shifted because of | |
247 | // the borders, scrollbars, other decorations...) | |
248 | wxPoint GetClientAreaOrigin() const; | |
249 | ||
250 | // get the client rectangle in window (i.e. client) coordinates | |
251 | wxRect GetClientRect() const; | |
252 | ||
253 | wxLayoutConstraints * GetConstraints(); | |
254 | wxEvtHandler* GetEventHandler(); | |
255 | ||
256 | wxFont GetFont(); | |
257 | wxColour GetForegroundColour(); | |
258 | wxWindow * GetGrandParent(); | |
259 | %addmethods { | |
260 | long GetHandle() { | |
261 | return wxPyGetWinHandle(self); //(long)self->GetHandle(); | |
262 | } | |
263 | } | |
264 | int GetId(); | |
265 | wxString GetLabel(); | |
266 | void SetLabel(const wxString& label); | |
267 | wxString GetName(); | |
268 | wxWindow * GetParent(); | |
269 | %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT); | |
270 | wxPoint GetPosition(); | |
271 | wxRect GetRect(); | |
272 | int GetScrollThumb(int orientation); | |
273 | int GetScrollPos(int orientation); | |
274 | int GetScrollRange(int orientation); | |
275 | %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT); | |
276 | wxSize GetSize(); | |
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) | |
281 | wxString GetTitle(); | |
282 | wxRegion GetUpdateRegion(); | |
283 | long GetWindowStyleFlag(); | |
284 | void SetWindowStyleFlag(long style); | |
285 | void SetWindowStyle(long style); | |
286 | bool HasScrollbar(int orient) const; | |
287 | bool Hide(); | |
288 | wxHitTest HitTest(const wxPoint& pt); | |
289 | void InitDialog(); | |
290 | bool IsEnabled(); | |
291 | bool IsExposed( int x, int y, int w=0, int h=0 ); | |
292 | %name(IsExposedPoint) bool IsExposed( const wxPoint& pt ); | |
293 | %name(IsExposedRect) bool IsExposed( const wxRect& rect ); | |
294 | bool IsRetained(); | |
295 | bool IsShown(); | |
296 | bool IsTopLevel(); | |
297 | void Layout(); | |
298 | #ifdef wxUSE_WX_RESOURCES | |
299 | bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL); | |
300 | #endif | |
301 | void Lower(); | |
302 | void MakeModal(bool flag=TRUE); | |
303 | %name(MoveXY)void Move(int x, int y, int flags = wxSIZE_USE_EXISTING); | |
304 | void Move(const wxPoint& point, int flags = wxSIZE_USE_EXISTING); | |
305 | ||
306 | wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE); | |
307 | void PushEventHandler(wxEvtHandler* handler); | |
308 | ||
309 | // find the given handler in the event handler chain and remove (but | |
310 | // not delete) it from the event handler chain, return TRUE if it was | |
311 | // found and FALSE otherwise (this also results in an assert failure so | |
312 | // this function should only be called when the handler is supposed to | |
313 | // be there) | |
314 | bool RemoveEventHandler(wxEvtHandler *handler); | |
315 | ||
316 | %name(PopupMenuXY)bool PopupMenu(wxMenu *menu, int x, int y); | |
317 | bool PopupMenu(wxMenu *menu, const wxPoint& pos); | |
318 | ||
319 | void Raise(); | |
320 | void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL); | |
321 | void RefreshRect(const wxRect& rect); | |
322 | ||
323 | void AddChild(wxWindow* child); | |
324 | void RemoveChild(wxWindow* child); | |
325 | bool Reparent( wxWindow* newParent ); | |
326 | ||
327 | // (uses apply'ed INOUT typemap, see above) | |
328 | %name(ScreenToClientXY)void ScreenToClient(int *x, int *y); | |
329 | wxPoint ScreenToClient(const wxPoint& pt); | |
330 | ||
331 | void ScrollWindow(int dx, int dy, const wxRect* rect = NULL); | |
332 | void SetAutoLayout(bool autoLayout); | |
333 | bool GetAutoLayout(); | |
334 | void SetBackgroundColour(const wxColour& colour); | |
335 | void SetConstraints(wxLayoutConstraints *constraints); | |
336 | void UnsetConstraints(wxLayoutConstraints *constraints); | |
337 | void SetFocus(); | |
338 | void SetFocusFromKbd(); | |
339 | bool AcceptsFocus(); | |
340 | void SetFont(const wxFont& font); | |
341 | void SetForegroundColour(const wxColour& colour); | |
342 | void SetId(int id); | |
343 | void SetName(const wxString& name); | |
344 | void SetScrollbar(int orientation, int position, int thumbSize, int range, int refresh = TRUE); | |
345 | void SetScrollPos(int orientation, int pos, bool refresh = TRUE); | |
346 | ||
347 | %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO); | |
348 | %addmethods { | |
349 | void SetSize(const wxSize& size) { | |
350 | self->SetSize(size); | |
351 | } | |
352 | ||
353 | void SetPosition(const wxPoint& pos, int flags = wxSIZE_USE_EXISTING) { | |
354 | self->Move(pos, flags); | |
355 | } | |
356 | ||
357 | void SetRect(const wxRect& rect, int sizeFlags=wxSIZE_AUTO) { | |
358 | self->SetSize(rect, sizeFlags); | |
359 | } | |
360 | } | |
361 | ||
362 | void SetSizeHints(int minW, int minH, | |
363 | int maxW=-1, int maxH=-1, | |
364 | int incW=-1, int incH=-1); | |
365 | void SetVirtualSizeHints( int minW, int minH, | |
366 | int maxW = -1, int maxH = -1 ); | |
367 | ||
368 | void SetVirtualSize( const wxSize &size ); | |
369 | %name(SetVirtualSizeWH)void SetVirtualSize( int x, int y ); | |
370 | ||
371 | wxSize GetVirtualSize() const; | |
372 | %name(GetVirtualSizeTuple)void GetVirtualSize( int *OUTPUT, int *OUTPUT ) const; | |
373 | ||
374 | wxSize GetBestVirtualSize(); | |
375 | ||
376 | %name(SetClientSizeWH)void SetClientSize(int width, int height); | |
377 | void SetClientSize(const wxSize& size); | |
378 | //void SetPalette(wxPalette* palette); | |
379 | bool SetCursor(const wxCursor& cursor); | |
380 | wxCursor& GetCursor(); | |
381 | void SetEventHandler(wxEvtHandler* handler); | |
382 | void SetExtraStyle(long exStyle); | |
383 | void SetTitle(const wxString& title); | |
384 | bool Show(bool show=TRUE); | |
385 | bool TransferDataFromWindow(); | |
386 | bool TransferDataToWindow(); | |
387 | ||
388 | // send wxUpdateUIEvents to this window, and children if recurse is TRUE | |
389 | void UpdateWindowUI(long flags = wxUPDATE_UI_NONE); | |
390 | ||
391 | bool Validate(); | |
392 | ||
393 | %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt); | |
394 | %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz); | |
395 | ||
396 | %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt); | |
397 | %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz); | |
398 | ||
399 | %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt); | |
400 | %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz); | |
401 | ||
402 | %name(SetToolTipString)void SetToolTip(const wxString &tip); | |
403 | void SetToolTip(wxToolTip *tooltip); | |
404 | wxToolTip* GetToolTip(); | |
405 | ||
406 | void SetSizer(wxSizer* sizer, bool deleteOld=TRUE); | |
407 | void SetSizerAndFit(wxSizer *sizer, bool deleteOld=TRUE); | |
408 | wxSizer* GetSizer(); | |
409 | ||
410 | // Track if this window is a member of a sizer | |
411 | void SetContainingSizer(wxSizer* sizer); | |
412 | wxSizer *GetContainingSizer() const; | |
413 | ||
414 | wxValidator* GetValidator(); | |
415 | void SetValidator(const wxValidator& validator); | |
416 | ||
417 | void SetDropTarget(wxDropTarget* target); | |
418 | wxDropTarget* GetDropTarget(); | |
419 | %pragma(python) addtomethod = "SetDropTarget:_args[0].thisown = 0" | |
420 | ||
421 | wxSize GetBestSize(); | |
422 | wxSize GetMaxSize(); | |
423 | ||
424 | // There are times (and windows) where 'Best' size and 'Min' size | |
425 | // are vastly out of sync. This should be remedied somehow, but in | |
426 | // the meantime, this method will return the larger of BestSize | |
427 | // (the window's smallest legible size), and any user specified | |
428 | // MinSize hint. | |
429 | wxSize GetAdjustedBestSize(); | |
430 | ||
431 | void SetCaret(wxCaret *caret); | |
432 | wxCaret *GetCaret(); | |
433 | %pragma(python) addtoclass = "# replaces broken shadow method | |
434 | def GetCaret(self, *_args, **_kwargs): | |
435 | from misc2 import wxCaretPtr | |
436 | val = windowsc.wxWindow_GetCaret(self, *_args, **_kwargs) | |
437 | if val: val = wxCaretPtr(val) | |
438 | return val | |
439 | " | |
440 | ||
441 | void Freeze(); | |
442 | void Thaw(); | |
443 | void Update(); | |
444 | ||
445 | wxString GetHelpText(); | |
446 | void SetHelpText(const wxString& helpText); | |
447 | void SetHelpTextForId(const wxString& text); | |
448 | ||
449 | bool ScrollLines(int lines); | |
450 | bool ScrollPages(int pages); | |
451 | bool LineUp(); | |
452 | bool LineDown(); | |
453 | bool PageUp(); | |
454 | bool PageDown(); | |
455 | ||
456 | static wxWindow* FindFocus(); | |
457 | static int NewControlId(); | |
458 | static int NextControlId(int id); | |
459 | static int PrevControlId(int id); | |
460 | ||
461 | void SetAcceleratorTable(const wxAcceleratorTable& accel); | |
462 | wxAcceleratorTable *GetAcceleratorTable(); | |
463 | ||
464 | %addmethods { | |
465 | // hot keys (system wide accelerators) | |
466 | bool RegisterHotKey(int hotkeyId, int modifiers, int keycode) { | |
467 | #if wxUSE_HOTKEY | |
468 | return self->RegisterHotKey(hotkeyId, modifiers, keycode); | |
469 | #else | |
470 | return FALSE; | |
471 | #endif | |
472 | } | |
473 | ||
474 | bool UnregisterHotKey(int hotkeyId) { | |
475 | #if wxUSE_HOTKEY | |
476 | return self->UnregisterHotKey(hotkeyId); | |
477 | #else | |
478 | return FALSE; | |
479 | #endif | |
480 | } | |
481 | } | |
482 | ||
483 | #ifdef __WXMSW__ | |
484 | // A way to do the native draw first... Too bad it isn't in wxGTK too. | |
485 | void OnPaint(wxPaintEvent& event); | |
486 | #endif | |
487 | ||
488 | wxWindow* GetDefaultItem(); | |
489 | wxWindow* SetDefaultItem(wxWindow *btn); | |
490 | void SetTmpDefaultItem(wxWindow *win); | |
491 | ||
492 | // move the mouse to the specified position | |
493 | void WarpPointer(int x, int y); | |
494 | ||
495 | // start or end mouse capture, these functions maintain the stack of | |
496 | // windows having captured the mouse and after calling ReleaseMouse() | |
497 | // the mouse is not released but returns to the window which had had | |
498 | // captured it previously (if any) | |
499 | void CaptureMouse(); | |
500 | void ReleaseMouse(); | |
501 | ||
502 | // get the window which currently captures the mouse or NULL | |
503 | static wxWindow *GetCapture(); | |
504 | ||
505 | // does this window have the capture? | |
506 | bool HasCapture() const; | |
507 | ||
508 | void SetThemeEnabled(bool enable); | |
509 | bool GetThemeEnabled(); | |
510 | ||
511 | // get the window border style from the given flags: this is different from | |
512 | // simply doing flags & wxBORDER_MASK because it uses GetDefaultBorder() to | |
513 | // translate wxBORDER_DEFAULT to something reasonable | |
514 | %name(GetBorderFlags) wxBorder GetBorder(long flags) const; | |
515 | ||
516 | // get border for the flags of this window | |
517 | wxBorder GetBorder() const; | |
518 | ||
519 | }; | |
520 | ||
521 | ||
522 | ||
523 | ||
524 | %pragma(python) code = " | |
525 | def wxDLG_PNT(win, point_or_x, y=None): | |
526 | if y is None: | |
527 | return win.ConvertDialogPointToPixels(point_or_x) | |
528 | else: | |
529 | return win.ConvertDialogPointToPixels(wxPoint(point_or_x, y)) | |
530 | ||
531 | def wxDLG_SZE(win, size_width, height=None): | |
532 | if height is None: | |
533 | return win.ConvertDialogSizeToPixels(size_width) | |
534 | else: | |
535 | return win.ConvertDialogSizeToPixels(wxSize(size_width, height)) | |
536 | " | |
537 | ||
538 | ||
539 | #ifdef __WXMSW__ | |
540 | %inline %{ | |
541 | wxWindow* wxWindow_FromHWND(unsigned long hWnd) { | |
542 | wxWindow* win = new wxWindow; | |
543 | win->SetHWND(hWnd); | |
544 | win->SubclassWin(hWnd); | |
545 | return win; | |
546 | } | |
547 | %} | |
548 | #endif | |
549 | ||
550 | ||
551 | // Unfortunatly the names of these new static methods clash with the | |
552 | // names wxPython has been using forever for the overloaded | |
553 | // wxWindow::FindWindow, so instead of swigging them as statics create | |
554 | // standalone functions for them. | |
555 | %inline %{ | |
556 | wxWindow* wxFindWindowById( long id, const wxWindow *parent = NULL ) { | |
557 | return wxWindow::FindWindowById(id, parent); | |
558 | } | |
559 | ||
560 | wxWindow* wxFindWindowByName( const wxString& name, | |
561 | const wxWindow *parent = NULL ) { | |
562 | return wxWindow::FindWindowByName(name, parent); | |
563 | } | |
564 | ||
565 | wxWindow* wxFindWindowByLabel( const wxString& label, | |
566 | const wxWindow *parent = NULL ) { | |
567 | return wxWindow::FindWindowByLabel(label, parent); | |
568 | } | |
569 | %} | |
570 | ||
571 | ||
572 | //--------------------------------------------------------------------------- | |
573 | ||
574 | class wxPanel : public wxWindow { | |
575 | public: | |
576 | wxPanel(wxWindow* parent, | |
577 | const wxWindowID id, | |
578 | const wxPoint& pos = wxDefaultPosition, | |
579 | const wxSize& size = wxDefaultSize, | |
580 | long style = wxTAB_TRAVERSAL, | |
581 | const wxString& name = wxPyPanelNameStr); | |
582 | %name(wxPrePanel)wxPanel(); | |
583 | ||
584 | bool Create(wxWindow* parent, | |
585 | const wxWindowID id, | |
586 | const wxPoint& pos = wxDefaultPosition, | |
587 | const wxSize& size = wxDefaultSize, | |
588 | long style = wxTAB_TRAVERSAL, | |
589 | const wxString& name = wxPyPanelNameStr); | |
590 | ||
591 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
592 | %pragma(python) addtomethod = "wxPrePanel:val._setOORInfo(val)" | |
593 | ||
594 | void InitDialog(); | |
595 | ||
596 | }; | |
597 | ||
598 | //--------------------------------------------------------------------------- | |
599 | ||
600 | ||
601 | // TODO: Add wrappers for the wxScrollHelper class, make wxScrolledWindow | |
602 | // derive from it and wxPanel. | |
603 | ||
604 | ||
605 | class wxScrolledWindow : public wxPanel { | |
606 | public: | |
607 | wxScrolledWindow(wxWindow* parent, | |
608 | const wxWindowID id = -1, | |
609 | const wxPoint& pos = wxDefaultPosition, | |
610 | const wxSize& size = wxDefaultSize, | |
611 | long style = wxHSCROLL | wxVSCROLL, | |
612 | const wxString& name = wxPyPanelNameStr); | |
613 | %name(wxPreScrolledWindow)wxScrolledWindow(); | |
614 | ||
615 | bool Create(wxWindow* parent, | |
616 | const wxWindowID id = -1, | |
617 | const wxPoint& pos = wxDefaultPosition, | |
618 | const wxSize& size = wxDefaultSize, | |
619 | long style = wxHSCROLL | wxVSCROLL, | |
620 | const wxString& name = wxPyPanelNameStr); | |
621 | ||
622 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
623 | %pragma(python) addtomethod = "wxPreScrolledWindow:val._setOORInfo(val)" | |
624 | ||
625 | void EnableScrolling(bool xScrolling, bool yScrolling); | |
626 | int GetScrollPageSize(int orient); | |
627 | void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT); | |
628 | wxWindow* GetTargetWindow(); | |
629 | bool IsRetained(); | |
630 | void PrepareDC(wxDC& dc); | |
631 | void Scroll(int x, int y); | |
632 | void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY, | |
633 | int noUnitsX, int noUnitsY, | |
634 | int xPos = 0, int yPos = 0, int noRefresh=FALSE); | |
635 | void SetScrollPageSize(int orient, int pageSize); | |
636 | void SetTargetWindow(wxWindow* window); | |
637 | void GetViewStart(int* OUTPUT, int* OUTPUT); | |
638 | %pragma(python) addtoclass = "ViewStart = GetViewStart" | |
639 | ||
640 | %name(CalcScrolledPosition1)wxPoint CalcScrolledPosition(const wxPoint& pt); | |
641 | %name(CalcScrolledPosition2)void CalcScrolledPosition( int x, int y, int *OUTPUT, int *OUTPUT); | |
642 | ||
643 | %name(CalcUnscrolledPosition1)wxPoint CalcUnscrolledPosition(const wxPoint& pt); | |
644 | %name(CalcUnscrolledPosition2)void CalcUnscrolledPosition( int x, int y, int *OUTPUT, int *OUTPUT); | |
645 | ||
646 | %pragma(python) addtoclass = " | |
647 | def CalcScrolledPosition(self, *args): | |
648 | if len(args) == 1: | |
649 | return self.CalcScrolledPosition1(*args) | |
650 | elif len(args) == 2: | |
651 | return self.CalcScrolledPosition2(*args) | |
652 | else: | |
653 | raise TypeError, 'Invalid parameters: only (x,y) or (point) allowed' | |
654 | ||
655 | def CalcUnscrolledPosition(self, *args): | |
656 | if len(args) == 1: | |
657 | return self.CalcUnscrolledPosition1(*args) | |
658 | elif len(args) == 2: | |
659 | return self.CalcUnscrolledPosition2(*args) | |
660 | else: | |
661 | raise TypeError, 'Invalid parameters: only (x,y) or (point) allowed' | |
662 | " | |
663 | ||
664 | void SetScale(double xs, double ys); | |
665 | double GetScaleX(); | |
666 | double GetScaleY(); | |
667 | ||
668 | void AdjustScrollbars(); | |
669 | ||
670 | bool Layout(); | |
671 | ||
672 | // Set the x, y scrolling increments. | |
673 | void SetScrollRate( int xstep, int ystep ); | |
674 | ||
675 | }; | |
676 | ||
677 | //---------------------------------------------------------------------- | |
678 | ||
679 | ||
680 | class wxMenu : public wxEvtHandler { | |
681 | public: | |
682 | wxMenu(const wxString& title = wxPyEmptyString, long style = 0); | |
683 | ||
684 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
685 | ||
686 | void Append(int id, const wxString& item, | |
687 | const wxString& helpString = wxPyEmptyString, | |
688 | wxItemKind kind = wxITEM_NORMAL); | |
689 | %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu, | |
690 | const wxString& helpString = wxPyEmptyString); | |
691 | %name(AppendItem)void Append(const wxMenuItem* item); | |
692 | void AppendCheckItem(int id, | |
693 | const wxString& text, | |
694 | const wxString& help = wxPyEmptyString); | |
695 | void AppendRadioItem(int id, | |
696 | const wxString& text, | |
697 | const wxString& help = wxPyEmptyString); | |
698 | void AppendSeparator(); | |
699 | ||
700 | ||
701 | void Insert(size_t pos, | |
702 | int id, | |
703 | const wxString& text, | |
704 | const wxString& help = wxPyEmptyString, | |
705 | wxItemKind kind = wxITEM_NORMAL); | |
706 | void InsertSeparator(size_t pos); | |
707 | void InsertCheckItem(size_t pos, | |
708 | int id, | |
709 | const wxString& text, | |
710 | const wxString& help = wxPyEmptyString); | |
711 | void InsertRadioItem(size_t pos, | |
712 | int id, | |
713 | const wxString& text, | |
714 | const wxString& help = wxPyEmptyString); | |
715 | %name(InsertMenu)void Insert(size_t pos, | |
716 | int id, | |
717 | const wxString& text, | |
718 | wxMenu *submenu, | |
719 | const wxString& help = wxPyEmptyString); | |
720 | %name(InsertItem)bool Insert(size_t pos, wxMenuItem *item); | |
721 | ||
722 | ||
723 | void Prepend(int id, | |
724 | const wxString& text, | |
725 | const wxString& help = wxPyEmptyString, | |
726 | wxItemKind kind = wxITEM_NORMAL); | |
727 | void PrependSeparator(); | |
728 | void PrependCheckItem(int id, | |
729 | const wxString& text, | |
730 | const wxString& help = wxPyEmptyString); | |
731 | void PrependRadioItem(int id, | |
732 | const wxString& text, | |
733 | const wxString& help = wxPyEmptyString); | |
734 | %name(PrependMenu)void Prepend(int id, | |
735 | const wxString& text, | |
736 | wxMenu *submenu, | |
737 | const wxString& help = wxPyEmptyString); | |
738 | %name(PrependItem)void Prepend(wxMenuItem *item); | |
739 | ||
740 | ||
741 | void Break(); | |
742 | void Check(int id, bool flag); | |
743 | bool IsChecked(int id); | |
744 | void Enable(int id, bool enable); | |
745 | bool IsEnabled(int id); | |
746 | ||
747 | int FindItem(const wxString& itemString); | |
748 | %name(FindItemById)wxMenuItem* FindItem(int id/*, wxMenu **menu = NULL*/); | |
749 | wxMenuItem* FindItemByPosition(size_t position) const; | |
750 | ||
751 | wxString GetTitle(); | |
752 | void SetTitle(const wxString& title); | |
753 | ||
754 | wxString GetLabel(int id); | |
755 | void SetLabel(int id, const wxString& label); | |
756 | ||
757 | wxString GetHelpString(int id); | |
758 | void SetHelpString(int id, const wxString& helpString); | |
759 | void UpdateUI(wxEvtHandler* source = NULL); | |
760 | ||
761 | bool Delete(int id); | |
762 | %name(DeleteItem)bool Delete(wxMenuItem *item); | |
763 | wxMenuItem *Remove(int id); | |
764 | %name(RemoveItem) wxMenuItem *Remove(wxMenuItem *item); | |
765 | ||
766 | ||
767 | %addmethods { | |
768 | void Destroy() { delete self; } | |
769 | } | |
770 | %name(DestroyId)bool Destroy(int id); | |
771 | %name(DestroyItem)bool Destroy(wxMenuItem *item); | |
772 | ||
773 | size_t GetMenuItemCount(); | |
774 | //wxMenuItemList& GetMenuItems(); | |
775 | %addmethods { | |
776 | PyObject* GetMenuItems() { | |
777 | wxMenuItemList& list = self->GetMenuItems(); | |
778 | return wxPy_ConvertList(&list, "wxMenuItem"); | |
779 | } | |
780 | } | |
781 | ||
782 | void SetEventHandler(wxEvtHandler *handler); | |
783 | wxEvtHandler *GetEventHandler(); | |
784 | ||
785 | void SetInvokingWindow(wxWindow *win); | |
786 | wxWindow *GetInvokingWindow(); | |
787 | ||
788 | long GetStyle(); | |
789 | ||
790 | bool IsAttached(); | |
791 | ||
792 | void SetParent(wxMenu *parent); | |
793 | wxMenu *GetParent(); | |
794 | }; | |
795 | ||
796 | ||
797 | //---------------------------------------------------------------------- | |
798 | ||
799 | class wxMenuBar : public wxWindow { | |
800 | public: | |
801 | wxMenuBar(long style = 0); | |
802 | ||
803 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
804 | ||
805 | bool Append(wxMenu *menu, const wxString& title); | |
806 | bool Insert(size_t pos, wxMenu *menu, const wxString& title); | |
807 | size_t GetMenuCount(); | |
808 | wxMenu *GetMenu(size_t pos); | |
809 | wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title); | |
810 | wxMenu *Remove(size_t pos); | |
811 | void EnableTop(size_t pos, bool enable); | |
812 | bool IsEnabledTop(size_t pos); | |
813 | void SetLabelTop(size_t pos, const wxString& label); | |
814 | wxString GetLabelTop(size_t pos); | |
815 | int FindMenu(const wxString& title); | |
816 | int FindMenuItem(const wxString& menuString, const wxString& itemString); | |
817 | %name(FindItemById)wxMenuItem* FindItem(int id/*, wxMenu **menu = NULL*/); | |
818 | void Enable(int id, bool enable); | |
819 | void Check(int id, bool check); | |
820 | bool IsChecked(int id); | |
821 | bool IsEnabled(int id); | |
822 | ||
823 | void SetLabel(int id, const wxString &label); | |
824 | wxString GetLabel(int id); | |
825 | ||
826 | void SetHelpString(int id, const wxString& helpString); | |
827 | wxString GetHelpString(int id); | |
828 | ||
829 | }; | |
830 | ||
831 | ||
832 | //---------------------------------------------------------------------- | |
833 | ||
834 | class wxMenuItem : public wxObject { | |
835 | public: | |
836 | wxMenuItem(wxMenu* parentMenu=NULL, int id=wxID_SEPARATOR, | |
837 | const wxString& text = wxPyEmptyString, | |
838 | const wxString& help = wxPyEmptyString, | |
839 | wxItemKind kind = wxITEM_NORMAL, | |
840 | wxMenu* subMenu = NULL); | |
841 | ||
842 | ||
843 | wxMenu *GetMenu(); | |
844 | void SetMenu(wxMenu* menu); | |
845 | void SetId(int id); | |
846 | int GetId(); | |
847 | bool IsSeparator(); | |
848 | void SetText(const wxString& str); | |
849 | wxString GetLabel(); | |
850 | const wxString& GetText(); | |
851 | wxItemKind GetKind(); | |
852 | void SetCheckable(bool checkable); | |
853 | bool IsCheckable(); | |
854 | bool IsSubMenu(); | |
855 | void SetSubMenu(wxMenu *menu); | |
856 | wxMenu *GetSubMenu(); | |
857 | void Enable(bool enable = TRUE); | |
858 | bool IsEnabled(); | |
859 | void Check(bool check = TRUE); | |
860 | bool IsChecked(); | |
861 | void Toggle(); | |
862 | void SetHelp(const wxString& str); | |
863 | const wxString& GetHelp(); | |
864 | wxAcceleratorEntry *GetAccel(); | |
865 | void SetAccel(wxAcceleratorEntry *accel); | |
866 | ||
867 | static wxString GetLabelFromText(const wxString& text); | |
868 | // static wxAcceleratorEntry *GetAccelFromString(const wxString& label); | |
869 | ||
870 | // wxOwnerDrawn methods | |
871 | #ifdef __WXMSW__ | |
872 | void SetFont(const wxFont& font); | |
873 | wxFont GetFont(); | |
874 | void SetTextColour(const wxColour& colText); | |
875 | wxColour GetTextColour(); | |
876 | void SetBackgroundColour(const wxColour& colBack); | |
877 | wxColour GetBackgroundColour(); | |
878 | void SetBitmaps(const wxBitmap& bmpChecked, | |
879 | const wxBitmap& bmpUnchecked = wxNullBitmap); | |
880 | //void SetBitmap(const wxBitmap& bmpChecked); | |
881 | //wxBitmap GetBitmap(bool bChecked = TRUE); | |
882 | ||
883 | void SetDisabledBitmap( const wxBitmap& bmpDisabled ); | |
884 | const wxBitmap& GetDisabledBitmap() const; | |
885 | ||
886 | void SetMarginWidth(int nWidth); | |
887 | int GetMarginWidth(); | |
888 | static int GetDefaultMarginWidth(); | |
889 | bool IsOwnerDrawn(); | |
890 | // switch on/off owner-drawing the item | |
891 | void SetOwnerDrawn(bool ownerDrawn = TRUE); | |
892 | void ResetOwnerDrawn(); | |
893 | #endif | |
894 | ||
895 | void SetBitmap(const wxBitmap& bitmap); | |
896 | const wxBitmap& GetBitmap(); | |
897 | ||
898 | }; | |
899 | ||
900 | //--------------------------------------------------------------------------- | |
901 | ||
902 | ||
903 |