]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_toplvl.i
moved wxIcon implementation for ports where it's identical to wxBitmap to generic...
[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,
c430d0dc 56
447f48ba 57 // Obsolete
6cffbf02
RD
58 wxDIALOG_MODAL,
59 wxDIALOG_MODELESS,
60 wxUSER_COLOURS,
61 wxNO_3D,
447f48ba
RD
62};
63
d14a1e28
RD
64enum
65{
f6bcfd97
BP
66 wxFULLSCREEN_NOMENUBAR,
67 wxFULLSCREEN_NOTOOLBAR,
68 wxFULLSCREEN_NOSTATUSBAR,
69 wxFULLSCREEN_NOBORDER,
70 wxFULLSCREEN_NOCAPTION,
ecc08ead
RD
71 wxFULLSCREEN_ALL,
72
73 wxTOPLEVEL_EX_DIALOG,
f6bcfd97
BP
74};
75
e51483b1
RD
76// Styles for RequestUserAttention
77enum
78{
79 wxUSER_ATTENTION_INFO = 1,
80 wxUSER_ATTENTION_ERROR = 2
81};
f6bcfd97 82
d14a1e28 83//---------------------------------------------------------------------------
ecc08ead
RD
84
85class wxTopLevelWindow : public wxWindow
86{
87public:
ecc08ead 88
d14a1e28 89 // No constructor as it can not be used directly from Python
ecc08ead 90
dd9f7fea 91 // maximize = True => maximize, otherwise - restore
a72f4631 92 virtual void Maximize(bool maximize = true);
ecc08ead
RD
93
94 // undo Maximize() or Iconize()
95 virtual void Restore();
96
dd9f7fea 97 // iconize = True => iconize, otherwise - restore
a72f4631 98 virtual void Iconize(bool iconize = true);
ecc08ead 99
dd9f7fea 100 // return True if the frame is maximized
ecc08ead
RD
101 virtual bool IsMaximized() const;
102
4a983d2c
RD
103 // return true if the frame is always maximized
104 // due to native guidelines or current policy
105 virtual bool IsAlwaysMaximized() const;
106
dd9f7fea 107 // return True if the frame is iconized
ecc08ead
RD
108 virtual bool IsIconized() const;
109
110 // get the frame icon
c5943253 111 wxIcon GetIcon() const;
ecc08ead
RD
112
113 // set the frame icon
114 virtual void SetIcon(const wxIcon& icon);
115
0e9b78ce 116 // set the frame icons
5cf1cb10 117 virtual void SetIcons(const wxIconBundle& icons);
ecc08ead
RD
118
119 // maximize the window to cover entire screen
120 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
121
dd9f7fea 122 // return True if the frame is in fullscreen mode
ecc08ead
RD
123 virtual bool IsFullScreen() const;
124
125 virtual void SetTitle(const wxString& title);
126 virtual wxString GetTitle() const;
1542ea39
RD
127
128 // Set the shape of the window to the given region.
5cf1cb10
DS
129 // Returns True if the platform supports this feature
130 // (and the operation is successful.)
1542ea39
RD
131 virtual bool SetShape(const wxRegion& region);
132
5cf1cb10
DS
133 // Attracts the users attention to this window if the application is inactive
134 // (should be called when a background event occurs)
e51483b1
RD
135 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
136
2e5cc335
RD
137 // Is this the active frame (highlighted in the taskbar)?
138 virtual bool IsActive();
5cf1cb10 139
a212b779 140#ifdef __WXMAC__
f355f03e
RD
141 %extend {
142 void MacSetMetalAppearance( bool on ) {
143 int style = self->GetExtraStyle();
144 if ( on )
145 style |= wxFRAME_EX_METAL;
146 else
147 style &= ~wxFRAME_EX_METAL;
148 self->SetExtraStyle(style);
149 }
150 }
5cf1cb10 151 bool MacGetMetalAppearance() const;
3e98bb2a 152#else
5cf1cb10
DS
153 %extend
154 {
3e98bb2a
RD
155 // TODO: Should they raise not implemented or just NOP???
156 void MacSetMetalAppearance( bool on ) { /*wxPyRaiseNotImplemented();*/ }
157 bool MacGetMetalAppearance() const { /*wxPyRaiseNotImplemented();*/ return false; }
158 }
a212b779 159#endif
51941b48
RD
160
161 DocDeclStr(
162 void , CenterOnScreen(int dir = wxBOTH),
163 "Center the window on screen", "");
164 %pythoncode { CentreOnScreen = CenterOnScreen }
50f3c41d
RD
165
166#ifdef __WXMSW__
167 bool EnableCloseButton(bool enable = true);
168#else
169 %extend {
170 bool EnableCloseButton(bool enable = true) { return false; }
171 }
172#endif
173
07880314
RD
174 virtual bool SetTransparent(byte alpha);
175 virtual bool CanSetTransparent();
50f3c41d 176
6aaca5ba
RD
177
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
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);
9c039d08
RD
319};
320
ecc08ead 321//---------------------------------------------------------------------------
d14a1e28 322%newgroup
ecc08ead 323
ab1f7d2a
RD
324MustHaveApp(wxDialog);
325
5cf1cb10
DS
326class wxDialog : public wxTopLevelWindow
327{
ecc08ead 328public:
1631143c
RD
329 enum
330 {
331 // all flags allowed in wxDialogBase::CreateButtonSizer()
5cf1cb10 332 ButtonSizerFlags = wxOK | wxCANCEL | wxYES | wxNO | wxHELP | wxNO_DEFAULT
1631143c
RD
333 };
334
2b9048c5
RD
335 %pythonAppend wxDialog "self._setOORInfo(self)"
336 %pythonAppend wxDialog() ""
b39c3fa0 337 %typemap(out) wxDialog*; // turn off this typemap
d14a1e28 338
ecc08ead 339 wxDialog(wxWindow* parent,
5cf1cb10 340 const wxWindowID id = -1,
d5573410 341 const wxString& title = wxPyEmptyString,
ecc08ead
RD
342 const wxPoint& pos = wxDefaultPosition,
343 const wxSize& size = wxDefaultSize,
344 long style = wxDEFAULT_DIALOG_STYLE,
137b5242 345 const wxString& name = wxPyDialogNameStr);
1b8c7ba6 346 %RenameCtor(PreDialog, wxDialog());
ecc08ead 347
b39c3fa0
RD
348 // Turn it back on again
349 %typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); }
350
ecc08ead 351 bool Create(wxWindow* parent,
5cf1cb10 352 const wxWindowID id = -1,
d5573410 353 const wxString& title = wxPyEmptyString,
ecc08ead
RD
354 const wxPoint& pos = wxDefaultPosition,
355 const wxSize& size = wxDefaultSize,
356 long style = wxDEFAULT_DIALOG_STYLE,
137b5242 357 const wxString& name = wxPyDialogNameStr);
ecc08ead 358
5cf1cb10 359 // the modal dialogs have a return code - usually the ID of the last
d14a1e28 360 // pressed button
705b61cc
RD
361 void SetReturnCode(int returnCode);
362 int GetReturnCode() const;
ecc08ead 363
99fbb25b
RD
364 // The identifier for the affirmative button
365 void SetAffirmativeId(int affirmativeId);
366 int GetAffirmativeId() const;
367
368 // Identifier for Esc key translation
369 void SetEscapeId(int escapeId);
370 int GetEscapeId() const;
371
d14a1e28
RD
372 // splits text up at newlines and places the
373 // lines into a vertical wxBoxSizer
9283228f 374 wxSizer* CreateTextSizer( const wxString &message );
ecc08ead 375
d14a1e28 376 // places buttons into a horizontal wxBoxSizer
1631143c
RD
377 wxSizer* CreateButtonSizer( long flags,
378 bool separated = false,
5cf1cb10 379 wxCoord distance = 0 );
9283228f 380 wxStdDialogButtonSizer* CreateStdDialogButtonSizer( long flags );
ecc08ead 381
5cf1cb10 382 //void SetModal( bool flag );
f87da722
RD
383
384 // is the dialog in modal state right now?
d14a1e28
RD
385 virtual bool IsModal() const;
386
387 // Shows the dialog and starts a nested event loop that returns when
388 // EndModal is called.
389 virtual int ShowModal();
390
391 // may be called to terminate the dialog with the given return code
392 virtual void EndModal(int retCode);
880715c9
RD
393
394 static wxVisualAttributes
395 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
d14a1e28 396};
ecc08ead 397
9c039d08 398//---------------------------------------------------------------------------
d14a1e28
RD
399%newgroup
400
9c039d08 401
ab1f7d2a
RD
402MustHaveApp(wxMiniFrame);
403
5cf1cb10
DS
404class wxMiniFrame : public wxFrame
405{
9c039d08 406public:
2b9048c5
RD
407 %pythonAppend wxMiniFrame "self._setOORInfo(self)"
408 %pythonAppend wxMiniFrame() ""
d14a1e28 409
5cf1cb10
DS
410 wxMiniFrame(wxWindow* parent,
411 const wxWindowID id = -1,
412 const wxString& title = wxPyEmptyString,
413 const wxPoint& pos = wxDefaultPosition,
414 const wxSize& size = wxDefaultSize,
415 long style = wxDEFAULT_FRAME_STYLE,
416 const wxString& name = wxPyFrameNameStr);
1b8c7ba6 417 %RenameCtor(PreMiniFrame, wxMiniFrame());
9c039d08 418
5cf1cb10
DS
419 bool Create(wxWindow* parent,
420 const wxWindowID id = -1,
421 const wxString& title = wxPyEmptyString,
422 const wxPoint& pos = wxDefaultPosition,
423 const wxSize& size = wxDefaultSize,
424 long style = wxDEFAULT_FRAME_STYLE,
425 const wxString& name = wxPyFrameNameStr);
9c039d08 426};
b8b8dda7
RD
427
428
429//---------------------------------------------------------------------------
d14a1e28
RD
430%newgroup
431
b8b8dda7 432
5cf1cb10
DS
433enum
434{
b5a5d647
RD
435 wxSPLASH_CENTRE_ON_PARENT,
436 wxSPLASH_CENTRE_ON_SCREEN,
437 wxSPLASH_NO_CENTRE,
438 wxSPLASH_TIMEOUT,
439 wxSPLASH_NO_TIMEOUT,
440};
441
442
ab1f7d2a
RD
443MustHaveApp(wxSplashScreenWindow);
444
b5a5d647
RD
445class wxSplashScreenWindow: public wxWindow
446{
447public:
2b9048c5 448 %pythonAppend wxSplashScreenWindow "self._setOORInfo(self)"
d14a1e28 449
b5a5d647 450 wxSplashScreenWindow(const wxBitmap& bitmap,
5cf1cb10
DS
451 wxWindow* parent,
452 wxWindowID id,
453 const wxPoint& pos = wxDefaultPosition,
454 const wxSize& size = wxDefaultSize,
455 long style = wxNO_BORDER);
b5a5d647
RD
456
457 void SetBitmap(const wxBitmap& bitmap);
458 wxBitmap& GetBitmap();
459};
460
461
ab1f7d2a
RD
462MustHaveApp(wxSplashScreen);
463
5cf1cb10
DS
464class wxSplashScreen : public wxFrame
465{
b5a5d647 466public:
2b9048c5 467 %pythonAppend wxSplashScreen "self._setOORInfo(self)"
d14a1e28 468
5cf1cb10
DS
469 wxSplashScreen(const wxBitmap& bitmap,
470 long splashStyle, int milliseconds,
471 wxWindow* parent,
472 wxWindowID id = -1,
473 const wxPoint& pos = wxDefaultPosition,
474 const wxSize& size = wxDefaultSize,
475 long style = wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP);
b5a5d647
RD
476
477 long GetSplashStyle() const;
478 wxSplashScreenWindow* GetSplashWindow() const;
479 int GetTimeout() const;
480};
481
482
483//---------------------------------------------------------------------------