]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/windows.i
1. wxStaticLine implemented (generic (ugly) and MSW versions)
[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
b8b8dda7 31%pragma(python) code = "import wx"
bb0054cd
RD
32//%pragma(python) code = "import controls"
33//%pragma(python) code = "wxButtonPtr = controls.wxWindowPtr"
7bf85405
RD
34
35//---------------------------------------------------------------------------
36
37class wxEvtHandler {
38public:
cf694132 39 bool ProcessEvent(wxEvent& event);
7bf85405
RD
40 %addmethods {
41 void Connect( int id, int lastId, int eventType, PyObject* func) {
42 if (PyCallable_Check(func)) {
43 self->Connect(id, lastId, eventType,
853b255a 44 (wxObjectEventFunction) &wxPyCallback::EventThunker,
7bf85405
RD
45 new wxPyCallback(func));
46 }
47 }
48 }
49};
50
51
52//----------------------------------------------------------------------
53
54
55class wxWindow : public wxEvtHandler {
56public:
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
b8b8dda7 64 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
7bf85405
RD
65
66 void CaptureMouse();
714e6a9e 67 void Center(int direction = wxHORIZONTAL);
7bf85405 68 void Centre(int direction = wxHORIZONTAL);
bb0054cd
RD
69 void CentreOnParent(int direction = wxHORIZONTAL );
70 void CenterOnParent(int direction = wxHORIZONTAL );
af309447
RD
71 %name(ClientToScreenXY)void ClientToScreen(int *BOTH, int *BOTH);
72 wxPoint ClientToScreen(const wxPoint& pt);
7bf85405
RD
73 bool Close(int force = FALSE);
74 bool Destroy();
75 void DestroyChildren();
853b255a 76#ifdef __WXMSW__
7bf85405 77 void DragAcceptFiles(bool accept);
853b255a 78#endif
7bf85405
RD
79 void Enable(bool enable);
80 //bool FakePopupMenu(wxMenu* menu, int x, int y);
af309447 81 %name(FindWindowById) wxWindow* FindWindow(long id);
714e6a9e 82 %name(FindWindowByName) wxWindow* FindWindow(const wxString& name);
7bf85405
RD
83 void Fit();
84 wxColour GetBackgroundColour();
85 int GetCharHeight();
86 int GetCharWidth();
b8b8dda7
RD
87 %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT);
88 wxSize GetClientSize();
7bf85405 89 wxLayoutConstraints * GetConstraints();
7bf85405 90 //wxEvtHandler* GetEventHandler();
105e45b9 91
b8b8dda7 92 wxFont& GetFont();
7bf85405
RD
93 wxColour GetForegroundColour();
94 wxWindow * GetGrandParent();
95 int GetId();
853b255a 96 wxString GetLabel();
bb0054cd 97 void SetLabel(const wxString& label);
853b255a 98 wxString GetName();
7bf85405 99 wxWindow * GetParent();
b8b8dda7
RD
100 %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT);
101 wxPoint GetPosition();
102 wxRect GetRect();
7bf85405
RD
103 int GetScrollThumb(int orientation);
104 int GetScrollPos(int orientation);
105 int GetScrollRange(int orientation);
b8b8dda7
RD
106 %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT);
107 wxSize GetSize();
af309447
RD
108 void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT);
109 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
110 int *OUTPUT, int *OUTPUT, int *OUTPUT, int* OUTPUT,
111 const wxFont* font = NULL); //, bool use16 = FALSE)
853b255a 112 wxString GetTitle();
7bf85405 113 long GetWindowStyleFlag();
bb0054cd 114 bool Hide();
7bf85405
RD
115 void InitDialog();
116 bool IsEnabled();
117 bool IsRetained();
118 bool IsShown();
bb0054cd 119 bool IsTopLevel();
7bf85405
RD
120 void Layout();
121 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
122 void Lower();
123 void MakeModal(bool flag);
af309447
RD
124 %name(MoveXY)void Move(int x, int y);
125 void Move(const wxPoint& point);
7bf85405
RD
126
127 //wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE);
128 bool PopupMenu(wxMenu *menu, int x, int y);
129 //void PushEventHandler(wxEvtHandler* handler);
130
131 void Raise();
132 void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL);
133 void ReleaseMouse();
bb0054cd
RD
134 bool Reparent( wxWindow* newParent );
135
af309447
RD
136 %name(ScreenToClientXY)void ScreenToClient(int *BOTH, int *BOTH);
137 wxPoint ScreenToClient(const wxPoint& pt);
138
7bf85405 139 void ScrollWindow(int dx, int dy, const wxRect* rect = NULL);
b8b8dda7 140 void SetAcceleratorTable(const wxAcceleratorTable& accel);
7bf85405
RD
141 void SetAutoLayout(bool autoLayout);
142 void SetBackgroundColour(const wxColour& colour);
143 void SetConstraints(wxLayoutConstraints *constraints);
4cd9591a 144// void SetDoubleClick(bool allowDoubleClick);
7bf85405
RD
145 void SetFocus();
146 void SetFont(const wxFont& font);
147 void SetForegroundColour(const wxColour& colour);
148 void SetId(int id);
149 void SetName(const wxString& name);
7bf85405
RD
150 void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh = TRUE);
151 void SetScrollPos(int orientation, int pos, bool refresh = TRUE);
152
7bf85405
RD
153 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
154 %addmethods {
155 void SetSize(const wxSize& size) {
156 self->SetSize(size.x, size.y);
157 }
158
159 void SetPosition(const wxPoint& pos) {
160 self->SetSize(pos.x, pos.y, -1, -1);
161 }
162 }
163
164 void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1);
af309447
RD
165 %name(SetClientSizeWH)void SetClientSize(int width, int height);
166 void SetClientSize(const wxSize& size);
7bf85405 167 //void SetPalette(wxPalette* palette);
7bf85405
RD
168 void SetCursor(const wxCursor&cursor);
169 //void SetEventHandler(wxEvtHandler* handler);
170 void SetTitle(const wxString& title);
171 bool Show(bool show);
172 bool TransferDataFromWindow();
173 bool TransferDataToWindow();
174 bool Validate();
175 void WarpPointer(int x, int y);
176
b8b8dda7
RD
177 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
178 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
179
cf694132
RD
180 %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt);
181 %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz);
182
b8b8dda7
RD
183 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
184 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
185
af309447
RD
186 %name(SetToolTipString)void SetToolTip(const wxString &tip);
187 void SetToolTip(wxToolTip *tooltip);
188 wxToolTip* GetToolTip();
7bf85405
RD
189};
190
b8b8dda7 191%pragma(python) code = "
bb0054cd
RD
192def wxDLG_PNT(win, point_or_x, y=None):
193 if y is None:
194 return win.ConvertDialogPointToPixels(point_or_x)
195 else:
196 return win.ConvertDialogPointToPixels(wxPoint(point_or_x, y))
197
198def wxDLG_SZE(win, size_width, height=None):
199 if height is None:
200 return win.ConvertDialogSizeToPixels(size_width)
201 else:
202 return win.ConvertDialogSizeToPixels(wxSize(size_width, height))
b8b8dda7 203"
7bf85405 204
853b255a 205#ifdef __WXMSW__
7bf85405
RD
206%inline %{
207 wxWindow* wxWindow_FindFocus() {
208 return wxWindow::FindFocus();
209 }
210%}
af309447
RD
211
212
213%inline %{
214wxWindow* wxWindow_FromHWND(unsigned long hWnd) {
215 wxWindow* win = new wxWindow;
216 win->SetHWND(hWnd);
217 win->SubclassWin(hWnd);
218 return win;
219}
220%}
853b255a 221#endif
7bf85405 222
7bf85405
RD
223
224//---------------------------------------------------------------------------
225
226class wxPanel : public wxWindow {
227public:
228 wxPanel(wxWindow* parent,
229 const wxWindowID id,
230 const wxPoint& pos = wxPyDefaultPosition,
231 const wxSize& size = wxPyDefaultSize,
232 long style = wxTAB_TRAVERSAL,
233 const char* name = "panel");
234
b8b8dda7 235 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
9c039d08 236
7bf85405 237 void InitDialog();
bb0054cd
RD
238 wxButton* GetDefaultItem();
239 void SetDefaultItem(wxButton *btn);
240
241 // fix a SWIG turd...
242 %pragma(python) addtoclass = "
243 def GetDefaultItem(self):
244 import controls
245 val = windowsc.wxPanel_GetDefaultItem(self.this)
246 val = controls.wxButtonPtr(val)
247 return val
248"
7bf85405
RD
249};
250
251//---------------------------------------------------------------------------
252
253class wxDialog : public wxPanel {
254public:
255 wxDialog(wxWindow* parent,
256 const wxWindowID id,
257 const wxString& title,
258 const wxPoint& pos = wxPyDefaultPosition,
259 const wxSize& size = wxPyDefaultSize,
260 long style = wxDEFAULT_DIALOG_STYLE,
261 const char* name = "dialogBox");
262
b8b8dda7 263 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
9c039d08 264
7bf85405
RD
265 void Centre(int direction = wxBOTH);
266 void EndModal(int retCode);
267 wxString GetTitle();
268 void Iconize(bool iconize);
269 bool IsIconized();
7bf85405 270 void SetModal(bool flag);
853b255a 271 bool IsModal();
7bf85405
RD
272 void SetTitle(const wxString& title);
273 bool Show(bool show);
274 int ShowModal();
4cd9591a
RD
275
276 int GetReturnCode();
277 void SetReturnCode(int retCode);
7bf85405
RD
278};
279
280//---------------------------------------------------------------------------
281
bb0054cd 282class wxScrolledWindow : public wxPanel {
7bf85405
RD
283public:
284 wxScrolledWindow(wxWindow* parent,
285 const wxWindowID id = -1,
286 const wxPoint& pos = wxPyDefaultPosition,
287 const wxSize& size = wxPyDefaultSize,
288 long style = wxHSCROLL | wxVSCROLL,
289 char* name = "scrolledWindow");
290
b8b8dda7
RD
291 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
292 %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)"
9c039d08 293
7bf85405
RD
294 void EnableScrolling(bool xScrolling, bool yScrolling);
295 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
296 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
297 bool IsRetained();
298 void PrepareDC(wxDC& dc);
299 void Scroll(int x, int y);
300 void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
301 int noUnitsX, int noUnitsY,
302 int xPos = 0, int yPos = 0);
303 void ViewStart(int* OUTPUT, int* OUTPUT);
304};
305
306//----------------------------------------------------------------------
307
308
309class wxMenu : public wxEvtHandler {
310public:
311 wxMenu(const wxString& title = wxPyEmptyStr);
312
313 void Append(int id, const wxString& item,
314 const wxString& helpString = wxPyEmptyStr,
315 int checkable = FALSE);
316 %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu,
317 const wxString& helpString = wxPyEmptyStr);
b57bdb5a 318#ifndef __WXGTK__
af309447 319 %name(AppendItem)void Append(const wxMenuItem* item);
b57bdb5a 320#endif
af309447 321
7bf85405
RD
322 void AppendSeparator();
323 void Break();
324 void Check(int id, bool flag);
7bf85405
RD
325 void Enable(int id, bool enable);
326 int FindItem(const wxString& itemString);
7bf85405 327 wxString GetTitle();
7bf85405 328 void SetTitle(const wxString& title);
714e6a9e
RD
329 wxMenuItem* FindItemForId(int id);
330 wxString GetHelpString(int id);
331 wxString GetLabel(int id);
332 void SetHelpString(int id, const wxString& helpString);
853b255a
RD
333 bool IsChecked(int id);
334 bool IsEnabled(int id);
335 void SetLabel(int id, const wxString& label);
7bf85405
RD
336};
337
338
7bf85405
RD
339//
340// This one knows how to set a callback and handle INC- and DECREFing it. To
341// be used for PopupMenus, but you must retain a referece to it while using
342// it.
343//
344class wxPyMenu : public wxMenu {
345public:
346 wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL);
347 ~wxPyMenu();
348};
349
350//----------------------------------------------------------------------
351
352class wxMenuBar : public wxEvtHandler {
353public:
354 wxMenuBar();
355
356 void Append(wxMenu *menu, const wxString& title);
357 void Check(int id, bool flag);
358 bool Checked(int id);
359 void Enable(int id, bool enable);
714e6a9e 360 bool Enabled(int id);
7bf85405 361 int FindMenuItem(const wxString& menuString, const wxString& itemString);
c95e68d8 362 wxMenuItem * FindItemForId(int id);
aeeb6a44 363#ifdef __WXMSW__
714e6a9e 364 void EnableTop(int pos, bool enable);
7bf85405
RD
365 wxString GetHelpString(int id);
366 wxString GetLabel(int id);
7bf85405
RD
367 void SetHelpString(int id, const wxString& helpString);
368 void SetLabel(int id, const wxString& label);
853b255a 369 wxString GetLabelTop(int pos);
7bf85405 370 void SetLabelTop(int pos, const wxString& label);
853b255a 371#endif
714e6a9e
RD
372 int GetMenuCount();
373 wxMenu* GetMenu(int i);
7bf85405
RD
374};
375
376
377//----------------------------------------------------------------------
378
379class wxMenuItem {
380public:
cf694132
RD
381#ifndef __WXGTK__
382 wxMenuItem(wxMenu* parentMenu=NULL, int id=ID_SEPARATOR,
383 const wxString& text = wxPyEmptyStr,
384 const wxString& helpString = wxPyEmptyStr,
385 bool checkable = FALSE, wxMenu* subMenu = NULL);
386#else
387 wxMenuItem();
388#endif
389
7bf85405
RD
390 bool IsSeparator();
391 bool IsEnabled();
392 bool IsChecked();
714e6a9e 393 bool IsCheckable();
7bf85405 394 int GetId();
7bf85405
RD
395 wxMenu* GetSubMenu();
396 void SetName(const wxString& strName);
cf694132
RD
397 wxString GetName();
398 wxString GetHelp();
714e6a9e
RD
399 void SetHelp(const wxString& strHelp);
400 void Enable(bool bDoEnable = TRUE);
401 void Check(bool bDoCheck = TRUE);
c95e68d8 402
4f22cf8d 403#ifdef __WXMSW__
cf694132
RD
404 wxColour& GetBackgroundColour();
405 wxBitmap GetBitmap(bool checked = TRUE);
406 wxFont& GetFont();
407 int GetMarginWidth();
408 wxColour& GetTextColour();
409 void SetBackgroundColour(const wxColour& colour);
410 void SetBitmaps(const wxBitmap& checked, const wxBitmap& unchecked = wxNullBitmap);
411 void SetFont(const wxFont& font);
412 void SetMarginWidth(int width);
413 void SetTextColour(const wxColour& colour);
4f22cf8d
RR
414 void DeleteSubMenu();
415#endif
7bf85405
RD
416};
417
418//---------------------------------------------------------------------------
419/////////////////////////////////////////////////////////////////////////////
420//
421// $Log$
bb0054cd
RD
422// Revision 1.17 1999/06/22 07:03:03 RD
423// wxPython 2.1b1 for wxMSW (wxGTK coming soon)
424// Lots of changes, see the README.txt for details...
425//
4cd9591a 426// Revision 1.16 1999/05/15 00:56:04 RD
bb0054cd 427//
4cd9591a
RD
428// fixes for GetReturnCode/SetReturnCode
429//
cf694132 430// Revision 1.15 1999/04/30 03:29:19 RD
4cd9591a 431//
cf694132
RD
432// wxPython 2.0b9, first phase (win32)
433// Added gobs of stuff, see wxPython/README.txt for details
434//
435// Revision 1.14.4.3 1999/03/27 23:29:15 RD
436//
437// wxPython 2.0b8
438// Python thread support
439// various minor additions
440// various minor fixes
441//
442// Revision 1.14.4.2 1999/03/16 06:26:29 RD
443//
444// wxPython 2.0b7
445//
446// Revision 1.14.4.1 1999/03/16 06:04:04 RD
447//
448// wxPython 2.0b7
449//
afc48cd0 450// Revision 1.14 1999/02/23 23:48:33 RD
cf694132 451//
afc48cd0
RD
452// reenabled some methods for wxPython on wxGTK
453//
b57bdb5a 454// Revision 1.13 1999/02/20 10:02:38 RD
afc48cd0 455//
b57bdb5a
RD
456// Changes needed to enable wxGTK compatibility.
457//
af309447
RD
458// Revision 1.12 1999/02/20 09:03:03 RD
459// Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
460// window handle. If you can get the window handle into the python code,
461// it should just work... More news on this later.
462//
463// Added wxImageList, wxToolTip.
464//
465// Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the
466// wxRegConfig class.
467//
468// As usual, some bug fixes, tweaks, etc.
469//
aeeb6a44 470// Revision 1.11 1998/12/18 15:49:10 RR
af309447 471//
aeeb6a44
RR
472// wxClipboard now serves the primary selection as well
473// wxPython fixes
474// warning mesages
475//
c95e68d8 476// Revision 1.10 1998/12/17 17:52:20 RD
aeeb6a44 477//
c95e68d8
RD
478// wxPython 0.5.2
479// Minor fixes and SWIG code generation for RR's changes. MSW and GTK
480// versions are much closer now!
481//
4f22cf8d 482// Revision 1.9 1998/12/17 14:07:46 RR
c95e68d8 483//
4f22cf8d
RR
484// Removed minor differences between wxMSW and wxGTK
485//
105e45b9 486// Revision 1.8 1998/12/16 22:10:56 RD
4f22cf8d 487//
105e45b9
RD
488// Tweaks needed to be able to build wxPython with wxGTK.
489//
b8b8dda7
RD
490// Revision 1.7 1998/12/15 20:41:25 RD
491// Changed the import semantics from "from wxPython import *" to "from
492// wxPython.wx import *" This is for people who are worried about
493// namespace pollution, they can use "from wxPython import wx" and then
494// prefix all the wxPython identifiers with "wx."
495//
496// Added wxTaskbarIcon for wxMSW.
497//
498// Made the events work for wxGrid.
499//
500// Added wxConfig.
501//
502// Added wxMiniFrame for wxGTK, (untested.)
503//
504// Changed many of the args and return values that were pointers to gdi
505// objects to references to reflect changes in the wxWindows API.
506//
507// Other assorted fixes and additions.
508//
9c039d08 509// Revision 1.6 1998/10/02 06:40:43 RD
b8b8dda7 510//
9c039d08
RD
511// Version 0.4 of wxPython for MSW.
512//
652e7bb4
RD
513// Revision 1.5 1998/08/17 18:29:40 RD
514// Removed an extra method definition
515//
714e6a9e
RD
516// Revision 1.4 1998/08/16 04:31:11 RD
517// More wxGTK work.
518//
03e9bead
RD
519// Revision 1.3 1998/08/15 07:36:47 RD
520// - Moved the header in the .i files out of the code that gets put into
521// the .cpp files. It caused CVS conflicts because of the RCS ID being
522// different each time.
523//
524// - A few minor fixes.
525//
853b255a
RD
526// Revision 1.2 1998/08/14 23:36:46 RD
527// Beginings of wxGTK compatibility
528//
7bf85405
RD
529// Revision 1.1 1998/08/09 08:25:52 RD
530// Initial version
531//
532//
533
534