📄 mltview.cpp
字号:
{ CScrollView::OnSize(nType, cx, cy); m_uClientWidth = cx; if (m_uUnitCountMax == 0) // there is nothing to draw m_uViewWidth = 0; else // allow horizontal scrolling when the unit width reduces to UNIT_WIDTH_MIN m_uViewWidth = __max ((cx - HORIZ_BORDER * 2) / m_uUnitCountMax, UNIT_WIDTH_MIN) * m_uUnitCountMax + HORIZ_BORDER * 2; SIZE sizeTotal; sizeTotal.cx = __max (m_uViewWidth, m_uClientWidth); if (CConfigTool::GetConfigToolDoc() == NULL) sizeTotal.cy = 0; else sizeTotal.cy = CConfigTool::GetConfigToolDoc()->MemoryMap.region_list.size () * REGION_SPACING + EXTERNAL_TEXT_BORDER * 2; SetScrollSizes (MM_TEXT, sizeTotal);}void CMLTView::CalcUnitCountMax (){ UINT uUnitCountMax = 0; UINT uUnitCount; list <mem_region>::iterator region; mem_map * pMemoryMap = & (CConfigTool::GetConfigToolDoc()->MemoryMap); for (region = pMemoryMap->region_list.begin (); region != pMemoryMap->region_list.end (); ++region) { uUnitCount = 0; for (list <mem_section_view>::iterator section_view = region->section_view_list.begin (); section_view != region->section_view_list.end (); ++section_view) uUnitCount += (section_view->section == NULL ? 1 : UNITS_PER_SECTION); if (uUnitCount > uUnitCountMax) uUnitCountMax = uUnitCount; } m_uUnitCountMax = uUnitCountMax;}BOOL CMLTView::OnEraseBkgnd(CDC* pDC) { // Work around bug apparently caused by SlickEdit CRect rcClient; pDC->GetClipBox(rcClient); pDC->FillSolidRect(rcClient,GetSysColor(COLOR_WINDOW)); return TRUE;//return CScrollView::OnEraseBkgnd(pDC);}BOOL CMLTView::OnToolTipText(UINT id, NMHDR* pNMHDR, LRESULT*pResult){ // need to handle both ANSI and UNICODE versions of the message TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR; TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR; id=pNMHDR->idFrom; if(id){ for(POSITION pos = m_arstrTooltipRects.GetStartPosition(); pos != NULL; ){ CRect *pRect; CString strTipText; m_arstrTooltipRects.GetNextAssoc( pos, strTipText, (void *&)pRect ); if((UINT)pRect==id){ #ifndef _UNICODE if (pNMHDR->code == TTN_NEEDTEXTA) lstrcpyn(pTTTA->szText, strTipText, sizeof pTTTA->szText/sizeof TCHAR - 1); else _mbstowcsz(pTTTW->szText, strTipText, sizeof pTTTW->szText/sizeof TCHAR - 1); #else if (pNMHDR->code == TTN_NEEDTEXTA) _wcstombsz(pTTTA->szText, strTipText, sizeof pTTTA->szText/sizeof TCHAR - 1); else lstrcpyn(pTTTW->szText, strTipText, sizeof pTTTW->szText/sizeof TCHAR - 1); #endif *pResult = 0; return TRUE; // message was handled } } } return FALSE;}int CMLTView::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const{ for(POSITION pos = m_arstrTooltipRects.GetStartPosition(); pos != NULL; ){ CRect *pRect; CString strName; m_arstrTooltipRects.GetNextAssoc( pos, strName, (void *&)pRect ); if(pRect->PtInRect(point)){ pTI->hwnd = m_hWnd; pTI->uId = (UINT)pRect; pTI->uFlags = 0 ; GetClientRect(&pTI->rect); pTI->lpszText=LPSTR_TEXTCALLBACK; return pTI->uId; } } return -1;}void CMLTView::OnInitialUpdate() { CScrollView::OnInitialUpdate(); EnableToolTips(true);}void CMLTView::OnMouseMove(UINT nFlags, CPoint point) {/* CString strToolTipText; for(POSITION pos = m_arstrTooltipRects.GetStartPosition(); pos != NULL; ){ CRect *pRect; CString strName; m_arstrTooltipRects.GetNextAssoc( pos, strName, (void *&)pRect ); if(pRect->PtInRect(point)){ strToolTipText=strName; break; } } if(strToolTipText!=m_strTipText){ _AFX_THREAD_STATE* pThreadState = AfxGetThreadState(); CToolTipCtrl* pToolTip = pThreadState->m_pToolTip; if(!m_strTipText.IsEmpty()){ pToolTip->Activate(false); } pToolTip->Activate(!strToolTipText.IsEmpty()); m_strTipText=strToolTipText; }*/ CScrollView::OnMouseMove(nFlags, point);}void CMLTView::OnMLTNewRegion (){ CConfigTool::GetConfigToolDoc ()->OnMLTNewRegion ();}void CMLTView::OnMLTNewSection (){ CConfigTool::GetConfigToolDoc ()->OnMLTNewSection ();}void CMLTView::OnMLTDelete (){ CConfigTool::GetConfigToolDoc ()->OnMLTDelete ();}void CMLTView::OnMLTProperties (){ CConfigTool::GetConfigToolDoc ()->OnMLTProperties ();}void CMLTView::OnUpdateMLTNewRegion (CCmdUI* pCmdUI){ pCmdUI->Enable (true);}void CMLTView::OnUpdateMLTNewSection (CCmdUI* pCmdUI){ pCmdUI->Enable (CConfigTool::GetConfigToolDoc()->MemoryMap.region_list.size() > 0);}void CMLTView::OnUpdateMLTDelete (CCmdUI* pCmdUI){ pCmdUI->Enable( (!CConfigTool::GetConfigToolDoc ()->strSelectedRegion.IsEmpty() || !CConfigTool::GetConfigToolDoc ()->strSelectedSection.IsEmpty()));}void CMLTView::OnUpdateMLTProperties (CCmdUI* pCmdUI){ pCmdUI->Enable( (!CConfigTool::GetConfigToolDoc ()->strSelectedRegion.IsEmpty() || !CConfigTool::GetConfigToolDoc ()->strSelectedSection.IsEmpty()));}void CMLTView::OnContextMenu(CWnd*, CPoint point) { CConfigToolDoc* pDoc = CConfigTool::GetConfigToolDoc(); if (!pDoc->strSelectedRegion.IsEmpty() || !pDoc->strSelectedSection.IsEmpty()){ if(point.x<0){ // Keyboard point=!pDoc->strSelectedRegion.IsEmpty()?m_rectSelectedItem.TopLeft():m_rectSelectedItem.CenterPoint(); ClientToScreen(&point); } Menu menu; menu.LoadMenu(IDR_MLTVIEW_POPUP); #ifndef PLUGIN menu.LoadToolbar(IDR_MISCBAR); #endif Menu *pPopup=(Menu *)menu.GetSubMenu(0); pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, point.x,point.y,this); }} void CMLTView::OnPopupProperties() { CConfigTool::GetConfigToolDoc()->OnMLTProperties ();}void CMLTView::OnRButtonDown(UINT nFlags, CPoint point) { OnLButtonDown(nFlags, point); ClientToScreen(&point); OnContextMenu(this, point) ;}void CMLTView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { POSITION pos; switch(nChar){ case VK_RIGHT: pos = listSectionRect.GetHeadPosition (); if(!CConfigTool::GetConfigToolDoc()->strSelectedSection.IsEmpty()){ while(NULL!=pos){ if (listSectionRect.GetNext (pos).SectionView==m_sviSelectedSectionView){ if(NULL==pos){ pos=listSectionRect.GetHeadPosition(); } break; } } } OnLButtonDown(0, listSectionRect.GetNext(pos).Rect.CenterPoint()-GetScrollPosition()); break; case VK_LEFT: pos = listSectionRect.GetTailPosition (); if(!CConfigTool::GetConfigToolDoc()->strSelectedSection.IsEmpty()){ while(NULL!=pos){ if (listSectionRect.GetPrev (pos).SectionView==m_sviSelectedSectionView){ if(NULL==pos){ pos=listSectionRect.GetTailPosition(); } break; } } } OnLButtonDown(0, listSectionRect.GetPrev(pos).Rect.CenterPoint()-GetScrollPosition()); break; case VK_DOWN: pos = listRegionRect.GetHeadPosition (); if(!CConfigTool::GetConfigToolDoc()->strSelectedRegion.IsEmpty()){ while(NULL!=pos){ if (listRegionRect.GetNext (pos).Region==m_riSelectedRegion){ if(NULL==pos){ pos=listRegionRect.GetHeadPosition(); } break; } } } OnLButtonDown(0, listRegionRect.GetNext(pos).Rect.TopLeft()-CPoint(1,1)-GetScrollPosition()); break; case VK_UP: pos = listRegionRect.GetTailPosition (); if(!CConfigTool::GetConfigToolDoc()->strSelectedRegion.IsEmpty()){ while(NULL!=pos){ if (listRegionRect.GetPrev (pos).Region==m_riSelectedRegion){ if(NULL==pos){ pos=listRegionRect.GetTailPosition(); } break; } } } OnLButtonDown(0, listRegionRect.GetPrev(pos).Rect.TopLeft()-CPoint(1,1)-GetScrollPosition()); break; default: break; } CScrollView::OnKeyDown(nChar, nRepCnt, nFlags);}BOOL CMLTView::OnHelpInfo(HELPINFO*) { return CConfigTool::GetConfigToolDoc()->ShowURL(CUtils::LoadString(IDS_MLT_VIEW_HELP)); }LRESULT CMLTView::OnMenuChar(UINT, UINT, CMenu*) { const MSG *pMsg=GetCurrentMessage(); // punt to the mainframe to deal with shortcuts in popups return AfxGetMainWnd()->SendMessage(pMsg->message,pMsg->wParam,pMsg->lParam);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -