// TypeSet.cpp: implementation of the CTypeset class.
//
//
#include "stdafx.h"
#include "../INC/TypeSet.h"
//用法示例
void TestTypeset(HDC dc)
{
//声明一个板材对象
CTypeset typeset;
//设置板材对象大小
typeset.m_Desktop.m_dHeight=9999;
typeset.m_Desktop.m_dWidth=100;
//声明一个排样元素对象
CMaterial material;
//设置排样元素对象大小
material.SetSize(20,99);
//添加进入板材对象
typeset.Add(&material);
//继续添加
material.SetSize(99,80);
typeset.Add(&material);
material.SetSize(10,60);
typeset.Add(&material);
material.SetSize(50,20);
typeset.Add(&material);
//添加完毕,进行排样
typeset.Go();
//排样完毕,输出
list<CMaterial*>::iterator iter;
//画板材对象
::Rectangle(dc,typeset.m_Desktop.m_dX,typeset.m_Desktop.m_dY,
typeset.m_Desktop.m_dX+typeset.m_Desktop.m_dWidth,
typeset.m_Desktop.m_dY+typeset.m_Desktop.m_dHeight);
//画排样元素对象
for(iter=typeset.m_MaterialList.begin();iter!=typeset.m_MaterialList.end();iter++)
{
::Rectangle(dc,(*iter)->m_dX,(*iter)->m_dY,
(*iter)->m_dX+(*iter)->m_dWidth,
(*iter)->m_dY+(*iter)->m_dHeight);
}
}
//
// CMaterial Class
//
//
// Construction/Destruction
//
#define ZERO 0.00001
CMaterial::CMaterial()
{
m_dHeight=100;
m_dWidth=100;
m_dX=0;
m_dY=0;
m_bUsed=FALSE;
m_bSeletcted=FALSE;
m_bRotated=FALSE;
m_iIndex=0;
}
CMaterial::CMaterial(double dWidth,double dHeight)
{
SetSize(dWidth,dHeight);
m_dX=0;
m_dY=0;
m_bUsed=FALSE;
m_bSeletcted=FALSE;
m_bRotated=FALSE;
m_iIndex=0;
}
CMaterial::CMaterial(CMaterial *pMaterial)
{
m_dX=pMaterial->m_dX;
m_dY=pMaterial->m_dY;
m_dHeight=pMaterial->m_dHeight;
m_dWidth=pMaterial->m_dWidth;
m_bUsed=pMaterial->m_bUsed;
m_bSeletcted=pMaterial->m_bSeletcted;
m_bRotated=pMaterial->m_bRotated;
m_iIndex=pMaterial->m_iIndex;
}
void CMaterial::SetSize(double dWidth, double dHeight)
{
m_dHeight=dHeight;
m_dWidth=dWidth;
}
void CMaterial::Rotated()
{
m_bRotated=!m_bRotated;
double dA=m_dHeight;
m_dHeight=m_dWidth;
m_dWidth=dA;
}
CMaterial::~CMaterial()
{
}
//
// Construction/Destruction