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