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