1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG definitions for wxTopLevelWindow, wxFrame, wxDialog and etc.
7 // Created: 27-Aug-1998
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
18 MAKE_CONST_WXSTRING(FrameNameStr);
19 MAKE_CONST_WXSTRING(DialogNameStr);
20 MAKE_CONST_WXSTRING(StatusLineNameStr);
21 MAKE_CONST_WXSTRING(ToolBarNameStr);
23 //---------------------------------------------------------------------------
44 wxDEFAULT_FRAME_STYLE,
45 wxDEFAULT_DIALOG_STYLE,
48 wxFRAME_FLOAT_ON_PARENT,
49 wxFRAME_NO_WINDOW_MENU,
64 wxFRAME_EX_CONTEXTHELP,
65 wxDIALOG_EX_CONTEXTHELP,
71 wxFULLSCREEN_NOMENUBAR,
72 wxFULLSCREEN_NOTOOLBAR,
73 wxFULLSCREEN_NOSTATUSBAR,
74 wxFULLSCREEN_NOBORDER,
75 wxFULLSCREEN_NOCAPTION,
81 // Styles for RequestUserAttention
84 wxUSER_ATTENTION_INFO = 1,
85 wxUSER_ATTENTION_ERROR = 2
88 //---------------------------------------------------------------------------
90 class wxTopLevelWindow : public wxWindow
94 // No constructor as it can not be used directly from Python
96 // maximize = True => maximize, otherwise - restore
97 virtual void Maximize(bool maximize = true);
99 // undo Maximize() or Iconize()
100 virtual void Restore();
102 // iconize = True => iconize, otherwise - restore
103 virtual void Iconize(bool iconize = true);
105 // return True if the frame is maximized
106 virtual bool IsMaximized() const;
108 // return true if the frame is always maximized
109 // due to native guidelines or current policy
110 virtual bool IsAlwaysMaximized() const;
112 // return True if the frame is iconized
113 virtual bool IsIconized() const;
115 // get the frame icon
116 wxIcon GetIcon() const;
118 // set the frame icon
119 virtual void SetIcon(const wxIcon& icon);
121 // set the frame icons
122 virtual void SetIcons(const wxIconBundle& icons);
124 // maximize the window to cover entire screen
125 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
127 // return True if the frame is in fullscreen mode
128 virtual bool IsFullScreen() const;
130 virtual void SetTitle(const wxString& title);
131 virtual wxString GetTitle() const;
133 // Set the shape of the window to the given region.
134 // Returns True if the platform supports this feature
135 // (and the operation is successful.)
136 virtual bool SetShape(const wxRegion& region);
138 // Attracts the users attention to this window if the application is inactive
139 // (should be called when a background event occurs)
140 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
142 // Is this the active frame (highlighted in the taskbar)?
143 virtual bool IsActive();
147 void MacSetMetalAppearance( bool on ) {
148 int style = self->GetExtraStyle();
150 style |= wxFRAME_EX_METAL;
152 style &= ~wxFRAME_EX_METAL;
153 self->SetExtraStyle(style);
156 bool MacGetMetalAppearance() const;
160 // TODO: Should they raise not implemented or just NOP???
161 void MacSetMetalAppearance( bool on ) { /*wxPyRaiseNotImplemented();*/ }
162 bool MacGetMetalAppearance() const { /*wxPyRaiseNotImplemented();*/ return false; }
167 void , CenterOnScreen(int dir = wxBOTH),
168 "Center the window on screen", "");
169 %pythoncode { CentreOnScreen = CenterOnScreen }
172 bool EnableCloseButton(bool enable = true);
175 bool EnableCloseButton(bool enable = true) { return false; }
182 virtual wxWindow *, GetDefaultItem() const,
183 "Get the default child of this parent, i.e. the one which is activated
184 by pressing <Enter> such as the OK button on a wx.Dialog.", "");
187 virtual wxWindow *, SetDefaultItem(wxWindow * child),
188 "Set this child as default, return the old default.", "");
191 virtual void , SetTmpDefaultItem(wxWindow * win),
192 "Set this child as temporary default", "");
195 virtual wxWindow *, GetTmpDefaultItem() const,
196 "Return the temporary default item, which can be None.", "");
201 //---------------------------------------------------------------------------
204 // wxFrame is a top-level window with optional menubar, statusbar and toolbar
206 // For each of *bars, a frame may have several of them, but only one is
207 // managed by the frame, i.e. resized/moved when the frame is and whose size
208 // is accounted for in client size calculations - all others should be taken
211 MustHaveApp(wxFrame);
213 class wxFrame : public wxTopLevelWindow
216 %pythonAppend wxFrame "self._setOORInfo(self)"
217 %pythonAppend wxFrame() ""
218 %typemap(out) wxFrame*; // turn off this typemap
220 wxFrame(wxWindow* parent,
221 const wxWindowID id = -1,
222 const wxString& title = wxPyEmptyString,
223 const wxPoint& pos = wxDefaultPosition,
224 const wxSize& size = wxDefaultSize,
225 long style = wxDEFAULT_FRAME_STYLE,
226 const wxString& name = wxPyFrameNameStr);
227 %RenameCtor(PreFrame, wxFrame());
229 // Turn it back on again
230 %typemap(out) wxFrame* { $result = wxPyMake_wxObject($1, $owner); }
232 bool Create(wxWindow* parent,
233 const wxWindowID id = -1,
234 const wxString& title = wxPyEmptyString,
235 const wxPoint& pos = wxDefaultPosition,
236 const wxSize& size = wxDefaultSize,
237 long style = wxDEFAULT_FRAME_STYLE,
238 const wxString& name = wxPyFrameNameStr);
243 // get the origin of the client area (which may be different from (0, 0)
244 // if the frame has a toolbar) in client coordinates
245 virtual wxPoint GetClientAreaOrigin() const;
247 // sends a size event to the window using its current size:
248 // this has a side effect of refreshing the window layout
249 virtual void SendSizeEvent();
251 // menu bar functions
252 // ------------------
254 virtual void SetMenuBar(wxMenuBar *menubar);
255 virtual wxMenuBar *GetMenuBar() const;
257 // process menu command: returns True if processed
258 bool ProcessCommand(int winid);
259 %pythoncode { Command = ProcessCommand }
261 // status bar functions
262 // --------------------
264 // create the main status bar by calling OnCreateStatusBar()
265 virtual wxStatusBar* CreateStatusBar(int number = 1,
266 long style = wxDEFAULT_STATUSBAR_STYLE,
267 wxWindowID winid = 0,
268 const wxString& name = wxPyStatusLineNameStr);
270 // TODO: with directors?
271 // // return a new status bar
272 // virtual wxStatusBar *OnCreateStatusBar(int number,
275 // const wxString& name);
277 // get the main status bar
278 virtual wxStatusBar *GetStatusBar() const;
280 // sets the main status bar
281 void SetStatusBar(wxStatusBar *statBar);
283 // forward these to status bar
284 virtual void SetStatusText(const wxString &text, int number = 0);
285 virtual void SetStatusWidths(int widths, const int* widths_field); // uses typemap above
286 void PushStatusText(const wxString &text, int number = 0);
287 void PopStatusText(int number = 0);
289 // set the status bar pane the help will be shown in
290 void SetStatusBarPane(int n);
291 int GetStatusBarPane() const;
296 // create main toolbar bycalling OnCreateToolBar()
297 virtual wxToolBar* CreateToolBar(long style = -1,
298 wxWindowID winid = -1,
299 const wxString& name = wxPyToolBarNameStr);
301 // TODO: with directors?
302 // // return a new toolbar
303 // virtual wxToolBar *OnCreateToolBar(long style,
305 // const wxString& name );
307 // get/set the main toolbar
308 virtual wxToolBar *GetToolBar() const;
309 virtual void SetToolBar(wxToolBar *toolbar);
311 // show help text (typically in the statusbar); show is False
312 // if you are hiding the help, True otherwise
313 virtual void DoGiveHelp(const wxString& text, bool show);
315 // send wxUpdateUIEvents for all menu items in the menubar,
316 // or just for menu if non-NULL
317 void DoMenuUpdates(wxMenu* menu = NULL);
319 static wxVisualAttributes
320 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
322 %property(MenuBar, GetMenuBar, SetMenuBar, doc="See `GetMenuBar` and `SetMenuBar`");
323 %property(StatusBar, GetStatusBar, SetStatusBar, doc="See `GetStatusBar` and `SetStatusBar`");
324 %property(StatusBarPane, GetStatusBarPane, SetStatusBarPane, doc="See `GetStatusBarPane` and `SetStatusBarPane`");
325 %property(ToolBar, GetToolBar, SetToolBar, doc="See `GetToolBar` and `SetToolBar`");
328 //---------------------------------------------------------------------------
331 MustHaveApp(wxDialog);
333 class wxDialog : public wxTopLevelWindow
338 // all flags allowed in wxDialogBase::CreateButtonSizer()
339 ButtonSizerFlags = wxOK | wxCANCEL | wxYES | wxNO | wxHELP | wxNO_DEFAULT
342 %pythonAppend wxDialog "self._setOORInfo(self)"
343 %pythonAppend wxDialog() ""
344 %typemap(out) wxDialog*; // turn off this typemap
346 wxDialog(wxWindow* parent,
347 const wxWindowID id = -1,
348 const wxString& title = wxPyEmptyString,
349 const wxPoint& pos = wxDefaultPosition,
350 const wxSize& size = wxDefaultSize,
351 long style = wxDEFAULT_DIALOG_STYLE,
352 const wxString& name = wxPyDialogNameStr);
353 %RenameCtor(PreDialog, wxDialog());
355 // Turn it back on again
356 %typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); }
358 bool Create(wxWindow* parent,
359 const wxWindowID id = -1,
360 const wxString& title = wxPyEmptyString,
361 const wxPoint& pos = wxDefaultPosition,
362 const wxSize& size = wxDefaultSize,
363 long style = wxDEFAULT_DIALOG_STYLE,
364 const wxString& name = wxPyDialogNameStr);
366 // the modal dialogs have a return code - usually the ID of the last
368 void SetReturnCode(int returnCode);
369 int GetReturnCode() const;
371 // Set the identifier for the affirmative button: this button will close
372 // the dialog after validating data and calling TransferDataFromWindow()
373 void SetAffirmativeId(int affirmativeId);
374 int GetAffirmativeId() const;
376 // Set identifier for Esc key translation: the button with this id will
377 // close the dialog without doing anything else; special value wxID_NONE
378 // means to not handle Esc at all while wxID_ANY means to map Esc to
379 // wxID_CANCEL if present and GetAffirmativeId() otherwise
380 void SetEscapeId(int escapeId);
381 int GetEscapeId() const;
383 // splits text up at newlines and places the
384 // lines into a vertical wxBoxSizer
385 wxSizer* CreateTextSizer( const wxString &message );
387 // places buttons into a horizontal wxBoxSizer
388 wxSizer* CreateButtonSizer( long flags,
389 bool separated = false,
390 wxCoord distance = 0 );
391 wxStdDialogButtonSizer* CreateStdDialogButtonSizer( long flags );
393 //void SetModal( bool flag );
395 // is the dialog in modal state right now?
396 virtual bool IsModal() const;
398 // Shows the dialog and starts a nested event loop that returns when
399 // EndModal is called.
400 virtual int ShowModal();
402 // may be called to terminate the dialog with the given return code
403 virtual void EndModal(int retCode);
405 static wxVisualAttributes
406 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
408 %property(AffirmativeId, GetAffirmativeId, SetAffirmativeId, doc="See `GetAffirmativeId` and `SetAffirmativeId`");
409 %property(EscapeId, GetEscapeId, SetEscapeId, doc="See `GetEscapeId` and `SetEscapeId`");
410 %property(ReturnCode, GetReturnCode, SetReturnCode, doc="See `GetReturnCode` and `SetReturnCode`");
413 //---------------------------------------------------------------------------
417 MustHaveApp(wxMiniFrame);
419 class wxMiniFrame : public wxFrame
422 %pythonAppend wxMiniFrame "self._setOORInfo(self)"
423 %pythonAppend wxMiniFrame() ""
425 wxMiniFrame(wxWindow* parent,
426 const wxWindowID id = -1,
427 const wxString& title = wxPyEmptyString,
428 const wxPoint& pos = wxDefaultPosition,
429 const wxSize& size = wxDefaultSize,
430 long style = wxDEFAULT_FRAME_STYLE,
431 const wxString& name = wxPyFrameNameStr);
432 %RenameCtor(PreMiniFrame, wxMiniFrame());
434 bool Create(wxWindow* parent,
435 const wxWindowID id = -1,
436 const wxString& title = wxPyEmptyString,
437 const wxPoint& pos = wxDefaultPosition,
438 const wxSize& size = wxDefaultSize,
439 long style = wxDEFAULT_FRAME_STYLE,
440 const wxString& name = wxPyFrameNameStr);
444 //---------------------------------------------------------------------------
450 wxSPLASH_CENTRE_ON_PARENT,
451 wxSPLASH_CENTRE_ON_SCREEN,
458 MustHaveApp(wxSplashScreenWindow);
460 class wxSplashScreenWindow: public wxWindow
463 %pythonAppend wxSplashScreenWindow "self._setOORInfo(self)"
465 wxSplashScreenWindow(const wxBitmap& bitmap,
468 const wxPoint& pos = wxDefaultPosition,
469 const wxSize& size = wxDefaultSize,
470 long style = wxNO_BORDER);
472 void SetBitmap(const wxBitmap& bitmap);
473 wxBitmap& GetBitmap();
477 MustHaveApp(wxSplashScreen);
479 class wxSplashScreen : public wxFrame
482 %pythonAppend wxSplashScreen "self._setOORInfo(self)"
484 wxSplashScreen(const wxBitmap& bitmap,
485 long splashStyle, int milliseconds,
488 const wxPoint& pos = wxDefaultPosition,
489 const wxSize& size = wxDefaultSize,
490 long style = wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP);
492 long GetSplashStyle() const;
493 wxSplashScreenWindow* GetSplashWindow() const;
494 int GetTimeout() const;
498 //---------------------------------------------------------------------------