<commit_before>
// WinUIView.cpp : CWinUIView ʵ
//

#include "stdafx.h"
// SHARED_HANDLERS ʵԤͼɸѡ
// ATL Ŀнж壬Ŀĵ롣
#ifndef SHARED_HANDLERS
#include "WinUI.h"
#endif

#include "WinUIDoc.h"
#include "WinUIView.h"
#include "ILogQuery.h"
#include "LogItem.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

#define LINE_HEIGHT 15

// CWinUIView

IMPLEMENT_DYNCREATE(CWinUIView, CScrollView)

BEGIN_MESSAGE_MAP(CWinUIView, CScrollView)
	// ׼ӡ
	ON_COMMAND(ID_FILE_PRINT, &CScrollView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, &CScrollView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CWinUIView::OnFilePrintPreview)
	ON_WM_CONTEXTMENU()
	ON_WM_RBUTTONUP()
	ON_WM_TIMER()
	ON_WM_ERASEBKGND()
END_MESSAGE_MAP()

// CWinUIView /

CWinUIView::CWinUIView()
{
	// TODO: ڴ˴ӹ

}

CWinUIView::~CWinUIView()
{
}

BOOL CWinUIView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: ڴ˴ͨ޸
	//  CREATESTRUCT cs ޸Ĵʽ

	return CScrollView::PreCreateWindow(cs);
}

// CWinUIView 

void CWinUIView::OnDraw(CDC* pDC)
{
	CWinUIDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	CRect clientRect;
	GetClientRect(clientRect);

	HDC memDC = ::CreateCompatibleDC(pDC->GetSafeHdc());

	HBITMAP memBmp = ::CreateCompatibleBitmap(pDC->GetSafeHdc(), clientRect.Width(), clientRect.Height());
	::SelectObject(memDC, memBmp);

	::SetBkMode(memDC, TRANSPARENT);

	HBRUSH bkgdBrush = reinterpret_cast<HBRUSH>(::GetStockObject(WHITE_BRUSH));
	::FillRect(memDC, clientRect, bkgdBrush);

	HFONT font = ::CreateFont(LINE_HEIGHT - 1, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
		DEFAULT_QUALITY, FIXED_PITCH, _T(""));
	HGDIOBJ oldFont = ::SelectObject(memDC, font);

	// TODO: ڴ˴Ϊӻƴ
	//DEBUG_INFO("ػ");

	CPoint scrollPosition = GetScrollPosition();
	//DEBUG_INFO(scrollPosition.x << ", " << scrollPosition.y);

	unsigned beginLine = scrollPosition.y / LINE_HEIGHT;
	unsigned endLine = (scrollPosition.y + clientRect.Height()) / LINE_HEIGHT;

	//DEBUG_INFO(beginLine << ", " << endLine);

	vector<LogItem*> vecLines = GetDocument()->logQuery->getRange(beginLine, endLine + 1);
	for (unsigned i = 0; i < vecLines.size(); i++) {
		LogItem* item = vecLines[i];

		wostringstream oss;
		oss << i + 1 << " " << item->text;
		wstring line = oss.str();
		::TextOut(memDC, 0, i * LINE_HEIGHT, line.c_str(), line.size());
	}

	::BitBlt(pDC->GetSafeHdc(), scrollPosition.x, scrollPosition.y, clientRect.Width(), clientRect.Height(),
		memDC, 0, 0, SRCCOPY);

	//wostringstream ossLoad;
	//ossLoad << pDoc->m_nLoadTimespan;
	//wstring load = ossLoad.str();
	//pDC->TextOut(100, 0, load.c_str(), load.size());

	::DeleteObject(font);
	::DeleteObject(memBmp);
	::DeleteDC(memDC);
}

void CWinUIView::OnInitialUpdate()
{
	CScrollView::OnInitialUpdate();

	// TODO: ͼĺϼƴС
	UpdateScroll();
	SetTimer(0, 500, NULL);
}

void CWinUIView::UpdateScroll()<commit_msg>1.修正行号错误问题 2.修正一处调试信息乱码<commit_after>
// WinUIView.cpp : CWinUIView ʵ
//

#include "stdafx.h"
// SHARED_HANDLERS ʵԤͼɸѡ
// ATL Ŀнж壬Ŀĵ롣
#ifndef SHARED_HANDLERS
#include "WinUI.h"
#endif

#include "WinUIDoc.h"
#include "WinUIView.h"
#include "ILogQuery.h"
#include "LogItem.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

#define LINE_HEIGHT 15

// CWinUIView

IMPLEMENT_DYNCREATE(CWinUIView, CScrollView)

BEGIN_MESSAGE_MAP(CWinUIView, CScrollView)
	// ׼ӡ
	ON_COMMAND(ID_FILE_PRINT, &CScrollView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, &CScrollView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CWinUIView::OnFilePrintPreview)
	ON_WM_CONTEXTMENU()
	ON_WM_RBUTTONUP()
	ON_WM_TIMER()
	ON_WM_ERASEBKGND()
END_MESSAGE_MAP()

// CWinUIView /

CWinUIView::CWinUIView()
{
	// TODO: ڴ˴ӹ

}

CWinUIView::~CWinUIView()
{
}

BOOL CWinUIView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: ڴ˴ͨ޸
	//  CREATESTRUCT cs ޸Ĵʽ

	return CScrollView::PreCreateWindow(cs);
}

// CWinUIView 

void CWinUIView::OnDraw(CDC* pDC)
{
	CWinUIDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	CRect clientRect;
	GetClientRect(clientRect);

	HDC memDC = ::CreateCompatibleDC(pDC->GetSafeHdc());

	HBITMAP memBmp = ::CreateCompatibleBitmap(pDC->GetSafeHdc(), clientRect.Width(), clientRect.Height());
	::SelectObject(memDC, memBmp);

	::SetBkMode(memDC, TRANSPARENT);

	HBRUSH bkgdBrush = reinterpret_cast<HBRUSH>(::GetStockObject(WHITE_BRUSH));
	::FillRect(memDC, clientRect, bkgdBrush);

	HFONT font = ::CreateFont(LINE_HEIGHT - 1, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
		DEFAULT_QUALITY, FIXED_PITCH, _T(""));
	HGDIOBJ oldFont = ::SelectObject(memDC, font);

	// TODO: ڴ˴Ϊӻƴ
	//DEBUG_INFO(_T("ػ"));

	CPoint scrollPosition = GetScrollPosition();
	//DEBUG_INFO(scrollPosition.x << ", " << scrollPosition.y);

	unsigned beginLine = scrollPosition.y / LINE_HEIGHT;
	unsigned endLine = (scrollPosition.y + clientRect.Height()) / LINE_HEIGHT;

	//DEBUG_INFO(beginLine << ", " << endLine);

	vector<LogItem*> vecLines = GetDocument()->logQuery->getRange(beginLine, endLine + 1);
	for (unsigned i = 0; i < vecLines.size(); i++) {
		LogItem* item = vecLines[i];

		wostringstream oss;
		oss << beginLine + i + 1 << " " << item->text;
		wstring line = oss.str();
		::TextOut(memDC, 0, i * LINE_HEIGHT, line.c_str(), line.size());
	}

	::BitBlt(pDC->GetSafeHdc(), scrollPosition.x, scrollPosition.y, clientRect.Width(), clientRect.Height(),
		memDC, 0, 0, SRCCOPY);

	//wostringstream ossLoad;
	//ossLoad << pDoc->m_nLoadTimespan;
	//wstring load = ossLoad.str();
	//pDC->TextOut(100, 0, load.c_str(), load.size());

	::DeleteObject(font);
	::DeleteObject(memBmp);
	::DeleteDC(memDC);
}

void CWinUIView::OnInitialUpdate()
{
	CScrollView::OnInitialUpdate();

	// TODO: ͼĺϼƴС
	UpdateScroll();
	SetTimer(0, 500, NULL);
}

void CWinUIView::UpdateScroll()
{'fraction_non_alphanumeric': 0.15916175961205403, 'fraction_numerical': 0.007620367163145133, 'mean_word_length': 5.5625, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6683522', 'n_tokens_mistral': 2524, 'n_tokens_neox': 2409, 'n_words': 401}