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