]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_toplvl.i
All platforms have the same GLCanvas API now
[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 wxSYSTEM_MENU,
34 wxMINIMIZE_BOX,
35 wxMAXIMIZE_BOX,
36 wxTINY_CAPTION_HORIZ,
37 wxTINY_CAPTION_VERT,
38 wxRESIZE_BORDER,
39
40 wxDIALOG_NO_PARENT,
41
42 wxDEFAULT_FRAME_STYLE,
43 wxDEFAULT_DIALOG_STYLE,
44
45 wxFRAME_TOOL_WINDOW,
46 wxFRAME_FLOAT_ON_PARENT,
47 wxFRAME_NO_WINDOW_MENU,
48 wxFRAME_NO_TASKBAR,
49 wxFRAME_SHAPED,
50 wxFRAME_DRAWER,
51
52 wxFRAME_EX_METAL,
53 wxDIALOG_EX_METAL,
54 wxWS_EX_CONTEXTHELP,
55
56 wxFRAME_EX_CONTEXTHELP,
57 wxDIALOG_EX_CONTEXTHELP,
58 };
59
60 %pythoncode {
61 %# deprecated
62 RESIZE_BOX = MAXIMIZE_BOX
63 THICK_FRAME = RESIZE_BORDER
64
65 %# Obsolete
66 wxDIALOG_MODAL = 0
67 wxDIALOG_MODELESS = 0
68 wxUSER_COLOURS = 0
69 wxNO_3D = 0
70 }
71
72
73 enum
74 {
75 wxFULLSCREEN_NOMENUBAR,
76 wxFULLSCREEN_NOTOOLBAR,
77 wxFULLSCREEN_NOSTATUSBAR,
78 wxFULLSCREEN_NOBORDER,
79 wxFULLSCREEN_NOCAPTION,
80 wxFULLSCREEN_ALL,
81
82 wxTOPLEVEL_EX_DIALOG,
83 };
84
85 // Styles for RequestUserAttention
86 enum
87 {
88 wxUSER_ATTENTION_INFO = 1,
89 wxUSER_ATTENTION_ERROR = 2
90 };
91
92 //---------------------------------------------------------------------------
93
94 class wxTopLevelWindow : public wxWindow
95 {
96 public:
97
98 // No constructor as it can not be used directly from Python
99
100 // maximize = True => maximize, otherwise - restore
101 virtual void Maximize(bool maximize = true);
102
103 // undo Maximize() or Iconize()
104 virtual void Restore();
105
106 // iconize = True => iconize, otherwise - restore
107 virtual void Iconize(bool iconize = true);
108
109 // return True if the frame is maximized
110 virtual bool IsMaximized() const;
111
112 // return true if the frame is always maximized
113 // due to native guidelines or current policy
114 virtual bool IsAlwaysMaximized() const;
115
116 // return True if the frame is iconized
117 virtual bool IsIconized() const;
118
119 // get the frame icon
120 wxIcon GetIcon() const;
121
122 // set the frame icon
123 virtual void SetIcon(const wxIcon& icon);
124
125 // set the frame icons
126 virtual void SetIcons(const wxIconBundle& icons);
127
128 // maximize the window to cover entire screen
129 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
130
131 // return True if the frame is in fullscreen mode
132 virtual bool IsFullScreen() const;
133
134 virtual void SetTitle(const wxString& title);
135 virtual wxString GetTitle() const;
136
137 // enable/disable close button [x]
138 virtual bool EnableCloseButton(bool enable );
139
140 // Set the shape of the window to the given region.
141 // Returns True if the platform supports this feature
142 // (and the operation is successful.)
143 virtual bool SetShape(const wxRegion& region);
144
145 // Attracts the users attention to this window if the application is inactive
146 // (should be called when a background event occurs)
147 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
148
149 // Is this the active frame (highlighted in the taskbar)?
150 virtual bool IsActive();
151
152 #ifdef __WXMAC__
153 %extend {
154 void MacSetMetalAppearance( bool on ) {
155 int style = self->GetExtraStyle();
156 if ( on )
157 style |= wxFRAME_EX_METAL;
158 else
159 style &= ~wxFRAME_EX_METAL;
160 self->SetExtraStyle(style);
161 }
162 }
163 bool MacGetMetalAppearance() const;
164 #else
165 %extend
166 {
167 // TODO: Should they raise not implemented or just NOP???
168 void MacSetMetalAppearance( bool on ) { /*wxPyRaiseNotImplemented();*/ }
169 bool MacGetMetalAppearance() const { /*wxPyRaiseNotImplemented();*/ return false; }
170 }
171 #endif
172
173 DocDeclStr(
174 void , CenterOnScreen(int dir = wxBOTH),
175 "Center the window on screen", "");
176 %pythoncode { CentreOnScreen = CenterOnScreen }
177
178
179 DocDeclStr(
180 virtual wxWindow *, GetDefaultItem() const,
181 "Get the default child of this parent, i.e. the one which is activated
182 by pressing <Enter> such as the OK button on a wx.Dialog.", "");
183
184 DocDeclStr(
185 virtual wxWindow *, SetDefaultItem(wxWindow * child),
186 "Set this child as default, return the old default.", "");
187
188 DocDeclStr(
189 virtual void , SetTmpDefaultItem(wxWindow * win),
190 "Set this child as temporary default", "");
191
192 DocDeclStr(
193 virtual wxWindow *, GetTmpDefaultItem() const,
194 "Return the temporary default item, which can be None.", "");
195
196 %property(DefaultItem, GetDefaultItem, SetDefaultItem, doc="See `GetDefaultItem` and `SetDefaultItem`");
197 %property(Icon, GetIcon, SetIcon, doc="See `GetIcon` and `SetIcon`");
198 %property(Title, GetTitle, SetTitle, doc="See `GetTitle` and `SetTitle`");
199 %property(TmpDefaultItem, GetTmpDefaultItem, SetTmpDefaultItem, doc="See `GetTmpDefaultItem` and `SetTmpDefaultItem`");
200 };
201
202
203 //---------------------------------------------------------------------------
204 %newgroup
205
206 // wxFrame is a top-level window with optional menubar, statusbar and toolbar
207 //
208 // For each of *bars, a frame may have several of them, but only one is
209 // managed by the frame, i.e. resized/moved when the frame is and whose size
210 // is accounted for in client size calculations - all others should be taken
211 // care of manually.
212
213 MustHaveApp(wxFrame);
214
215 class wxFrame : public wxTopLevelWindow
216 {
217 public:
218 %pythonAppend wxFrame "self._setOORInfo(self)"
219 %pythonAppend wxFrame() ""
220 %typemap(out) wxFrame*; // turn off this typemap
221
222 wxFrame(wxWindow* parent,
223 const wxWindowID id = -1,
224 const wxString& title = wxPyEmptyString,
225 const wxPoint& pos = wxDefaultPosition,
226 const wxSize& size = wxDefaultSize,
227 long style = wxDEFAULT_FRAME_STYLE,
228 const wxString& name = wxPyFrameNameStr);
229 %RenameCtor(PreFrame, wxFrame());
230
231 // Turn it back on again
232 %typemap(out) wxFrame* { $result = wxPyMake_wxObject($1, $owner); }
233
234 bool Create(wxWindow* parent,
235 const wxWindowID id = -1,
236 const wxString& title = wxPyEmptyString,
237 const wxPoint& pos = wxDefaultPosition,
238 const wxSize& size = wxDefaultSize,
239 long style = wxDEFAULT_FRAME_STYLE,
240 const wxString& name = wxPyFrameNameStr);
241
242 // frame state
243 // -----------
244
245 // get the origin of the client area (which may be different from (0, 0)
246 // if the frame has a toolbar) in client coordinates
247 virtual wxPoint GetClientAreaOrigin() const;
248
249 // sends a size event to the window using its current size:
250 // this has a side effect of refreshing the window layout
251 virtual void SendSizeEvent();
252
253 // menu bar functions
254 // ------------------
255
256 virtual void SetMenuBar(wxMenuBar *menubar);
257 virtual wxMenuBar *GetMenuBar() const;
258
259 // process menu command: returns True if processed
260 bool ProcessCommand(int winid);
261 %pythoncode { Command = ProcessCommand }
262
263 // status bar functions
264 // --------------------
265
266 // create the main status bar by calling OnCreateStatusBar()
267 virtual wxStatusBar* CreateStatusBar(int number = 1,
268 long style = wxDEFAULT_STATUSBAR_STYLE,
269 wxWindowID winid = 0,
270 const wxString& name = wxPyStatusLineNameStr);
271
272 // TODO: with directors?
273 // // return a new status bar
274 // virtual wxStatusBar *OnCreateStatusBar(int number,
275 // long style,
276 // wxWindowID winid,
277 // const wxString& name);
278
279 // get the main status bar
280 virtual wxStatusBar *GetStatusBar() const;
281
282 // sets the main status bar
283 void SetStatusBar(wxStatusBar *statBar);
284
285 // forward these to status bar
286 virtual void SetStatusText(const wxString &text, int number = 0);
287 virtual void SetStatusWidths(int widths, const int* widths_field); // uses typemap above
288 void PushStatusText(const wxString &text, int number = 0);
289 void PopStatusText(int number = 0);
290
291 // set the status bar pane the help will be shown in
292 void SetStatusBarPane(int n);
293 int GetStatusBarPane() const;
294
295 // toolbar functions
296 // -----------------
297
298 // create main toolbar bycalling OnCreateToolBar()
299 virtual wxToolBar* CreateToolBar(long style = -1,
300 wxWindowID winid = -1,
301 const wxString& name = wxPyToolBarNameStr);
302
303 // TODO: with directors?
304 // // return a new toolbar
305 // virtual wxToolBar *OnCreateToolBar(long style,
306 // wxWindowID winid,
307 // const wxString& name );
308
309 // get/set the main toolbar
310 virtual wxToolBar *GetToolBar() const;
311 virtual void SetToolBar(wxToolBar *toolbar);
312
313 // show help text (typically in the statusbar); show is False
314 // if you are hiding the help, True otherwise
315 virtual void DoGiveHelp(const wxString& text, bool show);
316
317 // send wxUpdateUIEvents for all menu items in the menubar,
318 // or just for menu if non-NULL
319 void DoMenuUpdates(wxMenu* menu = NULL);
320
321 static wxVisualAttributes
322 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
323
324 %property(MenuBar, GetMenuBar, SetMenuBar, doc="See `GetMenuBar` and `SetMenuBar`");
325 %property(StatusBar, GetStatusBar, SetStatusBar, doc="See `GetStatusBar` and `SetStatusBar`");
326 %property(StatusBarPane, GetStatusBarPane, SetStatusBarPane, doc="See `GetStatusBarPane` and `SetStatusBarPane`");
327 %property(ToolBar, GetToolBar, SetToolBar, doc="See `GetToolBar` and `SetToolBar`");
328 };
329
330 //---------------------------------------------------------------------------
331 %newgroup
332
333 MustHaveApp(wxDialog);
334
335 class wxDialog : public wxTopLevelWindow
336 {
337 public:
338 enum
339 {
340 // all flags allowed in wxDialogBase::CreateButtonSizer()
341 ButtonSizerFlags = wxOK | wxCANCEL | wxYES | wxNO | wxHELP | wxNO_DEFAULT
342 };
343
344 %pythonAppend wxDialog "self._setOORInfo(self)"
345 %pythonAppend wxDialog() ""
346 %typemap(out) wxDialog*; // turn off this typemap
347
348 wxDialog(wxWindow* parent,
349 const wxWindowID id = -1,
350 const wxString& title = wxPyEmptyString,
351 const wxPoint& pos = wxDefaultPosition,
352 const wxSize& size = wxDefaultSize,
353 long style = wxDEFAULT_DIALOG_STYLE,
354 const wxString& name = wxPyDialogNameStr);
355 %RenameCtor(PreDialog, wxDialog());
356
357 // Turn it back on again
358 %typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); }
359
360 bool Create(wxWindow* parent,
361 const wxWindowID id = -1,
362 const wxString& title = wxPyEmptyString,
363 const wxPoint& pos = wxDefaultPosition,
364 const wxSize& size = wxDefaultSize,
365 long style = wxDEFAULT_DIALOG_STYLE,
366 const wxString& name = wxPyDialogNameStr);
367
368 // the modal dialogs have a return code - usually the ID of the last
369 // pressed button
370 void SetReturnCode(int returnCode);
371 int GetReturnCode() const;
372
373 // Set the identifier for the affirmative button: this button will close
374 // the dialog after validating data and calling TransferDataFromWindow()
375 void SetAffirmativeId(int affirmativeId);
376 int GetAffirmativeId() const;
377
378 // Set identifier for Esc key translation: the button with this id will
379 // close the dialog without doing anything else; special value wxID_NONE
380 // means to not handle Esc at all while wxID_ANY means to map Esc to
381 // wxID_CANCEL if present and GetAffirmativeId() otherwise
382 void SetEscapeId(int escapeId);
383 int GetEscapeId() const;
384
385 // splits text up at newlines and places the
386 // lines into a vertical wxBoxSizer
387 wxSizer* CreateTextSizer( const wxString &message );
388
389
390 // returns a horizontal wxBoxSizer containing the given buttons
391 //
392 // notice that the returned sizer can be NULL if no buttons are put in the
393 // sizer (this mostly happens under smart phones and other atypical
394 // platforms which have hardware buttons replacing OK/Cancel and such)
395 %Rename(_CreateButtonSizer,
396 wxSizer* , CreateButtonSizer( long flags ));
397 %pythoncode {
398 def CreateButtonSizer(self, flags, *ignored):
399 return self._CreateButtonSizer(flags)
400 }
401
402 // returns the sizer containing CreateButtonSizer() below a separating
403 // static line for the platforms which use static lines for items
404 // separation (i.e. not Mac)
405 wxSizer *CreateSeparatedButtonSizer(long flags);
406
407 wxStdDialogButtonSizer* CreateStdDialogButtonSizer( long flags );
408
409 //void SetModal( bool flag );
410
411 // is the dialog in modal state right now?
412 virtual bool IsModal() const;
413
414 // Shows the dialog and starts a nested event loop that returns when
415 // EndModal is called.
416 virtual int ShowModal();
417
418 // may be called to terminate the dialog with the given return code
419 virtual void EndModal(int retCode);
420
421 static wxVisualAttributes
422 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
423
424 %property(AffirmativeId, GetAffirmativeId, SetAffirmativeId, doc="See `GetAffirmativeId` and `SetAffirmativeId`");
425 %property(EscapeId, GetEscapeId, SetEscapeId, doc="See `GetEscapeId` and `SetEscapeId`");
426 %property(ReturnCode, GetReturnCode, SetReturnCode, doc="See `GetReturnCode` and `SetReturnCode`");
427 };
428
429 //---------------------------------------------------------------------------
430 %newgroup
431
432 %{
433 #define wxDEFAULT_MINIFRAME_STYLE wxCAPTION | wxRESIZE_BORDER | wxTINY_CAPTION_HORIZ
434 %}
435
436 enum {
437 wxDEFAULT_MINIFRAME_STYLE
438 };
439
440
441 MustHaveApp(wxMiniFrame);
442
443 class wxMiniFrame : public wxFrame
444 {
445 public:
446 %pythonAppend wxMiniFrame "self._setOORInfo(self)"
447 %pythonAppend wxMiniFrame() ""
448
449 wxMiniFrame(wxWindow* parent,
450 const wxWindowID id = -1,
451 const wxString& title = wxPyEmptyString,
452 const wxPoint& pos = wxDefaultPosition,
453 const wxSize& size = wxDefaultSize,
454 long style = wxDEFAULT_MINIFRAME_STYLE,
455 const wxString& name = wxPyFrameNameStr);
456 %RenameCtor(PreMiniFrame, wxMiniFrame());
457
458 bool Create(wxWindow* parent,
459 const wxWindowID id = -1,
460 const wxString& title = wxPyEmptyString,
461 const wxPoint& pos = wxDefaultPosition,
462 const wxSize& size = wxDefaultSize,
463 long style = wxDEFAULT_MINIFRAME_STYLE,
464 const wxString& name = wxPyFrameNameStr);
465 };
466
467
468 //---------------------------------------------------------------------------
469 %newgroup
470
471
472 enum
473 {
474 wxSPLASH_CENTRE_ON_PARENT,
475 wxSPLASH_CENTRE_ON_SCREEN,
476 wxSPLASH_NO_CENTRE,
477 wxSPLASH_TIMEOUT,
478 wxSPLASH_NO_TIMEOUT,
479 };
480
481
482 MustHaveApp(wxSplashScreenWindow);
483
484 class wxSplashScreenWindow: public wxWindow
485 {
486 public:
487 %pythonAppend wxSplashScreenWindow "self._setOORInfo(self)"
488
489 wxSplashScreenWindow(const wxBitmap& bitmap,
490 wxWindow* parent,
491 wxWindowID id,
492 const wxPoint& pos = wxDefaultPosition,
493 const wxSize& size = wxDefaultSize,
494 long style = wxNO_BORDER);
495
496 void SetBitmap(const wxBitmap& bitmap);
497 wxBitmap& GetBitmap();
498
499 %property(Bitmap, GetBitmap, SetBitmap, doc="See `GetBitmap` and `SetBitmap`");
500 };
501
502
503 MustHaveApp(wxSplashScreen);
504
505 class wxSplashScreen : public wxFrame
506 {
507 public:
508 %pythonAppend wxSplashScreen "self._setOORInfo(self)"
509
510 wxSplashScreen(const wxBitmap& bitmap,
511 long splashStyle, int milliseconds,
512 wxWindow* parent,
513 wxWindowID id = -1,
514 const wxPoint& pos = wxDefaultPosition,
515 const wxSize& size = wxDefaultSize,
516 long style = wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP);
517
518 long GetSplashStyle() const;
519 wxSplashScreenWindow* GetSplashWindow() const;
520 int GetTimeout() const;
521
522 %property(SplashStyle, GetSplashStyle, doc="See `GetSplashStyle`");
523 %property(SplashWindow, GetSplashWindow, doc="See `GetSplashWindow`");
524 %property(Timeout, GetTimeout, doc="See `GetTimeout`");
525 };
526
527
528 //---------------------------------------------------------------------------