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