From: Colin Law Date: Thu, 29 Jan 2009 16:09:43 +0000 (+0000) Subject: Save and restore column widths for log and blame in registry. X-Git-Url: http://git.sourceforge.jp/view?a=commitdiff_plain;h=248b79fe4b70128d99cc271417a7077b4cbd85b8;p=tortoisegit%2FTortoiseGitJp.git Save and restore column widths for log and blame in registry. --- diff --git a/src/TortoiseProc/AppUtils.cpp b/src/TortoiseProc/AppUtils.cpp index 8d680b4..deeeeef 100644 --- a/src/TortoiseProc/AppUtils.cpp +++ b/src/TortoiseProc/AppUtils.cpp @@ -607,47 +607,6 @@ bool CAppUtils::LaunchTortoiseBlame(const CString& sBlameFile,CString Rev,const return LaunchApplication(viewer, IDS_ERR_EXTDIFFSTART, false); } -void CAppUtils::ResizeAllListCtrlCols(CListCtrl * pListCtrl) -{ - int maxcol = ((CHeaderCtrl*)(pListCtrl->GetDlgItem(0)))->GetItemCount()-1; - int nItemCount = pListCtrl->GetItemCount(); - TCHAR textbuf[MAX_PATH]; - CHeaderCtrl * pHdrCtrl = (CHeaderCtrl*)(pListCtrl->GetDlgItem(0)); - if (pHdrCtrl) - { - for (int col = 0; col <= maxcol; col++) - { - HDITEM hdi = {0}; - hdi.mask = HDI_TEXT; - hdi.pszText = textbuf; - hdi.cchTextMax = sizeof(textbuf); - pHdrCtrl->GetItem(col, &hdi); - int cx = pListCtrl->GetStringWidth(hdi.pszText)+20; // 20 pixels for col separator and margin - for (int index = 0; indexGetStringWidth(pListCtrl->GetItemText(index, col)) + 14; - if (index == 0) - { - // add the image size - CImageList * pImgList = pListCtrl->GetImageList(LVSIL_SMALL); - if ((pImgList)&&(pImgList->GetImageCount())) - { - IMAGEINFO imginfo; - pImgList->GetImageInfo(0, &imginfo); - linewidth += (imginfo.rcImage.right - imginfo.rcImage.left); - linewidth += 3; // 3 pixels between icon and text - } - } - if (cx < linewidth) - cx = linewidth; - } - pListCtrl->SetColumnWidth(col, cx); - - } - } -} - bool CAppUtils::FormatTextInRichEditControl(CWnd * pWnd) { CString sText; diff --git a/src/TortoiseProc/AppUtils.h b/src/TortoiseProc/AppUtils.h index 626aaa8..799fd5c 100644 --- a/src/TortoiseProc/AppUtils.h +++ b/src/TortoiseProc/AppUtils.h @@ -115,12 +115,6 @@ public: const CString& sBlameFile, CString Rev, const CString& sParams = CString()); /** - * Resizes all columns in a list control. Considers also icons in columns - * with no text. - */ - static void ResizeAllListCtrlCols(CListCtrl * pListCtrl); - - /** * Formats text in a rich edit control (version 2). * text in between * chars is formatted bold * text in between ^ chars is formatted italic diff --git a/src/TortoiseProc/GitLogListBase.cpp b/src/TortoiseProc/GitLogListBase.cpp index cc87122..d9c7ed6 100644 --- a/src/TortoiseProc/GitLogListBase.cpp +++ b/src/TortoiseProc/GitLogListBase.cpp @@ -216,83 +216,31 @@ void CGitLogListBase::InsertGitColumn() } +/** + * Resizes all columns in a list control to values in registry. + */ void CGitLogListBase::ResizeAllListCtrlCols() { - - const int nMinimumWidth = ICONITEMBORDER+16*4; - int maxcol = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1; - int nItemCount = GetItemCount(); - TCHAR textbuf[MAX_PATH]; - CHeaderCtrl * pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0)); + // column max and min widths to allow + static const int nMinimumWidth = 10; + static const int nMaximumWidth = 1000; + CHeaderCtrl* pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0)); if (pHdrCtrl) { - for (int col = 0; col <= maxcol; col++) + int numcols = pHdrCtrl->GetItemCount(); + for (int col = 0; col < numcols; col++) { - HDITEM hdi = {0}; - hdi.mask = HDI_TEXT; - hdi.pszText = textbuf; - hdi.cchTextMax = sizeof(textbuf); - pHdrCtrl->GetItem(col, &hdi); - int cx = GetStringWidth(hdi.pszText)+20; // 20 pixels for col separator and margin - for (int index = 0; index(m_arShownList.GetAt(index)); - if ((pCurLogEntry)&&(pCurLogEntry->m_CommitHash == m_wcRev.m_CommitHash)) - { - // set the bold font and ask for the string width again - SendMessage(WM_SETFONT, (WPARAM)m_boldFont, NULL); - linewidth = GetStringWidth(GetItemText(index, col)) + 14; - // restore the system font - SendMessage(WM_SETFONT, NULL, NULL); - } - } - if (index == 0) - { - // add the image size - CImageList * pImgList = GetImageList(LVSIL_SMALL); - if ((pImgList)&&(pImgList->GetImageCount())) - { - IMAGEINFO imginfo; - pImgList->GetImageInfo(0, &imginfo); - linewidth += (imginfo.rcImage.right - imginfo.rcImage.left); - linewidth += 3; // 3 pixels between icon and text - } - } - if (cx < linewidth) - cx = linewidth; - } - // Adjust columns "Actions" containing icons - if (col == this->LOGLIST_ACTION) - { - if (cx < nMinimumWidth) - { - cx = nMinimumWidth; - } - } - - if (col == this->LOGLIST_MESSAGE) - { - if (cx > LOGLIST_MESSAGE_MAX) - { - cx = LOGLIST_MESSAGE_MAX; - } - if (cx < LOGLIST_MESSAGE_MIN) - { - cx = LOGLIST_MESSAGE_MIN; - } - - } - // keep the bug id column small - if ((col == 4)&&(m_bShowBugtraqColumn)) + cx = nMinimumWidth; + } else if (cx > nMaximumWidth) { - if (cx > (int)(DWORD)m_regMaxBugIDColWidth) - { - cx = (int)(DWORD)m_regMaxBugIDColWidth; - } + cx = nMaximumWidth; } SetColumnWidth(col, cx); @@ -1505,9 +1453,9 @@ UINT CGitLogListBase::LogThread() return 0; RedrawItems(0, m_arShownList.GetCount()); - SetRedraw(false); - ResizeAllListCtrlCols(); - SetRedraw(true); +// SetRedraw(false); +// ResizeAllListCtrlCols(); +// SetRedraw(true); if ( m_pStoreSelection ) { @@ -1858,9 +1806,9 @@ void CGitLogListBase::RemoveFilter() DeleteAllItems(); SetItemCountEx(ShownCountWithStopped()); RedrawItems(0, ShownCountWithStopped()); - SetRedraw(false); - ResizeAllListCtrlCols(); - SetRedraw(true); +// SetRedraw(false); +// ResizeAllListCtrlCols(); +// SetRedraw(true); InterlockedExchange(&m_bNoDispUpdates, FALSE); } @@ -1880,11 +1828,33 @@ void CGitLogListBase::Clear() void CGitLogListBase::OnDestroy() { + // save the column widths to the registry + SaveColumnWidths(); while(m_LogCache.SaveCache()) { - if(CMessageBox::Show(NULL,_T("Can Save Log Cache to Disk,click yes for retry, click no for give up"),_T("TortoiseGit"), + if(CMessageBox::Show(NULL,_T("Cannot Save Log Cache to Disk,click yes for retry, click no for give up"),_T("TortoiseGit"), MB_YESNO) == IDNO) break; } CHintListCtrl::OnDestroy(); +} + +/** + * Save column widths to the registry + */ +void CGitLogListBase::SaveColumnWidths() +{ + CHeaderCtrl* pHdrCtrl = (CHeaderCtrl*)(GetDlgItem(0)); + if (pHdrCtrl) + { + int numcols = pHdrCtrl->GetItemCount(); + for (int col = 0; col < numcols; col++) + { + int width = GetColumnWidth( col ); + CString regentry; + regentry.Format( _T("Software\\TortoiseGit\\log\\ColWidth%d"), col); + CRegDWORD regwidth(regentry, 0); + regwidth = width; // this writes it to reg + } + } } \ No newline at end of file diff --git a/src/TortoiseProc/GitLogListBase.h b/src/TortoiseProc/GitLogListBase.h index 9b27658..47d78a2 100644 --- a/src/TortoiseProc/GitLogListBase.h +++ b/src/TortoiseProc/GitLogListBase.h @@ -191,7 +191,10 @@ protected: void paintGraphLane(HDC hdc,int laneHeight, int type, int x1, int x2, const COLORREF& col,int top) ; void DrawLine(HDC hdc, int x1, int y1, int x2, int y2){::MoveToEx(hdc,x1,y1,NULL);::LineTo(hdc,x2,y2);} - + /** + * Save column widths to the registry + */ + void SaveColumnWidths(); // save col widths to the registry BOOL IsEntryInDateRange(int i); diff --git a/src/TortoiseProc/LogDlg.cpp b/src/TortoiseProc/LogDlg.cpp index e2bb8a1..226983a 100644 --- a/src/TortoiseProc/LogDlg.cpp +++ b/src/TortoiseProc/LogDlg.cpp @@ -581,7 +581,6 @@ void CLogDlg::FillLogMessageCtrl(bool bShow /* = true*/) m_ChangedFileListCtrl.Invalidate(); } #endif - CAppUtils::ResizeAllListCtrlCols(&m_ChangedFileListCtrl); // sort according to the settings if (m_nSortColumnPathList > 0) SetSortArrow(&m_ChangedFileListCtrl, m_nSortColumnPathList, m_bAscendingPathList); @@ -2683,89 +2682,6 @@ int CLogDlg::SortCompare(const void * pElem1, const void * pElem2) return 0; } -#if 0 -void CLogDlg::ResizeAllListCtrlCols() -{ - - const int nMinimumWidth = ICONITEMBORDER+16*4; - int maxcol = ((CHeaderCtrl*)(m_LogList.GetDlgItem(0)))->GetItemCount()-1; - int nItemCount = m_LogList.GetItemCount(); - TCHAR textbuf[MAX_PATH]; - CHeaderCtrl * pHdrCtrl = (CHeaderCtrl*)(m_LogList.GetDlgItem(0)); - if (pHdrCtrl) - { - for (int col = 0; col <= maxcol; col++) - { - HDITEM hdi = {0}; - hdi.mask = HDI_TEXT; - hdi.pszText = textbuf; - hdi.cchTextMax = sizeof(textbuf); - pHdrCtrl->GetItem(col, &hdi); - int cx = m_LogList.GetStringWidth(hdi.pszText)+20; // 20 pixels for col separator and margin - for (int index = 0; index(m_arShownList.GetAt(index)); - if ((pCurLogEntry)&&(pCurLogEntry->m_CommitHash == m_wcRev.m_CommitHash)) - { - // set the bold font and ask for the string width again - m_LogList.SendMessage(WM_SETFONT, (WPARAM)m_boldFont, NULL); - linewidth = m_LogList.GetStringWidth(m_LogList.GetItemText(index, col)) + 14; - // restore the system font - m_LogList.SendMessage(WM_SETFONT, NULL, NULL); - } - } - if (index == 0) - { - // add the image size - CImageList * pImgList = m_LogList.GetImageList(LVSIL_SMALL); - if ((pImgList)&&(pImgList->GetImageCount())) - { - IMAGEINFO imginfo; - pImgList->GetImageInfo(0, &imginfo); - linewidth += (imginfo.rcImage.right - imginfo.rcImage.left); - linewidth += 3; // 3 pixels between icon and text - } - } - if (cx < linewidth) - cx = linewidth; - } - // Adjust columns "Actions" containing icons - if (col == this->LOGLIST_ACTION) - { - if (cx < nMinimumWidth) - { - cx = nMinimumWidth; - } - } - - if (col == this->LOGLIST_MESSAGE) - { - if (cx > LOGLIST_MESSAGE_MAX) - { - cx = LOGLIST_MESSAGE_MAX; - } - - } - // keep the bug id column small - if ((col == 4)&&(m_bShowBugtraqColumn)) - { - if (cx > (int)(DWORD)m_regMaxBugIDColWidth) - { - cx = (int)(DWORD)m_regMaxBugIDColWidth; - } - } - - m_LogList.SetColumnWidth(col, cx); - } - } - -} -#endif - void CLogDlg::OnBnClickedHidepaths() { FillLogMessageCtrl(); diff --git a/src/TortoiseProc/LogDlg.h b/src/TortoiseProc/LogDlg.h index fa42a04..0ec6952 100644 --- a/src/TortoiseProc/LogDlg.h +++ b/src/TortoiseProc/LogDlg.h @@ -197,8 +197,6 @@ private: virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam); static int __cdecl SortCompare(const void * pElem1, const void * pElem2); ///< sort callback function - void ResizeAllListCtrlCols(); - void ShowContextMenuForRevisions(CWnd* pWnd, CPoint point); void ShowContextMenuForChangedpaths(CWnd* pWnd, CPoint point); public: