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