1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG definitions of various window classes
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
20 // wxGTK defines wxMenuItem inside menu.h
21 #include <wx/menuitem.h>
25 #include <wx/minifram.h>
29 //----------------------------------------------------------------------
32 %include my_typemaps.i
34 // Import some definitions of other classes, etc.
39 %pragma(python) code = "import wx"
41 //---------------------------------------------------------------------------
46 void Connect( int id, int lastId, int eventType, PyObject* func) {
47 if (PyCallable_Check(func)) {
48 self->Connect(id, lastId, eventType,
49 (wxObjectEventFunction) &wxPyCallback::EventThunker,
50 new wxPyCallback(func));
57 //----------------------------------------------------------------------
60 class wxWindow : public wxEvtHandler {
63 wxWindow(wxWindow* parent, const wxWindowID id,
64 const wxPoint& pos = wxPyDefaultPosition,
65 const wxSize& size = wxPyDefaultSize,
67 char* name = "panel");
69 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
72 void Center(int direction = wxHORIZONTAL);
73 void Centre(int direction = wxHORIZONTAL);
74 void ClientToScreen(int *BOTH, int *BOTH);
75 bool Close(int force = FALSE);
77 void DestroyChildren();
79 void DragAcceptFiles(bool accept);
81 void Enable(bool enable);
82 //bool FakePopupMenu(wxMenu* menu, int x, int y);
83 %name(FindWindowByID) wxWindow* FindWindow(long id);
84 %name(FindWindowByName) wxWindow* FindWindow(const wxString& name);
86 wxColour GetBackgroundColour();
89 %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT);
90 wxSize GetClientSize();
91 wxLayoutConstraints * GetConstraints();
93 wxButton* GetDefaultItem();
95 //wxEvtHandler* GetEventHandler();
97 wxColour GetForegroundColour();
98 wxWindow * GetGrandParent();
102 wxWindow * GetParent();
103 %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT);
104 wxPoint GetPosition();
107 int GetScrollThumb(int orientation);
108 int GetScrollPos(int orientation);
109 int GetScrollRange(int orientation);
110 %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT);
112 void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT); // int* descent = NULL, int* externalLeading = NULL, const wxFont* font = NULL, bool use16 = FALSE)
114 long GetWindowStyleFlag();
120 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
122 void MakeModal(bool flag);
123 void Move(int x, int y);
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 void ScreenToClient(int *BOTH, int *BOTH);
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 //void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
149 //%name(SetSizeOnly) void SetSize(int width, int height);
151 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
153 void SetSize(const wxSize& size) {
154 self->SetSize(size.x, size.y);
157 void SetPosition(const wxPoint& pos) {
158 self->SetSize(pos.x, pos.y, -1, -1);
162 void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1);
163 void SetClientSize(int width, int height);
164 //void SetPalette(wxPalette* palette);
165 void SetCursor(const wxCursor&cursor);
166 //void SetEventHandler(wxEvtHandler* handler);
167 void SetTitle(const wxString& title);
168 bool Show(bool show);
169 bool TransferDataFromWindow();
170 bool TransferDataToWindow();
173 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);
184 %pragma(python) code = "
185 def wxDLG_PNT(win, point):
186 return win.ConvertDialogPointToPixels(point)
188 def wxDLG_SZE(win, size):
189 return win.ConvertDialogPointToPixels(size)
195 wxWindow* wxWindow_FindFocus() {
196 return wxWindow::FindFocus();
202 //---------------------------------------------------------------------------
204 class wxPanel : public wxWindow {
206 wxPanel(wxWindow* parent,
208 const wxPoint& pos = wxPyDefaultPosition,
209 const wxSize& size = wxPyDefaultSize,
210 long style = wxTAB_TRAVERSAL,
211 const char* name = "panel");
213 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
218 //---------------------------------------------------------------------------
220 class wxDialog : public wxPanel {
222 wxDialog(wxWindow* parent,
224 const wxString& title,
225 const wxPoint& pos = wxPyDefaultPosition,
226 const wxSize& size = wxPyDefaultSize,
227 long style = wxDEFAULT_DIALOG_STYLE,
228 const char* name = "dialogBox");
230 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
232 void Centre(int direction = wxBOTH);
233 void EndModal(int retCode);
235 void Iconize(bool iconize);
237 void SetModal(bool flag);
239 void SetTitle(const wxString& title);
240 bool Show(bool show);
244 //---------------------------------------------------------------------------
246 class wxScrolledWindow : public wxWindow {
248 wxScrolledWindow(wxWindow* parent,
249 const wxWindowID id = -1,
250 const wxPoint& pos = wxPyDefaultPosition,
251 const wxSize& size = wxPyDefaultSize,
252 long style = wxHSCROLL | wxVSCROLL,
253 char* name = "scrolledWindow");
255 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
256 %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)"
258 void EnableScrolling(bool xScrolling, bool yScrolling);
259 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
260 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
262 void PrepareDC(wxDC& dc);
263 void Scroll(int x, int y);
264 void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
265 int noUnitsX, int noUnitsY,
266 int xPos = 0, int yPos = 0);
267 void ViewStart(int* OUTPUT, int* OUTPUT);
270 //----------------------------------------------------------------------
273 class wxMenu : public wxEvtHandler {
275 wxMenu(const wxString& title = wxPyEmptyStr);
277 void Append(int id, const wxString& item,
278 const wxString& helpString = wxPyEmptyStr,
279 int checkable = FALSE);
280 %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu,
281 const wxString& helpString = wxPyEmptyStr);
282 void AppendSeparator();
284 void Check(int id, bool flag);
285 void Enable(int id, bool enable);
286 int FindItem(const wxString& itemString);
289 void SetTitle(const wxString& title);
291 wxMenuItem* FindItemForId(int id);
292 wxString GetHelpString(int id);
293 wxString GetLabel(int id);
294 void SetHelpString(int id, const wxString& helpString);
295 bool IsChecked(int id);
296 bool IsEnabled(int id);
297 void SetLabel(int id, const wxString& label);
302 // This one knows how to set a callback and handle INC- and DECREFing it. To
303 // be used for PopupMenus, but you must retain a referece to it while using
306 class wxPyMenu : public wxMenu {
308 wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL);
312 //----------------------------------------------------------------------
314 class wxMenuBar : public wxEvtHandler {
318 void Append(wxMenu *menu, const wxString& title);
319 void Check(int id, bool flag);
320 bool Checked(int id);
321 void Enable(int id, bool enable);
322 bool Enabled(int id);
323 int FindMenuItem(const wxString& menuString, const wxString& itemString);
325 %name(FindItemForId) wxMenuItem* FindMenuItemById( int id );
328 wxMenuItem * FindItemForId(int id);
329 void EnableTop(int pos, bool enable);
330 wxString GetHelpString(int id);
331 wxString GetLabel(int id);
332 void SetHelpString(int id, const wxString& helpString);
333 void SetLabel(int id, const wxString& label);
334 wxString GetLabelTop(int pos);
335 void SetLabelTop(int pos, const wxString& label);
338 wxMenu* GetMenu(int i);
342 //----------------------------------------------------------------------
351 wxMenu* GetSubMenu();
353 void SetName(const wxString& strName);
354 void DeleteSubMenu();
355 const wxString& GetName();
357 const wxString& GetHelp();
358 void SetHelp(const wxString& strHelp);
359 void Enable(bool bDoEnable = TRUE);
360 void Check(bool bDoCheck = TRUE);
363 //---------------------------------------------------------------------------
364 /////////////////////////////////////////////////////////////////////////////
367 // Revision 1.7 1998/12/15 20:41:25 RD
368 // Changed the import semantics from "from wxPython import *" to "from
369 // wxPython.wx import *" This is for people who are worried about
370 // namespace pollution, they can use "from wxPython import wx" and then
371 // prefix all the wxPython identifiers with "wx."
373 // Added wxTaskbarIcon for wxMSW.
375 // Made the events work for wxGrid.
379 // Added wxMiniFrame for wxGTK, (untested.)
381 // Changed many of the args and return values that were pointers to gdi
382 // objects to references to reflect changes in the wxWindows API.
384 // Other assorted fixes and additions.
386 // Revision 1.6 1998/10/02 06:40:43 RD
388 // Version 0.4 of wxPython for MSW.
390 // Revision 1.5 1998/08/17 18:29:40 RD
391 // Removed an extra method definition
393 // Revision 1.4 1998/08/16 04:31:11 RD
396 // Revision 1.3 1998/08/15 07:36:47 RD
397 // - Moved the header in the .i files out of the code that gets put into
398 // the .cpp files. It caused CVS conflicts because of the RCS ID being
399 // different each time.
401 // - A few minor fixes.
403 // Revision 1.2 1998/08/14 23:36:46 RD
404 // Beginings of wxGTK compatibility
406 // Revision 1.1 1998/08/09 08:25:52 RD