]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_toplvl.i
wxAUI: Support serialization of individual PaneInfo structures
[wxWidgets.git] / wxPython / src / _toplvl.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _toplvl.i
3 // Purpose: SWIG definitions for wxTopLevelWindow, wxFrame, wxDialog and etc.
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 27-Aug-1998
8 // RCS-ID: $Id$
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15
16 //---------------------------------------------------------------------------
17
18 MAKE_CONST_WXSTRING(FrameNameStr);
19 MAKE_CONST_WXSTRING(DialogNameStr);
20 MAKE_CONST_WXSTRING(StatusLineNameStr);
21 MAKE_CONST_WXSTRING(ToolBarNameStr);
22
23 //---------------------------------------------------------------------------
24 %newgroup
25
26 enum
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,
52 wxFRAME_DRAWER,
53
54 wxFRAME_EX_METAL,
55 wxDIALOG_EX_METAL,
56
57 // Obsolete
58 wxDIALOG_MODAL,
59 wxDIALOG_MODELESS,
60 wxUSER_COLOURS,
61 wxNO_3D,
62 };
63
64 enum
65 {
66 wxFULLSCREEN_NOMENUBAR,
67 wxFULLSCREEN_NOTOOLBAR,
68 wxFULLSCREEN_NOSTATUSBAR,
69 wxFULLSCREEN_NOBORDER,
70 wxFULLSCREEN_NOCAPTION,
71 wxFULLSCREEN_ALL,
72
73 wxTOPLEVEL_EX_DIALOG,
74 };
75
76 // Styles for RequestUserAttention
77 enum
78 {
79 wxUSER_ATTENTION_INFO = 1,
80 wxUSER_ATTENTION_ERROR = 2
81 };
82
83 //---------------------------------------------------------------------------
84
85 class wxTopLevelWindow : public wxWindow
86 {
87 public:
88
89 // No constructor as it can not be used directly from Python
90
91 // maximize = True => maximize, otherwise - restore
92 virtual void Maximize(bool maximize = true);
93
94 // undo Maximize() or Iconize()
95 virtual void Restore();
96
97 // iconize = True => iconize, otherwise - restore
98 virtual void Iconize(bool iconize = true);
99
100 // return True if the frame is maximized
101 virtual bool IsMaximized() const;
102
103 // return true if the frame is always maximized
104 // due to native guidelines or current policy
105 virtual bool IsAlwaysMaximized() const;
106
107 // return True if the frame is iconized
108 virtual bool IsIconized() const;
109
110 // get the frame icon
111 wxIcon GetIcon() const;
112
113 // set the frame icon
114 virtual void SetIcon(const wxIcon& icon);
115
116 // set the frame icons
117 virtual void SetIcons(const wxIconBundle& icons);
118
119 // maximize the window to cover entire screen
120 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
121
122 // return True if the frame is in fullscreen mode
123 virtual bool IsFullScreen() const;
124
125 virtual void SetTitle(const wxString& title);
126 virtual wxString GetTitle() const;
127
128 // Set the shape of the window to the given region.
129 // Returns True if the platform supports this feature
130 // (and the operation is successful.)
131 virtual bool SetShape(const wxRegion& region);
132
133 // Attracts the users attention to this window if the application is inactive
134 // (should be called when a background event occurs)
135 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
136
137 // Is this the active frame (highlighted in the taskbar)?
138 virtual bool IsActive();
139
140 #ifdef __WXMAC__
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 }
151 bool MacGetMetalAppearance() const;
152 #else
153 %extend
154 {
155 // TODO: Should they raise not implemented or just NOP???
156 void MacSetMetalAppearance( bool on ) { /*wxPyRaiseNotImplemented();*/ }
157 bool MacGetMetalAppearance() const { /*wxPyRaiseNotImplemented();*/ return false; }
158 }
159 #endif
160
161 DocDeclStr(
162 void , CenterOnScreen(int dir = wxBOTH),
163 "Center the window on screen", "");
164 %pythoncode { CentreOnScreen = CenterOnScreen }
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
174 virtual bool SetTransparent(byte alpha);
175 virtual bool CanSetTransparent();
176
177 };
178
179
180 //---------------------------------------------------------------------------
181 %newgroup
182
183 // wxFrame is a top-level window with optional menubar, statusbar and toolbar
184 //
185 // For each of *bars, a frame may have several of them, but only one is
186 // managed by the frame, i.e. resized/moved when the frame is and whose size
187 // is accounted for in client size calculations - all others should be taken
188 // care of manually.
189
190 MustHaveApp(wxFrame);
191
192 class wxFrame : public wxTopLevelWindow
193 {
194 public:
195 %pythonAppend wxFrame "self._setOORInfo(self)"
196 %pythonAppend wxFrame() ""
197 %typemap(out) wxFrame*; // turn off this typemap
198
199 wxFrame(wxWindow* parent,
200 const wxWindowID id = -1,
201 const wxString& title = wxPyEmptyString,
202 const wxPoint& pos = wxDefaultPosition,
203 const wxSize& size = wxDefaultSize,
204 long style = wxDEFAULT_FRAME_STYLE,
205 const wxString& name = wxPyFrameNameStr);
206 %RenameCtor(PreFrame, wxFrame());
207
208 // Turn it back on again
209 %typemap(out) wxFrame* { $result = wxPyMake_wxObject($1, $owner); }
210
211 bool Create(wxWindow* parent,
212 const wxWindowID id = -1,
213 const wxString& title = wxPyEmptyString,
214 const wxPoint& pos = wxDefaultPosition,
215 const wxSize& size = wxDefaultSize,
216 long style = wxDEFAULT_FRAME_STYLE,
217 const wxString& name = wxPyFrameNameStr);
218
219 // frame state
220 // -----------
221
222 // get the origin of the client area (which may be different from (0, 0)
223 // if the frame has a toolbar) in client coordinates
224 virtual wxPoint GetClientAreaOrigin() const;
225
226 // sends a size event to the window using its current size:
227 // this has a side effect of refreshing the window layout
228 virtual void SendSizeEvent();
229
230 // menu bar functions
231 // ------------------
232
233 virtual void SetMenuBar(wxMenuBar *menubar);
234 virtual wxMenuBar *GetMenuBar() const;
235
236 // process menu command: returns True if processed
237 bool ProcessCommand(int winid);
238 %pythoncode { Command = ProcessCommand }
239
240 // status bar functions
241 // --------------------
242
243 // create the main status bar by calling OnCreateStatusBar()
244 virtual wxStatusBar* CreateStatusBar(int number = 1,
245 long style = wxDEFAULT_STATUSBAR_STYLE,
246 wxWindowID winid = 0,
247 const wxString& name = wxPyStatusLineNameStr);
248
249 // TODO: with directors?
250 // // return a new status bar
251 // virtual wxStatusBar *OnCreateStatusBar(int number,
252 // long style,
253 // wxWindowID winid,
254 // const wxString& name);
255
256 // get the main status bar
257 virtual wxStatusBar *GetStatusBar() const;
258
259 // sets the main status bar
260 void SetStatusBar(wxStatusBar *statBar);
261
262 // forward these to status bar
263 virtual void SetStatusText(const wxString &text, int number = 0);
264 virtual void SetStatusWidths(int widths, const int* widths_field); // uses typemap above
265 void PushStatusText(const wxString &text, int number = 0);
266 void PopStatusText(int number = 0);
267
268 // set the status bar pane the help will be shown in
269 void SetStatusBarPane(int n);
270 int GetStatusBarPane() const;
271
272 // toolbar functions
273 // -----------------
274
275 // create main toolbar bycalling OnCreateToolBar()
276 virtual wxToolBar* CreateToolBar(long style = -1,
277 wxWindowID winid = -1,
278 const wxString& name = wxPyToolBarNameStr);
279
280 // TODO: with directors?
281 // // return a new toolbar
282 // virtual wxToolBar *OnCreateToolBar(long style,
283 // wxWindowID winid,
284 // const wxString& name );
285
286 // get/set the main toolbar
287 virtual wxToolBar *GetToolBar() const;
288 virtual void SetToolBar(wxToolBar *toolbar);
289
290 // show help text (typically in the statusbar); show is False
291 // if you are hiding the help, True otherwise
292 virtual void DoGiveHelp(const wxString& text, bool show);
293
294 // send wxUpdateUIEvents for all menu items in the menubar,
295 // or just for menu if non-NULL
296 void DoMenuUpdates(wxMenu* menu = NULL);
297
298 static wxVisualAttributes
299 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
300 };
301
302 //---------------------------------------------------------------------------
303 %newgroup
304
305 MustHaveApp(wxDialog);
306
307 class wxDialog : public wxTopLevelWindow
308 {
309 public:
310 enum
311 {
312 // all flags allowed in wxDialogBase::CreateButtonSizer()
313 ButtonSizerFlags = wxOK | wxCANCEL | wxYES | wxNO | wxHELP | wxNO_DEFAULT
314 };
315
316 %pythonAppend wxDialog "self._setOORInfo(self)"
317 %pythonAppend wxDialog() ""
318 %typemap(out) wxDialog*; // turn off this typemap
319
320 wxDialog(wxWindow* parent,
321 const wxWindowID id = -1,
322 const wxString& title = wxPyEmptyString,
323 const wxPoint& pos = wxDefaultPosition,
324 const wxSize& size = wxDefaultSize,
325 long style = wxDEFAULT_DIALOG_STYLE,
326 const wxString& name = wxPyDialogNameStr);
327 %RenameCtor(PreDialog, wxDialog());
328
329 // Turn it back on again
330 %typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); }
331
332 bool Create(wxWindow* parent,
333 const wxWindowID id = -1,
334 const wxString& title = wxPyEmptyString,
335 const wxPoint& pos = wxDefaultPosition,
336 const wxSize& size = wxDefaultSize,
337 long style = wxDEFAULT_DIALOG_STYLE,
338 const wxString& name = wxPyDialogNameStr);
339
340 // the modal dialogs have a return code - usually the ID of the last
341 // pressed button
342 void SetReturnCode(int returnCode);
343 int GetReturnCode() const;
344
345 // The identifier for the affirmative button
346 void SetAffirmativeId(int affirmativeId);
347 int GetAffirmativeId() const;
348
349 // Identifier for Esc key translation
350 void SetEscapeId(int escapeId);
351 int GetEscapeId() const;
352
353 // splits text up at newlines and places the
354 // lines into a vertical wxBoxSizer
355 wxSizer* CreateTextSizer( const wxString &message );
356
357 // places buttons into a horizontal wxBoxSizer
358 wxSizer* CreateButtonSizer( long flags,
359 bool separated = false,
360 wxCoord distance = 0 );
361 wxStdDialogButtonSizer* CreateStdDialogButtonSizer( long flags );
362
363 //void SetModal( bool flag );
364
365 // is the dialog in modal state right now?
366 virtual bool IsModal() const;
367
368 // Shows the dialog and starts a nested event loop that returns when
369 // EndModal is called.
370 virtual int ShowModal();
371
372 // may be called to terminate the dialog with the given return code
373 virtual void EndModal(int retCode);
374
375 static wxVisualAttributes
376 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
377 };
378
379 //---------------------------------------------------------------------------
380 %newgroup
381
382
383 MustHaveApp(wxMiniFrame);
384
385 class wxMiniFrame : public wxFrame
386 {
387 public:
388 %pythonAppend wxMiniFrame "self._setOORInfo(self)"
389 %pythonAppend wxMiniFrame() ""
390
391 wxMiniFrame(wxWindow* parent,
392 const wxWindowID id = -1,
393 const wxString& title = wxPyEmptyString,
394 const wxPoint& pos = wxDefaultPosition,
395 const wxSize& size = wxDefaultSize,
396 long style = wxDEFAULT_FRAME_STYLE,
397 const wxString& name = wxPyFrameNameStr);
398 %RenameCtor(PreMiniFrame, wxMiniFrame());
399
400 bool Create(wxWindow* parent,
401 const wxWindowID id = -1,
402 const wxString& title = wxPyEmptyString,
403 const wxPoint& pos = wxDefaultPosition,
404 const wxSize& size = wxDefaultSize,
405 long style = wxDEFAULT_FRAME_STYLE,
406 const wxString& name = wxPyFrameNameStr);
407 };
408
409
410 //---------------------------------------------------------------------------
411 %newgroup
412
413
414 enum
415 {
416 wxSPLASH_CENTRE_ON_PARENT,
417 wxSPLASH_CENTRE_ON_SCREEN,
418 wxSPLASH_NO_CENTRE,
419 wxSPLASH_TIMEOUT,
420 wxSPLASH_NO_TIMEOUT,
421 };
422
423
424 MustHaveApp(wxSplashScreenWindow);
425
426 class wxSplashScreenWindow: public wxWindow
427 {
428 public:
429 %pythonAppend wxSplashScreenWindow "self._setOORInfo(self)"
430
431 wxSplashScreenWindow(const wxBitmap& bitmap,
432 wxWindow* parent,
433 wxWindowID id,
434 const wxPoint& pos = wxDefaultPosition,
435 const wxSize& size = wxDefaultSize,
436 long style = wxNO_BORDER);
437
438 void SetBitmap(const wxBitmap& bitmap);
439 wxBitmap& GetBitmap();
440 };
441
442
443 MustHaveApp(wxSplashScreen);
444
445 class wxSplashScreen : public wxFrame
446 {
447 public:
448 %pythonAppend wxSplashScreen "self._setOORInfo(self)"
449
450 wxSplashScreen(const wxBitmap& bitmap,
451 long splashStyle, int milliseconds,
452 wxWindow* parent,
453 wxWindowID id = -1,
454 const wxPoint& pos = wxDefaultPosition,
455 const wxSize& size = wxDefaultSize,
456 long style = wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP);
457
458 long GetSplashStyle() const;
459 wxSplashScreenWindow* GetSplashWindow() const;
460 int GetTimeout() const;
461 };
462
463
464 //---------------------------------------------------------------------------