]>
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 | ||
38 | %{ | |
39 | // Put some wx default wxChar* values into wxStrings. | |
40 | DECLARE_DEF_STRING(PanelNameStr); | |
41 | static const wxString wxPyEmptyString(wxT("")); | |
42 | %} | |
43 | ||
44 | //--------------------------------------------------------------------------- | |
45 | ||
46 | class wxEvtHandler : public wxObject { | |
47 | public: | |
48 | wxEvtHandler(); | |
49 | ||
50 | bool ProcessEvent(wxEvent& event); | |
51 | void AddPendingEvent(wxEvent& event); | |
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 | ||
63 | %addmethods { | |
64 | void Connect( int id, int lastId, int eventType, PyObject* func) { | |
65 | if (PyCallable_Check(func)) { | |
66 | self->Connect(id, lastId, eventType, | |
67 | (wxObjectEventFunction) &wxPyCallback::EventThunker, | |
68 | new wxPyCallback(func)); | |
69 | } | |
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 | } | |
78 | } | |
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 | } | |
86 | } | |
87 | ||
88 | %addmethods { | |
89 | void _setOORInfo(PyObject* _self) { | |
90 | self->SetClientObject(new wxPyOORClientData(_self)); | |
91 | } | |
92 | } | |
93 | }; | |
94 | ||
95 | ||
96 | //---------------------------------------------------------------------- | |
97 | ||
98 | class wxValidator : public wxEvtHandler { | |
99 | public: | |
100 | wxValidator(); | |
101 | //~wxValidator(); | |
102 | ||
103 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
104 | ||
105 | wxValidator* Clone(); | |
106 | wxWindow* GetWindow(); | |
107 | void SetWindow(wxWindow* window); | |
108 | ||
109 | static bool IsSilent(); | |
110 | static void SetBellOnError(int doIt = TRUE); | |
111 | ||
112 | }; | |
113 | ||
114 | ||
115 | //---------------------------------------------------------------------- | |
116 | %{ | |
117 | class wxPyValidator : public wxValidator { | |
118 | DECLARE_DYNAMIC_CLASS(wxPyValidator); | |
119 | public: | |
120 | wxPyValidator() { | |
121 | } | |
122 | ||
123 | ~wxPyValidator() { | |
124 | } | |
125 | ||
126 | wxObject* Clone() const { | |
127 | wxPyValidator* ptr = NULL; | |
128 | wxPyValidator* self = (wxPyValidator*)this; | |
129 | ||
130 | wxPyBeginBlockThreads(); | |
131 | if (self->m_myInst.findCallback("Clone")) { | |
132 | PyObject* ro; | |
133 | ro = self->m_myInst.callCallbackObj(Py_BuildValue("()")); | |
134 | if (ro) { | |
135 | SWIG_GetPtrObj(ro, (void **)&ptr, "_wxPyValidator_p"); | |
136 | Py_DECREF(ro); | |
137 | } | |
138 | } | |
139 | wxPyEndBlockThreads(); | |
140 | ||
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; | |
146 | return ptr; | |
147 | } | |
148 | ||
149 | ||
150 | DEC_PYCALLBACK_BOOL_WXWIN(Validate); | |
151 | DEC_PYCALLBACK_BOOL_(TransferToWindow); | |
152 | DEC_PYCALLBACK_BOOL_(TransferFromWindow); | |
153 | ||
154 | PYPRIVATE; | |
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(); | |
168 | ||
169 | void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=TRUE); | |
170 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyValidator, 1)" | |
171 | ||
172 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
173 | }; | |
174 | ||
175 | //---------------------------------------------------------------------- | |
176 | ||
177 | %apply int * INOUT { int* x, int* y }; | |
178 | ||
179 | class wxWindow : public wxEvtHandler { | |
180 | public: | |
181 | wxWindow(wxWindow* parent, const wxWindowID id, | |
182 | const wxPoint& pos = wxDefaultPosition, | |
183 | const wxSize& size = wxDefaultSize, | |
184 | long style = 0, | |
185 | const wxString& name = wxPyPanelNameStr); | |
186 | %name(wxPreWindow)wxWindow(); | |
187 | ||
188 | bool Create(wxWindow* parent, const wxWindowID id, | |
189 | const wxPoint& pos = wxDefaultPosition, | |
190 | const wxSize& size = wxDefaultSize, | |
191 | long style = 0, | |
192 | const wxString& name = wxPyPanelNameStr); | |
193 | ||
194 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
195 | %pragma(python) addtomethod = "wxPreWindow:val._setOORInfo(val)" | |
196 | ||
197 | ||
198 | void Center(int direction = wxBOTH); | |
199 | void Centre(int direction = wxBOTH); | |
200 | void CentreOnParent(int direction = wxBOTH ); | |
201 | void CenterOnParent(int direction = wxBOTH ); | |
202 | void CentreOnScreen(int direction = wxBOTH ); | |
203 | void CenterOnScreen(int direction = wxBOTH ); | |
204 | ||
205 | void Clear(); | |
206 | ||
207 | // (uses apply'ed INOUT typemap, see above) | |
208 | %name(ClientToScreenXY)void ClientToScreen(int* x, int* y); | |
209 | wxPoint ClientToScreen(const wxPoint& pt); | |
210 | ||
211 | bool Close(int force = FALSE); | |
212 | bool Destroy(); | |
213 | void DestroyChildren(); | |
214 | bool IsBeingDeleted(); | |
215 | #ifdef __WXMSW__ | |
216 | void DragAcceptFiles(bool accept); | |
217 | #endif | |
218 | void Enable(bool enable); | |
219 | //bool FakePopupMenu(wxMenu* menu, int x, int y); | |
220 | %name(FindWindowById) wxWindow* FindWindow(long id); | |
221 | %name(FindWindowByName) wxWindow* FindWindow(const wxString& name); | |
222 | void Fit(); | |
223 | wxColour GetBackgroundColour(); | |
224 | wxBorder GetBorder() const; | |
225 | ||
226 | //wxList& GetChildren(); | |
227 | %addmethods { | |
228 | PyObject* GetChildren() { | |
229 | wxWindowList& list = self->GetChildren(); | |
230 | return wxPy_ConvertList(&list, "wxWindow"); | |
231 | } | |
232 | } | |
233 | ||
234 | int GetCharHeight(); | |
235 | int GetCharWidth(); | |
236 | %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT); | |
237 | wxSize GetClientSize(); | |
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 | ||
247 | wxLayoutConstraints * GetConstraints(); | |
248 | wxEvtHandler* GetEventHandler(); | |
249 | ||
250 | wxFont GetFont(); | |
251 | wxColour GetForegroundColour(); | |
252 | wxWindow * GetGrandParent(); | |
253 | %addmethods { | |
254 | long GetHandle() { | |
255 | return wxPyGetWinHandle(self); //(long)self->GetHandle(); | |
256 | } | |
257 | } | |
258 | int GetId(); | |
259 | wxString GetLabel(); | |
260 | void SetLabel(const wxString& label); | |
261 | wxString GetName(); | |
262 | wxWindow * GetParent(); | |
263 | %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT); | |
264 | wxPoint GetPosition(); | |
265 | wxRect GetRect(); | |
266 | int GetScrollThumb(int orientation); | |
267 | int GetScrollPos(int orientation); | |
268 | int GetScrollRange(int orientation); | |
269 | %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT); | |
270 | wxSize GetSize(); | |
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) | |
275 | wxString GetTitle(); | |
276 | wxRegion GetUpdateRegion(); | |
277 | long GetWindowStyleFlag(); | |
278 | void SetWindowStyleFlag(long style); | |
279 | void SetWindowStyle(long style); | |
280 | bool HasScrollbar(int orient) const; | |
281 | bool Hide(); | |
282 | wxHitTest HitTest(const wxPoint& pt); | |
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=TRUE); | |
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); | |
297 | ||
298 | wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE); | |
299 | void PushEventHandler(wxEvtHandler* handler); | |
300 | ||
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 | ||
308 | %name(PopupMenuXY)bool PopupMenu(wxMenu *menu, int x, int y); | |
309 | bool PopupMenu(wxMenu *menu, const wxPoint& pos); | |
310 | ||
311 | void Raise(); | |
312 | void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL); | |
313 | void RefreshRect(const wxRect& rect); | |
314 | ||
315 | void RemoveChild(wxWindow* child); | |
316 | bool Reparent( wxWindow* newParent ); | |
317 | ||
318 | // (uses apply'ed INOUT typemap, see above) | |
319 | %name(ScreenToClientXY)void ScreenToClient(int *x, int *y); | |
320 | wxPoint ScreenToClient(const wxPoint& pt); | |
321 | ||
322 | void ScrollWindow(int dx, int dy, const wxRect* rect = NULL); | |
323 | void SetAutoLayout(bool autoLayout); | |
324 | bool GetAutoLayout(); | |
325 | void SetBackgroundColour(const wxColour& colour); | |
326 | void SetConstraints(wxLayoutConstraints *constraints); | |
327 | void UnsetConstraints(wxLayoutConstraints *constraints); | |
328 | void SetFocus(); | |
329 | bool AcceptsFocus(); | |
330 | void SetFont(const wxFont& font); | |
331 | void SetForegroundColour(const wxColour& colour); | |
332 | void SetId(int id); | |
333 | void SetName(const wxString& name); | |
334 | void SetScrollbar(int orientation, int position, int thumbSize, int range, int refresh = TRUE); | |
335 | void SetScrollPos(int orientation, int pos, bool refresh = TRUE); | |
336 | ||
337 | %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO); | |
338 | %addmethods { | |
339 | void SetSize(const wxSize& size) { | |
340 | self->SetSize(size); | |
341 | } | |
342 | ||
343 | void SetPosition(const wxPoint& pos, int flags = wxSIZE_USE_EXISTING) { | |
344 | self->Move(pos, flags); | |
345 | } | |
346 | ||
347 | void SetRect(const wxRect& rect, int sizeFlags=wxSIZE_AUTO) { | |
348 | self->SetSize(rect, sizeFlags); | |
349 | } | |
350 | } | |
351 | ||
352 | void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1); | |
353 | %name(SetClientSizeWH)void SetClientSize(int width, int height); | |
354 | void SetClientSize(const wxSize& size); | |
355 | //void SetPalette(wxPalette* palette); | |
356 | void SetCursor(const wxCursor& cursor); | |
357 | void SetEventHandler(wxEvtHandler* handler); | |
358 | void SetExtraStyle(long exStyle); | |
359 | void SetTitle(const wxString& title); | |
360 | bool Show(bool show=TRUE); | |
361 | bool TransferDataFromWindow(); | |
362 | bool TransferDataToWindow(); | |
363 | void UpdateWindowUI(); | |
364 | bool Validate(); | |
365 | ||
366 | %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt); | |
367 | %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz); | |
368 | ||
369 | %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt); | |
370 | %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz); | |
371 | ||
372 | %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt); | |
373 | %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz); | |
374 | ||
375 | %name(SetToolTipString)void SetToolTip(const wxString &tip); | |
376 | void SetToolTip(wxToolTip *tooltip); | |
377 | wxToolTip* GetToolTip(); | |
378 | ||
379 | void SetSizer(wxSizer* sizer, bool deleteOld=TRUE); | |
380 | wxSizer* GetSizer(); | |
381 | ||
382 | // Track if this window is a member of a sizer | |
383 | void SetContainingSizer(wxSizer* sizer); | |
384 | wxSizer *GetContainingSizer() const; | |
385 | ||
386 | wxValidator* GetValidator(); | |
387 | void SetValidator(const wxValidator& validator); | |
388 | ||
389 | #ifndef __WXMAC__ | |
390 | void SetDropTarget(wxDropTarget* target); | |
391 | wxDropTarget* GetDropTarget(); | |
392 | %pragma(python) addtomethod = "SetDropTarget:_args[0].thisown = 0" | |
393 | #endif | |
394 | ||
395 | wxSize GetBestSize(); | |
396 | wxSize GetMaxSize(); | |
397 | ||
398 | void SetCaret(wxCaret *caret); | |
399 | wxCaret *GetCaret(); | |
400 | %pragma(python) addtoclass = "# replaces broken shadow method | |
401 | def GetCaret(self, *_args, **_kwargs): | |
402 | from misc2 import wxCaretPtr | |
403 | val = apply(windowsc.wxWindow_GetCaret,(self,) + _args, _kwargs) | |
404 | if val: val = wxCaretPtr(val) | |
405 | return val | |
406 | " | |
407 | ||
408 | void Freeze(); | |
409 | void Thaw(); | |
410 | void Update(); | |
411 | ||
412 | wxString GetHelpText(); | |
413 | void SetHelpText(const wxString& helpText); | |
414 | void SetHelpTextForId(const wxString& text); | |
415 | ||
416 | bool ScrollLines(int lines); | |
417 | bool ScrollPages(int pages); | |
418 | bool LineUp(); | |
419 | bool LineDown(); | |
420 | bool PageUp(); | |
421 | bool PageDown(); | |
422 | ||
423 | static wxWindow* FindFocus(); | |
424 | static int NewControlId(); | |
425 | static int NextControlId(int id); | |
426 | static int PrevControlId(int id); | |
427 | ||
428 | void SetAcceleratorTable(const wxAcceleratorTable& accel); | |
429 | wxAcceleratorTable *GetAcceleratorTable(); | |
430 | ||
431 | #ifdef __WXMSW__ | |
432 | // A way to do the native draw first... Too bad it isn't in wxGTK too. | |
433 | void OnPaint(wxPaintEvent& event); | |
434 | #endif | |
435 | ||
436 | wxWindow* GetDefaultItem(); | |
437 | wxWindow* SetDefaultItem(wxWindow *btn); | |
438 | ||
439 | ||
440 | // move the mouse to the specified position | |
441 | void WarpPointer(int x, int y); | |
442 | ||
443 | // start or end mouse capture, these functions maintain the stack of | |
444 | // windows having captured the mouse and after calling ReleaseMouse() | |
445 | // the mouse is not released but returns to the window which had had | |
446 | // captured it previously (if any) | |
447 | void CaptureMouse(); | |
448 | void ReleaseMouse(); | |
449 | ||
450 | // get the window which currently captures the mouse or NULL | |
451 | static wxWindow *GetCapture(); | |
452 | ||
453 | // does this window have the capture? | |
454 | bool HasCapture() const; | |
455 | }; | |
456 | ||
457 | ||
458 | ||
459 | ||
460 | %pragma(python) code = " | |
461 | def wxDLG_PNT(win, point_or_x, y=None): | |
462 | if y is None: | |
463 | return win.ConvertDialogPointToPixels(point_or_x) | |
464 | else: | |
465 | return win.ConvertDialogPointToPixels(wxPoint(point_or_x, y)) | |
466 | ||
467 | def wxDLG_SZE(win, size_width, height=None): | |
468 | if height is None: | |
469 | return win.ConvertDialogSizeToPixels(size_width) | |
470 | else: | |
471 | return win.ConvertDialogSizeToPixels(wxSize(size_width, height)) | |
472 | " | |
473 | ||
474 | ||
475 | #ifdef __WXMSW__ | |
476 | %inline %{ | |
477 | wxWindow* wxWindow_FromHWND(unsigned long hWnd) { | |
478 | wxWindow* win = new wxWindow; | |
479 | win->SetHWND(hWnd); | |
480 | win->SubclassWin(hWnd); | |
481 | return win; | |
482 | } | |
483 | %} | |
484 | #endif | |
485 | ||
486 | ||
487 | //--------------------------------------------------------------------------- | |
488 | ||
489 | class wxPanel : public wxWindow { | |
490 | public: | |
491 | wxPanel(wxWindow* parent, | |
492 | const wxWindowID id, | |
493 | const wxPoint& pos = wxDefaultPosition, | |
494 | const wxSize& size = wxDefaultSize, | |
495 | long style = wxTAB_TRAVERSAL, | |
496 | const wxString& name = wxPyPanelNameStr); | |
497 | %name(wxPrePanel)wxPanel(); | |
498 | ||
499 | bool Create(wxWindow* parent, | |
500 | const wxWindowID id, | |
501 | const wxPoint& pos = wxDefaultPosition, | |
502 | const wxSize& size = wxDefaultSize, | |
503 | long style = wxTAB_TRAVERSAL, | |
504 | const wxString& name = wxPyPanelNameStr); | |
505 | ||
506 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
507 | %pragma(python) addtomethod = "wxPrePanel:val._setOORInfo(val)" | |
508 | ||
509 | void InitDialog(); | |
510 | ||
511 | }; | |
512 | ||
513 | //--------------------------------------------------------------------------- | |
514 | ||
515 | ||
516 | // TODO: Add wrappers for the wxScrollHelper class, make wxScrolledWindow | |
517 | // derive from it and wxPanel. | |
518 | ||
519 | ||
520 | class wxScrolledWindow : public wxPanel { | |
521 | public: | |
522 | wxScrolledWindow(wxWindow* parent, | |
523 | const wxWindowID id = -1, | |
524 | const wxPoint& pos = wxDefaultPosition, | |
525 | const wxSize& size = wxDefaultSize, | |
526 | long style = wxHSCROLL | wxVSCROLL, | |
527 | const wxString& name = wxPyPanelNameStr); | |
528 | %name(wxPreScrolledWindow)wxScrolledWindow(); | |
529 | ||
530 | bool Create(wxWindow* parent, | |
531 | const wxWindowID id = -1, | |
532 | const wxPoint& pos = wxDefaultPosition, | |
533 | const wxSize& size = wxDefaultSize, | |
534 | long style = wxHSCROLL | wxVSCROLL, | |
535 | const wxString& name = wxPyPanelNameStr); | |
536 | ||
537 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
538 | %pragma(python) addtomethod = "wxPreScrolledWindow:val._setOORInfo(val)" | |
539 | ||
540 | void EnableScrolling(bool xScrolling, bool yScrolling); | |
541 | int GetScrollPageSize(int orient); | |
542 | void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT); | |
543 | wxWindow* GetTargetWindow(); | |
544 | void GetVirtualSize(int* OUTPUT, int* OUTPUT); | |
545 | bool IsRetained(); | |
546 | void PrepareDC(wxDC& dc); | |
547 | void Scroll(int x, int y); | |
548 | void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY, | |
549 | int noUnitsX, int noUnitsY, | |
550 | int xPos = 0, int yPos = 0, int noRefresh=FALSE); | |
551 | void SetScrollPageSize(int orient, int pageSize); | |
552 | void SetTargetWindow(wxWindow* window); | |
553 | void GetViewStart(int* OUTPUT, int* OUTPUT); | |
554 | %pragma(python) addtoclass = "ViewStart = GetViewStart" | |
555 | ||
556 | %name(CalcScrolledPosition1)wxPoint CalcScrolledPosition(const wxPoint& pt); | |
557 | %name(CalcScrolledPosition2)void CalcScrolledPosition( int x, int y, int *OUTPUT, int *OUTPUT); | |
558 | ||
559 | %name(CalcUnscrolledPosition1)wxPoint CalcUnscrolledPosition(const wxPoint& pt); | |
560 | %name(CalcUnscrolledPosition2)void CalcUnscrolledPosition( int x, int y, int *OUTPUT, int *OUTPUT); | |
561 | ||
562 | %pragma(python) addtoclass = " | |
563 | def CalcScrolledPosition(self, *args): | |
564 | if len(args) == 1: | |
565 | return apply(self.CalcScrolledPosition1, args) | |
566 | elif len(args) == 2: | |
567 | return apply(self.CalcScrolledPosition2, args) | |
568 | else: | |
569 | raise TypeError, 'Invalid parameters: only (x,y) or (point) allowed' | |
570 | ||
571 | def CalcUnscrolledPosition(self, *args): | |
572 | if len(args) == 1: | |
573 | return apply(self.CalcUnscrolledPosition1, args) | |
574 | elif len(args) == 2: | |
575 | return apply(self.CalcUnscrolledPosition2, args) | |
576 | else: | |
577 | raise TypeError, 'Invalid parameters: only (x,y) or (point) allowed' | |
578 | " | |
579 | ||
580 | void SetScale(double xs, double ys); | |
581 | double GetScaleX(); | |
582 | double GetScaleY(); | |
583 | ||
584 | void AdjustScrollbars(); | |
585 | ||
586 | bool Layout(); | |
587 | }; | |
588 | ||
589 | //---------------------------------------------------------------------- | |
590 | ||
591 | ||
592 | class wxMenu : public wxEvtHandler { | |
593 | public: | |
594 | wxMenu(const wxString& title = wxPyEmptyString, long style = 0); | |
595 | ||
596 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
597 | ||
598 | void Append(int id, const wxString& item, | |
599 | const wxString& helpString = wxPyEmptyString, | |
600 | wxItemKind kind = wxITEM_NORMAL); | |
601 | %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu, | |
602 | const wxString& helpString = wxPyEmptyString); | |
603 | %name(AppendItem)void Append(const wxMenuItem* item); | |
604 | void AppendCheckItem(int id, | |
605 | const wxString& text, | |
606 | const wxString& help = wxPyEmptyString); | |
607 | void AppendRadioItem(int id, | |
608 | const wxString& text, | |
609 | const wxString& help = wxPyEmptyString); | |
610 | void AppendSeparator(); | |
611 | ||
612 | ||
613 | void Insert(size_t pos, | |
614 | int id, | |
615 | const wxString& text, | |
616 | const wxString& help = wxPyEmptyString, | |
617 | wxItemKind kind = wxITEM_NORMAL); | |
618 | void InsertSeparator(size_t pos); | |
619 | void InsertCheckItem(size_t pos, | |
620 | int id, | |
621 | const wxString& text, | |
622 | const wxString& help = wxPyEmptyString); | |
623 | void InsertRadioItem(size_t pos, | |
624 | int id, | |
625 | const wxString& text, | |
626 | const wxString& help = wxPyEmptyString); | |
627 | %name(InsertMenu)void Insert(size_t pos, | |
628 | int id, | |
629 | const wxString& text, | |
630 | wxMenu *submenu, | |
631 | const wxString& help = wxPyEmptyString); | |
632 | %name(InsertItem)bool Insert(size_t pos, wxMenuItem *item); | |
633 | ||
634 | ||
635 | void Prepend(int id, | |
636 | const wxString& text, | |
637 | const wxString& help = wxPyEmptyString, | |
638 | wxItemKind kind = wxITEM_NORMAL); | |
639 | void PrependSeparator(); | |
640 | void PrependCheckItem(int id, | |
641 | const wxString& text, | |
642 | const wxString& help = wxPyEmptyString); | |
643 | void PrependRadioItem(int id, | |
644 | const wxString& text, | |
645 | const wxString& help = wxPyEmptyString); | |
646 | %name(PrependMenu)void Prepend(int id, | |
647 | const wxString& text, | |
648 | wxMenu *submenu, | |
649 | const wxString& help = wxPyEmptyString); | |
650 | %name(PrependItem)void Prepend(wxMenuItem *item); | |
651 | ||
652 | ||
653 | void Break(); | |
654 | void Check(int id, bool flag); | |
655 | bool IsChecked(int id); | |
656 | void Enable(int id, bool enable); | |
657 | bool IsEnabled(int id); | |
658 | ||
659 | int FindItem(const wxString& itemString); | |
660 | %name(FindItemById)wxMenuItem* FindItem(int id/*, wxMenu **menu = NULL*/); | |
661 | ||
662 | wxString GetTitle(); | |
663 | void SetTitle(const wxString& title); | |
664 | ||
665 | wxString GetLabel(int id); | |
666 | void SetLabel(int id, const wxString& label); | |
667 | ||
668 | wxString GetHelpString(int id); | |
669 | void SetHelpString(int id, const wxString& helpString); | |
670 | void UpdateUI(wxEvtHandler* source = NULL); | |
671 | ||
672 | bool Delete(int id); | |
673 | %name(DeleteItem)bool Delete(wxMenuItem *item); | |
674 | wxMenuItem *Remove(int id); | |
675 | %name(RemoveItem) wxMenuItem *Remove(wxMenuItem *item); | |
676 | ||
677 | ||
678 | ||
679 | ||
680 | %addmethods { | |
681 | void Destroy() { delete self; } | |
682 | } | |
683 | %name(DestroyId)bool Destroy(int id); | |
684 | %name(DestroyItem)bool Destroy(wxMenuItem *item); | |
685 | ||
686 | size_t GetMenuItemCount(); | |
687 | //wxMenuItemList& GetMenuItems(); | |
688 | %addmethods { | |
689 | PyObject* GetMenuItems() { | |
690 | wxMenuItemList& list = self->GetMenuItems(); | |
691 | return wxPy_ConvertList(&list, "wxMenuItem"); | |
692 | } | |
693 | } | |
694 | ||
695 | void SetEventHandler(wxEvtHandler *handler); | |
696 | wxEvtHandler *GetEventHandler(); | |
697 | ||
698 | void SetInvokingWindow(wxWindow *win); | |
699 | wxWindow *GetInvokingWindow(); | |
700 | ||
701 | long GetStyle(); | |
702 | ||
703 | bool IsAttached(); | |
704 | ||
705 | void SetParent(wxMenu *parent); | |
706 | wxMenu *GetParent(); | |
707 | }; | |
708 | ||
709 | ||
710 | //---------------------------------------------------------------------- | |
711 | ||
712 | class wxMenuBar : public wxWindow { | |
713 | public: | |
714 | wxMenuBar(long style = 0); | |
715 | ||
716 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
717 | ||
718 | bool Append(wxMenu *menu, const wxString& title); | |
719 | bool Insert(size_t pos, wxMenu *menu, const wxString& title); | |
720 | size_t GetMenuCount(); | |
721 | wxMenu *GetMenu(size_t pos); | |
722 | wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title); | |
723 | wxMenu *Remove(size_t pos); | |
724 | void EnableTop(size_t pos, bool enable); | |
725 | void SetLabelTop(size_t pos, const wxString& label); | |
726 | wxString GetLabelTop(size_t pos); | |
727 | int FindMenu(const wxString& title); | |
728 | int FindMenuItem(const wxString& menuString, const wxString& itemString); | |
729 | %name(FindItemById)wxMenuItem* FindItem(int id/*, wxMenu **menu = NULL*/); | |
730 | void Enable(int id, bool enable); | |
731 | void Check(int id, bool check); | |
732 | bool IsChecked(int id); | |
733 | bool IsEnabled(int id); | |
734 | ||
735 | void SetLabel(int id, const wxString &label); | |
736 | wxString GetLabel(int id); | |
737 | ||
738 | void SetHelpString(int id, const wxString& helpString); | |
739 | wxString GetHelpString(int id); | |
740 | ||
741 | }; | |
742 | ||
743 | ||
744 | //---------------------------------------------------------------------- | |
745 | ||
746 | class wxMenuItem : public wxObject { | |
747 | public: | |
748 | wxMenuItem(wxMenu* parentMenu=NULL, int id=wxID_SEPARATOR, | |
749 | const wxString& text = wxPyEmptyString, | |
750 | const wxString& help = wxPyEmptyString, | |
751 | wxItemKind kind = wxITEM_NORMAL, | |
752 | wxMenu* subMenu = NULL); | |
753 | ||
754 | ||
755 | wxMenu *GetMenu(); | |
756 | void SetId(int id); | |
757 | int GetId(); | |
758 | bool IsSeparator(); | |
759 | void SetText(const wxString& str); | |
760 | wxString GetLabel(); | |
761 | const wxString& GetText(); | |
762 | wxItemKind GetKind(); | |
763 | void SetCheckable(bool checkable); | |
764 | bool IsCheckable(); | |
765 | bool IsSubMenu(); | |
766 | void SetSubMenu(wxMenu *menu); | |
767 | wxMenu *GetSubMenu(); | |
768 | void Enable(bool enable = TRUE); | |
769 | bool IsEnabled(); | |
770 | void Check(bool check = TRUE); | |
771 | bool IsChecked(); | |
772 | void Toggle(); | |
773 | void SetHelp(const wxString& str); | |
774 | const wxString& GetHelp(); | |
775 | wxAcceleratorEntry *GetAccel(); | |
776 | void SetAccel(wxAcceleratorEntry *accel); | |
777 | ||
778 | static wxString GetLabelFromText(const wxString& text); | |
779 | // static wxAcceleratorEntry *GetAccelFromString(const wxString& label); | |
780 | ||
781 | // wxOwnerDrawn methods | |
782 | #ifdef __WXMSW__ | |
783 | void SetFont(const wxFont& font); | |
784 | wxFont GetFont(); | |
785 | void SetTextColour(const wxColour& colText); | |
786 | wxColour GetTextColour(); | |
787 | void SetBackgroundColour(const wxColour& colBack); | |
788 | wxColour GetBackgroundColour(); | |
789 | void SetBitmaps(const wxBitmap& bmpChecked, | |
790 | const wxBitmap& bmpUnchecked = wxNullBitmap); | |
791 | void SetBitmap(const wxBitmap& bmpChecked); | |
792 | wxBitmap GetBitmap(bool bChecked = TRUE); | |
793 | void SetMarginWidth(int nWidth); | |
794 | int GetMarginWidth(); | |
795 | static int GetDefaultMarginWidth(); | |
796 | //void SetName(const wxString& strName); | |
797 | //const wxString& GetName(); | |
798 | //void SetCheckable(bool checkable); | |
799 | //bool IsCheckable(); | |
800 | bool IsOwnerDrawn(); | |
801 | void ResetOwnerDrawn(); | |
802 | #endif | |
803 | }; | |
804 | ||
805 | //--------------------------------------------------------------------------- | |
806 | ||
807 | ||
808 |