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);
67 wxPoint ClientToScreen(const wxPoint& pt);
68 bool Close(int force = FALSE);
70 void DestroyChildren();
72 void DragAcceptFiles(bool accept);
74 void Enable(bool enable);
75 //bool FakePopupMenu(wxMenu* menu, int x, int y);
76 %name(FindWindowById) wxWindow* FindWindow(long id);
77 %name(FindWindowByName) wxWindow* FindWindow(const wxString& name);
79 wxColour GetBackgroundColour();
82 %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT);
83 wxSize GetClientSize();
84 wxLayoutConstraints * GetConstraints();
86 wxButton* GetDefaultItem();
88 //wxEvtHandler* GetEventHandler();
91 wxColour GetForegroundColour();
92 wxWindow * GetGrandParent();
96 wxWindow * GetParent();
97 %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT);
98 wxPoint GetPosition();
101 int GetScrollThumb(int orientation);
102 int GetScrollPos(int orientation);
103 int GetScrollRange(int orientation);
104 %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT);
106 void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT);
107 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
108 int *OUTPUT, int *OUTPUT, int *OUTPUT, int* OUTPUT,
109 const wxFont* font = NULL); //, bool use16 = FALSE)
111 long GetWindowStyleFlag();
117 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
119 void MakeModal(bool flag);
120 %name(MoveXY)void Move(int x, int y);
121 void Move(const wxPoint& point);
123 //wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE);
124 bool PopupMenu(wxMenu *menu, int x, int y);
125 //void PushEventHandler(wxEvtHandler* handler);
128 void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL);
130 %name(ScreenToClientXY)void ScreenToClient(int *BOTH, int *BOTH);
131 wxPoint ScreenToClient(const wxPoint& pt);
133 void ScrollWindow(int dx, int dy, const wxRect* rect = NULL);
134 void SetAcceleratorTable(const wxAcceleratorTable& accel);
135 void SetAutoLayout(bool autoLayout);
136 void SetBackgroundColour(const wxColour& colour);
137 void SetConstraints(wxLayoutConstraints *constraints);
138 void SetDoubleClick(bool allowDoubleClick);
140 void SetFont(const wxFont& font);
141 void SetForegroundColour(const wxColour& colour);
143 void SetName(const wxString& name);
144 void SetReturnCode(int retCode);
145 void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh = TRUE);
146 void SetScrollPos(int orientation, int pos, bool refresh = TRUE);
148 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
150 void SetSize(const wxSize& size) {
151 self->SetSize(size.x, size.y);
154 void SetPosition(const wxPoint& pos) {
155 self->SetSize(pos.x, pos.y, -1, -1);
159 void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1);
160 %name(SetClientSizeWH)void SetClientSize(int width, int height);
161 void SetClientSize(const wxSize& size);
162 //void SetPalette(wxPalette* palette);
163 void SetCursor(const wxCursor&cursor);
164 //void SetEventHandler(wxEvtHandler* handler);
165 void SetTitle(const wxString& title);
166 bool Show(bool show);
167 bool TransferDataFromWindow();
168 bool TransferDataToWindow();
170 void WarpPointer(int x, int y);
172 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
173 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
175 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
176 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
178 %name(SetToolTipString)void SetToolTip(const wxString &tip);
179 void SetToolTip(wxToolTip *tooltip);
180 wxToolTip* GetToolTip();
183 %pragma(python) code = "
184 def wxDLG_PNT(win, point):
185 return win.ConvertDialogPointToPixels(point)
187 def wxDLG_SZE(win, size):
188 return win.ConvertDialogSizeToPixels(size)
193 wxWindow* wxWindow_FindFocus() {
194 return wxWindow::FindFocus();
200 wxWindow* wxWindow_FromHWND(unsigned long hWnd) {
201 wxWindow* win = new wxWindow;
203 win->SubclassWin(hWnd);
210 //---------------------------------------------------------------------------
212 class wxPanel : public wxWindow {
214 wxPanel(wxWindow* parent,
216 const wxPoint& pos = wxPyDefaultPosition,
217 const wxSize& size = wxPyDefaultSize,
218 long style = wxTAB_TRAVERSAL,
219 const char* name = "panel");
221 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
226 //---------------------------------------------------------------------------
228 class wxDialog : public wxPanel {
230 wxDialog(wxWindow* parent,
232 const wxString& title,
233 const wxPoint& pos = wxPyDefaultPosition,
234 const wxSize& size = wxPyDefaultSize,
235 long style = wxDEFAULT_DIALOG_STYLE,
236 const char* name = "dialogBox");
238 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
240 void Centre(int direction = wxBOTH);
241 void EndModal(int retCode);
243 void Iconize(bool iconize);
245 void SetModal(bool flag);
247 void SetTitle(const wxString& title);
248 bool Show(bool show);
252 //---------------------------------------------------------------------------
254 class wxScrolledWindow : public wxWindow {
256 wxScrolledWindow(wxWindow* parent,
257 const wxWindowID id = -1,
258 const wxPoint& pos = wxPyDefaultPosition,
259 const wxSize& size = wxPyDefaultSize,
260 long style = wxHSCROLL | wxVSCROLL,
261 char* name = "scrolledWindow");
263 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
264 %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)"
266 void EnableScrolling(bool xScrolling, bool yScrolling);
267 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
268 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
270 void PrepareDC(wxDC& dc);
271 void Scroll(int x, int y);
272 void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
273 int noUnitsX, int noUnitsY,
274 int xPos = 0, int yPos = 0);
275 void ViewStart(int* OUTPUT, int* OUTPUT);
278 //----------------------------------------------------------------------
281 class wxMenu : public wxEvtHandler {
283 wxMenu(const wxString& title = wxPyEmptyStr);
285 void Append(int id, const wxString& item,
286 const wxString& helpString = wxPyEmptyStr,
287 int checkable = FALSE);
288 %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu,
289 const wxString& helpString = wxPyEmptyStr);
290 %name(AppendItem)void Append(const wxMenuItem* item);
292 void AppendSeparator();
294 void Check(int id, bool flag);
295 void Enable(int id, bool enable);
296 int FindItem(const wxString& itemString);
298 void SetTitle(const wxString& title);
299 wxMenuItem* FindItemForId(int id);
300 wxString GetHelpString(int id);
301 wxString GetLabel(int id);
302 void SetHelpString(int id, const wxString& helpString);
303 bool IsChecked(int id);
304 bool IsEnabled(int id);
305 void SetLabel(int id, const wxString& label);
310 // This one knows how to set a callback and handle INC- and DECREFing it. To
311 // be used for PopupMenus, but you must retain a referece to it while using
314 class wxPyMenu : public wxMenu {
316 wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL);
320 //----------------------------------------------------------------------
322 class wxMenuBar : public wxEvtHandler {
326 void Append(wxMenu *menu, const wxString& title);
327 void Check(int id, bool flag);
328 bool Checked(int id);
329 void Enable(int id, bool enable);
330 bool Enabled(int id);
331 int FindMenuItem(const wxString& menuString, const wxString& itemString);
332 wxMenuItem * FindItemForId(int id);
334 void EnableTop(int pos, bool enable);
335 wxString GetHelpString(int id);
336 wxString GetLabel(int id);
337 void SetHelpString(int id, const wxString& helpString);
338 void SetLabel(int id, const wxString& label);
339 wxString GetLabelTop(int pos);
340 void SetLabelTop(int pos, const wxString& label);
343 wxMenu* GetMenu(int i);
347 //----------------------------------------------------------------------
356 wxMenu* GetSubMenu();
357 void SetName(const wxString& strName);
358 const wxString& GetName();
359 const wxString& GetHelp();
360 void SetHelp(const wxString& strHelp);
361 void Enable(bool bDoEnable = TRUE);
362 void Check(bool bDoCheck = TRUE);
365 void DeleteSubMenu();
369 //---------------------------------------------------------------------------
370 /////////////////////////////////////////////////////////////////////////////
373 // Revision 1.12 1999/02/20 09:03:03 RD
374 // Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
375 // window handle. If you can get the window handle into the python code,
376 // it should just work... More news on this later.
378 // Added wxImageList, wxToolTip.
380 // Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the
381 // wxRegConfig class.
383 // As usual, some bug fixes, tweaks, etc.
385 // Revision 1.11 1998/12/18 15:49:10 RR
387 // wxClipboard now serves the primary selection as well
391 // Revision 1.10 1998/12/17 17:52:20 RD
394 // Minor fixes and SWIG code generation for RR's changes. MSW and GTK
395 // versions are much closer now!
397 // Revision 1.9 1998/12/17 14:07:46 RR
399 // Removed minor differences between wxMSW and wxGTK
401 // Revision 1.8 1998/12/16 22:10:56 RD
403 // Tweaks needed to be able to build wxPython with wxGTK.
405 // Revision 1.7 1998/12/15 20:41:25 RD
406 // Changed the import semantics from "from wxPython import *" to "from
407 // wxPython.wx import *" This is for people who are worried about
408 // namespace pollution, they can use "from wxPython import wx" and then
409 // prefix all the wxPython identifiers with "wx."
411 // Added wxTaskbarIcon for wxMSW.
413 // Made the events work for wxGrid.
417 // Added wxMiniFrame for wxGTK, (untested.)
419 // Changed many of the args and return values that were pointers to gdi
420 // objects to references to reflect changes in the wxWindows API.
422 // Other assorted fixes and additions.
424 // Revision 1.6 1998/10/02 06:40:43 RD
426 // Version 0.4 of wxPython for MSW.
428 // Revision 1.5 1998/08/17 18:29:40 RD
429 // Removed an extra method definition
431 // Revision 1.4 1998/08/16 04:31:11 RD
434 // Revision 1.3 1998/08/15 07:36:47 RD
435 // - Moved the header in the .i files out of the code that gets put into
436 // the .cpp files. It caused CVS conflicts because of the RCS ID being
437 // different each time.
439 // - A few minor fixes.
441 // Revision 1.2 1998/08/14 23:36:46 RD
442 // Beginings of wxGTK compatibility
444 // Revision 1.1 1998/08/09 08:25:52 RD