]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/windows.i
08e6ab1bb14ed1e3044eb137ece18d75512f09c0
[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
40 //---------------------------------------------------------------------------
41
42 class wxEvtHandler {
43 public:
44 %addmethods {
45 void Connect( int id, int lastId, int eventType, PyObject* func) {
46 if (PyCallable_Check(func)) {
47 self->Connect(id, lastId, eventType,
48 (wxObjectEventFunction) &wxPyCallback::EventThunker,
49 new wxPyCallback(func));
50 }
51 }
52 }
53 };
54
55
56 //----------------------------------------------------------------------
57
58
59 class wxWindow : public wxEvtHandler {
60 public:
61
62 wxWindow(wxWindow* parent, const wxWindowID id,
63 const wxPoint& pos = wxPyDefaultPosition,
64 const wxSize& size = wxPyDefaultSize,
65 long style = 0,
66 char* name = "panel");
67
68
69 void CaptureMouse();
70 //void Center(int direction = wxHORIZONTAL);
71 void Centre(int direction = wxHORIZONTAL);
72 void ClientToScreen(int *BOTH, int *BOTH);
73 bool Close(int force = FALSE);
74 bool Destroy();
75 void DestroyChildren();
76 #ifdef __WXMSW__
77 void DragAcceptFiles(bool accept);
78 #endif
79 void Enable(bool enable);
80 //bool FakePopupMenu(wxMenu* menu, int x, int y);
81 void Fit();
82 wxColour GetBackgroundColour();
83 #ifdef __WXMSW__
84 int GetCharHeight();
85 int GetCharWidth();
86 #endif
87 void GetClientSize(int *OUTPUT, int *OUTPUT);
88 wxLayoutConstraints * GetConstraints();
89 #ifdef __WXMSW__
90 wxButton* GetDefaultItem();
91 #endif
92 //wxEvtHandler* GetEventHandler();
93 wxFont* GetFont();
94 #ifdef __WXMSW__
95 wxColour GetForegroundColour();
96 wxWindow * GetGrandParent();
97 #endif
98 int GetId();
99 void GetPosition(int *OUTPUT, int *OUTPUT);
100 #ifdef __WXMSW__
101 wxString& GetLabel();
102 wxString& GetName();
103 #else
104 wxString GetLabel();
105 wxString GetName();
106 #endif
107 wxWindow * GetParent();
108 int GetReturnCode();
109 int GetScrollThumb(int orientation);
110 int GetScrollPos(int orientation);
111 int GetScrollRange(int orientation);
112 void GetSize(int *OUTPUT, int *OUTPUT);
113 #ifdef __WXMSW__
114 void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT); // int* descent = NULL, int* externalLeading = NULL, const wxFont* font = NULL, bool use16 = FALSE)
115 #endif
116 #ifdef __WXMSW__
117 wxString& GetTitle();
118 #else
119 wxString GetTitle();
120 #endif
121 long GetWindowStyleFlag();
122 void InitDialog();
123 bool IsEnabled();
124 bool IsRetained();
125 bool IsShown();
126 void Layout();
127 #ifdef __WXMSW__
128 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
129 #endif
130 void Lower();
131 void MakeModal(bool flag);
132 void Move(int x, int y);
133
134 //wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE);
135 bool PopupMenu(wxMenu *menu, int x, int y);
136 //void PushEventHandler(wxEvtHandler* handler);
137
138 void Raise();
139 void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL);
140 void ReleaseMouse();
141 void ScreenToClient(int *BOTH, int *BOTH);
142 void ScrollWindow(int dx, int dy, const wxRect* rect = NULL);
143 void SetAutoLayout(bool autoLayout);
144 void SetBackgroundColour(const wxColour& colour);
145 void SetConstraints(wxLayoutConstraints *constraints);
146 void SetDoubleClick(bool allowDoubleClick);
147 void SetFocus();
148 void SetFont(const wxFont& font);
149 #ifdef __WXMSW__
150 void SetForegroundColour(const wxColour& colour);
151 #endif
152 void SetId(int id);
153 void SetName(const wxString& name);
154 void SetReturnCode(int retCode);
155 void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh = TRUE);
156 void SetScrollPos(int orientation, int pos, bool refresh = TRUE);
157
158 //void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
159 //%name(SetSizeOnly) void SetSize(int width, int height);
160
161 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
162 %addmethods {
163 void SetSize(const wxSize& size) {
164 self->SetSize(size.x, size.y);
165 }
166
167 void SetPosition(const wxPoint& pos) {
168 self->SetSize(pos.x, pos.y, -1, -1);
169 }
170 }
171
172 #ifdef __WXMSW__
173 void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1);
174 #endif
175 void SetClientSize(int width, int height);
176 //void SetPalette(wxPalette* palette);
177 //void SetColourMap(wxColourMap *colourMap);
178 void SetCursor(const wxCursor&cursor);
179 //void SetEventHandler(wxEvtHandler* handler);
180 void SetTitle(const wxString& title);
181 bool Show(bool show);
182 bool TransferDataFromWindow();
183 bool TransferDataToWindow();
184 bool Validate();
185 #ifdef __WXMSW__
186 void WarpPointer(int x, int y);
187 #endif
188
189 };
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 class wxFrame : public wxWindow {
204 public:
205 wxFrame(wxWindow* parent, const wxWindowID id, const wxString& title,
206 const wxPoint& pos = wxPyDefaultPosition,
207 const wxSize& size = wxPyDefaultSize,
208 long style = wxDEFAULT_FRAME_STYLE,
209 char* name = "frame");
210
211 void Centre(int direction = wxBOTH);
212 #ifdef __WXMSW__
213 void Command(int id);
214 #endif
215 bool CreateStatusBar(int number = 1);
216 wxMenuBar* GetMenuBar();
217 wxStatusBar* GetStatusBar();
218 #ifdef __WXMSW__
219 wxString& GetTitle();
220 #else
221 wxString GetTitle();
222 #endif
223 #ifdef __WXMSW__
224 void Iconize(bool iconize);
225 bool IsIconized();
226 void SetAcceleratorTable(const wxAcceleratorTable& accel);
227 void Maximize(bool maximize);
228 #endif
229 void SetIcon(const wxIcon& icon);
230 void SetMenuBar(wxMenuBar* menuBar);
231 void SetStatusText(const wxString& text, int number = 0);
232 void SetStatusWidths(int LCOUNT, int* LIST); // use typemap
233 void SetTitle(const wxString& title);
234
235 };
236
237 //---------------------------------------------------------------------------
238
239 #ifdef __WXMSW__
240 class wxMiniFrame : public wxFrame {
241 public:
242 wxMiniFrame(wxWindow* parent, const wxWindowID id, const wxString& title,
243 const wxPoint& pos = wxPyDefaultPosition,
244 const wxSize& size = wxPyDefaultSize,
245 long style = wxDEFAULT_FRAME_STYLE,
246 char* name = "frame");
247 };
248 #endif
249
250 //---------------------------------------------------------------------------
251
252 class wxPanel : public wxWindow {
253 public:
254 wxPanel(wxWindow* parent,
255 const wxWindowID id,
256 const wxPoint& pos = wxPyDefaultPosition,
257 const wxSize& size = wxPyDefaultSize,
258 long style = wxTAB_TRAVERSAL,
259 const char* name = "panel");
260
261 void InitDialog();
262 };
263
264 //---------------------------------------------------------------------------
265
266 class wxDialog : public wxPanel {
267 public:
268 wxDialog(wxWindow* parent,
269 const wxWindowID id,
270 const wxString& title,
271 const wxPoint& pos = wxPyDefaultPosition,
272 const wxSize& size = wxPyDefaultSize,
273 long style = wxDEFAULT_DIALOG_STYLE,
274 const char* name = "dialogBox");
275
276 void Centre(int direction = wxBOTH);
277 void EndModal(int retCode);
278 wxString GetTitle();
279 #ifdef __WXMSW__
280 void Iconize(bool iconize);
281 bool IsIconized();
282 void SetModal(bool flag);
283 #endif
284 bool IsModal();
285 void SetTitle(const wxString& title);
286 bool Show(bool show);
287 int ShowModal();
288 };
289
290 //---------------------------------------------------------------------------
291
292 class wxScrolledWindow : public wxWindow {
293 public:
294 wxScrolledWindow(wxWindow* parent,
295 const wxWindowID id = -1,
296 const wxPoint& pos = wxPyDefaultPosition,
297 const wxSize& size = wxPyDefaultSize,
298 long style = wxHSCROLL | wxVSCROLL,
299 char* name = "scrolledWindow");
300
301 void EnableScrolling(bool xScrolling, bool yScrolling);
302 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
303 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
304 bool IsRetained();
305 void PrepareDC(wxDC& dc);
306 void Scroll(int x, int y);
307 void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
308 int noUnitsX, int noUnitsY,
309 int xPos = 0, int yPos = 0);
310 void ViewStart(int* OUTPUT, int* OUTPUT);
311 };
312
313 //----------------------------------------------------------------------
314
315
316 class wxMenu : public wxEvtHandler {
317 public:
318 wxMenu(const wxString& title = wxPyEmptyStr);
319
320 void Append(int id, const wxString& item,
321 const wxString& helpString = wxPyEmptyStr,
322 int checkable = FALSE);
323 %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu,
324 const wxString& helpString = wxPyEmptyStr);
325 void AppendSeparator();
326 void Break();
327 void Check(int id, bool flag);
328 void Enable(int id, bool enable);
329 int FindItem(const wxString& itemString);
330 #ifdef __WXMSW__
331 wxMenuItem* FindItemForId(int id);
332 wxString& GetHelpString(int id);
333 wxString GetLabel(int id);
334 wxString GetTitle();
335 void SetHelpString(int id, const wxString& helpString);
336 void SetTitle(const wxString& title);
337 #endif
338 bool IsChecked(int id);
339 bool IsEnabled(int id);
340 void SetLabel(int id, const wxString& label);
341 };
342
343
344 #ifdef __WXMSW__
345 //
346 // This one knows how to set a callback and handle INC- and DECREFing it. To
347 // be used for PopupMenus, but you must retain a referece to it while using
348 // it.
349 //
350 class wxPyMenu : public wxMenu {
351 public:
352 wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL);
353 ~wxPyMenu();
354 };
355 #endif
356
357 //----------------------------------------------------------------------
358
359 class wxMenuBar : public wxEvtHandler {
360 public:
361 wxMenuBar();
362
363 void Append(wxMenu *menu, const wxString& title);
364 void Check(int id, bool flag);
365 bool Checked(int id);
366 void Enable(int id, bool enable);
367 int FindMenuItem(const wxString& menuString, const wxString& itemString);
368 #ifdef __WXMSW__
369 void EnableTop(int pos, bool enable);
370 wxMenuItem * FindItemForId(int id);
371 wxString GetHelpString(int id);
372 wxString GetLabel(int id);
373 void SetHelpString(int id, const wxString& helpString);
374 void SetLabel(int id, const wxString& label);
375 wxString GetLabelTop(int pos);
376 void SetLabelTop(int pos, const wxString& label);
377 #endif
378 };
379
380
381 //----------------------------------------------------------------------
382
383 class wxMenuItem {
384 public:
385 bool IsSeparator();
386 bool IsEnabled();
387 bool IsChecked();
388 int GetId();
389 wxMenu* GetSubMenu();
390 #ifdef __WXMSW__
391 const wxString& GetHelp();
392 void SetName(const wxString& strName);
393 void SetHelp(const wxString& strHelp);
394 #endif
395 void Enable(bool bDoEnable = TRUE);
396 void Check(bool bDoCheck = TRUE);
397 #ifdef __WXMSW__
398 void DeleteSubMenu();
399 const wxString& GetName();
400 #endif
401 bool IsCheckable();
402 };
403
404 //---------------------------------------------------------------------------
405 /////////////////////////////////////////////////////////////////////////////
406 //
407 // $Log$
408 // Revision 1.3 1998/08/15 07:36:47 RD
409 // - Moved the header in the .i files out of the code that gets put into
410 // the .cpp files. It caused CVS conflicts because of the RCS ID being
411 // different each time.
412 //
413 // - A few minor fixes.
414 //
415 // Revision 1.2 1998/08/14 23:36:46 RD
416 // Beginings of wxGTK compatibility
417 //
418 // Revision 1.1 1998/08/09 08:25:52 RD
419 // Initial version
420 //
421 //
422
423