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"
33 //---------------------------------------------------------------------------
38 void Connect( int id, int lastId, int eventType, PyObject* func) {
39 if (PyCallable_Check(func)) {
40 self->Connect(id, lastId, eventType,
41 (wxObjectEventFunction) &wxPyCallback::EventThunker,
42 new wxPyCallback(func));
49 //----------------------------------------------------------------------
52 class wxWindow : public wxEvtHandler {
55 wxWindow(wxWindow* parent, const wxWindowID id,
56 const wxPoint& pos = wxPyDefaultPosition,
57 const wxSize& size = wxPyDefaultSize,
59 char* name = "panel");
61 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
64 void Center(int direction = wxHORIZONTAL);
65 void Centre(int direction = wxHORIZONTAL);
66 %name(ClientToScreenXY)void ClientToScreen(int *BOTH, int *BOTH);
68 wxPoint ClientToScreen(const wxPoint& pt);
70 bool Close(int force = FALSE);
72 void DestroyChildren();
74 void DragAcceptFiles(bool accept);
76 void Enable(bool enable);
77 //bool FakePopupMenu(wxMenu* menu, int x, int y);
78 %name(FindWindowById) wxWindow* FindWindow(long id);
79 %name(FindWindowByName) wxWindow* FindWindow(const wxString& name);
81 wxColour GetBackgroundColour();
84 %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT);
85 wxSize GetClientSize();
86 wxLayoutConstraints * GetConstraints();
88 wxButton* GetDefaultItem();
90 //wxEvtHandler* GetEventHandler();
93 wxColour GetForegroundColour();
94 wxWindow * GetGrandParent();
98 wxWindow * GetParent();
99 %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT);
100 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 long GetWindowStyleFlag();
119 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
121 void MakeModal(bool flag);
122 %name(MoveXY)void Move(int x, int y);
123 void Move(const wxPoint& point);
125 //wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE);
126 bool PopupMenu(wxMenu *menu, int x, int y);
127 //void PushEventHandler(wxEvtHandler* handler);
130 void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL);
132 %name(ScreenToClientXY)void ScreenToClient(int *BOTH, int *BOTH);
134 wxPoint ScreenToClient(const wxPoint& pt);
137 void ScrollWindow(int dx, int dy, const wxRect* rect = NULL);
138 void SetAcceleratorTable(const wxAcceleratorTable& accel);
139 void SetAutoLayout(bool autoLayout);
140 void SetBackgroundColour(const wxColour& colour);
141 void SetConstraints(wxLayoutConstraints *constraints);
142 void SetDoubleClick(bool allowDoubleClick);
144 void SetFont(const wxFont& font);
145 void SetForegroundColour(const wxColour& colour);
147 void SetName(const wxString& name);
148 void SetReturnCode(int retCode);
149 void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh = TRUE);
150 void SetScrollPos(int orientation, int pos, bool refresh = TRUE);
152 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
154 void SetSize(const wxSize& size) {
155 self->SetSize(size.x, size.y);
158 void SetPosition(const wxPoint& pos) {
159 self->SetSize(pos.x, pos.y, -1, -1);
163 void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1);
164 %name(SetClientSizeWH)void SetClientSize(int width, int height);
165 void SetClientSize(const wxSize& size);
166 //void SetPalette(wxPalette* palette);
167 void SetCursor(const wxCursor&cursor);
168 //void SetEventHandler(wxEvtHandler* handler);
169 void SetTitle(const wxString& title);
170 bool Show(bool show);
171 bool TransferDataFromWindow();
172 bool TransferDataToWindow();
174 void WarpPointer(int x, int y);
176 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
177 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
179 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
180 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
182 %name(SetToolTipString)void SetToolTip(const wxString &tip);
183 void SetToolTip(wxToolTip *tooltip);
184 wxToolTip* GetToolTip();
187 %pragma(python) code = "
188 def wxDLG_PNT(win, point):
189 return win.ConvertDialogPointToPixels(point)
191 def wxDLG_SZE(win, size):
192 return win.ConvertDialogSizeToPixels(size)
197 wxWindow* wxWindow_FindFocus() {
198 return wxWindow::FindFocus();
204 wxWindow* wxWindow_FromHWND(unsigned long hWnd) {
205 wxWindow* win = new wxWindow;
207 win->SubclassWin(hWnd);
214 //---------------------------------------------------------------------------
216 class wxPanel : public wxWindow {
218 wxPanel(wxWindow* parent,
220 const wxPoint& pos = wxPyDefaultPosition,
221 const wxSize& size = wxPyDefaultSize,
222 long style = wxTAB_TRAVERSAL,
223 const char* name = "panel");
225 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
230 //---------------------------------------------------------------------------
232 class wxDialog : public wxPanel {
234 wxDialog(wxWindow* parent,
236 const wxString& title,
237 const wxPoint& pos = wxPyDefaultPosition,
238 const wxSize& size = wxPyDefaultSize,
239 long style = wxDEFAULT_DIALOG_STYLE,
240 const char* name = "dialogBox");
242 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
244 void Centre(int direction = wxBOTH);
245 void EndModal(int retCode);
247 void Iconize(bool iconize);
249 void SetModal(bool flag);
251 void SetTitle(const wxString& title);
252 bool Show(bool show);
256 //---------------------------------------------------------------------------
258 class wxScrolledWindow : public wxWindow {
260 wxScrolledWindow(wxWindow* parent,
261 const wxWindowID id = -1,
262 const wxPoint& pos = wxPyDefaultPosition,
263 const wxSize& size = wxPyDefaultSize,
264 long style = wxHSCROLL | wxVSCROLL,
265 char* name = "scrolledWindow");
267 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
268 %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)"
270 void EnableScrolling(bool xScrolling, bool yScrolling);
271 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
272 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
274 void PrepareDC(wxDC& dc);
275 void Scroll(int x, int y);
276 void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
277 int noUnitsX, int noUnitsY,
278 int xPos = 0, int yPos = 0);
279 void ViewStart(int* OUTPUT, int* OUTPUT);
282 //----------------------------------------------------------------------
285 class wxMenu : public wxEvtHandler {
287 wxMenu(const wxString& title = wxPyEmptyStr);
289 void Append(int id, const wxString& item,
290 const wxString& helpString = wxPyEmptyStr,
291 int checkable = FALSE);
292 %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu,
293 const wxString& helpString = wxPyEmptyStr);
295 %name(AppendItem)void Append(const wxMenuItem* item);
298 void AppendSeparator();
300 void Check(int id, bool flag);
301 void Enable(int id, bool enable);
302 int FindItem(const wxString& itemString);
304 void SetTitle(const wxString& title);
305 wxMenuItem* FindItemForId(int id);
306 wxString GetHelpString(int id);
307 wxString GetLabel(int id);
308 void SetHelpString(int id, const wxString& helpString);
309 bool IsChecked(int id);
310 bool IsEnabled(int id);
311 void SetLabel(int id, const wxString& label);
316 // This one knows how to set a callback and handle INC- and DECREFing it. To
317 // be used for PopupMenus, but you must retain a referece to it while using
320 class wxPyMenu : public wxMenu {
322 wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL);
326 //----------------------------------------------------------------------
328 class wxMenuBar : public wxEvtHandler {
332 void Append(wxMenu *menu, const wxString& title);
333 void Check(int id, bool flag);
334 bool Checked(int id);
335 void Enable(int id, bool enable);
336 bool Enabled(int id);
337 int FindMenuItem(const wxString& menuString, const wxString& itemString);
338 wxMenuItem * FindItemForId(int id);
340 void EnableTop(int pos, bool enable);
341 wxString GetHelpString(int id);
342 wxString GetLabel(int id);
343 void SetHelpString(int id, const wxString& helpString);
344 void SetLabel(int id, const wxString& label);
345 wxString GetLabelTop(int pos);
346 void SetLabelTop(int pos, const wxString& label);
349 wxMenu* GetMenu(int i);
353 //----------------------------------------------------------------------
362 wxMenu* GetSubMenu();
363 void SetName(const wxString& strName);
364 const wxString& GetName();
365 const wxString& GetHelp();
366 void SetHelp(const wxString& strHelp);
367 void Enable(bool bDoEnable = TRUE);
368 void Check(bool bDoCheck = TRUE);
371 void DeleteSubMenu();
375 //---------------------------------------------------------------------------
376 /////////////////////////////////////////////////////////////////////////////
379 // Revision 1.14 1999/02/23 23:48:33 RD
380 // reenabled some methods for wxPython on wxGTK
382 // Revision 1.13 1999/02/20 10:02:38 RD
384 // Changes needed to enable wxGTK compatibility.
386 // Revision 1.12 1999/02/20 09:03:03 RD
387 // Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
388 // window handle. If you can get the window handle into the python code,
389 // it should just work... More news on this later.
391 // Added wxImageList, wxToolTip.
393 // Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the
394 // wxRegConfig class.
396 // As usual, some bug fixes, tweaks, etc.
398 // Revision 1.11 1998/12/18 15:49:10 RR
400 // wxClipboard now serves the primary selection as well
404 // Revision 1.10 1998/12/17 17:52:20 RD
407 // Minor fixes and SWIG code generation for RR's changes. MSW and GTK
408 // versions are much closer now!
410 // Revision 1.9 1998/12/17 14:07:46 RR
412 // Removed minor differences between wxMSW and wxGTK
414 // Revision 1.8 1998/12/16 22:10:56 RD
416 // Tweaks needed to be able to build wxPython with wxGTK.
418 // Revision 1.7 1998/12/15 20:41:25 RD
419 // Changed the import semantics from "from wxPython import *" to "from
420 // wxPython.wx import *" This is for people who are worried about
421 // namespace pollution, they can use "from wxPython import wx" and then
422 // prefix all the wxPython identifiers with "wx."
424 // Added wxTaskbarIcon for wxMSW.
426 // Made the events work for wxGrid.
430 // Added wxMiniFrame for wxGTK, (untested.)
432 // Changed many of the args and return values that were pointers to gdi
433 // objects to references to reflect changes in the wxWindows API.
435 // Other assorted fixes and additions.
437 // Revision 1.6 1998/10/02 06:40:43 RD
439 // Version 0.4 of wxPython for MSW.
441 // Revision 1.5 1998/08/17 18:29:40 RD
442 // Removed an extra method definition
444 // Revision 1.4 1998/08/16 04:31:11 RD
447 // Revision 1.3 1998/08/15 07:36:47 RD
448 // - Moved the header in the .i files out of the code that gets put into
449 // the .cpp files. It caused CVS conflicts because of the RCS ID being
450 // different each time.
452 // - A few minor fixes.
454 // Revision 1.2 1998/08/14 23:36:46 RD
455 // Beginings of wxGTK compatibility
457 // Revision 1.1 1998/08/09 08:25:52 RD