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