218 lines
5.8 KiB
C++
218 lines
5.8 KiB
C++
#include "stdafx.h"
|
|
#include "resource.h"
|
|
#include "GridStyleDialog.h"
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CGridStyleDialog dialog
|
|
|
|
const TCHAR * g_szHorModes[5]={_T("继承"), _T("左对齐"), _T("居中"), _T("右对齐"), _T("两端对齐"),};
|
|
const TCHAR * g_szVerModes[4]={_T("继承"), _T("靠上"), _T("居中"), _T("靠下"), };
|
|
const TCHAR * g_szFactors[]={_T("继承"), _T("0"), _T("0.1"), _T("0.2"), _T("0.3"), _T("0.4"), _T("0.5"), _T("0.6"), _T("0.7"), _T("0.8"), _T("0.9"), _T("1.0")};
|
|
const TCHAR * g_szTextSizes[]={_T("继承"), _T("2.5"), _T("3.0"), _T("3.5"), _T("4.0"), _T("5.0"), _T("7.0"), _T("10.0"), _T("14.0"), _T("20.0"), };
|
|
|
|
int g_nHorModeNum=ELEMENTS(g_szHorModes);
|
|
int g_nVerModeNum=ELEMENTS(g_szVerModes);
|
|
int g_nFactorNum=ELEMENTS(g_szFactors);
|
|
int g_nTextSizeNum=ELEMENTS(g_szTextSizes);
|
|
|
|
|
|
AcDb::TextHorzMode Index2HorMode(int nIndex)
|
|
{
|
|
AcDb::TextHorzMode nHorMode;
|
|
switch(nIndex) {
|
|
case 1:
|
|
nHorMode=AcDb::kTextLeft;
|
|
break;
|
|
case 2:
|
|
nHorMode=AcDb::kTextCenter;
|
|
break;
|
|
case 3:
|
|
nHorMode=AcDb::kTextRight;
|
|
break;
|
|
case 4:
|
|
nHorMode=AcDb::kTextFit;
|
|
break;
|
|
default:
|
|
ASSERT(0);
|
|
}
|
|
return nHorMode;
|
|
}
|
|
|
|
AcDb::TextVertMode Index2VerMode(int nIndex)
|
|
{
|
|
AcDb::TextVertMode nVerMode;
|
|
switch(nIndex) {
|
|
case 1:
|
|
nVerMode=AcDb::kTextTop;
|
|
break;
|
|
case 2:
|
|
nVerMode=AcDb::kTextVertMid;
|
|
break;
|
|
case 3:
|
|
nVerMode=AcDb::kTextBottom;
|
|
break;
|
|
default:
|
|
ASSERT(0);
|
|
}
|
|
return nVerMode;
|
|
}
|
|
|
|
|
|
int HorMode2Index(AcDb::TextHorzMode nHorMode)
|
|
{
|
|
int nIndex=0;
|
|
switch(nHorMode) {
|
|
case AcDb::kTextLeft:
|
|
nIndex=1;
|
|
break;
|
|
case AcDb::kTextCenter:
|
|
case AcDb::kTextMid:
|
|
nIndex=2;
|
|
break;
|
|
case AcDb::kTextRight:
|
|
nIndex=3;
|
|
break;
|
|
case AcDb::kTextFit:
|
|
nIndex=4;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return nIndex;
|
|
}
|
|
|
|
int VerMode2Index(AcDb::TextVertMode nVerMode)
|
|
{
|
|
int nIndex=0;
|
|
switch(nVerMode) {
|
|
case AcDb::kTextTop:
|
|
nIndex=1;
|
|
break;
|
|
case AcDb::kTextVertMid:
|
|
nIndex=2;
|
|
break;
|
|
case AcDb::kTextBase:
|
|
case AcDb::kTextBottom:
|
|
nIndex=3;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return nIndex;
|
|
}
|
|
|
|
CGridStyleDialog::CGridStyleDialog(UINT id, CWnd* pParent /*=NULL*/)
|
|
: CAcUiDialog(id, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CGridStyleDialog)
|
|
m_nHorMode = -1;
|
|
m_csLineSpaceFactor = _T("");
|
|
m_csTextSize = _T("");
|
|
m_nTextStyle = -1;
|
|
m_bTextWrap = FALSE;
|
|
m_nVerMode = -1;
|
|
m_bInheritWrapText = FALSE;
|
|
//}}AFX_DATA_INIT
|
|
m_nTextColor=0;
|
|
m_bParentTextWrap=FALSE;
|
|
for(int i=0; i<5; i++)
|
|
m_lstHorModes.Append(new XString(g_szHorModes[i]));
|
|
for(i=0; i<4; i++)
|
|
m_lstVerModes.Append(new XString(g_szVerModes[i]));
|
|
for(i=0; i<ELEMENTS(g_szFactors); i++)
|
|
m_lstFactors.Append(new XString(g_szFactors[i]));
|
|
for(i=0; i<ELEMENTS(g_szTextSizes); i++)
|
|
m_lstTextSizes.Append(new XString(g_szTextSizes[i]));
|
|
|
|
XSymbolList lstStyles(_T("STYLE"));
|
|
m_lstTextStyles.Append(new XString(_T("继承")));
|
|
for(i=0; i<lstStyles.Length(); i++)
|
|
m_lstTextStyles.Append(new XString(lstStyles[i]));
|
|
}
|
|
|
|
|
|
void CGridStyleDialog::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CAcUiDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CGridStyleDialog)
|
|
DDX_Control(pDX, IDC_LINESPACEFACTOR, m_factorBox);
|
|
DDX_Control(pDX, IDC_TEXTSIZE, m_textSizeBox);
|
|
DDX_Control(pDX, IDC_VERMODE, m_verModeBox);
|
|
DDX_Control(pDX, IDC_TEXTSTYLE, m_textStyleBox);
|
|
DDX_Control(pDX, IDC_HORMODE, m_horModeBox);
|
|
DDX_Control(pDX, IDC_TEXTCOLOR, m_colorComboBox);
|
|
DDX_CBIndex(pDX, IDC_HORMODE, m_nHorMode);
|
|
DDX_CBString(pDX, IDC_LINESPACEFACTOR, m_csLineSpaceFactor);
|
|
DDX_CBString(pDX, IDC_TEXTSIZE, m_csTextSize);
|
|
DDX_CBIndex(pDX, IDC_TEXTSTYLE, m_nTextStyle);
|
|
DDX_Check(pDX, IDC_TEXTWRAP, m_bTextWrap);
|
|
DDX_CBIndex(pDX, IDC_VERMODE, m_nVerMode);
|
|
DDX_Check(pDX, IDC_INHERIT_TEXTWRAP, m_bInheritWrapText);
|
|
//}}AFX_DATA_MAP
|
|
if(pDX->m_bSaveAndValidate) {
|
|
if(_tstof(m_csTextSize)<1.0E-3 || _tstof(m_csLineSpaceFactor)<-1.0E-3)
|
|
pDX->Fail();
|
|
}
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CGridStyleDialog, CAcUiDialog)
|
|
//{{AFX_MSG_MAP(CGridStyleDialog)
|
|
ON_BN_CLICKED(IDC_INHERIT_TEXTWRAP, OnInheritTextwrap)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
//初始化组合框
|
|
void CGridStyleDialog::InitComBox(CComboBox& combox, const DList<XString> &lstString)
|
|
{
|
|
combox.ResetContent();
|
|
for (int i = 0 ; i < lstString.Length(); i++) {
|
|
combox.AddString(lstString[i]);
|
|
}
|
|
}
|
|
|
|
|
|
BOOL CGridStyleDialog::OnInitDialog()
|
|
{
|
|
CAcUiDialog::OnInitDialog();
|
|
|
|
InitComBox(m_textSizeBox, m_lstTextSizes);
|
|
InitComBox(m_horModeBox, m_lstHorModes);
|
|
InitComBox(m_verModeBox, m_lstVerModes);
|
|
InitComBox(m_textStyleBox, m_lstTextStyles);
|
|
InitComBox(m_factorBox, m_lstFactors);
|
|
GetDlgItem(IDC_TEXTWRAP)->EnableWindow(!m_bInheritWrapText);
|
|
|
|
int nItem=m_colorComboBox.FindItemByColorIndex(m_nTextColor);
|
|
if(nItem<0) {
|
|
m_colorComboBox.AddColorToMRU(m_nTextColor);
|
|
nItem=m_colorComboBox.FindItemByColorIndex(m_nTextColor);
|
|
}
|
|
if(nItem>=0) m_colorComboBox.SetCurSel(nItem);
|
|
UpdateData(FALSE);
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
|
|
void CGridStyleDialog::OnInheritTextwrap()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
UpdateData(TRUE);
|
|
GetDlgItem(IDC_TEXTWRAP)->EnableWindow(!m_bInheritWrapText);
|
|
if(m_bInheritWrapText)
|
|
m_bTextWrap=m_bParentTextWrap;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CGridStyleDialog::OnOK()
|
|
{
|
|
// 检查对话框输入是否合法
|
|
//...
|
|
int nIndex=m_colorComboBox.GetCurrentItemColorIndex();
|
|
if(nIndex>=0)
|
|
m_nTextColor=nIndex;
|
|
CAcUiDialog::OnOK();
|
|
}
|