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 // enable/disable close button [x]
134 virtual bool EnableCloseButton(bool enable );
136 // Set the shape of the window to the given region.
137 // Returns True if the platform supports this feature
138 // (and the operation is successful.)
139 virtual bool SetShape(const wxRegion& region);
141 // Attracts the users attention to this window if the application is inactive
142 // (should be called when a background event occurs)
143 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
145 // Is this the active frame (highlighted in the taskbar)?
146 virtual bool IsActive();
150 void MacSetMetalAppearance( bool on ) {
151 int style = self->GetExtraStyle();
153 style |= wxFRAME_EX_METAL;
155 style &= ~wxFRAME_EX_METAL;
156 self->SetExtraStyle(style);
159 bool MacGetMetalAppearance() const;
163 // TODO: Should they raise not implemented or just NOP???
164 void MacSetMetalAppearance( bool on ) { /*wxPyRaiseNotImplemented();*/ }
165 bool MacGetMetalAppearance() const { /*wxPyRaiseNotImplemented();*/ return false; }
170 void , CenterOnScreen(int dir = wxBOTH),
171 "Center the window on screen", "");
172 %pythoncode { CentreOnScreen = CenterOnScreen }
176 virtual wxWindow *, GetDefaultItem() const,
177 "Get the default child of this parent, i.e. the one which is activated
178 by pressing <Enter> such as the OK button on a wx.Dialog.", "");
181 virtual wxWindow *, SetDefaultItem(wxWindow * child),
182 "Set this child as default, return the old default.", "");
185 virtual void , SetTmpDefaultItem(wxWindow * win),
186 "Set this child as temporary default", "");
189 virtual wxWindow *, GetTmpDefaultItem() const,
190 "Return the temporary default item, which can be None.", "");
192 %property(DefaultItem, GetDefaultItem, SetDefaultItem, doc="See `GetDefaultItem` and `SetDefaultItem`");
193 %property(Icon, GetIcon, SetIcon, doc="See `GetIcon` and `SetIcon`");
194 %property(Title, GetTitle, SetTitle, doc="See `GetTitle` and `SetTitle`");
195 %property(TmpDefaultItem, GetTmpDefaultItem, SetTmpDefaultItem, doc="See `GetTmpDefaultItem` and `SetTmpDefaultItem`");
199 //---------------------------------------------------------------------------
202 // wxFrame is a top-level window with optional menubar, statusbar and toolbar
204 // For each of *bars, a frame may have several of them, but only one is
205 // managed by the frame, i.e. resized/moved when the frame is and whose size
206 // is accounted for in client size calculations - all others should be taken
209 MustHaveApp(wxFrame);
211 class wxFrame : public wxTopLevelWindow
214 %pythonAppend wxFrame "self._setOORInfo(self)"
215 %pythonAppend wxFrame() ""
216 %typemap(out) wxFrame*; // turn off this typemap
218 wxFrame(wxWindow* parent,
219 const wxWindowID id = -1,
220 const wxString& title = wxPyEmptyString,
221 const wxPoint& pos = wxDefaultPosition,
222 const wxSize& size = wxDefaultSize,
223 long style = wxDEFAULT_FRAME_STYLE,
224 const wxString& name = wxPyFrameNameStr);
225 %RenameCtor(PreFrame, wxFrame());
227 // Turn it back on again
228 %typemap(out) wxFrame* { $result = wxPyMake_wxObject($1, $owner); }
230 bool Create(wxWindow* parent,
231 const wxWindowID id = -1,
232 const wxString& title = wxPyEmptyString,
233 const wxPoint& pos = wxDefaultPosition,
234 const wxSize& size = wxDefaultSize,
235 long style = wxDEFAULT_FRAME_STYLE,
236 const wxString& name = wxPyFrameNameStr);
241 // get the origin of the client area (which may be different from (0, 0)
242 // if the frame has a toolbar) in client coordinates
243 virtual wxPoint GetClientAreaOrigin() const;
245 // sends a size event to the window using its current size:
246 // this has a side effect of refreshing the window layout
247 virtual void SendSizeEvent();
249 // menu bar functions
250 // ------------------
252 virtual void SetMenuBar(wxMenuBar *menubar);
253 virtual wxMenuBar *GetMenuBar() const;
255 // process menu command: returns True if processed
256 bool ProcessCommand(int winid);
257 %pythoncode { Command = ProcessCommand }
259 // status bar functions
260 // --------------------
262 // create the main status bar by calling OnCreateStatusBar()
263 virtual wxStatusBar* CreateStatusBar(int number = 1,
264 long style = wxDEFAULT_STATUSBAR_STYLE,
265 wxWindowID winid = 0,
266 const wxString& name = wxPyStatusLineNameStr);
268 // TODO: with directors?
269 // // return a new status bar
270 // virtual wxStatusBar *OnCreateStatusBar(int number,
273 // const wxString& name);
275 // get the main status bar
276 virtual wxStatusBar *GetStatusBar() const;
278 // sets the main status bar
279 void SetStatusBar(wxStatusBar *statBar);
281 // forward these to status bar
282 virtual void SetStatusText(const wxString &text, int number = 0);
283 virtual void SetStatusWidths(int widths, const int* widths_field); // uses typemap above
284 void PushStatusText(const wxString &text, int number = 0);
285 void PopStatusText(int number = 0);
287 // set the status bar pane the help will be shown in
288 void SetStatusBarPane(int n);
289 int GetStatusBarPane() const;
294 // create main toolbar bycalling OnCreateToolBar()
295 virtual wxToolBar* CreateToolBar(long style = -1,
296 wxWindowID winid = -1,
297 const wxString& name = wxPyToolBarNameStr);
299 // TODO: with directors?
300 // // return a new toolbar
301 // virtual wxToolBar *OnCreateToolBar(long style,
303 // const wxString& name );
305 // get/set the main toolbar
306 virtual wxToolBar *GetToolBar() const;
307 virtual void SetToolBar(wxToolBar *toolbar);
309 // show help text (typically in the statusbar); show is False
310 // if you are hiding the help, True otherwise
311 virtual void DoGiveHelp(const wxString& text, bool show);
313 // send wxUpdateUIEvents for all menu items in the menubar,
314 // or just for menu if non-NULL
315 void DoMenuUpdates(wxMenu* menu = NULL);
317 static wxVisualAttributes
318 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
320 %property(MenuBar, GetMenuBar, SetMenuBar, doc="See `GetMenuBar` and `SetMenuBar`");
321 %property(StatusBar, GetStatusBar, SetStatusBar, doc="See `GetStatusBar` and `SetStatusBar`");
322 %property(StatusBarPane, GetStatusBarPane, SetStatusBarPane, doc="See `GetStatusBarPane` and `SetStatusBarPane`");
323 %property(ToolBar, GetToolBar, SetToolBar, doc="See `GetToolBar` and `SetToolBar`");
326 //---------------------------------------------------------------------------
329 MustHaveApp(wxDialog);
331 class wxDialog : public wxTopLevelWindow
336 // all flags allowed in wxDialogBase::CreateButtonSizer()
337 ButtonSizerFlags = wxOK | wxCANCEL | wxYES | wxNO | wxHELP | wxNO_DEFAULT
340 %pythonAppend wxDialog "self._setOORInfo(self)"
341 %pythonAppend wxDialog() ""
342 %typemap(out) wxDialog*; // turn off this typemap
344 wxDialog(wxWindow* parent,
345 const wxWindowID id = -1,
346 const wxString& title = wxPyEmptyString,
347 const wxPoint& pos = wxDefaultPosition,
348 const wxSize& size = wxDefaultSize,
349 long style = wxDEFAULT_DIALOG_STYLE,
350 const wxString& name = wxPyDialogNameStr);
351 %RenameCtor(PreDialog, wxDialog());
353 // Turn it back on again
354 %typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); }
356 bool Create(wxWindow* parent,
357 const wxWindowID id = -1,
358 const wxString& title = wxPyEmptyString,
359 const wxPoint& pos = wxDefaultPosition,
360 const wxSize& size = wxDefaultSize,
361 long style = wxDEFAULT_DIALOG_STYLE,
362 const wxString& name = wxPyDialogNameStr);
364 // the modal dialogs have a return code - usually the ID of the last
366 void SetReturnCode(int returnCode);
367 int GetReturnCode() const;
369 // Set the identifier for the affirmative button: this button will close
370 // the dialog after validating data and calling TransferDataFromWindow()
371 void SetAffirmativeId(int affirmativeId);
372 int GetAffirmativeId() const;
374 // Set identifier for Esc key translation: the button with this id will
375 // close the dialog without doing anything else; special value wxID_NONE
376 // means to not handle Esc at all while wxID_ANY means to map Esc to
377 // wxID_CANCEL if present and GetAffirmativeId() otherwise
378 void SetEscapeId(int escapeId);
379 int GetEscapeId() const;
381 // splits text up at newlines and places the
382 // lines into a vertical wxBoxSizer
383 wxSizer* CreateTextSizer( const wxString &message );
386 // returns a horizontal wxBoxSizer containing the given buttons
388 // notice that the returned sizer can be NULL if no buttons are put in the
389 // sizer (this mostly happens under smart phones and other atypical
390 // platforms which have hardware buttons replacing OK/Cancel and such)
391 %Rename(_CreateButtonSizer,
392 wxSizer* , CreateButtonSizer( long flags ));
394 def CreateButtonSizer(self, flags, *ignored):
395 return self._CreateButtonSizer(flags)
398 // returns the sizer containing CreateButtonSizer() below a separating
399 // static line for the platforms which use static lines for items
400 // separation (i.e. not Mac)
401 wxSizer *CreateSeparatedButtonSizer(long flags);
403 wxStdDialogButtonSizer* CreateStdDialogButtonSizer( long flags );
405 //void SetModal( bool flag );
407 // is the dialog in modal state right now?
408 virtual bool IsModal() const;
410 // Shows the dialog and starts a nested event loop that returns when
411 // EndModal is called.
412 virtual int ShowModal();
414 // may be called to terminate the dialog with the given return code
415 virtual void EndModal(int retCode);
417 static wxVisualAttributes
418 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
420 %property(AffirmativeId, GetAffirmativeId, SetAffirmativeId, doc="See `GetAffirmativeId` and `SetAffirmativeId`");
421 %property(EscapeId, GetEscapeId, SetEscapeId, doc="See `GetEscapeId` and `SetEscapeId`");
422 %property(ReturnCode, GetReturnCode, SetReturnCode, doc="See `GetReturnCode` and `SetReturnCode`");
425 //---------------------------------------------------------------------------
429 #define wxDEFAULT_MINIFRAME_STYLE wxCAPTION | wxRESIZE_BORDER | wxTINY_CAPTION_HORIZ
433 wxDEFAULT_MINIFRAME_STYLE
437 MustHaveApp(wxMiniFrame);
439 class wxMiniFrame : public wxFrame
442 %pythonAppend wxMiniFrame "self._setOORInfo(self)"
443 %pythonAppend wxMiniFrame() ""
445 wxMiniFrame(wxWindow* parent,
446 const wxWindowID id = -1,
447 const wxString& title = wxPyEmptyString,
448 const wxPoint& pos = wxDefaultPosition,
449 const wxSize& size = wxDefaultSize,
450 long style = wxDEFAULT_MINIFRAME_STYLE,
451 const wxString& name = wxPyFrameNameStr);
452 %RenameCtor(PreMiniFrame, wxMiniFrame());
454 bool Create(wxWindow* parent,
455 const wxWindowID id = -1,
456 const wxString& title = wxPyEmptyString,
457 const wxPoint& pos = wxDefaultPosition,
458 const wxSize& size = wxDefaultSize,
459 long style = wxDEFAULT_MINIFRAME_STYLE,
460 const wxString& name = wxPyFrameNameStr);
464 //---------------------------------------------------------------------------
470 wxSPLASH_CENTRE_ON_PARENT,
471 wxSPLASH_CENTRE_ON_SCREEN,
478 MustHaveApp(wxSplashScreenWindow);
480 class wxSplashScreenWindow: public wxWindow
483 %pythonAppend wxSplashScreenWindow "self._setOORInfo(self)"
485 wxSplashScreenWindow(const wxBitmap& bitmap,
488 const wxPoint& pos = wxDefaultPosition,
489 const wxSize& size = wxDefaultSize,
490 long style = wxNO_BORDER);
492 void SetBitmap(const wxBitmap& bitmap);
493 wxBitmap& GetBitmap();
495 %property(Bitmap, GetBitmap, SetBitmap, doc="See `GetBitmap` and `SetBitmap`");
499 MustHaveApp(wxSplashScreen);
501 class wxSplashScreen : public wxFrame
504 %pythonAppend wxSplashScreen "self._setOORInfo(self)"
506 wxSplashScreen(const wxBitmap& bitmap,
507 long splashStyle, int milliseconds,
510 const wxPoint& pos = wxDefaultPosition,
511 const wxSize& size = wxDefaultSize,
512 long style = wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP);
514 long GetSplashStyle() const;
515 wxSplashScreenWindow* GetSplashWindow() const;
516 int GetTimeout() const;
518 %property(SplashStyle, GetSplashStyle, doc="See `GetSplashStyle`");
519 %property(SplashWindow, GetSplashWindow, doc="See `GetSplashWindow`");
520 %property(Timeout, GetTimeout, doc="See `GetTimeout`");
524 //---------------------------------------------------------------------------