add window-modal dialog calls and fallback implementation
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60614 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -53,6 +53,13 @@ enum wxDialogLayoutAdaptationMode
|
|||||||
wxDIALOG_ADAPTATION_MODE_DISABLED = 2 // disable this dialog overriding global status
|
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[];
|
extern WXDLLIMPEXP_DATA_CORE(const char) wxDialogNameStr[];
|
||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxDialogBase : public wxTopLevelWindow
|
class WXDLLIMPEXP_CORE wxDialogBase : public wxTopLevelWindow
|
||||||
@@ -71,7 +78,10 @@ public:
|
|||||||
virtual int ShowModal() = 0;
|
virtual int ShowModal() = 0;
|
||||||
virtual void EndModal(int retCode) = 0;
|
virtual void EndModal(int retCode) = 0;
|
||||||
virtual bool IsModal() const = 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
|
// Modal dialogs have a return code - usually the id of the last
|
||||||
// pressed button
|
// pressed button
|
||||||
@@ -159,6 +169,8 @@ public:
|
|||||||
static bool IsLayoutAdaptationEnabled() { return sm_layoutAdaptation; }
|
static bool IsLayoutAdaptationEnabled() { return sm_layoutAdaptation; }
|
||||||
static void EnableLayoutAdaptation(bool enable) { sm_layoutAdaptation = enable; }
|
static void EnableLayoutAdaptation(bool enable) { sm_layoutAdaptation = enable; }
|
||||||
|
|
||||||
|
// modality kind
|
||||||
|
wxDialogModality GetModality() const;
|
||||||
protected:
|
protected:
|
||||||
// emulate click of a button with the given id if it's present in the dialog
|
// emulate click of a button with the given id if it's present in the dialog
|
||||||
//
|
//
|
||||||
@@ -181,7 +193,6 @@ protected:
|
|||||||
// wxID_OK return code
|
// wxID_OK return code
|
||||||
void AcceptAndClose();
|
void AcceptAndClose();
|
||||||
|
|
||||||
|
|
||||||
// The return code from modal dialog
|
// The return code from modal dialog
|
||||||
int m_returnCode;
|
int m_returnCode;
|
||||||
|
|
||||||
@@ -329,5 +340,30 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
#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
|
#endif
|
||||||
// _WX_DIALOG_H_BASE_
|
// _WX_DIALOG_H_BASE_
|
||||||
|
@@ -464,6 +464,40 @@ void wxDialogBase::OnButton(wxCommandEvent& event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// compatibility methods for supporting the modality API
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxDEFINE_EVENT( wxEVT_WINDOW_MODAL_DIALOG_CLOSED , wxWindowModalDialogEvent );
|
||||||
|
|
||||||
|
bool wxDialogBase::ShowWindowModal ()
|
||||||
|
{
|
||||||
|
ShowModal();
|
||||||
|
SendWindowModalDialogEvent ( wxEVT_WINDOW_MODAL_DIALOG_CLOSED );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxDialogBase::SendWindowModalDialogEvent ( wxEventType type )
|
||||||
|
{
|
||||||
|
wxCommandEvent event ( type, GetId());
|
||||||
|
event.SetEventObject(this);
|
||||||
|
|
||||||
|
if ( !GetEventHandler()->ProcessEvent(event) )
|
||||||
|
{
|
||||||
|
// the event is not propagated upwards to the parent automatically
|
||||||
|
// because the dialog is a top level window, so do it manually as
|
||||||
|
// in 9 cases of 10 the message must be processed by the dialog
|
||||||
|
// owner and not the dialog itself
|
||||||
|
(void)GetParent()->GetEventHandler()->ProcessEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxDialogModality wxDialogBase::GetModality() const
|
||||||
|
{
|
||||||
|
return IsModal() ? wxDIALOG_MODALITY_APP_MODAL : wxDIALOG_MODALITY_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// other event handlers
|
// other event handlers
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user