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