X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/53a2db124c633f80bdb16336084262037d879a2c..86ac84b8ce086e6bbda58f422d41f84268606e35:/include/wx/dialog.h diff --git a/include/wx/dialog.h b/include/wx/dialog.h index 9eee12da29..ef747fe246 100644 --- a/include/wx/dialog.h +++ b/include/wx/dialog.h @@ -53,6 +53,13 @@ enum wxDialogLayoutAdaptationMode wxDIALOG_ADAPTATION_MODE_DISABLED = 2 // disable this dialog overriding global status }; +enum wxDialogModality +{ + wxDIALOG_MODALITY_NONE = 0, + wxDIALOG_MODALITY_WINDOW_MODAL = 1, + wxDIALOG_MODALITY_APP_MODAL = 2 +}; + extern WXDLLIMPEXP_DATA_CORE(const char) wxDialogNameStr[]; class WXDLLIMPEXP_CORE wxDialogBase : public wxTopLevelWindow @@ -71,7 +78,10 @@ public: virtual int ShowModal() = 0; virtual void EndModal(int retCode) = 0; virtual bool IsModal() const = 0; - + // show the dialog frame-modally (needs a parent), using app-modal + // dialogs on platforms that don't support it + virtual bool ShowWindowModal () ; + virtual void SendWindowModalDialogEvent ( wxEventType type ); // Modal dialogs have a return code - usually the id of the last // pressed button @@ -90,8 +100,11 @@ public: void SetEscapeId(int escapeId); int GetEscapeId() const { return m_escapeId; } - // Returns the parent to use for modal dialogs if the user did not specify it - // explicitly + // Find the parent to use for modal dialog: try to use the specified parent + // but fall back to the current active window or main application window as + // last resort if it is unsuitable. + // + // This function always returns a valid top level window or NULL. wxWindow *GetParentForModalDialog(wxWindow *parent = NULL) const; #if wxUSE_STATTEXT // && wxUSE_TEXTCTRL @@ -156,6 +169,8 @@ public: static bool IsLayoutAdaptationEnabled() { return sm_layoutAdaptation; } static void EnableLayoutAdaptation(bool enable) { sm_layoutAdaptation = enable; } + // modality kind + wxDialogModality GetModality() const; protected: // emulate click of a button with the given id if it's present in the dialog // @@ -178,7 +193,6 @@ protected: // wxID_OK return code void AcceptAndClose(); - // The return code from modal dialog int m_returnCode; @@ -211,6 +225,10 @@ private: // common part of all ctors void Init(); + // helper of GetParentForModalDialog(): returns the passed in window if it + // can be used as our parent or NULL if it can't + wxWindow *CheckIfCanBeUsedAsParent(wxWindow *parent) const; + // handle Esc key presses void OnCharHook(wxKeyEvent& event); @@ -224,7 +242,7 @@ private: void OnSysColourChanged(wxSysColourChangedEvent& event); - DECLARE_NO_COPY_CLASS(wxDialogBase) + wxDECLARE_NO_COPY_CLASS(wxDialogBase); DECLARE_EVENT_TABLE() }; @@ -314,7 +332,7 @@ public: #elif defined(__WXGTK__) #include "wx/gtk1/dialog.h" #elif defined(__WXMAC__) - #include "wx/mac/dialog.h" + #include "wx/osx/dialog.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/dialog.h" #elif defined(__WXPM__) @@ -322,5 +340,30 @@ public: #endif #endif +class WXDLLIMPEXP_CORE wxWindowModalDialogEvent : public wxCommandEvent +{ +public: + wxWindowModalDialogEvent (wxEventType commandType = wxEVT_NULL, int id = 0) + : wxCommandEvent(commandType, id) { } + + wxDialog *GetDialog() const + { return wxStaticCast(GetEventObject(), wxDialog); } + + int GetReturnCode() const + { return GetDialog()->GetReturnCode(); } + + virtual wxEvent *Clone() const { return new wxWindowModalDialogEvent (*this); } + +private: + DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWindowModalDialogEvent ) +}; + +wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_WINDOW_MODAL_DIALOG_CLOSED , wxWindowModalDialogEvent ); + +typedef void (wxEvtHandler::*wxWindowModalDialogEventFunction)(wxWindowModalDialogEvent &); + +#define wxWindowModalDialogEventHandler(func) \ + wxEVENT_HANDLER_CAST(wxWindowModalDialogEventFunction, func) + #endif // _WX_DIALOG_H_BASE_