]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/windows.i
Added wxNB_LEFT,RIGHT,BOTTOM for notebook tab placement
[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 %name(AppendItem)void Append(const wxMenuItem* item);
340
341 void AppendSeparator();
342 void Break();
343 void Check(int id, bool flag);
344 void Enable(int id, bool enable);
345 int FindItem(const wxString& itemString);
346 wxString GetTitle();
347 void SetTitle(const wxString& title);
348 wxMenuItem* FindItemForId(int id);
349 wxString GetHelpString(int id);
350 wxString GetLabel(int id);
351 void SetHelpString(int id, const wxString& helpString);
352 bool IsChecked(int id);
353 bool IsEnabled(int id);
354 void SetLabel(int id, const wxString& label);
355 void UpdateUI(wxEvtHandler* source = NULL);
356
357 %addmethods {
358 void Destroy() {
359 delete self;
360 }
361 }
362
363 };
364
365
366 //
367 // This one knows how to set a callback and handle INC- and DECREFing it. To
368 // be used for PopupMenus, but you must retain a referece to it while using
369 // it.
370 //
371 // class wxPyMenu : public wxMenu {
372 // public:
373 // wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL);
374 // ~wxPyMenu();
375 // };
376
377 //----------------------------------------------------------------------
378
379 class wxMenuBar : public wxEvtHandler {
380 public:
381 wxMenuBar();
382
383 void Append(wxMenu *menu, const wxString& title);
384 void Check(int id, bool flag);
385 bool Checked(int id);
386 void Enable(int id, bool enable);
387 bool Enabled(int id);
388 int FindMenuItem(const wxString& menuString, const wxString& itemString);
389 wxMenuItem * FindItemForId(int id);
390 void SetLabel(int id, const wxString& label);
391 void EnableTop(int pos, bool enable);
392 wxString GetHelpString(int id);
393 wxString GetLabel(int id);
394 void SetHelpString(int id, const wxString& helpString);
395 wxString GetLabelTop(int pos);
396 void SetLabelTop(int pos, const wxString& label);
397 int GetMenuCount();
398 wxMenu* GetMenu(int i);
399 };
400
401
402 //----------------------------------------------------------------------
403
404 class wxMenuItem {
405 public:
406 #ifndef __WXGTK__
407 wxMenuItem(wxMenu* parentMenu=NULL, int id=ID_SEPARATOR,
408 const wxString& text = wxPyEmptyStr,
409 const wxString& helpString = wxPyEmptyStr,
410 bool checkable = FALSE, wxMenu* subMenu = NULL);
411 #else
412 wxMenuItem();
413 #endif
414
415 bool IsSeparator();
416 bool IsEnabled();
417 bool IsChecked();
418 bool IsCheckable();
419 int GetId();
420 wxMenu* GetSubMenu();
421 void SetName(const wxString& strName);
422 wxString GetName();
423 wxString GetHelp();
424 void SetHelp(const wxString& strHelp);
425 void Enable(bool bDoEnable = TRUE);
426 void Check(bool bDoCheck = TRUE);
427
428 #ifdef __WXMSW__
429 wxColour& GetBackgroundColour();
430 wxBitmap GetBitmap(bool checked = TRUE);
431 wxFont& GetFont();
432 int GetMarginWidth();
433 wxColour& GetTextColour();
434 void SetBackgroundColour(const wxColour& colour);
435 void SetBitmaps(const wxBitmap& checked, const wxBitmap& unchecked = wxNullBitmap);
436 void SetFont(const wxFont& font);
437 void SetMarginWidth(int width);
438 void SetTextColour(const wxColour& colour);
439 void DeleteSubMenu();
440 #endif
441 };
442
443 //---------------------------------------------------------------------------
444
445