Work-around incorrect spacing (and order) of buttons on Mac.

This commit is contained in:
Jeff Young 2021-08-31 22:38:45 +01:00
parent 345f506f0c
commit 2cdd3c9ebf
3 changed files with 31 additions and 26 deletions

View File

@ -153,12 +153,21 @@ long KIDIALOG::getStyle( KD_TYPE aType )
bool OverrideLock( wxWindow* aParent, const wxString& aMessage ) bool OverrideLock( wxWindow* aParent, const wxString& aMessage )
{ {
#ifdef __APPLE__
// wxMessageDialog gets the button spacing wrong on Mac so we have to use wxRichMessageDialog.
// Note that its warning icon is more like wxMessageDialog's error icon, so we use it instead
// of wxICON_ERROR.
wxRichMessageDialog dlg( aParent, aMessage, _( "File Open Error" ),
wxYES_NO | wxICON_WARNING | wxCENTER );
dlg.SetExtendedMessage( _( "Interleaved saves may produce very unexpected results." )
+ wxS( "\n" ) );
dlg.SetYesNoLabels( _( "OK" ), _( "Open Anyway" ) );
#else
wxMessageDialog dlg( aParent, aMessage, _( "File Open Error" ), wxMessageDialog dlg( aParent, aMessage, _( "File Open Error" ),
wxYES_NO | wxICON_ERROR | wxCENTER ); wxYES_NO | wxICON_ERROR | wxCENTER );
dlg.SetExtendedMessage( _( "Interleaved saves may produce very unexpected results." ) );
// Note: must use the "no" label to get the correct positioning/spacing for a (potentially) dlg.SetYesNoLabels( _( "OK" ), _( "Open Anyway" ) );
// destructive action #endif
dlg.SetYesNoLabels( _( "Do Not Open" ), _( "Open Anyway" ) );
return dlg.ShowModal() == wxID_NO; return dlg.ShowModal() == wxID_NO;
} }
@ -170,7 +179,8 @@ int UnsavedChangesDialog( wxWindow* parent, const wxString& aMessage, bool* aApp
wxRichMessageDialog dlg( parent, aMessage, _( "Save Changes?" ), wxRichMessageDialog dlg( parent, aMessage, _( "Save Changes?" ),
wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxICON_WARNING | wxCENTER ); wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxICON_WARNING | wxCENTER );
dlg.SetExtendedMessage( _( "If you don't save, all your changes will be permanently lost." ) ); dlg.SetExtendedMessage( _( "If you don't save, all your changes will be permanently lost." )
+ wxS( "\n" ) );
dlg.SetYesNoLabels( _( "Save" ), _( "Discard Changes" ) ); dlg.SetYesNoLabels( _( "Save" ), _( "Discard Changes" ) );
if( aApplyToAll ) if( aApplyToAll )
@ -192,7 +202,8 @@ int UnsavedChangesDialog( wxWindow* parent, const wxString& aMessage, bool* aApp
int UnsavedChangesDialog( wxWindow* parent, const wxString& aMessage ) int UnsavedChangesDialog( wxWindow* parent, const wxString& aMessage )
{ {
#ifdef __APPLE__ #ifdef __APPLE__
// wxWidgets gets the button order wrong on Mac so use the other dialog. // wxMessageDialog gets the button order (and spacing) wrong on Mac so we have to use
// wxRichMessageDialog.
return UnsavedChangesDialog( parent, aMessage, nullptr ); return UnsavedChangesDialog( parent, aMessage, nullptr );
#else #else
wxMessageDialog dlg( parent, aMessage, _( "Save Changes?" ), wxMessageDialog dlg( parent, aMessage, _( "Save Changes?" ),

View File

@ -114,15 +114,14 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
} }
wxString fullFileName( aFileSet[0] ); wxString fullFileName( aFileSet[0] );
wxFileName wx_filename( fullFileName );
// We insist on caller sending us an absolute path, if it does not, we say it's a bug. // We insist on caller sending us an absolute path, if it does not, we say it's a bug.
wxASSERT_MSG( wxFileName( fullFileName ).IsAbsolute(), wxT( "Path is not absolute!" ) ); wxASSERT_MSG( wx_filename.IsAbsolute(), wxT( "Path is not absolute!" ) );
if( !LockFile( fullFileName ) ) if( !LockFile( fullFileName ) )
{ {
msg.Printf( _( "Schematic file '%s' is already open.\n\n" msg.Printf( _( "Schematic '%s' is already open." ), wx_filename.GetFullName() );
"Interleaved saves may produce very unexpected results.\n" ),
fullFileName );
if( !OverrideLock( this, msg ) ) if( !OverrideLock( this, msg ) )
return false; return false;
@ -1119,6 +1118,7 @@ bool SCH_EDIT_FRAME::doAutoSave()
bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType ) bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
{ {
wxFileName filename( aFileName );
wxFileName newfilename; wxFileName newfilename;
SCH_SHEET_LIST sheetList = Schematic().GetSheets(); SCH_SHEET_LIST sheetList = Schematic().GetSheets();
SCH_IO_MGR::SCH_FILE_T fileType = (SCH_IO_MGR::SCH_FILE_T) aFileType; SCH_IO_MGR::SCH_FILE_T fileType = (SCH_IO_MGR::SCH_FILE_T) aFileType;
@ -1129,15 +1129,12 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
case SCH_IO_MGR::SCH_CADSTAR_ARCHIVE: case SCH_IO_MGR::SCH_CADSTAR_ARCHIVE:
case SCH_IO_MGR::SCH_EAGLE: case SCH_IO_MGR::SCH_EAGLE:
// We insist on caller sending us an absolute path, if it does not, we say it's a bug. // We insist on caller sending us an absolute path, if it does not, we say it's a bug.
wxASSERT_MSG( wxFileName( aFileName ).IsAbsolute(), wxASSERT_MSG( filename.IsAbsolute(), wxT( "Import schematic: path is not absolute!" ) );
wxT( "Import schematic caller didn't send full filename" ) );
if( !LockFile( aFileName ) ) if( !LockFile( aFileName ) )
{ {
wxString msg; wxString msg;
msg.Printf( _( "Schematic file '%s' is already open.\n\n" msg.Printf( _( "Schematic '%s' is already open." ), filename.GetFullName() );
"Interleaved saves may produce very unexpected results.\n" ),
aFileName );
if( !OverrideLock( this, msg ) ) if( !OverrideLock( this, msg ) )
return false; return false;

View File

@ -564,23 +564,20 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
} }
wxString fullFileName( aFileSet[0] ); wxString fullFileName( aFileSet[0] );
wxFileName wx_filename( fullFileName );
wxString msg; wxString msg;
if( Kiface().IsSingle() ) if( Kiface().IsSingle() )
{
KIPLATFORM::APP::RegisterApplicationRestart( fullFileName ); KIPLATFORM::APP::RegisterApplicationRestart( fullFileName );
}
// We insist on caller sending us an absolute path, if it does not, we say it's a bug. // We insist on caller sending us an absolute path, if it does not, we say it's a bug.
wxASSERT_MSG( wxFileName( fullFileName ).IsAbsolute(), wxT( "Path is not absolute!" ) ); wxASSERT_MSG( wx_filename.IsAbsolute(), wxT( "Path is not absolute!" ) );
std::unique_ptr<wxSingleInstanceChecker> lockFile = ::LockFile( fullFileName ); std::unique_ptr<wxSingleInstanceChecker> lockFile = ::LockFile( fullFileName );
if( !lockFile || lockFile->IsAnotherRunning() ) if( !lockFile || lockFile->IsAnotherRunning() )
{ {
msg.Printf( _( "PCB file '%s' is already open.\n\n" msg.Printf( _( "PCB '%s' is already open." ), wx_filename.GetFullName() );
"Interleaved saves may produce very unexpected results.\n" ),
fullFileName );
if( !OverrideLock( this, msg ) ) if( !OverrideLock( this, msg ) )
return false; return false;