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