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 void ClientToScreen(int *BOTH, int *BOTH);
67 bool Close(int force = FALSE);
69 void DestroyChildren();
71 void DragAcceptFiles(bool accept);
73 void Enable(bool enable);
74 //bool FakePopupMenu(wxMenu* menu, int x, int y);
75 %name(FindWindowByID) wxWindow* FindWindow(long id);
76 %name(FindWindowByName) wxWindow* FindWindow(const wxString& name);
78 wxColour GetBackgroundColour();
81 %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT);
82 wxSize GetClientSize();
83 wxLayoutConstraints * GetConstraints();
85 wxButton* GetDefaultItem();
87 //wxEvtHandler* GetEventHandler();
90 wxColour GetForegroundColour();
91 wxWindow * GetGrandParent();
95 wxWindow * GetParent();
96 %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT);
97 wxPoint GetPosition();
100 int GetScrollThumb(int orientation);
101 int GetScrollPos(int orientation);
102 int GetScrollRange(int orientation);
103 %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT);
105 void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT); // int* descent = NULL, int* externalLeading = NULL, const wxFont* font = NULL, bool use16 = FALSE)
107 long GetWindowStyleFlag();
113 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
115 void MakeModal(bool flag);
116 void Move(int x, int y);
118 //wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE);
119 bool PopupMenu(wxMenu *menu, int x, int y);
120 //void PushEventHandler(wxEvtHandler* handler);
123 void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL);
125 void ScreenToClient(int *BOTH, int *BOTH);
126 void ScrollWindow(int dx, int dy, const wxRect* rect = NULL);
127 void SetAcceleratorTable(const wxAcceleratorTable& accel);
128 void SetAutoLayout(bool autoLayout);
129 void SetBackgroundColour(const wxColour& colour);
130 void SetConstraints(wxLayoutConstraints *constraints);
131 void SetDoubleClick(bool allowDoubleClick);
133 void SetFont(const wxFont& font);
134 void SetForegroundColour(const wxColour& colour);
136 void SetName(const wxString& name);
137 void SetReturnCode(int retCode);
138 void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh = TRUE);
139 void SetScrollPos(int orientation, int pos, bool refresh = TRUE);
141 //void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
142 //%name(SetSizeOnly) void SetSize(int width, int height);
144 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
146 void SetSize(const wxSize& size) {
147 self->SetSize(size.x, size.y);
150 void SetPosition(const wxPoint& pos) {
151 self->SetSize(pos.x, pos.y, -1, -1);
155 void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1);
156 void SetClientSize(int width, int height);
157 //void SetPalette(wxPalette* palette);
158 void SetCursor(const wxCursor&cursor);
159 //void SetEventHandler(wxEvtHandler* handler);
160 void SetTitle(const wxString& title);
161 bool Show(bool show);
162 bool TransferDataFromWindow();
163 bool TransferDataToWindow();
165 void WarpPointer(int x, int y);
167 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
168 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
170 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
171 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
175 %pragma(python) code = "
176 def wxDLG_PNT(win, point):
177 return win.ConvertDialogPointToPixels(point)
179 def wxDLG_SZE(win, size):
180 return win.ConvertDialogPointToPixels(size)
186 wxWindow* wxWindow_FindFocus() {
187 return wxWindow::FindFocus();
193 //---------------------------------------------------------------------------
195 class wxPanel : public wxWindow {
197 wxPanel(wxWindow* parent,
199 const wxPoint& pos = wxPyDefaultPosition,
200 const wxSize& size = wxPyDefaultSize,
201 long style = wxTAB_TRAVERSAL,
202 const char* name = "panel");
204 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
209 //---------------------------------------------------------------------------
211 class wxDialog : public wxPanel {
213 wxDialog(wxWindow* parent,
215 const wxString& title,
216 const wxPoint& pos = wxPyDefaultPosition,
217 const wxSize& size = wxPyDefaultSize,
218 long style = wxDEFAULT_DIALOG_STYLE,
219 const char* name = "dialogBox");
221 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
223 void Centre(int direction = wxBOTH);
224 void EndModal(int retCode);
226 void Iconize(bool iconize);
228 void SetModal(bool flag);
230 void SetTitle(const wxString& title);
231 bool Show(bool show);
235 //---------------------------------------------------------------------------
237 class wxScrolledWindow : public wxWindow {
239 wxScrolledWindow(wxWindow* parent,
240 const wxWindowID id = -1,
241 const wxPoint& pos = wxPyDefaultPosition,
242 const wxSize& size = wxPyDefaultSize,
243 long style = wxHSCROLL | wxVSCROLL,
244 char* name = "scrolledWindow");
246 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
247 %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)"
249 void EnableScrolling(bool xScrolling, bool yScrolling);
250 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
251 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
253 void PrepareDC(wxDC& dc);
254 void Scroll(int x, int y);
255 void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
256 int noUnitsX, int noUnitsY,
257 int xPos = 0, int yPos = 0);
258 void ViewStart(int* OUTPUT, int* OUTPUT);
261 //----------------------------------------------------------------------
264 class wxMenu : public wxEvtHandler {
266 wxMenu(const wxString& title = wxPyEmptyStr);
268 void Append(int id, const wxString& item,
269 const wxString& helpString = wxPyEmptyStr,
270 int checkable = FALSE);
271 %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu,
272 const wxString& helpString = wxPyEmptyStr);
273 void AppendSeparator();
275 void Check(int id, bool flag);
276 void Enable(int id, bool enable);
277 int FindItem(const wxString& itemString);
279 void SetTitle(const wxString& title);
280 wxMenuItem* FindItemForId(int id);
281 wxString GetHelpString(int id);
282 wxString GetLabel(int id);
283 void SetHelpString(int id, const wxString& helpString);
284 bool IsChecked(int id);
285 bool IsEnabled(int id);
286 void SetLabel(int id, const wxString& label);
291 // This one knows how to set a callback and handle INC- and DECREFing it. To
292 // be used for PopupMenus, but you must retain a referece to it while using
295 class wxPyMenu : public wxMenu {
297 wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL);
301 //----------------------------------------------------------------------
303 class wxMenuBar : public wxEvtHandler {
307 void Append(wxMenu *menu, const wxString& title);
308 void Check(int id, bool flag);
309 bool Checked(int id);
310 void Enable(int id, bool enable);
311 bool Enabled(int id);
312 int FindMenuItem(const wxString& menuString, const wxString& itemString);
313 wxMenuItem * FindItemForId(int id);
315 void EnableTop(int pos, bool enable);
316 wxString GetHelpString(int id);
317 wxString GetLabel(int id);
318 void SetHelpString(int id, const wxString& helpString);
319 void SetLabel(int id, const wxString& label);
320 wxString GetLabelTop(int pos);
321 void SetLabelTop(int pos, const wxString& label);
324 wxMenu* GetMenu(int i);
328 //----------------------------------------------------------------------
337 wxMenu* GetSubMenu();
338 void SetName(const wxString& strName);
339 const wxString& GetName();
340 const wxString& GetHelp();
341 void SetHelp(const wxString& strHelp);
342 void Enable(bool bDoEnable = TRUE);
343 void Check(bool bDoCheck = TRUE);
346 void DeleteSubMenu();
350 //---------------------------------------------------------------------------
351 /////////////////////////////////////////////////////////////////////////////
354 // Revision 1.11 1998/12/18 15:49:10 RR
355 // wxClipboard now serves the primary selection as well
359 // Revision 1.10 1998/12/17 17:52:20 RD
362 // Minor fixes and SWIG code generation for RR's changes. MSW and GTK
363 // versions are much closer now!
365 // Revision 1.9 1998/12/17 14:07:46 RR
367 // Removed minor differences between wxMSW and wxGTK
369 // Revision 1.8 1998/12/16 22:10:56 RD
371 // Tweaks needed to be able to build wxPython with wxGTK.
373 // Revision 1.7 1998/12/15 20:41:25 RD
374 // Changed the import semantics from "from wxPython import *" to "from
375 // wxPython.wx import *" This is for people who are worried about
376 // namespace pollution, they can use "from wxPython import wx" and then
377 // prefix all the wxPython identifiers with "wx."
379 // Added wxTaskbarIcon for wxMSW.
381 // Made the events work for wxGrid.
385 // Added wxMiniFrame for wxGTK, (untested.)
387 // Changed many of the args and return values that were pointers to gdi
388 // objects to references to reflect changes in the wxWindows API.
390 // Other assorted fixes and additions.
392 // Revision 1.6 1998/10/02 06:40:43 RD
394 // Version 0.4 of wxPython for MSW.
396 // Revision 1.5 1998/08/17 18:29:40 RD
397 // Removed an extra method definition
399 // Revision 1.4 1998/08/16 04:31:11 RD
402 // Revision 1.3 1998/08/15 07:36:47 RD
403 // - Moved the header in the .i files out of the code that gets put into
404 // the .cpp files. It caused CVS conflicts because of the RCS ID being
405 // different each time.
407 // - A few minor fixes.
409 // Revision 1.2 1998/08/14 23:36:46 RD
410 // Beginings of wxGTK compatibility
412 // Revision 1.1 1998/08/09 08:25:52 RD