]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/windows.i
Removed some unnecessary bitmaps; other minor changes
[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
19 #ifdef __WXMSW__
20 // wxGTK defines wxMenuItem inside menu.h
21 #include <wx/menuitem.h>
22 #endif
23
24 #ifdef __WXMSW__
25 #include <wx/minifram.h>
26 #endif
27 %}
28
29 //----------------------------------------------------------------------
30
31 %include typemaps.i
32 %include my_typemaps.i
33
34 // Import some definitions of other classes, etc.
35 %import _defs.i
36 %import misc.i
37 %import gdi.i
38
39 %pragma(python) code = "import wx"
40
41 //---------------------------------------------------------------------------
42
43 class wxEvtHandler {
44 public:
45 %addmethods {
46 void Connect( int id, int lastId, int eventType, PyObject* func) {
47 if (PyCallable_Check(func)) {
48 self->Connect(id, lastId, eventType,
49 (wxObjectEventFunction) &wxPyCallback::EventThunker,
50 new wxPyCallback(func));
51 }
52 }
53 }
54 };
55
56
57 //----------------------------------------------------------------------
58
59
60 class wxWindow : public wxEvtHandler {
61 public:
62
63 wxWindow(wxWindow* parent, const wxWindowID id,
64 const wxPoint& pos = wxPyDefaultPosition,
65 const wxSize& size = wxPyDefaultSize,
66 long style = 0,
67 char* name = "panel");
68
69 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
70
71 void CaptureMouse();
72 void Center(int direction = wxHORIZONTAL);
73 void Centre(int direction = wxHORIZONTAL);
74 void ClientToScreen(int *BOTH, int *BOTH);
75 bool Close(int force = FALSE);
76 bool Destroy();
77 void DestroyChildren();
78 #ifdef __WXMSW__
79 void DragAcceptFiles(bool accept);
80 #endif
81 void Enable(bool enable);
82 //bool FakePopupMenu(wxMenu* menu, int x, int y);
83 %name(FindWindowByID) wxWindow* FindWindow(long id);
84 %name(FindWindowByName) wxWindow* FindWindow(const wxString& name);
85 void Fit();
86 wxColour GetBackgroundColour();
87 int GetCharHeight();
88 int GetCharWidth();
89 %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT);
90 wxSize GetClientSize();
91 wxLayoutConstraints * GetConstraints();
92 #ifdef __WXMSW__
93 wxButton* GetDefaultItem();
94 #endif
95 //wxEvtHandler* GetEventHandler();
96 wxFont& GetFont();
97 wxColour GetForegroundColour();
98 wxWindow * GetGrandParent();
99 int GetId();
100 wxString GetLabel();
101 wxString GetName();
102 wxWindow * GetParent();
103 %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT);
104 wxPoint GetPosition();
105 wxRect GetRect();
106 int GetReturnCode();
107 int GetScrollThumb(int orientation);
108 int GetScrollPos(int orientation);
109 int GetScrollRange(int orientation);
110 %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT);
111 wxSize GetSize();
112 void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT); // int* descent = NULL, int* externalLeading = NULL, const wxFont* font = NULL, bool use16 = FALSE)
113 wxString GetTitle();
114 long GetWindowStyleFlag();
115 void InitDialog();
116 bool IsEnabled();
117 bool IsRetained();
118 bool IsShown();
119 void Layout();
120 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
121 void Lower();
122 void MakeModal(bool flag);
123 void Move(int x, int y);
124
125 //wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE);
126 bool PopupMenu(wxMenu *menu, int x, int y);
127 //void PushEventHandler(wxEvtHandler* handler);
128
129 void Raise();
130 void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL);
131 void ReleaseMouse();
132 void ScreenToClient(int *BOTH, int *BOTH);
133 void ScrollWindow(int dx, int dy, const wxRect* rect = NULL);
134 void SetAcceleratorTable(const wxAcceleratorTable& accel);
135 void SetAutoLayout(bool autoLayout);
136 void SetBackgroundColour(const wxColour& colour);
137 void SetConstraints(wxLayoutConstraints *constraints);
138 void SetDoubleClick(bool allowDoubleClick);
139 void SetFocus();
140 void SetFont(const wxFont& font);
141 void SetForegroundColour(const wxColour& colour);
142 void SetId(int id);
143 void SetName(const wxString& name);
144 void SetReturnCode(int retCode);
145 void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh = TRUE);
146 void SetScrollPos(int orientation, int pos, bool refresh = TRUE);
147
148 //void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
149 //%name(SetSizeOnly) void SetSize(int width, int height);
150
151 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
152 %addmethods {
153 void SetSize(const wxSize& size) {
154 self->SetSize(size.x, size.y);
155 }
156
157 void SetPosition(const wxPoint& pos) {
158 self->SetSize(pos.x, pos.y, -1, -1);
159 }
160 }
161
162 void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1);
163 void SetClientSize(int width, int height);
164 //void SetPalette(wxPalette* palette);
165 void SetCursor(const wxCursor&cursor);
166 //void SetEventHandler(wxEvtHandler* handler);
167 void SetTitle(const wxString& title);
168 bool Show(bool show);
169 bool TransferDataFromWindow();
170 bool TransferDataToWindow();
171 bool Validate();
172 #ifdef __WXMSW__
173 void WarpPointer(int x, int y);
174 #endif
175
176 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
177 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
178
179 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
180 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
181
182 };
183
184 %pragma(python) code = "
185 def wxDLG_PNT(win, point):
186 return win.ConvertDialogPointToPixels(point)
187
188 def wxDLG_SZE(win, size):
189 return win.ConvertDialogPointToPixels(size)
190 "
191
192 // Static method(s)
193 #ifdef __WXMSW__
194 %inline %{
195 wxWindow* wxWindow_FindFocus() {
196 return wxWindow::FindFocus();
197 }
198 %}
199 #endif
200
201
202 //---------------------------------------------------------------------------
203
204 class wxPanel : public wxWindow {
205 public:
206 wxPanel(wxWindow* parent,
207 const wxWindowID id,
208 const wxPoint& pos = wxPyDefaultPosition,
209 const wxSize& size = wxPyDefaultSize,
210 long style = wxTAB_TRAVERSAL,
211 const char* name = "panel");
212
213 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
214
215 void InitDialog();
216 };
217
218 //---------------------------------------------------------------------------
219
220 class wxDialog : public wxPanel {
221 public:
222 wxDialog(wxWindow* parent,
223 const wxWindowID id,
224 const wxString& title,
225 const wxPoint& pos = wxPyDefaultPosition,
226 const wxSize& size = wxPyDefaultSize,
227 long style = wxDEFAULT_DIALOG_STYLE,
228 const char* name = "dialogBox");
229
230 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
231
232 void Centre(int direction = wxBOTH);
233 void EndModal(int retCode);
234 wxString GetTitle();
235 void Iconize(bool iconize);
236 bool IsIconized();
237 void SetModal(bool flag);
238 bool IsModal();
239 void SetTitle(const wxString& title);
240 bool Show(bool show);
241 int ShowModal();
242 };
243
244 //---------------------------------------------------------------------------
245
246 class wxScrolledWindow : public wxWindow {
247 public:
248 wxScrolledWindow(wxWindow* parent,
249 const wxWindowID id = -1,
250 const wxPoint& pos = wxPyDefaultPosition,
251 const wxSize& size = wxPyDefaultSize,
252 long style = wxHSCROLL | wxVSCROLL,
253 char* name = "scrolledWindow");
254
255 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
256 %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)"
257
258 void EnableScrolling(bool xScrolling, bool yScrolling);
259 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
260 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
261 bool IsRetained();
262 void PrepareDC(wxDC& dc);
263 void Scroll(int x, int y);
264 void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
265 int noUnitsX, int noUnitsY,
266 int xPos = 0, int yPos = 0);
267 void ViewStart(int* OUTPUT, int* OUTPUT);
268 };
269
270 //----------------------------------------------------------------------
271
272
273 class wxMenu : public wxEvtHandler {
274 public:
275 wxMenu(const wxString& title = wxPyEmptyStr);
276
277 void Append(int id, const wxString& item,
278 const wxString& helpString = wxPyEmptyStr,
279 int checkable = FALSE);
280 %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu,
281 const wxString& helpString = wxPyEmptyStr);
282 void AppendSeparator();
283 void Break();
284 void Check(int id, bool flag);
285 void Enable(int id, bool enable);
286 int FindItem(const wxString& itemString);
287 #ifdef __WXMSW__
288 wxString GetTitle();
289 void SetTitle(const wxString& title);
290 #endif
291 wxMenuItem* FindItemForId(int id);
292 wxString GetHelpString(int id);
293 wxString GetLabel(int id);
294 void SetHelpString(int id, const wxString& helpString);
295 bool IsChecked(int id);
296 bool IsEnabled(int id);
297 void SetLabel(int id, const wxString& label);
298 };
299
300
301 //
302 // This one knows how to set a callback and handle INC- and DECREFing it. To
303 // be used for PopupMenus, but you must retain a referece to it while using
304 // it.
305 //
306 class wxPyMenu : public wxMenu {
307 public:
308 wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL);
309 ~wxPyMenu();
310 };
311
312 //----------------------------------------------------------------------
313
314 class wxMenuBar : public wxEvtHandler {
315 public:
316 wxMenuBar();
317
318 void Append(wxMenu *menu, const wxString& title);
319 void Check(int id, bool flag);
320 bool Checked(int id);
321 void Enable(int id, bool enable);
322 bool Enabled(int id);
323 int FindMenuItem(const wxString& menuString, const wxString& itemString);
324 #ifdef __WXGTK__
325 %name(FindItemForId) wxMenuItem* FindMenuItemById( int id );
326 #endif
327 #ifdef __WXMSW__
328 wxMenuItem * FindItemForId(int id);
329 void EnableTop(int pos, bool enable);
330 wxString GetHelpString(int id);
331 wxString GetLabel(int id);
332 void SetHelpString(int id, const wxString& helpString);
333 void SetLabel(int id, const wxString& label);
334 wxString GetLabelTop(int pos);
335 void SetLabelTop(int pos, const wxString& label);
336 #endif
337 int GetMenuCount();
338 wxMenu* GetMenu(int i);
339 };
340
341
342 //----------------------------------------------------------------------
343
344 class wxMenuItem {
345 public:
346 bool IsSeparator();
347 bool IsEnabled();
348 bool IsChecked();
349 bool IsCheckable();
350 int GetId();
351 wxMenu* GetSubMenu();
352 #ifdef __WXMSW__
353 void SetName(const wxString& strName);
354 void DeleteSubMenu();
355 const wxString& GetName();
356 #endif
357 const wxString& GetHelp();
358 void SetHelp(const wxString& strHelp);
359 void Enable(bool bDoEnable = TRUE);
360 void Check(bool bDoCheck = TRUE);
361 };
362
363 //---------------------------------------------------------------------------
364 /////////////////////////////////////////////////////////////////////////////
365 //
366 // $Log$
367 // Revision 1.7 1998/12/15 20:41:25 RD
368 // Changed the import semantics from "from wxPython import *" to "from
369 // wxPython.wx import *" This is for people who are worried about
370 // namespace pollution, they can use "from wxPython import wx" and then
371 // prefix all the wxPython identifiers with "wx."
372 //
373 // Added wxTaskbarIcon for wxMSW.
374 //
375 // Made the events work for wxGrid.
376 //
377 // Added wxConfig.
378 //
379 // Added wxMiniFrame for wxGTK, (untested.)
380 //
381 // Changed many of the args and return values that were pointers to gdi
382 // objects to references to reflect changes in the wxWindows API.
383 //
384 // Other assorted fixes and additions.
385 //
386 // Revision 1.6 1998/10/02 06:40:43 RD
387 //
388 // Version 0.4 of wxPython for MSW.
389 //
390 // Revision 1.5 1998/08/17 18:29:40 RD
391 // Removed an extra method definition
392 //
393 // Revision 1.4 1998/08/16 04:31:11 RD
394 // More wxGTK work.
395 //
396 // Revision 1.3 1998/08/15 07:36:47 RD
397 // - Moved the header in the .i files out of the code that gets put into
398 // the .cpp files. It caused CVS conflicts because of the RCS ID being
399 // different each time.
400 //
401 // - A few minor fixes.
402 //
403 // Revision 1.2 1998/08/14 23:36:46 RD
404 // Beginings of wxGTK compatibility
405 //
406 // Revision 1.1 1998/08/09 08:25:52 RD
407 // Initial version
408 //
409 //
410
411