]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/windows.i
9b095fb0792f8b7ef85d12b27078b96d343b9a60
[wxWidgets.git] / utils / wxPython / src / windows.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: windows.i
3 // Purpose: SWIG definitions of various window classes
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 6/24/97
8 // RCS-ID: $Id$
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13
14 %module windows
15
16 %{
17 #include "helpers.h"
18
19 #ifdef __WXMSW__
20 // wxGTK defines wxMenuItem inside menu.h
21 #include <wx/menuitem.h>
22 #endif
23
24 #ifdef __WXMSW__
25 #include <wx/minifram.h>
26 #endif
27 %}
28
29 //----------------------------------------------------------------------
30
31 %include typemaps.i
32 %include my_typemaps.i
33
34 // Import some definitions of other classes, etc.
35 %import _defs.i
36 %import misc.i
37 %import gdi.i
38
39 %pragma(python) code = "import wx"
40
41 //---------------------------------------------------------------------------
42
43 class wxEvtHandler {
44 public:
45 %addmethods {
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));
51 }
52 }
53 }
54 };
55
56
57 //----------------------------------------------------------------------
58
59
60 class wxWindow : public wxEvtHandler {
61 public:
62
63 wxWindow(wxWindow* parent, const wxWindowID id,
64 const wxPoint& pos = wxPyDefaultPosition,
65 const wxSize& size = wxPyDefaultSize,
66 long style = 0,
67 char* name = "panel");
68
69 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
70
71 void CaptureMouse();
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);
76 bool Destroy();
77 void DestroyChildren();
78 #ifdef __WXMSW__
79 void DragAcceptFiles(bool accept);
80 #endif
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);
85 void Fit();
86 wxColour GetBackgroundColour();
87 int GetCharHeight();
88 int GetCharWidth();
89 %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT);
90 #ifdef __WXMSW__
91 wxSize GetClientSize();
92 #else
93 %addmethods {
94 wxSize GetClientSize() {
95 int w, h;
96 self->GetClientSize(&w, &h);
97 return wxSize(w, h);
98 }
99 }
100 #endif
101 wxLayoutConstraints * GetConstraints();
102 #ifdef __WXMSW__
103 wxButton* GetDefaultItem();
104 #endif
105 //wxEvtHandler* GetEventHandler();
106
107 #ifdef __WXMSW__
108 wxFont& GetFont();
109 #else
110 wxFont GetFont();
111 #endif
112 wxColour GetForegroundColour();
113 wxWindow * GetGrandParent();
114 int GetId();
115 wxString GetLabel();
116 wxString GetName();
117 wxWindow * GetParent();
118 %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT);
119 #ifdef __WXMSW__
120 wxPoint GetPosition();
121 wxRect GetRect();
122 #endif
123 int GetReturnCode();
124 int GetScrollThumb(int orientation);
125 int GetScrollPos(int orientation);
126 int GetScrollRange(int orientation);
127 %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT);
128 #ifdef __WXMSW__
129 wxSize GetSize();
130 #endif
131 void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT); // int* descent = NULL, int* externalLeading = NULL, const wxFont* font = NULL, bool use16 = FALSE)
132 wxString GetTitle();
133 long GetWindowStyleFlag();
134 void InitDialog();
135 bool IsEnabled();
136 bool IsRetained();
137 bool IsShown();
138 void Layout();
139 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
140 void Lower();
141 void MakeModal(bool flag);
142 void Move(int x, int y);
143
144 //wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE);
145 bool PopupMenu(wxMenu *menu, int x, int y);
146 //void PushEventHandler(wxEvtHandler* handler);
147
148 void Raise();
149 void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL);
150 void ReleaseMouse();
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);
158 void SetFocus();
159 void SetFont(const wxFont& font);
160 void SetForegroundColour(const wxColour& colour);
161 void SetId(int id);
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);
166
167 //void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
168 //%name(SetSizeOnly) void SetSize(int width, int height);
169
170 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
171 %addmethods {
172 void SetSize(const wxSize& size) {
173 self->SetSize(size.x, size.y);
174 }
175
176 void SetPosition(const wxPoint& pos) {
177 self->SetSize(pos.x, pos.y, -1, -1);
178 }
179 }
180
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();
190 bool Validate();
191 #ifdef __WXMSW__
192 void WarpPointer(int x, int y);
193 #endif
194
195 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
196 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
197
198 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
199 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
200
201 };
202
203 %pragma(python) code = "
204 def wxDLG_PNT(win, point):
205 return win.ConvertDialogPointToPixels(point)
206
207 def wxDLG_SZE(win, size):
208 return win.ConvertDialogPointToPixels(size)
209 "
210
211 // Static method(s)
212 #ifdef __WXMSW__
213 %inline %{
214 wxWindow* wxWindow_FindFocus() {
215 return wxWindow::FindFocus();
216 }
217 %}
218 #endif
219
220
221 //---------------------------------------------------------------------------
222
223 class wxPanel : public wxWindow {
224 public:
225 wxPanel(wxWindow* parent,
226 const wxWindowID id,
227 const wxPoint& pos = wxPyDefaultPosition,
228 const wxSize& size = wxPyDefaultSize,
229 long style = wxTAB_TRAVERSAL,
230 const char* name = "panel");
231
232 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
233
234 void InitDialog();
235 };
236
237 //---------------------------------------------------------------------------
238
239 class wxDialog : public wxPanel {
240 public:
241 wxDialog(wxWindow* parent,
242 const wxWindowID id,
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");
248
249 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
250
251 void Centre(int direction = wxBOTH);
252 void EndModal(int retCode);
253 wxString GetTitle();
254 void Iconize(bool iconize);
255 bool IsIconized();
256 void SetModal(bool flag);
257 bool IsModal();
258 void SetTitle(const wxString& title);
259 bool Show(bool show);
260 int ShowModal();
261 };
262
263 //---------------------------------------------------------------------------
264
265 class wxScrolledWindow : public wxWindow {
266 public:
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");
273
274 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
275 %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)"
276
277 void EnableScrolling(bool xScrolling, bool yScrolling);
278 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
279 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
280 bool IsRetained();
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);
287 };
288
289 //----------------------------------------------------------------------
290
291
292 class wxMenu : public wxEvtHandler {
293 public:
294 wxMenu(const wxString& title = wxPyEmptyStr);
295
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();
302 void Break();
303 void Check(int id, bool flag);
304 void Enable(int id, bool enable);
305 int FindItem(const wxString& itemString);
306 #ifdef __WXMSW__
307 wxString GetTitle();
308 void SetTitle(const wxString& title);
309 #endif
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);
317 };
318
319
320 //
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
323 // it.
324 //
325 class wxPyMenu : public wxMenu {
326 public:
327 wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL);
328 ~wxPyMenu();
329 };
330
331 //----------------------------------------------------------------------
332
333 class wxMenuBar : public wxEvtHandler {
334 public:
335 wxMenuBar();
336
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);
343 #ifdef __WXGTK__
344 %name(FindItemForId) wxMenuItem* FindMenuItemById( int id );
345 #endif
346 #ifdef __WXMSW__
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);
355 #endif
356 int GetMenuCount();
357 wxMenu* GetMenu(int i);
358 };
359
360
361 //----------------------------------------------------------------------
362
363 class wxMenuItem {
364 public:
365 bool IsSeparator();
366 bool IsEnabled();
367 bool IsChecked();
368 bool IsCheckable();
369 int GetId();
370 wxMenu* GetSubMenu();
371 #ifdef __WXMSW__
372 void SetName(const wxString& strName);
373 void DeleteSubMenu();
374 const wxString& GetName();
375 #endif
376 const wxString& GetHelp();
377 void SetHelp(const wxString& strHelp);
378 void Enable(bool bDoEnable = TRUE);
379 void Check(bool bDoCheck = TRUE);
380 };
381
382 //---------------------------------------------------------------------------
383 /////////////////////////////////////////////////////////////////////////////
384 //
385 // $Log$
386 // Revision 1.8 1998/12/16 22:10:56 RD
387 // Tweaks needed to be able to build wxPython with wxGTK.
388 //
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."
394 //
395 // Added wxTaskbarIcon for wxMSW.
396 //
397 // Made the events work for wxGrid.
398 //
399 // Added wxConfig.
400 //
401 // Added wxMiniFrame for wxGTK, (untested.)
402 //
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.
405 //
406 // Other assorted fixes and additions.
407 //
408 // Revision 1.6 1998/10/02 06:40:43 RD
409 //
410 // Version 0.4 of wxPython for MSW.
411 //
412 // Revision 1.5 1998/08/17 18:29:40 RD
413 // Removed an extra method definition
414 //
415 // Revision 1.4 1998/08/16 04:31:11 RD
416 // More wxGTK work.
417 //
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.
422 //
423 // - A few minor fixes.
424 //
425 // Revision 1.2 1998/08/14 23:36:46 RD
426 // Beginings of wxGTK compatibility
427 //
428 // Revision 1.1 1998/08/09 08:25:52 RD
429 // Initial version
430 //
431 //
432
433