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