]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/windows.i
1a8ef667e51d3b6d8e670c74b3e5d0c333c666e8
[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
36 class wxEvtHandler {
37 public:
38 bool ProcessEvent(wxEvent& event);
39 %addmethods {
40 void Connect( int id, int lastId, int eventType, PyObject* func) {
41 if (PyCallable_Check(func)) {
42 self->Connect(id, lastId, eventType,
43 (wxObjectEventFunction) &wxPyCallback::EventThunker,
44 new wxPyCallback(func));
45 }
46 }
47 }
48 };
49
50
51 //----------------------------------------------------------------------
52
53 %apply int * INOUT { int* x, int* y };
54
55 class wxWindow : public wxEvtHandler {
56 public:
57
58 wxWindow(wxWindow* parent, const wxWindowID id,
59 const wxPoint& pos = wxPyDefaultPosition,
60 const wxSize& size = wxPyDefaultSize,
61 long style = 0,
62 char* name = "panel");
63
64 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
65
66 void CaptureMouse();
67 void Center(int direction = wxBOTH);
68 void Centre(int direction = wxBOTH);
69 void CentreOnParent(int direction = wxBOTH );
70 void CenterOnParent(int direction = wxBOTH );
71
72 // (uses apply'ed INOUT typemap, see above)
73 %name(ClientToScreenXY)void ClientToScreen(int* x, int* y);
74 wxPoint ClientToScreen(const wxPoint& pt);
75
76 bool Close(int force = FALSE);
77 bool Destroy();
78 void DestroyChildren();
79 #ifdef __WXMSW__
80 void DragAcceptFiles(bool accept);
81 #endif
82 void Enable(bool enable);
83 //bool FakePopupMenu(wxMenu* menu, int x, int y);
84 %name(FindWindowById) wxWindow* FindWindow(long id);
85 %name(FindWindowByName) wxWindow* FindWindow(const wxString& name);
86 void Fit();
87 wxColour GetBackgroundColour();
88
89 //wxList& GetChildren();
90 %addmethods {
91 PyObject* GetChildren() {
92 wxWindowList& list = self->GetChildren();
93 return wxPy_ConvertList(&list, "wxWindow");
94 }
95 }
96
97
98 int GetCharHeight();
99 int GetCharWidth();
100 %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT);
101 wxSize GetClientSize();
102 wxLayoutConstraints * GetConstraints();
103 wxEvtHandler* GetEventHandler();
104
105 wxFont& GetFont();
106 wxColour GetForegroundColour();
107 wxWindow * GetGrandParent();
108 int GetId();
109 wxString GetLabel();
110 void SetLabel(const wxString& label);
111 wxString GetName();
112 wxWindow * GetParent();
113 %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT);
114 wxPoint GetPosition();
115 wxRect GetRect();
116 int GetScrollThumb(int orientation);
117 int GetScrollPos(int orientation);
118 int GetScrollRange(int orientation);
119 %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT);
120 wxSize GetSize();
121 void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT);
122 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
123 int *OUTPUT, int *OUTPUT, int *OUTPUT, int* OUTPUT,
124 const wxFont* font = NULL); //, bool use16 = FALSE)
125 wxString GetTitle();
126 wxRegion GetUpdateRegion();
127 long GetWindowStyleFlag();
128 bool Hide();
129 void InitDialog();
130 bool IsEnabled();
131 bool IsRetained();
132 bool IsShown();
133 bool IsTopLevel();
134 void Layout();
135 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
136 void Lower();
137 void MakeModal(bool flag);
138 %name(MoveXY)void Move(int x, int y);
139 void Move(const wxPoint& point);
140
141 wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE);
142 void PushEventHandler(wxEvtHandler* handler);
143
144 %name(PopupMenuXY)bool PopupMenu(wxMenu *menu, int x, int y);
145 bool PopupMenu(wxMenu *menu, const wxPoint& pos);
146
147 void Raise();
148 void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL);
149 void ReleaseMouse();
150 bool Reparent( wxWindow* newParent );
151
152 // (uses apply'ed INOUT typemap, see above)
153 %name(ScreenToClientXY)void ScreenToClient(int *x, int *y);
154 wxPoint ScreenToClient(const wxPoint& pt);
155
156 void ScrollWindow(int dx, int dy, const wxRect* rect = NULL);
157 void SetAcceleratorTable(const wxAcceleratorTable& accel);
158 void SetAutoLayout(bool autoLayout);
159 void SetBackgroundColour(const wxColour& colour);
160 void SetConstraints(wxLayoutConstraints *constraints);
161 void SetFocus();
162 void SetFont(const wxFont& font);
163 void SetForegroundColour(const wxColour& colour);
164 void SetId(int id);
165 void SetName(const wxString& name);
166 void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh = TRUE);
167 void SetScrollPos(int orientation, int pos, bool refresh = TRUE);
168
169 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
170 %addmethods {
171 void SetSize(const wxSize& size) {
172 self->SetSize(size.x, size.y);
173 }
174
175 void SetPosition(const wxPoint& pos) {
176 self->SetSize(pos.x, pos.y, -1, -1);
177 }
178 }
179
180 void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1);
181 %name(SetClientSizeWH)void SetClientSize(int width, int height);
182 void SetClientSize(const wxSize& size);
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 void WarpPointer(int x, int y);
192
193 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
194 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
195
196 %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt);
197 %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz);
198
199 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
200 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
201
202 %name(SetToolTipString)void SetToolTip(const wxString &tip);
203 void SetToolTip(wxToolTip *tooltip);
204 wxToolTip* GetToolTip();
205 };
206
207 //%clear int* x, int* y;
208
209
210
211 %pragma(python) code = "
212 def wxDLG_PNT(win, point_or_x, y=None):
213 if y is None:
214 return win.ConvertDialogPointToPixels(point_or_x)
215 else:
216 return win.ConvertDialogPointToPixels(wxPoint(point_or_x, y))
217
218 def wxDLG_SZE(win, size_width, height=None):
219 if height is None:
220 return win.ConvertDialogSizeToPixels(size_width)
221 else:
222 return win.ConvertDialogSizeToPixels(wxSize(size_width, height))
223 "
224
225 #ifdef __WXMSW__
226 %inline %{
227 wxWindow* wxWindow_FindFocus() {
228 return wxWindow::FindFocus();
229 }
230 %}
231
232
233 %inline %{
234 wxWindow* wxWindow_FromHWND(unsigned long hWnd) {
235 wxWindow* win = new wxWindow;
236 win->SetHWND(hWnd);
237 win->SubclassWin(hWnd);
238 return win;
239 }
240 %}
241 #endif
242
243
244
245 //---------------------------------------------------------------------------
246
247 class wxPanel : public wxWindow {
248 public:
249 wxPanel(wxWindow* parent,
250 const wxWindowID id,
251 const wxPoint& pos = wxPyDefaultPosition,
252 const wxSize& size = wxPyDefaultSize,
253 long style = wxTAB_TRAVERSAL,
254 const char* name = "panel");
255
256 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
257
258 void InitDialog();
259 wxButton* GetDefaultItem();
260 void SetDefaultItem(wxButton *btn);
261
262 // fix some SWIG trouble...
263 %pragma(python) addtoclass = "
264 def GetDefaultItem(self):
265 import controls
266 val = windowsc.wxPanel_GetDefaultItem(self.this)
267 val = controls.wxButtonPtr(val)
268 return val
269 "
270 };
271
272 //---------------------------------------------------------------------------
273
274 class wxDialog : public wxPanel {
275 public:
276 wxDialog(wxWindow* parent,
277 const wxWindowID id,
278 const wxString& title,
279 const wxPoint& pos = wxPyDefaultPosition,
280 const wxSize& size = wxPyDefaultSize,
281 long style = wxDEFAULT_DIALOG_STYLE,
282 const char* name = "dialogBox");
283
284 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
285
286 void Centre(int direction = wxBOTH);
287 void EndModal(int retCode);
288 wxString GetTitle();
289 void Iconize(bool iconize);
290 bool IsIconized();
291 void SetModal(bool flag);
292 bool IsModal();
293 void SetTitle(const wxString& title);
294 bool Show(bool show);
295 int ShowModal();
296
297 int GetReturnCode();
298 void SetReturnCode(int retCode);
299 };
300
301 //---------------------------------------------------------------------------
302
303 class wxScrolledWindow : public wxPanel {
304 public:
305 wxScrolledWindow(wxWindow* parent,
306 const wxWindowID id = -1,
307 const wxPoint& pos = wxPyDefaultPosition,
308 const wxSize& size = wxPyDefaultSize,
309 long style = wxHSCROLL | wxVSCROLL,
310 char* name = "scrolledWindow");
311
312 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
313 %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)"
314
315 void EnableScrolling(bool xScrolling, bool yScrolling);
316 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
317 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
318 bool IsRetained();
319 void PrepareDC(wxDC& dc);
320 void Scroll(int x, int y);
321 void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
322 int noUnitsX, int noUnitsY,
323 int xPos = 0, int yPos = 0);
324 void ViewStart(int* OUTPUT, int* OUTPUT);
325 };
326
327 //----------------------------------------------------------------------
328
329
330 class wxMenu : public wxEvtHandler {
331 public:
332 wxMenu(const wxString& title = wxPyEmptyStr, long style = 0);
333
334 void Append(int id, const wxString& item,
335 const wxString& helpString = wxPyEmptyStr,
336 int checkable = FALSE);
337 %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu,
338 const wxString& helpString = wxPyEmptyStr);
339 #ifndef __WXGTK__
340 %name(AppendItem)void Append(const wxMenuItem* item);
341 #endif
342
343 void AppendSeparator();
344 void Break();
345 void Check(int id, bool flag);
346 void Enable(int id, bool enable);
347 int FindItem(const wxString& itemString);
348 wxString GetTitle();
349 void SetTitle(const wxString& title);
350 wxMenuItem* FindItemForId(int id);
351 wxString GetHelpString(int id);
352 wxString GetLabel(int id);
353 void SetHelpString(int id, const wxString& helpString);
354 bool IsChecked(int id);
355 bool IsEnabled(int id);
356 void SetLabel(int id, const wxString& label);
357 void UpdateUI(wxEvtHandler* source = NULL);
358
359 %addmethods {
360 void Destroy() {
361 delete self;
362 }
363 }
364
365 };
366
367
368 //
369 // This one knows how to set a callback and handle INC- and DECREFing it. To
370 // be used for PopupMenus, but you must retain a referece to it while using
371 // it.
372 //
373 // class wxPyMenu : public wxMenu {
374 // public:
375 // wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL);
376 // ~wxPyMenu();
377 // };
378
379 //----------------------------------------------------------------------
380
381 class wxMenuBar : public wxEvtHandler {
382 public:
383 wxMenuBar();
384
385 void Append(wxMenu *menu, const wxString& title);
386 void Check(int id, bool flag);
387 bool Checked(int id);
388 void Enable(int id, bool enable);
389 bool Enabled(int id);
390 int FindMenuItem(const wxString& menuString, const wxString& itemString);
391 wxMenuItem * FindItemForId(int id);
392 #ifdef __WXMSW__
393 void EnableTop(int pos, bool enable);
394 wxString GetHelpString(int id);
395 wxString GetLabel(int id);
396 void SetHelpString(int id, const wxString& helpString);
397 void SetLabel(int id, const wxString& label);
398 wxString GetLabelTop(int pos);
399 void SetLabelTop(int pos, const wxString& label);
400 #endif
401 int GetMenuCount();
402 wxMenu* GetMenu(int i);
403 };
404
405
406 //----------------------------------------------------------------------
407
408 class wxMenuItem {
409 public:
410 #ifndef __WXGTK__
411 wxMenuItem(wxMenu* parentMenu=NULL, int id=ID_SEPARATOR,
412 const wxString& text = wxPyEmptyStr,
413 const wxString& helpString = wxPyEmptyStr,
414 bool checkable = FALSE, wxMenu* subMenu = NULL);
415 #else
416 wxMenuItem();
417 #endif
418
419 bool IsSeparator();
420 bool IsEnabled();
421 bool IsChecked();
422 bool IsCheckable();
423 int GetId();
424 wxMenu* GetSubMenu();
425 void SetName(const wxString& strName);
426 wxString GetName();
427 wxString GetHelp();
428 void SetHelp(const wxString& strHelp);
429 void Enable(bool bDoEnable = TRUE);
430 void Check(bool bDoCheck = TRUE);
431
432 #ifdef __WXMSW__
433 wxColour& GetBackgroundColour();
434 wxBitmap GetBitmap(bool checked = TRUE);
435 wxFont& GetFont();
436 int GetMarginWidth();
437 wxColour& GetTextColour();
438 void SetBackgroundColour(const wxColour& colour);
439 void SetBitmaps(const wxBitmap& checked, const wxBitmap& unchecked = wxNullBitmap);
440 void SetFont(const wxFont& font);
441 void SetMarginWidth(int width);
442 void SetTextColour(const wxColour& colour);
443 void DeleteSubMenu();
444 #endif
445 };
446
447 //---------------------------------------------------------------------------
448
449