void wxSFMultiSelRect::OnTopHandle(wxSFShapeHandle& handle) { if(GetParentCanvas() && !AnyHeightExceeded(wxPoint(0, -handle.GetDelta().y))) { wxXS::RealPointList::compatibility_iterator ptnode; wxSFLineShape* pLine; wxRealPoint* pt; double dy, sy = (GetRectSize().y - 2*sfDEFAULT_ME_OFFSET - handle.GetDelta().y)/(GetRectSize().y - 2*sfDEFAULT_ME_OFFSET); ShapeList m_lstSelection; GetParentCanvas()->GetSelectedShapes(m_lstSelection); ShapeList::compatibility_iterator node = m_lstSelection.GetFirst(); while(node) { wxSFShapeBase* pShape = node->GetData(); if(!pShape->IsKindOf(CLASSINFO(wxSFLineShape))) { if(pShape->ContainsStyle(sfsPOSITION_CHANGE)) { if(pShape->GetParentShape()) { pShape->SetRelativePosition(pShape->GetRelativePosition().x, pShape->GetRelativePosition().y*sy); } else { double dy = handle.GetDelta().y - (pShape->GetAbsolutePosition().y - (GetAbsolutePosition().y + sfDEFAULT_ME_OFFSET))/(GetRectSize().y - 2*sfDEFAULT_ME_OFFSET)*handle.GetDelta().y; pShape->MoveBy(0, dy); } } if(pShape->ContainsStyle(sfsSIZE_CHANGE))pShape->Scale(1, sy, sfWITHCHILDREN); if( ! pShape->ContainsStyle( sfsNO_FIT_TO_CHILDREN ) ) pShape->FitToChildren(); } else { if(pShape->ContainsStyle(sfsPOSITION_CHANGE)) { pLine = (wxSFLineShape*)pShape; ptnode = pLine->GetControlPoints().GetFirst(); while(ptnode) { pt = ptnode->GetData(); dy = handle.GetDelta().y - (pt->y - (GetAbsolutePosition().y + sfDEFAULT_ME_OFFSET))/(GetRectSize().y - 2*sfDEFAULT_ME_OFFSET)*handle.GetDelta().y; pt->y += dy; pt->y = floor(pt->y); ptnode = ptnode->GetNext(); } } } node = node->GetNext(); } } }
void wxSFMultiSelRect::OnRightHandle(wxSFShapeHandle& handle) { if(GetParentCanvas() && !AnyWidthExceeded(handle.GetDelta())) { wxXS::RealPointList::compatibility_iterator ptnode; wxSFLineShape* pLine; wxRealPoint* pt; double dx, sx = (GetRectSize().x - 2*sfDEFAULT_ME_OFFSET + handle.GetDelta().x)/(GetRectSize().x - 2*sfDEFAULT_ME_OFFSET); ShapeList m_lstSelection; GetParentCanvas()->GetSelectedShapes(m_lstSelection); ShapeList::compatibility_iterator node = m_lstSelection.GetFirst(); while(node) { wxSFShapeBase* pShape = node->GetData(); // scale main parent shape if(!pShape->IsKindOf(CLASSINFO(wxSFLineShape))) { dx = (pShape->GetAbsolutePosition().x - (GetAbsolutePosition().x + sfDEFAULT_ME_OFFSET))/(GetRectSize().x - 2*sfDEFAULT_ME_OFFSET)*handle.GetDelta().x; if(pShape->ContainsStyle(sfsSIZE_CHANGE))pShape->Scale(sx, 1, sfWITHCHILDREN); if(pShape->ContainsStyle(sfsPOSITION_CHANGE))pShape->MoveBy(dx, 0); if( ! pShape->ContainsStyle( sfsNO_FIT_TO_CHILDREN ) ) pShape->FitToChildren(); } else { if(pShape->ContainsStyle(sfsPOSITION_CHANGE)) { pLine = (wxSFLineShape*)pShape; ptnode = pLine->GetControlPoints().GetFirst(); while(ptnode) { pt = ptnode->GetData(); dx = ( pt->x - (GetAbsolutePosition().x + sfDEFAULT_ME_OFFSET))/(GetRectSize().x - 2*sfDEFAULT_ME_OFFSET)*handle.GetDelta().x; pt->x += dx; pt->x = floor(pt->x); ptnode = ptnode->GetNext(); } } } node = node->GetNext(); } } }
void uddTableItemElement::OnEndDrag(const wxPoint& pos) { uddPageElement* pageElement = wxDynamicCast( GetGrandParentShape(), uddPageElement ); wxPoint minPage = pageElement->GetAcceptableRangeMin(); wxPoint maxPage = pageElement->GetAcceptableRangeMax(); wxPoint minImage( GetAbsolutePosition().x, GetAbsolutePosition().y ); wxPoint maxImage( minImage.x + GetRectSize().x, minImage.y + GetRectSize().y ); if( minImage.x < minPage.x || minImage.y < minPage.y || maxImage.x > maxPage.x || maxImage.y > maxPage.y ) { wxMessageBox( wxT("Position out of acceptable range!") ); SetRelativePosition( m_previousAbsolutePosition ); } }
int CResizer::GetCoordinate(ESize eType, const RECT &rcInitial, const CBorder &border, const RECT &rc) const{ int nOld = GetRectCoord(eType, rcInitial); switch(border.eType){ case eFixed: { //Get initial relative window position RECT rcNew; GetInitialDlgItemRect(border.nRelID, rcNew); int nRelOld = GetRectCoord(border.eRelType, rcNew); //Get current relative window position int nRelNew = GetRelativeCoord(border); //Compute and return new position return nOld - nRelOld + nRelNew; } case eProportional: { //Get initial relative window position RECT rcOld; GetInitialDlgItemRect(border.nRelID, rcOld); int nOldSize = GetRectSize(eType, rcOld); int nOldBase = GetRectCoord(border.eRelType, rcOld); //Get current relative window position RECT rcNew; GetCachedDlgItemRect(border.nRelID, rcNew); int nNewSize = GetRectSize(eType, rcNew); int nNewBase = GetRectCoord(border.eRelType, rcNew); //Compute and return new position return nNewBase + (nOld - nOldBase)*nNewSize/(nOldSize <= 0 ? 1 : nOldSize); } case eWidth: { return rc.left + rcInitial.right - rcInitial.left; } case eHeight: { return rc.top + rcInitial.bottom - rcInitial.top; } } _ASSERTE(FALSE); //Wrong relation type is specified. Use items from EBorder enum. return 0; }