]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/windows.i
wxClipboard now serves the primary selection as well
[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 void ClientToScreen(int *BOTH, int *BOTH);
67 bool Close(int force = FALSE);
68 bool Destroy();
69 void DestroyChildren();
70 #ifdef __WXMSW__
71 void DragAcceptFiles(bool accept);
72 #endif
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);
77 void Fit();
78 wxColour GetBackgroundColour();
79 int GetCharHeight();
80 int GetCharWidth();
81 %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT);
82 wxSize GetClientSize();
83 wxLayoutConstraints * GetConstraints();
84 #ifdef __WXMSW__
85 wxButton* GetDefaultItem();
86 #endif
87 //wxEvtHandler* GetEventHandler();
88
89 wxFont& GetFont();
90 wxColour GetForegroundColour();
91 wxWindow * GetGrandParent();
92 int GetId();
93 wxString GetLabel();
94 wxString GetName();
95 wxWindow * GetParent();
96 %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT);
97 wxPoint GetPosition();
98 wxRect GetRect();
99 int GetReturnCode();
100 int GetScrollThumb(int orientation);
101 int GetScrollPos(int orientation);
102 int GetScrollRange(int orientation);
103 %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT);
104 wxSize GetSize();
105 void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT); // int* descent = NULL, int* externalLeading = NULL, const wxFont* font = NULL, bool use16 = FALSE)
106 wxString GetTitle();
107 long GetWindowStyleFlag();
108 void InitDialog();
109 bool IsEnabled();
110 bool IsRetained();
111 bool IsShown();
112 void Layout();
113 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
114 void Lower();
115 void MakeModal(bool flag);
116 void Move(int x, int y);
117
118 //wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE);
119 bool PopupMenu(wxMenu *menu, int x, int y);
120 //void PushEventHandler(wxEvtHandler* handler);
121
122 void Raise();
123 void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL);
124 void ReleaseMouse();
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);
132 void SetFocus();
133 void SetFont(const wxFont& font);
134 void SetForegroundColour(const wxColour& colour);
135 void SetId(int id);
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);
140
141 //void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
142 //%name(SetSizeOnly) void SetSize(int width, int height);
143
144 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
145 %addmethods {
146 void SetSize(const wxSize& size) {
147 self->SetSize(size.x, size.y);
148 }
149
150 void SetPosition(const wxPoint& pos) {
151 self->SetSize(pos.x, pos.y, -1, -1);
152 }
153 }
154
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();
164 bool Validate();
165 void WarpPointer(int x, int y);
166
167 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
168 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
169
170 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
171 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
172
173 };
174
175 %pragma(python) code = "
176 def wxDLG_PNT(win, point):
177 return win.ConvertDialogPointToPixels(point)
178
179 def wxDLG_SZE(win, size):
180 return win.ConvertDialogPointToPixels(size)
181 "
182
183 // Static method(s)
184 #ifdef __WXMSW__
185 %inline %{
186 wxWindow* wxWindow_FindFocus() {
187 return wxWindow::FindFocus();
188 }
189 %}
190 #endif
191
192
193 //---------------------------------------------------------------------------
194
195 class wxPanel : public wxWindow {
196 public:
197 wxPanel(wxWindow* parent,
198 const wxWindowID id,
199 const wxPoint& pos = wxPyDefaultPosition,
200 const wxSize& size = wxPyDefaultSize,
201 long style = wxTAB_TRAVERSAL,
202 const char* name = "panel");
203
204 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
205
206 void InitDialog();
207 };
208
209 //---------------------------------------------------------------------------
210
211 class wxDialog : public wxPanel {
212 public:
213 wxDialog(wxWindow* parent,
214 const wxWindowID id,
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");
220
221 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
222
223 void Centre(int direction = wxBOTH);
224 void EndModal(int retCode);
225 wxString GetTitle();
226 void Iconize(bool iconize);
227 bool IsIconized();
228 void SetModal(bool flag);
229 bool IsModal();
230 void SetTitle(const wxString& title);
231 bool Show(bool show);
232 int ShowModal();
233 };
234
235 //---------------------------------------------------------------------------
236
237 class wxScrolledWindow : public wxWindow {
238 public:
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");
245
246 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
247 %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)"
248
249 void EnableScrolling(bool xScrolling, bool yScrolling);
250 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
251 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
252 bool IsRetained();
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);
259 };
260
261 //----------------------------------------------------------------------
262
263
264 class wxMenu : public wxEvtHandler {
265 public:
266 wxMenu(const wxString& title = wxPyEmptyStr);
267
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();
274 void Break();
275 void Check(int id, bool flag);
276 void Enable(int id, bool enable);
277 int FindItem(const wxString& itemString);
278 wxString GetTitle();
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);
287 };
288
289
290 //
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
293 // it.
294 //
295 class wxPyMenu : public wxMenu {
296 public:
297 wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL);
298 ~wxPyMenu();
299 };
300
301 //----------------------------------------------------------------------
302
303 class wxMenuBar : public wxEvtHandler {
304 public:
305 wxMenuBar();
306
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);
314 #ifdef __WXMSW__
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);
322 #endif
323 int GetMenuCount();
324 wxMenu* GetMenu(int i);
325 };
326
327
328 //----------------------------------------------------------------------
329
330 class wxMenuItem {
331 public:
332 bool IsSeparator();
333 bool IsEnabled();
334 bool IsChecked();
335 bool IsCheckable();
336 int GetId();
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);
344
345 #ifdef __WXMSW__
346 void DeleteSubMenu();
347 #endif
348 };
349
350 //---------------------------------------------------------------------------
351 /////////////////////////////////////////////////////////////////////////////
352 //
353 // $Log$
354 // Revision 1.11 1998/12/18 15:49:10 RR
355 // wxClipboard now serves the primary selection as well
356 // wxPython fixes
357 // warning mesages
358 //
359 // Revision 1.10 1998/12/17 17:52:20 RD
360 //
361 // wxPython 0.5.2
362 // Minor fixes and SWIG code generation for RR's changes. MSW and GTK
363 // versions are much closer now!
364 //
365 // Revision 1.9 1998/12/17 14:07:46 RR
366 //
367 // Removed minor differences between wxMSW and wxGTK
368 //
369 // Revision 1.8 1998/12/16 22:10:56 RD
370 //
371 // Tweaks needed to be able to build wxPython with wxGTK.
372 //
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."
378 //
379 // Added wxTaskbarIcon for wxMSW.
380 //
381 // Made the events work for wxGrid.
382 //
383 // Added wxConfig.
384 //
385 // Added wxMiniFrame for wxGTK, (untested.)
386 //
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.
389 //
390 // Other assorted fixes and additions.
391 //
392 // Revision 1.6 1998/10/02 06:40:43 RD
393 //
394 // Version 0.4 of wxPython for MSW.
395 //
396 // Revision 1.5 1998/08/17 18:29:40 RD
397 // Removed an extra method definition
398 //
399 // Revision 1.4 1998/08/16 04:31:11 RD
400 // More wxGTK work.
401 //
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.
406 //
407 // - A few minor fixes.
408 //
409 // Revision 1.2 1998/08/14 23:36:46 RD
410 // Beginings of wxGTK compatibility
411 //
412 // Revision 1.1 1998/08/09 08:25:52 RD
413 // Initial version
414 //
415 //
416
417