⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lajournalpanel.cpp

📁 Lakey这是一个免费的CW练习/收/发软件
💻 CPP
字号:
#include "StdAfx.h"
#include "lajournalpanel.h"

CLaJournalPanel::CLaJournalPanel(IPaintableParent* pParent, const RECT* pRect, const MORSECODE* pMorseList, int nMaxShortCount, CFont* pFont/* = NULL */)
{
	m_pParent = pParent;
	m_oRect = *pRect;
	m_pFont = pFont;
	m_pPaintBoard = pParent->NewGraphics(pRect->right - pRect->left, pRect->bottom - pRect->top);
	RECT r;
	SetRect(&r, 0, 0, pRect->right - pRect->left, pRect->bottom - pRect->top);
	m_pPaintBoard->DrawRect(&r);
	//m_pPaintBoard->DrawLine(0, pRect->bottom - pRect->top - 1, pRect->right - pRect->left, pRect->bottom - pRect->top - 1);
	m_nCurrPos = 0;
	m_pMorseParser = new CMorseParser(pMorseList, MORSECODECOUNT, nMaxShortCount, this);
}

CLaJournalPanel::~CLaJournalPanel(void)
{
	delete m_pMorseParser;
	delete m_pPaintBoard;
}

BOOL CLaJournalPanel::IsRelated(int x, int y)
{
	return IControl::PointInRect(&m_oRect, x, y);
}

void CLaJournalPanel::GetRect(RECT* r)
{
	*r = m_oRect;
}

void CLaJournalPanel::OnPaint(void* owner, CGraphics* g, const RECT* pRect)
{
	int w = m_oRect.right - m_oRect.left;
	int h = m_oRect.bottom - m_oRect.top;

	RECT r;
	r.top = 0; r.bottom = h;

	r.left = 0; r.right = w - m_nCurrPos;
	g->Copy(&r, m_pPaintBoard, m_nCurrPos, 0);

	if (0 < m_nCurrPos)
	{
		r.left = w - m_nCurrPos; r.right = w;
		g->Copy(&r, m_pPaintBoard, 0, 0);
	}
}

void CLaJournalPanel::Sample(int nState)
{
	if (nState)
		m_pPaintBoard->SetColor(RGB(0, 0, 0));
	else
		m_pPaintBoard->SetColor(RGB(255, 255, 255));

	int y = 2;

	m_pPaintBoard->DrawLine(m_nCurrPos, y, m_nCurrPos, y + 2);

	m_pPaintBoard->SetColor(RGB(255, 255, 255));
	m_pPaintBoard->DrawLine(m_nCurrPos, m_oRect.bottom - m_oRect.top - 16, m_nCurrPos, m_oRect.bottom - m_oRect.top - 1);

	if (++m_nCurrPos >= m_oRect.right - m_oRect.left)
		m_nCurrPos = 0;

	m_pMorseParser->Sample(nState);

	m_pParent->Invalidate(&m_oRect);
}

void CLaJournalPanel::OnWorkOut(const MORSECODE* pResult)
{
	char buff[] = { '#', '\0' };

	if (pResult)
		buff[0] = pResult->nAscCode;

	m_pPaintBoard->SetColor(0);
	if (m_pFont)
		m_pPaintBoard->SetFont(m_pFont);

	RECT r;
	r.right = m_nCurrPos;
	r.left = r.right - 12;
	r.bottom = m_oRect.bottom - m_oRect.top;
	r.top = r.bottom - 16;
	m_pPaintBoard->DrawText(&r, buff, DT_VCENTER|DT_CENTER|DT_SINGLELINE);

	if (r.left < 0)
	{
		int w = m_oRect.right - m_oRect.left;
		r.right += w;
		r.left += w;
		m_pPaintBoard->DrawText(&r, buff, DT_VCENTER|DT_CENTER|DT_SINGLELINE);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -