]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/windows.i
Added wxPython support of new HTML Printing classes.
[wxWidgets.git] / utils / wxPython / src / windows.i
CommitLineData
7bf85405
RD
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
03e9bead
RD
14%module windows
15
16%{
7bf85405 17#include "helpers.h"
7bf85405
RD
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
efc5f224 31
2f90df85 32%pragma(python) code = "import wx"
7bf85405
RD
33
34//---------------------------------------------------------------------------
35
36class wxEvtHandler {
37public:
cf694132 38 bool ProcessEvent(wxEvent& event);
2f90df85
RD
39 //bool SearchEventTable(wxEventTable& table, wxEvent& event);
40
41 bool GetEvtHandlerEnabled();
42 void SetEvtHandlerEnabled(bool enabled);
43
44 wxEvtHandler* GetNextHandler();
45 wxEvtHandler* GetPreviousHandler();
46 void SetNextHandler(wxEvtHandler* handler);
47 void SetPreviousHandler(wxEvtHandler* handler);
48
49
7bf85405
RD
50 %addmethods {
51 void Connect( int id, int lastId, int eventType, PyObject* func) {
52 if (PyCallable_Check(func)) {
53 self->Connect(id, lastId, eventType,
853b255a 54 (wxObjectEventFunction) &wxPyCallback::EventThunker,
7bf85405
RD
55 new wxPyCallback(func));
56 }
57 }
58 }
59};
60
61
2f90df85
RD
62//----------------------------------------------------------------------
63
64class wxValidator : public wxEvtHandler {
65public:
66 wxValidator();
67 //~wxValidator();
68
69 wxValidator* Clone();
70 wxWindow* GetWindow();
71 void SetWindow(wxWindow* window);
72};
73
74%inline %{
75 bool wxValidator_IsSilent() {
76 return wxValidator::IsSilent();
77 }
78
79 void wxValidator_SetBellOnError(int doIt = TRUE) {
80 wxValidator::SetBellOnError(doIt);
81 }
82%}
83
84//----------------------------------------------------------------------
85%{
86class wxPyValidator : public wxValidator {
87 DECLARE_DYNAMIC_CLASS(wxPyValidator);
88public:
89 wxPyValidator() {
90 }
91// wxPyValidator(const wxPyValidator& other);
92
93 ~wxPyValidator() {
94 }
95
96 wxObject* wxPyValidator::Clone() const {
97 wxPyValidator* ptr = NULL;
98 wxPyValidator* self = (wxPyValidator*)this;
99
100 bool doSave = wxPyRestoreThread();
101 if (self->m_myInst.findCallback("Clone")) {
102 PyObject* ro;
103 ro = self->m_myInst.callCallbackObj(Py_BuildValue("()"));
104 SWIG_GetPtrObj(ro, (void **)&ptr, "_wxPyValidator_p");
105 }
106 // This is very dangerous!!! But is the only way I could find
107 // to squash a memory leak. Currently it is okay, but if the
108 // validator architecture in wxWindows ever changes, problems
109 // could arise.
110 delete self;
111
112 wxPySaveThread(doSave);
113 return ptr;
114}
115
116
117 DEC_PYCALLBACK_BOOL_WXWIN(Validate);
118 DEC_PYCALLBACK_BOOL_(TransferToWindow);
119 DEC_PYCALLBACK_BOOL_(TransferFromWindow);
120
121 PYPRIVATE;
122// PyObject* m_data;
123};
124
125IMP_PYCALLBACK_BOOL_WXWIN(wxPyValidator, wxValidator, Validate);
126IMP_PYCALLBACK_BOOL_(wxPyValidator, wxValidator, TransferToWindow);
127IMP_PYCALLBACK_BOOL_(wxPyValidator, wxValidator, TransferFromWindow);
128
129IMPLEMENT_DYNAMIC_CLASS(wxPyValidator, wxValidator);
130
131%}
132
133class wxPyValidator : public wxValidator {
134public:
135 wxPyValidator();
136// ~wxPyValidator();
137
138 %addmethods {
139 void Destroy() { delete self; }
140 }
141
142 void _setSelf(PyObject* self, int incref=TRUE);
143 %pragma(python) addtomethod = "__init__:self._setSelf(self, 0)"
144
145};
146
7bf85405
RD
147//----------------------------------------------------------------------
148
efc5f224 149%apply int * INOUT { int* x, int* y };
7bf85405
RD
150
151class wxWindow : public wxEvtHandler {
152public:
153
154 wxWindow(wxWindow* parent, const wxWindowID id,
155 const wxPoint& pos = wxPyDefaultPosition,
156 const wxSize& size = wxPyDefaultSize,
157 long style = 0,
158 char* name = "panel");
159
b8b8dda7 160 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
7bf85405
RD
161
162 void CaptureMouse();
8bf5d46e
RD
163 void Center(int direction = wxBOTH);
164 void Centre(int direction = wxBOTH);
165 void CentreOnParent(int direction = wxBOTH );
166 void CenterOnParent(int direction = wxBOTH );
efc5f224
RD
167
168 // (uses apply'ed INOUT typemap, see above)
169 %name(ClientToScreenXY)void ClientToScreen(int* x, int* y);
af309447 170 wxPoint ClientToScreen(const wxPoint& pt);
efc5f224 171
7bf85405
RD
172 bool Close(int force = FALSE);
173 bool Destroy();
174 void DestroyChildren();
853b255a 175#ifdef __WXMSW__
7bf85405 176 void DragAcceptFiles(bool accept);
853b255a 177#endif
7bf85405
RD
178 void Enable(bool enable);
179 //bool FakePopupMenu(wxMenu* menu, int x, int y);
af309447 180 %name(FindWindowById) wxWindow* FindWindow(long id);
714e6a9e 181 %name(FindWindowByName) wxWindow* FindWindow(const wxString& name);
7bf85405
RD
182 void Fit();
183 wxColour GetBackgroundColour();
d426c97e
RD
184
185 //wxList& GetChildren();
186 %addmethods {
187 PyObject* GetChildren() {
188 wxWindowList& list = self->GetChildren();
189 return wxPy_ConvertList(&list, "wxWindow");
190 }
191 }
192
7bf85405
RD
193 int GetCharHeight();
194 int GetCharWidth();
b8b8dda7
RD
195 %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT);
196 wxSize GetClientSize();
7bf85405 197 wxLayoutConstraints * GetConstraints();
3ab72185 198 wxEvtHandler* GetEventHandler();
105e45b9 199
b8b8dda7 200 wxFont& GetFont();
7bf85405
RD
201 wxColour GetForegroundColour();
202 wxWindow * GetGrandParent();
2abc0a0f
RD
203 %addmethods {
204 long GetHandle() {
205 return (long)self->GetHandle();
206 }
207 }
7bf85405 208 int GetId();
853b255a 209 wxString GetLabel();
bb0054cd 210 void SetLabel(const wxString& label);
853b255a 211 wxString GetName();
7bf85405 212 wxWindow * GetParent();
b8b8dda7
RD
213 %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT);
214 wxPoint GetPosition();
215 wxRect GetRect();
7bf85405
RD
216 int GetScrollThumb(int orientation);
217 int GetScrollPos(int orientation);
218 int GetScrollRange(int orientation);
b8b8dda7
RD
219 %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT);
220 wxSize GetSize();
af309447
RD
221 void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT);
222 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
223 int *OUTPUT, int *OUTPUT, int *OUTPUT, int* OUTPUT,
224 const wxFont* font = NULL); //, bool use16 = FALSE)
853b255a 225 wxString GetTitle();
8bf5d46e 226 wxRegion GetUpdateRegion();
7bf85405 227 long GetWindowStyleFlag();
bb0054cd 228 bool Hide();
7bf85405
RD
229 void InitDialog();
230 bool IsEnabled();
231 bool IsRetained();
232 bool IsShown();
bb0054cd 233 bool IsTopLevel();
7bf85405
RD
234 void Layout();
235 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
236 void Lower();
237 void MakeModal(bool flag);
af309447
RD
238 %name(MoveXY)void Move(int x, int y);
239 void Move(const wxPoint& point);
7bf85405 240
3ab72185
RD
241 wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE);
242 void PushEventHandler(wxEvtHandler* handler);
7bf85405 243
8bf5d46e
RD
244 %name(PopupMenuXY)bool PopupMenu(wxMenu *menu, int x, int y);
245 bool PopupMenu(wxMenu *menu, const wxPoint& pos);
246
7bf85405
RD
247 void Raise();
248 void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL);
249 void ReleaseMouse();
bb0054cd
RD
250 bool Reparent( wxWindow* newParent );
251
efc5f224
RD
252 // (uses apply'ed INOUT typemap, see above)
253 %name(ScreenToClientXY)void ScreenToClient(int *x, int *y);
af309447
RD
254 wxPoint ScreenToClient(const wxPoint& pt);
255
7bf85405 256 void ScrollWindow(int dx, int dy, const wxRect* rect = NULL);
b8b8dda7 257 void SetAcceleratorTable(const wxAcceleratorTable& accel);
7bf85405 258 void SetAutoLayout(bool autoLayout);
1dec68aa 259 bool GetAutoLayout();
7bf85405
RD
260 void SetBackgroundColour(const wxColour& colour);
261 void SetConstraints(wxLayoutConstraints *constraints);
2f90df85 262 void UnsetConstraints(wxLayoutConstraints *constraints);
7bf85405 263 void SetFocus();
2f90df85 264 bool AcceptsFocus();
7bf85405
RD
265 void SetFont(const wxFont& font);
266 void SetForegroundColour(const wxColour& colour);
267 void SetId(int id);
268 void SetName(const wxString& name);
7bf85405
RD
269 void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh = TRUE);
270 void SetScrollPos(int orientation, int pos, bool refresh = TRUE);
271
7bf85405
RD
272 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
273 %addmethods {
274 void SetSize(const wxSize& size) {
275 self->SetSize(size.x, size.y);
276 }
277
278 void SetPosition(const wxPoint& pos) {
279 self->SetSize(pos.x, pos.y, -1, -1);
280 }
281 }
282
283 void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1);
af309447
RD
284 %name(SetClientSizeWH)void SetClientSize(int width, int height);
285 void SetClientSize(const wxSize& size);
7bf85405 286 //void SetPalette(wxPalette* palette);
7bf85405 287 void SetCursor(const wxCursor&cursor);
3ab72185 288 void SetEventHandler(wxEvtHandler* handler);
7bf85405
RD
289 void SetTitle(const wxString& title);
290 bool Show(bool show);
291 bool TransferDataFromWindow();
292 bool TransferDataToWindow();
293 bool Validate();
294 void WarpPointer(int x, int y);
295
b8b8dda7
RD
296 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
297 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
298
cf694132
RD
299 %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt);
300 %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz);
301
b8b8dda7
RD
302 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
303 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
304
af309447
RD
305 %name(SetToolTipString)void SetToolTip(const wxString &tip);
306 void SetToolTip(wxToolTip *tooltip);
307 wxToolTip* GetToolTip();
2f90df85
RD
308
309 void SetSizer(wxSizer* sizer);
310 wxValidator* GetValidator();
311 void SetValidator(const wxValidator& validator);
312
7bf85405
RD
313};
314
efc5f224
RD
315//%clear int* x, int* y;
316
317
318
b8b8dda7 319%pragma(python) code = "
bb0054cd
RD
320def wxDLG_PNT(win, point_or_x, y=None):
321 if y is None:
322 return win.ConvertDialogPointToPixels(point_or_x)
323 else:
324 return win.ConvertDialogPointToPixels(wxPoint(point_or_x, y))
325
326def wxDLG_SZE(win, size_width, height=None):
327 if height is None:
328 return win.ConvertDialogSizeToPixels(size_width)
329 else:
330 return win.ConvertDialogSizeToPixels(wxSize(size_width, height))
b8b8dda7 331"
7bf85405 332
853b255a 333#ifdef __WXMSW__
7bf85405
RD
334%inline %{
335 wxWindow* wxWindow_FindFocus() {
336 return wxWindow::FindFocus();
337 }
338%}
af309447
RD
339
340
341%inline %{
342wxWindow* wxWindow_FromHWND(unsigned long hWnd) {
343 wxWindow* win = new wxWindow;
344 win->SetHWND(hWnd);
345 win->SubclassWin(hWnd);
346 return win;
347}
348%}
853b255a 349#endif
7bf85405 350
7bf85405 351
efc5f224 352
7bf85405
RD
353//---------------------------------------------------------------------------
354
355class wxPanel : public wxWindow {
356public:
357 wxPanel(wxWindow* parent,
358 const wxWindowID id,
359 const wxPoint& pos = wxPyDefaultPosition,
360 const wxSize& size = wxPyDefaultSize,
361 long style = wxTAB_TRAVERSAL,
362 const char* name = "panel");
363
b8b8dda7 364 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
9c039d08 365
7bf85405 366 void InitDialog();
bb0054cd
RD
367 wxButton* GetDefaultItem();
368 void SetDefaultItem(wxButton *btn);
369
3ab72185 370 // fix some SWIG trouble...
bb0054cd
RD
371 %pragma(python) addtoclass = "
372 def GetDefaultItem(self):
373 import controls
374 val = windowsc.wxPanel_GetDefaultItem(self.this)
375 val = controls.wxButtonPtr(val)
376 return val
377"
7bf85405
RD
378};
379
380//---------------------------------------------------------------------------
381
382class wxDialog : public wxPanel {
383public:
384 wxDialog(wxWindow* parent,
385 const wxWindowID id,
386 const wxString& title,
387 const wxPoint& pos = wxPyDefaultPosition,
388 const wxSize& size = wxPyDefaultSize,
389 long style = wxDEFAULT_DIALOG_STYLE,
390 const char* name = "dialogBox");
391
b8b8dda7 392 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
9c039d08 393
7bf85405
RD
394 void Centre(int direction = wxBOTH);
395 void EndModal(int retCode);
396 wxString GetTitle();
397 void Iconize(bool iconize);
398 bool IsIconized();
7bf85405 399 void SetModal(bool flag);
853b255a 400 bool IsModal();
7bf85405
RD
401 void SetTitle(const wxString& title);
402 bool Show(bool show);
403 int ShowModal();
4cd9591a
RD
404
405 int GetReturnCode();
406 void SetReturnCode(int retCode);
7bf85405
RD
407};
408
409//---------------------------------------------------------------------------
410
bb0054cd 411class wxScrolledWindow : public wxPanel {
7bf85405
RD
412public:
413 wxScrolledWindow(wxWindow* parent,
414 const wxWindowID id = -1,
415 const wxPoint& pos = wxPyDefaultPosition,
416 const wxSize& size = wxPyDefaultSize,
417 long style = wxHSCROLL | wxVSCROLL,
418 char* name = "scrolledWindow");
419
b8b8dda7
RD
420 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
421 %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)"
9c039d08 422
7bf85405
RD
423 void EnableScrolling(bool xScrolling, bool yScrolling);
424 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
425 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
426 bool IsRetained();
427 void PrepareDC(wxDC& dc);
428 void Scroll(int x, int y);
429 void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
430 int noUnitsX, int noUnitsY,
431 int xPos = 0, int yPos = 0);
432 void ViewStart(int* OUTPUT, int* OUTPUT);
9d8bd15f
RD
433
434 void CalcScrolledPosition( int x, int y, int *OUTPUT, int *OUTPUT);
435 void CalcUnscrolledPosition( int x, int y, int *OUTPUT, int *OUTPUT);
436
7bf85405
RD
437};
438
439//----------------------------------------------------------------------
440
441
442class wxMenu : public wxEvtHandler {
443public:
8bf5d46e 444 wxMenu(const wxString& title = wxPyEmptyStr, long style = 0);
7bf85405
RD
445
446 void Append(int id, const wxString& item,
447 const wxString& helpString = wxPyEmptyStr,
448 int checkable = FALSE);
449 %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu,
450 const wxString& helpString = wxPyEmptyStr);
af309447
RD
451 %name(AppendItem)void Append(const wxMenuItem* item);
452
7bf85405
RD
453 void AppendSeparator();
454 void Break();
455 void Check(int id, bool flag);
7bf85405
RD
456 void Enable(int id, bool enable);
457 int FindItem(const wxString& itemString);
7bf85405 458 wxString GetTitle();
7bf85405 459 void SetTitle(const wxString& title);
714e6a9e
RD
460 wxMenuItem* FindItemForId(int id);
461 wxString GetHelpString(int id);
462 wxString GetLabel(int id);
463 void SetHelpString(int id, const wxString& helpString);
853b255a
RD
464 bool IsChecked(int id);
465 bool IsEnabled(int id);
466 void SetLabel(int id, const wxString& label);
8bf5d46e 467 void UpdateUI(wxEvtHandler* source = NULL);
efc5f224
RD
468
469 %addmethods {
470 void Destroy() {
471 delete self;
472 }
473 }
474
7bf85405
RD
475};
476
477
7bf85405
RD
478//
479// This one knows how to set a callback and handle INC- and DECREFing it. To
480// be used for PopupMenus, but you must retain a referece to it while using
481// it.
482//
8bf5d46e
RD
483// class wxPyMenu : public wxMenu {
484// public:
485// wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL);
486// ~wxPyMenu();
487// };
7bf85405
RD
488
489//----------------------------------------------------------------------
490
491class wxMenuBar : public wxEvtHandler {
492public:
493 wxMenuBar();
494
495 void Append(wxMenu *menu, const wxString& title);
496 void Check(int id, bool flag);
2abc0a0f 497// bool Checked(int id);
7bf85405 498 void Enable(int id, bool enable);
2abc0a0f
RD
499// bool Enabled(int id);
500 bool IsChecked(int id);
501 bool IsEnabled(int id);
7bf85405 502 int FindMenuItem(const wxString& menuString, const wxString& itemString);
c95e68d8 503 wxMenuItem * FindItemForId(int id);
10534c0b 504 void SetLabel(int id, const wxString& label);
714e6a9e 505 void EnableTop(int pos, bool enable);
7bf85405
RD
506 wxString GetHelpString(int id);
507 wxString GetLabel(int id);
7bf85405 508 void SetHelpString(int id, const wxString& helpString);
853b255a 509 wxString GetLabelTop(int pos);
7bf85405 510 void SetLabelTop(int pos, const wxString& label);
714e6a9e
RD
511 int GetMenuCount();
512 wxMenu* GetMenu(int i);
06c0fba4 513 void Refresh();
2abc0a0f
RD
514 wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
515 wxMenu *Remove(size_t pos);
516
7bf85405
RD
517};
518
519
520//----------------------------------------------------------------------
521
522class wxMenuItem {
523public:
2abc0a0f 524//#ifndef __WXGTK__
cf694132
RD
525 wxMenuItem(wxMenu* parentMenu=NULL, int id=ID_SEPARATOR,
526 const wxString& text = wxPyEmptyStr,
527 const wxString& helpString = wxPyEmptyStr,
528 bool checkable = FALSE, wxMenu* subMenu = NULL);
2abc0a0f
RD
529//#else
530// wxMenuItem();
531//#endif
cf694132 532
7bf85405
RD
533 bool IsSeparator();
534 bool IsEnabled();
535 bool IsChecked();
714e6a9e 536 bool IsCheckable();
2abc0a0f 537 bool IsSubMenu();
7bf85405 538 int GetId();
2abc0a0f 539 void SetId(int id);
7bf85405 540 wxMenu* GetSubMenu();
cf694132 541 wxString GetHelp();
714e6a9e
RD
542 void SetHelp(const wxString& strHelp);
543 void Enable(bool bDoEnable = TRUE);
544 void Check(bool bDoCheck = TRUE);
c95e68d8 545
2abc0a0f 546//#ifdef __WXMSW__
cf694132
RD
547 wxColour& GetBackgroundColour();
548 wxBitmap GetBitmap(bool checked = TRUE);
549 wxFont& GetFont();
550 int GetMarginWidth();
551 wxColour& GetTextColour();
552 void SetBackgroundColour(const wxColour& colour);
553 void SetBitmaps(const wxBitmap& checked, const wxBitmap& unchecked = wxNullBitmap);
554 void SetFont(const wxFont& font);
555 void SetMarginWidth(int width);
2abc0a0f
RD
556 void SetText(const wxString& str);
557 const wxString& GetText();
cf694132 558 void SetTextColour(const wxColour& colour);
4f22cf8d 559 void DeleteSubMenu();
2abc0a0f
RD
560 void SetCheckable(bool checkable);
561 void SetSubMenu(wxMenu *menu);
562//#endif
7bf85405
RD
563};
564
565//---------------------------------------------------------------------------
7bf85405
RD
566
567