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.
31 %pragma(python) code = "import wx"
32 //%pragma(python) code = "import controls"
33 //%pragma(python) code = "wxButtonPtr = controls.wxWindowPtr"
35 //---------------------------------------------------------------------------
39 bool ProcessEvent(wxEvent& event);
41 void Connect( int id, int lastId, int eventType, PyObject* func) {
42 if (PyCallable_Check(func)) {
43 self->Connect(id, lastId, eventType,
44 (wxObjectEventFunction) &wxPyCallback::EventThunker,
45 new wxPyCallback(func));
52 //----------------------------------------------------------------------
55 class wxWindow : public wxEvtHandler {
58 wxWindow(wxWindow* parent, const wxWindowID id,
59 const wxPoint& pos = wxPyDefaultPosition,
60 const wxSize& size = wxPyDefaultSize,
62 char* name = "panel");
64 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
67 void Center(int direction = wxBOTH);
68 void Centre(int direction = wxBOTH);
69 void CentreOnParent(int direction = wxBOTH );
70 void CenterOnParent(int direction = wxBOTH );
71 %name(ClientToScreenXY)void ClientToScreen(int *BOTH, int *BOTH);
72 wxPoint ClientToScreen(const wxPoint& pt);
73 bool Close(int force = FALSE);
75 void DestroyChildren();
77 void DragAcceptFiles(bool accept);
79 void Enable(bool enable);
80 //bool FakePopupMenu(wxMenu* menu, int x, int y);
81 %name(FindWindowById) wxWindow* FindWindow(long id);
82 %name(FindWindowByName) wxWindow* FindWindow(const wxString& name);
84 wxColour GetBackgroundColour();
87 %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT);
88 wxSize GetClientSize();
89 wxLayoutConstraints * GetConstraints();
90 //wxEvtHandler* GetEventHandler();
93 wxColour GetForegroundColour();
94 wxWindow * GetGrandParent();
97 void SetLabel(const wxString& label);
99 wxWindow * GetParent();
100 %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT);
101 wxPoint GetPosition();
103 int GetScrollThumb(int orientation);
104 int GetScrollPos(int orientation);
105 int GetScrollRange(int orientation);
106 %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT);
108 void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT);
109 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
110 int *OUTPUT, int *OUTPUT, int *OUTPUT, int* OUTPUT,
111 const wxFont* font = NULL); //, bool use16 = FALSE)
113 wxRegion GetUpdateRegion();
114 long GetWindowStyleFlag();
122 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
124 void MakeModal(bool flag);
125 %name(MoveXY)void Move(int x, int y);
126 void Move(const wxPoint& point);
128 //wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE);
129 //void PushEventHandler(wxEvtHandler* handler);
131 %name(PopupMenuXY)bool PopupMenu(wxMenu *menu, int x, int y);
132 bool PopupMenu(wxMenu *menu, const wxPoint& pos);
135 void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL);
137 bool Reparent( wxWindow* newParent );
139 %name(ScreenToClientXY)void ScreenToClient(int *BOTH, int *BOTH);
140 wxPoint ScreenToClient(const wxPoint& pt);
142 void ScrollWindow(int dx, int dy, const wxRect* rect = NULL);
143 void SetAcceleratorTable(const wxAcceleratorTable& accel);
144 void SetAutoLayout(bool autoLayout);
145 void SetBackgroundColour(const wxColour& colour);
146 void SetConstraints(wxLayoutConstraints *constraints);
148 void SetFont(const wxFont& font);
149 void SetForegroundColour(const wxColour& colour);
151 void SetName(const wxString& name);
152 void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh = TRUE);
153 void SetScrollPos(int orientation, int pos, bool refresh = TRUE);
155 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
157 void SetSize(const wxSize& size) {
158 self->SetSize(size.x, size.y);
161 void SetPosition(const wxPoint& pos) {
162 self->SetSize(pos.x, pos.y, -1, -1);
166 void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1);
167 %name(SetClientSizeWH)void SetClientSize(int width, int height);
168 void SetClientSize(const wxSize& size);
169 //void SetPalette(wxPalette* palette);
170 void SetCursor(const wxCursor&cursor);
171 //void SetEventHandler(wxEvtHandler* handler);
172 void SetTitle(const wxString& title);
173 bool Show(bool show);
174 bool TransferDataFromWindow();
175 bool TransferDataToWindow();
177 void WarpPointer(int x, int y);
179 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
180 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
182 %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt);
183 %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz);
185 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
186 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
188 %name(SetToolTipString)void SetToolTip(const wxString &tip);
189 void SetToolTip(wxToolTip *tooltip);
190 wxToolTip* GetToolTip();
193 %pragma(python) code = "
194 def wxDLG_PNT(win, point_or_x, y=None):
196 return win.ConvertDialogPointToPixels(point_or_x)
198 return win.ConvertDialogPointToPixels(wxPoint(point_or_x, y))
200 def wxDLG_SZE(win, size_width, height=None):
202 return win.ConvertDialogSizeToPixels(size_width)
204 return win.ConvertDialogSizeToPixels(wxSize(size_width, height))
209 wxWindow* wxWindow_FindFocus() {
210 return wxWindow::FindFocus();
216 wxWindow* wxWindow_FromHWND(unsigned long hWnd) {
217 wxWindow* win = new wxWindow;
219 win->SubclassWin(hWnd);
226 //---------------------------------------------------------------------------
228 class wxPanel : public wxWindow {
230 wxPanel(wxWindow* parent,
232 const wxPoint& pos = wxPyDefaultPosition,
233 const wxSize& size = wxPyDefaultSize,
234 long style = wxTAB_TRAVERSAL,
235 const char* name = "panel");
237 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
240 wxButton* GetDefaultItem();
241 void SetDefaultItem(wxButton *btn);
243 // fix a SWIG turd...
244 %pragma(python) addtoclass = "
245 def GetDefaultItem(self):
247 val = windowsc.wxPanel_GetDefaultItem(self.this)
248 val = controls.wxButtonPtr(val)
253 //---------------------------------------------------------------------------
255 class wxDialog : public wxPanel {
257 wxDialog(wxWindow* parent,
259 const wxString& title,
260 const wxPoint& pos = wxPyDefaultPosition,
261 const wxSize& size = wxPyDefaultSize,
262 long style = wxDEFAULT_DIALOG_STYLE,
263 const char* name = "dialogBox");
265 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
267 void Centre(int direction = wxBOTH);
268 void EndModal(int retCode);
270 void Iconize(bool iconize);
272 void SetModal(bool flag);
274 void SetTitle(const wxString& title);
275 bool Show(bool show);
279 void SetReturnCode(int retCode);
282 //---------------------------------------------------------------------------
284 class wxScrolledWindow : public wxPanel {
286 wxScrolledWindow(wxWindow* parent,
287 const wxWindowID id = -1,
288 const wxPoint& pos = wxPyDefaultPosition,
289 const wxSize& size = wxPyDefaultSize,
290 long style = wxHSCROLL | wxVSCROLL,
291 char* name = "scrolledWindow");
293 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
294 %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)"
296 void EnableScrolling(bool xScrolling, bool yScrolling);
297 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
298 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
300 void PrepareDC(wxDC& dc);
301 void Scroll(int x, int y);
302 void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
303 int noUnitsX, int noUnitsY,
304 int xPos = 0, int yPos = 0);
305 void ViewStart(int* OUTPUT, int* OUTPUT);
308 //----------------------------------------------------------------------
311 class wxMenu : public wxEvtHandler {
313 wxMenu(const wxString& title = wxPyEmptyStr, long style = 0);
315 void Append(int id, const wxString& item,
316 const wxString& helpString = wxPyEmptyStr,
317 int checkable = FALSE);
318 %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu,
319 const wxString& helpString = wxPyEmptyStr);
321 %name(AppendItem)void Append(const wxMenuItem* item);
324 void AppendSeparator();
326 void Check(int id, bool flag);
327 void Enable(int id, bool enable);
328 int FindItem(const wxString& itemString);
330 void SetTitle(const wxString& title);
331 wxMenuItem* FindItemForId(int id);
332 wxString GetHelpString(int id);
333 wxString GetLabel(int id);
334 void SetHelpString(int id, const wxString& helpString);
335 bool IsChecked(int id);
336 bool IsEnabled(int id);
337 void SetLabel(int id, const wxString& label);
338 void UpdateUI(wxEvtHandler* source = NULL);
343 // This one knows how to set a callback and handle INC- and DECREFing it. To
344 // be used for PopupMenus, but you must retain a referece to it while using
347 // class wxPyMenu : public wxMenu {
349 // wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL);
353 //----------------------------------------------------------------------
355 class wxMenuBar : public wxEvtHandler {
359 void Append(wxMenu *menu, const wxString& title);
360 void Check(int id, bool flag);
361 bool Checked(int id);
362 void Enable(int id, bool enable);
363 bool Enabled(int id);
364 int FindMenuItem(const wxString& menuString, const wxString& itemString);
365 wxMenuItem * FindItemForId(int id);
367 void EnableTop(int pos, bool enable);
368 wxString GetHelpString(int id);
369 wxString GetLabel(int id);
370 void SetHelpString(int id, const wxString& helpString);
371 void SetLabel(int id, const wxString& label);
372 wxString GetLabelTop(int pos);
373 void SetLabelTop(int pos, const wxString& label);
376 wxMenu* GetMenu(int i);
380 //----------------------------------------------------------------------
385 wxMenuItem(wxMenu* parentMenu=NULL, int id=ID_SEPARATOR,
386 const wxString& text = wxPyEmptyStr,
387 const wxString& helpString = wxPyEmptyStr,
388 bool checkable = FALSE, wxMenu* subMenu = NULL);
398 wxMenu* GetSubMenu();
399 void SetName(const wxString& strName);
402 void SetHelp(const wxString& strHelp);
403 void Enable(bool bDoEnable = TRUE);
404 void Check(bool bDoCheck = TRUE);
407 wxColour& GetBackgroundColour();
408 wxBitmap GetBitmap(bool checked = TRUE);
410 int GetMarginWidth();
411 wxColour& GetTextColour();
412 void SetBackgroundColour(const wxColour& colour);
413 void SetBitmaps(const wxBitmap& checked, const wxBitmap& unchecked = wxNullBitmap);
414 void SetFont(const wxFont& font);
415 void SetMarginWidth(int width);
416 void SetTextColour(const wxColour& colour);
417 void DeleteSubMenu();
421 //---------------------------------------------------------------------------
422 /////////////////////////////////////////////////////////////////////////////
425 // Revision 1.18 1999/07/31 07:54:35 RD
428 // Added the missing wxWindow.GetUpdateRegion() method.
430 // Made a new change in SWIG (update your patches everybody) that
431 // provides a fix for global shadow objects that get an exception in
432 // their __del__ when their extension module has already been deleted.
433 // It was only a 1 line change in .../SWIG/Modules/pycpp.cxx at about
434 // line 496 if you want to do it by hand.
436 // It is now possible to run through MainLoop more than once in any one
437 // process. The cleanup that used to happen as MainLoop completed (and
438 // prevented it from running again) has been delayed until the wxc module
439 // is being unloaded by Python.
441 // wxWindow.PopupMenu() now takes a wxPoint instead of x,y. Added
442 // wxWindow.PopupMenuXY to be consistent with some other methods.
444 // Added wxGrid.SetEditInPlace and wxGrid.GetEditInPlace.
446 // You can now provide your own app.MainLoop method. See
447 // wxPython/demo/demoMainLoop.py for an example and some explaination.
449 // Got the in-place-edit for the wxTreeCtrl fixed and added some demo
450 // code to show how to use it.
452 // Put the wxIcon constructor back in for GTK as it now has one that
455 // Added wxGrid.GetCells
457 // Added wxSystemSettings static methods as functions with names like
458 // wxSystemSettings_GetSystemColour.
460 // Removed wxPyMenu since using menu callbacks have been depreciated in
461 // wxWindows. Use wxMenu and events instead.
463 // Added alternate wxBitmap constructor (for MSW only) as
464 // wxBitmapFromData(data, type, width, height, depth = 1)
466 // Added a helper function named wxPyTypeCast that can convert shadow
467 // objects of one type into shadow objects of another type. (Like doing
468 // a down-cast.) See the implementation in wx.py for some docs.
470 // Revision 1.17 1999/06/22 07:03:03 RD
472 // wxPython 2.1b1 for wxMSW (wxGTK coming soon)
473 // Lots of changes, see the README.txt for details...
475 // Revision 1.16 1999/05/15 00:56:04 RD
477 // fixes for GetReturnCode/SetReturnCode
479 // Revision 1.15 1999/04/30 03:29:19 RD
481 // wxPython 2.0b9, first phase (win32)
482 // Added gobs of stuff, see wxPython/README.txt for details
484 // Revision 1.14.4.3 1999/03/27 23:29:15 RD
487 // Python thread support
488 // various minor additions
489 // various minor fixes
491 // Revision 1.14.4.2 1999/03/16 06:26:29 RD
495 // Revision 1.14.4.1 1999/03/16 06:04:04 RD
499 // Revision 1.14 1999/02/23 23:48:33 RD
501 // reenabled some methods for wxPython on wxGTK
503 // Revision 1.13 1999/02/20 10:02:38 RD
505 // Changes needed to enable wxGTK compatibility.
507 // Revision 1.12 1999/02/20 09:03:03 RD
508 // Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
509 // window handle. If you can get the window handle into the python code,
510 // it should just work... More news on this later.
512 // Added wxImageList, wxToolTip.
514 // Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the
515 // wxRegConfig class.
517 // As usual, some bug fixes, tweaks, etc.
519 // Revision 1.11 1998/12/18 15:49:10 RR
521 // wxClipboard now serves the primary selection as well
525 // Revision 1.10 1998/12/17 17:52:20 RD
528 // Minor fixes and SWIG code generation for RR's changes. MSW and GTK
529 // versions are much closer now!
531 // Revision 1.9 1998/12/17 14:07:46 RR
533 // Removed minor differences between wxMSW and wxGTK
535 // Revision 1.8 1998/12/16 22:10:56 RD
537 // Tweaks needed to be able to build wxPython with wxGTK.
539 // Revision 1.7 1998/12/15 20:41:25 RD
540 // Changed the import semantics from "from wxPython import *" to "from
541 // wxPython.wx import *" This is for people who are worried about
542 // namespace pollution, they can use "from wxPython import wx" and then
543 // prefix all the wxPython identifiers with "wx."
545 // Added wxTaskbarIcon for wxMSW.
547 // Made the events work for wxGrid.
551 // Added wxMiniFrame for wxGTK, (untested.)
553 // Changed many of the args and return values that were pointers to gdi
554 // objects to references to reflect changes in the wxWindows API.
556 // Other assorted fixes and additions.
558 // Revision 1.6 1998/10/02 06:40:43 RD
560 // Version 0.4 of wxPython for MSW.
562 // Revision 1.5 1998/08/17 18:29:40 RD
563 // Removed an extra method definition
565 // Revision 1.4 1998/08/16 04:31:11 RD
568 // Revision 1.3 1998/08/15 07:36:47 RD
569 // - Moved the header in the .i files out of the code that gets put into
570 // the .cpp files. It caused CVS conflicts because of the RCS ID being
571 // different each time.
573 // - A few minor fixes.
575 // Revision 1.2 1998/08/14 23:36:46 RD
576 // Beginings of wxGTK compatibility
578 // Revision 1.1 1998/08/09 08:25:52 RD