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