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