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