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