]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_toplvl.i
Avoid using the OOR typemap in the constructors
[wxWidgets.git] / wxPython / src / _toplvl.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _toplvl.i
3 // Purpose: SWIG definitions for wxTopLevelWindow, wxFrame, wxDialog and etc.
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 27-Aug-1998
8 // RCS-ID: $Id$
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15
16 //---------------------------------------------------------------------------
17
18 MAKE_CONST_WXSTRING(FrameNameStr);
19 MAKE_CONST_WXSTRING(DialogNameStr);
20 MAKE_CONST_WXSTRING(StatusLineNameStr);
21 MAKE_CONST_WXSTRING(ToolBarNameStr);
22
23 //---------------------------------------------------------------------------
24 %newgroup
25
26 enum
27 {
28 wxSTAY_ON_TOP,
29 wxICONIZE,
30 wxMINIMIZE,
31 wxMAXIMIZE,
32 wxCLOSE_BOX,
33 wxTHICK_FRAME,
34 wxSYSTEM_MENU,
35 wxMINIMIZE_BOX,
36 wxMAXIMIZE_BOX,
37 wxTINY_CAPTION_HORIZ,
38 wxTINY_CAPTION_VERT,
39 wxRESIZE_BOX,
40 wxRESIZE_BORDER,
41
42 wxDIALOG_NO_PARENT,
43
44 wxDEFAULT_FRAME_STYLE,
45 wxDEFAULT_DIALOG_STYLE,
46
47 wxFRAME_TOOL_WINDOW,
48 wxFRAME_FLOAT_ON_PARENT,
49 wxFRAME_NO_WINDOW_MENU,
50 wxFRAME_NO_TASKBAR,
51 wxFRAME_SHAPED,
52
53 // Obsolete
54 wxDIALOG_MODAL,
55 wxDIALOG_MODELESS,
56 wxUSER_COLOURS,
57 wxNO_3D,
58 };
59
60 enum
61 {
62 wxFULLSCREEN_NOMENUBAR,
63 wxFULLSCREEN_NOTOOLBAR,
64 wxFULLSCREEN_NOSTATUSBAR,
65 wxFULLSCREEN_NOBORDER,
66 wxFULLSCREEN_NOCAPTION,
67 wxFULLSCREEN_ALL,
68
69 wxTOPLEVEL_EX_DIALOG,
70 };
71
72
73
74 %typemap(in) (int widths, int* widths_field) {
75 $1 = PyList_Size($input);
76 $2 = int_LIST_helper($input);
77 if ($2 == NULL) SWIG_fail;
78 }
79
80 %typemap(freearg) (int widths, int* widths_field) {
81 if ($2) delete [] $2;
82 }
83
84
85 //---------------------------------------------------------------------------
86
87 class wxTopLevelWindow : public wxWindow
88 {
89 public:
90
91 // No constructor as it can not be used directly from Python
92
93 // maximize = True => maximize, otherwise - restore
94 virtual void Maximize(bool maximize = True);
95
96 // undo Maximize() or Iconize()
97 virtual void Restore();
98
99 // iconize = True => iconize, otherwise - restore
100 virtual void Iconize(bool iconize = True);
101
102 // return True if the frame is maximized
103 virtual bool IsMaximized() const;
104
105 // return True if the frame is iconized
106 virtual bool IsIconized() const;
107
108 // get the frame icon
109 wxIcon GetIcon() const;
110
111 // set the frame icon
112 virtual void SetIcon(const wxIcon& icon);
113
114 // set the frame icons
115 virtual void SetIcons(const wxIconBundle& icons );
116
117 // maximize the window to cover entire screen
118 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
119
120 // return True if the frame is in fullscreen mode
121 virtual bool IsFullScreen() const;
122
123 virtual void SetTitle(const wxString& title);
124 virtual wxString GetTitle() const;
125
126 // Set the shape of the window to the given region.
127 // Returns True if the platform supports this feature (and the operation
128 // is successful.)
129 virtual bool SetShape(const wxRegion& region);
130
131 #ifdef __WXMAC__
132 void MacSetMetalAppearance( bool on ) ;
133 bool MacGetMetalAppearance() const ;
134 #endif
135 };
136
137
138 //---------------------------------------------------------------------------
139 %newgroup
140
141 // wxFrame is a top-level window with optional menubar, statusbar and toolbar
142 //
143 // For each of *bars, a frame may have several of them, but only one is
144 // managed by the frame, i.e. resized/moved when the frame is and whose size
145 // is accounted for in client size calculations - all others should be taken
146 // care of manually.
147
148 MustHaveApp(wxFrame);
149
150 class wxFrame : public wxTopLevelWindow {
151 public:
152 %pythonAppend wxFrame "self._setOORInfo(self)"
153 %pythonAppend wxFrame() ""
154 %typemap(out) wxFrame*; // turn off this typemap
155
156 wxFrame(wxWindow* parent, const wxWindowID id=-1,
157 const wxString& title = wxPyEmptyString,
158 const wxPoint& pos = wxDefaultPosition,
159 const wxSize& size = wxDefaultSize,
160 long style = wxDEFAULT_FRAME_STYLE,
161 const wxString& name = wxPyFrameNameStr);
162 %name(PreFrame)wxFrame();
163
164 // Turn it back on again
165 %typemap(out) wxFrame* { $result = wxPyMake_wxObject($1, $owner); }
166
167
168 bool Create(wxWindow* parent, const wxWindowID id=-1,
169 const wxString& title = wxPyEmptyString,
170 const wxPoint& pos = wxDefaultPosition,
171 const wxSize& size = wxDefaultSize,
172 long style = wxDEFAULT_FRAME_STYLE,
173 const wxString& name = wxPyFrameNameStr);
174
175
176 // frame state
177 // -----------
178
179 // get the origin of the client area (which may be different from (0, 0)
180 // if the frame has a toolbar) in client coordinates
181 virtual wxPoint GetClientAreaOrigin() const;
182
183 // sends a size event to the window using its current size -- this has an
184 // effect of refreshing the window layout
185 //
186 virtual void SendSizeEvent();
187
188
189 // menu bar functions
190 // ------------------
191
192 virtual void SetMenuBar(wxMenuBar *menubar);
193 virtual wxMenuBar *GetMenuBar() const;
194
195
196 // process menu command: returns True if processed
197 bool ProcessCommand(int winid);
198 %pythoncode { Command = ProcessCommand }
199
200
201 // status bar functions
202 // --------------------
203
204 // create the main status bar by calling OnCreateStatusBar()
205 virtual wxStatusBar* CreateStatusBar(int number = 1,
206 long style = wxDEFAULT_STATUSBAR_STYLE,
207 wxWindowID winid = 0,
208 const wxString& name = wxPyStatusLineNameStr);
209 // TODO: with directors?
210 // // return a new status bar
211 // virtual wxStatusBar *OnCreateStatusBar(int number,
212 // long style,
213 // wxWindowID winid,
214 // const wxString& name);
215
216 // get the main status bar
217 virtual wxStatusBar *GetStatusBar() const;
218
219 // sets the main status bar
220 void SetStatusBar(wxStatusBar *statBar);
221
222 // forward these to status bar
223 virtual void SetStatusText(const wxString &text, int number = 0);
224 virtual void SetStatusWidths(int widths, const int* widths_field); //uses typemap above
225 void PushStatusText(const wxString &text, int number = 0);
226 void PopStatusText(int number = 0);
227
228 // set the status bar pane the help will be shown in
229 void SetStatusBarPane(int n);
230 int GetStatusBarPane() const;
231
232
233 // toolbar functions
234 // -----------------
235
236 // create main toolbar bycalling OnCreateToolBar()
237 virtual wxToolBar* CreateToolBar(long style = -1,
238 wxWindowID winid = -1,
239 const wxString& name = wxPyToolBarNameStr);
240 // TODO: with directors?
241 // // return a new toolbar
242 // virtual wxToolBar *OnCreateToolBar(long style,
243 // wxWindowID winid,
244 // const wxString& name );
245
246 // get/set the main toolbar
247 virtual wxToolBar *GetToolBar() const;
248 virtual void SetToolBar(wxToolBar *toolbar);
249
250
251 // show help text (typically in the statusbar); show is False
252 // if you are hiding the help, True otherwise
253 virtual void DoGiveHelp(const wxString& text, bool show);
254
255
256 // send wxUpdateUIEvents for all menu items in the menubar,
257 // or just for menu if non-NULL
258 void DoMenuUpdates(wxMenu* menu = NULL);
259
260 static wxVisualAttributes
261 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
262 };
263
264 //---------------------------------------------------------------------------
265 %newgroup
266
267 MustHaveApp(wxDialog);
268
269 class wxDialog : public wxTopLevelWindow {
270 public:
271 %pythonAppend wxDialog "self._setOORInfo(self)"
272 %pythonAppend wxDialog() ""
273 %typemap(out) wxDialog*; // turn off this typemap
274
275 wxDialog(wxWindow* parent,
276 const wxWindowID id=-1,
277 const wxString& title = wxPyEmptyString,
278 const wxPoint& pos = wxDefaultPosition,
279 const wxSize& size = wxDefaultSize,
280 long style = wxDEFAULT_DIALOG_STYLE,
281 const wxString& name = wxPyDialogNameStr);
282 %name(PreDialog)wxDialog();
283
284 // Turn it back on again
285 %typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); }
286
287 bool Create(wxWindow* parent,
288 const wxWindowID id=-1,
289 const wxString& title = wxPyEmptyString,
290 const wxPoint& pos = wxDefaultPosition,
291 const wxSize& size = wxDefaultSize,
292 long style = wxDEFAULT_DIALOG_STYLE,
293 const wxString& name = wxPyDialogNameStr);
294
295
296 // the modal dialogs have a return code - usually the id of the last
297 // pressed button
298 void SetReturnCode(int returnCode);
299 int GetReturnCode() const;
300
301 // splits text up at newlines and places the
302 // lines into a vertical wxBoxSizer
303 wxSizer *CreateTextSizer( const wxString &message );
304
305 // places buttons into a horizontal wxBoxSizer
306 wxSizer *CreateButtonSizer( long flags );
307
308
309 //void SetModal(bool flag);
310
311 // is the dialog in modal state right now?
312 virtual bool IsModal() const;
313
314 // Shows the dialog and starts a nested event loop that returns when
315 // EndModal is called.
316 virtual int ShowModal();
317
318 // may be called to terminate the dialog with the given return code
319 virtual void EndModal(int retCode);
320
321 static wxVisualAttributes
322 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
323
324 %pythoncode {
325 def SendSizeEvent(self):
326 self.ProcessEvent(wx.SizeEvent((-1,-1)))
327 }
328 };
329
330 //---------------------------------------------------------------------------
331 %newgroup
332
333
334 MustHaveApp(wxMiniFrame);
335
336 class wxMiniFrame : public wxFrame {
337 public:
338 %pythonAppend wxMiniFrame "self._setOORInfo(self)"
339 %pythonAppend wxMiniFrame() ""
340
341 wxMiniFrame(wxWindow* parent, const wxWindowID id=-1,
342 const wxString& title = wxPyEmptyString,
343 const wxPoint& pos = wxDefaultPosition,
344 const wxSize& size = wxDefaultSize,
345 long style = wxDEFAULT_FRAME_STYLE,
346 const wxString& name = wxPyFrameNameStr);
347 %name(PreMiniFrame)wxMiniFrame();
348
349 bool Create(wxWindow* parent, const wxWindowID id=-1,
350 const wxString& title = wxPyEmptyString,
351 const wxPoint& pos = wxDefaultPosition,
352 const wxSize& size = wxDefaultSize,
353 long style = wxDEFAULT_FRAME_STYLE,
354 const wxString& name = wxPyFrameNameStr);
355
356 };
357
358
359 //---------------------------------------------------------------------------
360 %newgroup
361
362
363 enum {
364 wxSPLASH_CENTRE_ON_PARENT,
365 wxSPLASH_CENTRE_ON_SCREEN,
366 wxSPLASH_NO_CENTRE,
367 wxSPLASH_TIMEOUT,
368 wxSPLASH_NO_TIMEOUT,
369 };
370
371
372 MustHaveApp(wxSplashScreenWindow);
373
374 class wxSplashScreenWindow: public wxWindow
375 {
376 public:
377 %pythonAppend wxSplashScreenWindow "self._setOORInfo(self)"
378
379 wxSplashScreenWindow(const wxBitmap& bitmap,
380 wxWindow* parent, wxWindowID id,
381 const wxPoint& pos = wxDefaultPosition,
382 const wxSize& size = wxDefaultSize,
383 long style = wxNO_BORDER);
384
385 void SetBitmap(const wxBitmap& bitmap);
386 wxBitmap& GetBitmap();
387 };
388
389
390 MustHaveApp(wxSplashScreen);
391
392 class wxSplashScreen : public wxFrame {
393 public:
394 %pythonAppend wxSplashScreen "self._setOORInfo(self)"
395
396 wxSplashScreen(const wxBitmap& bitmap, long splashStyle, int milliseconds,
397 wxWindow* parent, wxWindowID id=-1,
398 const wxPoint& pos = wxDefaultPosition,
399 const wxSize& size = wxDefaultSize,
400 long style = wxSIMPLE_BORDER|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP);
401
402 long GetSplashStyle() const;
403 wxSplashScreenWindow* GetSplashWindow() const;
404 int GetTimeout() const;
405 };
406
407
408 //---------------------------------------------------------------------------