]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/windows.i
Additions for wxTreeCtrl
[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 wxp"
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__:wxp._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 void GetClientSize(int *OUTPUT, int *OUTPUT);
90 wxLayoutConstraints * GetConstraints();
91 #ifdef __WXMSW__
92 wxButton* GetDefaultItem();
93 #endif
94 //wxEvtHandler* GetEventHandler();
95 wxFont* GetFont();
96 wxColour GetForegroundColour();
97 wxWindow * GetGrandParent();
98 int GetId();
99 void GetPosition(int *OUTPUT, int *OUTPUT);
100 wxString GetLabel();
101 wxString GetName();
102 wxWindow * GetParent();
103 int GetReturnCode();
104 int GetScrollThumb(int orientation);
105 int GetScrollPos(int orientation);
106 int GetScrollRange(int orientation);
107 void GetSize(int *OUTPUT, int *OUTPUT);
108 void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT); // int* descent = NULL, int* externalLeading = NULL, const wxFont* font = NULL, bool use16 = FALSE)
109 wxString GetTitle();
110 long GetWindowStyleFlag();
111 void InitDialog();
112 bool IsEnabled();
113 bool IsRetained();
114 bool IsShown();
115 void Layout();
116 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
117 void Lower();
118 void MakeModal(bool flag);
119 void Move(int x, int y);
120
121 //wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE);
122 bool PopupMenu(wxMenu *menu, int x, int y);
123 //void PushEventHandler(wxEvtHandler* handler);
124
125 void Raise();
126 void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL);
127 void ReleaseMouse();
128 void ScreenToClient(int *BOTH, int *BOTH);
129 void ScrollWindow(int dx, int dy, const wxRect* rect = NULL);
130 void SetAutoLayout(bool autoLayout);
131 void SetBackgroundColour(const wxColour& colour);
132 void SetConstraints(wxLayoutConstraints *constraints);
133 void SetDoubleClick(bool allowDoubleClick);
134 void SetFocus();
135 void SetFont(const wxFont& font);
136 void SetForegroundColour(const wxColour& colour);
137 void SetId(int id);
138 void SetName(const wxString& name);
139 void SetReturnCode(int retCode);
140 void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh = TRUE);
141 void SetScrollPos(int orientation, int pos, bool refresh = TRUE);
142
143 //void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
144 //%name(SetSizeOnly) void SetSize(int width, int height);
145
146 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
147 %addmethods {
148 void SetSize(const wxSize& size) {
149 self->SetSize(size.x, size.y);
150 }
151
152 void SetPosition(const wxPoint& pos) {
153 self->SetSize(pos.x, pos.y, -1, -1);
154 }
155 }
156
157 void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1);
158 void SetClientSize(int width, int height);
159 //void SetPalette(wxPalette* palette);
160 //void SetColourMap(wxColourMap *colourMap);
161 void SetCursor(const wxCursor&cursor);
162 //void SetEventHandler(wxEvtHandler* handler);
163 void SetTitle(const wxString& title);
164 bool Show(bool show);
165 bool TransferDataFromWindow();
166 bool TransferDataToWindow();
167 bool Validate();
168 #ifdef __WXMSW__
169 void WarpPointer(int x, int y);
170 #endif
171
172 };
173
174
175 // Static method(s)
176 #ifdef __WXMSW__
177 %inline %{
178 wxWindow* wxWindow_FindFocus() {
179 return wxWindow::FindFocus();
180 }
181 %}
182 #endif
183
184
185 //---------------------------------------------------------------------------
186
187 class wxPanel : public wxWindow {
188 public:
189 wxPanel(wxWindow* parent,
190 const wxWindowID id,
191 const wxPoint& pos = wxPyDefaultPosition,
192 const wxSize& size = wxPyDefaultSize,
193 long style = wxTAB_TRAVERSAL,
194 const char* name = "panel");
195
196 %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)"
197
198 void InitDialog();
199 };
200
201 //---------------------------------------------------------------------------
202
203 class wxDialog : public wxPanel {
204 public:
205 wxDialog(wxWindow* parent,
206 const wxWindowID id,
207 const wxString& title,
208 const wxPoint& pos = wxPyDefaultPosition,
209 const wxSize& size = wxPyDefaultSize,
210 long style = wxDEFAULT_DIALOG_STYLE,
211 const char* name = "dialogBox");
212
213 %pragma(python) addtomethod = "__init__:wxp._StdDialogCallbacks(self)"
214
215 void Centre(int direction = wxBOTH);
216 void EndModal(int retCode);
217 wxString GetTitle();
218 void Iconize(bool iconize);
219 bool IsIconized();
220 void SetModal(bool flag);
221 bool IsModal();
222 void SetTitle(const wxString& title);
223 bool Show(bool show);
224 int ShowModal();
225 };
226
227 //---------------------------------------------------------------------------
228
229 class wxScrolledWindow : public wxWindow {
230 public:
231 wxScrolledWindow(wxWindow* parent,
232 const wxWindowID id = -1,
233 const wxPoint& pos = wxPyDefaultPosition,
234 const wxSize& size = wxPyDefaultSize,
235 long style = wxHSCROLL | wxVSCROLL,
236 char* name = "scrolledWindow");
237
238 %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)"
239 %pragma(python) addtomethod = "__init__:wxp._StdOnScrollCallbacks(self)"
240
241 void EnableScrolling(bool xScrolling, bool yScrolling);
242 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
243 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
244 bool IsRetained();
245 void PrepareDC(wxDC& dc);
246 void Scroll(int x, int y);
247 void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
248 int noUnitsX, int noUnitsY,
249 int xPos = 0, int yPos = 0);
250 void ViewStart(int* OUTPUT, int* OUTPUT);
251 };
252
253 //----------------------------------------------------------------------
254
255
256 class wxMenu : public wxEvtHandler {
257 public:
258 wxMenu(const wxString& title = wxPyEmptyStr);
259
260 void Append(int id, const wxString& item,
261 const wxString& helpString = wxPyEmptyStr,
262 int checkable = FALSE);
263 %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu,
264 const wxString& helpString = wxPyEmptyStr);
265 void AppendSeparator();
266 void Break();
267 void Check(int id, bool flag);
268 void Enable(int id, bool enable);
269 int FindItem(const wxString& itemString);
270 #ifdef __WXMSW__
271 wxString GetTitle();
272 void SetTitle(const wxString& title);
273 #endif
274 wxMenuItem* FindItemForId(int id);
275 wxString GetHelpString(int id);
276 wxString GetLabel(int id);
277 void SetHelpString(int id, const wxString& helpString);
278 bool IsChecked(int id);
279 bool IsEnabled(int id);
280 void SetLabel(int id, const wxString& label);
281 };
282
283
284 //
285 // This one knows how to set a callback and handle INC- and DECREFing it. To
286 // be used for PopupMenus, but you must retain a referece to it while using
287 // it.
288 //
289 class wxPyMenu : public wxMenu {
290 public:
291 wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL);
292 ~wxPyMenu();
293 };
294
295 //----------------------------------------------------------------------
296
297 class wxMenuBar : public wxEvtHandler {
298 public:
299 wxMenuBar();
300
301 void Append(wxMenu *menu, const wxString& title);
302 void Check(int id, bool flag);
303 bool Checked(int id);
304 void Enable(int id, bool enable);
305 bool Enabled(int id);
306 int FindMenuItem(const wxString& menuString, const wxString& itemString);
307 #ifdef __WXGTK__
308 %name(FindItemForId) wxMenuItem* FindMenuItemById( int id );
309 #endif
310 #ifdef __WXMSW__
311 wxMenuItem * FindItemForId(int id);
312 void EnableTop(int pos, bool enable);
313 wxString GetHelpString(int id);
314 wxString GetLabel(int id);
315 void SetHelpString(int id, const wxString& helpString);
316 void SetLabel(int id, const wxString& label);
317 wxString GetLabelTop(int pos);
318 void SetLabelTop(int pos, const wxString& label);
319 #endif
320 int GetMenuCount();
321 wxMenu* GetMenu(int i);
322 };
323
324
325 //----------------------------------------------------------------------
326
327 class wxMenuItem {
328 public:
329 bool IsSeparator();
330 bool IsEnabled();
331 bool IsChecked();
332 bool IsCheckable();
333 int GetId();
334 wxMenu* GetSubMenu();
335 #ifdef __WXMSW__
336 void SetName(const wxString& strName);
337 void DeleteSubMenu();
338 const wxString& GetName();
339 #endif
340 const wxString& GetHelp();
341 void SetHelp(const wxString& strHelp);
342 void Enable(bool bDoEnable = TRUE);
343 void Check(bool bDoCheck = TRUE);
344 };
345
346 //---------------------------------------------------------------------------
347 /////////////////////////////////////////////////////////////////////////////
348 //
349 // $Log$
350 // Revision 1.6 1998/10/02 06:40:43 RD
351 // Version 0.4 of wxPython for MSW.
352 //
353 // Revision 1.5 1998/08/17 18:29:40 RD
354 // Removed an extra method definition
355 //
356 // Revision 1.4 1998/08/16 04:31:11 RD
357 // More wxGTK work.
358 //
359 // Revision 1.3 1998/08/15 07:36:47 RD
360 // - Moved the header in the .i files out of the code that gets put into
361 // the .cpp files. It caused CVS conflicts because of the RCS ID being
362 // different each time.
363 //
364 // - A few minor fixes.
365 //
366 // Revision 1.2 1998/08/14 23:36:46 RD
367 // Beginings of wxGTK compatibility
368 //
369 // Revision 1.1 1998/08/09 08:25:52 RD
370 // Initial version
371 //
372 //
373
374