]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_toplvl.i
Adapt to some wxDC methods becoming protected
[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
RD
132
133 // Set the shape of the window to the given region.
5cf1cb10
DS
134 // Returns True if the platform supports this feature
135 // (and the operation is successful.)
1542ea39
RD
136 virtual bool SetShape(const wxRegion& region);
137
5cf1cb10
DS
138 // Attracts the users attention to this window if the application is inactive
139 // (should be called when a background event occurs)
e51483b1
RD
140 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
141
2e5cc335
RD
142 // Is this the active frame (highlighted in the taskbar)?
143 virtual bool IsActive();
5cf1cb10 144
a212b779 145#ifdef __WXMAC__
f355f03e
RD
146 %extend {
147 void MacSetMetalAppearance( bool on ) {
148 int style = self->GetExtraStyle();
149 if ( on )
150 style |= wxFRAME_EX_METAL;
151 else
152 style &= ~wxFRAME_EX_METAL;
153 self->SetExtraStyle(style);
154 }
155 }
5cf1cb10 156 bool MacGetMetalAppearance() const;
3e98bb2a 157#else
5cf1cb10
DS
158 %extend
159 {
3e98bb2a
RD
160 // TODO: Should they raise not implemented or just NOP???
161 void MacSetMetalAppearance( bool on ) { /*wxPyRaiseNotImplemented();*/ }
162 bool MacGetMetalAppearance() const { /*wxPyRaiseNotImplemented();*/ return false; }
163 }
a212b779 164#endif
51941b48
RD
165
166 DocDeclStr(
167 void , CenterOnScreen(int dir = wxBOTH),
168 "Center the window on screen", "");
169 %pythoncode { CentreOnScreen = CenterOnScreen }
50f3c41d
RD
170
171#ifdef __WXMSW__
172 bool EnableCloseButton(bool enable = true);
173#else
174 %extend {
175 bool EnableCloseButton(bool enable = true) { return false; }
176 }
177#endif
178
07880314
RD
179 virtual bool SetTransparent(byte alpha);
180 virtual bool CanSetTransparent();
50f3c41d 181
6aaca5ba
RD
182
183
184 DocDeclStr(
185 virtual wxWindow *, GetDefaultItem() const,
186 "Get the default child of this parent, i.e. the one which is activated
187by pressing <Enter> such as the OK button on a wx.Dialog.", "");
188
189 DocDeclStr(
190 virtual wxWindow *, SetDefaultItem(wxWindow * child),
191 "Set this child as default, return the old default.", "");
192
193 DocDeclStr(
194 virtual void , SetTmpDefaultItem(wxWindow * win),
195 "Set this child as temporary default", "");
196
197 DocDeclStr(
198 virtual wxWindow *, GetTmpDefaultItem() const,
199 "Return the temporary default item, which can be None.", "");
200
ecc08ead
RD
201};
202
ecc08ead 203
d14a1e28
RD
204//---------------------------------------------------------------------------
205%newgroup
206
207// wxFrame is a top-level window with optional menubar, statusbar and toolbar
208//
209// For each of *bars, a frame may have several of them, but only one is
210// managed by the frame, i.e. resized/moved when the frame is and whose size
211// is accounted for in client size calculations - all others should be taken
212// care of manually.
ecc08ead 213
ab1f7d2a
RD
214MustHaveApp(wxFrame);
215
5cf1cb10
DS
216class wxFrame : public wxTopLevelWindow
217{
9c039d08 218public:
2b9048c5
RD
219 %pythonAppend wxFrame "self._setOORInfo(self)"
220 %pythonAppend wxFrame() ""
b39c3fa0 221 %typemap(out) wxFrame*; // turn off this typemap
d14a1e28 222
5cf1cb10
DS
223 wxFrame(wxWindow* parent,
224 const wxWindowID id = -1,
d5573410 225 const wxString& title = wxPyEmptyString,
b68dc582
RD
226 const wxPoint& pos = wxDefaultPosition,
227 const wxSize& size = wxDefaultSize,
9c039d08 228 long style = wxDEFAULT_FRAME_STYLE,
137b5242 229 const wxString& name = wxPyFrameNameStr);
1b8c7ba6 230 %RenameCtor(PreFrame, wxFrame());
9c039d08 231
b39c3fa0
RD
232 // Turn it back on again
233 %typemap(out) wxFrame* { $result = wxPyMake_wxObject($1, $owner); }
234
5cf1cb10
DS
235 bool Create(wxWindow* parent,
236 const wxWindowID id = -1,
237 const wxString& title = wxPyEmptyString,
238 const wxPoint& pos = wxDefaultPosition,
239 const wxSize& size = wxDefaultSize,
240 long style = wxDEFAULT_FRAME_STYLE,
241 const wxString& name = wxPyFrameNameStr);
0122b7e3 242
d14a1e28
RD
243 // frame state
244 // -----------
ecc08ead 245
d14a1e28
RD
246 // get the origin of the client area (which may be different from (0, 0)
247 // if the frame has a toolbar) in client coordinates
248 virtual wxPoint GetClientAreaOrigin() const;
249
5cf1cb10
DS
250 // sends a size event to the window using its current size:
251 // this has a side effect of refreshing the window layout
705b61cc 252 virtual void SendSizeEvent();
d14a1e28 253
d14a1e28
RD
254 // menu bar functions
255 // ------------------
256
257 virtual void SetMenuBar(wxMenuBar *menubar);
258 virtual wxMenuBar *GetMenuBar() const;
ecc08ead 259
dd9f7fea 260 // process menu command: returns True if processed
d14a1e28
RD
261 bool ProcessCommand(int winid);
262 %pythoncode { Command = ProcessCommand }
263
d14a1e28
RD
264 // status bar functions
265 // --------------------
266
267 // create the main status bar by calling OnCreateStatusBar()
268 virtual wxStatusBar* CreateStatusBar(int number = 1,
69d81895 269 long style = wxDEFAULT_STATUSBAR_STYLE,
d14a1e28
RD
270 wxWindowID winid = 0,
271 const wxString& name = wxPyStatusLineNameStr);
5cf1cb10 272
d14a1e28
RD
273// TODO: with directors?
274// // return a new status bar
275// virtual wxStatusBar *OnCreateStatusBar(int number,
276// long style,
277// wxWindowID winid,
278// const wxString& name);
ecc08ead
RD
279
280 // get the main status bar
d14a1e28 281 virtual wxStatusBar *GetStatusBar() const;
ecc08ead
RD
282
283 // sets the main status bar
284 void SetStatusBar(wxStatusBar *statBar);
285
286 // forward these to status bar
287 virtual void SetStatusText(const wxString &text, int number = 0);
5cf1cb10 288 virtual void SetStatusWidths(int widths, const int* widths_field); // uses typemap above
94e36a51
RD
289 void PushStatusText(const wxString &text, int number = 0);
290 void PopStatusText(int number = 0);
291
94e36a51
RD
292 // set the status bar pane the help will be shown in
293 void SetStatusBarPane(int n);
294 int GetStatusBarPane() const;
ecc08ead 295
d14a1e28
RD
296 // toolbar functions
297 // -----------------
298
299 // create main toolbar bycalling OnCreateToolBar()
300 virtual wxToolBar* CreateToolBar(long style = -1,
301 wxWindowID winid = -1,
137b5242 302 const wxString& name = wxPyToolBarNameStr);
5cf1cb10 303
d14a1e28
RD
304// TODO: with directors?
305// // return a new toolbar
306// virtual wxToolBar *OnCreateToolBar(long style,
307// wxWindowID winid,
308// const wxString& name );
ecc08ead
RD
309
310 // get/set the main toolbar
d14a1e28
RD
311 virtual wxToolBar *GetToolBar() const;
312 virtual void SetToolBar(wxToolBar *toolbar);
ecc08ead 313
dd9f7fea
RD
314 // show help text (typically in the statusbar); show is False
315 // if you are hiding the help, True otherwise
d14a1e28 316 virtual void DoGiveHelp(const wxString& text, bool show);
3ef86e32 317
3ef86e32
RD
318 // send wxUpdateUIEvents for all menu items in the menubar,
319 // or just for menu if non-NULL
320 void DoMenuUpdates(wxMenu* menu = NULL);
880715c9
RD
321
322 static wxVisualAttributes
323 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
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
99fbb25b
RD
369 // The identifier for the affirmative button
370 void SetAffirmativeId(int affirmativeId);
371 int GetAffirmativeId() const;
372
373 // Identifier for Esc key translation
374 void SetEscapeId(int escapeId);
375 int GetEscapeId() const;
376
d14a1e28
RD
377 // splits text up at newlines and places the
378 // lines into a vertical wxBoxSizer
9283228f 379 wxSizer* CreateTextSizer( const wxString &message );
ecc08ead 380
d14a1e28 381 // places buttons into a horizontal wxBoxSizer
1631143c
RD
382 wxSizer* CreateButtonSizer( long flags,
383 bool separated = false,
5cf1cb10 384 wxCoord distance = 0 );
9283228f 385 wxStdDialogButtonSizer* CreateStdDialogButtonSizer( long flags );
ecc08ead 386
5cf1cb10 387 //void SetModal( bool flag );
f87da722
RD
388
389 // is the dialog in modal state right now?
d14a1e28
RD
390 virtual bool IsModal() const;
391
392 // Shows the dialog and starts a nested event loop that returns when
393 // EndModal is called.
394 virtual int ShowModal();
395
396 // may be called to terminate the dialog with the given return code
397 virtual void EndModal(int retCode);
880715c9
RD
398
399 static wxVisualAttributes
400 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
d14a1e28 401};
ecc08ead 402
9c039d08 403//---------------------------------------------------------------------------
d14a1e28
RD
404%newgroup
405
9c039d08 406
ab1f7d2a
RD
407MustHaveApp(wxMiniFrame);
408
5cf1cb10
DS
409class wxMiniFrame : public wxFrame
410{
9c039d08 411public:
2b9048c5
RD
412 %pythonAppend wxMiniFrame "self._setOORInfo(self)"
413 %pythonAppend wxMiniFrame() ""
d14a1e28 414
5cf1cb10
DS
415 wxMiniFrame(wxWindow* parent,
416 const wxWindowID id = -1,
417 const wxString& title = wxPyEmptyString,
418 const wxPoint& pos = wxDefaultPosition,
419 const wxSize& size = wxDefaultSize,
420 long style = wxDEFAULT_FRAME_STYLE,
421 const wxString& name = wxPyFrameNameStr);
1b8c7ba6 422 %RenameCtor(PreMiniFrame, wxMiniFrame());
9c039d08 423
5cf1cb10
DS
424 bool Create(wxWindow* parent,
425 const wxWindowID id = -1,
426 const wxString& title = wxPyEmptyString,
427 const wxPoint& pos = wxDefaultPosition,
428 const wxSize& size = wxDefaultSize,
429 long style = wxDEFAULT_FRAME_STYLE,
430 const wxString& name = wxPyFrameNameStr);
9c039d08 431};
b8b8dda7
RD
432
433
434//---------------------------------------------------------------------------
d14a1e28
RD
435%newgroup
436
b8b8dda7 437
5cf1cb10
DS
438enum
439{
b5a5d647
RD
440 wxSPLASH_CENTRE_ON_PARENT,
441 wxSPLASH_CENTRE_ON_SCREEN,
442 wxSPLASH_NO_CENTRE,
443 wxSPLASH_TIMEOUT,
444 wxSPLASH_NO_TIMEOUT,
445};
446
447
ab1f7d2a
RD
448MustHaveApp(wxSplashScreenWindow);
449
b5a5d647
RD
450class wxSplashScreenWindow: public wxWindow
451{
452public:
2b9048c5 453 %pythonAppend wxSplashScreenWindow "self._setOORInfo(self)"
d14a1e28 454
b5a5d647 455 wxSplashScreenWindow(const wxBitmap& bitmap,
5cf1cb10
DS
456 wxWindow* parent,
457 wxWindowID id,
458 const wxPoint& pos = wxDefaultPosition,
459 const wxSize& size = wxDefaultSize,
460 long style = wxNO_BORDER);
b5a5d647
RD
461
462 void SetBitmap(const wxBitmap& bitmap);
463 wxBitmap& GetBitmap();
464};
465
466
ab1f7d2a
RD
467MustHaveApp(wxSplashScreen);
468
5cf1cb10
DS
469class wxSplashScreen : public wxFrame
470{
b5a5d647 471public:
2b9048c5 472 %pythonAppend wxSplashScreen "self._setOORInfo(self)"
d14a1e28 473
5cf1cb10
DS
474 wxSplashScreen(const wxBitmap& bitmap,
475 long splashStyle, int milliseconds,
476 wxWindow* parent,
477 wxWindowID id = -1,
478 const wxPoint& pos = wxDefaultPosition,
479 const wxSize& size = wxDefaultSize,
480 long style = wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP);
b5a5d647
RD
481
482 long GetSplashStyle() const;
483 wxSplashScreenWindow* GetSplashWindow() const;
484 int GetTimeout() const;
485};
486
487
488//---------------------------------------------------------------------------