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);
91 wxSize GetClientSize();
94 wxSize GetClientSize() {
96 self->GetClientSize(&w, &h);
101 wxLayoutConstraints * GetConstraints();
103 wxButton* GetDefaultItem();
105 //wxEvtHandler* GetEventHandler();
112 wxColour GetForegroundColour();
113 wxWindow * GetGrandParent();
117 wxWindow * GetParent();
118 %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT);
120 wxPoint GetPosition();
124 int GetScrollThumb(int orientation);
125 int GetScrollPos(int orientation);
126 int GetScrollRange(int orientation);
127 %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT);
131 void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT); // int* descent = NULL, int* externalLeading = NULL, const wxFont* font = NULL, bool use16 = FALSE)
133 long GetWindowStyleFlag();
139 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
141 void MakeModal(bool flag);
142 void Move(int x, int y);
144 //wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE);
145 bool PopupMenu(wxMenu *menu, int x, int y);
146 //void PushEventHandler(wxEvtHandler* handler);
149 void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL);
151 void ScreenToClient(int *BOTH, int *BOTH);
152 void ScrollWindow(int dx, int dy, const wxRect* rect = NULL);
153 void SetAcceleratorTable(const wxAcceleratorTable& accel);
154 void SetAutoLayout(bool autoLayout);
155 void SetBackgroundColour(const wxColour& colour);
156 void SetConstraints(wxLayoutConstraints *constraints);
157 void SetDoubleClick(bool allowDoubleClick);
159 void SetFont(const wxFont& font);
160 void SetForegroundColour(const wxColour& colour);
162 void SetName(const wxString& name);
163 void SetReturnCode(int retCode);
164 void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh = TRUE);
165 void SetScrollPos(int orientation, int pos, bool refresh = TRUE);
167 //void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
168 //%name(SetSizeOnly) void SetSize(int width, int height);
170 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
172 void SetSize(const wxSize& size) {
173 self->SetSize(size.x, size.y);
176 void SetPosition(const wxPoint& pos) {
177 self->SetSize(pos.x, pos.y, -1, -1);
181 void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1);
182 void SetClientSize(int width, int height);
183 //void SetPalette(wxPalette* palette);
184 void SetCursor(const wxCursor&cursor);
185 //void SetEventHandler(wxEvtHandler* handler);
186 void SetTitle(const wxString& title);
187 bool Show(bool show);
188 bool TransferDataFromWindow();
189 bool TransferDataToWindow();
192 void WarpPointer(int x, int y);
195 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
196 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
198 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
199 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
203 %pragma(python) code = "
204 def wxDLG_PNT(win, point):
205 return win.ConvertDialogPointToPixels(point)
207 def wxDLG_SZE(win, size):
208 return win.ConvertDialogPointToPixels(size)
214 wxWindow* wxWindow_FindFocus() {
215 return wxWindow::FindFocus();
221 //---------------------------------------------------------------------------
223 class wxPanel : public wxWindow {
225 wxPanel(wxWindow* parent,
227 const wxPoint& pos = wxPyDefaultPosition,
228 const wxSize& size = wxPyDefaultSize,
229 long style = wxTAB_TRAVERSAL,
230 const char* name = "panel");
232 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
237 //---------------------------------------------------------------------------
239 class wxDialog : public wxPanel {
241 wxDialog(wxWindow* parent,
243 const wxString& title,
244 const wxPoint& pos = wxPyDefaultPosition,
245 const wxSize& size = wxPyDefaultSize,
246 long style = wxDEFAULT_DIALOG_STYLE,
247 const char* name = "dialogBox");
249 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
251 void Centre(int direction = wxBOTH);
252 void EndModal(int retCode);
254 void Iconize(bool iconize);
256 void SetModal(bool flag);
258 void SetTitle(const wxString& title);
259 bool Show(bool show);
263 //---------------------------------------------------------------------------
265 class wxScrolledWindow : public wxWindow {
267 wxScrolledWindow(wxWindow* parent,
268 const wxWindowID id = -1,
269 const wxPoint& pos = wxPyDefaultPosition,
270 const wxSize& size = wxPyDefaultSize,
271 long style = wxHSCROLL | wxVSCROLL,
272 char* name = "scrolledWindow");
274 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
275 %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)"
277 void EnableScrolling(bool xScrolling, bool yScrolling);
278 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
279 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
281 void PrepareDC(wxDC& dc);
282 void Scroll(int x, int y);
283 void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
284 int noUnitsX, int noUnitsY,
285 int xPos = 0, int yPos = 0);
286 void ViewStart(int* OUTPUT, int* OUTPUT);
289 //----------------------------------------------------------------------
292 class wxMenu : public wxEvtHandler {
294 wxMenu(const wxString& title = wxPyEmptyStr);
296 void Append(int id, const wxString& item,
297 const wxString& helpString = wxPyEmptyStr,
298 int checkable = FALSE);
299 %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu,
300 const wxString& helpString = wxPyEmptyStr);
301 void AppendSeparator();
303 void Check(int id, bool flag);
304 void Enable(int id, bool enable);
305 int FindItem(const wxString& itemString);
308 void SetTitle(const wxString& title);
310 wxMenuItem* FindItemForId(int id);
311 wxString GetHelpString(int id);
312 wxString GetLabel(int id);
313 void SetHelpString(int id, const wxString& helpString);
314 bool IsChecked(int id);
315 bool IsEnabled(int id);
316 void SetLabel(int id, const wxString& label);
321 // This one knows how to set a callback and handle INC- and DECREFing it. To
322 // be used for PopupMenus, but you must retain a referece to it while using
325 class wxPyMenu : public wxMenu {
327 wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL);
331 //----------------------------------------------------------------------
333 class wxMenuBar : public wxEvtHandler {
337 void Append(wxMenu *menu, const wxString& title);
338 void Check(int id, bool flag);
339 bool Checked(int id);
340 void Enable(int id, bool enable);
341 bool Enabled(int id);
342 int FindMenuItem(const wxString& menuString, const wxString& itemString);
344 %name(FindItemForId) wxMenuItem* FindMenuItemById( int id );
347 wxMenuItem * FindItemForId(int id);
348 void EnableTop(int pos, bool enable);
349 wxString GetHelpString(int id);
350 wxString GetLabel(int id);
351 void SetHelpString(int id, const wxString& helpString);
352 void SetLabel(int id, const wxString& label);
353 wxString GetLabelTop(int pos);
354 void SetLabelTop(int pos, const wxString& label);
357 wxMenu* GetMenu(int i);
361 //----------------------------------------------------------------------
370 wxMenu* GetSubMenu();
372 void SetName(const wxString& strName);
373 void DeleteSubMenu();
374 const wxString& GetName();
376 const wxString& GetHelp();
377 void SetHelp(const wxString& strHelp);
378 void Enable(bool bDoEnable = TRUE);
379 void Check(bool bDoCheck = TRUE);
382 //---------------------------------------------------------------------------
383 /////////////////////////////////////////////////////////////////////////////
386 // Revision 1.8 1998/12/16 22:10:56 RD
387 // Tweaks needed to be able to build wxPython with wxGTK.
389 // Revision 1.7 1998/12/15 20:41:25 RD
390 // Changed the import semantics from "from wxPython import *" to "from
391 // wxPython.wx import *" This is for people who are worried about
392 // namespace pollution, they can use "from wxPython import wx" and then
393 // prefix all the wxPython identifiers with "wx."
395 // Added wxTaskbarIcon for wxMSW.
397 // Made the events work for wxGrid.
401 // Added wxMiniFrame for wxGTK, (untested.)
403 // Changed many of the args and return values that were pointers to gdi
404 // objects to references to reflect changes in the wxWindows API.
406 // Other assorted fixes and additions.
408 // Revision 1.6 1998/10/02 06:40:43 RD
410 // Version 0.4 of wxPython for MSW.
412 // Revision 1.5 1998/08/17 18:29:40 RD
413 // Removed an extra method definition
415 // Revision 1.4 1998/08/16 04:31:11 RD
418 // Revision 1.3 1998/08/15 07:36:47 RD
419 // - Moved the header in the .i files out of the code that gets put into
420 // the .cpp files. It caused CVS conflicts because of the RCS ID being
421 // different each time.
423 // - A few minor fixes.
425 // Revision 1.2 1998/08/14 23:36:46 RD
426 // Beginings of wxGTK compatibility
428 // Revision 1.1 1998/08/09 08:25:52 RD