From: Leon W. <moo...@us...> - 2005-01-27 13:41:50
|
Update of /cvsroot/anyedit/AnyEditv2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8814 Modified Files: FileTypeManager.cpp FileTypeManager.h Log Message: Added extra functions to determine the default file filter. Index: FileTypeManager.h =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/FileTypeManager.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** FileTypeManager.h 31 Jul 2004 15:53:52 -0000 1.7 --- FileTypeManager.h 27 Jan 2005 13:41:39 -0000 1.8 *************** *** 1,2 **** --- 1,26 ---- + /**************************************************************************** + Copyright (C) AnyEdit Team + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source distribution. + + http://www.anyedit.org + *****************************************************************************/ + // FileTypeManager.h: interface for the CFileTypeManager class. // *************** *** 34,40 **** --- 58,79 ---- { public: + /// Get the file filter of language iLanguage CString GetFileFilter( int iLanguage ); + + /// Get the file filter list for open/save dialogs CString GetFileDialogFilter(void); + + /// Get the default file filter for a dialog + int GetFileDialogFilterDefault(); + + /// Get the file filter from the current file for a dialog + int GetFileDialogFilterCurrentFile(); + + /// Set the last selected file filter + void SetLastUsedFileFilter( int iFilter ) { m_iLastSelectedFilter = iFilter; } + + /// Get the name of language iLanguage CString GetLanguageName(int iLanguage); + /// Get keywords for a given language separated by cSep. CString GetDelimitedKeywords(int iLanguage, char cSep = ' '); *************** *** 67,79 **** void SetScintillaProperties(int iLanguage, CScintillaEx* pScintilla, BOOL bSyntaxHighlighting); protected: /// Fill array with language names void FillLanguageNames(CConfigFile *pConfigFile); /// Array of language filters CStringArray m_arrFilters; /// Array of language Names CStringArray m_arrLanguageNames; ! /// Map of language number pointing to a CSytnaxFile object. CMap<int, int, CSyntaxFile*, CSyntaxFile*> mapSyntaxFiles; ! /// Map of Extension strings pointing to a language number. CMapStringToString mapExtensions; --- 106,125 ---- void SetScintillaProperties(int iLanguage, CScintillaEx* pScintilla, BOOL bSyntaxHighlighting); protected: + /// Last selected file filter. + int m_iLastSelectedFilter; + /// Fill array with language names void FillLanguageNames(CConfigFile *pConfigFile); + /// Array of language filters CStringArray m_arrFilters; + /// Array of language Names CStringArray m_arrLanguageNames; ! ! /// Map of language number pointing to a CSytnaxFile object. CMap<int, int, CSyntaxFile*, CSyntaxFile*> mapSyntaxFiles; ! ! /// Map of Extension strings pointing to a language number. CMapStringToString mapExtensions; Index: FileTypeManager.cpp =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/FileTypeManager.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** FileTypeManager.cpp 27 Sep 2004 10:10:39 -0000 1.24 --- FileTypeManager.cpp 27 Jan 2005 13:41:39 -0000 1.25 *************** *** 1,2 **** --- 1,26 ---- + /**************************************************************************** + Copyright (C) AnyEdit Team + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source distribution. + + http://www.anyedit.org + *****************************************************************************/ + // FileTypeManager.cpp: implementation of the CFileTypeManager class. // *************** *** 8,11 **** --- 32,36 ---- #include "SyntaxFile.h" #include "FileTypeManager.h" + #include "AnyEditDoc.h" #ifdef _DEBUG *************** *** 21,24 **** --- 46,50 ---- CFileTypeManager::CFileTypeManager() { + m_iLastSelectedFilter = 0; } *************** *** 498,509 **** if( NULL == pConfigFile ) return ""; ! // Don't add default language, start with language 1 ! // but only add if the user wants to ! if( theApp.GetConfigFile()->GetUseSyntaxFileFilters() ) { ! for( iCount = 1; iCount < m_arrLanguageNames.GetSize(); ++ iCount ) ! { ! strFilter += GetFileFilter( iCount ) + "|"; ! } } --- 524,531 ---- if( NULL == pConfigFile ) return ""; ! // First add the default language filters, start with language 1 ! for( iCount = 1; iCount < m_arrLanguageNames.GetSize(); ++ iCount ) { ! strFilter += GetFileFilter( iCount ) + "|"; } *************** *** 521,526 **** --- 543,578 ---- } + // This function is used by the Preference dialog to fill the list of filters. CString CFileTypeManager::GetFileFilter( int iLanguage ) { return GetLanguageName( iLanguage ) + " (" + m_arrFilters.GetAt( iLanguage ) + ")|" + m_arrFilters.GetAt( iLanguage ); } + + int CFileTypeManager::GetFileDialogFilterDefault() + { + CConfigFile* pConfigFile = theApp.GetConfigFile(); + if( NULL == pConfigFile ) return 0; + + switch( pConfigFile->GetFileFilterDefault() ) + { + case -2: // Current file + return m_iLastSelectedFilter = GetFileDialogFilterCurrentFile(); + case -1: // Last used + if( 0 == m_iLastSelectedFilter ) m_iLastSelectedFilter = pConfigFile->GetLanguageCount() + pConfigFile->GetFileFiltersCount() ; + return m_iLastSelectedFilter; + default: // Chosen filter + return m_iLastSelectedFilter = pConfigFile->GetFileFilterDefault(); + } + } + + int CFileTypeManager::GetFileDialogFilterCurrentFile() + { + CConfigFile* pConfigFile = theApp.GetConfigFile(); + if( NULL == pConfigFile ) return 0; + + m_iLastSelectedFilter = ((CAnyEditDoc*)theApp.GetCurrentDoc())->GetLanguageNr(); + + if( 0 == m_iLastSelectedFilter ) m_iLastSelectedFilter = pConfigFile->GetLanguageCount() + pConfigFile->GetFileFiltersCount() ; + + return m_iLastSelectedFilter; + } \ No newline at end of file |