]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_toplvl.i
Add AppendSubMenu
[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
dd9f7fea 103 // return True if the frame is iconized
ecc08ead
RD
104 virtual bool IsIconized() const;
105
106 // get the frame icon
c5943253 107 wxIcon GetIcon() const;
ecc08ead
RD
108
109 // set the frame icon
110 virtual void SetIcon(const wxIcon& icon);
111
0e9b78ce 112 // set the frame icons
5cf1cb10 113 virtual void SetIcons(const wxIconBundle& icons);
ecc08ead
RD
114
115 // maximize the window to cover entire screen
116 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
117
dd9f7fea 118 // return True if the frame is in fullscreen mode
ecc08ead
RD
119 virtual bool IsFullScreen() const;
120
121 virtual void SetTitle(const wxString& title);
122 virtual wxString GetTitle() const;
1542ea39
RD
123
124 // Set the shape of the window to the given region.
5cf1cb10
DS
125 // Returns True if the platform supports this feature
126 // (and the operation is successful.)
1542ea39
RD
127 virtual bool SetShape(const wxRegion& region);
128
5cf1cb10
DS
129 // Attracts the users attention to this window if the application is inactive
130 // (should be called when a background event occurs)
e51483b1
RD
131 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
132
2e5cc335
RD
133 // Is this the active frame (highlighted in the taskbar)?
134 virtual bool IsActive();
5cf1cb10 135
a212b779 136#ifdef __WXMAC__
f355f03e
RD
137 %extend {
138 void MacSetMetalAppearance( bool on ) {
139 int style = self->GetExtraStyle();
140 if ( on )
141 style |= wxFRAME_EX_METAL;
142 else
143 style &= ~wxFRAME_EX_METAL;
144 self->SetExtraStyle(style);
145 }
146 }
5cf1cb10 147 bool MacGetMetalAppearance() const;
3e98bb2a 148#else
5cf1cb10
DS
149 %extend
150 {
3e98bb2a
RD
151 // TODO: Should they raise not implemented or just NOP???
152 void MacSetMetalAppearance( bool on ) { /*wxPyRaiseNotImplemented();*/ }
153 bool MacGetMetalAppearance() const { /*wxPyRaiseNotImplemented();*/ return false; }
154 }
a212b779 155#endif
51941b48
RD
156
157 DocDeclStr(
158 void , CenterOnScreen(int dir = wxBOTH),
159 "Center the window on screen", "");
160 %pythoncode { CentreOnScreen = CenterOnScreen }
ecc08ead
RD
161};
162
ecc08ead 163
d14a1e28
RD
164//---------------------------------------------------------------------------
165%newgroup
166
167// wxFrame is a top-level window with optional menubar, statusbar and toolbar
168//
169// For each of *bars, a frame may have several of them, but only one is
170// managed by the frame, i.e. resized/moved when the frame is and whose size
171// is accounted for in client size calculations - all others should be taken
172// care of manually.
ecc08ead 173
ab1f7d2a
RD
174MustHaveApp(wxFrame);
175
5cf1cb10
DS
176class wxFrame : public wxTopLevelWindow
177{
9c039d08 178public:
2b9048c5
RD
179 %pythonAppend wxFrame "self._setOORInfo(self)"
180 %pythonAppend wxFrame() ""
b39c3fa0 181 %typemap(out) wxFrame*; // turn off this typemap
d14a1e28 182
5cf1cb10
DS
183 wxFrame(wxWindow* parent,
184 const wxWindowID id = -1,
d5573410 185 const wxString& title = wxPyEmptyString,
b68dc582
RD
186 const wxPoint& pos = wxDefaultPosition,
187 const wxSize& size = wxDefaultSize,
9c039d08 188 long style = wxDEFAULT_FRAME_STYLE,
137b5242 189 const wxString& name = wxPyFrameNameStr);
1b8c7ba6 190 %RenameCtor(PreFrame, wxFrame());
9c039d08 191
b39c3fa0
RD
192 // Turn it back on again
193 %typemap(out) wxFrame* { $result = wxPyMake_wxObject($1, $owner); }
194
5cf1cb10
DS
195 bool Create(wxWindow* parent,
196 const wxWindowID id = -1,
197 const wxString& title = wxPyEmptyString,
198 const wxPoint& pos = wxDefaultPosition,
199 const wxSize& size = wxDefaultSize,
200 long style = wxDEFAULT_FRAME_STYLE,
201 const wxString& name = wxPyFrameNameStr);
0122b7e3 202
d14a1e28
RD
203 // frame state
204 // -----------
ecc08ead 205
d14a1e28
RD
206 // get the origin of the client area (which may be different from (0, 0)
207 // if the frame has a toolbar) in client coordinates
208 virtual wxPoint GetClientAreaOrigin() const;
209
5cf1cb10
DS
210 // sends a size event to the window using its current size:
211 // this has a side effect of refreshing the window layout
705b61cc 212 virtual void SendSizeEvent();
d14a1e28 213
d14a1e28
RD
214 // menu bar functions
215 // ------------------
216
217 virtual void SetMenuBar(wxMenuBar *menubar);
218 virtual wxMenuBar *GetMenuBar() const;
ecc08ead 219
dd9f7fea 220 // process menu command: returns True if processed
d14a1e28
RD
221 bool ProcessCommand(int winid);
222 %pythoncode { Command = ProcessCommand }
223
d14a1e28
RD
224 // status bar functions
225 // --------------------
226
227 // create the main status bar by calling OnCreateStatusBar()
228 virtual wxStatusBar* CreateStatusBar(int number = 1,
69d81895 229 long style = wxDEFAULT_STATUSBAR_STYLE,
d14a1e28
RD
230 wxWindowID winid = 0,
231 const wxString& name = wxPyStatusLineNameStr);
5cf1cb10 232
d14a1e28
RD
233// TODO: with directors?
234// // return a new status bar
235// virtual wxStatusBar *OnCreateStatusBar(int number,
236// long style,
237// wxWindowID winid,
238// const wxString& name);
ecc08ead
RD
239
240 // get the main status bar
d14a1e28 241 virtual wxStatusBar *GetStatusBar() const;
ecc08ead
RD
242
243 // sets the main status bar
244 void SetStatusBar(wxStatusBar *statBar);
245
246 // forward these to status bar
247 virtual void SetStatusText(const wxString &text, int number = 0);
5cf1cb10 248 virtual void SetStatusWidths(int widths, const int* widths_field); // uses typemap above
94e36a51
RD
249 void PushStatusText(const wxString &text, int number = 0);
250 void PopStatusText(int number = 0);
251
94e36a51
RD
252 // set the status bar pane the help will be shown in
253 void SetStatusBarPane(int n);
254 int GetStatusBarPane() const;
ecc08ead 255
d14a1e28
RD
256 // toolbar functions
257 // -----------------
258
259 // create main toolbar bycalling OnCreateToolBar()
260 virtual wxToolBar* CreateToolBar(long style = -1,
261 wxWindowID winid = -1,
137b5242 262 const wxString& name = wxPyToolBarNameStr);
5cf1cb10 263
d14a1e28
RD
264// TODO: with directors?
265// // return a new toolbar
266// virtual wxToolBar *OnCreateToolBar(long style,
267// wxWindowID winid,
268// const wxString& name );
ecc08ead
RD
269
270 // get/set the main toolbar
d14a1e28
RD
271 virtual wxToolBar *GetToolBar() const;
272 virtual void SetToolBar(wxToolBar *toolbar);
ecc08ead 273
dd9f7fea
RD
274 // show help text (typically in the statusbar); show is False
275 // if you are hiding the help, True otherwise
d14a1e28 276 virtual void DoGiveHelp(const wxString& text, bool show);
3ef86e32 277
3ef86e32
RD
278 // send wxUpdateUIEvents for all menu items in the menubar,
279 // or just for menu if non-NULL
280 void DoMenuUpdates(wxMenu* menu = NULL);
880715c9
RD
281
282 static wxVisualAttributes
283 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
9c039d08
RD
284};
285
ecc08ead 286//---------------------------------------------------------------------------
d14a1e28 287%newgroup
ecc08ead 288
ab1f7d2a
RD
289MustHaveApp(wxDialog);
290
5cf1cb10
DS
291class wxDialog : public wxTopLevelWindow
292{
ecc08ead 293public:
1631143c
RD
294 enum
295 {
296 // all flags allowed in wxDialogBase::CreateButtonSizer()
5cf1cb10 297 ButtonSizerFlags = wxOK | wxCANCEL | wxYES | wxNO | wxHELP | wxNO_DEFAULT
1631143c
RD
298 };
299
2b9048c5
RD
300 %pythonAppend wxDialog "self._setOORInfo(self)"
301 %pythonAppend wxDialog() ""
b39c3fa0 302 %typemap(out) wxDialog*; // turn off this typemap
d14a1e28 303
ecc08ead 304 wxDialog(wxWindow* parent,
5cf1cb10 305 const wxWindowID id = -1,
d5573410 306 const wxString& title = wxPyEmptyString,
ecc08ead
RD
307 const wxPoint& pos = wxDefaultPosition,
308 const wxSize& size = wxDefaultSize,
309 long style = wxDEFAULT_DIALOG_STYLE,
137b5242 310 const wxString& name = wxPyDialogNameStr);
1b8c7ba6 311 %RenameCtor(PreDialog, wxDialog());
ecc08ead 312
b39c3fa0
RD
313 // Turn it back on again
314 %typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); }
315
ecc08ead 316 bool Create(wxWindow* parent,
5cf1cb10 317 const wxWindowID id = -1,
d5573410 318 const wxString& title = wxPyEmptyString,
ecc08ead
RD
319 const wxPoint& pos = wxDefaultPosition,
320 const wxSize& size = wxDefaultSize,
321 long style = wxDEFAULT_DIALOG_STYLE,
137b5242 322 const wxString& name = wxPyDialogNameStr);
ecc08ead 323
5cf1cb10 324 // the modal dialogs have a return code - usually the ID of the last
d14a1e28 325 // pressed button
705b61cc
RD
326 void SetReturnCode(int returnCode);
327 int GetReturnCode() const;
ecc08ead 328
99fbb25b
RD
329 // The identifier for the affirmative button
330 void SetAffirmativeId(int affirmativeId);
331 int GetAffirmativeId() const;
332
333 // Identifier for Esc key translation
334 void SetEscapeId(int escapeId);
335 int GetEscapeId() const;
336
d14a1e28
RD
337 // splits text up at newlines and places the
338 // lines into a vertical wxBoxSizer
9283228f 339 wxSizer* CreateTextSizer( const wxString &message );
ecc08ead 340
d14a1e28 341 // places buttons into a horizontal wxBoxSizer
1631143c
RD
342 wxSizer* CreateButtonSizer( long flags,
343 bool separated = false,
5cf1cb10 344 wxCoord distance = 0 );
9283228f 345 wxStdDialogButtonSizer* CreateStdDialogButtonSizer( long flags );
ecc08ead 346
5cf1cb10 347 //void SetModal( bool flag );
f87da722
RD
348
349 // is the dialog in modal state right now?
d14a1e28
RD
350 virtual bool IsModal() const;
351
352 // Shows the dialog and starts a nested event loop that returns when
353 // EndModal is called.
354 virtual int ShowModal();
355
356 // may be called to terminate the dialog with the given return code
357 virtual void EndModal(int retCode);
880715c9
RD
358
359 static wxVisualAttributes
360 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
d14a1e28 361};
ecc08ead 362
9c039d08 363//---------------------------------------------------------------------------
d14a1e28
RD
364%newgroup
365
9c039d08 366
ab1f7d2a
RD
367MustHaveApp(wxMiniFrame);
368
5cf1cb10
DS
369class wxMiniFrame : public wxFrame
370{
9c039d08 371public:
2b9048c5
RD
372 %pythonAppend wxMiniFrame "self._setOORInfo(self)"
373 %pythonAppend wxMiniFrame() ""
d14a1e28 374
5cf1cb10
DS
375 wxMiniFrame(wxWindow* parent,
376 const wxWindowID id = -1,
377 const wxString& title = wxPyEmptyString,
378 const wxPoint& pos = wxDefaultPosition,
379 const wxSize& size = wxDefaultSize,
380 long style = wxDEFAULT_FRAME_STYLE,
381 const wxString& name = wxPyFrameNameStr);
1b8c7ba6 382 %RenameCtor(PreMiniFrame, wxMiniFrame());
9c039d08 383
5cf1cb10
DS
384 bool Create(wxWindow* parent,
385 const wxWindowID id = -1,
386 const wxString& title = wxPyEmptyString,
387 const wxPoint& pos = wxDefaultPosition,
388 const wxSize& size = wxDefaultSize,
389 long style = wxDEFAULT_FRAME_STYLE,
390 const wxString& name = wxPyFrameNameStr);
9c039d08 391};
b8b8dda7
RD
392
393
394//---------------------------------------------------------------------------
d14a1e28
RD
395%newgroup
396
b8b8dda7 397
5cf1cb10
DS
398enum
399{
b5a5d647
RD
400 wxSPLASH_CENTRE_ON_PARENT,
401 wxSPLASH_CENTRE_ON_SCREEN,
402 wxSPLASH_NO_CENTRE,
403 wxSPLASH_TIMEOUT,
404 wxSPLASH_NO_TIMEOUT,
405};
406
407
ab1f7d2a
RD
408MustHaveApp(wxSplashScreenWindow);
409
b5a5d647
RD
410class wxSplashScreenWindow: public wxWindow
411{
412public:
2b9048c5 413 %pythonAppend wxSplashScreenWindow "self._setOORInfo(self)"
d14a1e28 414
b5a5d647 415 wxSplashScreenWindow(const wxBitmap& bitmap,
5cf1cb10
DS
416 wxWindow* parent,
417 wxWindowID id,
418 const wxPoint& pos = wxDefaultPosition,
419 const wxSize& size = wxDefaultSize,
420 long style = wxNO_BORDER);
b5a5d647
RD
421
422 void SetBitmap(const wxBitmap& bitmap);
423 wxBitmap& GetBitmap();
424};
425
426
ab1f7d2a
RD
427MustHaveApp(wxSplashScreen);
428
5cf1cb10
DS
429class wxSplashScreen : public wxFrame
430{
b5a5d647 431public:
2b9048c5 432 %pythonAppend wxSplashScreen "self._setOORInfo(self)"
d14a1e28 433
5cf1cb10
DS
434 wxSplashScreen(const wxBitmap& bitmap,
435 long splashStyle, int milliseconds,
436 wxWindow* parent,
437 wxWindowID id = -1,
438 const wxPoint& pos = wxDefaultPosition,
439 const wxSize& size = wxDefaultSize,
440 long style = wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP);
b5a5d647
RD
441
442 long GetSplashStyle() const;
443 wxSplashScreenWindow* GetSplashWindow() const;
444 int GetTimeout() const;
445};
446
447
448//---------------------------------------------------------------------------