?? huffmandoc.cpp
字號(hào):
// huffmanDoc.cpp : ChuffmanDoc 類的實(shí)現(xiàn)
//
#include "stdafx.h"
#include "huffman.h"
#include "NodeFont.h"
#include "HuffTree.h"
#include "ShowCodeDlg.h"
#include "huffmanDoc.h"
#include ".\huffmandoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// ChuffmanDoc
IMPLEMENT_DYNCREATE(ChuffmanDoc, CDocument)
BEGIN_MESSAGE_MAP(ChuffmanDoc, CDocument)
ON_COMMAND(ID__CODESHOW, OnShowCode)
END_MESSAGE_MAP()
// ChuffmanDoc 構(gòu)造/析構(gòu)
ChuffmanDoc::ChuffmanDoc()
: m_strYFile(_T(""))
, m_widthDoc(30)
, m_heigthDoc(40)
, m_notLeaf(_T("*"))
, m_spaceLeaf(_T("#"))
{
m_clrNotLeaf=RGB(0,0,0);
m_clrSpaceLeaf=RGB(0,0,0);
m_clrLeaf=RGB(0,0,0);
m_clrEdge=RGB(0,0,0);
m_clrBack=RGB(255,240,240);
m_leafFont.lfHeight=16;
m_leafFont.lfWidth=7;
m_leafFont.lfWeight=700;
m_leafFont.lfQuality=2;
m_leafFont.lfCharSet=134;
m_leafFont.lfOrientation=0;
m_leafFont.lfEscapement=0;
m_leafFont.lfClipPrecision=2;
m_leafFont.lfItalic=false;
m_leafFont.lfStrikeOut=false;
m_leafFont.lfUnderline=false;
::lstrcpy(m_leafFont.lfFaceName,_T("System"));
m_notLeafFont.lfHeight=16;
m_notLeafFont.lfWidth=7;
m_notLeafFont.lfWeight=700;
m_notLeafFont.lfQuality=2;
m_notLeafFont.lfCharSet=134;
m_notLeafFont.lfOrientation=0;
m_notLeafFont.lfEscapement=0;
m_notLeafFont.lfClipPrecision=2;
m_notLeafFont.lfItalic=false;
m_notLeafFont.lfStrikeOut=false;
m_notLeafFont.lfUnderline=false;
::lstrcpy(m_notLeafFont.lfFaceName,_T("System"));
m_spaceLeafFont.lfHeight=16;
m_spaceLeafFont.lfWidth=7;
m_spaceLeafFont.lfWeight=700;
m_spaceLeafFont.lfQuality=2;
m_spaceLeafFont.lfCharSet=134;
m_spaceLeafFont.lfOrientation=0;
m_spaceLeafFont.lfEscapement=0;
m_spaceLeafFont.lfClipPrecision=2;
m_spaceLeafFont.lfItalic=false;
m_spaceLeafFont.lfStrikeOut=false;
m_spaceLeafFont.lfUnderline=false;
::lstrcpy(m_spaceLeafFont.lfFaceName,_T("System"));
}
ChuffmanDoc::~ChuffmanDoc()
{
}
BOOL ChuffmanDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: 在此添加重新初始化代碼
// (SDI 文檔將重用該文檔)
return TRUE;
}
// ChuffmanDoc 序列化
void ChuffmanDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
ar<<m_strYFile;
ar<<m_widthDoc<<m_heigthDoc;
ar<<m_notLeaf<<m_spaceLeaf;
ar<<m_notLeafFont.lfCharSet<<m_notLeafFont.lfClipPrecision<<m_notLeafFont.lfEscapement
<<m_notLeafFont.lfHeight<<m_notLeafFont.lfItalic<<m_notLeafFont.lfOrientation
<<m_notLeafFont.lfOutPrecision<<m_notLeafFont.lfPitchAndFamily<<m_notLeafFont.lfQuality
<<m_notLeafFont.lfStrikeOut<<m_notLeafFont.lfUnderline<<m_notLeafFont.lfWeight<<m_notLeafFont.lfWidth;
ar<<m_spaceLeafFont.lfCharSet<<m_spaceLeafFont.lfClipPrecision<<m_spaceLeafFont.lfEscapement
<<m_spaceLeafFont.lfHeight<<m_spaceLeafFont.lfItalic<<m_spaceLeafFont.lfOrientation
<<m_spaceLeafFont.lfOutPrecision<<m_spaceLeafFont.lfPitchAndFamily<<m_spaceLeafFont.lfQuality
<<m_spaceLeafFont.lfStrikeOut<<m_spaceLeafFont.lfUnderline<<m_spaceLeafFont.lfWeight<<m_spaceLeafFont.lfWidth;
ar<<m_leafFont.lfCharSet<<m_leafFont.lfClipPrecision<<m_leafFont.lfEscapement
<<m_leafFont.lfHeight<<m_leafFont.lfItalic<<m_leafFont.lfOrientation
<<m_leafFont.lfOutPrecision<<m_leafFont.lfPitchAndFamily<<m_leafFont.lfQuality
<<m_leafFont.lfStrikeOut<<m_leafFont.lfUnderline<<m_leafFont.lfWeight<<m_leafFont.lfWidth;
ar<<m_clrNotLeaf<<m_clrSpaceLeaf<<m_clrLeaf;
ar<<m_clrEdge<<m_clrBack;
int len=::lstrlen(m_notLeafFont.lfFaceName);
int i=0;
ar<<len;
for(i=0;i<len;i++)
{
ar<<m_notLeafFont.lfFaceName[i];
}
len=::lstrlen(m_spaceLeafFont.lfFaceName);
ar<<len;
for(i=0;i<len;i++)
{
ar<<m_spaceLeafFont.lfFaceName[i];
}
len=::lstrlen(m_leafFont.lfFaceName);
ar<<len;
for(i=0;i<len;i++)
{
ar<<m_leafFont.lfFaceName[i];
}
theApp.m_HuffTree.Serialize(ar);
}
else
{
ar>>m_strYFile;
ar>>m_widthDoc>>m_heigthDoc;
ar>>m_notLeaf>>m_spaceLeaf;
ar>>m_notLeafFont.lfCharSet>>m_notLeafFont.lfClipPrecision>>m_notLeafFont.lfEscapement
>>m_notLeafFont.lfHeight>>m_notLeafFont.lfItalic>>m_notLeafFont.lfOrientation
>>m_notLeafFont.lfOutPrecision>>m_notLeafFont.lfPitchAndFamily>>m_notLeafFont.lfQuality
>>m_notLeafFont.lfStrikeOut>>m_notLeafFont.lfUnderline>>m_notLeafFont.lfWeight>>m_notLeafFont.lfWidth;
ar>>m_spaceLeafFont.lfCharSet>>m_spaceLeafFont.lfClipPrecision>>m_spaceLeafFont.lfEscapement
>>m_spaceLeafFont.lfHeight>>m_spaceLeafFont.lfItalic>>m_spaceLeafFont.lfOrientation
>>m_spaceLeafFont.lfOutPrecision>>m_spaceLeafFont.lfPitchAndFamily>>m_spaceLeafFont.lfQuality
>>m_spaceLeafFont.lfStrikeOut>>m_spaceLeafFont.lfUnderline>>m_spaceLeafFont.lfWeight>>m_spaceLeafFont.lfWidth;
ar>>m_leafFont.lfCharSet>>m_leafFont.lfClipPrecision>>m_leafFont.lfEscapement
>>m_leafFont.lfHeight>>m_leafFont.lfItalic>>m_leafFont.lfOrientation
>>m_leafFont.lfOutPrecision>>m_leafFont.lfPitchAndFamily>>m_leafFont.lfQuality
>>m_leafFont.lfStrikeOut>>m_leafFont.lfUnderline>>m_leafFont.lfWeight>>m_leafFont.lfWidth;
ar>>m_clrNotLeaf>>m_clrSpaceLeaf>>m_clrLeaf;
ar>>m_clrEdge>>m_clrBack;
int len,i;
ar>>len;
for(i=0;i<len;i++)
{
ar>>m_notLeafFont.lfFaceName[i];
}
ar>>len;
for(i=0;i<len;i++)
{
ar>>m_spaceLeafFont.lfFaceName[i];
}
ar>>len;
for(i=0;i<len;i++)
{
ar>>m_leafFont.lfFaceName[i];
}
theApp.m_HuffTree.Serialize(ar);
}
}
// ChuffmanDoc 診斷
#ifdef _DEBUG
void ChuffmanDoc::AssertValid() const
{
CDocument::AssertValid();
}
void ChuffmanDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
// ChuffmanDoc 命令
void ChuffmanDoc::OnShowCode()
{
CShowCodeDlg scdlg;
if(scdlg.DoModal()==IDOK)
{
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -