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