]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_toplvl.i
fixed wxString iterators linked list corruption
[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
a7c987f9
RD
385 // Returns the parent to use for modal dialogs if the user did not specify it
386 // explicitly
387 wxWindow *GetParentForModalDialog(wxWindow *parent = NULL) const;
388
d14a1e28
RD
389 // splits text up at newlines and places the
390 // lines into a vertical wxBoxSizer
9283228f 391 wxSizer* CreateTextSizer( const wxString &message );
ecc08ead 392
76612558
RD
393
394 // returns a horizontal wxBoxSizer containing the given buttons
395 //
396 // notice that the returned sizer can be NULL if no buttons are put in the
397 // sizer (this mostly happens under smart phones and other atypical
398 // platforms which have hardware buttons replacing OK/Cancel and such)
399 %Rename(_CreateButtonSizer,
400 wxSizer* , CreateButtonSizer( long flags ));
401 %pythoncode {
402 def CreateButtonSizer(self, flags, *ignored):
403 return self._CreateButtonSizer(flags)
404 }
405
406 // returns the sizer containing CreateButtonSizer() below a separating
407 // static line for the platforms which use static lines for items
408 // separation (i.e. not Mac)
409 wxSizer *CreateSeparatedButtonSizer(long flags);
410
9283228f 411 wxStdDialogButtonSizer* CreateStdDialogButtonSizer( long flags );
ecc08ead 412
5cf1cb10 413 //void SetModal( bool flag );
f87da722
RD
414
415 // is the dialog in modal state right now?
d14a1e28
RD
416 virtual bool IsModal() const;
417
418 // Shows the dialog and starts a nested event loop that returns when
419 // EndModal is called.
420 virtual int ShowModal();
421
422 // may be called to terminate the dialog with the given return code
423 virtual void EndModal(int retCode);
880715c9
RD
424
425 static wxVisualAttributes
426 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
0eae5d09
RD
427
428 %property(AffirmativeId, GetAffirmativeId, SetAffirmativeId, doc="See `GetAffirmativeId` and `SetAffirmativeId`");
429 %property(EscapeId, GetEscapeId, SetEscapeId, doc="See `GetEscapeId` and `SetEscapeId`");
430 %property(ReturnCode, GetReturnCode, SetReturnCode, doc="See `GetReturnCode` and `SetReturnCode`");
d14a1e28 431};
ecc08ead 432
9c039d08 433//---------------------------------------------------------------------------
d14a1e28
RD
434%newgroup
435
39dddf28
RD
436%{
437#define wxDEFAULT_MINIFRAME_STYLE wxCAPTION | wxRESIZE_BORDER | wxTINY_CAPTION_HORIZ
438%}
439
440enum {
441 wxDEFAULT_MINIFRAME_STYLE
442};
443
9c039d08 444
ab1f7d2a
RD
445MustHaveApp(wxMiniFrame);
446
5cf1cb10
DS
447class wxMiniFrame : public wxFrame
448{
9c039d08 449public:
2b9048c5
RD
450 %pythonAppend wxMiniFrame "self._setOORInfo(self)"
451 %pythonAppend wxMiniFrame() ""
d14a1e28 452
5cf1cb10
DS
453 wxMiniFrame(wxWindow* parent,
454 const wxWindowID id = -1,
455 const wxString& title = wxPyEmptyString,
456 const wxPoint& pos = wxDefaultPosition,
457 const wxSize& size = wxDefaultSize,
39dddf28 458 long style = wxDEFAULT_MINIFRAME_STYLE,
5cf1cb10 459 const wxString& name = wxPyFrameNameStr);
1b8c7ba6 460 %RenameCtor(PreMiniFrame, wxMiniFrame());
9c039d08 461
5cf1cb10
DS
462 bool Create(wxWindow* parent,
463 const wxWindowID id = -1,
464 const wxString& title = wxPyEmptyString,
465 const wxPoint& pos = wxDefaultPosition,
466 const wxSize& size = wxDefaultSize,
39dddf28 467 long style = wxDEFAULT_MINIFRAME_STYLE,
5cf1cb10 468 const wxString& name = wxPyFrameNameStr);
9c039d08 469};
b8b8dda7
RD
470
471
472//---------------------------------------------------------------------------
d14a1e28
RD
473%newgroup
474
b8b8dda7 475
5cf1cb10
DS
476enum
477{
b5a5d647
RD
478 wxSPLASH_CENTRE_ON_PARENT,
479 wxSPLASH_CENTRE_ON_SCREEN,
480 wxSPLASH_NO_CENTRE,
481 wxSPLASH_TIMEOUT,
482 wxSPLASH_NO_TIMEOUT,
483};
484
485
ab1f7d2a
RD
486MustHaveApp(wxSplashScreenWindow);
487
b5a5d647
RD
488class wxSplashScreenWindow: public wxWindow
489{
490public:
2b9048c5 491 %pythonAppend wxSplashScreenWindow "self._setOORInfo(self)"
d14a1e28 492
b5a5d647 493 wxSplashScreenWindow(const wxBitmap& bitmap,
5cf1cb10
DS
494 wxWindow* parent,
495 wxWindowID id,
496 const wxPoint& pos = wxDefaultPosition,
497 const wxSize& size = wxDefaultSize,
498 long style = wxNO_BORDER);
b5a5d647
RD
499
500 void SetBitmap(const wxBitmap& bitmap);
501 wxBitmap& GetBitmap();
7012bb9f
RD
502
503 %property(Bitmap, GetBitmap, SetBitmap, doc="See `GetBitmap` and `SetBitmap`");
b5a5d647
RD
504};
505
506
ab1f7d2a
RD
507MustHaveApp(wxSplashScreen);
508
5cf1cb10
DS
509class wxSplashScreen : public wxFrame
510{
b5a5d647 511public:
2b9048c5 512 %pythonAppend wxSplashScreen "self._setOORInfo(self)"
d14a1e28 513
5cf1cb10
DS
514 wxSplashScreen(const wxBitmap& bitmap,
515 long splashStyle, int milliseconds,
516 wxWindow* parent,
517 wxWindowID id = -1,
518 const wxPoint& pos = wxDefaultPosition,
519 const wxSize& size = wxDefaultSize,
520 long style = wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP);
b5a5d647
RD
521
522 long GetSplashStyle() const;
523 wxSplashScreenWindow* GetSplashWindow() const;
524 int GetTimeout() const;
7012bb9f
RD
525
526 %property(SplashStyle, GetSplashStyle, doc="See `GetSplashStyle`");
527 %property(SplashWindow, GetSplashWindow, doc="See `GetSplashWindow`");
528 %property(Timeout, GetTimeout, doc="See `GetTimeout`");
b5a5d647
RD
529};
530
531
532//---------------------------------------------------------------------------