// **************************************************************************** // // Function Name: REditImageInterfaceImp::GetClippingPath( ) // // Description: Returns the component image's clipping path // (if any). // // Returns: // // Exceptions: // // **************************************************************************** // BOOLEAN REditImageInterfaceImp::GetClippingPath( RClippingPath& rPath ) { // Get a pointer to the image document's image. Note, // normally we can assume that it is a RBitmapImage // as this interface is only provided by image components, // but if this is a placeholder from a layout there is no // RBitmapImage so just return FALSE in that case. RBitmapImage* pImage = dynamic_cast<RBitmapImage*>( m_pImageDocument->GetImage() ); if (!pImage) return FALSE; rPath.Undefine(); RClippingPath* pPath = pImage->GetClippingRPath(); if (pPath) { const RImageEffects& rEffects = GetImageEffects(); RRealSize rSize = RImageLibrary().GetImageDimensions( m_pImageDocument->m_rInternalDataBuffer ); R2dTransform xform; xform.PostScale( rSize.m_dx, rSize.m_dy ); RRealRect rRect( rEffects.m_rCropArea * xform ); xform.MakeIdentity(); xform.PostTranslate( rRect.m_Left, rSize.m_dy - rRect.m_Bottom - rRect.m_Top ); rPath = RClippingPath( *pPath, xform ); return TRUE; } return FALSE; }
void RWinColorPaletteWell::OnPaint( ) { CPaintDC dc( this ); CRect rect; GetClientRect( rect ); if (m_crColor.GetFillMethod() != RColor::kTransparent) { // The bounding rect is in logical units, so we // need to create a transform to scale from logical // units to device units. We also divide by 2 to // account for the scaling in the bounding rect to // make the texture more visible in such a small area. RRealSize dpi( ::GetScreenDPI() ); R2dTransform transform; transform.PostScale( dpi.m_dx / kSystemDPI * 0.5, dpi.m_dy / kSystemDPI * 0.5 ); RColor crFillColor = m_crColor; crFillColor *= transform; RIntRect rRect( rect ); RDcDrawingSurface ds; ds.Initialize( (HDC) dc ); RColor oldColor = ds.GetFillColor(); ds.SetFillColor( crFillColor ); ds.FillRectangle( rRect ); ds.SetFillColor( oldColor ); ds.DetachDCs(); } else { dc.FillSolidRect( rect, RGB( 255, 255, 255 ) ); CString strText ; GetWindowText( strText ); CRect rcTextRect( rect ); rcTextRect.DeflateRect( 1, 1 ); CFont* pFont = dc.SelectObject( GetParent()->GetFont() ); dc.DrawText( strText, rcTextRect, DT_CENTER | DT_VCENTER ); dc.SelectObject( pFont ); } dc.MoveTo( rect.left, rect.bottom - 1 ); dc.LineTo( rect.left, rect.top ); dc.LineTo( rect.right, rect.top ); }
void RWinColorPaletteWell::SetColor( RColor& crColor ) { if (crColor != m_crColor) { m_crColor = crColor; CRect rect; GetClientRect( rect ); RIntRect rRect( rect ); // By making the bounding rect // twice as large, we will make // textures more visible. R2dTransform transform; transform.PostScale( 2, 2 ); rRect *= transform; ::ScreenUnitsToLogicalUnits( rRect ); m_crColor.SetBoundingRect( rRect ); if (m_hWnd) Invalidate( FALSE ); } }