//鼠标移动,移动对象 void CGuiderView::OnMouseMove(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 CGuiderDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; CDC*pDC=this->GetDC (); int i=0;//判断鼠标位置 if(this->WhetherOnPoint (point.x ,point.y )!=0) //点 i=1; else if(this->WhetherOnRoad (point.x ,point.y )) //边 i=2; /////////////////////////////////////////////////////////////////////////// int sp=sitelist.OnSite(point.x,point.y); Site * s=sitelist.GetOfID(sp); Route *rp=routelist.OnRoute(point.x,point.y); if(i==0) { if(sp!=0) i=3;//是地点 if(rp!=NULL) i=4;//是路径 } ///////////////////////////////////////////////////////////// //...........................................................修改状态栏-方案2-成功 CString str,str1; switch(i) { case 0:str1.Format (L"新建地点...");break; case 1:str1.Format (L"路口");break; case 2:str1.Format (L"路 长度:%d",(int)this->length );break; case 3:str1.Format(L"%s",s->SiteInfo);break; case 4: double l=rp->Length(); l*=2.287; str1.Format(L"%s 长度:%d",rp->RouteInfo,int(l));break; } str.Format (L"%d - %d %s",point.x ,point.y,str1); CStatusBar * pStatus=(CStatusBar*)AfxGetApp()->m_pMainWnd->GetDescendantWindow (ID_VIEW_STATUS_BAR); pStatus->SetPaneText (0,str); ////////////////////////////////////////////////////////////// if(App_Veriable::LBDown==true&&App_Veriable::IsAddingRoute==false)//添加路径不要移动,防止误删!!! { int i=routelist.RemoveRoutesOfSite(App_Veriable::SelectedSiteID);//删除周围路径 if(i!=0)//既保证了移动之前的全屏刷新,又避免了无条件的Move刷新! Invalidate(); //////////////////////////////////////////////删除一起系列的边的时候的处理方法//////////////////////////// CGuiderDoc* pDoc = GetDocument(); pDoc->graph_doc.removev(App_Veriable::SelectedSiteID);//删除点和周围的路径 pDoc->graph_doc.insertv(App_Veriable::SelectedSiteID);//恢复删除的点 Site*s=sitelist.GetOfID(App_Veriable::SelectedSiteID);//找鼠标按下的地点对象 s->Position=point; //Invalidate(); CRect rectOld(App_Veriable::LastMovePoint .x -s->Size ,App_Veriable::LastMovePoint .y -s->Size ,App_Veriable::LastMovePoint .x +s->Size ,App_Veriable::LastMovePoint .y +s->Size ); this->InvalidateRect (rectOld); App_Veriable::LastMovePoint =point; CRect rectNew(App_Veriable::LastMovePoint .x -s->Size,App_Veriable::LastMovePoint .y -s->Size ,App_Veriable::LastMovePoint .x +s->Size,App_Veriable::LastMovePoint .y +s->Size); this->InvalidateRect (rectOld); } ReleaseDC(pDC); CView::OnMouseMove(nFlags, point); }
int CXTPDockBar::_AdjustRow(CToolBarArray& arrRow, CPoint pt, int nLength, BOOL bHorz, AFX_SIZEPARENTPARAMS* lpLayout, int& nRemove) { CDockInfoArray arrInfo; int nPos; // Step 1. Getting maximum available size; for (nPos = 0; nPos < arrRow.GetSize(); nPos++) { CXTPToolBar* pBar = arrRow[nPos]; CSize sizeBar = pBar->CalcDockingLayout(nLength, _GetMode(bHorz, pBar)); CPoint p = bHorz ? CPoint(pBar->m_pDockContext->m_rectMRUDockPos.left, pt.y) : CPoint(pt.x, pBar->m_pDockContext->m_rectMRUDockPos.top); DOCK_INFO dockInfo(pBar, CRect(p, sizeBar), nPos); arrInfo.Add(dockInfo); } ASSERT(arrInfo.GetSize() == arrRow.GetSize()); if (!bHorz) arrInfo.InvertRects(); arrInfo.Sort(); // Step 2. if Total length is more than available, fill empty area. int nIndex = -1; int nLen = 0; BOOL bMove = TRUE; for (nPos = 0; nPos < arrInfo.GetSize(); nPos++) { CRect& rect = arrInfo[nPos].rcBar; bMove = (rect.left < nLen && (nIndex < arrInfo[nPos].nIndex || bMove)); if (bMove) rect.OffsetRect(nLen - rect.left, 0); nLen = rect.right; nIndex = arrInfo[nPos].nIndex; } nLen = nLength; nIndex = -1; bMove = TRUE; for (nPos = (int)arrInfo.GetSize() - 1; nPos >= 0; nPos--) { CRect& rect = arrInfo[nPos].rcBar; bMove = (rect.right - nLen > 0 && (nIndex < arrInfo[nPos].nIndex || bMove)); if (bMove) rect.OffsetRect(nLen - rect.right, 0); nLen = rect.left; nIndex = arrInfo[nPos].nIndex; } nLen = 0; for (nPos = 0; nPos < arrInfo.GetSize(); nPos++) { CRect& rect = arrInfo[nPos].rcBar; if (rect.left < nLen) rect.OffsetRect(nLen - rect.left, 0); nLen = rect.left + rect.Width(); } // Step 3. if Total length is more than available, make it expandable. if (nLen > nLength) { int nSum = 0; for (nPos = 0; nPos < arrInfo.GetSize(); nPos++) { CXTPToolBar* pBar = arrInfo[nPos].pBar; if (!(_GetMode(bHorz, pBar) & LM_HIDEWRAP)) arrInfo[nPos].nMinWidth = nLength; else { CSize sz = pBar->CalcDockingLayout(1, _GetMode(bHorz, pBar)); arrInfo[nPos].nMinWidth = bHorz ? sz.cx : sz.cy; } arrInfo[nPos].nTotlaMinWidth = nSum; nSum += arrInfo[nPos].nMinWidth; } nLen = nLength; for (nPos = (int)arrInfo.GetSize() - 1; nPos >= 0; nPos--) { CRect& rect = arrInfo[nPos].rcBar; int nLeft = bHorz ? arrInfo[nPos].rcMRUPos.left : arrInfo[nPos].rcMRUPos.top; if (nLeft > rect.left) nLeft = rect.left; if (nLeft < nLen - rect.Width()) nLeft = nLen - rect.Width(); if (nLeft < arrInfo[nPos].nTotlaMinWidth) nLeft = arrInfo[nPos].nTotlaMinWidth; if (nLen - nLeft < arrInfo[nPos].nMinWidth) nLeft = nLen - arrInfo[nPos].nMinWidth; if ((nLen - nLeft < arrInfo[nPos].nMinWidth || nLeft < arrInfo[nPos].nTotlaMinWidth) && arrInfo.GetSize() != 1) { nRemove = arrInfo[arrInfo.GetSize() - 1].nIndex; return -1; } rect.right = nLen; nLen = rect.left = max(0, nLeft); } } if (!bHorz) arrInfo.InvertRects(); int nWidth = 0; // Calculate total width for (nPos = 0; nPos < arrInfo.GetSize(); nPos++) { CXTPToolBar* pBar = arrInfo[nPos].pBar; CRect& rect = arrInfo[nPos].rcBar; CSize sizeBar = pBar->CalcDockingLayout(bHorz ? rect.Width() : rect.Height(), _GetMode(bHorz, pBar)); nWidth = max(nWidth, bHorz ? sizeBar.cy : sizeBar.cx); } if (lpLayout->hDWP == 0) return nWidth; // Step 4. Move it. for (nPos = 0; nPos < arrInfo.GetSize(); nPos++) { CXTPToolBar* pBar = arrInfo[nPos].pBar; CRect& rect = arrInfo[nPos].rcBar; int nMode = _GetMode(bHorz, pBar) | LM_COMMIT; if (pBar->GetFlags() & xtpFlagStretchedShared) { if (bHorz) { rect.right = nPos == arrInfo.GetSize() - 1 ? nLength : arrInfo[nPos + 1].rcBar.left; rect.left = nPos == 0 ? 0 : min(arrInfo[nPos - 1].rcBar.right, rect.left); } else { rect.bottom = nPos == arrInfo.GetSize() - 1 ? nLength : arrInfo[nPos + 1].rcBar.top; rect.top = nPos == 0 ? 0 : min(arrInfo[nPos - 1].rcBar.bottom, rect.top); } nMode |= LM_STRETCH; } CSize sz = pBar->CalcDockingLayout(bHorz ? rect.Width() : rect.Height(), nMode, nWidth); rect = CRect(rect.TopLeft(), sz); pBar->m_pDockContext->m_uMRUDockPosition = GetPosition(); CXTPWindowRect rectOld(pBar); ScreenToClient(&rectOld); if (!::EqualRect(rectOld, rect)) { AfxRepositionWindow(lpLayout, pBar->m_hWnd, &rect); pBar->Redraw(); } } return nWidth; }