class WXDLLIMPEXP_FWD_CORE wxButton;
class WXDLLIMPEXP_FWD_CORE wxScrolledWindow;
-#define wxDIALOG_NO_PARENT 0x0001 // Don't make owned by apps top window
+// Also see the bit summary table in wx/toplevel.h.
+
+#define wxDIALOG_NO_PARENT 0x0100 // Don't make owned by apps top window
#ifdef __WXWINCE__
#define wxDEFAULT_DIALOG_STYLE (wxCAPTION | wxMAXIMIZE | wxCLOSE_BOX | wxNO_BORDER)
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
{
public:
- enum
- {
- // all flags allowed in wxDialogBase::CreateButtonSizer()
- ButtonSizerFlags = wxOK|wxCANCEL|wxYES|wxNO|wxHELP|wxNO_DEFAULT
- };
-
wxDialogBase() { Init(); }
virtual ~wxDialogBase() { }
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 void ShowWindowModal () ;
+ virtual void SendWindowModalDialogEvent ( wxEventType type );
// Modal dialogs have a return code - usually the id of the last
// pressed button
// but fall back to the current active window or main application window as
// last resort if it is unsuitable.
//
+ // As this function is often called from the ctor, the window style may be
+ // not set yet and hence must be passed explicitly to it so that we could
+ // check whether it contains wxDIALOG_NO_PARENT bit.
+ //
// This function always returns a valid top level window or NULL.
- wxWindow *GetParentForModalDialog(wxWindow *parent = NULL) const;
+ wxWindow *GetParentForModalDialog(wxWindow *parent, long style) const;
+
+ // This overload can only be used for already initialized windows, i.e. not
+ // from the ctor. It uses the current window parent and style.
+ wxWindow *GetParentForModalDialog() const
+ {
+ return GetParentForModalDialog(GetParent(), GetWindowStyle());
+ }
#if wxUSE_STATTEXT // && wxUSE_TEXTCTRL
// splits text up at newlines and places the
static bool IsLayoutAdaptationEnabled() { return sm_layoutAdaptation; }
static void EnableLayoutAdaptation(bool enable) { sm_layoutAdaptation = enable; }
+ // modality kind
+ virtual wxDialogModality GetModality() const;
protected:
// emulate click of a button with the given id if it's present in the dialog
//
// wxID_OK return code
void AcceptAndClose();
-
// The return code from modal dialog
int m_returnCode;
#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_