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