]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/windows.i
fix for brain dead egcs - this stupid compiler not only doesn't compile what it shoul...
[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();
10e07c70 216 bool IsBeingDeleted();
853b255a 217#ifdef __WXMSW__
7bf85405 218 void DragAcceptFiles(bool accept);
853b255a 219#endif
7bf85405
RD
220 void Enable(bool enable);
221 //bool FakePopupMenu(wxMenu* menu, int x, int y);
af309447 222 %name(FindWindowById) wxWindow* FindWindow(long id);
714e6a9e 223 %name(FindWindowByName) wxWindow* FindWindow(const wxString& name);
7bf85405
RD
224 void Fit();
225 wxColour GetBackgroundColour();
d426c97e
RD
226
227 //wxList& GetChildren();
228 %addmethods {
229 PyObject* GetChildren() {
230 wxWindowList& list = self->GetChildren();
231 return wxPy_ConvertList(&list, "wxWindow");
232 }
233 }
234
7bf85405
RD
235 int GetCharHeight();
236 int GetCharWidth();
b8b8dda7
RD
237 %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT);
238 wxSize GetClientSize();
7bf85405 239 wxLayoutConstraints * GetConstraints();
3ab72185 240 wxEvtHandler* GetEventHandler();
105e45b9 241
b8b8dda7 242 wxFont& GetFont();
7bf85405
RD
243 wxColour GetForegroundColour();
244 wxWindow * GetGrandParent();
2abc0a0f
RD
245 %addmethods {
246 long GetHandle() {
54b96882 247 return wxPyGetWinHandle(self); //(long)self->GetHandle();
2abc0a0f
RD
248 }
249 }
7bf85405 250 int GetId();
853b255a 251 wxString GetLabel();
bb0054cd 252 void SetLabel(const wxString& label);
853b255a 253 wxString GetName();
7bf85405 254 wxWindow * GetParent();
b8b8dda7
RD
255 %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT);
256 wxPoint GetPosition();
257 wxRect GetRect();
7bf85405
RD
258 int GetScrollThumb(int orientation);
259 int GetScrollPos(int orientation);
260 int GetScrollRange(int orientation);
b8b8dda7
RD
261 %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT);
262 wxSize GetSize();
af309447
RD
263 void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT);
264 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
265 int *OUTPUT, int *OUTPUT, int *OUTPUT, int* OUTPUT,
266 const wxFont* font = NULL); //, bool use16 = FALSE)
853b255a 267 wxString GetTitle();
8bf5d46e 268 wxRegion GetUpdateRegion();
7bf85405 269 long GetWindowStyleFlag();
f6bcfd97
BP
270 void SetWindowStyleFlag(long style);
271 void SetWindowStyle(long style);
bb0054cd 272 bool Hide();
7bf85405
RD
273 void InitDialog();
274 bool IsEnabled();
1b55cabf
RD
275 bool IsExposed( int x, int y, int w=0, int h=0 );
276 %name(IsExposedPoint) bool IsExposed( const wxPoint& pt );
277 %name(IsExposedRect) bool IsExposed( const wxRect& rect );
7bf85405
RD
278 bool IsRetained();
279 bool IsShown();
bb0054cd 280 bool IsTopLevel();
7bf85405
RD
281 void Layout();
282 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
283 void Lower();
284 void MakeModal(bool flag);
af309447
RD
285 %name(MoveXY)void Move(int x, int y);
286 void Move(const wxPoint& point);
7bf85405 287
3ab72185
RD
288 wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE);
289 void PushEventHandler(wxEvtHandler* handler);
7bf85405 290
8bf5d46e
RD
291 %name(PopupMenuXY)bool PopupMenu(wxMenu *menu, int x, int y);
292 bool PopupMenu(wxMenu *menu, const wxPoint& pos);
293
7bf85405
RD
294 void Raise();
295 void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL);
296 void ReleaseMouse();
b7e72427 297 void RemoveChild(wxWindow* child);
bb0054cd
RD
298 bool Reparent( wxWindow* newParent );
299
efc5f224
RD
300 // (uses apply'ed INOUT typemap, see above)
301 %name(ScreenToClientXY)void ScreenToClient(int *x, int *y);
af309447
RD
302 wxPoint ScreenToClient(const wxPoint& pt);
303
7bf85405 304 void ScrollWindow(int dx, int dy, const wxRect* rect = NULL);
b8b8dda7 305 void SetAcceleratorTable(const wxAcceleratorTable& accel);
7bf85405 306 void SetAutoLayout(bool autoLayout);
1dec68aa 307 bool GetAutoLayout();
7bf85405
RD
308 void SetBackgroundColour(const wxColour& colour);
309 void SetConstraints(wxLayoutConstraints *constraints);
2f90df85 310 void UnsetConstraints(wxLayoutConstraints *constraints);
7bf85405 311 void SetFocus();
2f90df85 312 bool AcceptsFocus();
7bf85405
RD
313 void SetFont(const wxFont& font);
314 void SetForegroundColour(const wxColour& colour);
315 void SetId(int id);
316 void SetName(const wxString& name);
eb715945 317 void SetScrollbar(int orientation, int position, int thumbSize, int range, int refresh = TRUE);
7bf85405
RD
318 void SetScrollPos(int orientation, int pos, bool refresh = TRUE);
319
7bf85405
RD
320 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
321 %addmethods {
322 void SetSize(const wxSize& size) {
b7e72427 323 self->SetSize(size);
7bf85405
RD
324 }
325
326 void SetPosition(const wxPoint& pos) {
b7e72427 327 self->Move(pos);
7bf85405 328 }
33510773
RD
329
330 void SetRect(const wxRect& rect, int sizeFlags=wxSIZE_AUTO) {
331 self->SetSize(rect, sizeFlags);
332 }
7bf85405
RD
333 }
334
335 void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1);
af309447
RD
336 %name(SetClientSizeWH)void SetClientSize(int width, int height);
337 void SetClientSize(const wxSize& size);
7bf85405 338 //void SetPalette(wxPalette* palette);
7bf85405 339 void SetCursor(const wxCursor&cursor);
3ab72185 340 void SetEventHandler(wxEvtHandler* handler);
83b18bab 341 void SetExtraStyle(long exStyle);
7bf85405
RD
342 void SetTitle(const wxString& title);
343 bool Show(bool show);
344 bool TransferDataFromWindow();
345 bool TransferDataToWindow();
346 bool Validate();
347 void WarpPointer(int x, int y);
348
b8b8dda7
RD
349 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
350 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
351
cf694132
RD
352 %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt);
353 %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz);
354
b8b8dda7
RD
355 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
356 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
357
af309447
RD
358 %name(SetToolTipString)void SetToolTip(const wxString &tip);
359 void SetToolTip(wxToolTip *tooltip);
360 wxToolTip* GetToolTip();
2f90df85
RD
361
362 void SetSizer(wxSizer* sizer);
f6bcfd97
BP
363 wxSizer* GetSizer();
364
2f90df85
RD
365 wxValidator* GetValidator();
366 void SetValidator(const wxValidator& validator);
367
b1462dfa
RD
368 void SetDropTarget(wxDropTarget* target);
369 wxDropTarget* GetDropTarget();
370 %pragma(python) addtomethod = "SetDropTarget:_args[0].thisown = 0"
694759cf
RD
371
372 wxSize GetBestSize();
a1df7a95
RD
373
374 void SetCaret(wxCaret *caret);
375 wxCaret *GetCaret();
9416aa89 376 %pragma(python) addtoclass = "# replaces broken shadow method
a1df7a95
RD
377 def GetCaret(self, *_args, **_kwargs):
378 from misc2 import wxCaretPtr
379 val = apply(windowsc.wxWindow_GetCaret,(self,) + _args, _kwargs)
380 if val: val = wxCaretPtr(val)
381 return val
f6bcfd97 382 "
c368d904
RD
383
384
385// // Properties list
386// %pragma(python) addtoclass = "
387// _prop_list_ = {
388// 'size' : ('GetSize', 'SetSize'),
389// 'enabled' : ('IsEnabled', 'Enable'),
390// 'background' : ('GetBackgroundColour', 'SetBackgroundColour'),
391// 'foreground' : ('GetForegroundColour', 'SetForegroundColour'),
392// 'children' : ('GetChildren', None),
393// 'charHeight' : ('GetCharHeight', None),
394// 'charWidth' : ('GetCharWidth', None),
395// 'clientSize' : ('GetClientSize', 'SetClientSize'),
396// 'font' : ('GetFont', 'SetFont'),
397// 'grandParent' : ('GetGrandParent', None),
398// 'handle' : ('GetHandle', None),
399// 'label' : ('GetLabel', 'SetLabel'),
400// 'name' : ('GetName', 'SetName'),
401// 'parent' : ('GetParent', None),
402// 'position' : ('GetPosition', 'SetPosition'),
403// 'title' : ('GetTitle', 'SetTitle'),
404// 'style' : ('GetWindowStyleFlag', 'SetWindowStyleFlag'),
405// 'visible' : ('IsShown', 'Show'),
406// 'toolTip' : ('GetToolTip', 'SetToolTip'),
407// 'sizer' : ('GetSizer', 'SetSizer'),
408// 'validator' : ('GetValidator', 'SetValidator'),
409// 'dropTarget' : ('GetDropTarget', 'SetDropTarget'),
410// 'caret' : ('GetCaret', 'SetCaret'),
411// 'autoLayout' : ('GetAutoLayout', 'SetAutoLayout'),
412// 'constraints' : ('GetConstraints', 'SetConstraints'),
413
414// }
415// _prop_list_.update(wxEvtHandler._prop_list_)
416// "
7bf85405
RD
417};
418
efc5f224
RD
419
420
421
b8b8dda7 422%pragma(python) code = "
bb0054cd
RD
423def wxDLG_PNT(win, point_or_x, y=None):
424 if y is None:
425 return win.ConvertDialogPointToPixels(point_or_x)
426 else:
427 return win.ConvertDialogPointToPixels(wxPoint(point_or_x, y))
428
429def wxDLG_SZE(win, size_width, height=None):
430 if height is None:
431 return win.ConvertDialogSizeToPixels(size_width)
432 else:
433 return win.ConvertDialogSizeToPixels(wxSize(size_width, height))
b8b8dda7 434"
7bf85405 435
7bf85405
RD
436%inline %{
437 wxWindow* wxWindow_FindFocus() {
438 return wxWindow::FindFocus();
439 }
440%}
af309447
RD
441
442
c368d904 443#ifdef __WXMSW__
af309447
RD
444%inline %{
445wxWindow* wxWindow_FromHWND(unsigned long hWnd) {
446 wxWindow* win = new wxWindow;
447 win->SetHWND(hWnd);
448 win->SubclassWin(hWnd);
449 return win;
450}
451%}
853b255a 452#endif
7bf85405 453
a1df7a95
RD
454%inline %{
455 int wxWindow_NewControlId() {
456 return wxWindow::NewControlId();
457 }
458 int wxWindow_NextControlId(int id) {
459 return wxWindow::NextControlId(id);
460 }
461 int wxWindow_PrevControlId(int id) {
462 return wxWindow::PrevControlId(id);
463 }
464%}
7bf85405 465
efc5f224 466
7bf85405
RD
467//---------------------------------------------------------------------------
468
469class wxPanel : public wxWindow {
470public:
471 wxPanel(wxWindow* parent,
472 const wxWindowID id,
b68dc582
RD
473 const wxPoint& pos = wxDefaultPosition,
474 const wxSize& size = wxDefaultSize,
7bf85405
RD
475 long style = wxTAB_TRAVERSAL,
476 const char* name = "panel");
477
f6bcfd97 478 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 479
7bf85405 480 void InitDialog();
bb0054cd
RD
481 wxButton* GetDefaultItem();
482 void SetDefaultItem(wxButton *btn);
483
7bf85405
RD
484};
485
486//---------------------------------------------------------------------------
487
488class wxDialog : public wxPanel {
489public:
490 wxDialog(wxWindow* parent,
491 const wxWindowID id,
492 const wxString& title,
b68dc582
RD
493 const wxPoint& pos = wxDefaultPosition,
494 const wxSize& size = wxDefaultSize,
7bf85405
RD
495 long style = wxDEFAULT_DIALOG_STYLE,
496 const char* name = "dialogBox");
497
f6bcfd97 498 %pragma(python) addtomethod = "__init__:#wx._StdDialogCallbacks(self)"
9c039d08 499
7bf85405
RD
500 void Centre(int direction = wxBOTH);
501 void EndModal(int retCode);
502 wxString GetTitle();
503 void Iconize(bool iconize);
504 bool IsIconized();
7bf85405 505 void SetModal(bool flag);
853b255a 506 bool IsModal();
7bf85405
RD
507 void SetTitle(const wxString& title);
508 bool Show(bool show);
509 int ShowModal();
4cd9591a
RD
510
511 int GetReturnCode();
512 void SetReturnCode(int retCode);
f3d9dc1d
RD
513
514 wxSizer* CreateTextSizer( const wxString &message );
515 wxSizer* CreateButtonSizer( long flags );
516
7bf85405
RD
517};
518
519//---------------------------------------------------------------------------
520
bb0054cd 521class wxScrolledWindow : public wxPanel {
7bf85405
RD
522public:
523 wxScrolledWindow(wxWindow* parent,
524 const wxWindowID id = -1,
b68dc582
RD
525 const wxPoint& pos = wxDefaultPosition,
526 const wxSize& size = wxDefaultSize,
7bf85405
RD
527 long style = wxHSCROLL | wxVSCROLL,
528 char* name = "scrolledWindow");
529
f6bcfd97
BP
530 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
531 %pragma(python) addtomethod = "__init__:#wx._StdOnScrollCallbacks(self)"
9c039d08 532
7bf85405 533 void EnableScrolling(bool xScrolling, bool yScrolling);
b7e72427 534 int GetScrollPageSize(int orient);
7bf85405 535 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
b7e72427 536 wxWindow* GetTargetWindow();
7bf85405
RD
537 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
538 bool IsRetained();
539 void PrepareDC(wxDC& dc);
540 void Scroll(int x, int y);
541 void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
542 int noUnitsX, int noUnitsY,
f6bcfd97 543 int xPos = 0, int yPos = 0, int noRefresh=FALSE);
b7e72427 544 void SetScrollPageSize(int orient, int pageSize);
eb715945 545 void SetTargetWindow(wxWindow* window);
4c9993c3 546 void GetViewStart(int* OUTPUT, int* OUTPUT);
7bf85405 547 void ViewStart(int* OUTPUT, int* OUTPUT);
9d8bd15f
RD
548
549 void CalcScrolledPosition( int x, int y, int *OUTPUT, int *OUTPUT);
550 void CalcUnscrolledPosition( int x, int y, int *OUTPUT, int *OUTPUT);
551
d1679124
RD
552 void SetScale(double xs, double ys);
553 double GetScaleX();
554 double GetScaleY();
555
556 void AdjustScrollbars();
7bf85405
RD
557};
558
559//----------------------------------------------------------------------
560
561
562class wxMenu : public wxEvtHandler {
563public:
8bf5d46e 564 wxMenu(const wxString& title = wxPyEmptyStr, long style = 0);
7bf85405
RD
565
566 void Append(int id, const wxString& item,
567 const wxString& helpString = wxPyEmptyStr,
926bb76c 568 int checkable = FALSE);
7bf85405
RD
569 %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu,
570 const wxString& helpString = wxPyEmptyStr);
af309447
RD
571 %name(AppendItem)void Append(const wxMenuItem* item);
572
7bf85405
RD
573 void AppendSeparator();
574 void Break();
575 void Check(int id, bool flag);
b1462dfa 576 bool IsChecked(int id);
7bf85405 577 void Enable(int id, bool enable);
b1462dfa
RD
578 bool IsEnabled(int id);
579
7bf85405 580 int FindItem(const wxString& itemString);
b1462dfa
RD
581 %name(FindItemById)wxMenuItem* FindItem(int id/*, wxMenu **menu = NULL*/);
582
7bf85405 583 wxString GetTitle();
7bf85405 584 void SetTitle(const wxString& title);
b1462dfa 585
714e6a9e 586 wxString GetLabel(int id);
853b255a 587 void SetLabel(int id, const wxString& label);
b1462dfa
RD
588
589 wxString GetHelpString(int id);
590 void SetHelpString(int id, const wxString& helpString);
8bf5d46e 591 void UpdateUI(wxEvtHandler* source = NULL);
efc5f224 592
b1462dfa
RD
593 bool Delete(int id);
594 %name(DeleteItem)bool Delete(wxMenuItem *item);
595 bool Insert(size_t pos, wxMenuItem *item);
596 wxMenuItem *Remove(int id);
597 %name(RemoveItem) wxMenuItem *Remove(wxMenuItem *item);
598
efc5f224 599 %addmethods {
eb715945 600 void Destroy() { delete self; }
efc5f224 601 }
b1462dfa
RD
602 %name(DestroyId)bool Destroy(int id);
603 %name(DestroyItem)bool Destroy(wxMenuItem *item);
efc5f224 604
b1462dfa
RD
605 size_t GetMenuItemCount();
606 //wxMenuItemList& GetMenuItems();
607 %addmethods {
608 PyObject* GetMenuItems() {
609 wxMenuItemList& list = self->GetMenuItems();
610 return wxPy_ConvertList(&list, "wxMenuItem");
611 }
612 }
7bf85405 613
b1462dfa
RD
614 void SetEventHandler(wxEvtHandler *handler);
615 wxEvtHandler *GetEventHandler();
616
617 void SetInvokingWindow(wxWindow *win);
618 wxWindow *GetInvokingWindow();
619
620 long GetStyle();
621
622 bool IsAttached();
623
624 void SetParent(wxMenu *parent);
625 wxMenu *GetParent();
626};
7bf85405 627
7bf85405
RD
628
629//----------------------------------------------------------------------
630
b1462dfa 631class wxMenuBar : public wxWindow {
7bf85405 632public:
c368d904 633 wxMenuBar(long style = 0);
7bf85405 634
b1462dfa
RD
635 bool Append(wxMenu *menu, const wxString& title);
636 bool Insert(size_t pos, wxMenu *menu, const wxString& title);
637 size_t GetMenuCount();
638 wxMenu *GetMenu(size_t pos);
639 wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
640 wxMenu *Remove(size_t pos);
641 void EnableTop(size_t pos, bool enable);
642 void SetLabelTop(size_t pos, const wxString& label);
643 wxString GetLabelTop(size_t pos);
644 int FindMenuItem(const wxString& menuString, const wxString& itemString);
645 %name(FindItemById)wxMenuItem* FindItem(int id/*, wxMenu **menu = NULL*/);
7bf85405 646 void Enable(int id, bool enable);
b1462dfa 647 void Check(int id, bool check);
2abc0a0f
RD
648 bool IsChecked(int id);
649 bool IsEnabled(int id);
b1462dfa
RD
650
651 void SetLabel(int id, const wxString &label);
7bf85405 652 wxString GetLabel(int id);
b1462dfa 653
7bf85405 654 void SetHelpString(int id, const wxString& helpString);
b1462dfa 655 wxString GetHelpString(int id);
2abc0a0f 656
7bf85405
RD
657};
658
659
660//----------------------------------------------------------------------
661
9416aa89 662class wxMenuItem : public wxObject {
7bf85405 663public:
4c9993c3 664 wxMenuItem(wxMenu* parentMenu=NULL, int id=wxID_SEPARATOR,
cf694132 665 const wxString& text = wxPyEmptyStr,
b1462dfa
RD
666 const wxString& help = wxPyEmptyStr,
667 bool isCheckable = FALSE, wxMenu* subMenu = NULL);
cf694132 668
b1462dfa
RD
669
670 wxMenu *GetMenu();
2abc0a0f 671 void SetId(int id);
b1462dfa
RD
672 int GetId();
673 bool IsSeparator();
2abc0a0f 674 void SetText(const wxString& str);
b1462dfa 675 wxString GetLabel();
2abc0a0f 676 const wxString& GetText();
2abc0a0f 677 void SetCheckable(bool checkable);
b1462dfa
RD
678 bool IsCheckable();
679 bool IsSubMenu();
2abc0a0f 680 void SetSubMenu(wxMenu *menu);
b1462dfa
RD
681 wxMenu *GetSubMenu();
682 void Enable(bool enable = TRUE);
683 bool IsEnabled();
684 void Check(bool check = TRUE);
685 bool IsChecked();
686 void Toggle();
687 void SetHelp(const wxString& str);
688 const wxString& GetHelp();
689 wxAcceleratorEntry *GetAccel();
690 void SetAccel(wxAcceleratorEntry *accel);
691
1b62f00d
RD
692 static wxString GetLabelFromText(const wxString& text);
693
f3d9dc1d 694 // wxOwnerDrawn methods
4662be59 695#ifdef __WXMSW__
f3d9dc1d
RD
696 void SetFont(const wxFont& font);
697 wxFont& GetFont();
698 void SetTextColour(const wxColour& colText);
25832b3f 699 wxColour GetTextColour();
f3d9dc1d 700 void SetBackgroundColour(const wxColour& colBack);
25832b3f 701 wxColour GetBackgroundColour();
f3d9dc1d
RD
702 void SetBitmaps(const wxBitmap& bmpChecked,
703 const wxBitmap& bmpUnchecked = wxNullBitmap);
704 void SetBitmap(const wxBitmap& bmpChecked);
705 const wxBitmap& GetBitmap(bool bChecked = TRUE);
706 void SetMarginWidth(int nWidth);
707 int GetMarginWidth();
708 static int GetDefaultMarginWidth();
709 //void SetName(const wxString& strName);
710 //const wxString& GetName();
711 //void SetCheckable(bool checkable);
712 //bool IsCheckable();
713 bool IsOwnerDrawn();
714 void ResetOwnerDrawn();
4662be59 715#endif
7bf85405
RD
716};
717
718//---------------------------------------------------------------------------
7bf85405
RD
719
720
694759cf 721