From: boca4711 <boc...@us...> - 2005-10-16 12:09:03
|
Update of /cvsroot/anyedit/AnyEditv2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19487 Added Files: FilePropGeneral.cpp FilePropGeneral.h Log Message: Page to show general file informations. --- NEW FILE: FilePropGeneral.h --- (This appears to be a binary file; contents omitted.) --- NEW FILE: FilePropGeneral.cpp --- // FilePropGeneral.cpp: Implementierungsdatei // #include "stdafx.h" #include "anyedit.h" #include "FilePropGeneral.h" #include "AnyEditDoc.h" #include "AnyEditView.h" #include "DateTimeFormat.h" #include "FilePropertyDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // Dialogfeld CFilePropGeneral CFilePropGeneral::CFilePropGeneral(CWnd* pParent /*=NULL*/) : CPropertyPage(CFilePropGeneral::IDD) { //{{AFX_DATA_INIT(CFilePropGeneral) m_strFileSize = _T(""); m_strSaveDate = _T(""); m_nIndentSize = 0; m_nTabSize = 0; m_strDescription = _T(""); m_strFilename = _T(""); //}}AFX_DATA_INIT m_hFileIcon = NULL; m_pFileProp = NULL; } void CFilePropGeneral::DoDataExchange(CDataExchange* pDX) { CPropertyPage::DoDataExchange(pDX); //{{AFX_DATA_MAP(CFilePropGeneral) DDX_Control(pDX, IDC_EDIT_DEFAULTS, m_iconDefaults); DDX_Control(pDX, IDC_EDIT_SPIN2, m_spinIndent); DDX_Control(pDX, IDC_EDIT_SPIN1, m_spinTab); DDX_Control(pDX, IDC_EDIT_LANGUAGE, m_comboLanguages); DDX_Control(pDX, IDC_EDIT_CRLF_STYLE, m_comboCRLFStyle); DDX_Text(pDX, IDC_EDIT_FILESIZE, m_strFileSize); DDX_Text(pDX, IDC_EDIT_SAVEDDATE, m_strSaveDate); DDX_Text(pDX, IDC_EDIT_INDENTSIZE, m_nIndentSize); DDV_MinMaxUInt(pDX, m_nIndentSize, 1, 32); DDX_Text(pDX, IDC_EDIT_TABSIZE, m_nTabSize); DDV_MinMaxUInt(pDX, m_nTabSize, 1, 32); DDX_Text(pDX, IDC_EDIT_DESCRIPTION, m_strDescription); DDX_Text(pDX, IDC_EDIT_FILENAME, m_strFilename); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CFilePropGeneral, CPropertyPage) //{{AFX_MSG_MAP(CFilePropGeneral) ON_CBN_SELCHANGE(IDC_EDIT_LANGUAGE, OnSelchangeEditLanguage) ON_CBN_SELCHANGE(IDC_EDIT_CRLF_STYLE, OnSelchangeEditCrlfStyle) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // Behandlungsroutinen für Nachrichten CFilePropGeneral BOOL CFilePropGeneral::OnInitDialog() { CPropertyPage::OnInitDialog(); if (m_pFileProp) { m_nTabSize = m_pFileProp->m_nTabSize; m_nIndentSize = m_pFileProp->m_nIndentSize; m_nCRLFStyle = m_pFileProp->m_nCRLF; } m_spinTab.SetBuddy(GetDlgItem(IDC_EDIT_TABSIZE)); m_spinTab.SetRange(1, 32); m_spinTab.SetPos(m_nTabSize); m_spinIndent.SetBuddy(GetDlgItem(IDC_EDIT_INDENTSIZE)); m_spinIndent.SetRange(1, 32); m_spinIndent.SetPos(m_nIndentSize); // m_comboCRLFStyle.AddString(_T("Automatic")); //TODO--From resource int nIndex = m_comboCRLFStyle.AddString(_T("Windows (CR LF)")); //TODO--From resource m_comboCRLFStyle.SetItemData(nIndex, SC_EOL_CRLF); nIndex = m_comboCRLFStyle.AddString(_T("Unix (LF)")); //TODO--From resource m_comboCRLFStyle.SetItemData(nIndex, SC_EOL_LF); nIndex = m_comboCRLFStyle.AddString(_T("Macintosh (CR)")); //TODO--From resource m_comboCRLFStyle.SetItemData(nIndex, SC_EOL_CR); for (int i = 0; i < m_comboCRLFStyle.GetCount(); i++) { if (m_comboCRLFStyle.GetItemData(i) == m_nCRLFStyle) { m_comboCRLFStyle.SetCurSel(i); break; } } /* switch (m_nCRLFStyle) { case SC_EOL_CRLF: m_comboCRLFStyle.SetCurSel(1); break; case SC_EOL_LF: m_comboCRLFStyle.SetCurSel(2); break; case SC_EOL_CR: m_comboCRLFStyle.SetCurSel(3); break; default: m_comboCRLFStyle.SetCurSel(0); } */ int nCurrentLexer = 0; CConfigFile* pConfigFile = theApp.GetConfigFile(); ASSERT(pConfigFile != NULL); int iActiveLanguage = -1; iActiveLanguage = m_pFileProp->m_nLanguage; int iNrOfLanguages = pConfigFile->GetLanguageCount(); for(int iCount = 0; iCount < iNrOfLanguages; ++ iCount ) { CString strLanguage(pConfigFile->GetLanguageName( iCount )); if (!strLanguage.IsEmpty()) { int nIndex = m_comboLanguages.AddString(strLanguage); m_comboLanguages.SetItemData(nIndex, (DWORD)iCount); } if (iActiveLanguage == iCount) nCurrentLexer = iCount; } m_comboLanguages.SetCurSel(nCurrentLexer); m_strFilename = m_pFileProp->m_strFilePath; if (!m_strFilename.IsEmpty()) // get and set file properties { SetDlgItemText(IDC_EDIT_FILENAME, m_strFilename); WIN32_FIND_DATA fd; HANDLE hFind = ::FindFirstFile(m_strFilename, &fd); if(hFind != INVALID_HANDLE_VALUE) { int nSizeK = (int)(fd.nFileSizeLow / 1024); // assume it not bigger than 2GB if (nSizeK == 0 && fd.nFileSizeLow != 0) nSizeK = 1; TCHAR szBuff[100]; wsprintf(szBuff, _T("%i KB"), nSizeK); SetDlgItemText(IDC_EDIT_FILESIZE, szBuff); COleDateTime odt(fd.ftLastWriteTime); CDateTimeFormat dtf; dtf.SetDateTime(odt); CString strFormat; TCHAR szTemp[MAX_PATH] = {0}; GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLONGDATE, szTemp, MAX_PATH); strFormat = szTemp; GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, szTemp, MAX_PATH); strFormat += _T(", "); strFormat += szTemp; dtf.SetFormat(strFormat); SetDlgItemText(IDC_EDIT_SAVEDDATE, dtf.GetString()); ::FindClose(hFind); } SHFILEINFO sfi; if (::SHGetFileInfo(m_strFilename, 0, &sfi, sizeof(SHFILEINFO), SHGFI_TYPENAME | SHGFI_ICON | SHGFI_SHELLICONSIZE | SHGFI_LARGEICON)) { m_hFileIcon = sfi.hIcon; m_strDescription = sfi.szTypeName; SetDlgItemText(IDC_EDIT_DESCRIPTION, m_strDescription); m_iconDefaults.SetIcon(m_hFileIcon); } } else { } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX-Eigenschaftenseiten sollten FALSE zurückgeben } CFilePropGeneral::~CFilePropGeneral() { if (m_hFileIcon != NULL) { ::DestroyIcon(m_hFileIcon); m_hFileIcon = NULL; } } void CFilePropGeneral::SetFileInfo(CFileProperty *pFileInfo) { m_pFileProp = pFileInfo; } void CFilePropGeneral::OnSelchangeEditLanguage() { int nIndex = m_comboLanguages.GetCurSel(); if (nIndex != CB_ERR && m_pFileProp != NULL) { m_pFileProp->m_nLanguage = m_comboLanguages.GetItemData(nIndex); } } void CFilePropGeneral::OnSelchangeEditCrlfStyle() { int nIndex = m_comboCRLFStyle.GetCurSel(); if (nIndex != CB_ERR && m_pFileProp != NULL) { m_pFileProp->m_nCRLF = m_comboCRLFStyle.GetItemData(nIndex); } } BOOL CFilePropGeneral::OnApply() { UpdateData(TRUE); if (m_pFileProp) { m_pFileProp->m_nTabSize = m_nTabSize; m_pFileProp->m_nIndentSize = m_nIndentSize; } return CPropertyPage::OnApply(); } |