// //------------------------------------------------------------------------ //文件名: MyPropertyPage.cpp : implementation file // 创建人: cwk // 日 期: // 描 述: // 版 本: // 修改人: // 修改日期: // 修改目的: //------------------------------------------------------------------------- #include "stdafx.h" #include "FontPropertyPage.h" #include "InPlaceEdit.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif //extern void HideTabBar(BOOL bTrue); extern TARCH_IMPEXP BOOL g_bDwgTabBar,g_bZoomKey,g_nRBtnMenuTime,g_nSpeedMenu; extern TARCH_IMPEXP void SaveGlobalToReg(); ///////////////////////////////////////////////////////////////////////////// // CFontPropertyPage property page CString CFontPropertyPage::m_str = _T("上华软件Tangent Software"); //modified by fxj 081229 IMPLEMENT_DYNCREATE(CFontPropertyPage, CAcUiTabChildDialog) CFontPropertyPage::CFontPropertyPage(CWnd* pParent) : CAcUiTabChildDialog(pParent) { //{{AFX_DATA_INIT(CFontPropertyPage) //add by fxj 081229 m_bChecked = FALSE; // m_nRClick = -1; // m_bShortcutMenu = FALSE; m_bDwgTabBar=g_bDwgTabBar; // m_bZoomKey=g_bZoomKey; // m_nMenuTime=g_nRBtnMenuTime; // m_nRClick = g_nSpeedMenu-1; // m_bShortcutMenu = (g_nSpeedMenu!=0); //}}AFX_DATA_INIT } CFontPropertyPage::~CFontPropertyPage() { } void CFontPropertyPage::DoDataExchange(CDataExchange* pDX) { CAcUiTabChildDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CFontPropertyPage) DDX_Control(pDX, IDC_EDIT_FONTCOL, m_cFontCol); DDX_Control(pDX, IDC_SPIN, m_cSpin); DDX_Control(pDX, IDC_EDIT_BKCOL, m_cBkCol); DDX_Control(pDX, IDC_EDIT_PREVIEW, m_cEdit); DDX_Text(pDX, IDC_EDIT_FONTHEIGHT, m_cFontHeight); //add by fxj 081229 // DDX_Radio(pDX, IDC_RCLICK, m_nRClick); // DDX_Check(pDX, IDC_SHORTCUT_MENU, m_bShortcutMenu); DDX_Check(pDX, IDC_DWG_TABBAR, m_bDwgTabBar); // DDX_Check(pDX, IDC_ZOOM_KEY, m_bZoomKey); // DDX_Text(pDX, IDC_MENU_TIME, m_nMenuTime); // DDV_MinMaxUInt(pDX, m_nMenuTime, 0, 5000); //if (!pDX->m_bSaveAndValidate) //{ // GetDlgItem(IDC_RCLICK)->EnableWindow(m_bShortcutMenu); // GetDlgItem(IDC_CTRL_RCLICK)->EnableWindow(m_bShortcutMenu); // GetDlgItem(IDC_SLOW_RCLICK)->EnableWindow(m_bShortcutMenu); // GetDlgItem(IDC_MENU_TIME)->EnableWindow(m_bShortcutMenu&&m_nRClick==2); //} //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CFontPropertyPage, CAcUiTabChildDialog) //{{AFX_MSG_MAP(CFontPropertyPage) ON_BN_CLICKED(IDC_BUTTON_SET_FONTCOL, OnSetFontColour) ON_BN_CLICKED(IDC_BUTTON_BKCOL, OnBkcolour) ON_EN_CHANGE(IDC_EDIT_FONTHEIGHT, OnChangeEditFontheight) //add by fxj 080925 // ON_BN_CLICKED(IDC_SHORTCUT_MENU, OnShortcutMenu) // ON_BN_CLICKED(IDC_RCLICK, OnBnClickedRclick) // ON_BN_CLICKED(IDC_CTRL_RCLICK, OnBnClickedCtrlRclick) // ON_BN_CLICKED(IDC_SLOW_RCLICK, OnBnClickedSlowRclick) ON_MESSAGE(TARCH_SETTING_MSG_UPDATA,OnReUpdataDlg) //}}AFX_MSG_MAP // ON_BN_CLICKED(IDC_ZOOM_KEY, CFontPropertyPage::OnBnClickedZoomKey) ON_BN_CLICKED(IDC_DWG_TABBAR, CFontPropertyPage::OnBnClickedDwgTabbar) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CFontPropertyPage message handlers BOOL CFontPropertyPage::ReadIni() { XString sFullFile; if (!FindFile(_T("tch.ini"), sFullFile)) { AfxMessageBox(_T("\n找不到'tch.ini'文件!")); return FALSE; } // 是否显示启动选择CAD平台的界面,1表示显示,0表示不显示 int nTmp = GetPrivateProfileInt(_T("Startup"), _T("ShowStartDlg"), 1, sFullFile); if (nTmp == 0) { m_bShow = FALSE; } else { m_bShow = TRUE; } CButton *pBtn = (CButton*)GetDlgItem(IDC_INIT_SHOW); if (pBtn->GetSafeHwnd()) { pBtn->SetCheck(m_bShow); return TRUE; } return FALSE; } BOOL CFontPropertyPage::WriteIni() { XString sFullFile; if (!FindFile(_T("tch.ini"), sFullFile)) { AfxMessageBox(_T("\n找不到'tch.ini'文件!")); return FALSE; } CButton *pBtn = (CButton*)GetDlgItem(IDC_INIT_SHOW); if (pBtn->GetSafeHwnd()) { //pBtn->SetCheck(m_bShow); m_bShow = pBtn->GetCheck(); CString strValue; strValue = m_bShow?_T("1"):_T("0"); WritePrivateProfileString(_T("Startup"), _T("ShowStartDlg"),strValue,sFullFile); return TRUE; } return FALSE; } LRESULT CFontPropertyPage::OnReUpdataDlg(WPARAM w,LPARAM l) { // m_nRClick = -1; // m_bShortcutMenu = FALSE; m_bDwgTabBar=g_bDwgTabBar; // m_bZoomKey=g_bZoomKey; // m_nMenuTime=g_nRBtnMenuTime; // m_nRClick = g_nSpeedMenu-1; // m_bShortcutMenu = (g_nSpeedMenu!=0); UpdateData(FALSE); UpdataGlobal(); WriteIni(); return 0; } void CFontPropertyPage::UpdataGlobal() { UpdateData(FALSE); if (g_bDwgTabBar!=m_bDwgTabBar) { m_bDwgTabBar=g_bDwgTabBar; //HideTabBar(!g_bDwgTabBar); } m_cEdit.m_colorInPlaceText = g_colorInPlaceText; m_cFontCol.m_colorInPlaceText = g_colorInPlaceText; m_cEdit.m_colorInPlaceGround =g_colorInPlaceGround ; m_cBkCol.m_colorInPlaceGround = g_colorInPlaceGround; m_cFontCol.SetWindowText(_T("")); m_cEdit.SetWindowText(m_str); m_cBkCol.SetWindowText(_T("")); m_cEdit.SetWindowText(m_str); m_cFontHeight= g_iInPlaceFontHeight; UpdateData(FALSE); } LRESULT CFontPropertyPage::OnReOK(WPARAM w,LPARAM l) { OnOK(); return 0; } void CFontPropertyPage::OnSetFontColour() { // TODO: Add your control notification handler code here CColorDialog m_Dlg; if (m_Dlg.DoModal() == IDOK) { m_cEdit.m_colorInPlaceText = m_Dlg.GetColor(); m_cFontCol.m_colorInPlaceText = m_Dlg.GetColor(); m_cFontCol.SetWindowText(_T("")); m_cEdit.SetWindowText(m_str); GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION); m_bChecked = TRUE; } } void CFontPropertyPage::OnBkcolour() { // TODO: Add your control notification handler code here CColorDialog m_Dlg; if (m_Dlg.DoModal() == IDOK) { m_cEdit.m_colorInPlaceGround = m_Dlg.GetColor(); m_cBkCol.m_colorInPlaceGround = m_Dlg.GetColor(); m_cBkCol.SetWindowText(_T("")); m_cEdit.SetWindowText(m_str); GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION); m_bChecked = TRUE; } } void CFontPropertyPage::OnChangeEditFontheight() { int size=m_cFontHeight; //modify by xlc on 090106 解决字高退格后崩溃的问题 // CDataExchange dc(this,TRUE); // DDX_Text(&dc,IDC_EDIT_FONTHEIGHT,m_cFontHeight); UpdateData(); if (m_cFontHeight>0 && m_cFontHeight <41) { m_cEdit.m_iInPlaceFontHeight = m_cFontHeight; m_cEdit.SetHeight(); } else { m_cFontHeight = size; UpdateData(FALSE); } GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION); m_bChecked = TRUE; } BOOL CFontPropertyPage::OnInitDialog() { CAcUiTabChildDialog::OnInitDialog(); m_cBkCol.EnableWindow(FALSE); m_cFontCol.EnableWindow(FALSE); m_cEdit.Init(); m_cEdit.SetWindowText(m_str); //add by whl m_cEdit.SetHeight(); m_cSpin.SetBuddy(GetDlgItem(IDC_EDIT_FONTHEIGHT)); //modify by xlc on 070808 //m_cSpin.SetRange(12,40); m_cSpin.SetRange(1,40); m_cFontHeight = m_cEdit.m_iInPlaceFontHeight; m_cEdit.m_colorInPlaceText = g_colorInPlaceText; m_cFontCol.m_colorInPlaceText = g_colorInPlaceText; m_cEdit.m_colorInPlaceGround = g_colorInPlaceGround; m_cBkCol.m_colorInPlaceGround = g_colorInPlaceGround; m_cFontCol.SetWindowText(_T("")); m_cEdit.SetWindowText(m_str); m_cBkCol.SetWindowText(_T("")); m_cEdit.SetWindowText(m_str); m_cFontHeight = g_iInPlaceFontHeight; ReadIni(); UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } //add by fxj 080925 //void CFontPropertyPage::OnShortcutMenu() //{ // m_bShortcutMenu=!m_bShortcutMenu; // m_nRClick = m_bShortcutMenu-1; // GetDlgItem(IDC_RCLICK)->EnableWindow(m_bShortcutMenu); // GetDlgItem(IDC_CTRL_RCLICK)->EnableWindow(m_bShortcutMenu); // GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION); // UpdateData(FALSE); // m_bChecked = TRUE; //} //void CFontPropertyPage::OnBnClickedRclick() //{ // UpdateData(); // UpdateData(FALSE); // GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION); // m_bChecked = TRUE; //} // //void CFontPropertyPage::OnBnClickedCtrlRclick() //{ // UpdateData(); // UpdateData(FALSE); // GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION); // m_bChecked = TRUE; //} //void CFontPropertyPage::OnBnClickedSlowRclick() //{ // UpdateData(); // UpdateData(FALSE); // GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION); // m_bChecked = TRUE; //} void CFontPropertyPage::ApplySet() { UpdateData(TRUE); if (g_bDwgTabBar!=m_bDwgTabBar) { g_bDwgTabBar=m_bDwgTabBar; //HideTabBar(!g_bDwgTabBar); } g_colorInPlaceText = m_cEdit.m_colorInPlaceText; g_colorInPlaceText = m_cFontCol.m_colorInPlaceText; g_colorInPlaceGround = m_cEdit.m_colorInPlaceGround; g_colorInPlaceGround = m_cBkCol.m_colorInPlaceGround; m_cFontCol.SetWindowText(_T("")); m_cEdit.SetWindowText(m_str); m_cBkCol.SetWindowText(_T("")); m_cEdit.SetWindowText(m_str); g_iInPlaceFontHeight = m_cFontHeight; WriteIni(); UpdateData(FALSE); } void CFontPropertyPage::OnOK() { CAcUiTabChildDialog::OnOK(); // if (!m_bShortcutMenu) g_nSpeedMenu=0; // else g_nSpeedMenu=m_nRClick+1; UpdateData(TRUE); if (g_bDwgTabBar!=m_bDwgTabBar) { g_bDwgTabBar=m_bDwgTabBar; //HideTabBar(!g_bDwgTabBar); } g_colorInPlaceText = m_cEdit.m_colorInPlaceText; g_colorInPlaceText = m_cFontCol.m_colorInPlaceText; g_colorInPlaceGround = m_cEdit.m_colorInPlaceGround; g_colorInPlaceGround = m_cBkCol.m_colorInPlaceGround; g_iInPlaceFontHeight = m_cFontHeight; WriteIni(); // g_bZoomKey=m_bZoomKey; // g_nRBtnMenuTime=m_nMenuTime; } void CFontPropertyPage::UpdateFontProperty(const Array& aryNodeInfo) { int nLen = aryNodeInfo.GetLength(); int i=0; for (i=0;i0) { CString strName = nodeInfo.m_aryNodeAttribute.GetAt(0).second; if (strName == _T("启用上华右键快捷菜单")) { int nIndex = GetIndex(nodeInfo); if (nIndex==0) { // m_bShortcutMenu = TRUE; } else if (nIndex == 1) { // m_bShortcutMenu = FALSE; } } else if (strName == _T("空选时右键状态")) { int nIndex = GetIndex(nodeInfo); // m_nRClick = nIndex; if (nIndex==2) { int nLen = strName.GetLength(); int nSubIndex = -1; int i=0; for (i=0;i=30&&strName.GetAt(i)<=39) { nSubIndex=i; break; } } if (nSubIndex!=-1) { // CString strNum = strName.Mid(nSubIndex,nLen-nSubIndex); //#ifdef UNICODE //m_nMenuTime = _wtoi(strNum); //#else //m_nMenuTime = atoi(strNum); //#endif } } } else if (strName==_T("启用放大缩小热键")) { //int nIndex = GetIndex(nodeInfo); //if (nIndex==0) //{ // m_bZoomKey = TRUE; //} //else if (nIndex == 1) //{ // m_bZoomKey = FALSE; //} } else if (strName==_T("启用文档标签")) { int nIndex = GetIndex(nodeInfo); if (nIndex==0) { m_bDwgTabBar = TRUE; } else if (nIndex == 1) { m_bDwgTabBar = FALSE; } } else if (strName==_T("字体颜色")) { m_cFontCol.SetWindowText(nodeInfo.m_strNodeValue); } else if (strName==_T("背景颜色")) { m_cBkCol.SetWindowText(nodeInfo.m_strNodeValue); } else if (strName==_T("字体高度")) { #ifdef UNICODE m_cFontHeight = _wtoi(nodeInfo.m_strNodeValue); #else m_cFontHeight = atoi(nodeInfo.m_strNodeValue); #endif } } } int CFontPropertyPage::GetIndex(const CXMLNodeInfoEx &data) { int nIndex = -1; NodeAttriButeAry aryNodeAttribute = data.m_aryNodeAttribute; NodeAttriBute attriBute; int nLen = aryNodeAttribute.GetLength(); int i=0; BOOL bFind = FALSE; for (;iSendMessage(TARCH_SETTING_MSG_BUTTONSTATION); // m_bChecked = TRUE; //} void CFontPropertyPage::OnBnClickedDwgTabbar() { GetParent()->SendMessage(TARCH_SETTING_MSG_BUTTONSTATION); m_bChecked = TRUE; }