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.", "");
 
 198     %property(DefaultItem, GetDefaultItem, SetDefaultItem, doc="See `GetDefaultItem` and `SetDefaultItem`");
 
 199     %property(Icon, GetIcon, SetIcon, doc="See `GetIcon` and `SetIcon`");
 
 200     %property(Title, GetTitle, SetTitle, doc="See `GetTitle` and `SetTitle`");
 
 201     %property(TmpDefaultItem, GetTmpDefaultItem, SetTmpDefaultItem, doc="See `GetTmpDefaultItem` and `SetTmpDefaultItem`");
 
 205 //---------------------------------------------------------------------------
 
 208 // wxFrame is a top-level window with optional menubar, statusbar and toolbar
 
 210 // For each of *bars, a frame may have several of them, but only one is
 
 211 // managed by the frame, i.e. resized/moved when the frame is and whose size
 
 212 // is accounted for in client size calculations - all others should be taken
 
 215 MustHaveApp(wxFrame);
 
 217 class wxFrame : public wxTopLevelWindow
 
 220     %pythonAppend wxFrame         "self._setOORInfo(self)"
 
 221     %pythonAppend wxFrame()       ""
 
 222     %typemap(out) wxFrame*;    // turn off this typemap
 
 224     wxFrame(wxWindow* parent,
 
 225             const wxWindowID id = -1,
 
 226             const wxString& title = wxPyEmptyString,
 
 227             const wxPoint& pos = wxDefaultPosition,
 
 228             const wxSize& size = wxDefaultSize,
 
 229             long style = wxDEFAULT_FRAME_STYLE,
 
 230             const wxString& name = wxPyFrameNameStr);
 
 231     %RenameCtor(PreFrame, wxFrame());
 
 233     // Turn it back on again
 
 234     %typemap(out) wxFrame* { $result = wxPyMake_wxObject($1, $owner); }
 
 236     bool Create(wxWindow* parent,
 
 237             const wxWindowID id = -1,
 
 238             const wxString& title = wxPyEmptyString,
 
 239             const wxPoint& pos = wxDefaultPosition,
 
 240             const wxSize& size = wxDefaultSize,
 
 241             long style = wxDEFAULT_FRAME_STYLE,
 
 242             const wxString& name = wxPyFrameNameStr);
 
 247     // get the origin of the client area (which may be different from (0, 0)
 
 248     // if the frame has a toolbar) in client coordinates
 
 249     virtual wxPoint GetClientAreaOrigin() const;
 
 251     // sends a size event to the window using its current size:
 
 252     //  this has a side effect of refreshing the window layout
 
 253     virtual void SendSizeEvent();
 
 255     // menu bar functions
 
 256     // ------------------
 
 258     virtual void SetMenuBar(wxMenuBar *menubar);
 
 259     virtual wxMenuBar *GetMenuBar() const;
 
 261     // process menu command: returns True if processed
 
 262     bool ProcessCommand(int winid);
 
 263     %pythoncode { Command = ProcessCommand }
 
 265     // status bar functions
 
 266     // --------------------
 
 268     // create the main status bar by calling OnCreateStatusBar()
 
 269     virtual wxStatusBar* CreateStatusBar(int number = 1,
 
 270                                          long style = wxDEFAULT_STATUSBAR_STYLE,
 
 271                                          wxWindowID winid = 0,
 
 272                                          const wxString& name = wxPyStatusLineNameStr);
 
 274 // TODO: with directors?
 
 275 //     // return a new status bar
 
 276 //     virtual wxStatusBar *OnCreateStatusBar(int number,
 
 279 //                                            const wxString& name);
 
 281     // get the main status bar
 
 282     virtual wxStatusBar *GetStatusBar() const;
 
 284     // sets the main status bar
 
 285     void SetStatusBar(wxStatusBar *statBar);
 
 287     // forward these to status bar
 
 288     virtual void SetStatusText(const wxString &text, int number = 0);
 
 289     virtual void SetStatusWidths(int widths, const int* widths_field); // uses typemap above
 
 290     void PushStatusText(const wxString &text, int number = 0);
 
 291     void PopStatusText(int number = 0);
 
 293     // set the status bar pane the help will be shown in
 
 294     void SetStatusBarPane(int n);
 
 295     int GetStatusBarPane() const;
 
 300     // create main toolbar bycalling OnCreateToolBar()
 
 301     virtual wxToolBar* CreateToolBar(long style = -1,
 
 302                                      wxWindowID winid = -1,
 
 303                                      const wxString& name = wxPyToolBarNameStr);
 
 305 // TODO: with directors?
 
 306 //     // return a new toolbar
 
 307 //     virtual wxToolBar *OnCreateToolBar(long style,
 
 309 //                                        const wxString& name );
 
 311     // get/set the main toolbar
 
 312     virtual wxToolBar *GetToolBar() const;
 
 313     virtual void SetToolBar(wxToolBar *toolbar);
 
 315     // show help text (typically in the statusbar); show is False
 
 316     // if you are hiding the help, True otherwise
 
 317     virtual void DoGiveHelp(const wxString& text, bool show);
 
 319     // send wxUpdateUIEvents for all menu items in the menubar,
 
 320     // or just for menu if non-NULL
 
 321     void DoMenuUpdates(wxMenu* menu = NULL);
 
 323     static wxVisualAttributes
 
 324     GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
 
 326     %property(MenuBar, GetMenuBar, SetMenuBar, doc="See `GetMenuBar` and `SetMenuBar`");
 
 327     %property(StatusBar, GetStatusBar, SetStatusBar, doc="See `GetStatusBar` and `SetStatusBar`");
 
 328     %property(StatusBarPane, GetStatusBarPane, SetStatusBarPane, doc="See `GetStatusBarPane` and `SetStatusBarPane`");
 
 329     %property(ToolBar, GetToolBar, SetToolBar, doc="See `GetToolBar` and `SetToolBar`");
 
 332 //---------------------------------------------------------------------------
 
 335 MustHaveApp(wxDialog);
 
 337 class wxDialog : public wxTopLevelWindow
 
 342         // all flags allowed in wxDialogBase::CreateButtonSizer()
 
 343         ButtonSizerFlags = wxOK | wxCANCEL | wxYES | wxNO | wxHELP | wxNO_DEFAULT
 
 346     %pythonAppend wxDialog   "self._setOORInfo(self)"
 
 347     %pythonAppend wxDialog() ""
 
 348     %typemap(out) wxDialog*;    // turn off this typemap
 
 350     wxDialog(wxWindow* parent,
 
 351              const wxWindowID id = -1,
 
 352              const wxString& title = wxPyEmptyString,
 
 353              const wxPoint& pos = wxDefaultPosition,
 
 354              const wxSize& size = wxDefaultSize,
 
 355              long style = wxDEFAULT_DIALOG_STYLE,
 
 356              const wxString& name = wxPyDialogNameStr);
 
 357     %RenameCtor(PreDialog, wxDialog());
 
 359     // Turn it back on again
 
 360     %typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); }
 
 362     bool Create(wxWindow* parent,
 
 363                 const wxWindowID id = -1,
 
 364                 const wxString& title = wxPyEmptyString,
 
 365                 const wxPoint& pos = wxDefaultPosition,
 
 366                 const wxSize& size = wxDefaultSize,
 
 367                 long style = wxDEFAULT_DIALOG_STYLE,
 
 368                 const wxString& name = wxPyDialogNameStr);
 
 370     // the modal dialogs have a return code - usually the ID of the last
 
 372     void SetReturnCode(int returnCode);
 
 373     int GetReturnCode() const;
 
 375     // Set the identifier for the affirmative button: this button will close
 
 376     // the dialog after validating data and calling TransferDataFromWindow()
 
 377     void SetAffirmativeId(int affirmativeId);
 
 378     int GetAffirmativeId() const;
 
 380     // Set identifier for Esc key translation: the button with this id will
 
 381     // close the dialog without doing anything else; special value wxID_NONE
 
 382     // means to not handle Esc at all while wxID_ANY means to map Esc to
 
 383     // wxID_CANCEL if present and GetAffirmativeId() otherwise
 
 384     void SetEscapeId(int escapeId);
 
 385     int GetEscapeId() const;
 
 387     // splits text up at newlines and places the
 
 388     // lines into a vertical wxBoxSizer
 
 389     wxSizer* CreateTextSizer( const wxString &message );
 
 392     // returns a horizontal wxBoxSizer containing the given buttons
 
 394     // notice that the returned sizer can be NULL if no buttons are put in the
 
 395     // sizer (this mostly happens under smart phones and other atypical
 
 396     // platforms which have hardware buttons replacing OK/Cancel and such)
 
 397    %Rename(_CreateButtonSizer,
 
 398            wxSizer* , CreateButtonSizer( long flags ));
 
 400         def CreateButtonSizer(self, flags, *ignored):
 
 401             return self._CreateButtonSizer(flags)
 
 404     // returns the sizer containing CreateButtonSizer() below a separating
 
 405     // static line for the platforms which use static lines for items
 
 406     // separation (i.e. not Mac)
 
 407     wxSizer *CreateSeparatedButtonSizer(long flags);
 
 409     wxStdDialogButtonSizer* CreateStdDialogButtonSizer( long flags );
 
 411     //void SetModal( bool flag );
 
 413     // is the dialog in modal state right now?
 
 414     virtual bool IsModal() const;
 
 416     // Shows the dialog and starts a nested event loop that returns when
 
 417     // EndModal is called.
 
 418     virtual int ShowModal();
 
 420     // may be called to terminate the dialog with the given return code
 
 421     virtual void EndModal(int retCode);
 
 423     static wxVisualAttributes
 
 424     GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
 
 426     %property(AffirmativeId, GetAffirmativeId, SetAffirmativeId, doc="See `GetAffirmativeId` and `SetAffirmativeId`");
 
 427     %property(EscapeId, GetEscapeId, SetEscapeId, doc="See `GetEscapeId` and `SetEscapeId`");
 
 428     %property(ReturnCode, GetReturnCode, SetReturnCode, doc="See `GetReturnCode` and `SetReturnCode`");
 
 431 //---------------------------------------------------------------------------
 
 435 MustHaveApp(wxMiniFrame);
 
 437 class wxMiniFrame : public wxFrame
 
 440     %pythonAppend wxMiniFrame         "self._setOORInfo(self)"
 
 441     %pythonAppend wxMiniFrame()       ""
 
 443     wxMiniFrame(wxWindow* parent,
 
 444             const wxWindowID id = -1,
 
 445             const wxString& title = wxPyEmptyString,
 
 446             const wxPoint& pos = wxDefaultPosition,
 
 447             const wxSize& size = wxDefaultSize,
 
 448             long style = wxDEFAULT_FRAME_STYLE,
 
 449             const wxString& name = wxPyFrameNameStr);
 
 450     %RenameCtor(PreMiniFrame, wxMiniFrame());
 
 452     bool Create(wxWindow* parent,
 
 453             const wxWindowID id = -1,
 
 454             const wxString& title = wxPyEmptyString,
 
 455             const wxPoint& pos = wxDefaultPosition,
 
 456             const wxSize& size = wxDefaultSize,
 
 457             long style = wxDEFAULT_FRAME_STYLE,
 
 458             const wxString& name = wxPyFrameNameStr);
 
 462 //---------------------------------------------------------------------------
 
 468     wxSPLASH_CENTRE_ON_PARENT,
 
 469     wxSPLASH_CENTRE_ON_SCREEN,
 
 476 MustHaveApp(wxSplashScreenWindow);
 
 478 class wxSplashScreenWindow: public wxWindow
 
 481     %pythonAppend wxSplashScreenWindow         "self._setOORInfo(self)"
 
 483     wxSplashScreenWindow(const wxBitmap& bitmap,
 
 486              const wxPoint& pos = wxDefaultPosition,
 
 487              const wxSize& size = wxDefaultSize,
 
 488              long style = wxNO_BORDER);
 
 490     void SetBitmap(const wxBitmap& bitmap);
 
 491     wxBitmap& GetBitmap();
 
 493     %property(Bitmap, GetBitmap, SetBitmap, doc="See `GetBitmap` and `SetBitmap`");
 
 497 MustHaveApp(wxSplashScreen);
 
 499 class wxSplashScreen : public wxFrame
 
 502     %pythonAppend wxSplashScreen         "self._setOORInfo(self)"
 
 504     wxSplashScreen(const wxBitmap& bitmap,
 
 505             long splashStyle, int milliseconds,
 
 508             const wxPoint& pos = wxDefaultPosition,
 
 509             const wxSize& size = wxDefaultSize,
 
 510             long style = wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP);
 
 512     long GetSplashStyle() const;
 
 513     wxSplashScreenWindow* GetSplashWindow() const;
 
 514     int GetTimeout() const;
 
 516     %property(SplashStyle, GetSplashStyle, doc="See `GetSplashStyle`");
 
 517     %property(SplashWindow, GetSplashWindow, doc="See `GetSplashWindow`");
 
 518     %property(Timeout, GetTimeout, doc="See `GetTimeout`");
 
 522 //---------------------------------------------------------------------------