📄 memo.cpp
字号:
// MEMO.cpp: implementation of the CMEMO class.
//
//////////////////////////////////////////////////////////////////////
#include "MEMO.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMEMO::CMEMO(CAppMainHandler *pAppMain)
{
AEEDeviceInfo di;
m_pAppMain = pAppMain;
ISHELL_GetDeviceInfo(m_pAppMain->m_pIShell, &di);
m_Mi.m_nx = m_Mi.m_ny = 0;
m_Mi.m_nWidth = di.cxScreen;
m_Mi.m_nHeight = di.cyScreen;
AEEFont font;
int pnAscent, pnDescent;
int m_nFontHeight = IDISPLAY_GetFontMetrics (m_pAppMain->m_pIDisplay, font, &pnAscent, &pnDescent);
m_Mi.m_nLineCount = m_Mi.m_nHeight / (m_nFontHeight + 4);
for( int i=0; i< m_Mi.m_nLineCount; i++ )
m_Mti.m_pLineText[i] = (char*)new char[30];
m_Mti.m_nStartLine = 0;
m_Mti.m_pMemoText = NULL;
m_ptxtFile = NULL;
}
CMEMO::~CMEMO()
{
}
void CMEMO::Size(int x, int y, int width, int height)
{
m_Mi.m_nx = x;
m_Mi.m_ny = y;
m_Mi.m_nWidth = width;
m_Mi.m_nHeight = height;
m_Mi.m_nLineCount = m_Mi.m_nHeight / (m_nFontHeight + 4);
}
int CMEMO::LoadFromFile(char *szFile)
{
if( m_ptagFile )
m_ptagFile->Close();
m_ptagFile = new CTAGTEXTFILE(m_pAppMain, m_Mi.m_nWidth);
m_ptagFile->Open(szFile);
InitTextLine();
return 0;
}
void CMEMO::InitTextLine()
{
m_ptagFile->InitText();
for( int i=0; i < m_Mi.m_nLineCount-1; i++ ) {
m_Mti.m_pLineText[i] = m_ptagFile->Read(true);
}
DrawLine();
}
bool CMEMO::Next()
{
m_Mti.m_nStartLine++;
if( m_Mti.m_nStartLine > m_Mi.m_nLineCount-1)
m_Mti.m_nStartLine = 0;
MakeTextLine(true);
DrawLine();
return true;
}
bool CMEMO::Prev()
{
m_Mti.m_nStartLine--;
if( m_Mti.m_nStartLine < 0 )
m_Mti.m_nStartLine = m_Mi.m_nLineCount - 1;
MakeTextLine(false);
DrawLine();
return true;
}
void CMEMO::MakeTextLine(bool bNext)
{
int nIdx;
nIdx = m_Mti.m_nStartLine - 1;
if( nIdx < 0 )
nIdx = m_Mi.m_nLineCount - 1;
m_Mti.m_pLineText[nIdx] = m_ptagFile->Read(bNext);
}
void CMEMO::DrawLine()
{
int nCount, nIdx;
nCount = nIdx = 0;
nIdx = m_Mti.m_nStartLine;
while( true ) {
if( nIdx > m_Mi.m_nLineCount-1 )
nIdx = 0;
Draw(m_Mti.m_pLineText[nIdx], nCount);
nCount++;
if( nCount == m_Mi.m_nLineCount )
break;
}
}
void CMEMO::Draw(char *pLine, int nY)
{
IDISPLAY_ClearScreen(m_pAppMain->m_pIDisplay); // Clear whole screen
IDISPLAY_DrawText(m_pAppMain->m_pIDisplay, AEE_FONT_NORMAL, (AECHAR*)pLine,
-1, 0, nY*m_nFontHeight+2 , 0, IDF_ALIGN_CENTER | IDF_ALIGN_TOP);
IDISPLAY_Update (m_pAppMain->m_pIDisplay);
}
void CMEMO::CloseFile()
{
if( m_ptxtFile ) {
m_ptxtFile->Close();
delete m_ptxtFile;
m_ptxtFile = NULL;
}
}
int CMEMO::GetText(char *szOut)
{
szOut = m_Mti.m_pMemoText;
return m_Mti.m_nTextLength;
}
int CMEMO::SetText(char *szIn, int nSize)
{
m_Mti.m_pMemoText = szIn;
m_Mti.m_pCurrText = szIn;
m_Mti.m_pEndText = &szIn[nSize-1];
m_Mti.m_nTextLength = STRLEN(szIn);
return m_Mti.m_nTextLength;
}
int CMEMO::GetLength()
{
return m_Mti.m_nTextLength;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -