Fix the apply button not graying out anymore like it used to.

This is a patch from Jake.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4236 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
ramapcsx2 2011-01-18 00:58:54 +00:00
parent 5071456d53
commit 3d6ac25f3c
4 changed files with 61 additions and 42 deletions

View File

@ -109,7 +109,6 @@ void IEventListener_AppStatus::DispatchEvent( const AppEventInfo& evtinfo )
AppStatusEvent_OnSettingsApplied();
break;
case AppStatus_Exiting:
AppStatusEvent_OnExit();
break;

View File

@ -42,6 +42,54 @@ using namespace Panels;
static const int s_orient = wxBK_LEFT;
#endif
class ScopedOkButtonDisabler
{
protected:
Dialogs::BaseConfigurationDialog* m_parent;
wxWindow* m_apply;
wxWindow* m_ok;
wxWindow* m_cancel;
public:
ScopedOkButtonDisabler( Dialogs::BaseConfigurationDialog* parent )
{
m_parent = parent;
m_parent->AllowApplyActivation( false );
m_apply = m_parent->FindWindow( wxID_APPLY );
m_ok = m_parent->FindWindow( wxID_OK );
m_cancel = m_parent->FindWindow( wxID_CANCEL );
if (m_apply) m_apply ->Disable();
if (m_ok) m_ok ->Disable();
if (m_cancel) m_cancel->Disable();
}
// Use this to prevent the Apply button from being re-enabled.
void DetachApply()
{
m_apply = NULL;
}
void DetachAll()
{
m_apply = m_ok = m_cancel = NULL;
}
virtual ~ScopedOkButtonDisabler() throw()
{
if (m_apply) m_apply ->Enable();
if (m_ok) m_ok ->Enable();
if (m_cancel) m_cancel->Enable();
m_parent->AllowApplyActivation( true );
}
};
// --------------------------------------------------------------------------------------
// BaseApplicableDialog (implementations)
// --------------------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(BaseApplicableDialog, wxDialogWithHelpers)
BaseApplicableDialog::BaseApplicableDialog( wxWindow* parent, const wxString& title, const pxDialogCreationFlags& cflags )
@ -86,7 +134,8 @@ Dialogs::BaseConfigurationDialog::BaseConfigurationDialog( wxWindow* parent, con
: _parent( parent, title )
{
SetMinWidth( idealWidth );
m_listbook = NULL;
m_listbook = NULL;
m_allowApplyActivation = true;
Connect( wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BaseConfigurationDialog::OnOk_Click ) );
Connect( wxID_CANCEL, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BaseConfigurationDialog::OnCancel_Click ) );
@ -170,7 +219,8 @@ void Dialogs::BaseConfigurationDialog::SomethingChanged()
void Dialogs::BaseConfigurationDialog::OnSomethingChanged( wxCommandEvent& evt )
{
evt.Skip();
if( (evt.GetId() != wxID_OK) && (evt.GetId() != wxID_CANCEL) && (evt.GetId() != wxID_APPLY) )
if (!m_allowApplyActivation) return;
if ((evt.GetId() != wxID_OK) && (evt.GetId() != wxID_CANCEL) && (evt.GetId() != wxID_APPLY))
SomethingChanged();
}
@ -181,44 +231,11 @@ void Dialogs::BaseConfigurationDialog::OnCloseWindow( wxCloseEvent& evt )
evt.Skip();
}
class ScopedOkButtonDisabler
void Dialogs::BaseConfigurationDialog::AllowApplyActivation( bool allow )
{
protected:
wxWindow* m_apply;
wxWindow* m_ok;
wxWindow* m_cancel;
public:
ScopedOkButtonDisabler( wxWindow* parent )
{
m_apply = parent->FindWindow( wxID_APPLY );
m_ok = parent->FindWindow( wxID_OK );
m_cancel = parent->FindWindow( wxID_CANCEL );
if (m_apply) m_apply ->Disable();
if (m_ok) m_ok ->Disable();
if (m_cancel) m_cancel->Disable();
}
// Use this to prevent the Apply buton from being re-enabled.
//avih: Does this work?? As far as I know Apply is always enabled...
void DetachApply()
{
m_apply = NULL;
}
void DetachAll()
{
m_apply = m_ok = m_cancel = NULL;
}
virtual ~ScopedOkButtonDisabler() throw()
{
if (m_apply) m_apply ->Enable();
if (m_ok) m_ok ->Enable();
if (m_cancel) m_cancel->Enable();
}
};
m_allowApplyActivation = allow;
}
void Dialogs::BaseConfigurationDialog::OnOk_Click( wxCommandEvent& evt )
{

View File

@ -44,6 +44,7 @@ namespace Dialogs
protected:
wxListbook* m_listbook;
wxArrayString m_labels;
bool m_allowApplyActivation;
public:
virtual ~BaseConfigurationDialog() throw();
@ -59,6 +60,8 @@ namespace Dialogs
template< typename T >
void AddPage( const wxChar* label, int iconid );
void AllowApplyActivation( bool allow=true );
protected:
void OnSettingsApplied( wxCommandEvent& evt );

View File

@ -199,12 +199,12 @@ void BaseApplicableConfigPanel::OnSettingsApplied( wxCommandEvent& evt )
void BaseApplicableConfigPanel::AppStatusEvent_OnSettingsApplied() {}
BaseApplicableConfigPanel_SpecificConfig::BaseApplicableConfigPanel_SpecificConfig(wxWindow* parent, wxOrientation orient)
: BaseApplicableConfigPanel( parent, orient)
: BaseApplicableConfigPanel( parent, orient )
{
}
BaseApplicableConfigPanel_SpecificConfig::BaseApplicableConfigPanel_SpecificConfig(wxWindow* parent, wxOrientation orient, const wxString& staticLabel )
: BaseApplicableConfigPanel( parent, orient, staticLabel)
: BaseApplicableConfigPanel( parent, orient, staticLabel )
{
}