1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG definitions of various window classes
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
18 #include <wx/menuitem.h>
21 //----------------------------------------------------------------------
24 %include my_typemaps.i
26 // Import some definitions of other classes, etc.
32 %pragma(python) code = "import wx"
34 //---------------------------------------------------------------------------
38 bool ProcessEvent(wxEvent& event);
39 //bool SearchEventTable(wxEventTable& table, wxEvent& event);
41 bool GetEvtHandlerEnabled();
42 void SetEvtHandlerEnabled(bool enabled);
44 wxEvtHandler* GetNextHandler();
45 wxEvtHandler* GetPreviousHandler();
46 void SetNextHandler(wxEvtHandler* handler);
47 void SetPreviousHandler(wxEvtHandler* handler);
51 void Connect( int id, int lastId, int eventType, PyObject* func) {
52 if (PyCallable_Check(func)) {
53 self->Connect(id, lastId, eventType,
54 (wxObjectEventFunction) &wxPyCallback::EventThunker,
55 new wxPyCallback(func));
62 //----------------------------------------------------------------------
64 class wxValidator : public wxEvtHandler {
70 wxWindow* GetWindow();
71 void SetWindow(wxWindow* window);
75 bool wxValidator_IsSilent() {
76 return wxValidator::IsSilent();
79 void wxValidator_SetBellOnError(int doIt = TRUE) {
80 wxValidator::SetBellOnError(doIt);
84 //----------------------------------------------------------------------
86 class wxPyValidator : public wxValidator {
87 DECLARE_DYNAMIC_CLASS(wxPyValidator);
91 // wxPyValidator(const wxPyValidator& other);
96 wxObject* wxPyValidator::Clone() const {
97 wxPyValidator* ptr = NULL;
98 wxPyValidator* self = (wxPyValidator*)this;
100 bool doSave = wxPyRestoreThread();
101 if (self->m_myInst.findCallback("Clone")) {
103 ro = self->m_myInst.callCallbackObj(Py_BuildValue("()"));
104 SWIG_GetPtrObj(ro, (void **)&ptr, "_wxPyValidator_p");
106 // This is very dangerous!!! But is the only way I could find
107 // to squash a memory leak. Currently it is okay, but if the
108 // validator architecture in wxWindows ever changes, problems
112 wxPySaveThread(doSave);
117 DEC_PYCALLBACK_BOOL_WXWIN(Validate);
118 DEC_PYCALLBACK_BOOL_(TransferToWindow);
119 DEC_PYCALLBACK_BOOL_(TransferFromWindow);
125 IMP_PYCALLBACK_BOOL_WXWIN(wxPyValidator, wxValidator, Validate);
126 IMP_PYCALLBACK_BOOL_(wxPyValidator, wxValidator, TransferToWindow);
127 IMP_PYCALLBACK_BOOL_(wxPyValidator, wxValidator, TransferFromWindow);
129 IMPLEMENT_DYNAMIC_CLASS(wxPyValidator, wxValidator);
133 class wxPyValidator : public wxValidator {
139 void Destroy() { delete self; }
142 void _setSelf(PyObject* self, int incref=TRUE);
143 %pragma(python) addtomethod = "__init__:self._setSelf(self, 0)"
147 //----------------------------------------------------------------------
149 %apply int * INOUT { int* x, int* y };
151 class wxWindow : public wxEvtHandler {
154 wxWindow(wxWindow* parent, const wxWindowID id,
155 const wxPoint& pos = wxPyDefaultPosition,
156 const wxSize& size = wxPyDefaultSize,
158 char* name = "panel");
160 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
163 void Center(int direction = wxBOTH);
164 void Centre(int direction = wxBOTH);
165 void CentreOnParent(int direction = wxBOTH );
166 void CenterOnParent(int direction = wxBOTH );
168 // (uses apply'ed INOUT typemap, see above)
169 %name(ClientToScreenXY)void ClientToScreen(int* x, int* y);
170 wxPoint ClientToScreen(const wxPoint& pt);
172 bool Close(int force = FALSE);
174 void DestroyChildren();
176 void DragAcceptFiles(bool accept);
178 void Enable(bool enable);
179 //bool FakePopupMenu(wxMenu* menu, int x, int y);
180 %name(FindWindowById) wxWindow* FindWindow(long id);
181 %name(FindWindowByName) wxWindow* FindWindow(const wxString& name);
183 wxColour GetBackgroundColour();
185 //wxList& GetChildren();
187 PyObject* GetChildren() {
188 wxWindowList& list = self->GetChildren();
189 return wxPy_ConvertList(&list, "wxWindow");
196 %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT);
197 wxSize GetClientSize();
198 wxLayoutConstraints * GetConstraints();
199 wxEvtHandler* GetEventHandler();
202 wxColour GetForegroundColour();
203 wxWindow * GetGrandParent();
206 void SetLabel(const wxString& label);
208 wxWindow * GetParent();
209 %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT);
210 wxPoint GetPosition();
212 int GetScrollThumb(int orientation);
213 int GetScrollPos(int orientation);
214 int GetScrollRange(int orientation);
215 %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT);
217 void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT);
218 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
219 int *OUTPUT, int *OUTPUT, int *OUTPUT, int* OUTPUT,
220 const wxFont* font = NULL); //, bool use16 = FALSE)
222 wxRegion GetUpdateRegion();
223 long GetWindowStyleFlag();
231 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
233 void MakeModal(bool flag);
234 %name(MoveXY)void Move(int x, int y);
235 void Move(const wxPoint& point);
237 wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE);
238 void PushEventHandler(wxEvtHandler* handler);
240 %name(PopupMenuXY)bool PopupMenu(wxMenu *menu, int x, int y);
241 bool PopupMenu(wxMenu *menu, const wxPoint& pos);
244 void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL);
246 bool Reparent( wxWindow* newParent );
248 // (uses apply'ed INOUT typemap, see above)
249 %name(ScreenToClientXY)void ScreenToClient(int *x, int *y);
250 wxPoint ScreenToClient(const wxPoint& pt);
252 void ScrollWindow(int dx, int dy, const wxRect* rect = NULL);
253 void SetAcceleratorTable(const wxAcceleratorTable& accel);
254 void SetAutoLayout(bool autoLayout);
255 void SetBackgroundColour(const wxColour& colour);
256 void SetConstraints(wxLayoutConstraints *constraints);
257 void UnsetConstraints(wxLayoutConstraints *constraints);
260 void SetFont(const wxFont& font);
261 void SetForegroundColour(const wxColour& colour);
263 void SetName(const wxString& name);
264 void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh = TRUE);
265 void SetScrollPos(int orientation, int pos, bool refresh = TRUE);
267 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
269 void SetSize(const wxSize& size) {
270 self->SetSize(size.x, size.y);
273 void SetPosition(const wxPoint& pos) {
274 self->SetSize(pos.x, pos.y, -1, -1);
278 void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1);
279 %name(SetClientSizeWH)void SetClientSize(int width, int height);
280 void SetClientSize(const wxSize& size);
281 //void SetPalette(wxPalette* palette);
282 void SetCursor(const wxCursor&cursor);
283 void SetEventHandler(wxEvtHandler* handler);
284 void SetTitle(const wxString& title);
285 bool Show(bool show);
286 bool TransferDataFromWindow();
287 bool TransferDataToWindow();
289 void WarpPointer(int x, int y);
291 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
292 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
294 %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt);
295 %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz);
297 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
298 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
300 %name(SetToolTipString)void SetToolTip(const wxString &tip);
301 void SetToolTip(wxToolTip *tooltip);
302 wxToolTip* GetToolTip();
304 void SetSizer(wxSizer* sizer);
305 wxValidator* GetValidator();
306 void SetValidator(const wxValidator& validator);
310 //%clear int* x, int* y;
314 %pragma(python) code = "
315 def wxDLG_PNT(win, point_or_x, y=None):
317 return win.ConvertDialogPointToPixels(point_or_x)
319 return win.ConvertDialogPointToPixels(wxPoint(point_or_x, y))
321 def wxDLG_SZE(win, size_width, height=None):
323 return win.ConvertDialogSizeToPixels(size_width)
325 return win.ConvertDialogSizeToPixels(wxSize(size_width, height))
330 wxWindow* wxWindow_FindFocus() {
331 return wxWindow::FindFocus();
337 wxWindow* wxWindow_FromHWND(unsigned long hWnd) {
338 wxWindow* win = new wxWindow;
340 win->SubclassWin(hWnd);
348 //---------------------------------------------------------------------------
350 class wxPanel : public wxWindow {
352 wxPanel(wxWindow* parent,
354 const wxPoint& pos = wxPyDefaultPosition,
355 const wxSize& size = wxPyDefaultSize,
356 long style = wxTAB_TRAVERSAL,
357 const char* name = "panel");
359 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
362 wxButton* GetDefaultItem();
363 void SetDefaultItem(wxButton *btn);
365 // fix some SWIG trouble...
366 %pragma(python) addtoclass = "
367 def GetDefaultItem(self):
369 val = windowsc.wxPanel_GetDefaultItem(self.this)
370 val = controls.wxButtonPtr(val)
375 //---------------------------------------------------------------------------
377 class wxDialog : public wxPanel {
379 wxDialog(wxWindow* parent,
381 const wxString& title,
382 const wxPoint& pos = wxPyDefaultPosition,
383 const wxSize& size = wxPyDefaultSize,
384 long style = wxDEFAULT_DIALOG_STYLE,
385 const char* name = "dialogBox");
387 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
389 void Centre(int direction = wxBOTH);
390 void EndModal(int retCode);
392 void Iconize(bool iconize);
394 void SetModal(bool flag);
396 void SetTitle(const wxString& title);
397 bool Show(bool show);
401 void SetReturnCode(int retCode);
404 //---------------------------------------------------------------------------
406 class wxScrolledWindow : public wxPanel {
408 wxScrolledWindow(wxWindow* parent,
409 const wxWindowID id = -1,
410 const wxPoint& pos = wxPyDefaultPosition,
411 const wxSize& size = wxPyDefaultSize,
412 long style = wxHSCROLL | wxVSCROLL,
413 char* name = "scrolledWindow");
415 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
416 %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)"
418 void EnableScrolling(bool xScrolling, bool yScrolling);
419 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
420 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
422 void PrepareDC(wxDC& dc);
423 void Scroll(int x, int y);
424 void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
425 int noUnitsX, int noUnitsY,
426 int xPos = 0, int yPos = 0);
427 void ViewStart(int* OUTPUT, int* OUTPUT);
430 //----------------------------------------------------------------------
433 class wxMenu : public wxEvtHandler {
435 wxMenu(const wxString& title = wxPyEmptyStr, long style = 0);
437 void Append(int id, const wxString& item,
438 const wxString& helpString = wxPyEmptyStr,
439 int checkable = FALSE);
440 %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu,
441 const wxString& helpString = wxPyEmptyStr);
442 %name(AppendItem)void Append(const wxMenuItem* item);
444 void AppendSeparator();
446 void Check(int id, bool flag);
447 void Enable(int id, bool enable);
448 int FindItem(const wxString& itemString);
450 void SetTitle(const wxString& title);
451 wxMenuItem* FindItemForId(int id);
452 wxString GetHelpString(int id);
453 wxString GetLabel(int id);
454 void SetHelpString(int id, const wxString& helpString);
455 bool IsChecked(int id);
456 bool IsEnabled(int id);
457 void SetLabel(int id, const wxString& label);
458 void UpdateUI(wxEvtHandler* source = NULL);
470 // This one knows how to set a callback and handle INC- and DECREFing it. To
471 // be used for PopupMenus, but you must retain a referece to it while using
474 // class wxPyMenu : public wxMenu {
476 // wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL);
480 //----------------------------------------------------------------------
482 class wxMenuBar : public wxEvtHandler {
486 void Append(wxMenu *menu, const wxString& title);
487 void Check(int id, bool flag);
488 bool Checked(int id);
489 void Enable(int id, bool enable);
490 bool Enabled(int id);
491 int FindMenuItem(const wxString& menuString, const wxString& itemString);
492 wxMenuItem * FindItemForId(int id);
493 void SetLabel(int id, const wxString& label);
494 void EnableTop(int pos, bool enable);
495 wxString GetHelpString(int id);
496 wxString GetLabel(int id);
497 void SetHelpString(int id, const wxString& helpString);
498 wxString GetLabelTop(int pos);
499 void SetLabelTop(int pos, const wxString& label);
501 wxMenu* GetMenu(int i);
505 //----------------------------------------------------------------------
510 wxMenuItem(wxMenu* parentMenu=NULL, int id=ID_SEPARATOR,
511 const wxString& text = wxPyEmptyStr,
512 const wxString& helpString = wxPyEmptyStr,
513 bool checkable = FALSE, wxMenu* subMenu = NULL);
523 wxMenu* GetSubMenu();
524 void SetName(const wxString& strName);
527 void SetHelp(const wxString& strHelp);
528 void Enable(bool bDoEnable = TRUE);
529 void Check(bool bDoCheck = TRUE);
532 wxColour& GetBackgroundColour();
533 wxBitmap GetBitmap(bool checked = TRUE);
535 int GetMarginWidth();
536 wxColour& GetTextColour();
537 void SetBackgroundColour(const wxColour& colour);
538 void SetBitmaps(const wxBitmap& checked, const wxBitmap& unchecked = wxNullBitmap);
539 void SetFont(const wxFont& font);
540 void SetMarginWidth(int width);
541 void SetTextColour(const wxColour& colour);
542 void DeleteSubMenu();
546 //---------------------------------------------------------------------------