| ÎļþÃû´Ó SourceCode/Bond/BondEq/AxisSettingsDlg.cpp ÐÞ¸Ä |
| | |
| | | CDialogEx::DoDataExchange(pDX); |
| | | } |
| | | |
| | | CFont* CAxisSettingsDlg::GetOrCreateFont(int nFontSize) |
| | | { |
| | | auto it = m_mapFonts.find(nFontSize); |
| | | if (it != m_mapFonts.end()) { |
| | | return it->second; |
| | | } |
| | | |
| | | CFont* font = new CFont(); |
| | | LOGFONT logFont = { 0 }; |
| | | _tcscpy_s(logFont.lfFaceName, _T("Segoe UI")); |
| | | logFont.lfHeight = -nFontSize; |
| | | logFont.lfQuality = CLEARTYPE_QUALITY; |
| | | font->CreateFontIndirect(&logFont); |
| | | m_mapFonts[nFontSize] = font; |
| | | |
| | | return font; |
| | | } |
| | | |
| | | void CAxisSettingsDlg::SetDefaultFont() |
| | | { |
| | | CFont* defaultFont = nullptr; |
| | | |
| | | // 妿åä½ç®¡ç容å¨ä¸æé»è®¤å¤§å°ï¼å¦ 12ï¼çåä½ï¼ç´æ¥ä½¿ç¨ |
| | | auto it = m_mapFonts.find(12); |
| | | if (it != m_mapFonts.end()) { |
| | | defaultFont = it->second; |
| | | } |
| | | else { |
| | | // å建é»è®¤åä½ |
| | | defaultFont = new CFont(); |
| | | LOGFONT logFont = { 0 }; |
| | | _tcscpy_s(logFont.lfFaceName, _T("Segoe UI")); |
| | | logFont.lfHeight = -12; |
| | | logFont.lfQuality = CLEARTYPE_QUALITY; |
| | | defaultFont->CreateFontIndirect(&logFont); |
| | | m_mapFonts[12] = defaultFont; // åå¨å°åä½ç®¡çå®¹å¨ |
| | | } |
| | | CFont* defaultFont = GetOrCreateFont(12); |
| | | |
| | | // éåæææ§ä»¶ï¼åºç¨é»è®¤åä½ |
| | | CWnd* pWnd = GetWindow(GW_CHILD); |
| | |
| | | } |
| | | } |
| | | |
| | | void CAxisSettingsDlg::AdjustControls(int nWidth, int nHeight) |
| | | void CAxisSettingsDlg::AdjustControls(float dScaleX, float dScaleY) |
| | | { |
| | | CWnd* pWnd = GetWindow(GW_CHILD); |
| | | while (pWnd) { |
| | | UINT nCtrlID = pWnd->GetDlgCtrlID(); |
| | | int nCtrlID = pWnd->GetDlgCtrlID(); |
| | | if (nCtrlID != -1 && m_mapCtrlLayouts.find(nCtrlID) != m_mapCtrlLayouts.end()) |
| | | { |
| | | CRect originalRect = m_mapCtrlLayouts[nCtrlID]; |
| | | CRect newRect( |
| | | static_cast<int>(originalRect.left * dScaleX), |
| | | static_cast<int>(originalRect.top * dScaleY), |
| | | static_cast<int>(originalRect.right * dScaleX), |
| | | static_cast<int>(originalRect.bottom * dScaleY)); |
| | | |
| | | CRect ctrlRect; |
| | | pWnd->GetWindowRect(&ctrlRect); |
| | | ScreenToClient(&ctrlRect); |
| | | TCHAR szClassName[256]; |
| | | GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName)); |
| | | |
| | | // è®¡ç®æ§ä»¶çæ°ä½ç½®å大å°ï¼ææ¯ä¾è°æ´ |
| | | int newX = (int)(ctrlRect.left * (nWidth / (float)m_nInitialWidth)); |
| | | int newY = (int)(ctrlRect.top * (nHeight / (float)m_nInitialHeight)); |
| | | int newWidth = (int)(ctrlRect.Width() * (nWidth / (float)m_nInitialWidth)); |
| | | int newHeight = (int)(ctrlRect.Height() * (nHeight / (float)m_nInitialHeight)); |
| | | if (_tcsicmp(szClassName, _T("ComboBox")) == 0) { |
| | | CComboBox* pComboBox = (CComboBox*)pWnd; |
| | | pComboBox->SetItemHeight(-1, newRect.Height()); // -1 表示ææé¡¹çé«åº¦ |
| | | } |
| | | |
| | | TCHAR szClassName[256]; |
| | | GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName)); |
| | | |
| | | if (_tcsicmp(szClassName, _T("ComboBox")) == 0) { |
| | | CComboBox* pComboBox = (CComboBox*)pWnd; |
| | | pComboBox->SetItemHeight(-1, nHeight); // -1 表示ææé¡¹çé«åº¦ |
| | | pWnd->MoveWindow(&newRect); |
| | | AdjustControlFont(pWnd, newRect.Width(), newRect.Height()); |
| | | } |
| | | |
| | | pWnd->MoveWindow(newX, newY, newWidth, newHeight); |
| | | AdjustControlFont(pWnd, newWidth, newHeight); |
| | | |
| | | // è·åä¸ä¸ä¸ªæ§ä»¶ |
| | | pWnd = pWnd->GetNextWindow(); |
| | | } |
| | | } |
| | |
| | | int fontSize = nHeight / 2; |
| | | if (fontSize < 8) fontSize = 8; |
| | | |
| | | // æ£æ¥å使¯å¦å·²ç»åå¨ |
| | | auto it = m_mapFonts.find(fontSize); |
| | | if (it == m_mapFonts.end()) { |
| | | // 卿å建æ°åä½ |
| | | CFont* newFont = new CFont(); |
| | | LOGFONT logFont = { 0 }; |
| | | _tcscpy_s(logFont.lfFaceName, _T("Segoe UI")); |
| | | logFont.lfHeight = -fontSize; |
| | | logFont.lfQuality = CLEARTYPE_QUALITY; // å¯ç¨ ClearType æé¯é½¿ |
| | | newFont->CreateFontIndirect(&logFont); |
| | | // è·åæå建åä½ |
| | | CFont* pFont = GetOrCreateFont(fontSize); |
| | | |
| | | // åå¨å°åä½ç®¡ç容å¨ä¸ |
| | | m_mapFonts[fontSize] = newFont; |
| | | it = m_mapFonts.find(fontSize); |
| | | } |
| | | |
| | | pWnd->SetFont(it->second); |
| | | pWnd->SetFont(pFont); |
| | | pWnd->Invalidate(); // å·æ°æ§ä»¶æ¾ç¤º |
| | | } |
| | | |
| | |
| | | CDialogEx::OnInitDialog(); |
| | | |
| | | // TODO: 卿¤æ·»å é¢å¤çåå§å |
| | | //ModifyStyle(0, WS_THICKFRAME | WS_SIZEBOX); |
| | | |
| | | // 设置é»è®¤åä½ |
| | | SetDefaultFont(); |
| | | |
| | | CRect screenRect, dlgRect, clientRect; |
| | | GetClientRect(&clientRect); |
| | | m_nInitialWidth = clientRect.Width(); |
| | | m_nInitialHeight = clientRect.Height(); |
| | | |
| | | // åå§åé»è®¤åä½ |
| | | CFont* pDefaultFont = GetOrCreateFont(12); |
| | | |
| | | // éåææåæ§ä»¶ï¼è®°å½åå§ä½ç½®å¹¶è®¾ç½®é»è®¤åä½ |
| | | CWnd* pWnd = GetWindow(GW_CHILD); |
| | | while (pWnd) { |
| | | int nCtrlID = pWnd->GetDlgCtrlID(); |
| | | if (nCtrlID != -1) { |
| | | // è®°å½æ§ä»¶åå§å¸å± |
| | | CRect ctrlRect; |
| | | pWnd->GetWindowRect(&ctrlRect); |
| | | ScreenToClient(&ctrlRect); |
| | | m_mapCtrlLayouts[nCtrlID] = ctrlRect; |
| | | |
| | | // 设置é»è®¤åä½ |
| | | pWnd->SetFont(pDefaultFont); |
| | | } |
| | | pWnd = pWnd->GetNextWindow(); |
| | | } |
| | | |
| | | GetWindowRect(&dlgRect); |
| | | int dlgWidth = dlgRect.Width() * 2; |
| | | int dlgHeight = dlgRect.Height() * 2; |