]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/windows.i
More unicode related cleanup and fixes for wxPython
[wxWidgets.git] / wxPython / src / windows.i
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 wxPyClientData(_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 CaptureMouse();
199 void Center(int direction = wxBOTH);
200 void Centre(int direction = wxBOTH);
201 void CentreOnParent(int direction = wxBOTH );
202 void CenterOnParent(int direction = wxBOTH );
203 void CentreOnScreen(int direction = wxBOTH );
204 void CenterOnScreen(int direction = wxBOTH );
205
206 void Clear();
207
208 // (uses apply'ed INOUT typemap, see above)
209 %name(ClientToScreenXY)void ClientToScreen(int* x, int* y);
210 wxPoint ClientToScreen(const wxPoint& pt);
211
212 bool Close(int force = FALSE);
213 bool Destroy();
214 void DestroyChildren();
215 bool IsBeingDeleted();
216 #ifdef __WXMSW__
217 void DragAcceptFiles(bool accept);
218 #endif
219 void Enable(bool enable);
220 //bool FakePopupMenu(wxMenu* menu, int x, int y);
221 %name(FindWindowById) wxWindow* FindWindow(long id);
222 %name(FindWindowByName) wxWindow* FindWindow(const wxString& name);
223 void Fit();
224 wxColour GetBackgroundColour();
225 wxBorder GetBorder() const;
226
227 //wxList& GetChildren();
228 %addmethods {
229 PyObject* GetChildren() {
230 wxWindowList& list = self->GetChildren();
231 return wxPy_ConvertList(&list, "wxWindow");
232 }
233 }
234
235 int GetCharHeight();
236 int GetCharWidth();
237 %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT);
238 wxSize GetClientSize();
239
240 // get the origin of the client area of the window relative to the
241 // window top left corner (the client area may be shifted because of
242 // the borders, scrollbars, other decorations...)
243 wxPoint GetClientAreaOrigin() const;
244
245 // get the client rectangle in window (i.e. client) coordinates
246 wxRect GetClientRect() const;
247
248 wxLayoutConstraints * GetConstraints();
249 wxEvtHandler* GetEventHandler();
250
251 wxFont GetFont();
252 wxColour GetForegroundColour();
253 wxWindow * GetGrandParent();
254 %addmethods {
255 long GetHandle() {
256 return wxPyGetWinHandle(self); //(long)self->GetHandle();
257 }
258 }
259 int GetId();
260 wxString GetLabel();
261 void SetLabel(const wxString& label);
262 wxString GetName();
263 wxWindow * GetParent();
264 %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT);
265 wxPoint GetPosition();
266 wxRect GetRect();
267 int GetScrollThumb(int orientation);
268 int GetScrollPos(int orientation);
269 int GetScrollRange(int orientation);
270 %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT);
271 wxSize GetSize();
272 void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT);
273 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
274 int *OUTPUT, int *OUTPUT, int *OUTPUT, int* OUTPUT,
275 const wxFont* font = NULL); //, bool use16 = FALSE)
276 wxString GetTitle();
277 wxRegion GetUpdateRegion();
278 long GetWindowStyleFlag();
279 void SetWindowStyleFlag(long style);
280 void SetWindowStyle(long style);
281 bool HasScrollbar(int orient) const;
282 bool Hide();
283 wxHitTest HitTest(const wxPoint& pt);
284 void InitDialog();
285 bool IsEnabled();
286 bool IsExposed( int x, int y, int w=0, int h=0 );
287 %name(IsExposedPoint) bool IsExposed( const wxPoint& pt );
288 %name(IsExposedRect) bool IsExposed( const wxRect& rect );
289 bool IsRetained();
290 bool IsShown();
291 bool IsTopLevel();
292 void Layout();
293 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
294 void Lower();
295 void MakeModal(bool flag=TRUE);
296 %name(MoveXY)void Move(int x, int y, int flags = wxSIZE_USE_EXISTING);
297 void Move(const wxPoint& point, int flags = wxSIZE_USE_EXISTING);
298
299 wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE);
300 void PushEventHandler(wxEvtHandler* handler);
301
302 // find the given handler in the event handler chain and remove (but
303 // not delete) it from the event handler chain, return TRUE if it was
304 // found and FALSE otherwise (this also results in an assert failure so
305 // this function should only be called when the handler is supposed to
306 // be there)
307 bool RemoveEventHandler(wxEvtHandler *handler);
308
309 %name(PopupMenuXY)bool PopupMenu(wxMenu *menu, int x, int y);
310 bool PopupMenu(wxMenu *menu, const wxPoint& pos);
311
312 void Raise();
313 void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL);
314 void RefreshRect(const wxRect& rect);
315
316 void ReleaseMouse();
317 void RemoveChild(wxWindow* child);
318 bool Reparent( wxWindow* newParent );
319
320 // (uses apply'ed INOUT typemap, see above)
321 %name(ScreenToClientXY)void ScreenToClient(int *x, int *y);
322 wxPoint ScreenToClient(const wxPoint& pt);
323
324 void ScrollWindow(int dx, int dy, const wxRect* rect = NULL);
325 void SetAutoLayout(bool autoLayout);
326 bool GetAutoLayout();
327 void SetBackgroundColour(const wxColour& colour);
328 void SetConstraints(wxLayoutConstraints *constraints);
329 void UnsetConstraints(wxLayoutConstraints *constraints);
330 void SetFocus();
331 bool AcceptsFocus();
332 void SetFont(const wxFont& font);
333 void SetForegroundColour(const wxColour& colour);
334 void SetId(int id);
335 void SetName(const wxString& name);
336 void SetScrollbar(int orientation, int position, int thumbSize, int range, int refresh = TRUE);
337 void SetScrollPos(int orientation, int pos, bool refresh = TRUE);
338
339 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
340 %addmethods {
341 void SetSize(const wxSize& size) {
342 self->SetSize(size);
343 }
344
345 void SetPosition(const wxPoint& pos, int flags = wxSIZE_USE_EXISTING) {
346 self->Move(pos, flags);
347 }
348
349 void SetRect(const wxRect& rect, int sizeFlags=wxSIZE_AUTO) {
350 self->SetSize(rect, sizeFlags);
351 }
352 }
353
354 void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1);
355 %name(SetClientSizeWH)void SetClientSize(int width, int height);
356 void SetClientSize(const wxSize& size);
357 //void SetPalette(wxPalette* palette);
358 void SetCursor(const wxCursor& cursor);
359 void SetEventHandler(wxEvtHandler* handler);
360 void SetExtraStyle(long exStyle);
361 void SetTitle(const wxString& title);
362 bool Show(bool show=TRUE);
363 bool TransferDataFromWindow();
364 bool TransferDataToWindow();
365 void UpdateWindowUI();
366 bool Validate();
367 void WarpPointer(int x, int y);
368
369 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
370 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
371
372 %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt);
373 %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz);
374
375 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
376 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
377
378 %name(SetToolTipString)void SetToolTip(const wxString &tip);
379 void SetToolTip(wxToolTip *tooltip);
380 wxToolTip* GetToolTip();
381
382 void SetSizer(wxSizer* sizer, bool deleteOld=TRUE);
383 wxSizer* GetSizer();
384
385 // Track if this window is a member of a sizer
386 void SetContainingSizer(wxSizer* sizer);
387 wxSizer *GetContainingSizer() const;
388
389 wxValidator* GetValidator();
390 void SetValidator(const wxValidator& validator);
391
392 #ifndef __WXMAC__
393 void SetDropTarget(wxDropTarget* target);
394 wxDropTarget* GetDropTarget();
395 %pragma(python) addtomethod = "SetDropTarget:_args[0].thisown = 0"
396 #endif
397
398 wxSize GetBestSize();
399 wxSize GetMaxSize();
400
401 void SetCaret(wxCaret *caret);
402 wxCaret *GetCaret();
403 %pragma(python) addtoclass = "# replaces broken shadow method
404 def GetCaret(self, *_args, **_kwargs):
405 from misc2 import wxCaretPtr
406 val = apply(windowsc.wxWindow_GetCaret,(self,) + _args, _kwargs)
407 if val: val = wxCaretPtr(val)
408 return val
409 "
410
411 void Freeze();
412 void Thaw();
413 void Update();
414
415 wxString GetHelpText();
416 void SetHelpText(const wxString& helpText);
417 void SetHelpTextForId(const wxString& text);
418
419 bool ScrollLines(int lines);
420 bool ScrollPages(int pages);
421 bool LineUp();
422 bool LineDown();
423 bool PageUp();
424 bool PageDown();
425
426 static wxWindow* FindFocus();
427 static int NewControlId();
428 static int NextControlId(int id);
429 static int PrevControlId(int id);
430
431 void SetAcceleratorTable(const wxAcceleratorTable& accel);
432 wxAcceleratorTable *GetAcceleratorTable();
433
434 #ifdef __WXMSW__
435 // A way to do the native draw first... Too bad it isn't in wxGTK too.
436 void OnPaint(wxPaintEvent& event);
437 #endif
438
439 wxWindow* GetDefaultItem();
440 wxWindow* SetDefaultItem(wxWindow *btn);
441 };
442
443
444
445
446 %pragma(python) code = "
447 def wxDLG_PNT(win, point_or_x, y=None):
448 if y is None:
449 return win.ConvertDialogPointToPixels(point_or_x)
450 else:
451 return win.ConvertDialogPointToPixels(wxPoint(point_or_x, y))
452
453 def wxDLG_SZE(win, size_width, height=None):
454 if height is None:
455 return win.ConvertDialogSizeToPixels(size_width)
456 else:
457 return win.ConvertDialogSizeToPixels(wxSize(size_width, height))
458 "
459
460
461 #ifdef __WXMSW__
462 %inline %{
463 wxWindow* wxWindow_FromHWND(unsigned long hWnd) {
464 wxWindow* win = new wxWindow;
465 win->SetHWND(hWnd);
466 win->SubclassWin(hWnd);
467 return win;
468 }
469 %}
470 #endif
471
472
473 //---------------------------------------------------------------------------
474
475 class wxPanel : public wxWindow {
476 public:
477 wxPanel(wxWindow* parent,
478 const wxWindowID id,
479 const wxPoint& pos = wxDefaultPosition,
480 const wxSize& size = wxDefaultSize,
481 long style = wxTAB_TRAVERSAL,
482 const wxString& name = wxPyPanelNameStr);
483 %name(wxPrePanel)wxPanel();
484
485 bool Create(wxWindow* parent,
486 const wxWindowID id,
487 const wxPoint& pos = wxDefaultPosition,
488 const wxSize& size = wxDefaultSize,
489 long style = wxTAB_TRAVERSAL,
490 const wxString& name = wxPyPanelNameStr);
491
492 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
493 %pragma(python) addtomethod = "wxPrePanel:val._setOORInfo(val)"
494
495 void InitDialog();
496
497 };
498
499 //---------------------------------------------------------------------------
500
501
502 // TODO: Add wrappers for the wxScrollHelper class, make wxScrolledWindow
503 // derive from it and wxPanel.
504
505
506 class wxScrolledWindow : public wxPanel {
507 public:
508 wxScrolledWindow(wxWindow* parent,
509 const wxWindowID id = -1,
510 const wxPoint& pos = wxDefaultPosition,
511 const wxSize& size = wxDefaultSize,
512 long style = wxHSCROLL | wxVSCROLL,
513 const wxString& name = wxPyPanelNameStr);
514 %name(wxPreScrolledWindow)wxScrolledWindow();
515
516 bool Create(wxWindow* parent,
517 const wxWindowID id = -1,
518 const wxPoint& pos = wxDefaultPosition,
519 const wxSize& size = wxDefaultSize,
520 long style = wxHSCROLL | wxVSCROLL,
521 const wxString& name = wxPyPanelNameStr);
522
523 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
524 %pragma(python) addtomethod = "wxPreScrolledWindow:val._setOORInfo(val)"
525
526 void EnableScrolling(bool xScrolling, bool yScrolling);
527 int GetScrollPageSize(int orient);
528 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
529 wxWindow* GetTargetWindow();
530 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
531 bool IsRetained();
532 void PrepareDC(wxDC& dc);
533 void Scroll(int x, int y);
534 void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
535 int noUnitsX, int noUnitsY,
536 int xPos = 0, int yPos = 0, int noRefresh=FALSE);
537 void SetScrollPageSize(int orient, int pageSize);
538 void SetTargetWindow(wxWindow* window);
539 void GetViewStart(int* OUTPUT, int* OUTPUT);
540 %pragma(python) addtoclass = "ViewStart = GetViewStart"
541
542 %name(CalcScrolledPosition1)wxPoint CalcScrolledPosition(const wxPoint& pt);
543 %name(CalcScrolledPosition2)void CalcScrolledPosition( int x, int y, int *OUTPUT, int *OUTPUT);
544
545 %name(CalcUnscrolledPosition1)wxPoint CalcUnscrolledPosition(const wxPoint& pt);
546 %name(CalcUnscrolledPosition2)void CalcUnscrolledPosition( int x, int y, int *OUTPUT, int *OUTPUT);
547
548 %pragma(python) addtoclass = "
549 def CalcScrolledPosition(self, *args):
550 if len(args) == 1:
551 return apply(self.CalcScrolledPosition1, args)
552 elif len(args) == 2:
553 return apply(self.CalcScrolledPosition2, args)
554 else:
555 raise TypeError, 'Invalid parameters: only (x,y) or (point) allowed'
556
557 def CalcUnscrolledPosition(self, *args):
558 if len(args) == 1:
559 return apply(self.CalcUnscrolledPosition1, args)
560 elif len(args) == 2:
561 return apply(self.CalcUnscrolledPosition2, args)
562 else:
563 raise TypeError, 'Invalid parameters: only (x,y) or (point) allowed'
564 "
565
566 void SetScale(double xs, double ys);
567 double GetScaleX();
568 double GetScaleY();
569
570 void AdjustScrollbars();
571
572 bool Layout();
573 };
574
575 //----------------------------------------------------------------------
576
577
578 class wxMenu : public wxEvtHandler {
579 public:
580 wxMenu(const wxString& title = wxPyEmptyString, long style = 0);
581
582 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
583
584 void Append(int id, const wxString& item,
585 const wxString& helpString = wxPyEmptyString,
586 wxItemKind kind = wxItem_Normal);
587 %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu,
588 const wxString& helpString = wxPyEmptyString);
589 %name(AppendItem)void Append(const wxMenuItem* item);
590 void AppendCheckItem(int id,
591 const wxString& text,
592 const wxString& help = wxPyEmptyString);
593 void AppendRadioItem(int id,
594 const wxString& text,
595 const wxString& help = wxPyEmptyString);
596 void AppendSeparator();
597
598
599 void Insert(size_t pos,
600 int id,
601 const wxString& text,
602 const wxString& help = wxPyEmptyString,
603 wxItemKind kind = wxItem_Normal);
604 void InsertSeparator(size_t pos);
605 void InsertCheckItem(size_t pos,
606 int id,
607 const wxString& text,
608 const wxString& help = wxPyEmptyString);
609 void InsertRadioItem(size_t pos,
610 int id,
611 const wxString& text,
612 const wxString& help = wxPyEmptyString);
613 %name(InsertMenu)void Insert(size_t pos,
614 int id,
615 const wxString& text,
616 wxMenu *submenu,
617 const wxString& help = wxPyEmptyString);
618 %name(InsertItem)bool Insert(size_t pos, wxMenuItem *item);
619
620
621 void Prepend(int id,
622 const wxString& text,
623 const wxString& help = wxPyEmptyString,
624 wxItemKind kind = wxItem_Normal);
625 void PrependSeparator();
626 void PrependCheckItem(int id,
627 const wxString& text,
628 const wxString& help = wxPyEmptyString);
629 void PrependRadioItem(int id,
630 const wxString& text,
631 const wxString& help = wxPyEmptyString);
632 %name(PrependMenu)void Prepend(int id,
633 const wxString& text,
634 wxMenu *submenu,
635 const wxString& help = wxPyEmptyString);
636 %name(PrependItem)void Prepend(wxMenuItem *item);
637
638
639 void Break();
640 void Check(int id, bool flag);
641 bool IsChecked(int id);
642 void Enable(int id, bool enable);
643 bool IsEnabled(int id);
644
645 int FindItem(const wxString& itemString);
646 %name(FindItemById)wxMenuItem* FindItem(int id/*, wxMenu **menu = NULL*/);
647
648 wxString GetTitle();
649 void SetTitle(const wxString& title);
650
651 wxString GetLabel(int id);
652 void SetLabel(int id, const wxString& label);
653
654 wxString GetHelpString(int id);
655 void SetHelpString(int id, const wxString& helpString);
656 void UpdateUI(wxEvtHandler* source = NULL);
657
658 bool Delete(int id);
659 %name(DeleteItem)bool Delete(wxMenuItem *item);
660 wxMenuItem *Remove(int id);
661 %name(RemoveItem) wxMenuItem *Remove(wxMenuItem *item);
662
663
664
665
666 %addmethods {
667 void Destroy() { delete self; }
668 }
669 %name(DestroyId)bool Destroy(int id);
670 %name(DestroyItem)bool Destroy(wxMenuItem *item);
671
672 size_t GetMenuItemCount();
673 //wxMenuItemList& GetMenuItems();
674 %addmethods {
675 PyObject* GetMenuItems() {
676 wxMenuItemList& list = self->GetMenuItems();
677 return wxPy_ConvertList(&list, "wxMenuItem");
678 }
679 }
680
681 void SetEventHandler(wxEvtHandler *handler);
682 wxEvtHandler *GetEventHandler();
683
684 void SetInvokingWindow(wxWindow *win);
685 wxWindow *GetInvokingWindow();
686
687 long GetStyle();
688
689 bool IsAttached();
690
691 void SetParent(wxMenu *parent);
692 wxMenu *GetParent();
693 };
694
695
696 //----------------------------------------------------------------------
697
698 class wxMenuBar : public wxWindow {
699 public:
700 wxMenuBar(long style = 0);
701
702 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
703
704 bool Append(wxMenu *menu, const wxString& title);
705 bool Insert(size_t pos, wxMenu *menu, const wxString& title);
706 size_t GetMenuCount();
707 wxMenu *GetMenu(size_t pos);
708 wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
709 wxMenu *Remove(size_t pos);
710 void EnableTop(size_t pos, bool enable);
711 void SetLabelTop(size_t pos, const wxString& label);
712 wxString GetLabelTop(size_t pos);
713 int FindMenu(const wxString& title);
714 int FindMenuItem(const wxString& menuString, const wxString& itemString);
715 %name(FindItemById)wxMenuItem* FindItem(int id/*, wxMenu **menu = NULL*/);
716 void Enable(int id, bool enable);
717 void Check(int id, bool check);
718 bool IsChecked(int id);
719 bool IsEnabled(int id);
720
721 void SetLabel(int id, const wxString &label);
722 wxString GetLabel(int id);
723
724 void SetHelpString(int id, const wxString& helpString);
725 wxString GetHelpString(int id);
726
727 };
728
729
730 //----------------------------------------------------------------------
731
732 class wxMenuItem : public wxObject {
733 public:
734 wxMenuItem(wxMenu* parentMenu=NULL, int id=wxID_SEPARATOR,
735 const wxString& text = wxPyEmptyString,
736 const wxString& help = wxPyEmptyString,
737 wxItemKind kind = wxItem_Normal,
738 wxMenu* subMenu = NULL);
739
740
741 wxMenu *GetMenu();
742 void SetId(int id);
743 int GetId();
744 bool IsSeparator();
745 void SetText(const wxString& str);
746 wxString GetLabel();
747 const wxString& GetText();
748 wxItemKind GetKind();
749 void SetCheckable(bool checkable);
750 bool IsCheckable();
751 bool IsSubMenu();
752 void SetSubMenu(wxMenu *menu);
753 wxMenu *GetSubMenu();
754 void Enable(bool enable = TRUE);
755 bool IsEnabled();
756 void Check(bool check = TRUE);
757 bool IsChecked();
758 void Toggle();
759 void SetHelp(const wxString& str);
760 const wxString& GetHelp();
761 wxAcceleratorEntry *GetAccel();
762 void SetAccel(wxAcceleratorEntry *accel);
763
764 static wxString GetLabelFromText(const wxString& text);
765 // static wxAcceleratorEntry *GetAccelFromString(const wxString& label);
766
767 // wxOwnerDrawn methods
768 #ifdef __WXMSW__
769 void SetFont(const wxFont& font);
770 wxFont GetFont();
771 void SetTextColour(const wxColour& colText);
772 wxColour GetTextColour();
773 void SetBackgroundColour(const wxColour& colBack);
774 wxColour GetBackgroundColour();
775 void SetBitmaps(const wxBitmap& bmpChecked,
776 const wxBitmap& bmpUnchecked = wxNullBitmap);
777 void SetBitmap(const wxBitmap& bmpChecked);
778 wxBitmap GetBitmap(bool bChecked = TRUE);
779 void SetMarginWidth(int nWidth);
780 int GetMarginWidth();
781 static int GetDefaultMarginWidth();
782 //void SetName(const wxString& strName);
783 //const wxString& GetName();
784 //void SetCheckable(bool checkable);
785 //bool IsCheckable();
786 bool IsOwnerDrawn();
787 void ResetOwnerDrawn();
788 #endif
789 };
790
791 //---------------------------------------------------------------------------
792
793
794