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 //---------------------------------------------------------------------------
 
  42     wxDEFAULT_FRAME_STYLE,
 
  43     wxDEFAULT_DIALOG_STYLE,
 
  46     wxFRAME_FLOAT_ON_PARENT,
 
  47     wxFRAME_NO_WINDOW_MENU,
 
  56     wxFRAME_EX_CONTEXTHELP,
 
  57     wxDIALOG_EX_CONTEXTHELP,
 
  62     RESIZE_BOX  = MAXIMIZE_BOX
 
  63     THICK_FRAME = RESIZE_BORDER
 
  75     wxFULLSCREEN_NOMENUBAR,
 
  76     wxFULLSCREEN_NOTOOLBAR,
 
  77     wxFULLSCREEN_NOSTATUSBAR,
 
  78     wxFULLSCREEN_NOBORDER,
 
  79     wxFULLSCREEN_NOCAPTION,
 
  85 // Styles for RequestUserAttention
 
  88     wxUSER_ATTENTION_INFO = 1,
 
  89     wxUSER_ATTENTION_ERROR = 2
 
  92 //---------------------------------------------------------------------------
 
  94 class  wxTopLevelWindow : public wxWindow
 
  98     // No constructor as it can not be used directly from Python
 
 100     // maximize = True => maximize, otherwise - restore
 
 101     virtual void Maximize(bool maximize = true);
 
 103     // undo Maximize() or Iconize()
 
 104     virtual void Restore();
 
 106     // iconize = True => iconize, otherwise - restore
 
 107     virtual void Iconize(bool iconize = true);
 
 109     // return True if the frame is maximized
 
 110     virtual bool IsMaximized() const;
 
 112     // return true if the frame is always maximized
 
 113     // due to native guidelines or current policy
 
 114     virtual bool IsAlwaysMaximized() const;
 
 116     // return True if the frame is iconized
 
 117     virtual bool IsIconized() const;
 
 119     // get the frame icon
 
 120     wxIcon GetIcon() const;
 
 122     // set the frame icon
 
 123     virtual void SetIcon(const wxIcon& icon);
 
 125     // set the frame icons
 
 126     virtual void SetIcons(const wxIconBundle& icons);
 
 128     // maximize the window to cover entire screen
 
 129     virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
 
 131     // return True if the frame is in fullscreen mode
 
 132     virtual bool IsFullScreen() const;
 
 134     virtual void SetTitle(const wxString& title);
 
 135     virtual wxString GetTitle() const;
 
 137     // enable/disable close button [x]
 
 138     virtual bool EnableCloseButton(bool enable );
 
 140     // Set the shape of the window to the given region.
 
 141     // Returns True if the platform supports this feature
 
 142     // (and the operation is successful.)
 
 143     virtual bool SetShape(const wxRegion& region);
 
 145     // Attracts the users attention to this window if the application is inactive
 
 146     // (should be called when a background event occurs)
 
 147     virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
 
 149     // Is this the active frame (highlighted in the taskbar)?
 
 150     virtual bool IsActive();
 
 154         void MacSetMetalAppearance( bool on ) {
 
 155             int style = self->GetExtraStyle();
 
 157                 style |= wxFRAME_EX_METAL;
 
 159                 style &= ~wxFRAME_EX_METAL;
 
 160             self->SetExtraStyle(style);
 
 163     bool MacGetMetalAppearance() const;
 
 167         // TODO: Should they raise not implemented or just NOP???
 
 168         void MacSetMetalAppearance( bool on ) { /*wxPyRaiseNotImplemented();*/ }
 
 169         bool MacGetMetalAppearance() const    { /*wxPyRaiseNotImplemented();*/ return false; }
 
 174         void , CenterOnScreen(int dir = wxBOTH),
 
 175         "Center the window on screen", "");
 
 176     %pythoncode { CentreOnScreen = CenterOnScreen }
 
 180         virtual wxWindow *, GetDefaultItem() const,
 
 181         "Get the default child of this parent, i.e. the one which is activated
 
 182 by pressing <Enter> such as the OK button on a wx.Dialog.", "");
 
 185         virtual wxWindow *, SetDefaultItem(wxWindow * child),
 
 186         "Set this child as default, return the old default.", "");
 
 189         virtual void , SetTmpDefaultItem(wxWindow * win),
 
 190         "Set this child as temporary default", "");
 
 193         virtual wxWindow *, GetTmpDefaultItem() const,
 
 194         "Return the temporary default item, which can be None.", "");
 
 196     %property(DefaultItem, GetDefaultItem, SetDefaultItem, doc="See `GetDefaultItem` and `SetDefaultItem`");
 
 197     %property(Icon, GetIcon, SetIcon, doc="See `GetIcon` and `SetIcon`");
 
 198     %property(Title, GetTitle, SetTitle, doc="See `GetTitle` and `SetTitle`");
 
 199     %property(TmpDefaultItem, GetTmpDefaultItem, SetTmpDefaultItem, doc="See `GetTmpDefaultItem` and `SetTmpDefaultItem`");
 
 203 //---------------------------------------------------------------------------
 
 206 // wxFrame is a top-level window with optional menubar, statusbar and toolbar
 
 208 // For each of *bars, a frame may have several of them, but only one is
 
 209 // managed by the frame, i.e. resized/moved when the frame is and whose size
 
 210 // is accounted for in client size calculations - all others should be taken
 
 213 MustHaveApp(wxFrame);
 
 215 class wxFrame : public wxTopLevelWindow
 
 218     %pythonAppend wxFrame         "self._setOORInfo(self)"
 
 219     %pythonAppend wxFrame()       ""
 
 220     %typemap(out) wxFrame*;    // turn off this typemap
 
 222     wxFrame(wxWindow* parent,
 
 223             const wxWindowID id = -1,
 
 224             const wxString& title = wxPyEmptyString,
 
 225             const wxPoint& pos = wxDefaultPosition,
 
 226             const wxSize& size = wxDefaultSize,
 
 227             long style = wxDEFAULT_FRAME_STYLE,
 
 228             const wxString& name = wxPyFrameNameStr);
 
 229     %RenameCtor(PreFrame, wxFrame());
 
 231     // Turn it back on again
 
 232     %typemap(out) wxFrame* { $result = wxPyMake_wxObject($1, $owner); }
 
 234     bool Create(wxWindow* parent,
 
 235             const wxWindowID id = -1,
 
 236             const wxString& title = wxPyEmptyString,
 
 237             const wxPoint& pos = wxDefaultPosition,
 
 238             const wxSize& size = wxDefaultSize,
 
 239             long style = wxDEFAULT_FRAME_STYLE,
 
 240             const wxString& name = wxPyFrameNameStr);
 
 245     // get the origin of the client area (which may be different from (0, 0)
 
 246     // if the frame has a toolbar) in client coordinates
 
 247     virtual wxPoint GetClientAreaOrigin() const;
 
 249     // sends a size event to the window using its current size:
 
 250     //  this has a side effect of refreshing the window layout
 
 251     virtual void SendSizeEvent();
 
 253     // menu bar functions
 
 254     // ------------------
 
 256     virtual void SetMenuBar(wxMenuBar *menubar);
 
 257     virtual wxMenuBar *GetMenuBar() const;
 
 259     // process menu command: returns True if processed
 
 260     bool ProcessCommand(int winid);
 
 261     %pythoncode { Command = ProcessCommand }
 
 263     // status bar functions
 
 264     // --------------------
 
 266     // create the main status bar by calling OnCreateStatusBar()
 
 267     virtual wxStatusBar* CreateStatusBar(int number = 1,
 
 268                                          long style = wxDEFAULT_STATUSBAR_STYLE,
 
 269                                          wxWindowID winid = 0,
 
 270                                          const wxString& name = wxPyStatusLineNameStr);
 
 272 // TODO: with directors?
 
 273 //     // return a new status bar
 
 274 //     virtual wxStatusBar *OnCreateStatusBar(int number,
 
 277 //                                            const wxString& name);
 
 279     // get the main status bar
 
 280     virtual wxStatusBar *GetStatusBar() const;
 
 282     // sets the main status bar
 
 283     void SetStatusBar(wxStatusBar *statBar);
 
 285     // forward these to status bar
 
 286     virtual void SetStatusText(const wxString &text, int number = 0);
 
 287     virtual void SetStatusWidths(int widths, const int* widths_field); // uses typemap above
 
 288     void PushStatusText(const wxString &text, int number = 0);
 
 289     void PopStatusText(int number = 0);
 
 291     // set the status bar pane the help will be shown in
 
 292     void SetStatusBarPane(int n);
 
 293     int GetStatusBarPane() const;
 
 298     // create main toolbar bycalling OnCreateToolBar()
 
 299     virtual wxToolBar* CreateToolBar(long style = -1,
 
 300                                      wxWindowID winid = -1,
 
 301                                      const wxString& name = wxPyToolBarNameStr);
 
 303 // TODO: with directors?
 
 304 //     // return a new toolbar
 
 305 //     virtual wxToolBar *OnCreateToolBar(long style,
 
 307 //                                        const wxString& name );
 
 309     // get/set the main toolbar
 
 310     virtual wxToolBar *GetToolBar() const;
 
 311     virtual void SetToolBar(wxToolBar *toolbar);
 
 313     // show help text (typically in the statusbar); show is False
 
 314     // if you are hiding the help, True otherwise
 
 315     virtual void DoGiveHelp(const wxString& text, bool show);
 
 317     // send wxUpdateUIEvents for all menu items in the menubar,
 
 318     // or just for menu if non-NULL
 
 319     void DoMenuUpdates(wxMenu* menu = NULL);
 
 321     static wxVisualAttributes
 
 322     GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
 
 324     %property(MenuBar, GetMenuBar, SetMenuBar, doc="See `GetMenuBar` and `SetMenuBar`");
 
 325     %property(StatusBar, GetStatusBar, SetStatusBar, doc="See `GetStatusBar` and `SetStatusBar`");
 
 326     %property(StatusBarPane, GetStatusBarPane, SetStatusBarPane, doc="See `GetStatusBarPane` and `SetStatusBarPane`");
 
 327     %property(ToolBar, GetToolBar, SetToolBar, doc="See `GetToolBar` and `SetToolBar`");
 
 330 //---------------------------------------------------------------------------
 
 333 MustHaveApp(wxDialog);
 
 335 class wxDialog : public wxTopLevelWindow
 
 340         // all flags allowed in wxDialogBase::CreateButtonSizer()
 
 341         ButtonSizerFlags = wxOK | wxCANCEL | wxYES | wxNO | wxHELP | wxNO_DEFAULT
 
 344     %pythonAppend wxDialog   "self._setOORInfo(self)"
 
 345     %pythonAppend wxDialog() ""
 
 346     %typemap(out) wxDialog*;    // turn off this typemap
 
 348     wxDialog(wxWindow* parent,
 
 349              const wxWindowID id = -1,
 
 350              const wxString& title = wxPyEmptyString,
 
 351              const wxPoint& pos = wxDefaultPosition,
 
 352              const wxSize& size = wxDefaultSize,
 
 353              long style = wxDEFAULT_DIALOG_STYLE,
 
 354              const wxString& name = wxPyDialogNameStr);
 
 355     %RenameCtor(PreDialog, wxDialog());
 
 357     // Turn it back on again
 
 358     %typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); }
 
 360     bool Create(wxWindow* parent,
 
 361                 const wxWindowID id = -1,
 
 362                 const wxString& title = wxPyEmptyString,
 
 363                 const wxPoint& pos = wxDefaultPosition,
 
 364                 const wxSize& size = wxDefaultSize,
 
 365                 long style = wxDEFAULT_DIALOG_STYLE,
 
 366                 const wxString& name = wxPyDialogNameStr);
 
 368     // the modal dialogs have a return code - usually the ID of the last
 
 370     void SetReturnCode(int returnCode);
 
 371     int GetReturnCode() const;
 
 373     // Set the identifier for the affirmative button: this button will close
 
 374     // the dialog after validating data and calling TransferDataFromWindow()
 
 375     void SetAffirmativeId(int affirmativeId);
 
 376     int GetAffirmativeId() const;
 
 378     // Set identifier for Esc key translation: the button with this id will
 
 379     // close the dialog without doing anything else; special value wxID_NONE
 
 380     // means to not handle Esc at all while wxID_ANY means to map Esc to
 
 381     // wxID_CANCEL if present and GetAffirmativeId() otherwise
 
 382     void SetEscapeId(int escapeId);
 
 383     int GetEscapeId() const;
 
 385     // splits text up at newlines and places the
 
 386     // lines into a vertical wxBoxSizer
 
 387     wxSizer* CreateTextSizer( const wxString &message );
 
 390     // returns a horizontal wxBoxSizer containing the given buttons
 
 392     // notice that the returned sizer can be NULL if no buttons are put in the
 
 393     // sizer (this mostly happens under smart phones and other atypical
 
 394     // platforms which have hardware buttons replacing OK/Cancel and such)
 
 395    %Rename(_CreateButtonSizer,
 
 396            wxSizer* , CreateButtonSizer( long flags ));
 
 398         def CreateButtonSizer(self, flags, *ignored):
 
 399             return self._CreateButtonSizer(flags)
 
 402     // returns the sizer containing CreateButtonSizer() below a separating
 
 403     // static line for the platforms which use static lines for items
 
 404     // separation (i.e. not Mac)
 
 405     wxSizer *CreateSeparatedButtonSizer(long flags);
 
 407     wxStdDialogButtonSizer* CreateStdDialogButtonSizer( long flags );
 
 409     //void SetModal( bool flag );
 
 411     // is the dialog in modal state right now?
 
 412     virtual bool IsModal() const;
 
 414     // Shows the dialog and starts a nested event loop that returns when
 
 415     // EndModal is called.
 
 416     virtual int ShowModal();
 
 418     // may be called to terminate the dialog with the given return code
 
 419     virtual void EndModal(int retCode);
 
 421     static wxVisualAttributes
 
 422     GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
 
 424     %property(AffirmativeId, GetAffirmativeId, SetAffirmativeId, doc="See `GetAffirmativeId` and `SetAffirmativeId`");
 
 425     %property(EscapeId, GetEscapeId, SetEscapeId, doc="See `GetEscapeId` and `SetEscapeId`");
 
 426     %property(ReturnCode, GetReturnCode, SetReturnCode, doc="See `GetReturnCode` and `SetReturnCode`");
 
 429 //---------------------------------------------------------------------------
 
 433 #define wxDEFAULT_MINIFRAME_STYLE wxCAPTION | wxRESIZE_BORDER | wxTINY_CAPTION_HORIZ
 
 437     wxDEFAULT_MINIFRAME_STYLE
 
 441 MustHaveApp(wxMiniFrame);
 
 443 class wxMiniFrame : public wxFrame
 
 446     %pythonAppend wxMiniFrame         "self._setOORInfo(self)"
 
 447     %pythonAppend wxMiniFrame()       ""
 
 449     wxMiniFrame(wxWindow* parent,
 
 450             const wxWindowID id = -1,
 
 451             const wxString& title = wxPyEmptyString,
 
 452             const wxPoint& pos = wxDefaultPosition,
 
 453             const wxSize& size = wxDefaultSize,
 
 454             long style = wxDEFAULT_MINIFRAME_STYLE,
 
 455             const wxString& name = wxPyFrameNameStr);
 
 456     %RenameCtor(PreMiniFrame, wxMiniFrame());
 
 458     bool Create(wxWindow* parent,
 
 459             const wxWindowID id = -1,
 
 460             const wxString& title = wxPyEmptyString,
 
 461             const wxPoint& pos = wxDefaultPosition,
 
 462             const wxSize& size = wxDefaultSize,
 
 463             long style = wxDEFAULT_MINIFRAME_STYLE,
 
 464             const wxString& name = wxPyFrameNameStr);
 
 468 //---------------------------------------------------------------------------
 
 474     wxSPLASH_CENTRE_ON_PARENT,
 
 475     wxSPLASH_CENTRE_ON_SCREEN,
 
 482 MustHaveApp(wxSplashScreenWindow);
 
 484 class wxSplashScreenWindow: public wxWindow
 
 487     %pythonAppend wxSplashScreenWindow         "self._setOORInfo(self)"
 
 489     wxSplashScreenWindow(const wxBitmap& bitmap,
 
 492              const wxPoint& pos = wxDefaultPosition,
 
 493              const wxSize& size = wxDefaultSize,
 
 494              long style = wxNO_BORDER);
 
 496     void SetBitmap(const wxBitmap& bitmap);
 
 497     wxBitmap& GetBitmap();
 
 499     %property(Bitmap, GetBitmap, SetBitmap, doc="See `GetBitmap` and `SetBitmap`");
 
 503 MustHaveApp(wxSplashScreen);
 
 505 class wxSplashScreen : public wxFrame
 
 508     %pythonAppend wxSplashScreen         "self._setOORInfo(self)"
 
 510     wxSplashScreen(const wxBitmap& bitmap,
 
 511             long splashStyle, int milliseconds,
 
 514             const wxPoint& pos = wxDefaultPosition,
 
 515             const wxSize& size = wxDefaultSize,
 
 516             long style = wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP);
 
 518     long GetSplashStyle() const;
 
 519     wxSplashScreenWindow* GetSplashWindow() const;
 
 520     int GetTimeout() const;
 
 522     %property(SplashStyle, GetSplashStyle, doc="See `GetSplashStyle`");
 
 523     %property(SplashWindow, GetSplashWindow, doc="See `GetSplashWindow`");
 
 524     %property(Timeout, GetTimeout, doc="See `GetTimeout`");
 
 528 //---------------------------------------------------------------------------