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 = wxHORIZONTAL);
68 void Centre(int direction = wxHORIZONTAL);
69 void CentreOnParent(int direction = wxHORIZONTAL );
70 void CenterOnParent(int direction = wxHORIZONTAL );
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 long GetWindowStyleFlag();
121 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
123 void MakeModal(bool flag);
124 %name(MoveXY)void Move(int x, int y);
125 void Move(const wxPoint& point);
127 //wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE);
128 bool PopupMenu(wxMenu *menu, int x, int y);
129 //void PushEventHandler(wxEvtHandler* handler);
132 void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL);
134 bool Reparent( wxWindow* newParent );
136 %name(ScreenToClientXY)void ScreenToClient(int *BOTH, int *BOTH);
137 wxPoint ScreenToClient(const wxPoint& pt);
139 void ScrollWindow(int dx, int dy, const wxRect* rect = NULL);
140 void SetAcceleratorTable(const wxAcceleratorTable& accel);
141 void SetAutoLayout(bool autoLayout);
142 void SetBackgroundColour(const wxColour& colour);
143 void SetConstraints(wxLayoutConstraints *constraints);
144 // void SetDoubleClick(bool allowDoubleClick);
146 void SetFont(const wxFont& font);
147 void SetForegroundColour(const wxColour& colour);
149 void SetName(const wxString& name);
150 void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh = TRUE);
151 void SetScrollPos(int orientation, int pos, bool refresh = TRUE);
153 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
155 void SetSize(const wxSize& size) {
156 self->SetSize(size.x, size.y);
159 void SetPosition(const wxPoint& pos) {
160 self->SetSize(pos.x, pos.y, -1, -1);
164 void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1);
165 %name(SetClientSizeWH)void SetClientSize(int width, int height);
166 void SetClientSize(const wxSize& size);
167 //void SetPalette(wxPalette* palette);
168 void SetCursor(const wxCursor&cursor);
169 //void SetEventHandler(wxEvtHandler* handler);
170 void SetTitle(const wxString& title);
171 bool Show(bool show);
172 bool TransferDataFromWindow();
173 bool TransferDataToWindow();
175 void WarpPointer(int x, int y);
177 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
178 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
180 %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt);
181 %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz);
183 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
184 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
186 %name(SetToolTipString)void SetToolTip(const wxString &tip);
187 void SetToolTip(wxToolTip *tooltip);
188 wxToolTip* GetToolTip();
191 %pragma(python) code = "
192 def wxDLG_PNT(win, point_or_x, y=None):
194 return win.ConvertDialogPointToPixels(point_or_x)
196 return win.ConvertDialogPointToPixels(wxPoint(point_or_x, y))
198 def wxDLG_SZE(win, size_width, height=None):
200 return win.ConvertDialogSizeToPixels(size_width)
202 return win.ConvertDialogSizeToPixels(wxSize(size_width, height))
207 wxWindow* wxWindow_FindFocus() {
208 return wxWindow::FindFocus();
214 wxWindow* wxWindow_FromHWND(unsigned long hWnd) {
215 wxWindow* win = new wxWindow;
217 win->SubclassWin(hWnd);
224 //---------------------------------------------------------------------------
226 class wxPanel : public wxWindow {
228 wxPanel(wxWindow* parent,
230 const wxPoint& pos = wxPyDefaultPosition,
231 const wxSize& size = wxPyDefaultSize,
232 long style = wxTAB_TRAVERSAL,
233 const char* name = "panel");
235 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
238 wxButton* GetDefaultItem();
239 void SetDefaultItem(wxButton *btn);
241 // fix a SWIG turd...
242 %pragma(python) addtoclass = "
243 def GetDefaultItem(self):
245 val = windowsc.wxPanel_GetDefaultItem(self.this)
246 val = controls.wxButtonPtr(val)
251 //---------------------------------------------------------------------------
253 class wxDialog : public wxPanel {
255 wxDialog(wxWindow* parent,
257 const wxString& title,
258 const wxPoint& pos = wxPyDefaultPosition,
259 const wxSize& size = wxPyDefaultSize,
260 long style = wxDEFAULT_DIALOG_STYLE,
261 const char* name = "dialogBox");
263 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
265 void Centre(int direction = wxBOTH);
266 void EndModal(int retCode);
268 void Iconize(bool iconize);
270 void SetModal(bool flag);
272 void SetTitle(const wxString& title);
273 bool Show(bool show);
277 void SetReturnCode(int retCode);
280 //---------------------------------------------------------------------------
282 class wxScrolledWindow : public wxPanel {
284 wxScrolledWindow(wxWindow* parent,
285 const wxWindowID id = -1,
286 const wxPoint& pos = wxPyDefaultPosition,
287 const wxSize& size = wxPyDefaultSize,
288 long style = wxHSCROLL | wxVSCROLL,
289 char* name = "scrolledWindow");
291 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
292 %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)"
294 void EnableScrolling(bool xScrolling, bool yScrolling);
295 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
296 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
298 void PrepareDC(wxDC& dc);
299 void Scroll(int x, int y);
300 void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
301 int noUnitsX, int noUnitsY,
302 int xPos = 0, int yPos = 0);
303 void ViewStart(int* OUTPUT, int* OUTPUT);
306 //----------------------------------------------------------------------
309 class wxMenu : public wxEvtHandler {
311 wxMenu(const wxString& title = wxPyEmptyStr);
313 void Append(int id, const wxString& item,
314 const wxString& helpString = wxPyEmptyStr,
315 int checkable = FALSE);
316 %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu,
317 const wxString& helpString = wxPyEmptyStr);
319 %name(AppendItem)void Append(const wxMenuItem* item);
322 void AppendSeparator();
324 void Check(int id, bool flag);
325 void Enable(int id, bool enable);
326 int FindItem(const wxString& itemString);
328 void SetTitle(const wxString& title);
329 wxMenuItem* FindItemForId(int id);
330 wxString GetHelpString(int id);
331 wxString GetLabel(int id);
332 void SetHelpString(int id, const wxString& helpString);
333 bool IsChecked(int id);
334 bool IsEnabled(int id);
335 void SetLabel(int id, const wxString& label);
340 // This one knows how to set a callback and handle INC- and DECREFing it. To
341 // be used for PopupMenus, but you must retain a referece to it while using
344 class wxPyMenu : public wxMenu {
346 wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL);
350 //----------------------------------------------------------------------
352 class wxMenuBar : public wxEvtHandler {
356 void Append(wxMenu *menu, const wxString& title);
357 void Check(int id, bool flag);
358 bool Checked(int id);
359 void Enable(int id, bool enable);
360 bool Enabled(int id);
361 int FindMenuItem(const wxString& menuString, const wxString& itemString);
362 wxMenuItem * FindItemForId(int id);
364 void EnableTop(int pos, bool enable);
365 wxString GetHelpString(int id);
366 wxString GetLabel(int id);
367 void SetHelpString(int id, const wxString& helpString);
368 void SetLabel(int id, const wxString& label);
369 wxString GetLabelTop(int pos);
370 void SetLabelTop(int pos, const wxString& label);
373 wxMenu* GetMenu(int i);
377 //----------------------------------------------------------------------
382 wxMenuItem(wxMenu* parentMenu=NULL, int id=ID_SEPARATOR,
383 const wxString& text = wxPyEmptyStr,
384 const wxString& helpString = wxPyEmptyStr,
385 bool checkable = FALSE, wxMenu* subMenu = NULL);
395 wxMenu* GetSubMenu();
396 void SetName(const wxString& strName);
399 void SetHelp(const wxString& strHelp);
400 void Enable(bool bDoEnable = TRUE);
401 void Check(bool bDoCheck = TRUE);
404 wxColour& GetBackgroundColour();
405 wxBitmap GetBitmap(bool checked = TRUE);
407 int GetMarginWidth();
408 wxColour& GetTextColour();
409 void SetBackgroundColour(const wxColour& colour);
410 void SetBitmaps(const wxBitmap& checked, const wxBitmap& unchecked = wxNullBitmap);
411 void SetFont(const wxFont& font);
412 void SetMarginWidth(int width);
413 void SetTextColour(const wxColour& colour);
414 void DeleteSubMenu();
418 //---------------------------------------------------------------------------
419 /////////////////////////////////////////////////////////////////////////////
422 // Revision 1.17 1999/06/22 07:03:03 RD
423 // wxPython 2.1b1 for wxMSW (wxGTK coming soon)
424 // Lots of changes, see the README.txt for details...
426 // Revision 1.16 1999/05/15 00:56:04 RD
428 // fixes for GetReturnCode/SetReturnCode
430 // Revision 1.15 1999/04/30 03:29:19 RD
432 // wxPython 2.0b9, first phase (win32)
433 // Added gobs of stuff, see wxPython/README.txt for details
435 // Revision 1.14.4.3 1999/03/27 23:29:15 RD
438 // Python thread support
439 // various minor additions
440 // various minor fixes
442 // Revision 1.14.4.2 1999/03/16 06:26:29 RD
446 // Revision 1.14.4.1 1999/03/16 06:04:04 RD
450 // Revision 1.14 1999/02/23 23:48:33 RD
452 // reenabled some methods for wxPython on wxGTK
454 // Revision 1.13 1999/02/20 10:02:38 RD
456 // Changes needed to enable wxGTK compatibility.
458 // Revision 1.12 1999/02/20 09:03:03 RD
459 // Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
460 // window handle. If you can get the window handle into the python code,
461 // it should just work... More news on this later.
463 // Added wxImageList, wxToolTip.
465 // Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the
466 // wxRegConfig class.
468 // As usual, some bug fixes, tweaks, etc.
470 // Revision 1.11 1998/12/18 15:49:10 RR
472 // wxClipboard now serves the primary selection as well
476 // Revision 1.10 1998/12/17 17:52:20 RD
479 // Minor fixes and SWIG code generation for RR's changes. MSW and GTK
480 // versions are much closer now!
482 // Revision 1.9 1998/12/17 14:07:46 RR
484 // Removed minor differences between wxMSW and wxGTK
486 // Revision 1.8 1998/12/16 22:10:56 RD
488 // Tweaks needed to be able to build wxPython with wxGTK.
490 // Revision 1.7 1998/12/15 20:41:25 RD
491 // Changed the import semantics from "from wxPython import *" to "from
492 // wxPython.wx import *" This is for people who are worried about
493 // namespace pollution, they can use "from wxPython import wx" and then
494 // prefix all the wxPython identifiers with "wx."
496 // Added wxTaskbarIcon for wxMSW.
498 // Made the events work for wxGrid.
502 // Added wxMiniFrame for wxGTK, (untested.)
504 // Changed many of the args and return values that were pointers to gdi
505 // objects to references to reflect changes in the wxWindows API.
507 // Other assorted fixes and additions.
509 // Revision 1.6 1998/10/02 06:40:43 RD
511 // Version 0.4 of wxPython for MSW.
513 // Revision 1.5 1998/08/17 18:29:40 RD
514 // Removed an extra method definition
516 // Revision 1.4 1998/08/16 04:31:11 RD
519 // Revision 1.3 1998/08/15 07:36:47 RD
520 // - Moved the header in the .i files out of the code that gets put into
521 // the .cpp files. It caused CVS conflicts because of the RCS ID being
522 // different each time.
524 // - A few minor fixes.
526 // Revision 1.2 1998/08/14 23:36:46 RD
527 // Beginings of wxGTK compatibility
529 // Revision 1.1 1998/08/09 08:25:52 RD