simplifying code, removing outdated API
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63266 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -50,10 +50,10 @@ public:
|
|||||||
// virtual bool Destroy();
|
// virtual bool Destroy();
|
||||||
virtual bool Show(bool show = true);
|
virtual bool Show(bool show = true);
|
||||||
|
|
||||||
void SetModal(bool flag);
|
// return true if we're showing the dialog modally
|
||||||
virtual bool IsModal() const;
|
virtual bool IsModal() const;
|
||||||
|
|
||||||
// For now, same as Show(TRUE) but returns return code
|
// show the dialog modally and return the value passed to EndModal()
|
||||||
virtual int ShowModal();
|
virtual int ShowModal();
|
||||||
|
|
||||||
virtual void ShowWindowModal();
|
virtual void ShowWindowModal();
|
||||||
@@ -64,10 +64,15 @@ public:
|
|||||||
// implementation
|
// implementation
|
||||||
// --------------
|
// --------------
|
||||||
|
|
||||||
|
wxDialogModality GetModality() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
// show modal dialog and enter modal loop
|
// show modal dialog and enter modal loop
|
||||||
void DoShowModal();
|
void DoShowModal();
|
||||||
|
|
||||||
|
// show modal dialog and enter modal loop
|
||||||
|
void DoShowWindowModal();
|
||||||
|
|
||||||
protected:
|
|
||||||
// mac also takes command-period as cancel
|
// mac also takes command-period as cancel
|
||||||
virtual bool IsEscapeKey(const wxKeyEvent& event);
|
virtual bool IsEscapeKey(const wxKeyEvent& event);
|
||||||
|
|
||||||
@@ -77,7 +82,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
bool m_isModalStyle;
|
wxDialogModality m_modality;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -23,14 +23,12 @@
|
|||||||
#include "wx/osx/private.h"
|
#include "wx/osx/private.h"
|
||||||
#include "wx/evtloop.h"
|
#include "wx/evtloop.h"
|
||||||
|
|
||||||
extern wxList wxModalDialogs;
|
|
||||||
|
|
||||||
void wxDialog::EndWindowModal()
|
void wxDialog::EndWindowModal()
|
||||||
{
|
{
|
||||||
// Nothing to do for now.
|
// Nothing to do for now.
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDialog::ShowWindowModal()
|
void wxDialog::DoShowWindowModal()
|
||||||
{
|
{
|
||||||
// If someone wants to add support for this to wxOSX Carbon, here would
|
// If someone wants to add support for this to wxOSX Carbon, here would
|
||||||
// be the place to start: http://trac.wxwidgets.org/ticket/9459
|
// be the place to start: http://trac.wxwidgets.org/ticket/9459
|
||||||
@@ -41,9 +39,6 @@ void wxDialog::ShowWindowModal()
|
|||||||
|
|
||||||
void wxDialog::DoShowModal()
|
void wxDialog::DoShowModal()
|
||||||
{
|
{
|
||||||
wxCHECK_RET( !IsModal(), wxT("DoShowModal() called twice") );
|
|
||||||
|
|
||||||
wxModalDialogs.Append(this);
|
|
||||||
|
|
||||||
SetFocus() ;
|
SetFocus() ;
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
extern wxList wxModalDialogs;
|
extern wxList wxModalDialogs;
|
||||||
|
|
||||||
void wxDialog::ShowWindowModal()
|
void wxDialog::DoShowWindowModal()
|
||||||
{
|
{
|
||||||
wxTopLevelWindow* parent = static_cast<wxTopLevelWindow*>(wxGetTopLevelParent(GetParent()));
|
wxTopLevelWindow* parent = static_cast<wxTopLevelWindow*>(wxGetTopLevelParent(GetParent()));
|
||||||
|
|
||||||
@@ -32,8 +32,6 @@ void wxDialog::ShowWindowModal()
|
|||||||
|
|
||||||
NSWindow* parentWindow = parent->GetWXWindow();
|
NSWindow* parentWindow = parent->GetWXWindow();
|
||||||
NSWindow* theWindow = GetWXWindow();
|
NSWindow* theWindow = GetWXWindow();
|
||||||
|
|
||||||
wxWindow::Show(true);
|
|
||||||
|
|
||||||
[NSApp beginSheet: theWindow
|
[NSApp beginSheet: theWindow
|
||||||
modalForWindow: parentWindow
|
modalForWindow: parentWindow
|
||||||
@@ -49,8 +47,6 @@ void wxDialog::EndWindowModal()
|
|||||||
|
|
||||||
void wxDialog::DoShowModal()
|
void wxDialog::DoShowModal()
|
||||||
{
|
{
|
||||||
wxCHECK_RET( !IsModal(), wxT("DoShowModal() called twice") );
|
|
||||||
|
|
||||||
// If the app hasn't started, flush the event queue
|
// If the app hasn't started, flush the event queue
|
||||||
// If we don't do this, the Dock doesn't get the message that
|
// If we don't do this, the Dock doesn't get the message that
|
||||||
// the app has started so will refuse to activate it.
|
// the app has started so will refuse to activate it.
|
||||||
@@ -64,8 +60,6 @@ void wxDialog::DoShowModal()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxModalDialogs.Append(this);
|
|
||||||
|
|
||||||
SetFocus() ;
|
SetFocus() ;
|
||||||
/*
|
/*
|
||||||
WindowGroupRef windowGroup;
|
WindowGroupRef windowGroup;
|
||||||
|
@@ -32,7 +32,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxTopLevelWindow)
|
|||||||
|
|
||||||
void wxDialog::Init()
|
void wxDialog::Init()
|
||||||
{
|
{
|
||||||
m_isModalStyle = false;
|
m_modality = wxDIALOG_MODALITY_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDialog::Create( wxWindow *parent,
|
bool wxDialog::Create( wxWindow *parent,
|
||||||
@@ -57,18 +57,6 @@ bool wxDialog::Create( wxWindow *parent,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDialog::SetModal( bool flag )
|
|
||||||
{
|
|
||||||
if ( flag )
|
|
||||||
{
|
|
||||||
m_isModalStyle = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_isModalStyle = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wxDialog::~wxDialog()
|
wxDialog::~wxDialog()
|
||||||
{
|
{
|
||||||
SendDestroyEvent();
|
SendDestroyEvent();
|
||||||
@@ -89,16 +77,23 @@ bool wxDialog::IsEscapeKey(const wxKeyEvent& event)
|
|||||||
|
|
||||||
bool wxDialog::IsModal() const
|
bool wxDialog::IsModal() const
|
||||||
{
|
{
|
||||||
return wxModalDialogs.Find((wxDialog *)this) != NULL; // const_cast
|
return m_modality != wxDIALOG_MODALITY_NONE;
|
||||||
// return m_isModalStyle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool wxDialog::Show(bool show)
|
bool wxDialog::Show(bool show)
|
||||||
{
|
{
|
||||||
if ( !wxDialogBase::Show(show) )
|
if ( m_modality == wxDIALOG_MODALITY_WINDOW_MODAL )
|
||||||
// nothing to do
|
{
|
||||||
return false;
|
if ( !wxWindow::Show(show) )
|
||||||
|
// nothing to do
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( !wxDialogBase::Show(show) )
|
||||||
|
// nothing to do
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (show && CanDoLayoutAdaptation())
|
if (show && CanDoLayoutAdaptation())
|
||||||
DoLayoutAdaptation();
|
DoLayoutAdaptation();
|
||||||
@@ -107,48 +102,54 @@ bool wxDialog::Show(bool show)
|
|||||||
// usually will result in TransferDataToWindow() being called
|
// usually will result in TransferDataToWindow() being called
|
||||||
InitDialog();
|
InitDialog();
|
||||||
|
|
||||||
if ( m_isModalStyle )
|
if ( !show )
|
||||||
{
|
{
|
||||||
if ( show )
|
switch( m_modality )
|
||||||
{
|
{
|
||||||
DoShowModal();
|
case wxDIALOG_MODALITY_WINDOW_MODAL:
|
||||||
}
|
EndWindowModal(); // OS X implementation method for cleanup
|
||||||
else // end of modal dialog
|
SendWindowModalDialogEvent ( wxEVT_WINDOW_MODAL_DIALOG_CLOSED );
|
||||||
{
|
break;
|
||||||
// this will cause IsModalShowing() return false and our local
|
default:
|
||||||
// message loop will terminate
|
break;
|
||||||
wxModalDialogs.DeleteObject(this);
|
|
||||||
}
|
}
|
||||||
|
m_modality = wxDIALOG_MODALITY_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replacement for Show(true) for modal dialogs - returns return code
|
// Replacement for Show(true) for modal dialogs - returns return code
|
||||||
int wxDialog::ShowModal()
|
int wxDialog::ShowModal()
|
||||||
{
|
{
|
||||||
if ( !m_isModalStyle )
|
m_modality = wxDIALOG_MODALITY_WINDOW_MODAL;
|
||||||
SetModal(true);
|
|
||||||
|
Show();
|
||||||
|
|
||||||
if ( IsShown() )
|
DoShowModal();
|
||||||
DoShowModal();
|
|
||||||
else
|
|
||||||
Show(true);
|
|
||||||
|
|
||||||
return GetReturnCode();
|
return GetReturnCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxDialog::ShowWindowModal()
|
||||||
|
{
|
||||||
|
m_modality = wxDIALOG_MODALITY_WINDOW_MODAL;
|
||||||
|
|
||||||
|
Show();
|
||||||
|
|
||||||
|
DoShowWindowModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDialogModality wxDialog::GetModality() const
|
||||||
|
{
|
||||||
|
return m_modality;
|
||||||
|
}
|
||||||
|
|
||||||
// NB: this function (surprisingly) may be called for both modal and modeless
|
// NB: this function (surprisingly) may be called for both modal and modeless
|
||||||
// dialogs and should work for both of them
|
// dialogs and should work for both of them
|
||||||
void wxDialog::EndModal(int retCode)
|
void wxDialog::EndModal(int retCode)
|
||||||
{
|
{
|
||||||
SetReturnCode(retCode);
|
SetReturnCode(retCode);
|
||||||
Show(false);
|
Show(false);
|
||||||
SetModal(false);
|
|
||||||
if (GetModality() == wxDIALOG_MODALITY_WINDOW_MODAL)
|
|
||||||
{
|
|
||||||
EndWindowModal(); // OS X implementation method for cleanup
|
|
||||||
SendWindowModalDialogEvent ( wxEVT_WINDOW_MODAL_DIALOG_CLOSED );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user