Add FILE_NAME_WITH_PATH_CHAR_VALIDATOR, a custom wxValidator which allows file names with paths, in schematic sheet editor
( FILE_NAME_CHAR_VALIDATOR previously used in this dialog does not allow chars used in path names, like / and on Windows \ and : )
This commit is contained in:
parent
d12ffd307f
commit
7c9418f667
|
@ -6,7 +6,7 @@
|
|||
DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS( wxWindow* parent ) :
|
||||
DIALOG_SCH_SHEET_PROPS_BASE( parent )
|
||||
{
|
||||
m_textFileName->SetValidator( FILE_NAME_CHAR_VALIDATOR() );
|
||||
m_textFileName->SetValidator( FILE_NAME_WITH_PATH_CHAR_VALIDATOR() );
|
||||
m_textFileName->SetFocus();
|
||||
m_sdbSizer1OK->SetDefault();
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue )
|
||||
{
|
||||
// The Windows (DOS) file system forbidden characters already include the forbidden
|
||||
// file name characters for both Posix and OSX systems. The characters \/*?|"<> are
|
||||
// file name characters for both Posix and OSX systems. The characters \/:*?|"<> are
|
||||
// illegal and filtered by the validator.
|
||||
wxString illegalChars = wxFileName::GetForbiddenChars( wxPATH_DOS );
|
||||
wxTextValidator nameValidator( wxFILTER_EXCLUDE_CHAR_LIST );
|
||||
|
@ -55,3 +55,38 @@ public:
|
|||
SetExcludes( illegalCharList );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Class FILE_NAME_WITH_PATH_CHAR_VALIDATOR
|
||||
*
|
||||
* This class provides a custom wxValidator object for limiting the allowable characters when
|
||||
* defining file names with path, for instance in schematic sheet file names.
|
||||
*/
|
||||
class FILE_NAME_WITH_PATH_CHAR_VALIDATOR : public wxTextValidator
|
||||
{
|
||||
public:
|
||||
FILE_NAME_WITH_PATH_CHAR_VALIDATOR( wxString* aValue = NULL ) :
|
||||
wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue )
|
||||
{
|
||||
// The Windows (DOS) file system forbidden characters already include the forbidden
|
||||
// file name characters for both Posix and OSX systems. The characters *?|"<> are
|
||||
// illegal and filtered by the validator, but /\: are valid (\ and : only on Windows.
|
||||
wxString illegalChars = wxFileName::GetForbiddenChars(wxPATH_DOS );
|
||||
wxTextValidator nameValidator( wxFILTER_EXCLUDE_CHAR_LIST );
|
||||
wxArrayString illegalCharList;
|
||||
|
||||
for( unsigned i = 0; i < illegalChars.size(); i++ )
|
||||
{
|
||||
if( illegalChars[i] == '/' )
|
||||
continue;
|
||||
|
||||
#if defined (__WINDOWS__)
|
||||
if( illegalChars[i] == '\\' || illegalChars[i] == ':' )
|
||||
continue;
|
||||
#endif
|
||||
illegalCharList.Add( wxString( illegalChars[i] ) );
|
||||
}
|
||||
|
||||
SetExcludes( illegalCharList );
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue