void RRotateDialog::DeriveSourceAndDestinationRects( const RIntSize& sizeBmpRotated, RIntRect& rectSource, RIntRect& rectDest ) { rectSource.m_Left = 0; rectSource.m_Top = 0; rectSource.m_Right = sizeBmpRotated.m_dx; rectSource.m_Bottom = sizeBmpRotated.m_dy; RIntPoint ptSourceCenter; ptSourceCenter.m_x = sizeBmpRotated.m_dx / 2; ptSourceCenter.m_y = sizeBmpRotated.m_dy / 2; rectDest = rectSource; YFloatType flHorzCropFactor = 1.F; YFloatType flVertCropFactor = 1.F; if ( sizeBmpRotated.m_dx > m_rSizeStaticDisplay.m_dx ) { flHorzCropFactor = 1.F - YFloatType( sizeBmpRotated.m_dx - m_rSizeStaticDisplay.m_dx ) / YFloatType( sizeBmpRotated.m_dx ); rectDest.m_Right = YIntCoordinate( YFloatType( rectDest.m_Right ) * flHorzCropFactor ); } if ( sizeBmpRotated.m_dy > m_rSizeStaticDisplay.m_dy ) { flVertCropFactor = 1.F - YFloatType( sizeBmpRotated.m_dy - m_rSizeStaticDisplay.m_dy ) / YFloatType( sizeBmpRotated.m_dy ); rectDest.m_Bottom = YIntCoordinate( YFloatType( rectDest.m_Bottom ) * flVertCropFactor ); } rectDest.Offset( RIntSize( m_rPtStaticCenter.m_x - YIntCoordinate( YFloatType( rectDest.Width() ) / 2.F ), m_rPtStaticCenter.m_y - YIntCoordinate( YFloatType( rectDest.Height() ) / 2.F ) ) ); if ( flHorzCropFactor < 1.F ) { YIntDimension iHorzSrcCropDistance = YIntDimension( ( 1.F - flHorzCropFactor ) * YFloatType( rectSource.m_Right ) / 2.F ); rectSource.m_Left += iHorzSrcCropDistance; rectSource.m_Right -= iHorzSrcCropDistance; } if ( flVertCropFactor < 1.F ) { YIntDimension iVertSrcCropDistance = YIntDimension( ( 1.F - flVertCropFactor ) * YFloatType( rectSource.m_Bottom ) / 2.F ); rectSource.m_Top += iVertSrcCropDistance; rectSource.m_Bottom -= iVertSrcCropDistance; } }
// **************************************************************************** // // Function Name: RSingleSelection::GetResizeSelectionHandle( ) // // Description: Retrieves a vector rect representing requested resize handle. // // Returns: Nothing // // Exceptions: Memory // // **************************************************************************** // void RSingleSelection::GetResizeSelectionHandle( RRealRect& rHandle, const R2dTransform& transform, EHitLocation eHit, BOOLEAN fRender ) const { RRealPoint point; YSelectionBoundingRect boundingRect; RIntSize outsetSize = (fRender)? RRealSize( kCornerResizeHandleRenderSize, kCornerResizeHandleRenderSize ) : RRealSize( kResizeHandleHitSize, kResizeHandleHitSize ); // Get the bounding rectangle GetSelectionBoundingRect( boundingRect ); // Get the proper point to transform switch ( eHit ) { case kLeftResizeHandle: ::midpoint( point, boundingRect.m_TopLeft, boundingRect.m_BottomLeft ); outsetSize.m_dx = Max( kEdgeResizeHandleRenderSize, YIntDimension(outsetSize.m_dx/2) ); break; case kTopResizeHandle: ::midpoint( point, boundingRect.m_TopLeft, boundingRect.m_TopRight ); outsetSize.m_dy = Max( kEdgeResizeHandleRenderSize, YIntDimension(outsetSize.m_dy/2) ); break; case kRightResizeHandle: ::midpoint( point, boundingRect.m_TopRight, boundingRect.m_BottomRight ); outsetSize.m_dx = Max( kEdgeResizeHandleRenderSize, YIntDimension(outsetSize.m_dx/2) ); break; case kBottomResizeHandle: ::midpoint( point, boundingRect.m_BottomLeft, boundingRect.m_BottomRight ); outsetSize.m_dy = Max( kEdgeResizeHandleRenderSize, YIntDimension(outsetSize.m_dy/2) ); break; case kTopLeftResizeHandle: point = boundingRect.m_TopLeft; break; case kTopRightResizeHandle: point = boundingRect.m_TopRight; break; case kBottomLeftResizeHandle: point = boundingRect.m_BottomLeft; break; case kBottomRightResizeHandle: point = boundingRect.m_BottomRight; break; default : TpsAssertAlways( "Asking for the selection handle of invalid type" ); point = boundingRect.GetCenterPoint(); } RIntSize halfOutset( outsetSize.m_dx/2, outsetSize.m_dy/2); ::LogicalUnitsToDeviceUnits( point, *m_pView ); rHandle.m_Left = point.m_x - halfOutset.m_dx; rHandle.m_Top = point.m_y - halfOutset.m_dy; rHandle.m_Right = point.m_x + outsetSize.m_dx - halfOutset.m_dx; rHandle.m_Bottom = point.m_y + outsetSize.m_dy - halfOutset.m_dy; ::DeviceUnitsToLogicalUnits( rHandle, *m_pView ); rHandle *= transform; }