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