📄 readtxt.cpp
字号:
//////////////////////////////////////////////////////
#include "stdafx.h"
#include "newpt.h"
#include "Writebuf.h"
#include "Readtxt.h"
#include "newdzini.h"
#define ZOOMOUT 1
#define ZOOMIN 2
#define STEPBYSTEP 3
#define NORMAL 4
#define EXPLTOR 5
#define EXPRTOL 6
#define EXPUTOD 7
#define EXPDTOU 8
#define EXPDJB 9
#define EXPDJA 10
#define CENTOLR 11
#define LRTOCEN 12
#define CENTOUD 13
#define UDTOCEN 14
#define CENTOROUND 15
#define ROUNDTOCEN 16
#define SHIFTWINLTOR 17
#define SHIFTWINRTOL 18
#define SHIFTWINUTOD 19
#define SHIFTWINDTOU 20
#define DANRU 21
#define DANCU 22
#define LEFTTOPTORIGHTBOTTOM 23
#define RIGHTTOPTOLEFTBOTTOM 24
#define LEFTTOPDRAWCICLE 25
#define RIGHTTOPDRAWCICLE 26
#define CENTRETOGROUND 27
#define GROUNDTOCENTRE 28
#define LEFTRIGHTSWITCH 29
#define TOPBOTTOMSWITCH 30
#define LEFTTOPRIGHTBOTTOMTOLEFTRIGHT 31
#define LINEBYLINE 32
#define CTTOB 40
#define CLTOR 41
#define UTOD 42
#define DTOU 43
#define LTOR 44
#define RTOL 45
#define CHANGECOLOR 46
LOGFONT lp;
IMPLEMENT_DYNCREATE(CFontDraw, CObject)
IMPLEMENT_DYNCREATE(CFontSizeDraw, CObject)
IMPLEMENT_DYNCREATE(CColorDraw, CObject)
IMPLEMENT_DYNCREATE(CShowDraw, CObject)
IMPLEMENT_DYNCREATE(CDrawTxt, CObject)
CDrawTxt::CDrawTxt()
{
}
CDrawTxt::~CDrawTxt()
{
}
CShowTxt::CShowTxt(CWnd *m_pWnd,CAdd *padd,BYTE m_hei)
{
font_width=theApp.font_width;
font_hight=theApp.font_hight;
font_name=theApp.font_name;
font_color=theApp.font_color;
font_space=theApp.font_space;
font_mode=theApp.font_mode;
font_delay=theApp.font_delay;
font_s=theApp.font_s;
m_enter=FALSE;
m_txt=0;
CRect m_rect;
theApp.WriteProfileInt("","",0);
m_pWnd->GetClientRect(&m_rect);
m_size.cx=m_rect.Width();
m_size.cy=m_rect.Height();
m_openfile=FALSE;
m_ptopdrawtxt=NULL;
m_pbottomdrawtxt=NULL;
m_TitleRowNO=0;
m_BottomRowNO=0;
bClrScreen=FALSE;
m_padd=padd;
m_led=new WriteLed(m_padd,m_hei);
}
CShowTxt::CShowTxt(CString m_filename,CWnd *m_pWnd,CRect m_rc,CStringList * fontlist,CAdd * padd,BYTE m_hei)
{
font_width=theApp.font_width;
font_hight=theApp.font_hight;
font_name=theApp.font_name;
font_color=theApp.font_color;
font_space=theApp.font_space;
font_mode=theApp.font_mode;
font_delay=theApp.font_delay;
font_s=theApp.font_s;
m_enter=FALSE;
m_txt=0;
SetTxt(m_filename,m_pWnd,m_rc,fontlist,padd,m_hei);
CRect m_rect;
m_pWnd->GetClientRect(&m_rect);
m_size.cx=m_rect.Width();
m_size.cy=m_rect.Height();
m_openfile=FALSE;
//ShowOnePage();
m_TitleRowNO=0;
m_BottomRowNO=0;
bClrScreen=FALSE;
}
void CShowTxt::SetTxt(CString m_filename,CWnd *m_pWnd,CRect m_rc,CStringList * fontlist,CAdd * padd,BYTE m_hei)
{
m_fontlist=fontlist;
m_txtfilename=m_filename;
m_pshowwnd=m_pWnd;
m_showrect=m_rc;
m_oldrect=m_rc;
////////////////////
if(m_txtfile.Open(m_filename,CFile::modeRead|CFile::shareDenyNone))
m_openfile=TRUE;
else
m_openfile=FALSE;
m_ptopdrawtxt=NULL;
m_pbottomdrawtxt=NULL;
}
CShowTxt::~CShowTxt()
{
// CDrawTxt* pDrawTxt;
POSITION pos;
if(m_openfile&&m_txtfile.m_hFile)
m_txtfile.Close();
if(m_ptopdrawtxt)
delete m_ptopdrawtxt;
if(m_pbottomdrawtxt)
delete m_pbottomdrawtxt;
for(int i=0;i<m_topdrawtxtList.GetCount();i++)
{
pos=m_topdrawtxtList.FindIndex(i);
// pDrawTxt=(CDrawTxt*)m_topdrawtxtList.GetAt(pos);
// m_ptopdrawtxt=(CDrawTxt*)m_topdrawtxtList.GetAt(pos);
// delete m_ptopdrawtxt;
/*
POSITION m_pos1;
for(int jj=pDrawTxt->m_fontdrawlist.GetCount()-1;jj>=0;jj--)
{
m_pos1=pDrawTxt->m_fontdrawlist.FindIndex(jj);
CFontDraw *m_demofont=(CFontDraw *)pDrawTxt->m_fontdrawlist.GetAt(m_pos1);
pDrawTxt->m_fontdrawlist.RemoveAt(m_pos1);
delete m_demofont;
}
for(jj=pDrawTxt->m_colordrawlist.GetCount()-1;jj>=0;jj--)
{
m_pos1=pDrawTxt->m_colordrawlist.FindIndex(jj);
CColorDraw *m_democolor=(CColorDraw *)pDrawTxt->m_colordrawlist.GetAt(m_pos1);
pDrawTxt->m_colordrawlist.RemoveAt(m_pos1);
delete m_democolor;
}
for(jj=pDrawTxt->m_showdrawlist.GetCount()-1;jj>=0;jj--)
{
m_pos1=pDrawTxt->m_showdrawlist.FindIndex(jj);
CShowDraw *m_demoshow=(CShowDraw *)pDrawTxt->m_showdrawlist.GetAt(m_pos1);
pDrawTxt->m_showdrawlist.RemoveAt(m_pos1);
delete m_demoshow;
}
for(jj=pDrawTxt->m_fontsizelist.GetCount()-1;jj>=0;jj--)
{
m_pos1=pDrawTxt->m_fontsizelist.FindIndex(jj);
CFontSizeDraw *m_demoshow=(CFontSizeDraw *)pDrawTxt->m_fontsizelist.GetAt(m_pos1);
pDrawTxt->m_fontsizelist.RemoveAt(m_pos1);
delete m_demoshow;
}
m_topdrawtxtList.RemoveAt(pos);
if(pDrawTxt)delete pDrawTxt;
*/ }
for( i=0;i<m_bottomdrawtxtList.GetCount();i++)
{
pos=m_bottomdrawtxtList.FindIndex(i);
// pDrawTxt=(CDrawTxt*)m_bottomdrawtxtList.GetAt(pos);
// m_bottomdrawtxtList.RemoveAt(pos);
// if(pDrawTxt)delete pDrawTxt;
}
if(m_led)
delete m_led;
}
void CShowTxt::ShowOnePage()
{
CDrawTxt * m_demo;
CFontDraw *m_demofont;
CColorDraw *m_democolor;
CShowDraw *m_demoshow;
POSITION m_pos;
POSITION m_pos1;
int ii,jj;
if(!m_openfile)
return;
while(1)
{
for(ii=m_listdrawtxt.GetCount()-1;ii>=0;ii--)
{
m_pos=m_listdrawtxt.FindIndex(ii);
m_demo=(CDrawTxt *)m_listdrawtxt.GetAt(m_pos);
for(jj=m_demo->m_fontdrawlist.GetCount()-1;jj>=0;jj--)
{
m_pos1=m_demo->m_fontdrawlist.FindIndex(jj);
m_demofont=(CFontDraw *)m_demo->m_fontdrawlist.GetAt(m_pos1);
m_demo->m_fontdrawlist.RemoveAt(m_pos1);
delete m_demofont;
}
for(jj=m_demo->m_colordrawlist.GetCount()-1;jj>=0;jj--)
{
m_pos1=m_demo->m_colordrawlist.FindIndex(jj);
m_democolor=(CColorDraw *)m_demo->m_colordrawlist.GetAt(m_pos1);
m_demo->m_colordrawlist.RemoveAt(m_pos1);
delete m_democolor;
}
for(jj=m_demo->m_showdrawlist.GetCount()-1;jj>=0;jj--)
{
m_pos1=m_demo->m_showdrawlist.FindIndex(jj);
m_demoshow=(CShowDraw *)m_demo->m_showdrawlist.GetAt(m_pos1);
m_demo->m_showdrawlist.RemoveAt(m_pos1);
delete m_demoshow;
}
m_listdrawtxt.RemoveAt(m_pos);
delete m_demo;
}
if(!GetOnePage())
break;
m_showrect=m_oldrect;
POSITION pos;
int iu=m_topdrawtxtList.GetCount();
for(int jj=0;jj<m_topdrawtxtList.GetCount();jj++)
{
pos=m_topdrawtxtList.FindIndex(jj);
m_ptopdrawtxt=(CDrawTxt*)m_topdrawtxtList.GetAt(pos);
if(m_ptopdrawtxt&&m_ptopdrawtxt->m_showstr.GetLength()>0)
m_showrect.top+=(m_ptopdrawtxt->maxhight+m_ptopdrawtxt->space);
// delete m_ptopdrawtxt;
}
for( jj=0;jj<m_bottomdrawtxtList.GetCount();jj++)
{
pos=m_bottomdrawtxtList.FindIndex(jj);
m_pbottomdrawtxt=(CDrawTxt*)m_topdrawtxtList.GetAt(pos);
if(m_pbottomdrawtxt&&m_pbottomdrawtxt->m_showstr.GetLength()>0)
// m_showrect.top+=(m_ptopdrawtxt->maxhight+m_ptopdrawtxt->space);
m_showrect.bottom-=(m_pbottomdrawtxt->maxhight+m_pbottomdrawtxt->space);
}
// if(m_pbottomdrawtxt&&m_pbottomdrawtxt->m_showstr.GetLength()>0)
// m_showrect.bottom-=(m_pbottomdrawtxt->maxhight+m_pbottomdrawtxt->space);
if(font_mode==1||font_mode==2)
ZoomInAndOut(font_mode-1);
else if(font_mode==3)
ScrollStepByStep();
else if(font_mode==15)
ScrollRToL();
else
CommonShow();
}
}
BOOL CShowTxt::GetOnePage()
{
CDrawTxt* m_demo;
int cur_hight;
int jj;
char m_ch;
jj=0;
cur_hight=m_showrect.Height();
while(1)
{
m_demo=new CDrawTxt;
m_demo->space=font_space;
m_demo->maxhight=font_hight;
m_ch=GetOneLine(m_demo,cur_hight);
if(m_ch==0)
{
delete m_demo;
continue;
}
else if(m_ch==-1)
{
if(jj==0)
return FALSE;
else
return TRUE;
}
CheckMode(m_demo);
if(m_txt>0)
{
if(m_txt==1)
{
// if(m_ptopdrawtxt)
// delete m_ptopdrawtxt;
// m_ptopdrawtxt->m_showstr+="/r/n"+m_demo->m_showstr ;
// m_ptopdrawtxt=m_demo;
m_txt=0;
CString str=m_demo->m_showstr;
if(str.GetLength()==0)continue;
//if(m_ptopdrawtxt->m_showstr.GetLength()==0)
// continue;
m_topdrawtxtList.AddTail(m_demo); //////
}
else
{
// if(m_pbottomdrawtxt)
// delete m_pbottomdrawtxt;
// m_pbottomdrawtxt=m_demo;
m_txt=0;
CString str=m_demo->m_showstr;
if(str.GetLength()==0)continue;
// if(m_pbottomdrawtxt->m_showstr.GetLength()==0)
// continue;
m_bottomdrawtxtList.AddTail(m_demo); /////
}
}
else
{
m_listdrawtxt.AddTail(m_demo);
if(font_mode==1||font_mode==2||font_mode==3)
break;
}
cur_hight-=(m_demo->space+m_demo->maxhight);
if(cur_hight<0)
break;
jj++;
if(m_ch==2)
break;
}
return TRUE;
}
char CShowTxt::GetOneLine(CDrawTxt *m_drawtxt,int &m_hight)
{
BYTE ch;
int kk,jj,m_cur,old_fontcur,old_colorcur,old_fontsize;
char m_buf[1024];
char m_str[1024];
char m_str1[8];
WORD cur_len=0;
int m_len;
int len;
DWORD m_value;
CString HTime_start,HTime_end;//wanli
if(m_hight<m_drawtxt->maxhight)//m_hight屏高,m_drawtxt->maxhight默认字高
return -1;
memset(m_buf,0,1024);
memset(m_str,0,1024);
m_len=m_showrect.Width();
len=m_txtfile.Read(m_buf,1024);
read_len=len;
if(len==0) return -1;
kk=0;
m_cur=old_fontcur=old_colorcur=old_fontsize=0;
//宽度,看一行是否超过所要显示的宽度
while(kk<m_len)
{
if(m_buf[kk]=='\r')
{
kk++;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -