300 lines
7.9 KiB
C++
300 lines
7.9 KiB
C++
// CSheetProp.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "resource.h"
|
|
#include "SheetProp.h"
|
|
#include "GridSheetDlg.h"//add by whl
|
|
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char BASED_CODE THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSheetProp
|
|
extern void SheetFullEdit();
|
|
extern void EditColumn();
|
|
extern void EditRow();
|
|
extern void MergeCell();
|
|
extern void EditCell();
|
|
int EditSheetProp(AcDbObjectId id)//modified by whl
|
|
{
|
|
UINT nRet;
|
|
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbSheet, pSheet);
|
|
CTemporaryResourceOverride vTemp;//加载菜单
|
|
CSheetProp dlg(acedGetAcadFrame());
|
|
dlg.Obj2Dlg(pSheet);
|
|
// Zyu modify on 100726,强制转换,去除编译警告
|
|
//nRet=dlg.DoModal();
|
|
nRet = (int)dlg.DoModal();
|
|
if(nRet!=IDCANCEL){
|
|
if(pSheet->upgradeOpen()==Acad::eOk) {
|
|
dlg.Dlg2Obj(pSheet);
|
|
pSheet->CalculateRowHeight(0, pSheet->GetRowNum()-1);
|
|
pSheet->downgradeOpen();
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
switch(nRet)
|
|
{
|
|
case ID_EDIT_ALL:
|
|
{
|
|
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbSheet, pSheet);
|
|
if(pSheet) {
|
|
TDbSheet sheet;
|
|
CopyObject(*pSheet, sheet);
|
|
CTemporaryResourceOverride vTemp;
|
|
CGridSheetDlg dlg(&sheet, acedGetAcadFrame());
|
|
if(dlg.DoModal()==IDOK) {
|
|
if(pSheet->upgradeOpen()==Acad::eOk) {
|
|
pSheet->assertWriteEnabled();
|
|
CopyObject(sheet, *pSheet);
|
|
pSheet->CalculateRowHeight(0, pSheet->GetRowNum()-1);
|
|
pSheet->downgradeOpen();
|
|
}
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
break;
|
|
}
|
|
case ID_EDIT_CELL:EditCell();break;
|
|
case ID_CONBINE_CELL:MergeCell();break;
|
|
case ID_EDIT_ROW:EditRow();break;
|
|
case ID_EDIT_COL:EditColumn();break;
|
|
}
|
|
return RTNORM;
|
|
}
|
|
|
|
|
|
IMPLEMENT_DYNCREATE(CSheetGridStylePage, CGridStylePage)
|
|
|
|
CSheetGridStylePage::CSheetGridStylePage()
|
|
:CGridStylePage(CSheetGridStylePage::IDD)
|
|
{
|
|
//{{AFX_DATA_INIT(CSheetGridStylePage)
|
|
m_bApplyDescend = FALSE;
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
CSheetGridStylePage::~CSheetGridStylePage()
|
|
{
|
|
}
|
|
|
|
|
|
|
|
void CSheetGridStylePage::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CGridStylePage::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CSheetGridStylePage)
|
|
DDX_Check(pDX, IDC_APPLY_DESCEND, m_bApplyDescend);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CSheetGridStylePage, CGridStylePage)
|
|
|
|
|
|
//{{AFX_MSG_MAP(CSheetGridStylePage)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
IMPLEMENT_DYNAMIC(CSheetProp, CPropertySheet)
|
|
|
|
int CSheetProp::g_nActivePage=0;
|
|
CSheetProp::CSheetProp(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_gridStyle);
|
|
AddPage(&m_rowDivider);
|
|
AddPage(&m_colDivider);
|
|
AddPage(&m_border);
|
|
AddPage(&m_title);
|
|
m_gridStyle.InitDataMember(FALSE);
|
|
m_title.InitDataMember(FALSE);
|
|
|
|
m_psh.dwFlags=m_psh.dwFlags | PSH_NOAPPLYNOW;
|
|
m_psh.dwFlags=m_psh.dwFlags ^ PSH_HASHELP ;
|
|
m_gridStyle.m_psp.dwFlags=m_gridStyle.m_psp.dwFlags ^ (PSH_HASHELP | PSH_WIZARD) ;
|
|
m_rowDivider.m_psp.dwFlags=m_rowDivider.m_psp.dwFlags ^ (PSH_HASHELP | PSH_WIZARD);
|
|
m_colDivider.m_psp.dwFlags=m_colDivider.m_psp.dwFlags ^ (PSH_HASHELP | PSH_WIZARD);
|
|
m_border.m_psp.dwFlags=m_border.m_psp.dwFlags ^ (PSH_HASHELP | PSH_WIZARD);
|
|
m_title.m_psp.dwFlags=m_title.m_psp.dwFlags ^ (PSH_HASHELP | PSH_WIZARD);
|
|
}
|
|
|
|
CSheetProp::~CSheetProp()
|
|
{
|
|
}
|
|
|
|
void CSheetProp::Obj2Dlg(const TDbSheet *pSheet)
|
|
{
|
|
m_gridStyle.Obj2Dlg(pSheet->GetGridStyle());
|
|
m_rowDivider.Obj2Dlg(pSheet);
|
|
m_colDivider.Obj2Dlg(pSheet);
|
|
m_border.Obj2Dlg(pSheet);
|
|
m_title.Obj2Dlg(pSheet);
|
|
}
|
|
|
|
void CSheetProp::Dlg2Obj(TDbSheet *pSheet) const
|
|
{
|
|
pSheet->assertWriteEnabled();
|
|
m_gridStyle.Dlg2Obj(pSheet->GetGridStyle());
|
|
if(m_gridStyle.m_bApplyDescend) {
|
|
pSheet->DescInheritGridStyle();
|
|
}
|
|
m_rowDivider.Dlg2Obj(pSheet);
|
|
if(m_rowDivider.m_bApplyDescend) {
|
|
pSheet->DescInheritRowDivider(true);
|
|
}
|
|
|
|
m_colDivider.Dlg2Obj(pSheet);
|
|
if(m_colDivider.m_bApplyDescend)
|
|
pSheet->DescInheritColDivider();
|
|
|
|
m_border.Dlg2Obj(pSheet);
|
|
m_title.Dlg2Obj(pSheet);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CSheetProp, CPropertySheet)
|
|
|
|
//add by whl
|
|
ON_COMMAND_RANGE(ID_EDIT_ALL, ID_EDIT_COL, OnEdit)
|
|
ON_COMMAND(IDCANCEL,OnCancel)
|
|
ON_COMMAND(IDOK,OnOK)
|
|
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
|
|
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)
|
|
|
|
//{{AFX_MSG_MAP(CSheetProp)
|
|
ON_WM_DESTROY()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSheetProp message handlers
|
|
|
|
BOOL CSheetProp::OnInitDialog()
|
|
{
|
|
BOOL bResult = CPropertySheet::OnInitDialog();
|
|
|
|
//add by whl
|
|
CRect rect;
|
|
GetWindowRect(&rect);
|
|
rect.right+=82;
|
|
rect.bottom-=28;
|
|
SetWindowPos(NULL,rect.left,rect.top,rect.Width(),rect.Height(),0);
|
|
m_toolbar.Create(this);
|
|
m_toolbar.LoadToolBar(IDR_TOOLBAR_SHEET);
|
|
m_toolbar.ShowWindow(SW_SHOW);
|
|
m_toolbar.SetBarStyle(CBRS_ALIGN_RIGHT| CBRS_FLYBY );
|
|
GetClientRect(&rect);
|
|
rect.top+=25;
|
|
rect.right-=4;
|
|
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0,reposDefault,0 ,&rect);
|
|
GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
|
|
|
|
// TODO: Add your specialized code here
|
|
SetActivePage(g_nActivePage);
|
|
|
|
return bResult;
|
|
}
|
|
|
|
|
|
void CSheetProp::OnDestroy()
|
|
{
|
|
CPropertySheet::OnDestroy();
|
|
g_nActivePage=GetActiveIndex();
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSheetProp::PostNcDestroy()
|
|
{
|
|
// TODO: Add your specialized code here and/or call the base class
|
|
CPropertySheet::PostNcDestroy();
|
|
}
|
|
|
|
|
|
//add by whl begin
|
|
void CSheetProp::OnEdit(UINT nID)
|
|
{
|
|
PressButton(PSBTN_APPLYNOW);
|
|
EndDialog(nID);
|
|
}
|
|
void CSheetProp::OnOK()
|
|
{
|
|
PressButton(PSBTN_APPLYNOW);
|
|
EndDialog(IDOK);
|
|
}
|
|
void CSheetProp::OnCancel()
|
|
{
|
|
EndDialog(IDCANCEL);
|
|
}
|
|
|
|
BOOL CSheetProp::OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
ASSERT(pNMHDR->code == TTN_NEEDTEXTA || pNMHDR->code == TTN_NEEDTEXTW);
|
|
|
|
// if there is a top level routing frame then let it handle the message
|
|
if (GetRoutingFrame() != NULL) return FALSE;
|
|
|
|
// to be thorough we will need to handle UNICODE versions of the message also !!
|
|
TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
|
|
TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
|
|
//TCHAR szFullText[512];
|
|
CString strTipText;
|
|
// Zyu modify on 100726,去掉编译警告
|
|
//UINT nID = pNMHDR->idFrom;
|
|
UINT nID = (UINT)pNMHDR->idFrom;
|
|
|
|
if (pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) ||
|
|
pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND))
|
|
{
|
|
// idFrom is actually the HWND of the tool
|
|
//nID = ::GetDlgCtrlID((HWND)nID);
|
|
return FALSE; // shen rui add 对话框控件不显示
|
|
}
|
|
|
|
if (nID != 0) // will be zero on a separator
|
|
{
|
|
//LoadString(AfxGetResourceHandle(), nID, szFullText, 8);
|
|
//strTipText=szFullText;
|
|
CTemporaryResourceOverride vTmp;
|
|
strTipText.LoadString(nID); //=szFullText;
|
|
|
|
#ifndef _UNICODE
|
|
if (pNMHDR->code == TTN_NEEDTEXTA)
|
|
{
|
|
lstrcpyn(pTTTA->szText, strTipText, sizeof(pTTTA->szText));
|
|
}
|
|
else
|
|
{
|
|
_mbstowcsz(pTTTW->szText, strTipText, sizeof(pTTTW->szText));
|
|
}
|
|
#else
|
|
if (pNMHDR->code == TTN_NEEDTEXTA)
|
|
{
|
|
_wcstombsz(pTTTA->szText, strTipText,sizeof(pTTTA->szText));
|
|
}
|
|
else
|
|
{
|
|
lstrcpyn(pTTTW->szText, strTipText, sizeof(pTTTW->szText));
|
|
}
|
|
#endif
|
|
// bring the tooltip window above other popup windows
|
|
::SetWindowPos(pNMHDR->hwndFrom, HWND_TOP, 0, 0, 0, 0,SWP_NOACTIVATE|
|
|
SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER); return TRUE;
|
|
}
|
|
return TRUE;
|
|
}
|