260 lines
7.3 KiB
C++
260 lines
7.3 KiB
C++
// RowPropPage.cpp : implementation file
|
|
//
|
|
#include "stdafx.h"
|
|
#include "resource.h"
|
|
#include "RowPropPage.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
extern AcDb::TextVertMode Index2VerMode(int nIndex);
|
|
extern int VerMode2Index(AcDb::TextVertMode nVerMode);
|
|
|
|
extern int g_nHorModeNum, g_nVerModeNum, g_nFactorNum, g_nTextSizeNum;
|
|
extern const TCHAR *g_szVerModes[];
|
|
extern TARCH_IMPEXP XString GetSymbolName(AcDbObjectId idSymbolRec);
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CRowPropPage property page
|
|
const TCHAR *g_szRowHeightModes[]={ _T("固定"), _T("至少"), _T("自由"), _T("自动"), _T("继承") };
|
|
|
|
|
|
IMPLEMENT_DYNCREATE(CRowPropPage, CDividerPage)
|
|
|
|
CRowPropPage::CRowPropPage() : CDividerPage(CRowPropPage::IDD)
|
|
{
|
|
//{{AFX_DATA_INIT(CRowPropPage)
|
|
m_nRowFlagItem = -1;
|
|
m_csRowHeight = _T("");
|
|
m_bInheritSheet = FALSE;
|
|
m_nVerMode = -1;
|
|
m_bApplyDescend = FALSE;
|
|
//}}AFX_DATA_INIT
|
|
|
|
for(int i=0; i<4; i++)
|
|
m_lstVerModes.Append(new XString(g_szVerModes[i]));
|
|
for(i=0; i<5; i++)
|
|
m_lstRowHeightModes.Append(new XString(g_szRowHeightModes[i]));
|
|
m_parentRowHeightStyle = TSheetRow::kFixed;
|
|
}
|
|
|
|
CRowPropPage::~CRowPropPage()
|
|
{
|
|
}
|
|
|
|
void CRowPropPage::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDividerPage::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CRowPropPage)
|
|
DDX_Control(pDX, IDC_VERT_ALIGN, m_verModeBox);
|
|
DDX_Control(pDX, IDC_ROWFLAG, m_rowHeightBox);
|
|
DDX_CBIndex(pDX, IDC_ROWFLAG, m_nRowFlagItem);
|
|
DDX_CBString(pDX, IDC_ROWHEIGHT, m_csRowHeight);
|
|
DDX_Check(pDX, IDC_INHERIT_SHEETROW, m_bInheritSheet);
|
|
DDX_CBIndex(pDX, IDC_VERT_ALIGN, m_nVerMode);
|
|
DDX_Check(pDX, IDC_APPLY_DESCEND, m_bApplyDescend);
|
|
//}}AFX_DATA_MAP
|
|
if(!pDX->m_bSaveAndValidate) {
|
|
if(m_bInheritSheet) {
|
|
GetDlgItem(IDC_DIVIDER_COLOR)->EnableWindow(FALSE);
|
|
GetDlgItem(IDC_DIVIDER_LINETYPE)->EnableWindow(FALSE);
|
|
GetDlgItem(IDC_DIVIDER_LINEWIDTH)->EnableWindow(FALSE);
|
|
GetDlgItem(IDC_NODIVIDER)->EnableWindow(FALSE);
|
|
} else {
|
|
GetDlgItem(IDC_NODIVIDER)->EnableWindow(TRUE);
|
|
}
|
|
m_verModeBox.SetCurSel(m_nVerMode);
|
|
BOOL bAllowChHeight=TRUE;
|
|
if((TSheetRow::TRowHeightStyle)m_nRowFlagItem==TSheetRow::kParent &&
|
|
m_parentRowHeightStyle==TSheetRow::kFixed)
|
|
bAllowChHeight=FALSE;
|
|
GetDlgItem(IDC_ROWHEIGHT)->EnableWindow(bAllowChHeight);
|
|
} else {
|
|
m_nVerMode=m_verModeBox.GetCurSel();
|
|
if(_tstof(m_csRowHeight)<1.0E-3)
|
|
pDX->Fail();
|
|
}
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CRowPropPage, CDividerPage)
|
|
//{{AFX_MSG_MAP(CRowPropPage)
|
|
ON_BN_CLICKED(IDC_INHERIT_SHEETROW, OnInheritSheetrow)
|
|
ON_CBN_SELENDOK(IDC_ROWFLAG, OnSelendokRowflag)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CRowPropPage message handlers
|
|
|
|
void CRowPropPage::Obj2Dlg(const TSheetRow &row,
|
|
const TDividerStyle &styleParent,
|
|
const TGridStyle &parentGrid,
|
|
const TDbSheet &sheet)
|
|
{
|
|
const TDividerStyle ÷r=row.GetDividerStyle();
|
|
m_parentDivider=styleParent;
|
|
if(divider.GetDividerFlag()==TDividerStyle::kParent) {
|
|
CDividerPage::Obj2Dlg(m_parentDivider);
|
|
m_bInheritSheet=TRUE;
|
|
} else {
|
|
CDividerPage::Obj2Dlg(divider);
|
|
m_bInheritSheet=FALSE;
|
|
}
|
|
|
|
// 高度
|
|
m_parentRowHeightStyle=sheet.GetRowHeightStyle();
|
|
BOOL bUseParentHeight=FALSE;
|
|
if(row.GetRowHeightStyle()==TSheetRow::kParent && m_parentRowHeightStyle==TSheetRow::kFixed)
|
|
bUseParentHeight=TRUE;
|
|
|
|
m_csRowHeight.Format(_T("%.1f"), bUseParentHeight? sheet.GetRowHeight() : row.GetHeight());
|
|
if(row.GetRowHeightStyle()==TSheetRow::kParent) {
|
|
m_nRowFlagItem = sheet.GetRowHeightStyle();
|
|
if(m_nRowFlagItem>3)
|
|
m_nRowFlagItem=0;
|
|
XString sTemp;
|
|
sTemp << g_szRowHeightModes[m_nRowFlagItem] << _T("(继承)");
|
|
*m_lstRowHeightModes[4] = sTemp;
|
|
m_nRowFlagItem=4;
|
|
}
|
|
else
|
|
m_nRowFlagItem = row.GetRowHeightStyle();
|
|
|
|
|
|
|
|
//垂直对齐
|
|
BOOL bLocal=row.GetVerMode()!=0;
|
|
m_nVerMode=bLocal? VerMode2Index(row.GetVerMode()) : 0;
|
|
int nParentVerMode=VerMode2Index(parentGrid.GetVerMode());
|
|
XString sVerMode;
|
|
sVerMode << g_szVerModes[nParentVerMode] << _T("(继承)");
|
|
*m_lstVerModes[0]=sVerMode;
|
|
|
|
|
|
}
|
|
|
|
void CRowPropPage::Dlg2Obj(TSheetRow &row) const
|
|
{
|
|
TDividerStyle ÷r=row.GetDividerStyle();
|
|
if(m_bInheritSheet) {
|
|
CopyObject(m_parentDivider, divider);
|
|
divider.SetDividerFlag(TDividerStyle::kParent);
|
|
} else {
|
|
CDividerPage::Dlg2Obj(divider);
|
|
if(divider.GetDividerFlag()==TDividerStyle::kParent)
|
|
divider.SetDividerFlag(TDividerStyle::kLocal);
|
|
}
|
|
|
|
TSheetRow::TRowHeightStyle rhs=(TSheetRow::TRowHeightStyle)m_nRowFlagItem;
|
|
double nRowHeight=_tstof(m_csRowHeight);
|
|
if(nRowHeight>1.0E-3 && rhs!=TSheetRow::kParent)
|
|
row.SetHeight(nRowHeight);
|
|
if(m_nRowFlagItem>=0)
|
|
row.SetRowHeightStyle(rhs);
|
|
|
|
//垂直对齐
|
|
if(m_nVerMode>0)
|
|
row.SetVerMode(Index2VerMode(m_nVerMode));
|
|
else if(m_nVerMode==0)
|
|
row.SetVerMode(AcDb::kTextBase);
|
|
|
|
}
|
|
|
|
void CRowPropPage::OnInheritSheetrow()
|
|
{
|
|
UpdateData(TRUE);
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOL CRowPropPage::OnInitDialog()
|
|
{
|
|
CDividerPage::OnInitDialog();
|
|
InitComBox(m_verModeBox, m_lstVerModes);
|
|
InitComBox(m_rowHeightBox, m_lstRowHeightModes);
|
|
UpdateData(FALSE);
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CRowProp
|
|
|
|
IMPLEMENT_DYNAMIC(CRowProp, CPropertySheet)
|
|
|
|
int CRowProp::g_nActivePage=0;
|
|
CRowProp::CRowProp(CWnd* pWndParent)
|
|
: CPropertySheet(_T("行设定"), pWndParent)
|
|
{
|
|
// Add all of the property pages here. Note that
|
|
// the order that they appear in here will be
|
|
// the order they appear in on screen. By default,
|
|
// the first page of the set is the active one.
|
|
// One way to make a different property page the
|
|
// active one is to call SetActivePage().
|
|
AddPage(&m_rowPage);
|
|
|
|
m_psh.dwFlags=m_psh.dwFlags | PSH_NOAPPLYNOW;
|
|
m_psh.dwFlags=m_psh.dwFlags ^ PSH_HASHELP ;
|
|
m_rowPage.m_psp.dwFlags=m_rowPage.m_psp.dwFlags ^ (PSH_HASHELP | PSH_WIZARD) ;
|
|
}
|
|
|
|
CRowProp::~CRowProp()
|
|
{
|
|
}
|
|
|
|
void CRowProp::Obj2Dlg(const TDbSheet &sheet, int nRow)
|
|
{
|
|
m_rowPage.Obj2Dlg(*sheet.GetRow(nRow), sheet.GetRowDivider(), sheet.GetGridStyle(), sheet);
|
|
}
|
|
|
|
void CRowProp::Dlg2Obj(TDbSheet &sheet, int nFrom, int nTo) const
|
|
{
|
|
sheet.assertWriteEnabled();
|
|
for(int i=nFrom; i<=nTo; i++) {
|
|
TSheetRow &row=*sheet.GetRow(i);
|
|
m_rowPage.Dlg2Obj(row);
|
|
if(row.GetRowHeightStyle()==TSheetRow::kParent)
|
|
row.SetHeight(sheet.GetRowHeight(TRUE));
|
|
if(m_rowPage.m_bApplyDescend)
|
|
sheet.DescInheritRowGridStyle(i);
|
|
}
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CRowProp, CPropertySheet)
|
|
//{{AFX_MSG_MAP(CRowProp)
|
|
ON_WM_DESTROY()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CRowProp message handlers
|
|
|
|
BOOL CRowProp::OnInitDialog()
|
|
{
|
|
BOOL bResult = CPropertySheet::OnInitDialog();
|
|
|
|
return bResult;
|
|
}
|
|
|
|
void CRowProp::OnDestroy()
|
|
{
|
|
CPropertySheet::OnDestroy();
|
|
|
|
// TODO: Add your message handler code here
|
|
}
|
|
|
|
|
|
void CRowPropPage::OnSelendokRowflag()
|
|
{
|
|
UpdateData(TRUE);
|
|
UpdateData(FALSE);
|
|
}
|