From: Frank Li Date: Tue, 14 Apr 2009 05:40:52 +0000 (+0800) Subject: Add Patch List to Sendmail Listctrl. X-Git-Url: http://git.sourceforge.jp/view?p=tortoisegit%2FTortoiseGitJp.git;a=commitdiff_plain;h=68af400f23af3a02d99151ba703321ee2b6e0285 Add Patch List to Sendmail Listctrl. Signed-off-by: Frank Li --- diff --git a/src/Resources/TortoiseProcENG.rc b/src/Resources/TortoiseProcENG.rc index 928c47e..88ebf07 100644 Binary files a/src/Resources/TortoiseProcENG.rc and b/src/Resources/TortoiseProcENG.rc differ diff --git a/src/TortoiseProc/Commands/SendMailCommand.cpp b/src/TortoiseProc/Commands/SendMailCommand.cpp index 1dd7a62..2ac80c9 100644 --- a/src/TortoiseProc/Commands/SendMailCommand.cpp +++ b/src/TortoiseProc/Commands/SendMailCommand.cpp @@ -5,6 +5,9 @@ bool SendMailCommand::Execute() { CSendMailDlg dlg; + + dlg.m_PathList = orgPathList; + if(dlg.DoModal()==IDOK) { return true; diff --git a/src/TortoiseProc/SendMailDlg.cpp b/src/TortoiseProc/SendMailDlg.cpp index fdcd57d..47914da 100644 --- a/src/TortoiseProc/SendMailDlg.cpp +++ b/src/TortoiseProc/SendMailDlg.cpp @@ -4,8 +4,8 @@ #include "stdafx.h" #include "TortoiseProc.h" #include "SendMailDlg.h" - - +#include "MessageBox.h" +#include "commonresource.h" // CSendMailDlg dialog IMPLEMENT_DYNAMIC(CSendMailDlg, CResizableStandAloneDialog) @@ -35,11 +35,14 @@ void CSendMailDlg::DoDataExchange(CDataExchange* pDX) DDX_Check(pDX, IDC_SENDMAIL_COMBINE, m_bBranch); DDX_Control(pDX, IDC_SENDMAIL_PATCHS, m_ctrlList); DDX_Control(pDX,IDC_SENDMAIL_SETUP, this->m_SmtpSetup); + DDX_Control(pDX,IDC_SENDMAIL_TO,m_ctrlTO); + DDX_Control(pDX,IDC_SENDMAIL_CC,m_ctrlCC); } BEGIN_MESSAGE_MAP(CSendMailDlg, CResizableStandAloneDialog) ON_BN_CLICKED(IDC_SENDMAIL_COMBINE, &CSendMailDlg::OnBnClickedSendmailCombine) + ON_BN_CLICKED(IDOK, &CSendMailDlg::OnBnClickedOk) END_MESSAGE_MAP() @@ -61,9 +64,65 @@ BOOL CSendMailDlg::OnInitDialog() this->AddOthersToAnchor(); EnableSaveRestore(_T("SendMailDlg")); + + m_ctrlCC.Init(); + m_ctrlTO.Init(); + + m_ctrlCC.SetSeparator(_T(";")); + m_ctrlTO.SetSeparator(_T(";")); + + m_AddressReg.SetMaxHistoryItems(0xFFFF); + + m_AddressReg.Load(_T("Software\\TortoiseGit\\TortoiseProc\\EmailAddress\\"),_T("email")); + for(int i=0;iUpdateData(); + if(this->m_To.IsEmpty() && this->m_CC.IsEmpty()) + { + CMessageBox::Show(NULL,IDS_ERR_ADDRESS_NO_EMPTY,IDS_APPNAME,MB_OK|MB_ICONERROR); + return; + } + int start =0; + CString Address; + while(start>=0) + { + Address=this->m_CC.Tokenize(_T(";"),start); + m_AddressReg.AddEntry(Address); + m_AddressReg.Save(); + } + start =0; + while(start>=0) + { + Address=this->m_To.Tokenize(_T(";"),start); + m_AddressReg.AddEntry(Address); + m_AddressReg.Save(); + } + + OnOK(); + // TODO: Add your control notification handler code here +} diff --git a/src/TortoiseProc/SendMailDlg.h b/src/TortoiseProc/SendMailDlg.h index 8b119d3..427cfb2 100644 --- a/src/TortoiseProc/SendMailDlg.h +++ b/src/TortoiseProc/SendMailDlg.h @@ -3,6 +3,9 @@ #include "StandAloneDlg.h" #include "HyperLink.h" // CSendMailDlg dialog +#include "ACEdit.h" +#include "RegHistory.h" +#include "TGitPath.h" class CSendMailDlg : public CResizableStandAloneDialog { @@ -22,6 +25,9 @@ protected: CHyperLink m_SmtpSetup; + CACEdit m_ctrlCC; + CACEdit m_ctrlTO; + CRegHistory m_AddressReg; public: CString m_To; CString m_CC; @@ -29,5 +35,8 @@ public: BOOL m_bAttachment; BOOL m_bBranch; CListCtrl m_ctrlList; + CTGitPathList m_PathList; + afx_msg void OnBnClickedSendmailCombine(); + afx_msg void OnBnClickedOk(); }; diff --git a/src/TortoiseProc/resource.h b/src/TortoiseProc/resource.h index 90ee32d..c9996a2 100644 Binary files a/src/TortoiseProc/resource.h and b/src/TortoiseProc/resource.h differ diff --git a/src/Utils/ACEdit.cpp b/src/Utils/ACEdit.cpp new file mode 100644 index 0000000..826fd2d --- /dev/null +++ b/src/Utils/ACEdit.cpp @@ -0,0 +1,680 @@ +// ACEdit.cpp: Implementierungsdatei +// + +#include "stdafx.h" +#include "ACEdit.h" +#include + + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#define _EDIT_ 1 +#define _COMBOBOX_ 2 + +///////////////////////////////////////////////////////////////////////////// +// CACEdit + +CACEdit::CACEdit() +{ + m_iMode = _MODE_STANDARD_; + m_iType = -1; + m_pEdit = NULL; + m_CursorMode = false; + m_PrefixChar = 0; +} + +/*********************************************************************/ + +CACEdit::~CACEdit() +{ + DestroyWindow(); +} + +/*********************************************************************/ + +BEGIN_MESSAGE_MAP(CACEdit, CWnd) + //{{AFX_MSG_MAP(CACEdit) + ON_CONTROL_REFLECT(EN_KILLFOCUS, OnKillfocus) + ON_CONTROL_REFLECT(CBN_KILLFOCUS, OnKillfocus) + ON_WM_KEYDOWN() + ON_CONTROL_REFLECT(EN_CHANGE, OnChange) + ON_CONTROL_REFLECT(CBN_EDITCHANGE, OnChange) + ON_CONTROL_REFLECT(CBN_DROPDOWN, OnCloseList) + //}}AFX_MSG_MAP + ON_MESSAGE(ENAC_UPDATE,OnUpdateFromList) +END_MESSAGE_MAP() + +/*********************************************************************/ + +void CACEdit::SetMode(int iMode) +{ + if(m_iType == -1) + Init(); + + m_iMode = iMode; + + /* + ** Vers. 1.1 + ** NEW: _MODE_CURSOR_O_LIST_ + */ + if(iMode == _MODE_CURSOR_O_LIST_) + m_iMode |= _MODE_STANDARD_; + + if(iMode & _MODE_FILESYSTEM_) + m_SeparationStr = _T("\\"); + + // Vers. 1.2 + if(iMode & _MODE_FIND_ALL_) + { + m_Liste.m_lMode |= _MODE_FIND_ALL_; + } +} + +/*********************************************************************/ + +void CACEdit::Init() +{ + CString szClassName = AfxRegisterWndClass(CS_CLASSDC|CS_SAVEBITS|CS_HREDRAW|CS_VREDRAW, + 0,(HBRUSH) (COLOR_WINDOW), 0); + CRect rcWnd,rcWnd1; + GetWindowRect(rcWnd); + + VERIFY(m_Liste.CreateEx(WS_EX_TOOLWINDOW, + szClassName,NULL, + WS_THICKFRAME | WS_CHILD | WS_BORDER | + WS_CLIPSIBLINGS | WS_OVERLAPPED, + CRect(rcWnd.left, rcWnd.top +20, rcWnd.left+ 200, rcWnd.top+200), + GetDesktopWindow(), + 0x3E8, NULL)); + + CString m_ClassName; + ::GetClassName(GetSafeHwnd(), m_ClassName.GetBuffer(32), 32); + m_ClassName.ReleaseBuffer(); + + if (m_ClassName.Compare(_T("Edit")) == 0) + { + m_iType = _EDIT_; + } + else + { + if (m_ClassName.Compare(_T("ComboBox")) == 0) + { + m_iType = _COMBOBOX_; + + m_pEdit = (CEdit*)GetWindow(GW_CHILD); + VERIFY(m_pEdit); + ::GetClassName(m_pEdit->GetSafeHwnd(), m_ClassName.GetBuffer(32), 32); + m_ClassName.ReleaseBuffer(); + VERIFY(m_ClassName.Compare(_T("Edit")) == 0); + } + } + + if(m_iType == -1) + { + ASSERT(0); + return; + } + + m_Liste.Init(this); +} + +/*********************************************************************/ + +void CACEdit::AddSearchStrings(LPCTSTR Strings[]) +{ + int i = 0; + LPCTSTR str; + if(m_iType == -1) {ASSERT(0); return;} + + m_Liste.RemoveAll(); + + do + { + str = Strings[i]; + if(str) + { + m_Liste.AddSearchString(str); + } + + i++; + } + while(str); + + m_Liste.SortSearchList(); +} + +/*********************************************************************/ + +void CACEdit::AddSearchString(LPCTSTR lpszString) +{ + if(m_iType == -1) {ASSERT(0); return;} + + m_Liste.AddSearchString(lpszString); +} + +/*********************************************************************/ + +void CACEdit::RemoveSearchAll() +{ + if(m_iType == -1) {ASSERT(0); return;} + + m_Liste.RemoveAll(); +} + +/*********************************************************************/ + +void CACEdit::OnKillfocus() +{ + if(m_Liste.GetSafeHwnd()) // fix Vers 1.1 + m_Liste.ShowWindow(false); +} + +/*********************************************************************/ + +void CACEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ + if(!HandleKey(nChar,false)) + CWnd::OnKeyDown(nChar, nRepCnt, nFlags); +} + +/*********************************************************************/ + +bool CACEdit::HandleKey(UINT nChar, bool m_bFromChild) +{ + if (nChar == VK_ESCAPE ||nChar == VK_RETURN) + { + m_Liste.ShowWindow(false); + return true; + } + + if (nChar == VK_DOWN || nChar == VK_UP + || nChar == VK_PRIOR || nChar == VK_NEXT + || nChar == VK_HOME || nChar == VK_END) + { + /* + ** Vers. 1.1 + ** NEW: _MODE_CURSOR_O_LIST_ + */ + if(!m_Liste.IsWindowVisible() && (m_iMode & _MODE_CURSOR_O_LIST_)) + { + GetWindowText(m_EditText); + if(m_EditText.IsEmpty()) + { + m_Liste.CopyList(); + return true; + } + } + + if(m_Liste.IsWindowVisible()) + { + int pos; + + + if(m_iMode & _MODE_STANDARD_ + || m_iMode & _MODE_FILESYSTEM_ + || m_iMode & _MODE_FS_START_DIR_) + { + m_CursorMode = true; + + if(!m_bFromChild) + m_EditText = m_Liste.GetNextString(nChar); + else + m_EditText = m_Liste.GetString(); + + if(m_iMode & _MODE_FILESYSTEM_) + { + if (m_EditText.Right(1) == _T('\\')) + m_EditText = m_EditText.Mid(0,m_EditText.GetLength()-1); + } + + m_Liste.SelectItem(-1); + SetWindowText(m_EditText); + pos = m_EditText.GetLength(); + + if(m_iType == _COMBOBOX_) + { + m_pEdit->SetSel(pos,pos,true); + m_pEdit->SetModify(true); + } + + if(m_iType == _EDIT_) + { + ((CEdit*)this)->SetSel(pos,pos,true); + ((CEdit*)this)->SetModify(true); + } + + GetParent()->SendMessage(ENAC_UPDATE, WM_KEYDOWN, GetDlgCtrlID()); + m_CursorMode = false; + return true; + } + + if(m_iMode & _MODE_SEPARATION_) + { + CString m_Text,m_Left,m_Right; + int left,right,pos=0,len; + + m_CursorMode = true; + + GetWindowText(m_EditText); + + if(m_iType == _EDIT_) + pos = LOWORD(((CEdit*)this)->CharFromPos(GetCaretPos())); + + if(m_iType == _COMBOBOX_) + pos = m_pEdit->CharFromPos(m_pEdit->GetCaretPos()); + + left = FindSepLeftPos(pos-1,true); + right = FindSepRightPos(pos); + + m_Text = m_EditText.Left(left); + + if(!m_bFromChild) + m_Text += m_Liste.GetNextString(nChar); + else + m_Text += m_Liste.GetString(); + + m_Liste.SelectItem(-1); + m_Text += m_EditText.Mid(right); + len = m_Liste.GetString().GetLength(); + + m_Text += this->m_SeparationStr; + + SetWindowText(m_Text); + GetParent()->SendMessage(ENAC_UPDATE, WM_KEYDOWN, GetDlgCtrlID()); + + right = FindSepLeftPos2(pos-1); + left -= right; + len += right; + + left+=m_SeparationStr.GetLength(); + + if(m_iType == _EDIT_) + { + ((CEdit*)this)->SetModify(true); + ((CEdit*)this)->SetSel(left+len,left+len,false); + } + + if(m_iType == _COMBOBOX_) + { + m_pEdit->SetModify(true); + m_pEdit->SetSel(left,left+len,true); + } + + m_CursorMode = false; + return true; + } + } + } + return false; +} + +/*********************************************************************/ + +void CACEdit::OnChange() +{ + CString m_Text; + int pos=0,len; + + if(m_iType == -1) + {ASSERT(0); return;} + + GetWindowText(m_EditText); + len = m_EditText.GetLength(); + //---------------------------------------------- + if(m_iMode & _MODE_FILESYSTEM_ || m_iMode & _MODE_FS_START_DIR_) + { + if(!m_CursorMode) + { + if(m_iType == _EDIT_) + pos = LOWORD(((CEdit*)this)->CharFromPos(GetCaretPos())); + + if(m_iType == _COMBOBOX_) + pos = m_pEdit->CharFromPos(m_pEdit->GetCaretPos()); + + if(m_iMode & _MODE_FS_START_DIR_) + { + if(len) + m_Liste.FindString(-1,m_EditText); + else + m_Liste.ShowWindow(false); + } + else + { + if(len > 2 && pos == len) + { + if(_taccess(m_EditText,0) == 0) + { + ReadDirectory(m_EditText); + } + m_Liste.FindString(-1,m_EditText); + } + else + m_Liste.ShowWindow(false); + } + } // m_CursorMode + } + //---------------------------------------------- + if(m_iMode & _MODE_SEPARATION_) + { + if(!m_CursorMode) + { + if(m_iType == _EDIT_) + pos = LOWORD(((CEdit*)this)->CharFromPos(GetCaretPos())); + + if(m_iType == _COMBOBOX_) + pos = m_pEdit->CharFromPos(m_pEdit->GetCaretPos()); + + int left,right; + left = FindSepLeftPos(pos-1); + right = FindSepRightPos(pos); + m_Text = m_EditText.Mid(left,right-left); + m_Liste.FindString(-1,m_Text); + } + } + //---------------------------------------------- + if(m_iMode & _MODE_STANDARD_) + { + if(!m_CursorMode) + m_Liste.FindString(-1,m_EditText); + } + //---------------------------------------------- + GetParent()->SendMessage(ENAC_UPDATE, EN_UPDATE, GetDlgCtrlID()); +} + +/*********************************************************************/ + +int CACEdit::FindSepLeftPos(int pos,bool m_bIncludePrefix) +{ + int len = m_EditText.GetLength(); + TCHAR ch; + int i; + + if(pos >= len && len != 1) + pos = len -1; + + for(i = pos; i >= 0 ; i--) + { + ch = m_EditText.GetAt(i); + if(m_PrefixChar == ch) + return i + (m_bIncludePrefix ? 1 : 0); + if(m_SeparationStr.Find(ch) != -1) + break; + } + + return i + 1; +} + +/*********************************************************************/ + +int CACEdit::FindSepLeftPos2(int pos) +{ + int len = m_EditText.GetLength(); + TCHAR ch; + + if(pos >= len && len != 1) + pos = len -1; + + if(len == 1) + return 0; + + for(int i = pos; i >= 0 ; i--) + { + ch = m_EditText.GetAt(i); + if(m_PrefixChar == ch) + return 1; + } + + return 0; +} + +/*********************************************************************/ + +int CACEdit::FindSepRightPos(int pos) +{ + int len = m_EditText.GetLength(); + TCHAR ch; + int i; + + for(i = pos; i < len ; i++) + { + ch = m_EditText.GetAt(i); + if(m_SeparationStr.Find(ch) != -1) + break; + } + + return i; +} + +/*********************************************************************/ + +LONG CACEdit::OnUpdateFromList(UINT lParam, LONG /*wParam*/) +{ + UpdateData(true); + + if(lParam == WM_KEYDOWN) + { + HandleKey(VK_DOWN,true); + } + return 0; +} + +/*********************************************************************/ + +void CACEdit::OnCloseList() +{ + m_Liste.ShowWindow(false); +} + +/*********************************************************************/ + +BOOL CACEdit::PreTranslateMessage(MSG* pMsg) +{ + if(pMsg->message == WM_KEYDOWN) + { + if(m_Liste.IsWindowVisible()) + { + if(m_iType == _COMBOBOX_) + { + if(pMsg->wParam == VK_DOWN || pMsg->wParam == VK_UP) + if(HandleKey(pMsg->wParam,false)) + return true; + } + + if(pMsg->wParam == VK_ESCAPE || pMsg->wParam == VK_RETURN) + if(HandleKey(pMsg->wParam,false)) + return true; + } + } + return CWnd::PreTranslateMessage(pMsg); +} + +/*********************************************************************/ + +void CACEdit::ReadDirectory(CString m_Dir) +{ + CFileFind FoundFiles; + TCHAR ch; + CWaitCursor hg; + + // Wenn mittem im Pfad, + // vorheriges Verzeichnis einlesen. + if (m_Dir.Right(1) != _T('\\')) + { + _tsplitpath(m_Dir, m_szDrive, m_szDir, m_szFname, m_szExt); + m_Dir.Format(_T("%s%s"),m_szDrive, m_szDir); + } + + //ist hübscher + ch = (TCHAR)towupper(m_Dir.GetAt(0)); + m_Dir.SetAt(0,ch); + + CString m_Name,m_File,m_Dir1 = m_Dir; + if (m_Dir.Right(1) != _T('\\')) + m_Dir += _T("\\"); + + if(m_LastDirectory.CompareNoCase(m_Dir) == 0 && m_Liste.m_SearchList.GetSize()) + return; + + m_LastDirectory = m_Dir; + m_Dir += _T("*.*"); + + BOOL bContinue = FoundFiles.FindFile(m_Dir); + if(bContinue) + RemoveSearchAll(); + + while (bContinue == TRUE) + { + bContinue = FoundFiles.FindNextFile(); + m_File = FoundFiles.GetFileName(); + + if(FoundFiles.IsHidden() || FoundFiles.IsSystem()) + continue; + if(FoundFiles.IsDirectory()) + { + if(m_iMode & _MODE_ONLY_FILES) + continue; + if(FoundFiles.IsDots()) + continue; + + if (m_File.Right(1) != _T('\\')) + m_File += _T("\\"); + } + + if(!FoundFiles.IsDirectory()) + if(m_iMode & _MODE_ONLY_DIRS) + continue; + + if(m_iMode & _MODE_FS_START_DIR_) + { + m_Name = m_File; + } + else + { + m_Name = m_Dir1; + if (m_Name.Right(1) != _T('\\')) + m_Name += _T("\\"); + + m_Name += m_File; + } + + AddSearchString(m_Name); + } + FoundFiles.Close(); + return; + +} + +/*********************************************************************/ + +void CACEdit::SetStartDirectory(LPCTSTR lpszString) +{ + if(m_iType == -1) {ASSERT(0); return;} + + if(m_iMode & _MODE_FS_START_DIR_) + ReadDirectory(lpszString); +} + +/********************************************************************* +** CComboBox +** NEW:V1.1 +*********************************************************************/ + +int CACEdit::AddString( LPCTSTR lpszString ) +{ + if(m_iType == _COMBOBOX_) + { + return ((CComboBox *)this)->AddString(lpszString); + } + return CB_ERR; +} + +/*********************************************************************/ + +int CACEdit::SetDroppedWidth( UINT nWidth ) +{ + if(m_iType == _COMBOBOX_) + { + return ((CComboBox *)this)->SetDroppedWidth(nWidth); + } + return CB_ERR; +} + +/*********************************************************************/ + +int CACEdit::FindString( int nStartAfter, LPCTSTR lpszString ) +{ + if(m_iType == _COMBOBOX_) + { + return ((CComboBox *)this)->FindString(nStartAfter,lpszString); + } + return CB_ERR; +} + +/*********************************************************************/ + +int CACEdit::SelectString( int nStartAfter, LPCTSTR lpszString ) +{ + if(m_iType == _COMBOBOX_) + { + return ((CComboBox *)this)->SelectString(nStartAfter,lpszString); + } + return CB_ERR; +} + +/*********************************************************************/ + +void CACEdit::ShowDropDown(BOOL bShowIt) +{ + if(m_iType == _COMBOBOX_) + { + ((CComboBox *)this)->ShowDropDown(bShowIt); + } +} + +/*********************************************************************/ + +void CACEdit::ResetContent() +{ + if(m_iType == _COMBOBOX_) + { + ((CComboBox *)this)->ResetContent(); + } +} + +/*********************************************************************/ + +int CACEdit::GetCurSel() +{ + if(m_iType == _COMBOBOX_) + { + return ((CComboBox *)this)->GetCurSel(); + } + return CB_ERR; +} + +/*********************************************************************/ + +int CACEdit::GetLBText( int nIndex, LPTSTR lpszText ) +{ + if(m_iType == _COMBOBOX_) + { + return ((CComboBox *)this)->GetLBText(nIndex,lpszText); + } + return CB_ERR; +} + +/*********************************************************************/ + +void CACEdit::GetLBText( int nIndex, CString& rString ) +{ + if(m_iType == _COMBOBOX_) + { + ((CComboBox *)this)->GetLBText(nIndex,rString); + } +} + +/*********************************************************************/ diff --git a/src/Utils/ACEdit.h b/src/Utils/ACEdit.h new file mode 100644 index 0000000..26454fa --- /dev/null +++ b/src/Utils/ACEdit.h @@ -0,0 +1,117 @@ +#if !defined(AFX_ACEDIT_H__56D21C13_ECEA_41DF_AADF_55980E861AC2__INCLUDED_) +#define AFX_ACEDIT_H__56D21C13_ECEA_41DF_AADF_55980E861AC2__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// ACEdit.h : Header-Datei +// + +/********************************************************************* +* +* CACEdit +* Copyright (c) 2003 by Andreas Kapust +* All rights reserved. +* info@akinstaller.de +* +*********************************************************************/ + + +#define _MODE_ONLY_FILES (1L << 16) +#define _MODE_ONLY_DIRS (1L << 17) + +#define _MODE_STANDARD_ (1L << 0) +#define _MODE_SEPARATION_ (1L << 1) +#define _MODE_FILESYSTEM_ (1L << 2) +#define _MODE_FS_START_DIR_ (1L << 3) +#define _MODE_CURSOR_O_LIST_ (1L << 4) +#define _MODE_FIND_ALL_ (1L << 5) + +#define _MODE_FS_ONLY_FILE_ (_MODE_FILESYSTEM_|_MODE_ONLY_FILES) +#define _MODE_FS_ONLY_DIR_ (_MODE_FILESYSTEM_|_MODE_ONLY_DIRS) +#define _MODE_SD_ONLY_FILE_ (_MODE_FS_START_DIR_|_MODE_ONLY_FILES) +#define _MODE_SD_ONLY_DIR_ (_MODE_FS_START_DIR_|_MODE_ONLY_DIRS) //Fix 1.2 + +///////////////////////////////////////////////////////////////////////////// +// Fenster CACEdit +#include "ACListWnd.h" + + +class CACEdit : public CWnd //CEdit +{ + // Konstruktion +public: + CACEdit(); + void SetMode(int iMode=_MODE_STANDARD_); + void SetSeparator(LPCTSTR lpszString,TCHAR lpszPrefixChar = 0) + { + m_SeparationStr = lpszString; + m_Liste.m_PrefixChar = m_PrefixChar = lpszPrefixChar; + SetMode(_MODE_SEPARATION_); + } + + // CComboBox + int AddString( LPCTSTR lpszString); + int GetLBText( int nIndex, LPTSTR lpszText ); + void GetLBText( int nIndex, CString& rString ); + int SetDroppedWidth(UINT nWidth); + int FindString( int nStartAfter, LPCTSTR lpszString ); + int SelectString( int nStartAfter, LPCTSTR lpszString ); + void ShowDropDown(BOOL bShowIt = TRUE ); + void ResetContent(); + int GetCurSel(); + // Attribute +public: + void Init(); + void AddSearchString(LPCTSTR lpszString); + void AddSearchStrings(LPCTSTR Strings[]); + void RemoveSearchAll(); + void SetStartDirectory(LPCTSTR lpszString); + // Operationen +public: + + // Überschreibungen + // Vom Klassen-Assistenten generierte virtuelle Funktionsüberschreibungen + //{{AFX_VIRTUAL(CACEdit) +public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + //}}AFX_VIRTUAL + + // Implementierung +public: + virtual ~CACEdit(); + CACListWnd m_Liste; + // Generierte Nachrichtenzuordnungsfunktionen +protected: + CString m_EditText, m_SeparationStr,m_LastDirectory; + TCHAR m_PrefixChar; + int m_iMode; + //{{AFX_MSG(CACEdit) + afx_msg void OnKillfocus(); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + afx_msg void OnChange(); + afx_msg void OnCloseList(); + //}}AFX_MSG + afx_msg LONG OnUpdateFromList(UINT lParam, LONG wParam); + DECLARE_MESSAGE_MAP() + + + void ReadDirectory(CString m_Dir); + int FindSepLeftPos(int pos, bool FindSepLeftPos = false); + int FindSepLeftPos2(int pos); + int FindSepRightPos(int pos); + bool HandleKey(UINT nChar, bool m_bFromChild); + + bool m_CursorMode; + int m_iType; + CEdit *m_pEdit; + + TCHAR m_szDrive[_MAX_DRIVE], m_szDir[_MAX_DIR],m_szFname[_MAX_FNAME], m_szExt[_MAX_EXT]; +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ fügt unmittelbar vor der vorhergehenden Zeile zusätzliche Deklarationen ein. + +#endif // AFX_ACEDIT_H__56D21C13_ECEA_41DF_AADF_55980E861AC2__INCLUDED_ diff --git a/src/Utils/ACListWnd.cpp b/src/Utils/ACListWnd.cpp new file mode 100644 index 0000000..4ec4363 --- /dev/null +++ b/src/Utils/ACListWnd.cpp @@ -0,0 +1,933 @@ +// ACWnd.cpp: Implementierungsdatei +// + +#include "stdafx.h" +#include "ACListWnd.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +static UINT auIDStatusBar[] = +{ + ID_SEPARATOR +}; + +#define _MAX_ENTRYS_ 8 +#define _MODE_FIND_ALL_ (1L << 5) + +///////////////////////////////////////////////////////////////////////////// +// CACListWnd + +void DoPaintMessageLoop() +{ + MSG message1; + while(::PeekMessage(&message1,NULL,WM_PAINT,WM_PAINT, PM_REMOVE)) + { + ::TranslateMessage(&message1); + ::DispatchMessage(&message1); + } +} + +/**********************************************************************/ + +CACListWnd::CACListWnd() +{ + m_lTopIndex = 0; + m_lCount = 0; + m_ItemHeight = 16; + m_lSelItem = -1; + m_VisibleItems = 0; + m_pEditParent = NULL; + m_LastSize.SetRectEmpty(); + m_PrefixChar = 0; + m_lMode = 0; +} + +/**********************************************************************/ + +CACListWnd::~CACListWnd() +{ + m_SearchList.RemoveAll(); + m_DisplayList.RemoveAll(); + DestroyWindow(); +} + +/*********************************************************************/ + +void CACListWnd::OnActivateApp(BOOL bActive, DWORD dwThreadID) +{ +#if (_MSC_VER >= 1300) + CWnd::OnActivateApp(bActive, dwThreadID); //vc7 FIX 1.2 +#else + CWnd::OnActivateApp(bActive, (HTASK)dwThreadID); //vc6 FIX 1.2 +#endif + + ShowWindow(false); +} + + +BEGIN_MESSAGE_MAP(CACListWnd, CWnd) + //{{AFX_MSG_MAP(CACListWnd) + ON_WM_PAINT() + ON_WM_SIZE() + ON_WM_ERASEBKGND() + ON_WM_NCPAINT() + ON_WM_KEYDOWN() + ON_WM_NCCALCSIZE() + ON_WM_VSCROLL() + ON_WM_ACTIVATEAPP() + ON_WM_NCHITTEST() + ON_WM_LBUTTONDOWN() + ON_WM_RBUTTONDOWN() + ON_WM_SETCURSOR() + ON_WM_SHOWWINDOW() + ON_WM_NCLBUTTONDOWN() + ON_WM_MOUSEMOVE() + ON_WM_TIMER() + ON_WM_GETMINMAXINFO() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + + +///////////////////////////////////////////////////////////////////////////// +// Behandlungsroutinen für Nachrichten CACListWnd + +void CACListWnd::DrawItem(CDC* pDC,long m_lItem,long width) +{ + long y = m_lItem - m_lTopIndex; + CRect rcLabel(2,y*m_ItemHeight,width,(y+1)*m_ItemHeight); + + pDC->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT)); + + if(m_lItem == m_lSelItem) + { + rcLabel.left = 0; + pDC->FillSolidRect(rcLabel,::GetSysColor(COLOR_HIGHLIGHT)); + pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT)); + rcLabel.left = 2; + } + + if(m_PrefixChar) + m_DisplayStr = m_PrefixChar + m_DisplayList.GetAt(m_lItem); + else + m_DisplayStr = m_DisplayList.GetAt(m_lItem); + + pDC->DrawText(m_DisplayStr, -1, rcLabel, DT_LEFT | DT_SINGLELINE | + DT_NOPREFIX | DT_VCENTER | DT_END_ELLIPSIS); +} + +/*********************************************************************/ + +void CACListWnd::OnPaint() +{ + CPaintDC dc(this); + CRect rcWnd,m_rect, rc; + CDC MemDC,*pDC=NULL; + CBitmap m_bitmap, *m_pOldBitmap; + int i; + + GetClientRect(rc); + rcWnd = m_rect = rc; + + rc.left = rc.right-GetSystemMetrics(SM_CXHSCROLL); + rc.top = rc.bottom-GetSystemMetrics(SM_CYVSCROLL); + + m_rect.right -= ScrollBarWidth(); + + MemDC.CreateCompatibleDC(&dc); + + m_bitmap.CreateCompatibleBitmap(&dc, m_rect.Width(), m_rect.Height()); + m_pOldBitmap = MemDC.SelectObject(&m_bitmap); + + MemDC.SetWindowOrg(m_rect.left, m_rect.top); + + long width = rcWnd.Width() - ScrollBarWidth(); + + MemDC.FillSolidRect(rcWnd,::GetSysColor(COLOR_WINDOW)); + MemDC.SelectObject(GetStockObject(DEFAULT_GUI_FONT)); + MemDC.SetBkMode(TRANSPARENT); + + for(i = m_lTopIndex; i < m_lCount;i++) + { + DrawItem(&MemDC,i,width); + } + + + CPen m_Pen1(PS_SOLID, 1, ::GetSysColor(COLOR_WINDOW)); + CPen m_Pen2(PS_SOLID, 1, ::GetSysColor(COLOR_BTNFACE)); + CPen m_Pen3(PS_SOLID, 1, ::GetSysColor(COLOR_3DSHADOW)); + + pDC = &dc; + + if(m_VertBar.IsWindowVisible()) + dc.FillSolidRect(rc, ::GetSysColor(COLOR_BTNFACE) ); + else + pDC = &MemDC; + + CPen *pOldPen = (CPen*)pDC->SelectObject(&m_Pen1); + int a = 1,bottom; + + width = GetSystemMetrics(SM_CXHSCROLL); + bottom = (rcWnd.bottom-GetSystemMetrics(SM_CXHSCROLL))-1; + + //gripper + for( i = 0; i < 20 ;i++,a++) + { + if(a==1) + pDC->SelectObject(&m_Pen1); + if(a==2) + pDC->SelectObject(&m_Pen2); + if(a==3) + pDC->SelectObject(&m_Pen3); + if(a > 3) + a = 0; + + pDC->MoveTo(rc.left + i - 1, rcWnd.bottom); + pDC->LineTo(rc.left + i + width, bottom); + } + + dc.BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(), + &MemDC, m_rect.left, m_rect.top, SRCCOPY); + + pDC->SelectObject( pOldPen ); + MemDC.SelectObject(m_pOldBitmap); +} + +/*********************************************************************/ + +void CACListWnd::Init(CWnd *pWnd) +{ + VERIFY(m_VertBar.Create(WS_VISIBLE|SBS_VERT|SBS_LEFTALIGN, + CRect(0,0,GetSystemMetrics(SM_CYVSCROLL),100),this,0)); + + SetScroller(); + m_pEditParent = (CEdit*)pWnd; + + m_lCount = m_DisplayList.GetSize(); + m_VertBar.SetScrollPos(0,false); + SetProp(); + + CDC *m_pDC; + m_pDC = GetDC(); + if(m_pDC) + { + m_pDC->SelectObject(GetStockObject(DEFAULT_GUI_FONT)); + CSize m_Size = m_pDC->GetOutputTextExtent(_T("Hg")); + m_ItemHeight = m_Size.cy; + ReleaseDC(m_pDC); + } +} + +/*********************************************************************/ + +void CACListWnd::SetScroller() +{ + CRect rcWnd,rcBar; + GetClientRect(rcWnd); + + if(m_VertBar.GetSafeHwnd()) + { + rcBar = rcWnd; + rcBar.top=-1; + rcBar.left = (rcWnd.Width()-GetSystemMetrics(SM_CYVSCROLL)); + rcBar.bottom-= GetSystemMetrics(SM_CYHSCROLL); + m_VertBar.MoveWindow(rcBar); + rcBar.top = rcWnd.bottom-20; + rcBar.bottom = rcWnd.bottom; + + m_VertBar.SetScrollPos(m_lTopIndex,true); + } + +} + +/*********************************************************************/ + +void CACListWnd::OnSize(UINT nType, int cx, int cy) +{ + CWnd::OnSize(nType, cx, cy); + SetScroller(); + SetProp(); + + if(!m_LastSize.IsRectEmpty()) + GetWindowRect(m_LastSize); +} + +/*********************************************************************/ + +long CACListWnd::ScrollBarWidth() +{ + if(m_VertBar.IsWindowVisible()) + return GetSystemMetrics(SM_CYVSCROLL); + else + return 0; +} + +/*********************************************************************/ + +void CACListWnd::SetProp() +{ + CRect rcWnd,rcBar; + + if(!m_lCount) + return; + + CWnd::GetWindowRect(rcWnd); + ScreenToClient(rcWnd); + + SCROLLINFO si; + si.cbSize = sizeof(SCROLLINFO); + si.fMask = SIF_PAGE|SIF_RANGE; + si.nMin = 0; + si.nMax = m_lCount-1; + m_VisibleItems = si.nPage = rcWnd.Height()/m_ItemHeight; + si.nTrackPos = 2; + m_VertBar.SetScrollRange(0,m_lCount-1); + m_VertBar.SetScrollInfo(&si); + + if(m_VisibleItems > m_lCount-1) + m_VertBar.ShowWindow(false); + else + m_VertBar.ShowWindow(true); + + if(m_lTopIndex+m_VisibleItems > m_lCount) + { + m_lTopIndex = m_lCount-m_VisibleItems; + if(m_lTopIndex < 0) + m_lTopIndex = 0; + m_VertBar.SetScrollPos(m_lTopIndex,true); + } +} + +/*********************************************************************/ + +BOOL CACListWnd::OnEraseBkgnd(CDC* /*pDC*/) +{ + return false; +} + +/*********************************************************************/ + +void CACListWnd::OnNcPaint() +{ + CWindowDC dc(this); + CRect rectClient, rectWindow,rcWnd; + + GetClientRect(rectClient); + GetWindowRect(rectWindow); + ScreenToClient(rectWindow); + + rectClient.OffsetRect(-(rectWindow.left), -(rectWindow.top)); + dc.ExcludeClipRect(rectClient); + + rectWindow.OffsetRect(-rectWindow.left, -rectWindow.top); + + dc.FillSolidRect(rectWindow,::GetSysColor(COLOR_WINDOWTEXT)); +} + +/*********************************************************************/ + +void CACListWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ + CWnd::OnKeyDown(nChar, nRepCnt, nFlags); + + if (nChar == VK_ESCAPE) + ShowWindow(false); +} + +/*********************************************************************/ + +void CACListWnd::OnNcCalcSize(BOOL /*bCalcValidRects*/, NCCALCSIZE_PARAMS FAR* lpncsp) +{ + ::InflateRect(lpncsp->rgrc, + -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER)); +} + +/*********************************************************************/ + +int CACListWnd::HitTest(CPoint point) +{ + CRect rcItem; + CRect rcWnd; + + GetClientRect(rcWnd); + long width = rcWnd.Width() - ScrollBarWidth(); + + for(int i = m_lTopIndex; i < m_lCount; i++) + { + long y = i - m_lTopIndex; + rcItem.SetRect(2,y*m_ItemHeight,width,(y+1)*m_ItemHeight); + + if(PtInRect(&rcItem, point)) + return (m_lSelItem = (y+m_lTopIndex)); + } + + return -1; +} + +/*********************************************************************/ + +LRESULT CACListWnd::OnNcHitTest(CPoint point) +{ + CRect rectClient; + GetWindowRect(rectClient); + + rectClient.left = rectClient.right - GetSystemMetrics(SM_CYVSCROLL); + rectClient.top = rectClient.bottom - GetSystemMetrics(SM_CXVSCROLL); + + if(rectClient.PtInRect(point)) + return HTBOTTOMRIGHT; + else + return HTCLIENT; +} + +/*********************************************************************/ + +void CACListWnd::OnLButtonDown(UINT nFlags, CPoint point) +{ + CWnd::OnLButtonDown(nFlags, point); + int sel = HitTest(point); + + if(sel >= 0) + { + if(!EnsureVisible(sel,true)) + Invalidate(); + m_lSelItem = sel; + m_pEditParent->SendMessage(ENAC_UPDATE, WM_KEYDOWN, GetDlgCtrlID()); + DoPaintMessageLoop(); + Sleep(500); + ShowWindow(false); + } + else + { + CRect rc; + GetClientRect(rc); + if(!rc.PtInRect(point)) + ShowWindow(false); + } +} + +/*********************************************************************/ + +void CACListWnd::OnRButtonDown(UINT nFlags, CPoint point) +{ + CWnd::OnRButtonDown(nFlags, point); + ShowWindow(false); +} + +/*********************************************************************/ + +BOOL CACListWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) +{ + CRect rectClient; + CPoint ptCursor; + + GetWindowRect(rectClient); + ScreenToClient(&rectClient); + + rectClient.left = rectClient.right - GetSystemMetrics(SM_CYVSCROLL); + rectClient.top = rectClient.bottom - GetSystemMetrics(SM_CXVSCROLL); + + + GetCursorPos(&ptCursor); + ScreenToClient(&ptCursor); + + if(rectClient.PtInRect(ptCursor)) // Vergrößerungs-Cursor + { + return CWnd::OnSetCursor(pWnd, nHitTest, message); + } + + ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); + return TRUE; +} + +/*********************************************************************/ + +void CACListWnd::InvalidateAndScroll() +{ + m_VertBar.SetScrollPos(m_lTopIndex,true); + Invalidate(); + DoPaintMessageLoop(); +} + +/*********************************************************************/ + +bool CACListWnd::EnsureVisible(int item, bool m_bWait) +{ + if(item > m_lTopIndex && item < m_lTopIndex + m_VisibleItems) + return false; // ist visible + + if(item > m_lTopIndex) // scroll down + { + long m_len = item; + for(int i = m_lTopIndex; i < m_len; i++) + { + if(i >= m_lCount-m_VisibleItems) + break; + if(i >= m_lCount-m_VisibleItems || i + m_VisibleItems > item) + { + break; + } + + m_lTopIndex++; + + if(m_bWait) + { + InvalidateAndScroll(); + Sleep(10); + DoPaintMessageLoop(); + } + } + InvalidateAndScroll(); + return true; + } + + if(item < m_lTopIndex) // scroll up + { + while(item < m_lTopIndex) + { + if(m_lTopIndex > 0) + m_lTopIndex--; + else + { + break; + } + + if(m_bWait) + { + InvalidateAndScroll(); + Sleep(10); + DoPaintMessageLoop(); + } + } + + InvalidateAndScroll(); + return true; + } + + return false; +} + +/*********************************************************************/ + +bool CACListWnd::SelectItem(int item) +{ + if(item > m_lCount) + return false; + + if(item == -1) + { + EnsureVisible(m_lSelItem,false); + Invalidate(); + return false; + } + + m_lSelItem = item; + + if(!EnsureVisible(item,true)) + Invalidate(); + + return true; +} + +/*********************************************************************/ + +int CACListWnd::FindStringExact( int nStartAfter, LPCTSTR lpszString ) +{ + if(nStartAfter > m_SearchList.GetSize()) + return -1; + + for(int i = nStartAfter+1; i < m_SearchList.GetSize(); i++) + if(m_SearchList.GetAt(i).Compare(lpszString) == 0) + return i; + return -1; +} + +/*********************************************************************/ +/* +** Vers. 1.1 +* NEW: m_bDisplayOnly +*/ +int CACListWnd::FindString(int nStartAfter, LPCTSTR lpszString, bool m_bDisplayOnly) +{ + long m_AktCount = m_DisplayList.GetSize(); + + if(!m_bDisplayOnly) + { + CString m_Str1,m_Str2 = lpszString; + if(!m_pEditParent) + { + ShowWindow(false); + return -1; + } + + if(nStartAfter > m_SearchList.GetSize()) + { + ShowWindow(false); + return -1; + } + + if(m_Str2.IsEmpty()) + { + ShowWindow(false); + return -1; + } + + m_DisplayList.RemoveAll(); + + m_Str2.MakeUpper(); + + for(int i = nStartAfter+1; i < m_SearchList.GetSize(); i++) + { + if(m_PrefixChar) + m_Str1 = m_PrefixChar; + else + m_Str1 = _T(""); + + m_Str1 += m_SearchList.GetAt(i); + + m_Str1.MakeUpper(); + + if(m_lMode & _MODE_FIND_ALL_) + { + if(m_Str1.Find(m_Str2) >= 0) + { + m_DisplayList.Add(m_SearchList.GetAt(i)); + } + } + else // _MODE_FIND_EXACT_ + { + if(m_Str1.Find(m_Str2) == 0) + { + m_DisplayList.Add(m_SearchList.GetAt(i)); + } + } + } + } + m_lCount = m_DisplayList.GetSize(); + + if(m_lCount) + { + CRect rcWnd; + int iHeight,iWight; + + m_pEditParent->GetWindowRect(rcWnd); + + SetScroller(); + SetProp(); + + ShowWindow(true); + Invalidate(); + + iHeight = m_lCount*m_ItemHeight+(GetSystemMetrics(SM_CYBORDER)*2); + + if(m_lCount > _MAX_ENTRYS_) + iHeight = _MAX_ENTRYS_*m_ItemHeight+(GetSystemMetrics(SM_CYBORDER)*2); + + if(!m_LastSize.IsRectEmpty()) + { + iWight = m_LastSize.Width(); + iHeight = m_LastSize.Height(); + rcWnd.top += rcWnd.Height(); + rcWnd.right = rcWnd.left+iWight; + rcWnd.bottom = rcWnd.top+iHeight; + + SetWindowPos(&CWnd::wndTopMost, rcWnd.left, + rcWnd.top, + rcWnd.Width(), + rcWnd.Height(), 0); + } + else + { + SetWindowPos(&CWnd::wndTopMost, rcWnd.left, + rcWnd.top + rcWnd.Height(), + rcWnd.Width(), + iHeight, 0); + } + + if(m_AktCount != m_DisplayList.GetSize()) + m_lSelItem = -1; + + SortList(m_DisplayList); + } + else + { + ShowWindow(false); + } + + return 1; +} + +/*********************************************************************/ + +int CACListWnd::SelectString(LPCTSTR lpszString ) +{ + int item = FindString(-1, lpszString); + SelectItem(item); + return item; +} + +/*********************************************************************/ + +bool CACListWnd::GetText(int item, CString& m_Text) +{ + if(item < 0 || item > m_SearchList.GetSize()) + return false; + m_Text = m_SearchList.GetAt(item); + return true; +} + +/*********************************************************************/ + +void CACListWnd::OnShowWindow(BOOL bShow, UINT nStatus) +{ + if(bShow) + { + m_nIDTimer = SetTimer( IDTimerInstall, 200, NULL); + m_pEditParent->GetParent()->GetWindowRect(m_ParentRect); + } + else + { + if(m_nIDTimer) + KillTimer(IDTimerInstall); + m_nIDTimer = 0; + m_lSelItem = -1; + m_lTopIndex = 0; + } + + CWnd::OnShowWindow(bShow, nStatus); + ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); +} + +/*********************************************************************/ + +void CACListWnd::OnNcLButtonDown(UINT nHitTest, CPoint point) +{ + + if(OnNcHitTest(point) == HTBOTTOMRIGHT) + GetWindowRect(m_LastSize); + CWnd::OnNcLButtonDown(nHitTest, point); +} + +/*********************************************************************/ + +CString CACListWnd::GetString() +{ + int i = m_DisplayList.GetSize(); + + if(!i) + return _T(""); + if(i <= m_lSelItem || m_lSelItem == -1) + i = 0; + else + i = m_lSelItem; + + return m_DisplayList.GetAt(i); +} + +/*********************************************************************/ + +void CACListWnd::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + CWnd::OnVScroll(nSBCode, nPos, pScrollBar); + long m_oldlTopIndex = m_lTopIndex; + + switch(nSBCode) + { + case SB_ENDSCROLL: + break; + + case SB_PAGEUP: + m_lTopIndex -= m_VisibleItems; + if(m_lTopIndex < 0) + m_lTopIndex = 0; + break; + + case SB_PAGEDOWN: + m_lTopIndex += m_VisibleItems; + if(m_lTopIndex >= m_lCount-m_VisibleItems) + m_lTopIndex = m_lCount-m_VisibleItems; + break; + + case SB_LINEUP: + m_lTopIndex--; + if(m_lTopIndex < 0) + m_lTopIndex = 0; + break; + + case SB_LINEDOWN: + m_lTopIndex++; + if(m_lTopIndex >= m_lCount-m_VisibleItems) + m_lTopIndex = m_lCount-m_VisibleItems; + break; + + case SB_THUMBTRACK: + m_lTopIndex = nPos; + break; + } + + m_VertBar.SetScrollPos(m_lTopIndex,true); + + if(m_oldlTopIndex != m_lTopIndex) + Invalidate(); +} + +/*********************************************************************/ + +CString CACListWnd::GetNextString(int nChar) +{ + switch(nChar) + { + case VK_DOWN: + m_lSelItem++; + break; + + case VK_UP: + m_lSelItem--; + break; + + case VK_PRIOR: + m_lSelItem -= m_VisibleItems; + if(m_lSelItem < 0) + m_lSelItem = 0; + break; + + case VK_NEXT: + m_lSelItem += m_VisibleItems; + if(m_lSelItem >= m_lCount-1) + m_lSelItem = m_lCount-1; + break; + + case VK_HOME: + m_lSelItem = 0; + break; + + case VK_END: + m_lSelItem = m_lCount-1; + break; + } + + if(m_lSelItem < 0) + m_lSelItem = m_lCount-1; + + if(m_lSelItem >= m_lCount) + m_lSelItem = 0; + + if(EnsureVisible(m_lSelItem,(m_lCount > 50) ? false : true)) + InvalidateAndScroll(); + + return GetString(); +} + +/*********************************************************************/ + +void CACListWnd::OnMouseMove(UINT nFlags, CPoint point) +{ + CWnd::OnMouseMove(nFlags, point); + int sel = HitTest(point); + if(sel >= 0) + { + Invalidate(); + } +} + +/*********************************************************************/ + +void CACListWnd::OnTimer(UINT nIDEvent) +{ + CWnd::OnTimer(nIDEvent); + + CRect m_ParentRect1; + m_pEditParent->GetParent()->GetWindowRect(m_ParentRect1); + if(!m_ParentRect1.EqualRect(m_ParentRect)) + ShowWindow(false); +} + +/*********************************************************************/ + +void CACListWnd::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) +{ + if(GetSafeHwnd()) + { + // Vers. 1.2 + long m_lMinY1 = GetSystemMetrics(SM_CYHSCROLL)*2 + GetSystemMetrics(SM_CYSIZEFRAME) + GetSystemMetrics(SM_CXHTHUMB), + m_lMinY2 = m_lCount * m_ItemHeight + (GetSystemMetrics(SM_CYBORDER)*2); + + if(m_VisibleItems > m_lCount-1 && m_lMinY2 < m_lMinY1) + lpMMI->ptMinTrackSize.y = m_lMinY2; + else + lpMMI->ptMinTrackSize.y = m_lMinY1; + //--------- + + lpMMI->ptMinTrackSize.x = GetSystemMetrics(SM_CXHSCROLL)*4; + + + // Vers. 1.2 + if(m_pEditParent != NULL) + { + RECT rc; + m_pEditParent->GetWindowRect (&rc); + lpMMI->ptMinTrackSize.x = rc.right - rc.left; + } + } + else + CWnd::OnGetMinMaxInfo(lpMMI); +} + +/*********************************************************************/ + +int CACListWnd::CompareString(const void* p1, const void* p2) +{ + return _stricmp( * ( char** ) p1, * ( char** ) p2 ); +} + +/*********************************************************************/ + +void CACListWnd::SortList(CStringArray& m_List) +{ + int m_Count = m_List.GetSize(); + int i; + + if (m_Count > 1) + { + CStringArray m_Liste1; + m_Liste1.Copy(m_List); + + LPCTSTR* ppSortArray = new LPCTSTR[m_Count+1]; + + + for(i=0; i < m_Count; i++) + { + ppSortArray[i] = (LPCTSTR)m_Liste1.GetAt(i); + } + + m_List.RemoveAll(); + + qsort(ppSortArray, m_Count, sizeof(LPCTSTR), CompareString); + + for(i=0; i < m_Count; i++) + { + m_List.Add((LPCTSTR) ppSortArray[i]); + } + m_Liste1.RemoveAll(); + delete [] ppSortArray; + } +} + +/*********************************************************************/ +/* +** Vers. 1.1 +** NEW: CopyList() +*/ +void CACListWnd::CopyList() +{ + m_DisplayList.Copy(m_SearchList); + m_lCount = m_DisplayList.GetSize(); + if(m_lCount) + FindString(0,_T(""),true); +} + +/*********************************************************************/ + diff --git a/src/Utils/ACListWnd.h b/src/Utils/ACListWnd.h new file mode 100644 index 0000000..6f77924 --- /dev/null +++ b/src/Utils/ACListWnd.h @@ -0,0 +1,110 @@ +#if !defined(AFX_ACWND_H__5CED9BF8_C1CB_4A74_B022_ABA25680CC42__INCLUDED_) +#define AFX_ACWND_H__5CED9BF8_C1CB_4A74_B022_ABA25680CC42__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// ACWnd.h : Header-Datei +// + +/********************************************************************* +* +* CACListWnd +* Copyright (c) 200 by Andreas Kapust +* All rights reserved. +* info@akinstaller.de +* +*********************************************************************/ + +#include // CArray +#define ENAC_UPDATE WM_USER + 1200 +///////////////////////////////////////////////////////////////////////////// +// Fenster CACListWnd +#define IDTimerInstall 10 +class CACListWnd : public CWnd +{ + // Konstruktion +public: + CACListWnd(); + void Init(CWnd *pWnd); + bool EnsureVisible(int item,bool m_bWait); + bool SelectItem(int item); + int FindString(int nStartAfter, LPCTSTR lpszString, bool m_bDisplayOnly = false); + int FindStringExact( int nIndexStart, LPCTSTR lpszFind ); + int SelectString(LPCTSTR lpszString ); + bool GetText(int item, CString& m_Text); + void AddSearchString(LPCTSTR lpszString){m_SearchList.Add(lpszString);} + void RemoveAll(){m_SearchList.RemoveAll(); m_DisplayList.RemoveAll();} + CString GetString(); + CString GetNextString(int m_iChar); + + void CopyList(); + void SortSearchList(){SortList(m_SearchList);} + // Attribute +public: + CListCtrl m_List; + CString m_DisplayStr; + TCHAR m_PrefixChar; + long m_lMode; + // Operationen +public: + CStringArray m_SearchList; + // Überschreibungen + // Vom Klassen-Assistenten generierte virtuelle Funktionsüberschreibungen + //{{AFX_VIRTUAL(CACListWnd) + //}}AFX_VIRTUAL + + // Implementierung +public: + virtual ~CACListWnd(); + void DrawItem(CDC* pDC,long m_lItem,long width); + + // Generierte Nachrichtenzuordnungsfunktionen +protected: + //{{AFX_MSG(CACListWnd) + afx_msg void OnPaint(); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnNcPaint(); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp); + afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + afx_msg void OnActivateApp(BOOL bActive, DWORD dwThreadID); + afx_msg LRESULT OnNcHitTest(CPoint point); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnRButtonDown(UINT nFlags, CPoint point); + afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); + afx_msg void OnShowWindow(BOOL bShow, UINT nStatus); + afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnTimer(UINT nIDEvent); + afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + + CStringArray m_DisplayList; + CScrollBar m_VertBar, m_HoriBar; + CRect m_LastSize, m_ParentRect; + CFont *pFontDC; + CFont fontDC, boldFontDC; + CEdit *m_pEditParent; + LOGFONT logfont; + + int m_nIDTimer; + long m_lTopIndex,m_lCount,m_ItemHeight,m_VisibleItems,m_lSelItem; + + int HitTest(CPoint point); + void SetScroller(); + void SetProp(); + long ScrollBarWidth(); + void InvalidateAndScroll(); + void SortList(CStringArray& m_List); + static int CompareString(const void* p1, const void* p2); +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ fügt unmittelbar vor der vorhergehenden Zeile zusätzliche Deklarationen ein. + +#endif // AFX_ACWND_H__5CED9BF8_C1CB_4A74_B022_ABA25680CC42__INCLUDED_ diff --git a/src/Utils/Utils.vcproj b/src/Utils/Utils.vcproj index 6262ffc..789e48b 100644 --- a/src/Utils/Utils.vcproj +++ b/src/Utils/Utils.vcproj @@ -285,6 +285,22 @@ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > + + + + + + + +