// GrepView.h // // (c)1998-2025 Codejock Software, All Rights Reserved. // // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN // CONSENT OF CODEJOCK SOFTWARE. // // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A // SINGLE COMPUTER. // // CONTACT INFORMATION: // support@codejock.com // http://www.codejock.com // ///////////////////////////////////////////////////////////////////////////// #if !defined(AFX_GREPVIEW_H__841CCA0D_0740_40E5_810B_7A57EBDD46B7__INCLUDED_) # define AFX_GREPVIEW_H__841CCA0D_0740_40E5_810B_7A57EBDD46B7__INCLUDED_ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 class CGrepRecordPreview : public CXTPGridRecordItemPreview { public: CGrepRecordPreview(CString strFindLine, CString strReplaceLine) : CXTPGridRecordItemPreview(0) { m_strFindLine = strFindLine; m_strReplaceLine = strReplaceLine; m_bChanged = strFindLine != strReplaceLine; m_strFindLine.Replace(_T("\t"), _T(" ")); m_strReplaceLine.Replace(_T("\t"), _T(" ")); } CString m_strFindLine; CString m_strReplaceLine; BOOL m_bChanged; protected: int GetPreviewHeight(CDC* pDC, CXTPGridRow* pRow, int nWidth) { CXTPGridControl* pControl = pRow->GetControl(); int nIndentWidth = pControl->GetHeaderIndent(); CRect& rcIndent = pControl->GetPaintManager()->m_rcPreviewIndent; CRect rcPreviewItem(nIndentWidth + rcIndent.left, 0, nWidth - rcIndent.right, 0); CXTPFontDC font(pDC, &pControl->GetPaintManager()->m_xtpFontPreview); CRect rcFind(rcPreviewItem.left, 0, rcPreviewItem.right, 0); pDC->DrawText(m_strFindLine, rcFind, DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX); CRect rcReplace(rcPreviewItem.left, 0, rcPreviewItem.right, 0); pDC->DrawText(m_strReplaceLine, rcReplace, DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX); return rcFind.Height() + rcReplace.Height() + rcIndent.top + rcIndent.bottom; } void OnDrawCaption(XTP_GRIDRECORDITEM_DRAWARGS* pDrawArgs, XTP_GRIDRECORDITEM_METRICS* /*pMetrics*/) { CRect rcItem(pDrawArgs->rcItem); CDC* pDC = pDrawArgs->pDC; CRect& rcIndent = pDrawArgs->pControl->GetPaintManager()->m_rcPreviewIndent; rcItem.DeflateRect(rcIndent.left, rcIndent.top, rcIndent.right, rcIndent.bottom); CRect rcFind(rcItem); pDC->DrawText(m_strFindLine, rcFind, DT_WORDBREAK | DT_LEFT | DT_NOPREFIX); rcFind.bottom = rcFind.top; pDC->DrawText(m_strFindLine, rcFind, DT_WORDBREAK | DT_LEFT | DT_NOPREFIX | DT_CALCRECT); CRect rcReplace(rcItem); rcReplace.top += rcFind.Height(); if (m_bChanged) if (pDC->GetTextColor() == 0xFF0000) pDC->SetTextColor(0xFF); pDC->DrawText(m_strReplaceLine, rcReplace, DT_WORDBREAK | DT_LEFT | DT_NOPREFIX); } }; class CGrepRecord : public CXTPGridRecord { public: CGrepRecord(CString strPath, CString strDirectory, CString strName, CString strFind, long nLine, CString strFindLine, CString strReplaceLine, long nIndex, long nLength, CString strReplace) { AddItem(new CXTPGridRecordItemText(strName)); AddItem(new CXTPGridRecordItemText(strDirectory)); AddItem(new CXTPGridRecordItemText(strFind)); AddItem(new CXTPGridRecordItemNumber(nLine)); CXTPGridRecordItem* pItem = AddItem(new CXTPGridRecordItem()); pItem->HasCheckbox(TRUE); pItem->SetChecked(strFindLine != strReplaceLine); pItem->SetSortPriority(strFindLine != strReplaceLine ? 1 : 0); pItem->SetGroupPriority(strFindLine != strReplaceLine ? 1 : 0); CString strExt; int nExt = strName.ReverseFind(_T('.')); if (nExt > 0) strExt = strName.Mid(nExt + 1); AddItem(new CXTPGridRecordItemText(strExt)); SetPreviewItem(new CGrepRecordPreview(strFindLine, strReplaceLine)); m_strPath = strPath; m_nIndex = nIndex; m_nLength = nLength; m_strReplace = strReplace; } BOOL IsChecked() { return GetItem(4)->IsChecked(); } void SetChecked(BOOL bChecked) { GetItem(4)->SetChecked(bChecked); } BOOL IsChanged() { return ((CGrepRecordPreview*)GetItemPreview())->m_bChanged; } public: CString m_strPath; int m_nIndex; int m_nLength; CString m_strReplace; }; class CGrepDoc; class CGrepView : public CXTPGridView { protected: // create from serialization only CGrepView(); DECLARE_DYNCREATE(CGrepView) // Attributes public: CGrepDoc* GetDocument(); // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CGrepView) public: virtual BOOL PreCreateWindow(CREATESTRUCT& cs); protected: //}}AFX_VIRTUAL // Implementation public: virtual ~CGrepView(); # ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; # endif protected: void OnGridItemDblClick(NMHDR* pNotifyStruct, LRESULT* /*result*/); void OnGridKeyDown(NMHDR* pNotifyStruct, LRESULT* /*result*/); void OnGridLButtonDown(NMHDR* pNotifyStruct, LRESULT* /*result*/); void CheckSelected(BOOL bChecked); void OnFilePrintPreview(); // Generated message map functions protected: //{{AFX_MSG(CGrepView) afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; # ifndef _DEBUG // debug version in GrepView.cpp inline CGrepDoc* CGrepView::GetDocument() { return (CGrepDoc*)m_pDocument; } # endif ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_GREPVIEW_H__841CCA0D_0740_40E5_810B_7A57EBDD46B7__INCLUDED_)