void CTrkObjList::GetBoundRectSel(LPRECT pRect) const { CRect ObjRect; CRect BoundRect; if ( GetCountSel() > 0 ) BoundRect = CRect(INT_MAX,INT_MAX,INT_MIN,INT_MIN); else BoundRect = CRect(0,0,0,0); POSITION Pos = GetHeadPosSel(); while (Pos != NULL) { CTrkObj* pObj = GetNextSel(Pos); pObj->GetRect(ObjRect); if (BoundRect.left > ObjRect.left) BoundRect.left = ObjRect.left; if (BoundRect.top > ObjRect.top) BoundRect.top = ObjRect.top; if (BoundRect.right < ObjRect.right) BoundRect.right = ObjRect.right; if (BoundRect.bottom < ObjRect.bottom) BoundRect.bottom = ObjRect.bottom; } *pRect = BoundRect; }
void CTrkObjList::OnCenter(int CenterMode,LPCRECT pRect, CWnd* pWnd,double Zoom,int UpdateMode) { CRect SelRect; GetBoundRectSel(SelRect); CPoint SelVal = GetCenterVal(CenterMode,SelRect); CPoint RectVal = GetCenterVal(CenterMode,pRect); CSize Off; Off.cx = RectVal.x - SelVal.x; Off.cy = RectVal.y - SelVal.y; CTrkObj* pObj; CRect NewPos; POSITION Pos = GetHeadPosSel(); while (Pos != NULL) { pObj = GetNextSel(Pos); NewPos = GetAlignPos(pObj,Off); pObj->Move(NewPos,pWnd,Zoom,UpdateMode); } }
int CTrkObjList::GetTakenSpace(int SameSpaceMode, CTrkObj* pFirstObj,CTrkObj* pLastObj) const { int TakenSpace = 0,Space; CTrkObj* pObj; CRect Rect; POSITION Pos = GetHeadPosSel(); while (Pos != NULL) { pObj = GetNextSel(Pos); if ( (pObj != pFirstObj) && (pObj != pLastObj) ) { pObj->GetRect(Rect); if (SameSpaceMode == SAME_SPACE_WIDTH) Space = Rect.right - Rect.left + 1; else Space = Rect.bottom - Rect.top + 1; TakenSpace = TakenSpace + Space; } } return(TakenSpace); }
void CTrkObjList::UnselectAll(CWnd* pWnd,double Zoom,int UpdateMode) { POSITION Pos = GetHeadPosSel(); while (Pos != NULL) { CTrkObj* pObj = GetNextSel(Pos); Unselect(pObj,pWnd,Zoom,UpdateMode); } }
CTrkObj* CTrkObjList::GetLastInPos(int SameSpaceMode) const { CTrkObj* pLastObj = NULL; CTrkObj* pObj; CRect Rect; int LastVal = INT_MIN,Val; POSITION Pos = GetHeadPosSel(); if (Pos != NULL) { pObj = GetNextSel(Pos); pObj->GetRect(Rect); if (SameSpaceMode == SAME_SPACE_WIDTH) LastVal = Rect.left; else LastVal = Rect.top; pLastObj = pObj; } while (Pos != NULL) { pObj = GetNextSel(Pos); pObj->GetRect(Rect); if (SameSpaceMode == SAME_SPACE_WIDTH) Val = Rect.left; else Val = Rect.top; if (Val >= LastVal) { LastVal = Val; pLastObj = pObj; } } return(pLastObj); }
void CTrkObjList::CopyToCB() { ClearCB(); POSITION Pos = GetHeadPosSel(); while (Pos != NULL) { CTrkObj* pObj = GetNextSel(Pos); CTrkObj* pClone = pObj->SetupClone(); AddCB(pClone); } }
void CTrkObjList::OffsetSelObjs(SIZE Off,CWnd* pWnd,double Zoom, int UpdateMode) { POSITION Pos = GetHeadPosSel(); while (Pos != NULL) { CTrkObj* pSelObj = GetNextSel(Pos); CRect NewPos; pSelObj->GetRect(NewPos); NewPos.left = NewPos.left + Off.cx; NewPos.top = NewPos.top + Off.cy; NewPos.right = NewPos.right + Off.cx; NewPos.bottom = NewPos.bottom + Off.cy; pSelObj->Move(NewPos,pWnd,Zoom,UpdateMode); } }
int CEnListCtrl::GetLastSel() const { int nIndexSel, nLastSel; nIndexSel = GetFirstSel(); if (nIndexSel == -1) return -1; do { nLastSel = nIndexSel; } while((nIndexSel = GetNextSel(nIndexSel)) != -1); return nLastSel; }
BOOL CTrkObjList::OnSetCursor(CWnd* pWnd,UINT HitTest, UINT Msg,double Zoom) const { BOOL Set = FALSE; POSITION Pos = GetHeadPosSel(); while (Pos != NULL) { CTrkObj* pObj = GetNextSel(Pos); Set = pObj->OnSetCursor(pWnd,HitTest,Msg,Zoom); if (Set) break; } return(Set); }
CTrkObj* CTrkObjList::GetNextInPos(int SameSpaceMode,CTrkObj* pRefObj) const { CTrkObj* pNextObj = NULL; CTrkObj* pObj; CRect Rect; int RefVal,ActVal = INT_MAX,Val; BOOL RefPassed = FALSE; pRefObj->GetRect(Rect); if (SameSpaceMode == SAME_SPACE_WIDTH) RefVal = Rect.left; else RefVal = Rect.top; POSITION Pos = GetHeadPosSel(); while (Pos != NULL) { pObj = GetNextSel(Pos); pObj->GetRect(Rect); if (SameSpaceMode == SAME_SPACE_WIDTH) Val = Rect.left; else Val = Rect.top; if ( (Val >= RefVal) && (Val < ActVal) ) { if (pObj == pRefObj) RefPassed = TRUE; else { if ( (Val > RefVal) || RefPassed ) { pNextObj = pObj; pNextObj->GetRect(Rect); if (SameSpaceMode == SAME_SPACE_WIDTH) ActVal = Rect.left; else ActVal = Rect.top; } } } } return(pNextObj); }
int CEnListCtrl::GetPrevSel(int nNextSel) const { ASSERT (nNextSel >= 0 && nNextSel <= GetItemCount()); int nIndexSel, nPrevSel; nIndexSel = GetFirstSel(); if (nIndexSel == -1) return -1; do { nPrevSel = nIndexSel; } while((nIndexSel = GetNextSel(nIndexSel)) != -1 && nIndexSel < nNextSel); return nPrevSel; }
void CTrkObjList::OnObjToBack() { CTrkObj* pSelObj; POSITION Pos = GetHeadPosSel(); if (Pos != NULL) pSelObj = GetNextSel(Pos); else goto End; Pos = m_List.Find(pSelObj); m_List.RemoveAt(Pos); m_List.AddHead(pSelObj); End:; }
void CTrkObjList::OnEditClear(CWnd* pWnd,double Zoom,int UpdateMode) { POSITION Pos = GetHeadPosSel(); while (Pos != NULL) { CTrkObj* pObj = GetNextSel(Pos); pObj->Update(UpdateMode,pWnd,Zoom); Remove(pObj); } RemoveAllSel(); Pos = GetHeadPos(); if (Pos != NULL) { CTrkObj* pObj = GetNext(Pos); Select(pObj,pWnd,Zoom,UpdateMode); } }
BOOL CTrkObjList::TrackSelObjs(POINT Point,UINT Flags,CWnd* pWnd,double Zoom, int UpdateMode) { BOOL Changed = FALSE; CMoveTrk MoveTrk; POSITION Pos = GetHeadPosSel(); while (Pos != NULL) { CTrkObj* pObj = GetNextSel(Pos); CRect Rect; pObj->GetRect(Rect); MoveTrk.Add(Rect); } SetMoveTrkDefaults(&MoveTrk); CRect OldRect; MoveTrk.GetRect(OldRect); Changed = MoveTrk.TrackMove(Point,Flags,pWnd,Zoom); if (Changed) { CRect NewRect; MoveTrk.GetRect(NewRect); CSize Off; Off.cx = NewRect.left - OldRect.left; Off.cy = NewRect.top - OldRect.top; OffsetSelObjs(Off,pWnd,Zoom,UpdateMode); } return(Changed); }