]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_toplvl.i
SetCanFocus
[wxWidgets.git] / wxPython / src / _toplvl.i
CommitLineData
9c039d08 1/////////////////////////////////////////////////////////////////////////////
d14a1e28
RD
2// Name: _toplvl.i
3// Purpose: SWIG definitions for wxTopLevelWindow, wxFrame, wxDialog and etc.
9c039d08
RD
4//
5// Author: Robin Dunn
6//
d14a1e28 7// Created: 27-Aug-1998
9c039d08 8// RCS-ID: $Id$
d14a1e28 9// Copyright: (c) 2003 by Total Control Software
9c039d08
RD
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
d14a1e28 13// Not a %module
9c039d08 14
9c039d08 15
d14a1e28 16//---------------------------------------------------------------------------
9c039d08 17
b2dc1044
RD
18MAKE_CONST_WXSTRING(FrameNameStr);
19MAKE_CONST_WXSTRING(DialogNameStr);
20MAKE_CONST_WXSTRING(StatusLineNameStr);
21MAKE_CONST_WXSTRING(ToolBarNameStr);
137b5242 22
d14a1e28
RD
23//---------------------------------------------------------------------------
24%newgroup
137b5242 25
447f48ba
RD
26enum
27{
28 wxSTAY_ON_TOP,
29 wxICONIZE,
30 wxMINIMIZE,
31 wxMAXIMIZE,
32 wxCLOSE_BOX,
447f48ba
RD
33 wxSYSTEM_MENU,
34 wxMINIMIZE_BOX,
35 wxMAXIMIZE_BOX,
36 wxTINY_CAPTION_HORIZ,
37 wxTINY_CAPTION_VERT,
447f48ba
RD
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,
c430d0dc 50 wxFRAME_DRAWER,
4a065572
RD
51
52 wxFRAME_EX_METAL,
53 wxDIALOG_EX_METAL,
5472694a 54 wxWS_EX_CONTEXTHELP,
5472694a
RD
55
56 wxFRAME_EX_CONTEXTHELP,
57 wxDIALOG_EX_CONTEXTHELP,
cbfc9df6
RD
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}
447f48ba 71
5472694a 72
d14a1e28
RD
73enum
74{
f6bcfd97
BP
75 wxFULLSCREEN_NOMENUBAR,
76 wxFULLSCREEN_NOTOOLBAR,
77 wxFULLSCREEN_NOSTATUSBAR,
78 wxFULLSCREEN_NOBORDER,
79 wxFULLSCREEN_NOCAPTION,
ecc08ead
RD
80 wxFULLSCREEN_ALL,
81
82 wxTOPLEVEL_EX_DIALOG,
f6bcfd97
BP
83};
84
e51483b1
RD
85// Styles for RequestUserAttention
86enum
87{
88 wxUSER_ATTENTION_INFO = 1,
89 wxUSER_ATTENTION_ERROR = 2
90};
f6bcfd97 91
d14a1e28 92//---------------------------------------------------------------------------
ecc08ead
RD
93
94class wxTopLevelWindow : public wxWindow
95{
96public:
ecc08ead 97
d14a1e28 98 // No constructor as it can not be used directly from Python
ecc08ead 99
dd9f7fea 100 // maximize = True => maximize, otherwise - restore
a72f4631 101 virtual void Maximize(bool maximize = true);
ecc08ead
RD
102
103 // undo Maximize() or Iconize()
104 virtual void Restore();
105
dd9f7fea 106 // iconize = True => iconize, otherwise - restore
a72f4631 107 virtual void Iconize(bool iconize = true);
ecc08ead 108
dd9f7fea 109 // return True if the frame is maximized
ecc08ead
RD
110 virtual bool IsMaximized() const;
111
4a983d2c
RD
112 // return true if the frame is always maximized
113 // due to native guidelines or current policy
114 virtual bool IsAlwaysMaximized() const;
115
dd9f7fea 116 // return True if the frame is iconized
ecc08ead
RD
117 virtual bool IsIconized() const;
118
119 // get the frame icon
c5943253 120 wxIcon GetIcon() const;
ecc08ead
RD
121
122 // set the frame icon
123 virtual void SetIcon(const wxIcon& icon);
124
0e9b78ce 125 // set the frame icons
5cf1cb10 126 virtual void SetIcons(const wxIconBundle& icons);
ecc08ead
RD
127
128 // maximize the window to cover entire screen
129 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
130
dd9f7fea 131 // return True if the frame is in fullscreen mode
ecc08ead
RD
132 virtual bool IsFullScreen() const;
133
134 virtual void SetTitle(const wxString& title);
135 virtual wxString GetTitle() const;
1542ea39 136
55811cde
RD
137 // enable/disable close button [x]
138 virtual bool EnableCloseButton(bool enable );
139
1542ea39 140 // Set the shape of the window to the given region.
5cf1cb10
DS
141 // Returns True if the platform supports this feature
142 // (and the operation is successful.)
1542ea39
RD
143 virtual bool SetShape(const wxRegion& region);
144
5cf1cb10
DS
145 // Attracts the users attention to this window if the application is inactive
146 // (should be called when a background event occurs)
e51483b1
RD
147 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
148
2e5cc335
RD
149 // Is this the active frame (highlighted in the taskbar)?
150 virtual bool IsActive();
5cf1cb10 151
a212b779 152#ifdef __WXMAC__
f355f03e
RD
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 }
5cf1cb10 163 bool MacGetMetalAppearance() const;
3e98bb2a 164#else
5cf1cb10
DS
165 %extend
166 {
3e98bb2a
RD
167 // TODO: Should they raise not implemented or just NOP???
168 void MacSetMetalAppearance( bool on ) { /*wxPyRaiseNotImplemented();*/ }
169 bool MacGetMetalAppearance() const { /*wxPyRaiseNotImplemented();*/ return false; }
170 }
a212b779 171#endif
51941b48
RD
172
173 DocDeclStr(
174 void , CenterOnScreen(int dir = wxBOTH),
175 "Center the window on screen", "");
176 %pythoncode { CentreOnScreen = CenterOnScreen }
50f3c41d 177
6aaca5ba
RD
178
179 DocDeclStr(
180 virtual wxWindow *, GetDefaultItem() const,
181 "Get the default child of this parent, i.e. the one which is activated
182by 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
994453b8
RD
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`");
ecc08ead
RD
200};
201
ecc08ead 202
d14a1e28
RD
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.
ecc08ead 212
ab1f7d2a
RD
213MustHaveApp(wxFrame);
214
5cf1cb10
DS
215class wxFrame : public wxTopLevelWindow
216{
9c039d08 217public:
2b9048c5
RD
218 %pythonAppend wxFrame "self._setOORInfo(self)"
219 %pythonAppend wxFrame() ""
b39c3fa0 220 %typemap(out) wxFrame*; // turn off this typemap
d14a1e28 221
5cf1cb10
DS
222 wxFrame(wxWindow* parent,
223 const wxWindowID id = -1,
d5573410 224 const wxString& title = wxPyEmptyString,
b68dc582
RD
225 const wxPoint& pos = wxDefaultPosition,
226 const wxSize& size = wxDefaultSize,
9c039d08 227 long style = wxDEFAULT_FRAME_STYLE,
137b5242 228 const wxString& name = wxPyFrameNameStr);
1b8c7ba6 229 %RenameCtor(PreFrame, wxFrame());
9c039d08 230
b39c3fa0
RD
231 // Turn it back on again
232 %typemap(out) wxFrame* { $result = wxPyMake_wxObject($1, $owner); }
233
5cf1cb10
DS
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);
0122b7e3 241
d14a1e28
RD
242 // frame state
243 // -----------
ecc08ead 244
d14a1e28
RD
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
5cf1cb10
DS
249 // sends a size event to the window using its current size:
250 // this has a side effect of refreshing the window layout
705b61cc 251 virtual void SendSizeEvent();
d14a1e28 252
d14a1e28
RD
253 // menu bar functions
254 // ------------------
255
256 virtual void SetMenuBar(wxMenuBar *menubar);
257 virtual wxMenuBar *GetMenuBar() const;
ecc08ead 258
dd9f7fea 259 // process menu command: returns True if processed
d14a1e28
RD
260 bool ProcessCommand(int winid);
261 %pythoncode { Command = ProcessCommand }
262
d14a1e28
RD
263 // status bar functions
264 // --------------------
265
266 // create the main status bar by calling OnCreateStatusBar()
267 virtual wxStatusBar* CreateStatusBar(int number = 1,
69d81895 268 long style = wxDEFAULT_STATUSBAR_STYLE,
d14a1e28
RD
269 wxWindowID winid = 0,
270 const wxString& name = wxPyStatusLineNameStr);
5cf1cb10 271
d14a1e28
RD
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);
ecc08ead
RD
278
279 // get the main status bar
d14a1e28 280 virtual wxStatusBar *GetStatusBar() const;
ecc08ead
RD
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);
5cf1cb10 287 virtual void SetStatusWidths(int widths, const int* widths_field); // uses typemap above
94e36a51
RD
288 void PushStatusText(const wxString &text, int number = 0);
289 void PopStatusText(int number = 0);
290
94e36a51
RD
291 // set the status bar pane the help will be shown in
292 void SetStatusBarPane(int n);
293 int GetStatusBarPane() const;
ecc08ead 294
d14a1e28
RD
295 // toolbar functions
296 // -----------------
297
298 // create main toolbar bycalling OnCreateToolBar()
299 virtual wxToolBar* CreateToolBar(long style = -1,
300 wxWindowID winid = -1,
137b5242 301 const wxString& name = wxPyToolBarNameStr);
5cf1cb10 302
d14a1e28
RD
303// TODO: with directors?
304// // return a new toolbar
305// virtual wxToolBar *OnCreateToolBar(long style,
306// wxWindowID winid,
307// const wxString& name );
ecc08ead
RD
308
309 // get/set the main toolbar
d14a1e28
RD
310 virtual wxToolBar *GetToolBar() const;
311 virtual void SetToolBar(wxToolBar *toolbar);
ecc08ead 312
dd9f7fea
RD
313 // show help text (typically in the statusbar); show is False
314 // if you are hiding the help, True otherwise
d14a1e28 315 virtual void DoGiveHelp(const wxString& text, bool show);
3ef86e32 316
3ef86e32
RD
317 // send wxUpdateUIEvents for all menu items in the menubar,
318 // or just for menu if non-NULL
319 void DoMenuUpdates(wxMenu* menu = NULL);
880715c9
RD
320
321 static wxVisualAttributes
322 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
42e2bbb9
RD
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`");
9c039d08
RD
328};
329
ecc08ead 330//---------------------------------------------------------------------------
d14a1e28 331%newgroup
ecc08ead 332
ab1f7d2a
RD
333MustHaveApp(wxDialog);
334
5cf1cb10
DS
335class wxDialog : public wxTopLevelWindow
336{
ecc08ead 337public:
1631143c
RD
338 enum
339 {
340 // all flags allowed in wxDialogBase::CreateButtonSizer()
5cf1cb10 341 ButtonSizerFlags = wxOK | wxCANCEL | wxYES | wxNO | wxHELP | wxNO_DEFAULT
1631143c
RD
342 };
343
2b9048c5
RD
344 %pythonAppend wxDialog "self._setOORInfo(self)"
345 %pythonAppend wxDialog() ""
b39c3fa0 346 %typemap(out) wxDialog*; // turn off this typemap
d14a1e28 347
ecc08ead 348 wxDialog(wxWindow* parent,
5cf1cb10 349 const wxWindowID id = -1,
d5573410 350 const wxString& title = wxPyEmptyString,
ecc08ead
RD
351 const wxPoint& pos = wxDefaultPosition,
352 const wxSize& size = wxDefaultSize,
353 long style = wxDEFAULT_DIALOG_STYLE,
137b5242 354 const wxString& name = wxPyDialogNameStr);
1b8c7ba6 355 %RenameCtor(PreDialog, wxDialog());
ecc08ead 356
b39c3fa0
RD
357 // Turn it back on again
358 %typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); }
359
ecc08ead 360 bool Create(wxWindow* parent,
5cf1cb10 361 const wxWindowID id = -1,
d5573410 362 const wxString& title = wxPyEmptyString,
ecc08ead
RD
363 const wxPoint& pos = wxDefaultPosition,
364 const wxSize& size = wxDefaultSize,
365 long style = wxDEFAULT_DIALOG_STYLE,
137b5242 366 const wxString& name = wxPyDialogNameStr);
ecc08ead 367
5cf1cb10 368 // the modal dialogs have a return code - usually the ID of the last
d14a1e28 369 // pressed button
705b61cc
RD
370 void SetReturnCode(int returnCode);
371 int GetReturnCode() const;
ecc08ead 372
b58d5e2d
RD
373 // Set the identifier for the affirmative button: this button will close
374 // the dialog after validating data and calling TransferDataFromWindow()
99fbb25b
RD
375 void SetAffirmativeId(int affirmativeId);
376 int GetAffirmativeId() const;
377
b58d5e2d
RD
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
99fbb25b
RD
382 void SetEscapeId(int escapeId);
383 int GetEscapeId() const;
384
d14a1e28
RD
385 // splits text up at newlines and places the
386 // lines into a vertical wxBoxSizer
9283228f 387 wxSizer* CreateTextSizer( const wxString &message );
ecc08ead 388
76612558
RD
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
9283228f 407 wxStdDialogButtonSizer* CreateStdDialogButtonSizer( long flags );
ecc08ead 408
5cf1cb10 409 //void SetModal( bool flag );
f87da722
RD
410
411 // is the dialog in modal state right now?
d14a1e28
RD
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);
880715c9
RD
420
421 static wxVisualAttributes
422 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
0eae5d09
RD
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`");
d14a1e28 427};
ecc08ead 428
9c039d08 429//---------------------------------------------------------------------------
d14a1e28
RD
430%newgroup
431
39dddf28
RD
432%{
433#define wxDEFAULT_MINIFRAME_STYLE wxCAPTION | wxRESIZE_BORDER | wxTINY_CAPTION_HORIZ
434%}
435
436enum {
437 wxDEFAULT_MINIFRAME_STYLE
438};
439
9c039d08 440
ab1f7d2a
RD
441MustHaveApp(wxMiniFrame);
442
5cf1cb10
DS
443class wxMiniFrame : public wxFrame
444{
9c039d08 445public:
2b9048c5
RD
446 %pythonAppend wxMiniFrame "self._setOORInfo(self)"
447 %pythonAppend wxMiniFrame() ""
d14a1e28 448
5cf1cb10
DS
449 wxMiniFrame(wxWindow* parent,
450 const wxWindowID id = -1,
451 const wxString& title = wxPyEmptyString,
452 const wxPoint& pos = wxDefaultPosition,
453 const wxSize& size = wxDefaultSize,
39dddf28 454 long style = wxDEFAULT_MINIFRAME_STYLE,
5cf1cb10 455 const wxString& name = wxPyFrameNameStr);
1b8c7ba6 456 %RenameCtor(PreMiniFrame, wxMiniFrame());
9c039d08 457
5cf1cb10
DS
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,
39dddf28 463 long style = wxDEFAULT_MINIFRAME_STYLE,
5cf1cb10 464 const wxString& name = wxPyFrameNameStr);
9c039d08 465};
b8b8dda7
RD
466
467
468//---------------------------------------------------------------------------
d14a1e28
RD
469%newgroup
470
b8b8dda7 471
5cf1cb10
DS
472enum
473{
b5a5d647
RD
474 wxSPLASH_CENTRE_ON_PARENT,
475 wxSPLASH_CENTRE_ON_SCREEN,
476 wxSPLASH_NO_CENTRE,
477 wxSPLASH_TIMEOUT,
478 wxSPLASH_NO_TIMEOUT,
479};
480
481
ab1f7d2a
RD
482MustHaveApp(wxSplashScreenWindow);
483
b5a5d647
RD
484class wxSplashScreenWindow: public wxWindow
485{
486public:
2b9048c5 487 %pythonAppend wxSplashScreenWindow "self._setOORInfo(self)"
d14a1e28 488
b5a5d647 489 wxSplashScreenWindow(const wxBitmap& bitmap,
5cf1cb10
DS
490 wxWindow* parent,
491 wxWindowID id,
492 const wxPoint& pos = wxDefaultPosition,
493 const wxSize& size = wxDefaultSize,
494 long style = wxNO_BORDER);
b5a5d647
RD
495
496 void SetBitmap(const wxBitmap& bitmap);
497 wxBitmap& GetBitmap();
7012bb9f
RD
498
499 %property(Bitmap, GetBitmap, SetBitmap, doc="See `GetBitmap` and `SetBitmap`");
b5a5d647
RD
500};
501
502
ab1f7d2a
RD
503MustHaveApp(wxSplashScreen);
504
5cf1cb10
DS
505class wxSplashScreen : public wxFrame
506{
b5a5d647 507public:
2b9048c5 508 %pythonAppend wxSplashScreen "self._setOORInfo(self)"
d14a1e28 509
5cf1cb10
DS
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);
b5a5d647
RD
517
518 long GetSplashStyle() const;
519 wxSplashScreenWindow* GetSplashWindow() const;
520 int GetTimeout() const;
7012bb9f
RD
521
522 %property(SplashStyle, GetSplashStyle, doc="See `GetSplashStyle`");
523 %property(SplashWindow, GetSplashWindow, doc="See `GetSplashWindow`");
524 %property(Timeout, GetTimeout, doc="See `GetTimeout`");
b5a5d647
RD
525};
526
527
528//---------------------------------------------------------------------------