]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/windows.i
Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
[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 #include <wx/menuitem.h>
19 %}
20
21 //----------------------------------------------------------------------
22
23 %include typemaps.i
24 %include my_typemaps.i
25
26 // Import some definitions of other classes, etc.
27 %import _defs.i
28 %import misc.i
29 %import gdi.i
30
31 %pragma(python) code = "import wx"
32
33 //---------------------------------------------------------------------------
34
35 class wxEvtHandler {
36 public:
37 %addmethods {
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));
43 }
44 }
45 }
46 };
47
48
49 //----------------------------------------------------------------------
50
51
52 class wxWindow : public wxEvtHandler {
53 public:
54
55 wxWindow(wxWindow* parent, const wxWindowID id,
56 const wxPoint& pos = wxPyDefaultPosition,
57 const wxSize& size = wxPyDefaultSize,
58 long style = 0,
59 char* name = "panel");
60
61 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
62
63 void CaptureMouse();
64 void Center(int direction = wxHORIZONTAL);
65 void Centre(int direction = wxHORIZONTAL);
66 %name(ClientToScreenXY)void ClientToScreen(int *BOTH, int *BOTH);
67 wxPoint ClientToScreen(const wxPoint& pt);
68 bool Close(int force = FALSE);
69 bool Destroy();
70 void DestroyChildren();
71 #ifdef __WXMSW__
72 void DragAcceptFiles(bool accept);
73 #endif
74 void Enable(bool enable);
75 //bool FakePopupMenu(wxMenu* menu, int x, int y);
76 %name(FindWindowById) wxWindow* FindWindow(long id);
77 %name(FindWindowByName) wxWindow* FindWindow(const wxString& name);
78 void Fit();
79 wxColour GetBackgroundColour();
80 int GetCharHeight();
81 int GetCharWidth();
82 %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT);
83 wxSize GetClientSize();
84 wxLayoutConstraints * GetConstraints();
85 #ifdef __WXMSW__
86 wxButton* GetDefaultItem();
87 #endif
88 //wxEvtHandler* GetEventHandler();
89
90 wxFont& GetFont();
91 wxColour GetForegroundColour();
92 wxWindow * GetGrandParent();
93 int GetId();
94 wxString GetLabel();
95 wxString GetName();
96 wxWindow * GetParent();
97 %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT);
98 wxPoint GetPosition();
99 wxRect GetRect();
100 int GetReturnCode();
101 int GetScrollThumb(int orientation);
102 int GetScrollPos(int orientation);
103 int GetScrollRange(int orientation);
104 %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT);
105 wxSize GetSize();
106 void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT);
107 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
108 int *OUTPUT, int *OUTPUT, int *OUTPUT, int* OUTPUT,
109 const wxFont* font = NULL); //, bool use16 = FALSE)
110 wxString GetTitle();
111 long GetWindowStyleFlag();
112 void InitDialog();
113 bool IsEnabled();
114 bool IsRetained();
115 bool IsShown();
116 void Layout();
117 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
118 void Lower();
119 void MakeModal(bool flag);
120 %name(MoveXY)void Move(int x, int y);
121 void Move(const wxPoint& point);
122
123 //wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE);
124 bool PopupMenu(wxMenu *menu, int x, int y);
125 //void PushEventHandler(wxEvtHandler* handler);
126
127 void Raise();
128 void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL);
129 void ReleaseMouse();
130 %name(ScreenToClientXY)void ScreenToClient(int *BOTH, int *BOTH);
131 wxPoint ScreenToClient(const wxPoint& pt);
132
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);
139 void SetFocus();
140 void SetFont(const wxFont& font);
141 void SetForegroundColour(const wxColour& colour);
142 void SetId(int id);
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);
147
148 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
149 %addmethods {
150 void SetSize(const wxSize& size) {
151 self->SetSize(size.x, size.y);
152 }
153
154 void SetPosition(const wxPoint& pos) {
155 self->SetSize(pos.x, pos.y, -1, -1);
156 }
157 }
158
159 void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1);
160 %name(SetClientSizeWH)void SetClientSize(int width, int height);
161 void SetClientSize(const wxSize& size);
162 //void SetPalette(wxPalette* palette);
163 void SetCursor(const wxCursor&cursor);
164 //void SetEventHandler(wxEvtHandler* handler);
165 void SetTitle(const wxString& title);
166 bool Show(bool show);
167 bool TransferDataFromWindow();
168 bool TransferDataToWindow();
169 bool Validate();
170 void WarpPointer(int x, int y);
171
172 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
173 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
174
175 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
176 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
177
178 %name(SetToolTipString)void SetToolTip(const wxString &tip);
179 void SetToolTip(wxToolTip *tooltip);
180 wxToolTip* GetToolTip();
181 };
182
183 %pragma(python) code = "
184 def wxDLG_PNT(win, point):
185 return win.ConvertDialogPointToPixels(point)
186
187 def wxDLG_SZE(win, size):
188 return win.ConvertDialogSizeToPixels(size)
189 "
190
191 #ifdef __WXMSW__
192 %inline %{
193 wxWindow* wxWindow_FindFocus() {
194 return wxWindow::FindFocus();
195 }
196 %}
197
198
199 %inline %{
200 wxWindow* wxWindow_FromHWND(unsigned long hWnd) {
201 wxWindow* win = new wxWindow;
202 win->SetHWND(hWnd);
203 win->SubclassWin(hWnd);
204 return win;
205 }
206 %}
207 #endif
208
209
210 //---------------------------------------------------------------------------
211
212 class wxPanel : public wxWindow {
213 public:
214 wxPanel(wxWindow* parent,
215 const wxWindowID id,
216 const wxPoint& pos = wxPyDefaultPosition,
217 const wxSize& size = wxPyDefaultSize,
218 long style = wxTAB_TRAVERSAL,
219 const char* name = "panel");
220
221 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
222
223 void InitDialog();
224 };
225
226 //---------------------------------------------------------------------------
227
228 class wxDialog : public wxPanel {
229 public:
230 wxDialog(wxWindow* parent,
231 const wxWindowID id,
232 const wxString& title,
233 const wxPoint& pos = wxPyDefaultPosition,
234 const wxSize& size = wxPyDefaultSize,
235 long style = wxDEFAULT_DIALOG_STYLE,
236 const char* name = "dialogBox");
237
238 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
239
240 void Centre(int direction = wxBOTH);
241 void EndModal(int retCode);
242 wxString GetTitle();
243 void Iconize(bool iconize);
244 bool IsIconized();
245 void SetModal(bool flag);
246 bool IsModal();
247 void SetTitle(const wxString& title);
248 bool Show(bool show);
249 int ShowModal();
250 };
251
252 //---------------------------------------------------------------------------
253
254 class wxScrolledWindow : public wxWindow {
255 public:
256 wxScrolledWindow(wxWindow* parent,
257 const wxWindowID id = -1,
258 const wxPoint& pos = wxPyDefaultPosition,
259 const wxSize& size = wxPyDefaultSize,
260 long style = wxHSCROLL | wxVSCROLL,
261 char* name = "scrolledWindow");
262
263 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
264 %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)"
265
266 void EnableScrolling(bool xScrolling, bool yScrolling);
267 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
268 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
269 bool IsRetained();
270 void PrepareDC(wxDC& dc);
271 void Scroll(int x, int y);
272 void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
273 int noUnitsX, int noUnitsY,
274 int xPos = 0, int yPos = 0);
275 void ViewStart(int* OUTPUT, int* OUTPUT);
276 };
277
278 //----------------------------------------------------------------------
279
280
281 class wxMenu : public wxEvtHandler {
282 public:
283 wxMenu(const wxString& title = wxPyEmptyStr);
284
285 void Append(int id, const wxString& item,
286 const wxString& helpString = wxPyEmptyStr,
287 int checkable = FALSE);
288 %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu,
289 const wxString& helpString = wxPyEmptyStr);
290 %name(AppendItem)void Append(const wxMenuItem* item);
291
292 void AppendSeparator();
293 void Break();
294 void Check(int id, bool flag);
295 void Enable(int id, bool enable);
296 int FindItem(const wxString& itemString);
297 wxString GetTitle();
298 void SetTitle(const wxString& title);
299 wxMenuItem* FindItemForId(int id);
300 wxString GetHelpString(int id);
301 wxString GetLabel(int id);
302 void SetHelpString(int id, const wxString& helpString);
303 bool IsChecked(int id);
304 bool IsEnabled(int id);
305 void SetLabel(int id, const wxString& label);
306 };
307
308
309 //
310 // This one knows how to set a callback and handle INC- and DECREFing it. To
311 // be used for PopupMenus, but you must retain a referece to it while using
312 // it.
313 //
314 class wxPyMenu : public wxMenu {
315 public:
316 wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL);
317 ~wxPyMenu();
318 };
319
320 //----------------------------------------------------------------------
321
322 class wxMenuBar : public wxEvtHandler {
323 public:
324 wxMenuBar();
325
326 void Append(wxMenu *menu, const wxString& title);
327 void Check(int id, bool flag);
328 bool Checked(int id);
329 void Enable(int id, bool enable);
330 bool Enabled(int id);
331 int FindMenuItem(const wxString& menuString, const wxString& itemString);
332 wxMenuItem * FindItemForId(int id);
333 #ifdef __WXMSW__
334 void EnableTop(int pos, bool enable);
335 wxString GetHelpString(int id);
336 wxString GetLabel(int id);
337 void SetHelpString(int id, const wxString& helpString);
338 void SetLabel(int id, const wxString& label);
339 wxString GetLabelTop(int pos);
340 void SetLabelTop(int pos, const wxString& label);
341 #endif
342 int GetMenuCount();
343 wxMenu* GetMenu(int i);
344 };
345
346
347 //----------------------------------------------------------------------
348
349 class wxMenuItem {
350 public:
351 bool IsSeparator();
352 bool IsEnabled();
353 bool IsChecked();
354 bool IsCheckable();
355 int GetId();
356 wxMenu* GetSubMenu();
357 void SetName(const wxString& strName);
358 const wxString& GetName();
359 const wxString& GetHelp();
360 void SetHelp(const wxString& strHelp);
361 void Enable(bool bDoEnable = TRUE);
362 void Check(bool bDoCheck = TRUE);
363
364 #ifdef __WXMSW__
365 void DeleteSubMenu();
366 #endif
367 };
368
369 //---------------------------------------------------------------------------
370 /////////////////////////////////////////////////////////////////////////////
371 //
372 // $Log$
373 // Revision 1.12 1999/02/20 09:03:03 RD
374 // Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
375 // window handle. If you can get the window handle into the python code,
376 // it should just work... More news on this later.
377 //
378 // Added wxImageList, wxToolTip.
379 //
380 // Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the
381 // wxRegConfig class.
382 //
383 // As usual, some bug fixes, tweaks, etc.
384 //
385 // Revision 1.11 1998/12/18 15:49:10 RR
386 //
387 // wxClipboard now serves the primary selection as well
388 // wxPython fixes
389 // warning mesages
390 //
391 // Revision 1.10 1998/12/17 17:52:20 RD
392 //
393 // wxPython 0.5.2
394 // Minor fixes and SWIG code generation for RR's changes. MSW and GTK
395 // versions are much closer now!
396 //
397 // Revision 1.9 1998/12/17 14:07:46 RR
398 //
399 // Removed minor differences between wxMSW and wxGTK
400 //
401 // Revision 1.8 1998/12/16 22:10:56 RD
402 //
403 // Tweaks needed to be able to build wxPython with wxGTK.
404 //
405 // Revision 1.7 1998/12/15 20:41:25 RD
406 // Changed the import semantics from "from wxPython import *" to "from
407 // wxPython.wx import *" This is for people who are worried about
408 // namespace pollution, they can use "from wxPython import wx" and then
409 // prefix all the wxPython identifiers with "wx."
410 //
411 // Added wxTaskbarIcon for wxMSW.
412 //
413 // Made the events work for wxGrid.
414 //
415 // Added wxConfig.
416 //
417 // Added wxMiniFrame for wxGTK, (untested.)
418 //
419 // Changed many of the args and return values that were pointers to gdi
420 // objects to references to reflect changes in the wxWindows API.
421 //
422 // Other assorted fixes and additions.
423 //
424 // Revision 1.6 1998/10/02 06:40:43 RD
425 //
426 // Version 0.4 of wxPython for MSW.
427 //
428 // Revision 1.5 1998/08/17 18:29:40 RD
429 // Removed an extra method definition
430 //
431 // Revision 1.4 1998/08/16 04:31:11 RD
432 // More wxGTK work.
433 //
434 // Revision 1.3 1998/08/15 07:36:47 RD
435 // - Moved the header in the .i files out of the code that gets put into
436 // the .cpp files. It caused CVS conflicts because of the RCS ID being
437 // different each time.
438 //
439 // - A few minor fixes.
440 //
441 // Revision 1.2 1998/08/14 23:36:46 RD
442 // Beginings of wxGTK compatibility
443 //
444 // Revision 1.1 1998/08/09 08:25:52 RD
445 // Initial version
446 //
447 //
448
449